Diff
Modified: trunk/Source/WebCore/ChangeLog (269227 => 269228)
--- trunk/Source/WebCore/ChangeLog 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/ChangeLog 2020-10-31 19:06:24 UTC (rev 269228)
@@ -1,3 +1,93 @@
+2020-10-31 Simon Fraser <[email protected]>
+
+ Clean up BoxSide and BorderEdge code
+ https://bugs.webkit.org/show_bug.cgi?id=218197
+
+ Reviewed by Sam Weinig.
+
+ Change border-drawing functions in RenderBoxModelObject which took BorderEdge[] to
+ use RectEdges<BorderEdge>. In addition, make BoxSide an enum class, and remove the redundant
+ PhysicalBoxSide. Also make BorderEdgeFlags an OptionSet<>.
+
+ I renamed PhysicalBoxSide to BoxSide because "physical" is a loaded term (it could mean
+ either locally top/right/bottom/left, or refer to absolute "physical coordinates").
+ This allowed BoxSide to be used in RectEdges, therefore making RectEdges<BorderEdge>
+ the right way to represent the set of edges for a box.
+
+ An equivalent set of bit flags, BoxSideFlag, allows use in an OptionSet<>.
+
+ Use more enumeration of sides in the border painting code.
+
+ * page/IntersectionObserver.cpp:
+ (WebCore::IntersectionObserver::rootMargin const):
+ * platform/RectEdges.h:
+ (WebCore::RectEdges::at):
+ (WebCore::RectEdges::top):
+ (WebCore::RectEdges::right):
+ (WebCore::RectEdges::bottom):
+ (WebCore::RectEdges::left):
+ (WebCore::RectEdges::at const):
+ (WebCore::RectEdges::top const):
+ (WebCore::RectEdges::right const):
+ (WebCore::RectEdges::bottom const):
+ (WebCore::RectEdges::left const):
+ (WebCore::RectEdges::setAt):
+ (WebCore::RectEdges::setTop):
+ (WebCore::RectEdges::setRight):
+ (WebCore::RectEdges::setBottom):
+ (WebCore::RectEdges::setLeft):
+ * platform/text/WritingMode.h:
+ (WebCore::isHorizontalPhysicalSide):
+ (WebCore::mirrorPhysicalSide):
+ (WebCore::rotatePhysicalSide):
+ (WebCore::mapLogicalSideToPhysicalSide):
+ * rendering/BorderEdge.cpp:
+ (WebCore::borderEdges):
+ (WebCore::BorderEdge::getBorderEdgeInfo): Deleted.
+ * rendering/BorderEdge.h:
+ (WebCore::edgeFlagForSide):
+ (WebCore::includesEdge):
+ (WebCore::includesAdjacentEdges):
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::borderWillArcInnerEdge):
+ (WebCore::borderStyleHasUnmatchedColorsAtCorner):
+ (WebCore::colorsMatchAtCorner):
+ (WebCore::colorNeedsAntiAliasAtCorner):
+ (WebCore::willBeOverdrawn):
+ (WebCore::joinRequiresMitre):
+ (WebCore::calculateAdjustedInnerBorder):
+ (WebCore::RenderBoxModelObject::paintOneBorderSide):
+ (WebCore::calculateSideRect):
+ (WebCore::RenderBoxModelObject::paintBorderSides):
+ (WebCore::RenderBoxModelObject::paintTranslucentBorderSides):
+ (WebCore::RenderBoxModelObject::paintBorder):
+ (WebCore::RenderBoxModelObject::drawBoxSideFromPath):
+ (WebCore::RenderBoxModelObject::clipBorderSidePolygon):
+ (WebCore::RenderBoxModelObject::borderObscuresBackgroundEdge const):
+ (WebCore::RenderBoxModelObject::borderObscuresBackground const):
+ * rendering/RenderBoxModelObject.h:
+ * rendering/RenderElement.cpp:
+ (WebCore::RenderElement::drawLineForBoxSide const):
+ (WebCore::RenderElement::paintOutline):
+ * rendering/RenderInline.cpp:
+ (WebCore::RenderInline::paintOutlineForLine):
+ * rendering/RenderMultiColumnSet.cpp:
+ (WebCore::RenderMultiColumnSet::paintColumnRules):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::calculateBorderStyleColor):
+ * rendering/RenderObjectEnums.h:
+ * rendering/RenderTableCell.cpp:
+ (WebCore::RenderTableCell::paintCollapsedBorders):
+ * rendering/RenderTableSection.cpp:
+ (WebCore::RenderTableSection::offsetTopForRowGroupBorder):
+ (WebCore::RenderTableSection::paintRowGroupBorderIfRequired):
+ (WebCore::physicalBorderForDirection):
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::RenderThemeIOS::paintMenuListButtonDecorations):
+ * rendering/style/NinePieceImage.h:
+ (WebCore::imagePieceHorizontalSide):
+ (WebCore::imagePieceVerticalSide):
+
2020-10-31 Chris Dumez <[email protected]>
Promises returned by our DOM API have the caller's global instead of the callee's
Modified: trunk/Source/WebCore/page/IntersectionObserver.cpp (269227 => 269228)
--- trunk/Source/WebCore/page/IntersectionObserver.cpp 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/page/IntersectionObserver.cpp 2020-10-31 19:06:24 UTC (rev 269228)
@@ -150,8 +150,7 @@
String IntersectionObserver::rootMargin() const
{
StringBuilder stringBuilder;
- PhysicalBoxSide sides[4] = { PhysicalBoxSide::Top, PhysicalBoxSide::Right, PhysicalBoxSide::Bottom, PhysicalBoxSide::Left };
- for (auto side : sides) {
+ for (auto side : allBoxSides) {
auto& length = m_rootMargin.at(side);
stringBuilder.appendNumber(length.intValue());
if (length.type() == Percent)
@@ -158,7 +157,7 @@
stringBuilder.append('%');
else
stringBuilder.appendLiteral("px");
- if (side != PhysicalBoxSide::Left)
+ if (side != BoxSide::Left)
stringBuilder.append(' ');
}
return stringBuilder.toString();
Modified: trunk/Source/WebCore/platform/RectEdges.h (269227 => 269228)
--- trunk/Source/WebCore/platform/RectEdges.h 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/platform/RectEdges.h 2020-10-31 19:06:24 UTC (rev 269228)
@@ -27,9 +27,19 @@
#include "WritingMode.h"
#include <array>
+#include <wtf/OptionSet.h>
namespace WebCore {
-
+
+enum class BoxSideFlag : uint8_t {
+ Top = 1 << static_cast<unsigned>(BoxSide::Top),
+ Right = 1 << static_cast<unsigned>(BoxSide::Right),
+ Bottom = 1 << static_cast<unsigned>(BoxSide::Bottom),
+ Left = 1 << static_cast<unsigned>(BoxSide::Left)
+};
+
+using BoxSideSet = OptionSet<BoxSideFlag>;
+
template<typename T> class RectEdges {
public:
RectEdges() = default;
@@ -38,45 +48,47 @@
RectEdges(U&& top, U&& right, U&& bottom, U&& left)
: m_sides({ { std::forward<T>(top), std::forward<T>(right), std::forward<T>(bottom), std::forward<T>(left) } })
{ }
-
- T& at(PhysicalBoxSide side) { return m_sides[static_cast<size_t>(side)]; }
- T& top() { return at(PhysicalBoxSide::Top); }
- T& right() { return at(PhysicalBoxSide::Right); }
- T& bottom() { return at(PhysicalBoxSide::Bottom); }
- T& left() { return at(PhysicalBoxSide::Left); }
-
- const T& at(PhysicalBoxSide side) const { return m_sides[static_cast<size_t>(side)]; }
- const T& top() const { return at(PhysicalBoxSide::Top); }
- const T& right() const { return at(PhysicalBoxSide::Right); }
- const T& bottom() const { return at(PhysicalBoxSide::Bottom); }
- const T& left() const { return at(PhysicalBoxSide::Left); }
-
- void setAt(PhysicalBoxSide side, const T& v) { at(side) = v; }
- void setTop(const T& top) { setAt(PhysicalBoxSide::Top, top); }
- void setRight(const T& right) { setAt(PhysicalBoxSide::Right, right); }
- void setBottom(const T& bottom) { setAt(PhysicalBoxSide::Bottom, bottom); }
- void setLeft(const T& left) { setAt(PhysicalBoxSide::Left, left); }
-
+
+ T& at(BoxSide side) { return m_sides[static_cast<size_t>(side)]; }
+ T& operator[](BoxSide side) { return m_sides[static_cast<size_t>(side)]; }
+ T& top() { return at(BoxSide::Top); }
+ T& right() { return at(BoxSide::Right); }
+ T& bottom() { return at(BoxSide::Bottom); }
+ T& left() { return at(BoxSide::Left); }
+
+ const T& at(BoxSide side) const { return m_sides[static_cast<size_t>(side)]; }
+ const T& operator[](BoxSide side) const { return m_sides[static_cast<size_t>(side)]; }
+ const T& top() const { return at(BoxSide::Top); }
+ const T& right() const { return at(BoxSide::Right); }
+ const T& bottom() const { return at(BoxSide::Bottom); }
+ const T& left() const { return at(BoxSide::Left); }
+
+ void setAt(BoxSide side, const T& v) { at(side) = v; }
+ void setTop(const T& top) { setAt(BoxSide::Top, top); }
+ void setRight(const T& right) { setAt(BoxSide::Right, right); }
+ void setBottom(const T& bottom) { setAt(BoxSide::Bottom, bottom); }
+ void setLeft(const T& left) { setAt(BoxSide::Left, left); }
+
T& before(WritingMode writingMode) { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::Before)); }
T& after(WritingMode writingMode) { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::After)); }
T& start(WritingMode writingMode, TextDirection direction = TextDirection::LTR) { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::Start)); }
T& end(WritingMode writingMode, TextDirection direction = TextDirection::LTR) { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::End)); }
-
+
const T& before(WritingMode writingMode) const { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::Before)); }
const T& after(WritingMode writingMode) const { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::After)); }
const T& start(WritingMode writingMode, TextDirection direction = TextDirection::LTR) const { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::Start)); }
const T& end(WritingMode writingMode, TextDirection direction = TextDirection::LTR) const { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::End)); }
-
+
void setBefore(const T& before, WritingMode writingMode) { this->before(writingMode) = before; }
void setAfter(const T& after, WritingMode writingMode) { this->after(writingMode) = after; }
void setStart(const T& start, WritingMode writingMode, TextDirection direction = TextDirection::LTR) { this->start(writingMode, direction) = start; }
void setEnd(const T& end, WritingMode writingMode, TextDirection direction = TextDirection::LTR) { this->end(writingMode, direction) = end; }
-
+
bool operator==(const RectEdges& other) const { return m_sides == other.m_sides; }
bool operator!=(const RectEdges& other) const { return m_sides != other.m_sides; }
private:
- std::array<T, 4> m_sides {{0, 0, 0, 0}};
+ std::array<T, 4> m_sides { };
};
}
Modified: trunk/Source/WebCore/platform/text/WritingMode.h (269227 => 269228)
--- trunk/Source/WebCore/platform/text/WritingMode.h 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/platform/text/WritingMode.h 2020-10-31 19:06:24 UTC (rev 269228)
@@ -31,6 +31,7 @@
#pragma once
+#include <array>
#include <wtf/EnumTraits.h>
namespace WebCore {
@@ -121,7 +122,7 @@
Start
};
-enum class PhysicalBoxSide : uint8_t {
+enum class BoxSide : uint8_t {
Top,
Right,
Bottom,
@@ -128,27 +129,29 @@
Left
};
-inline bool isHorizontalPhysicalSide(PhysicalBoxSide physicalSide)
+constexpr std::array<BoxSide, 4> allBoxSides = { BoxSide::Top, BoxSide::Right, BoxSide::Bottom, BoxSide::Left };
+
+inline bool isHorizontalPhysicalSide(BoxSide physicalSide)
{
- return physicalSide == PhysicalBoxSide::Left || physicalSide == PhysicalBoxSide::Right;
+ return physicalSide == BoxSide::Left || physicalSide == BoxSide::Right;
}
-inline PhysicalBoxSide mirrorPhysicalSide(PhysicalBoxSide physicalSide)
+inline BoxSide mirrorPhysicalSide(BoxSide physicalSide)
{
// top <-> bottom and left <-> right conversion
- return static_cast<PhysicalBoxSide>((static_cast<int>(physicalSide) + 2) % 4);
+ return static_cast<BoxSide>((static_cast<int>(physicalSide) + 2) % 4);
}
-inline PhysicalBoxSide rotatePhysicalSide(PhysicalBoxSide physicalSide)
+inline BoxSide rotatePhysicalSide(BoxSide physicalSide)
{
// top <-> left and right <-> bottom conversion
bool horizontalSide = isHorizontalPhysicalSide(physicalSide);
- return static_cast<PhysicalBoxSide>((static_cast<int>(physicalSide) + (horizontalSide ? 1 : 3)) % 4);
+ return static_cast<BoxSide>((static_cast<int>(physicalSide) + (horizontalSide ? 1 : 3)) % 4);
}
-inline PhysicalBoxSide mapLogicalSideToPhysicalSide(TextFlow textflow, LogicalBoxSide logicalSide)
+inline BoxSide mapLogicalSideToPhysicalSide(TextFlow textflow, LogicalBoxSide logicalSide)
{
- PhysicalBoxSide physicalSide = static_cast<PhysicalBoxSide>(logicalSide);
+ BoxSide physicalSide = static_cast<BoxSide>(logicalSide);
bool horizontalSide = isHorizontalPhysicalSide(physicalSide);
if (isVerticalTextFlow(textflow))
@@ -160,7 +163,7 @@
return physicalSide;
}
-inline PhysicalBoxSide mapLogicalSideToPhysicalSide(WritingMode writingMode, LogicalBoxSide logicalSide)
+inline BoxSide mapLogicalSideToPhysicalSide(WritingMode writingMode, LogicalBoxSide logicalSide)
{
// Set the direction such that side is mirrored if isFlippedWritingMode() is true
TextDirection direction = isFlippedWritingMode(writingMode) ? TextDirection::RTL : TextDirection::LTR;
Modified: trunk/Source/WebCore/rendering/BorderEdge.cpp (269227 => 269228)
--- trunk/Source/WebCore/rendering/BorderEdge.cpp 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/BorderEdge.cpp 2020-10-31 19:06:24 UTC (rev 269228)
@@ -46,20 +46,22 @@
m_flooredToDevicePixelWidth = floorf(edgeWidth * devicePixelRatio) / devicePixelRatio;
}
-void BorderEdge::getBorderEdgeInfo(BorderEdge edges[], const RenderStyle& style, float deviceScaleFactor, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
+BorderEdges borderEdges(const RenderStyle& style, float deviceScaleFactor, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
{
bool horizontal = style.isHorizontalWritingMode();
- edges[BSTop] = BorderEdge(style.borderTopWidth(), style.visitedDependentColorWithColorFilter(CSSPropertyBorderTopColor), style.borderTopStyle(), style.borderTopIsTransparent(),
- horizontal || includeLogicalLeftEdge, deviceScaleFactor);
- edges[BSRight] = BorderEdge(style.borderRightWidth(), style.visitedDependentColorWithColorFilter(CSSPropertyBorderRightColor), style.borderRightStyle(), style.borderRightIsTransparent(),
- !horizontal || includeLogicalRightEdge, deviceScaleFactor);
- edges[BSBottom] = BorderEdge(style.borderBottomWidth(), style.visitedDependentColorWithColorFilter(CSSPropertyBorderBottomColor), style.borderBottomStyle(), style.borderBottomIsTransparent(),
- horizontal || includeLogicalRightEdge, deviceScaleFactor);
- edges[BSLeft] = BorderEdge(style.borderLeftWidth(), style.visitedDependentColorWithColorFilter(CSSPropertyBorderLeftColor), style.borderLeftStyle(), style.borderLeftIsTransparent(),
- !horizontal || includeLogicalLeftEdge, deviceScaleFactor);
- }
+ auto constructBorderEdge = [&](float width, CSSPropertyID borderColorProperty, BorderStyle borderStyle, bool isTransparent, bool isPresent) {
+ return BorderEdge(width, style.visitedDependentColorWithColorFilter(borderColorProperty), borderStyle, isTransparent, isPresent, deviceScaleFactor);
+ };
+ return {
+ constructBorderEdge(style.borderTopWidth(), CSSPropertyBorderTopColor, style.borderTopStyle(), style.borderTopIsTransparent(), horizontal || includeLogicalLeftEdge),
+ constructBorderEdge(style.borderRightWidth(), CSSPropertyBorderRightColor, style.borderRightStyle(), style.borderRightIsTransparent(), !horizontal || includeLogicalRightEdge),
+ constructBorderEdge(style.borderBottomWidth(), CSSPropertyBorderBottomColor, style.borderBottomStyle(), style.borderBottomIsTransparent(), horizontal || includeLogicalRightEdge),
+ constructBorderEdge(style.borderLeftWidth(), CSSPropertyBorderLeftColor, style.borderLeftStyle(), style.borderLeftIsTransparent(), !horizontal || includeLogicalLeftEdge)
+ };
+}
+
bool BorderEdge::obscuresBackgroundEdge(float scale) const
{
if (!m_isPresent || m_isTransparent || (m_width * scale) < borderWidthInDevicePixel(2) || !m_color.isOpaque() || m_style == BorderStyle::Hidden)
Modified: trunk/Source/WebCore/rendering/BorderEdge.h (269227 => 269228)
--- trunk/Source/WebCore/rendering/BorderEdge.h 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/BorderEdge.h 2020-10-31 19:06:24 UTC (rev 269228)
@@ -27,30 +27,20 @@
#include "Color.h"
#include "LayoutUnit.h"
+#include "RectEdges.h"
#include "RenderObjectEnums.h"
#include "RenderStyleConstants.h"
+#include <wtf/OptionSet.h>
namespace WebCore {
-typedef unsigned BorderEdgeFlags;
-
class RenderStyle;
class BorderEdge {
public:
- enum BorderEdgeFlag {
- TopBorderEdge = 1 << BSTop,
- RightBorderEdge = 1 << BSRight,
- BottomBorderEdge = 1 << BSBottom,
- LeftBorderEdge = 1 << BSLeft,
- AllBorderEdges = TopBorderEdge | BottomBorderEdge | LeftBorderEdge | RightBorderEdge
- };
-
BorderEdge() = default;
BorderEdge(float edgeWidth, Color edgeColor, BorderStyle edgeStyle, bool edgeIsTransparent, bool edgeIsPresent, float devicePixelRatio);
- static void getBorderEdgeInfo(BorderEdge edges[], const RenderStyle&, float deviceScaleFactor, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
-
BorderStyle style() const { return m_style; }
const Color& color() const { return m_color; }
bool isTransparent() const { return m_isTransparent; }
@@ -76,15 +66,19 @@
bool m_isPresent { false };
};
+using BorderEdges = RectEdges<BorderEdge>;
+BorderEdges borderEdges(const RenderStyle&, float deviceScaleFactor, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
+
inline bool edgesShareColor(const BorderEdge& firstEdge, const BorderEdge& secondEdge) { return firstEdge.color() == secondEdge.color(); }
-inline BorderEdge::BorderEdgeFlag edgeFlagForSide(BoxSide side) { return static_cast<BorderEdge::BorderEdgeFlag>(1 << side); }
-inline bool includesEdge(BorderEdgeFlags flags, BoxSide side) { return flags & edgeFlagForSide(side); }
-inline bool includesAdjacentEdges(BorderEdgeFlags flags)
+inline BoxSideFlag edgeFlagForSide(BoxSide side) { return static_cast<BoxSideFlag>(1 << static_cast<unsigned>(side)); }
+inline bool includesEdge(OptionSet<BoxSideFlag> flags, BoxSide side) { return flags.contains(edgeFlagForSide(side)); }
+
+inline bool includesAdjacentEdges(OptionSet<BoxSideFlag> flags)
{
- return (flags & (BorderEdge::TopBorderEdge | BorderEdge::RightBorderEdge)) == (BorderEdge::TopBorderEdge | BorderEdge::RightBorderEdge)
- || (flags & (BorderEdge::RightBorderEdge | BorderEdge::BottomBorderEdge)) == (BorderEdge::RightBorderEdge | BorderEdge::BottomBorderEdge)
- || (flags & (BorderEdge::BottomBorderEdge | BorderEdge::LeftBorderEdge)) == (BorderEdge::BottomBorderEdge | BorderEdge::LeftBorderEdge)
- || (flags & (BorderEdge::LeftBorderEdge | BorderEdge::TopBorderEdge)) == (BorderEdge::LeftBorderEdge | BorderEdge::TopBorderEdge);
+ return flags.containsAll({ BoxSideFlag::Top, BoxSideFlag::Right })
+ || flags.containsAll({ BoxSideFlag::Right, BoxSideFlag::Bottom })
+ || flags.containsAll({ BoxSideFlag::Bottom, BoxSideFlag::Left })
+ || flags.containsAll({ BoxSideFlag::Left, BoxSideFlag::Top });
}
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (269227 => 269228)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2020-10-31 19:06:24 UTC (rev 269228)
@@ -1455,7 +1455,7 @@
return true;
}
-static bool borderWillArcInnerEdge(const LayoutSize& firstRadius, const FloatSize& secondRadius)
+static bool borderWillArcInnerEdge(const LayoutSize& firstRadius, const LayoutSize& secondRadius)
{
return !firstRadius.isZero() || !secondRadius.isZero();
}
@@ -1486,60 +1486,69 @@
{
// These styles match at the top/left and bottom/right.
if (style == BorderStyle::Inset || style == BorderStyle::Groove || style == BorderStyle::Ridge || style == BorderStyle::Outset) {
- const BorderEdgeFlags topRightFlags = edgeFlagForSide(BSTop) | edgeFlagForSide(BSRight);
- const BorderEdgeFlags bottomLeftFlags = edgeFlagForSide(BSBottom) | edgeFlagForSide(BSLeft);
+ BoxSideSet topRightSides = { BoxSideFlag::Top, BoxSideFlag::Right };
+ BoxSideSet bottomLeftSides = { BoxSideFlag::Bottom, BoxSideFlag::Left };
- BorderEdgeFlags flags = edgeFlagForSide(side) | edgeFlagForSide(adjacentSide);
- return flags == topRightFlags || flags == bottomLeftFlags;
+ BoxSideSet usedSides { edgeFlagForSide(side), edgeFlagForSide(adjacentSide) };
+ return usedSides == topRightSides || usedSides == bottomLeftSides;
}
return false;
}
-static inline bool colorsMatchAtCorner(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[])
+static inline bool colorsMatchAtCorner(BoxSide side, BoxSide adjacentSide, const BorderEdges& edges)
{
- if (edges[side].shouldRender() != edges[adjacentSide].shouldRender())
+ auto& edge = edges.at(side);
+ auto& adjacentEdge = edges.at(adjacentSide);
+
+ if (edge.shouldRender() != adjacentEdge.shouldRender())
return false;
- if (!edgesShareColor(edges[side], edges[adjacentSide]))
+ if (!edgesShareColor(edge, adjacentEdge))
return false;
- return !borderStyleHasUnmatchedColorsAtCorner(edges[side].style(), side, adjacentSide);
+ return !borderStyleHasUnmatchedColorsAtCorner(edge.style(), side, adjacentSide);
}
-static inline bool colorNeedsAntiAliasAtCorner(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[])
+static inline bool colorNeedsAntiAliasAtCorner(BoxSide side, BoxSide adjacentSide, const BorderEdges& edges)
{
- if (edges[side].color().isOpaque())
+ auto& edge = edges.at(side);
+ auto& adjacentEdge = edges.at(adjacentSide);
+
+ if (edge.color().isOpaque())
return false;
- if (edges[side].shouldRender() != edges[adjacentSide].shouldRender())
+ if (edge.shouldRender() != adjacentEdge.shouldRender())
return false;
- if (!edgesShareColor(edges[side], edges[adjacentSide]))
+ if (!edgesShareColor(edge, adjacentEdge))
return true;
- return borderStyleHasUnmatchedColorsAtCorner(edges[side].style(), side, adjacentSide);
+ return borderStyleHasUnmatchedColorsAtCorner(edge.style(), side, adjacentSide);
}
// This assumes that we draw in order: top, bottom, left, right.
-static inline bool willBeOverdrawn(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[])
+static inline bool willBeOverdrawn(BoxSide side, BoxSide adjacentSide, const BorderEdges& edges)
{
switch (side) {
- case BSTop:
- case BSBottom:
- if (edges[adjacentSide].presentButInvisible())
+ case BoxSide::Top:
+ case BoxSide::Bottom: {
+ auto& edge = edges.at(side);
+ auto& adjacentEdge = edges.at(adjacentSide);
+
+ if (adjacentEdge.presentButInvisible())
return false;
- if (!edgesShareColor(edges[side], edges[adjacentSide]) && !edges[adjacentSide].color().isOpaque())
+ if (!edgesShareColor(edge, adjacentEdge) && !adjacentEdge.color().isOpaque())
return false;
- if (!borderStyleFillsBorderArea(edges[adjacentSide].style()))
+ if (!borderStyleFillsBorderArea(adjacentEdge.style()))
return false;
return true;
-
- case BSLeft:
- case BSRight:
+ }
+ case BoxSide::Left:
+ case BoxSide::Right:
// These draw last, so are never overdrawn.
return false;
}
@@ -1560,18 +1569,21 @@
return borderStyleHasUnmatchedColorsAtCorner(style, side, adjacentSide);
}
-static bool joinRequiresMitre(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[], bool allowOverdraw)
+static bool joinRequiresMitre(BoxSide side, BoxSide adjacentSide, const BorderEdges& edges, bool allowOverdraw)
{
- if ((edges[side].isTransparent() && edges[adjacentSide].isTransparent()) || !edges[adjacentSide].isPresent())
+ auto& edge = edges.at(side);
+ auto& adjacentEdge = edges.at(adjacentSide);
+
+ if ((edge.isTransparent() && adjacentEdge.isTransparent()) || !adjacentEdge.isPresent())
return false;
if (allowOverdraw && willBeOverdrawn(side, adjacentSide, edges))
return false;
- if (!edgesShareColor(edges[side], edges[adjacentSide]))
+ if (!edgesShareColor(edge, adjacentEdge))
return true;
- if (borderStylesRequireMitre(side, adjacentSide, edges[side].style(), edges[adjacentSide].style()))
+ if (borderStylesRequireMitre(side, adjacentSide, edge.style(), adjacentEdge.style()))
return true;
return false;
@@ -1589,7 +1601,7 @@
float maxRadii;
switch (side) {
- case BSTop:
+ case BoxSide::Top:
overshoot = newRadii.topLeft().width() + newRadii.topRight().width() - newRect.width();
if (overshoot > 0) {
ASSERT(!(newRadii.topLeft().width() && newRadii.topRight().width()));
@@ -1597,14 +1609,14 @@
if (!newRadii.topLeft().width())
newRect.move(-overshoot, 0);
}
- newRadii.setBottomLeft(IntSize(0, 0));
- newRadii.setBottomRight(IntSize(0, 0));
+ newRadii.setBottomLeft({ });
+ newRadii.setBottomRight({ });
maxRadii = std::max(newRadii.topLeft().height(), newRadii.topRight().height());
if (maxRadii > newRect.height())
newRect.setHeight(maxRadii);
break;
- case BSBottom:
+ case BoxSide::Bottom:
overshoot = newRadii.bottomLeft().width() + newRadii.bottomRight().width() - newRect.width();
if (overshoot > 0) {
ASSERT(!(newRadii.bottomLeft().width() && newRadii.bottomRight().width()));
@@ -1612,8 +1624,8 @@
if (!newRadii.bottomLeft().width())
newRect.move(-overshoot, 0);
}
- newRadii.setTopLeft(IntSize(0, 0));
- newRadii.setTopRight(IntSize(0, 0));
+ newRadii.setTopLeft({ });
+ newRadii.setTopRight({ });
maxRadii = std::max(newRadii.bottomLeft().height(), newRadii.bottomRight().height());
if (maxRadii > newRect.height()) {
newRect.move(0, newRect.height() - maxRadii);
@@ -1621,7 +1633,7 @@
}
break;
- case BSLeft:
+ case BoxSide::Left:
overshoot = newRadii.topLeft().height() + newRadii.bottomLeft().height() - newRect.height();
if (overshoot > 0) {
ASSERT(!(newRadii.topLeft().height() && newRadii.bottomLeft().height()));
@@ -1629,14 +1641,14 @@
if (!newRadii.topLeft().height())
newRect.move(0, -overshoot);
}
- newRadii.setTopRight(IntSize(0, 0));
- newRadii.setBottomRight(IntSize(0, 0));
+ newRadii.setTopRight({ });
+ newRadii.setBottomRight({ });
maxRadii = std::max(newRadii.topLeft().width(), newRadii.bottomLeft().width());
if (maxRadii > newRect.width())
newRect.setWidth(maxRadii);
break;
- case BSRight:
+ case BoxSide::Right:
overshoot = newRadii.topRight().height() + newRadii.bottomRight().height() - newRect.height();
if (overshoot > 0) {
ASSERT(!(newRadii.topRight().height() && newRadii.bottomRight().height()));
@@ -1644,8 +1656,8 @@
if (!newRadii.topRight().height())
newRect.move(0, -overshoot);
}
- newRadii.setTopLeft(IntSize(0, 0));
- newRadii.setBottomLeft(IntSize(0, 0));
+ newRadii.setTopLeft({ });
+ newRadii.setBottomLeft({ });
maxRadii = std::max(newRadii.topRight().width(), newRadii.bottomRight().width());
if (maxRadii > newRect.width()) {
newRect.move(newRect.width() - maxRadii, 0);
@@ -1658,13 +1670,13 @@
}
void RenderBoxModelObject::paintOneBorderSide(GraphicsContext& graphicsContext, const RenderStyle& style, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
- const LayoutRect& sideRect, BoxSide side, BoxSide adjacentSide1, BoxSide adjacentSide2, const BorderEdge edges[], const Path* path,
+ const LayoutRect& sideRect, BoxSide side, BoxSide adjacentSide1, BoxSide adjacentSide2, const BorderEdges& edges, const Path* path,
BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias, const Color* overrideColor)
{
- const BorderEdge& edgeToRender = edges[side];
+ auto& edgeToRender = edges.at(side);
ASSERT(edgeToRender.widthForPainting());
- const BorderEdge& adjacentEdge1 = edges[adjacentSide1];
- const BorderEdge& adjacentEdge2 = edges[adjacentSide2];
+ auto& adjacentEdge1 = edges.at(adjacentSide1);
+ auto& adjacentEdge2 = edges.at(adjacentSide2);
bool mitreAdjacentSide1 = joinRequiresMitre(side, adjacentSide1, edges, !antialias);
bool mitreAdjacentSide2 = joinRequiresMitre(side, adjacentSide2, edges, !antialias);
@@ -1704,25 +1716,31 @@
}
}
-static LayoutRect calculateSideRect(const RoundedRect& outerBorder, const BorderEdge edges[], int side)
+static LayoutRect calculateSideRect(const RoundedRect& outerBorder, const BorderEdges& edges, BoxSide side)
{
LayoutRect sideRect = outerBorder.rect();
- float width = edges[side].widthForPainting();
+ float width = edges.at(side).widthForPainting();
- if (side == BSTop)
+ switch (side) {
+ case BoxSide::Top:
sideRect.setHeight(width);
- else if (side == BSBottom)
+ break;
+ case BoxSide::Right:
+ sideRect.shiftXEdgeTo(sideRect.maxX() - width);
+ break;
+ case BoxSide::Bottom:
sideRect.shiftYEdgeTo(sideRect.maxY() - width);
- else if (side == BSLeft)
+ break;
+ case BoxSide::Left:
sideRect.setWidth(width);
- else
- sideRect.shiftXEdgeTo(sideRect.maxX() - width);
+ break;
+ }
return sideRect;
}
void RenderBoxModelObject::paintBorderSides(GraphicsContext& graphicsContext, const RenderStyle& style, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
- const IntPoint& innerBorderAdjustment, const BorderEdge edges[], BorderEdgeFlags edgeSet, BackgroundBleedAvoidance bleedAvoidance,
+ const IntPoint& innerBorderAdjustment, const BorderEdges& edges, BoxSideSet edgeSet, BackgroundBleedAvoidance bleedAvoidance,
bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias, const Color* overrideColor)
{
bool renderRadii = outerBorder.isRounded();
@@ -1736,65 +1754,74 @@
// is only to be used for solid borders and the shape of the border painted by drawBoxSideFromPath
// only depends on sideRect when painting solid borders.
- if (edges[BSTop].shouldRender() && includesEdge(edgeSet, BSTop)) {
- LayoutRect sideRect = outerBorder.rect();
- sideRect.setHeight(edges[BSTop].widthForPainting() + innerBorderAdjustment.y());
+ auto paintOneSide = [&](BoxSide side, BoxSide adjacentSide1, BoxSide adjacentSide2) {
+ auto& edge = edges.at(side);
+ if (!edge.shouldRender() || !edgeSet.contains(edgeFlagForSide(side)))
+ return;
- bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSTop].style()) || borderWillArcInnerEdge(innerBorder.radii().topLeft(), innerBorder.radii().topRight()));
- paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, BSTop, BSLeft, BSRight, edges, usePath ? &roundedPath : nullptr, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor);
- }
-
- if (edges[BSBottom].shouldRender() && includesEdge(edgeSet, BSBottom)) {
LayoutRect sideRect = outerBorder.rect();
- sideRect.shiftYEdgeTo(sideRect.maxY() - edges[BSBottom].widthForPainting() - innerBorderAdjustment.y());
+ LayoutSize firstRadius;
+ LayoutSize secondRadius;
- bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSBottom].style()) || borderWillArcInnerEdge(innerBorder.radii().bottomLeft(), innerBorder.radii().bottomRight()));
- paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, BSBottom, BSLeft, BSRight, edges, usePath ? &roundedPath : nullptr, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor);
- }
+ switch (side) {
+ case BoxSide::Top:
+ sideRect.setHeight(edge.widthForPainting() + innerBorderAdjustment.y());
+ firstRadius = innerBorder.radii().topLeft();
+ secondRadius = innerBorder.radii().topRight();
+ break;
+ case BoxSide::Right:
+ sideRect.shiftXEdgeTo(sideRect.maxX() - edge.widthForPainting() - innerBorderAdjustment.x());
+ firstRadius = innerBorder.radii().bottomRight();
+ secondRadius = innerBorder.radii().topRight();
+ break;
+ case BoxSide::Bottom:
+ sideRect.shiftYEdgeTo(sideRect.maxY() - edge.widthForPainting() - innerBorderAdjustment.y());
+ firstRadius = innerBorder.radii().bottomLeft();
+ secondRadius = innerBorder.radii().bottomRight();
+ break;
+ case BoxSide::Left:
+ sideRect.setWidth(edge.widthForPainting() + innerBorderAdjustment.x());
+ firstRadius = innerBorder.radii().bottomLeft();
+ secondRadius = innerBorder.radii().topLeft();
+ break;
+ }
- if (edges[BSLeft].shouldRender() && includesEdge(edgeSet, BSLeft)) {
- LayoutRect sideRect = outerBorder.rect();
- sideRect.setWidth(edges[BSLeft].widthForPainting() + innerBorderAdjustment.x());
+ bool usePath = renderRadii && (borderStyleHasInnerDetail(edge.style()) || borderWillArcInnerEdge(firstRadius, secondRadius));
+ paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, side, adjacentSide1, adjacentSide2, edges, usePath ? &roundedPath : nullptr, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor);
+ };
- bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSLeft].style()) || borderWillArcInnerEdge(innerBorder.radii().bottomLeft(), innerBorder.radii().topLeft()));
- paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, BSLeft, BSTop, BSBottom, edges, usePath ? &roundedPath : nullptr, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor);
- }
-
- if (edges[BSRight].shouldRender() && includesEdge(edgeSet, BSRight)) {
- LayoutRect sideRect = outerBorder.rect();
- sideRect.shiftXEdgeTo(sideRect.maxX() - edges[BSRight].widthForPainting() - innerBorderAdjustment.x());
-
- bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSRight].style()) || borderWillArcInnerEdge(innerBorder.radii().bottomRight(), innerBorder.radii().topRight()));
- paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, BSRight, BSTop, BSBottom, edges, usePath ? &roundedPath : nullptr, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor);
- }
+ paintOneSide(BoxSide::Top, BoxSide::Left, BoxSide::Right);
+ paintOneSide(BoxSide::Bottom, BoxSide::Left, BoxSide::Right);
+ paintOneSide(BoxSide::Left, BoxSide::Top, BoxSide::Bottom);
+ paintOneSide(BoxSide::Right, BoxSide::Top, BoxSide::Bottom);
}
void RenderBoxModelObject::paintTranslucentBorderSides(GraphicsContext& graphicsContext, const RenderStyle& style, const RoundedRect& outerBorder, const RoundedRect& innerBorder, const IntPoint& innerBorderAdjustment,
- const BorderEdge edges[], BorderEdgeFlags edgesToDraw, BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias)
+ const BorderEdges& edges, BoxSideSet edgesToDraw, BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias)
{
// willBeOverdrawn assumes that we draw in order: top, bottom, left, right.
// This is different from BoxSide enum order.
- static const BoxSide paintOrder[] = { BSTop, BSBottom, BSLeft, BSRight };
+ static constexpr std::array<BoxSide, 4> paintOrderSides = { BoxSide::Top, BoxSide::Bottom, BoxSide::Left, BoxSide::Right };
while (edgesToDraw) {
// Find undrawn edges sharing a color.
Color commonColor;
- BorderEdgeFlags commonColorEdgeSet = 0;
- for (size_t i = 0; i < sizeof(paintOrder) / sizeof(paintOrder[0]); ++i) {
- BoxSide currSide = paintOrder[i];
- if (!includesEdge(edgesToDraw, currSide))
+ BoxSideSet commonColorEdgeSet;
+ for (auto side : paintOrderSides) {
+ if (!edgesToDraw.contains(edgeFlagForSide(side)))
continue;
+ auto& edge = edges.at(side);
bool includeEdge;
- if (!commonColorEdgeSet) {
- commonColor = edges[currSide].color();
+ if (commonColorEdgeSet.isEmpty()) {
+ commonColor = edge.color();
includeEdge = true;
} else
- includeEdge = edges[currSide].color() == commonColor;
+ includeEdge = edge.color() == commonColor;
if (includeEdge)
- commonColorEdgeSet |= edgeFlagForSide(currSide);
+ commonColorEdgeSet.add(edgeFlagForSide(side));
}
bool useTransparencyLayer = includesAdjacentEdges(commonColorEdgeSet) && !commonColor.isOpaque();
@@ -1808,7 +1835,7 @@
if (useTransparencyLayer)
graphicsContext.endTransparencyLayer();
- edgesToDraw &= ~commonColorEdgeSet;
+ edgesToDraw.remove(commonColorEdgeSet);
}
}
@@ -1833,8 +1860,7 @@
if (paintNinePieceImage(graphicsContext, rect, style, style.borderImage()))
return;
- BorderEdge edges[4];
- BorderEdge::getBorderEdgeInfo(edges, style, document().deviceScaleFactor(), includeLogicalLeftEdge, includeLogicalRightEdge);
+ auto edges = borderEdges(style, document().deviceScaleFactor(), includeLogicalLeftEdge, includeLogicalRightEdge);
RoundedRect outerBorder = style.getRoundedBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge);
RoundedRect innerBorder = style.getRoundedInnerBorderFor(borderInnerRectAdjustedForBleedAvoidance(graphicsContext, rect, bleedAvoidance), includeLogicalLeftEdge, includeLogicalRightEdge);
@@ -1847,14 +1873,14 @@
bool haveAllDoubleEdges = true;
int numEdgesVisible = 4;
bool allEdgesShareColor = true;
- int firstVisibleEdge = -1;
- BorderEdgeFlags edgesToDraw = 0;
+ Optional<BoxSide> firstVisibleSide;
+ BoxSideSet edgesToDraw;
- for (int i = BSTop; i <= BSLeft; ++i) {
- const BorderEdge& currEdge = edges[i];
+ for (auto side : allBoxSides) {
+ auto& currEdge = edges.at(side);
- if (edges[i].shouldRender())
- edgesToDraw |= edgeFlagForSide(static_cast<BoxSide>(i));
+ if (currEdge.shouldRender())
+ edgesToDraw.add(edgeFlagForSide(side));
if (currEdge.presentButInvisible()) {
--numEdgesVisible;
@@ -1867,9 +1893,9 @@
continue;
}
- if (firstVisibleEdge == -1)
- firstVisibleEdge = i;
- else if (currEdge.color() != edges[firstVisibleEdge].color())
+ if (!firstVisibleSide)
+ firstVisibleSide = side;
+ else if (currEdge.color() != edges.at(*firstVisibleSide).color())
allEdgesShareColor = false;
if (!currEdge.color().isOpaque())
@@ -1904,23 +1930,27 @@
if (haveAllDoubleEdges) {
LayoutRect innerThirdRect = outerBorder.rect();
LayoutRect outerThirdRect = outerBorder.rect();
- for (int side = BSTop; side <= BSLeft; ++side) {
+ for (auto side : allBoxSides) {
LayoutUnit outerWidth;
LayoutUnit innerWidth;
- edges[side].getDoubleBorderStripeWidths(outerWidth, innerWidth);
-
- if (side == BSTop) {
+ edges.at(side).getDoubleBorderStripeWidths(outerWidth, innerWidth);
+ switch (side) {
+ case BoxSide::Top:
innerThirdRect.shiftYEdgeTo(innerThirdRect.y() + innerWidth);
outerThirdRect.shiftYEdgeTo(outerThirdRect.y() + outerWidth);
- } else if (side == BSBottom) {
+ break;
+ case BoxSide::Right:
+ innerThirdRect.setWidth(innerThirdRect.width() - innerWidth);
+ outerThirdRect.setWidth(outerThirdRect.width() - outerWidth);
+ break;
+ case BoxSide::Bottom:
innerThirdRect.setHeight(innerThirdRect.height() - innerWidth);
outerThirdRect.setHeight(outerThirdRect.height() - outerWidth);
- } else if (side == BSLeft) {
+ break;
+ case BoxSide::Left:
innerThirdRect.shiftXEdgeTo(innerThirdRect.x() + innerWidth);
outerThirdRect.shiftXEdgeTo(outerThirdRect.x() + outerWidth);
- } else {
- innerThirdRect.setWidth(innerThirdRect.width() - innerWidth);
- outerThirdRect.setWidth(outerThirdRect.width() - outerWidth);
+ break;
}
}
@@ -1947,7 +1977,7 @@
path.addRect(pixelSnappedInnerBorder.rect());
graphicsContext.setFillRule(WindRule::EvenOdd);
- graphicsContext.setFillColor(edges[firstVisibleEdge].color());
+ graphicsContext.setFillColor(edges.at(*firstVisibleSide).color());
graphicsContext.fillPath(path);
return;
}
@@ -1955,16 +1985,15 @@
if (haveAllSolidEdges && numEdgesVisible != 4 && !outerBorder.isRounded() && haveAlphaColor) {
Path path;
- for (int i = BSTop; i <= BSLeft; ++i) {
- const BorderEdge& currEdge = edges[i];
- if (currEdge.shouldRender()) {
- LayoutRect sideRect = calculateSideRect(outerBorder, edges, i);
- path.addRect(sideRect);
+ for (auto side : allBoxSides) {
+ if (edges.at(side).shouldRender()) {
+ auto sideRect = calculateSideRect(outerBorder, edges, side);
+ path.addRect(sideRect); // FIXME: Need pixel snapping here.
}
}
graphicsContext.setFillRule(WindRule::NonZero);
- graphicsContext.setFillColor(edges[firstVisibleEdge].color());
+ graphicsContext.setFillColor(edges.at(*firstVisibleSide).color());
graphicsContext.fillPath(path);
return;
}
@@ -1992,7 +2021,7 @@
paintBorderSides(graphicsContext, style, outerBorder, unadjustedInnerBorder, innerBorderAdjustment, edges, edgesToDraw, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias);
}
-void RenderBoxModelObject::drawBoxSideFromPath(GraphicsContext& graphicsContext, const LayoutRect& borderRect, const Path& borderPath, const BorderEdge edges[],
+void RenderBoxModelObject::drawBoxSideFromPath(GraphicsContext& graphicsContext, const LayoutRect& borderRect, const Path& borderPath, const BorderEdges& edges,
float thickness, float drawThickness, BoxSide side, const RenderStyle& style, Color color, BorderStyle borderStyle, BackgroundBleedAvoidance bleedAvoidance,
bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
{
@@ -2051,19 +2080,19 @@
// Get the inner border rects for both the outer border line and the inner border line
LayoutUnit outerBorderTopWidth;
LayoutUnit innerBorderTopWidth;
- edges[BSTop].getDoubleBorderStripeWidths(outerBorderTopWidth, innerBorderTopWidth);
+ edges.top().getDoubleBorderStripeWidths(outerBorderTopWidth, innerBorderTopWidth);
LayoutUnit outerBorderRightWidth;
LayoutUnit innerBorderRightWidth;
- edges[BSRight].getDoubleBorderStripeWidths(outerBorderRightWidth, innerBorderRightWidth);
+ edges.right().getDoubleBorderStripeWidths(outerBorderRightWidth, innerBorderRightWidth);
LayoutUnit outerBorderBottomWidth;
LayoutUnit innerBorderBottomWidth;
- edges[BSBottom].getDoubleBorderStripeWidths(outerBorderBottomWidth, innerBorderBottomWidth);
+ edges.bottom().getDoubleBorderStripeWidths(outerBorderBottomWidth, innerBorderBottomWidth);
LayoutUnit outerBorderLeftWidth;
LayoutUnit innerBorderLeftWidth;
- edges[BSLeft].getDoubleBorderStripeWidths(outerBorderLeftWidth, innerBorderLeftWidth);
+ edges.left().getDoubleBorderStripeWidths(outerBorderLeftWidth, innerBorderLeftWidth);
// Draw inner border line
{
@@ -2114,10 +2143,10 @@
// Paint inner only
GraphicsContextStateSaver stateSaver(graphicsContext);
- LayoutUnit topWidth { edges[BSTop].widthForPainting() / 2 };
- LayoutUnit bottomWidth { edges[BSBottom].widthForPainting() / 2 };
- LayoutUnit leftWidth { edges[BSLeft].widthForPainting() / 2 };
- LayoutUnit rightWidth { edges[BSRight].widthForPainting() / 2 };
+ LayoutUnit topWidth { edges.top().widthForPainting() / 2 };
+ LayoutUnit bottomWidth { edges.bottom().widthForPainting() / 2 };
+ LayoutUnit leftWidth { edges.left().widthForPainting() / 2 };
+ LayoutUnit rightWidth { edges.right().widthForPainting() / 2 };
RoundedRect clipRect = style.getRoundedInnerBorderFor(borderRect,
topWidth, bottomWidth, leftWidth, rightWidth,
@@ -2164,7 +2193,7 @@
Vector<FloatPoint> quad;
quad.reserveInitialCapacity(4);
switch (side) {
- case BSTop:
+ case BoxSide::Top:
quad.uncheckedAppend(outerRect.minXMinYCorner());
quad.uncheckedAppend(innerRect.minXMinYCorner());
quad.uncheckedAppend(innerRect.maxXMinYCorner());
@@ -2177,7 +2206,7 @@
findIntersection(outerRect.maxXMinYCorner(), innerRect.maxXMinYCorner(), innerRect.minXMinYCorner(), innerRect.maxXMaxYCorner(), quad[2]);
break;
- case BSLeft:
+ case BoxSide::Left:
quad.uncheckedAppend(outerRect.minXMinYCorner());
quad.uncheckedAppend(innerRect.minXMinYCorner());
quad.uncheckedAppend(innerRect.minXMaxYCorner());
@@ -2190,7 +2219,7 @@
findIntersection(outerRect.minXMaxYCorner(), innerRect.minXMaxYCorner(), innerRect.minXMinYCorner(), innerRect.maxXMaxYCorner(), quad[2]);
break;
- case BSBottom:
+ case BoxSide::Bottom:
quad.uncheckedAppend(outerRect.minXMaxYCorner());
quad.uncheckedAppend(innerRect.minXMaxYCorner());
quad.uncheckedAppend(innerRect.maxXMaxYCorner());
@@ -2203,7 +2232,7 @@
findIntersection(outerRect.maxXMaxYCorner(), innerRect.maxXMaxYCorner(), innerRect.maxXMinYCorner(), innerRect.minXMaxYCorner(), quad[2]);
break;
- case BSRight:
+ case BoxSide::Right:
quad.uncheckedAppend(outerRect.maxXMinYCorner());
quad.uncheckedAppend(innerRect.maxXMinYCorner());
quad.uncheckedAppend(innerRect.maxXMaxYCorner());
@@ -2232,7 +2261,7 @@
quad[0],
quad[1],
quad[2],
- side == BSTop || side == BSBottom ? FloatPoint(quad[3].x(), quad[2].y()) : FloatPoint(quad[2].x(), quad[3].y()),
+ side == BoxSide::Top || side == BoxSide::Bottom ? FloatPoint(quad[3].x(), quad[2].y()) : FloatPoint(quad[2].x(), quad[3].y()),
quad[3]
};
bool wasAntialiased = graphicsContext.shouldAntialias();
@@ -2241,7 +2270,7 @@
Vector<FloatPoint> secondQuad = {
quad[0],
- side == BSTop || side == BSBottom ? FloatPoint(quad[0].x(), quad[1].y()) : FloatPoint(quad[1].x(), quad[0].y()),
+ side == BoxSide::Top || side == BoxSide::Bottom ? FloatPoint(quad[0].x(), quad[1].y()) : FloatPoint(quad[1].x(), quad[0].y()),
quad[1],
quad[2],
quad[3]
@@ -2255,13 +2284,12 @@
bool RenderBoxModelObject::borderObscuresBackgroundEdge(const FloatSize& contextScale) const
{
- BorderEdge edges[4];
- BorderEdge::getBorderEdgeInfo(edges, style(), document().deviceScaleFactor());
+ auto edges = borderEdges(style(), document().deviceScaleFactor());
- for (int i = BSTop; i <= BSLeft; ++i) {
- const BorderEdge& currEdge = edges[i];
+ for (auto side : allBoxSides) {
+ auto& currEdge = edges.at(side);
// FIXME: for vertical text
- float axisScale = (i == BSTop || i == BSBottom) ? contextScale.height() : contextScale.width();
+ float axisScale = (side == BoxSide::Top || side == BoxSide::Bottom) ? contextScale.height() : contextScale.width();
if (!currEdge.obscuresBackgroundEdge(axisScale))
return false;
}
@@ -2278,12 +2306,10 @@
if (style().borderImage().image())
return false;
- BorderEdge edges[4];
- BorderEdge::getBorderEdgeInfo(edges, style(), document().deviceScaleFactor());
+ auto edges = borderEdges(style(), document().deviceScaleFactor());
- for (int i = BSTop; i <= BSLeft; ++i) {
- const BorderEdge& currEdge = edges[i];
- if (!currEdge.obscuresBackground())
+ for (auto side : allBoxSides) {
+ if (!edges.at(side).obscuresBackground())
return false;
}
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (269227 => 269228)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h 2020-10-31 19:06:24 UTC (rev 269228)
@@ -25,6 +25,7 @@
#include "FontBaseline.h"
#include "LayoutRect.h"
+#include "RectEdges.h"
#include "RenderLayerModelObject.h"
namespace WebCore {
@@ -32,7 +33,6 @@
// Modes for some of the line-related functions.
enum LinePositionMode { PositionOnContainingLine, PositionOfInteriorLineBoxes };
enum LineDirectionMode { HorizontalLine, VerticalLine };
-typedef unsigned BorderEdgeFlags;
enum BackgroundBleedAvoidance {
BackgroundBleedNone,
@@ -63,6 +63,10 @@
class RenderTextFragment;
class StickyPositionViewportConstraints;
+enum class BoxSideFlag : uint8_t;
+using BoxSideSet = OptionSet<BoxSideFlag>;
+using BorderEdges = RectEdges<BorderEdge>;
+
class BackgroundImageGeometry {
public:
BackgroundImageGeometry(const LayoutRect& destinationRect, const LayoutSize& tile, const LayoutSize& phase, const LayoutSize& space, bool fixedAttachment)
@@ -313,14 +317,14 @@
BoxSide, bool firstEdgeMatches, bool secondEdgeMatches);
void paintOneBorderSide(GraphicsContext&, const RenderStyle&, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
- const LayoutRect& sideRect, BoxSide, BoxSide adjacentSide1, BoxSide adjacentSide2, const BorderEdge[],
+ const LayoutRect& sideRect, BoxSide, BoxSide adjacentSide1, BoxSide adjacentSide2, const BorderEdges&,
const Path*, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias, const Color* overrideColor = nullptr);
void paintTranslucentBorderSides(GraphicsContext&, const RenderStyle&, const RoundedRect& outerBorder, const RoundedRect& innerBorder, const IntPoint& innerBorderAdjustment,
- const BorderEdge[], BorderEdgeFlags, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias = false);
+ const BorderEdges&, BoxSideSet, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias = false);
void paintBorderSides(GraphicsContext&, const RenderStyle&, const RoundedRect& outerBorder, const RoundedRect& innerBorder,
- const IntPoint& innerBorderAdjustment, const BorderEdge[], BorderEdgeFlags, BackgroundBleedAvoidance,
+ const IntPoint& innerBorderAdjustment, const BorderEdges&, BoxSideSet, BackgroundBleedAvoidance,
bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias = false, const Color* overrideColor = nullptr);
- void drawBoxSideFromPath(GraphicsContext&, const LayoutRect&, const Path&, const BorderEdge[],
+ void drawBoxSideFromPath(GraphicsContext&, const LayoutRect&, const Path&, const BorderEdges&,
float thickness, float drawThickness, BoxSide, const RenderStyle&,
Color, BorderStyle, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
void paintMaskForTextFillBox(ImageBuffer*, const IntRect&, InlineFlowBox*, const LayoutRect&);
Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (269227 => 269228)
--- trunk/Source/WebCore/rendering/RenderElement.cpp 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp 2020-10-31 19:06:24 UTC (rev 269228)
@@ -1702,7 +1702,7 @@
float y2 = rect.maxY();
float thickness;
float length;
- if (side == BSTop || side == BSBottom) {
+ if (side == BoxSide::Top || side == BoxSide::Bottom) {
thickness = y2 - y1;
length = x2 - x1;
} else {
@@ -1748,13 +1748,13 @@
graphicsContext.setShouldAntialias(antialias);
switch (side) {
- case BSTop:
- case BSBottom:
+ case BoxSide::Top:
+ case BoxSide::Bottom:
drawBorderRect(snapRectToDevicePixels(LayoutRect(x1, y1, length, thirdOfThickness), deviceScaleFactor));
drawBorderRect(snapRectToDevicePixels(LayoutRect(x1, y2 - thirdOfThickness, length, thirdOfThickness), deviceScaleFactor));
break;
- case BSLeft:
- case BSRight:
+ case BoxSide::Left:
+ case BoxSide::Right:
drawBorderRect(snapRectToDevicePixels(LayoutRect(x1, y1, thirdOfThickness, length), deviceScaleFactor));
drawBorderRect(snapRectToDevicePixels(LayoutRect(x2 - thirdOfThickness, y1, thirdOfThickness, length), deviceScaleFactor));
break;
@@ -1776,7 +1776,7 @@
FloatRect paintBorderRect;
switch (side) {
- case BSTop:
+ case BoxSide::Top:
paintBorderRect = snapRectToDevicePixels(LayoutRect(x1 + mitreOffset1, y1, (x2 - mitreOffset3) - (x1 + mitreOffset1), thirdOfThickness), deviceScaleFactor);
drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird));
@@ -1783,7 +1783,7 @@
paintBorderRect = snapRectToDevicePixels(LayoutRect(x1 + mitreOffset2, y2 - thirdOfThickness, (x2 - mitreOffset4) - (x1 + mitreOffset2), thirdOfThickness), deviceScaleFactor);
drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird));
break;
- case BSLeft:
+ case BoxSide::Left:
paintBorderRect = snapRectToDevicePixels(LayoutRect(x1, y1 + mitreOffset1, thirdOfThickness, (y2 - mitreOffset3) - (y1 + mitreOffset1)), deviceScaleFactor);
drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird));
@@ -1790,7 +1790,7 @@
paintBorderRect = snapRectToDevicePixels(LayoutRect(x2 - thirdOfThickness, y1 + mitreOffset2, thirdOfThickness, (y2 - mitreOffset4) - (y1 + mitreOffset2)), deviceScaleFactor);
drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird));
break;
- case BSBottom:
+ case BoxSide::Bottom:
paintBorderRect = snapRectToDevicePixels(LayoutRect(x1 + mitreOffset2, y1, (x2 - mitreOffset4) - (x1 + mitreOffset2), thirdOfThickness), deviceScaleFactor);
drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird));
@@ -1797,7 +1797,7 @@
paintBorderRect = snapRectToDevicePixels(LayoutRect(x1 + mitreOffset1, y2 - thirdOfThickness, (x2 - mitreOffset3) - (x1 + mitreOffset1), thirdOfThickness), deviceScaleFactor);
drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird));
break;
- case BSRight:
+ case BoxSide::Right:
paintBorderRect = snapRectToDevicePixels(LayoutRect(x1, y1 + mitreOffset2, thirdOfThickness, (y2 - mitreOffset4) - (y1 + mitreOffset2)), deviceScaleFactor);
drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird));
@@ -1833,16 +1833,16 @@
float offset3 = 0;
float offset4 = 0;
- if (((side == BSTop || side == BSLeft) && adjacentWidth1 < 0) || ((side == BSBottom || side == BSRight) && adjacentWidth1 > 0))
+ if (((side == BoxSide::Top || side == BoxSide::Left) && adjacentWidth1 < 0) || ((side == BoxSide::Bottom || side == BoxSide::Right) && adjacentWidth1 > 0))
offset1 = floorToDevicePixel(adjacentWidth1 / 2, deviceScaleFactor);
- if (((side == BSTop || side == BSLeft) && adjacentWidth2 < 0) || ((side == BSBottom || side == BSRight) && adjacentWidth2 > 0))
+ if (((side == BoxSide::Top || side == BoxSide::Left) && adjacentWidth2 < 0) || ((side == BoxSide::Bottom || side == BoxSide::Right) && adjacentWidth2 > 0))
offset2 = ceilToDevicePixel(adjacentWidth2 / 2, deviceScaleFactor);
- if (((side == BSTop || side == BSLeft) && adjacentWidth1 > 0) || ((side == BSBottom || side == BSRight) && adjacentWidth1 < 0))
+ if (((side == BoxSide::Top || side == BoxSide::Left) && adjacentWidth1 > 0) || ((side == BoxSide::Bottom || side == BoxSide::Right) && adjacentWidth1 < 0))
offset3 = floorToDevicePixel(fabs(adjacentWidth1) / 2, deviceScaleFactor);
- if (((side == BSTop || side == BSLeft) && adjacentWidth2 > 0) || ((side == BSBottom || side == BSRight) && adjacentWidth2 < 0))
+ if (((side == BoxSide::Top || side == BoxSide::Left) && adjacentWidth2 > 0) || ((side == BoxSide::Bottom || side == BoxSide::Right) && adjacentWidth2 < 0))
offset4 = ceilToDevicePixel(adjacentWidth2 / 2, deviceScaleFactor);
float adjustedX = ceilToDevicePixel((x1 + x2) / 2, deviceScaleFactor);
@@ -1854,19 +1854,19 @@
y2 = roundToDevicePixel(y2, deviceScaleFactor);
switch (side) {
- case BSTop:
+ case BoxSide::Top:
drawLineFor(FloatRect(FloatPoint(x1 + offset1, y1), FloatPoint(x2 - offset2, adjustedY)), side, s1, FloatSize(adjacent1BigHalf, adjacent2BigHalf));
drawLineFor(FloatRect(FloatPoint(x1 + offset3, adjustedY), FloatPoint(x2 - offset4, y2)), side, s2, FloatSize(adjacent1SmallHalf, adjacent2SmallHalf));
break;
- case BSLeft:
+ case BoxSide::Left:
drawLineFor(FloatRect(FloatPoint(x1, y1 + offset1), FloatPoint(adjustedX, y2 - offset2)), side, s1, FloatSize(adjacent1BigHalf, adjacent2BigHalf));
drawLineFor(FloatRect(FloatPoint(adjustedX, y1 + offset3), FloatPoint(x2, y2 - offset4)), side, s2, FloatSize(adjacent1SmallHalf, adjacent2SmallHalf));
break;
- case BSBottom:
+ case BoxSide::Bottom:
drawLineFor(FloatRect(FloatPoint(x1 + offset1, y1), FloatPoint(x2 - offset2, adjustedY)), side, s2, FloatSize(adjacent1BigHalf, adjacent2BigHalf));
drawLineFor(FloatRect(FloatPoint(x1 + offset3, adjustedY), FloatPoint(x2 - offset4, y2)), side, s1, FloatSize(adjacent1SmallHalf, adjacent2SmallHalf));
break;
- case BSRight:
+ case BoxSide::Right:
drawLineFor(FloatRect(FloatPoint(x1, y1 + offset1), FloatPoint(adjustedX, y2 - offset2)), side, s2, FloatSize(adjacent1BigHalf, adjacent2BigHalf));
drawLineFor(FloatRect(FloatPoint(adjustedX, y1 + offset3), FloatPoint(x2, y2 - offset4)), side, s1, FloatSize(adjacent1SmallHalf, adjacent2SmallHalf));
break;
@@ -1901,25 +1901,25 @@
Vector<FloatPoint> quad;
quad.reserveInitialCapacity(4);
switch (side) {
- case BSTop:
+ case BoxSide::Top:
quad.uncheckedAppend({ x1 + std::max<float>(-adjacentWidth1, 0), y1 });
quad.uncheckedAppend({ x1 + std::max<float>( adjacentWidth1, 0), y2 });
quad.uncheckedAppend({ x2 - std::max<float>( adjacentWidth2, 0), y2 });
quad.uncheckedAppend({ x2 - std::max<float>(-adjacentWidth2, 0), y1 });
break;
- case BSBottom:
+ case BoxSide::Bottom:
quad.uncheckedAppend({ x1 + std::max<float>( adjacentWidth1, 0), y1 });
quad.uncheckedAppend({ x1 + std::max<float>(-adjacentWidth1, 0), y2 });
quad.uncheckedAppend({ x2 - std::max<float>(-adjacentWidth2, 0), y2 });
quad.uncheckedAppend({ x2 - std::max<float>( adjacentWidth2, 0), y1 });
break;
- case BSLeft:
+ case BoxSide::Left:
quad.uncheckedAppend({ x1, y1 + std::max<float>(-adjacentWidth1, 0) });
quad.uncheckedAppend({ x1, y2 - std::max<float>(-adjacentWidth2, 0) });
quad.uncheckedAppend({ x2, y2 - std::max<float>( adjacentWidth2, 0) });
quad.uncheckedAppend({ x2, y1 + std::max<float>( adjacentWidth1, 0) });
break;
- case BSRight:
+ case BoxSide::Right:
quad.uncheckedAppend({ x1, y1 + std::max<float>( adjacentWidth1, 0) });
quad.uncheckedAppend({ x1, y2 - std::max<float>( adjacentWidth2, 0) });
quad.uncheckedAppend({ x2, y2 - std::max<float>(-adjacentWidth2, 0) });
@@ -2083,10 +2083,10 @@
float bottomOuter = outer.maxY();
float bottomInner = std::min(inner.maxY(), bottomOuter);
- drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(leftOuter, topOuter), FloatPoint(leftInner, bottomOuter)), BSLeft, outlineColor, outlineStyle, outlineWidth, outlineWidth);
- drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(leftOuter, topOuter), FloatPoint(rightOuter, topInner)), BSTop, outlineColor, outlineStyle, outlineWidth, outlineWidth);
- drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(rightInner, topOuter), FloatPoint(rightOuter, bottomOuter)), BSRight, outlineColor, outlineStyle, outlineWidth, outlineWidth);
- drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(leftOuter, bottomInner), FloatPoint(rightOuter, bottomOuter)), BSBottom, outlineColor, outlineStyle, outlineWidth, outlineWidth);
+ drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(leftOuter, topOuter), FloatPoint(leftInner, bottomOuter)), BoxSide::Left, outlineColor, outlineStyle, outlineWidth, outlineWidth);
+ drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(leftOuter, topOuter), FloatPoint(rightOuter, topInner)), BoxSide::Top, outlineColor, outlineStyle, outlineWidth, outlineWidth);
+ drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(rightInner, topOuter), FloatPoint(rightOuter, bottomOuter)), BoxSide::Right, outlineColor, outlineStyle, outlineWidth, outlineWidth);
+ drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(leftOuter, bottomInner), FloatPoint(rightOuter, bottomOuter)), BoxSide::Bottom, outlineColor, outlineStyle, outlineWidth, outlineWidth);
if (useTransparencyLayer)
graphicsContext.endTransparencyLayer();
Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (269227 => 269228)
--- trunk/Source/WebCore/rendering/RenderInline.cpp 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp 2020-10-31 19:06:24 UTC (rev 269228)
@@ -1284,7 +1284,7 @@
bottomRight.move(0, -2 * outlineOffset);
adjacentWidth2 = -outlineWidth;
}
- drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSLeft, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
+ drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Left, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
// right edge
topLeft = outlineBoxRect.maxXMinYCorner();
@@ -1303,7 +1303,7 @@
bottomRight.move(outlineWidth, -2 * outlineOffset);
adjacentWidth2 = -outlineWidth;
}
- drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSRight, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
+ drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Right, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
// upper edge
if (thisLine.x() < previousLine.x()) {
@@ -1317,7 +1317,7 @@
adjacentWidth2 = -outlineWidth;
} else
adjacentWidth2 = outlineWidth;
- drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSTop, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
+ drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Top, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
}
if (previousLine.maxX() < thisLine.maxX()) {
@@ -1331,7 +1331,7 @@
bottomRight = outlineBoxRect.maxXMinYCorner();
bottomRight.move(outlineWidth, 0);
adjacentWidth2 = outlineWidth;
- drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSTop, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
+ drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Top, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
}
if (thisLine.x() == thisLine.maxX()) {
@@ -1341,7 +1341,7 @@
bottomRight = outlineBoxRect.maxXMinYCorner();
bottomRight.move(outlineWidth, 0);
adjacentWidth2 = outlineWidth;
- drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSTop, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
+ drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Top, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
}
// lower edge
@@ -1356,7 +1356,7 @@
adjacentWidth2 = -outlineWidth;
} else
adjacentWidth2 = outlineWidth;
- drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSBottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
+ drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Bottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
}
if (nextLine.maxX() < thisLine.maxX()) {
@@ -1370,7 +1370,7 @@
bottomRight = outlineBoxRect.maxXMaxYCorner();
bottomRight.move(outlineWidth, outlineWidth);
adjacentWidth2 = outlineWidth;
- drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSBottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
+ drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Bottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
}
if (thisLine.x() == thisLine.maxX()) {
@@ -1380,7 +1380,7 @@
bottomRight = outlineBoxRect.maxXMaxYCorner();
bottomRight.move(outlineWidth, outlineWidth);
adjacentWidth2 = outlineWidth;
- drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BSBottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
+ drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Bottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);
}
}
Modified: trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp (269227 => 269228)
--- trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp 2020-10-31 19:06:24 UTC (rev 269228)
@@ -603,8 +603,8 @@
LayoutUnit ruleLogicalLeft = leftToRight ? 0_lu : contentLogicalWidth();
LayoutUnit inlineDirectionSize = computedColumnWidth();
BoxSide boxSide = isHorizontalWritingMode()
- ? leftToRight ? BSLeft : BSRight
- : leftToRight ? BSTop : BSBottom;
+ ? leftToRight ? BoxSide::Left : BoxSide::Right
+ : leftToRight ? BoxSide::Top : BoxSide::Bottom;
for (unsigned i = 0; i < colCount; i++) {
// Move to the next position.
@@ -645,7 +645,7 @@
ruleRect.moveBy(paintOffset);
- BoxSide boxSide = isHorizontalWritingMode() ? topToBottom ? BSTop : BSBottom : topToBottom ? BSLeft : BSRight;
+ BoxSide boxSide = isHorizontalWritingMode() ? topToBottom ? BoxSide::Top : BoxSide::Bottom : topToBottom ? BoxSide::Left : BoxSide::Right;
LayoutSize step(0_lu, topToBottom ? computedColumnHeight() + colGap : -(computedColumnHeight() + colGap));
if (!isHorizontalWritingMode())
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (269227 => 269228)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2020-10-31 19:06:24 UTC (rev 269228)
@@ -1826,7 +1826,7 @@
enum Operation { Darken, Lighten };
- Operation operation = (side == BSTop || side == BSLeft) == (style == BorderStyle::Inset) ? Darken : Lighten;
+ Operation operation = (side == BoxSide::Top || side == BoxSide::Left) == (style == BorderStyle::Inset) ? Darken : Lighten;
// Here we will darken the border decoration color when needed. This will yield a similar behavior as in FF.
if (operation == Darken) {
Modified: trunk/Source/WebCore/rendering/RenderObjectEnums.h (269227 => 269228)
--- trunk/Source/WebCore/rendering/RenderObjectEnums.h 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/RenderObjectEnums.h 2020-10-31 19:06:24 UTC (rev 269228)
@@ -47,14 +47,6 @@
HitTestForeground
};
-// Sides used when drawing borders and outlines. The values should run clockwise from top.
-enum BoxSide {
- BSTop,
- BSRight,
- BSBottom,
- BSLeft
-};
-
enum MarkingBehavior {
MarkOnlyThis,
MarkContainingBlockChain,
Modified: trunk/Source/WebCore/rendering/RenderTableCell.cpp (269227 => 269228)
--- trunk/Source/WebCore/rendering/RenderTableCell.cpp 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/RenderTableCell.cpp 2020-10-31 19:06:24 UTC (rev 269228)
@@ -1251,10 +1251,10 @@
// We never paint diagonals at the joins. We simply let the border with the highest
// precedence paint on top of borders with lower precedence.
CollapsedBorders borders;
- borders.addBorder(topVal, BSTop, renderTop, borderRect.x(), borderRect.y(), borderRect.maxX(), borderRect.y() + topWidth, topStyle);
- borders.addBorder(bottomVal, BSBottom, renderBottom, borderRect.x(), borderRect.maxY() - bottomWidth, borderRect.maxX(), borderRect.maxY(), bottomStyle);
- borders.addBorder(leftVal, BSLeft, renderLeft, borderRect.x(), borderRect.y(), borderRect.x() + leftWidth, borderRect.maxY(), leftStyle);
- borders.addBorder(rightVal, BSRight, renderRight, borderRect.maxX() - rightWidth, borderRect.y(), borderRect.maxX(), borderRect.maxY(), rightStyle);
+ borders.addBorder(topVal, BoxSide::Top, renderTop, borderRect.x(), borderRect.y(), borderRect.maxX(), borderRect.y() + topWidth, topStyle);
+ borders.addBorder(bottomVal, BoxSide::Bottom, renderBottom, borderRect.x(), borderRect.maxY() - bottomWidth, borderRect.maxX(), borderRect.maxY(), bottomStyle);
+ borders.addBorder(leftVal, BoxSide::Left, renderLeft, borderRect.x(), borderRect.y(), borderRect.x() + leftWidth, borderRect.maxY(), leftStyle);
+ borders.addBorder(rightVal, BoxSide::Right, renderRight, borderRect.maxX() - rightWidth, borderRect.y(), borderRect.maxX(), borderRect.maxY(), rightStyle);
bool antialias = shouldAntialiasLines(graphicsContext);
Modified: trunk/Source/WebCore/rendering/RenderTableSection.cpp (269227 => 269228)
--- trunk/Source/WebCore/rendering/RenderTableSection.cpp 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/RenderTableSection.cpp 2020-10-31 19:06:24 UTC (rev 269228)
@@ -1096,10 +1096,10 @@
{
bool isLastRow = row + 1 == m_grid.size();
if (style().isHorizontalWritingMode())
- return m_rowPos[row] + (!row && borderSide == BSRight ? -outerBorderTop(&style()) : isLastRow && borderSide == BSLeft ? outerBorderTop(&style()) : 0_lu);
+ return m_rowPos[row] + (!row && borderSide == BoxSide::Right ? -outerBorderTop(&style()) : isLastRow && borderSide == BoxSide::Left ? outerBorderTop(&style()) : 0_lu);
if (style().isLeftToRightDirection())
- return (cell ? cell->y() + cell->height() : 0_lu) + (borderSide == BSLeft ? outerBorderTop(&style()) : 0_lu);
- return borderSide == BSRight ? -outerBorderTop(&style()) : 0_lu;
+ return (cell ? cell->y() + cell->height() : 0_lu) + (borderSide == BoxSide::Left ? outerBorderTop(&style()) : 0_lu);
+ return borderSide == BoxSide::Right ? -outerBorderTop(&style()) : 0_lu;
}
LayoutUnit RenderTableSection::verticalRowGroupBorderHeight(RenderTableCell* cell, const LayoutRect& rowGroupRect, unsigned row)
@@ -1133,24 +1133,24 @@
const RenderStyle& style = this->style();
bool antialias = shouldAntialiasLines(paintInfo.context());
LayoutRect rowGroupRect = LayoutRect(paintOffset, size());
- rowGroupRect.moveBy(-LayoutPoint(outerBorderLeft(&style), (borderSide == BSRight) ? 0_lu : outerBorderTop(&style)));
+ rowGroupRect.moveBy(-LayoutPoint(outerBorderLeft(&style), (borderSide == BoxSide::Right) ? 0_lu : outerBorderTop(&style)));
switch (borderSide) {
- case BSTop:
+ case BoxSide::Top:
paintRowGroupBorder(paintInfo, antialias, LayoutRect(paintOffset.x() + offsetLeftForRowGroupBorder(cell, rowGroupRect, row), rowGroupRect.y(),
- horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), LayoutUnit(style.borderTop().width())), BSTop, CSSPropertyBorderTopColor, style.borderTopStyle(), table()->style().borderTopStyle());
+ horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), LayoutUnit(style.borderTop().width())), BoxSide::Top, CSSPropertyBorderTopColor, style.borderTopStyle(), table()->style().borderTopStyle());
break;
- case BSBottom:
+ case BoxSide::Bottom:
paintRowGroupBorder(paintInfo, antialias, LayoutRect(paintOffset.x() + offsetLeftForRowGroupBorder(cell, rowGroupRect, row), rowGroupRect.y() + rowGroupRect.height(),
- horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), LayoutUnit(style.borderBottom().width())), BSBottom, CSSPropertyBorderBottomColor, style.borderBottomStyle(), table()->style().borderBottomStyle());
+ horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), LayoutUnit(style.borderBottom().width())), BoxSide::Bottom, CSSPropertyBorderBottomColor, style.borderBottomStyle(), table()->style().borderBottomStyle());
break;
- case BSLeft:
+ case BoxSide::Left:
paintRowGroupBorder(paintInfo, antialias, LayoutRect(rowGroupRect.x(), rowGroupRect.y() + offsetTopForRowGroupBorder(cell, borderSide, row), LayoutUnit(style.borderLeft().width()),
- verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BSLeft, CSSPropertyBorderLeftColor, style.borderLeftStyle(), table()->style().borderLeftStyle());
+ verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BoxSide::Left, CSSPropertyBorderLeftColor, style.borderLeftStyle(), table()->style().borderLeftStyle());
break;
- case BSRight:
+ case BoxSide::Right:
paintRowGroupBorder(paintInfo, antialias, LayoutRect(rowGroupRect.x() + rowGroupRect.width(), rowGroupRect.y() + offsetTopForRowGroupBorder(cell, borderSide, row), LayoutUnit(style.borderRight().width()),
- verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BSRight, CSSPropertyBorderRightColor, style.borderRightStyle(), table()->style().borderRightStyle());
+ verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BoxSide::Right, CSSPropertyBorderRightColor, style.borderRightStyle(), table()->style().borderRightStyle());
break;
default:
break;
@@ -1164,23 +1164,23 @@
switch (side) {
case CBSStart:
if (styleForCellFlow->isHorizontalWritingMode())
- return styleForCellFlow->isLeftToRightDirection() ? BSLeft : BSRight;
- return styleForCellFlow->isLeftToRightDirection() ? BSTop : BSBottom;
+ return styleForCellFlow->isLeftToRightDirection() ? BoxSide::Left : BoxSide::Right;
+ return styleForCellFlow->isLeftToRightDirection() ? BoxSide::Top : BoxSide::Bottom;
case CBSEnd:
if (styleForCellFlow->isHorizontalWritingMode())
- return styleForCellFlow->isLeftToRightDirection() ? BSRight : BSLeft;
- return styleForCellFlow->isLeftToRightDirection() ? BSBottom : BSTop;
+ return styleForCellFlow->isLeftToRightDirection() ? BoxSide::Right : BoxSide::Left;
+ return styleForCellFlow->isLeftToRightDirection() ? BoxSide::Bottom : BoxSide::Top;
case CBSBefore:
if (styleForCellFlow->isHorizontalWritingMode())
- return BSTop;
- return styleForCellFlow->isLeftToRightDirection() ? BSRight : BSLeft;
+ return BoxSide::Top;
+ return styleForCellFlow->isLeftToRightDirection() ? BoxSide::Right : BoxSide::Left;
case CBSAfter:
if (styleForCellFlow->isHorizontalWritingMode())
- return BSBottom;
- return styleForCellFlow->isLeftToRightDirection() ? BSLeft : BSRight;
+ return BoxSide::Bottom;
+ return styleForCellFlow->isLeftToRightDirection() ? BoxSide::Left : BoxSide::Right;
default:
ASSERT_NOT_REACHED();
- return BSLeft;
+ return BoxSide::Left;
}
}
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (269227 => 269228)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2020-10-31 19:06:24 UTC (rev 269228)
@@ -695,7 +695,7 @@
float separatorPosition = isRTL ? (clip.x() + MenuListButtonPaddingAfter) : (clip.maxX() - MenuListButtonPaddingAfter);
- box.drawLineForBoxSide(paintInfo.context(), FloatRect(FloatPoint(separatorPosition - borderTopWidth, clip.y()), FloatPoint(separatorPosition, clip.maxY())), BSRight, style.visitedDependentColor(CSSPropertyBorderTopColor), style.borderTopStyle(), 0, 0);
+ box.drawLineForBoxSide(paintInfo.context(), FloatRect(FloatPoint(separatorPosition - borderTopWidth, clip.y()), FloatPoint(separatorPosition, clip.maxY())), BoxSide::Right, style.visitedDependentColor(CSSPropertyBorderTopColor), style.borderTopStyle(), 0, 0);
FloatRect buttonClip;
if (isRTL)
Modified: trunk/Source/WebCore/rendering/style/NinePieceImage.h (269227 => 269228)
--- trunk/Source/WebCore/rendering/style/NinePieceImage.h 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebCore/rendering/style/NinePieceImage.h 2020-10-31 19:06:24 UTC (rev 269228)
@@ -82,24 +82,24 @@
return piece == LeftPiece || piece == RightPiece || piece == MiddlePiece;
}
-inline Optional<PhysicalBoxSide> imagePieceHorizontalSide(ImagePiece piece)
+inline Optional<BoxSide> imagePieceHorizontalSide(ImagePiece piece)
{
if (piece == TopLeftPiece || piece == TopPiece || piece == TopRightPiece)
- return PhysicalBoxSide::Top;
+ return BoxSide::Top;
if (piece == BottomLeftPiece || piece == BottomPiece || piece == BottomRightPiece)
- return PhysicalBoxSide::Bottom;
+ return BoxSide::Bottom;
return WTF::nullopt;
}
-inline Optional<PhysicalBoxSide> imagePieceVerticalSide(ImagePiece piece)
+inline Optional<BoxSide> imagePieceVerticalSide(ImagePiece piece)
{
if (piece == TopLeftPiece || piece == LeftPiece || piece == BottomLeftPiece)
- return PhysicalBoxSide::Left;
+ return BoxSide::Left;
if (piece == TopRightPiece || piece == RightPiece || piece == BottomRightPiece)
- return PhysicalBoxSide::Right;
+ return BoxSide::Right;
return WTF::nullopt;
}
Modified: trunk/Source/WebKit/ChangeLog (269227 => 269228)
--- trunk/Source/WebKit/ChangeLog 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebKit/ChangeLog 2020-10-31 19:06:24 UTC (rev 269228)
@@ -1,3 +1,13 @@
+2020-10-31 Simon Fraser <[email protected]>
+
+ Clean up BoxSide and BorderEdge code
+ https://bugs.webkit.org/show_bug.cgi?id=218197
+
+ Reviewed by Sam Weinig.
+
+ * UIProcess/ios/WKKeyboardScrollingAnimator.mm:
+ (boxSide):
+
2020-10-30 Brian Burg <[email protected]>
Web Inspector: move InspectorFrontendAPIDispatcher to WebCore, clean up uses
Modified: trunk/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.mm (269227 => 269228)
--- trunk/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.mm 2020-10-31 16:11:57 UTC (rev 269227)
+++ trunk/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.mm 2020-10-31 19:06:24 UTC (rev 269228)
@@ -163,17 +163,17 @@
}
}
-static WebCore::PhysicalBoxSide boxSide(WebKit::ScrollingDirection direction)
+static WebCore::BoxSide boxSide(WebKit::ScrollingDirection direction)
{
switch (direction) {
case WebKit::ScrollingDirection::Up:
- return WebCore::PhysicalBoxSide::Top;
+ return WebCore::BoxSide::Top;
case WebKit::ScrollingDirection::Down:
- return WebCore::PhysicalBoxSide::Bottom;
+ return WebCore::BoxSide::Bottom;
case WebKit::ScrollingDirection::Left:
- return WebCore::PhysicalBoxSide::Left;
+ return WebCore::BoxSide::Left;
case WebKit::ScrollingDirection::Right:
- return WebCore::PhysicalBoxSide::Right;
+ return WebCore::BoxSide::Right;
}
}