Changeset 269228 in webkit
- Timestamp:
- Oct 31, 2020, 12:06:24 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r269227 r269228 1 2020-10-31 Simon Fraser <simon.fraser@apple.com> 2 3 Clean up BoxSide and BorderEdge code 4 https://bugs.webkit.org/show_bug.cgi?id=218197 5 6 Reviewed by Sam Weinig. 7 8 Change border-drawing functions in RenderBoxModelObject which took BorderEdge[] to 9 use RectEdges<BorderEdge>. In addition, make BoxSide an enum class, and remove the redundant 10 PhysicalBoxSide. Also make BorderEdgeFlags an OptionSet<>. 11 12 I renamed PhysicalBoxSide to BoxSide because "physical" is a loaded term (it could mean 13 either locally top/right/bottom/left, or refer to absolute "physical coordinates"). 14 This allowed BoxSide to be used in RectEdges, therefore making RectEdges<BorderEdge> 15 the right way to represent the set of edges for a box. 16 17 An equivalent set of bit flags, BoxSideFlag, allows use in an OptionSet<>. 18 19 Use more enumeration of sides in the border painting code. 20 21 * page/IntersectionObserver.cpp: 22 (WebCore::IntersectionObserver::rootMargin const): 23 * platform/RectEdges.h: 24 (WebCore::RectEdges::at): 25 (WebCore::RectEdges::top): 26 (WebCore::RectEdges::right): 27 (WebCore::RectEdges::bottom): 28 (WebCore::RectEdges::left): 29 (WebCore::RectEdges::at const): 30 (WebCore::RectEdges::top const): 31 (WebCore::RectEdges::right const): 32 (WebCore::RectEdges::bottom const): 33 (WebCore::RectEdges::left const): 34 (WebCore::RectEdges::setAt): 35 (WebCore::RectEdges::setTop): 36 (WebCore::RectEdges::setRight): 37 (WebCore::RectEdges::setBottom): 38 (WebCore::RectEdges::setLeft): 39 * platform/text/WritingMode.h: 40 (WebCore::isHorizontalPhysicalSide): 41 (WebCore::mirrorPhysicalSide): 42 (WebCore::rotatePhysicalSide): 43 (WebCore::mapLogicalSideToPhysicalSide): 44 * rendering/BorderEdge.cpp: 45 (WebCore::borderEdges): 46 (WebCore::BorderEdge::getBorderEdgeInfo): Deleted. 47 * rendering/BorderEdge.h: 48 (WebCore::edgeFlagForSide): 49 (WebCore::includesEdge): 50 (WebCore::includesAdjacentEdges): 51 * rendering/RenderBoxModelObject.cpp: 52 (WebCore::borderWillArcInnerEdge): 53 (WebCore::borderStyleHasUnmatchedColorsAtCorner): 54 (WebCore::colorsMatchAtCorner): 55 (WebCore::colorNeedsAntiAliasAtCorner): 56 (WebCore::willBeOverdrawn): 57 (WebCore::joinRequiresMitre): 58 (WebCore::calculateAdjustedInnerBorder): 59 (WebCore::RenderBoxModelObject::paintOneBorderSide): 60 (WebCore::calculateSideRect): 61 (WebCore::RenderBoxModelObject::paintBorderSides): 62 (WebCore::RenderBoxModelObject::paintTranslucentBorderSides): 63 (WebCore::RenderBoxModelObject::paintBorder): 64 (WebCore::RenderBoxModelObject::drawBoxSideFromPath): 65 (WebCore::RenderBoxModelObject::clipBorderSidePolygon): 66 (WebCore::RenderBoxModelObject::borderObscuresBackgroundEdge const): 67 (WebCore::RenderBoxModelObject::borderObscuresBackground const): 68 * rendering/RenderBoxModelObject.h: 69 * rendering/RenderElement.cpp: 70 (WebCore::RenderElement::drawLineForBoxSide const): 71 (WebCore::RenderElement::paintOutline): 72 * rendering/RenderInline.cpp: 73 (WebCore::RenderInline::paintOutlineForLine): 74 * rendering/RenderMultiColumnSet.cpp: 75 (WebCore::RenderMultiColumnSet::paintColumnRules): 76 * rendering/RenderObject.cpp: 77 (WebCore::RenderObject::calculateBorderStyleColor): 78 * rendering/RenderObjectEnums.h: 79 * rendering/RenderTableCell.cpp: 80 (WebCore::RenderTableCell::paintCollapsedBorders): 81 * rendering/RenderTableSection.cpp: 82 (WebCore::RenderTableSection::offsetTopForRowGroupBorder): 83 (WebCore::RenderTableSection::paintRowGroupBorderIfRequired): 84 (WebCore::physicalBorderForDirection): 85 * rendering/RenderThemeIOS.mm: 86 (WebCore::RenderThemeIOS::paintMenuListButtonDecorations): 87 * rendering/style/NinePieceImage.h: 88 (WebCore::imagePieceHorizontalSide): 89 (WebCore::imagePieceVerticalSide): 90 1 91 2020-10-31 Chris Dumez <cdumez@apple.com> 2 92 -
trunk/Source/WebCore/page/IntersectionObserver.cpp
r265397 r269228 151 151 { 152 152 StringBuilder stringBuilder; 153 PhysicalBoxSide sides[4] = { PhysicalBoxSide::Top, PhysicalBoxSide::Right, PhysicalBoxSide::Bottom, PhysicalBoxSide::Left }; 154 for (auto side : sides) { 153 for (auto side : allBoxSides) { 155 154 auto& length = m_rootMargin.at(side); 156 155 stringBuilder.appendNumber(length.intValue()); … … 159 158 else 160 159 stringBuilder.appendLiteral("px"); 161 if (side != PhysicalBoxSide::Left)160 if (side != BoxSide::Left) 162 161 stringBuilder.append(' '); 163 162 } -
trunk/Source/WebCore/platform/RectEdges.h
r234808 r269228 28 28 #include "WritingMode.h" 29 29 #include <array> 30 #include <wtf/OptionSet.h> 30 31 31 32 namespace WebCore { 32 33 34 enum class BoxSideFlag : uint8_t { 35 Top = 1 << static_cast<unsigned>(BoxSide::Top), 36 Right = 1 << static_cast<unsigned>(BoxSide::Right), 37 Bottom = 1 << static_cast<unsigned>(BoxSide::Bottom), 38 Left = 1 << static_cast<unsigned>(BoxSide::Left) 39 }; 40 41 using BoxSideSet = OptionSet<BoxSideFlag>; 42 33 43 template<typename T> class RectEdges { 34 44 public: … … 39 49 : m_sides({ { std::forward<T>(top), std::forward<T>(right), std::forward<T>(bottom), std::forward<T>(left) } }) 40 50 { } 41 42 T& at(PhysicalBoxSide side) { return m_sides[static_cast<size_t>(side)]; } 43 T& top() { return at(PhysicalBoxSide::Top); } 44 T& right() { return at(PhysicalBoxSide::Right); } 45 T& bottom() { return at(PhysicalBoxSide::Bottom); } 46 T& left() { return at(PhysicalBoxSide::Left); } 47 48 const T& at(PhysicalBoxSide side) const { return m_sides[static_cast<size_t>(side)]; } 49 const T& top() const { return at(PhysicalBoxSide::Top); } 50 const T& right() const { return at(PhysicalBoxSide::Right); } 51 const T& bottom() const { return at(PhysicalBoxSide::Bottom); } 52 const T& left() const { return at(PhysicalBoxSide::Left); } 53 54 void setAt(PhysicalBoxSide side, const T& v) { at(side) = v; } 55 void setTop(const T& top) { setAt(PhysicalBoxSide::Top, top); } 56 void setRight(const T& right) { setAt(PhysicalBoxSide::Right, right); } 57 void setBottom(const T& bottom) { setAt(PhysicalBoxSide::Bottom, bottom); } 58 void setLeft(const T& left) { setAt(PhysicalBoxSide::Left, left); } 59 51 52 T& at(BoxSide side) { return m_sides[static_cast<size_t>(side)]; } 53 T& operator[](BoxSide side) { return m_sides[static_cast<size_t>(side)]; } 54 T& top() { return at(BoxSide::Top); } 55 T& right() { return at(BoxSide::Right); } 56 T& bottom() { return at(BoxSide::Bottom); } 57 T& left() { return at(BoxSide::Left); } 58 59 const T& at(BoxSide side) const { return m_sides[static_cast<size_t>(side)]; } 60 const T& operator[](BoxSide side) const { return m_sides[static_cast<size_t>(side)]; } 61 const T& top() const { return at(BoxSide::Top); } 62 const T& right() const { return at(BoxSide::Right); } 63 const T& bottom() const { return at(BoxSide::Bottom); } 64 const T& left() const { return at(BoxSide::Left); } 65 66 void setAt(BoxSide side, const T& v) { at(side) = v; } 67 void setTop(const T& top) { setAt(BoxSide::Top, top); } 68 void setRight(const T& right) { setAt(BoxSide::Right, right); } 69 void setBottom(const T& bottom) { setAt(BoxSide::Bottom, bottom); } 70 void setLeft(const T& left) { setAt(BoxSide::Left, left); } 71 60 72 T& before(WritingMode writingMode) { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::Before)); } 61 73 T& after(WritingMode writingMode) { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::After)); } 62 74 T& start(WritingMode writingMode, TextDirection direction = TextDirection::LTR) { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::Start)); } 63 75 T& end(WritingMode writingMode, TextDirection direction = TextDirection::LTR) { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::End)); } 64 76 65 77 const T& before(WritingMode writingMode) const { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::Before)); } 66 78 const T& after(WritingMode writingMode) const { return at(mapLogicalSideToPhysicalSide(writingMode, LogicalBoxSide::After)); } 67 79 const T& start(WritingMode writingMode, TextDirection direction = TextDirection::LTR) const { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::Start)); } 68 80 const T& end(WritingMode writingMode, TextDirection direction = TextDirection::LTR) const { return at(mapLogicalSideToPhysicalSide(makeTextFlow(writingMode, direction), LogicalBoxSide::End)); } 69 81 70 82 void setBefore(const T& before, WritingMode writingMode) { this->before(writingMode) = before; } 71 83 void setAfter(const T& after, WritingMode writingMode) { this->after(writingMode) = after; } 72 84 void setStart(const T& start, WritingMode writingMode, TextDirection direction = TextDirection::LTR) { this->start(writingMode, direction) = start; } 73 85 void setEnd(const T& end, WritingMode writingMode, TextDirection direction = TextDirection::LTR) { this->end(writingMode, direction) = end; } 74 86 75 87 bool operator==(const RectEdges& other) const { return m_sides == other.m_sides; } 76 88 bool operator!=(const RectEdges& other) const { return m_sides != other.m_sides; } 77 89 78 90 private: 79 std::array<T, 4> m_sides { {0, 0, 0, 0}};91 std::array<T, 4> m_sides { }; 80 92 }; 81 93 -
trunk/Source/WebCore/platform/text/WritingMode.h
r266691 r269228 32 32 #pragma once 33 33 34 #include <array> 34 35 #include <wtf/EnumTraits.h> 35 36 … … 122 123 }; 123 124 124 enum class PhysicalBoxSide : uint8_t {125 enum class BoxSide : uint8_t { 125 126 Top, 126 127 Right, … … 129 130 }; 130 131 131 inline bool isHorizontalPhysicalSide(PhysicalBoxSide physicalSide) 132 constexpr std::array<BoxSide, 4> allBoxSides = { BoxSide::Top, BoxSide::Right, BoxSide::Bottom, BoxSide::Left }; 133 134 inline bool isHorizontalPhysicalSide(BoxSide physicalSide) 132 135 { 133 return physicalSide == PhysicalBoxSide::Left || physicalSide == PhysicalBoxSide::Right;136 return physicalSide == BoxSide::Left || physicalSide == BoxSide::Right; 134 137 } 135 138 136 inline PhysicalBoxSide mirrorPhysicalSide(PhysicalBoxSide physicalSide)139 inline BoxSide mirrorPhysicalSide(BoxSide physicalSide) 137 140 { 138 141 // top <-> bottom and left <-> right conversion 139 return static_cast< PhysicalBoxSide>((static_cast<int>(physicalSide) + 2) % 4);142 return static_cast<BoxSide>((static_cast<int>(physicalSide) + 2) % 4); 140 143 } 141 144 142 inline PhysicalBoxSide rotatePhysicalSide(PhysicalBoxSide physicalSide)145 inline BoxSide rotatePhysicalSide(BoxSide physicalSide) 143 146 { 144 147 // top <-> left and right <-> bottom conversion 145 148 bool horizontalSide = isHorizontalPhysicalSide(physicalSide); 146 return static_cast< PhysicalBoxSide>((static_cast<int>(physicalSide) + (horizontalSide ? 1 : 3)) % 4);149 return static_cast<BoxSide>((static_cast<int>(physicalSide) + (horizontalSide ? 1 : 3)) % 4); 147 150 } 148 151 149 inline PhysicalBoxSide mapLogicalSideToPhysicalSide(TextFlow textflow, LogicalBoxSide logicalSide)152 inline BoxSide mapLogicalSideToPhysicalSide(TextFlow textflow, LogicalBoxSide logicalSide) 150 153 { 151 PhysicalBoxSide physicalSide = static_cast<PhysicalBoxSide>(logicalSide);154 BoxSide physicalSide = static_cast<BoxSide>(logicalSide); 152 155 bool horizontalSide = isHorizontalPhysicalSide(physicalSide); 153 156 … … 161 164 } 162 165 163 inline PhysicalBoxSide mapLogicalSideToPhysicalSide(WritingMode writingMode, LogicalBoxSide logicalSide)166 inline BoxSide mapLogicalSideToPhysicalSide(WritingMode writingMode, LogicalBoxSide logicalSide) 164 167 { 165 168 // Set the direction such that side is mirrored if isFlippedWritingMode() is true -
trunk/Source/WebCore/rendering/BorderEdge.cpp
r245543 r269228 47 47 } 48 48 49 void BorderEdge::getBorderEdgeInfo(BorderEdge edges[],const RenderStyle& style, float deviceScaleFactor, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)49 BorderEdges borderEdges(const RenderStyle& style, float deviceScaleFactor, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) 50 50 { 51 51 bool horizontal = style.isHorizontalWritingMode(); 52 52 53 edges[BSTop] = BorderEdge(style.borderTopWidth(), style.visitedDependentColorWithColorFilter(CSSPropertyBorderTopColor), style.borderTopStyle(), style.borderTopIsTransparent(), 54 horizontal || includeLogicalLeftEdge, deviceScaleFactor); 55 edges[BSRight] = BorderEdge(style.borderRightWidth(), style.visitedDependentColorWithColorFilter(CSSPropertyBorderRightColor), style.borderRightStyle(), style.borderRightIsTransparent(), 56 !horizontal || includeLogicalRightEdge, deviceScaleFactor); 57 edges[BSBottom] = BorderEdge(style.borderBottomWidth(), style.visitedDependentColorWithColorFilter(CSSPropertyBorderBottomColor), style.borderBottomStyle(), style.borderBottomIsTransparent(), 58 horizontal || includeLogicalRightEdge, deviceScaleFactor); 59 edges[BSLeft] = BorderEdge(style.borderLeftWidth(), style.visitedDependentColorWithColorFilter(CSSPropertyBorderLeftColor), style.borderLeftStyle(), style.borderLeftIsTransparent(), 60 !horizontal || includeLogicalLeftEdge, deviceScaleFactor); 61 } 53 auto constructBorderEdge = [&](float width, CSSPropertyID borderColorProperty, BorderStyle borderStyle, bool isTransparent, bool isPresent) { 54 return BorderEdge(width, style.visitedDependentColorWithColorFilter(borderColorProperty), borderStyle, isTransparent, isPresent, deviceScaleFactor); 55 }; 56 57 return { 58 constructBorderEdge(style.borderTopWidth(), CSSPropertyBorderTopColor, style.borderTopStyle(), style.borderTopIsTransparent(), horizontal || includeLogicalLeftEdge), 59 constructBorderEdge(style.borderRightWidth(), CSSPropertyBorderRightColor, style.borderRightStyle(), style.borderRightIsTransparent(), !horizontal || includeLogicalRightEdge), 60 constructBorderEdge(style.borderBottomWidth(), CSSPropertyBorderBottomColor, style.borderBottomStyle(), style.borderBottomIsTransparent(), horizontal || includeLogicalRightEdge), 61 constructBorderEdge(style.borderLeftWidth(), CSSPropertyBorderLeftColor, style.borderLeftStyle(), style.borderLeftIsTransparent(), !horizontal || includeLogicalLeftEdge) 62 }; 63 } 62 64 63 65 bool BorderEdge::obscuresBackgroundEdge(float scale) const -
trunk/Source/WebCore/rendering/BorderEdge.h
r239563 r269228 28 28 #include "Color.h" 29 29 #include "LayoutUnit.h" 30 #include "RectEdges.h" 30 31 #include "RenderObjectEnums.h" 31 32 #include "RenderStyleConstants.h" 33 #include <wtf/OptionSet.h> 32 34 33 35 namespace WebCore { 34 35 typedef unsigned BorderEdgeFlags;36 36 37 37 class RenderStyle; … … 39 39 class BorderEdge { 40 40 public: 41 enum BorderEdgeFlag {42 TopBorderEdge = 1 << BSTop,43 RightBorderEdge = 1 << BSRight,44 BottomBorderEdge = 1 << BSBottom,45 LeftBorderEdge = 1 << BSLeft,46 AllBorderEdges = TopBorderEdge | BottomBorderEdge | LeftBorderEdge | RightBorderEdge47 };48 49 41 BorderEdge() = default; 50 42 BorderEdge(float edgeWidth, Color edgeColor, BorderStyle edgeStyle, bool edgeIsTransparent, bool edgeIsPresent, float devicePixelRatio); 51 52 static void getBorderEdgeInfo(BorderEdge edges[], const RenderStyle&, float deviceScaleFactor, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);53 43 54 44 BorderStyle style() const { return m_style; } … … 77 67 }; 78 68 69 using BorderEdges = RectEdges<BorderEdge>; 70 BorderEdges borderEdges(const RenderStyle&, float deviceScaleFactor, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true); 71 79 72 inline bool edgesShareColor(const BorderEdge& firstEdge, const BorderEdge& secondEdge) { return firstEdge.color() == secondEdge.color(); } 80 inline BorderEdge::BorderEdgeFlag edgeFlagForSide(BoxSide side) { return static_cast<BorderEdge::BorderEdgeFlag>(1 << side); } 81 inline bool includesEdge(BorderEdgeFlags flags, BoxSide side) { return flags & edgeFlagForSide(side); } 82 inline bool includesAdjacentEdges(BorderEdgeFlags flags) 73 inline BoxSideFlag edgeFlagForSide(BoxSide side) { return static_cast<BoxSideFlag>(1 << static_cast<unsigned>(side)); } 74 inline bool includesEdge(OptionSet<BoxSideFlag> flags, BoxSide side) { return flags.contains(edgeFlagForSide(side)); } 75 76 inline bool includesAdjacentEdges(OptionSet<BoxSideFlag> flags) 83 77 { 84 return (flags & (BorderEdge::TopBorderEdge | BorderEdge::RightBorderEdge)) == (BorderEdge::TopBorderEdge | BorderEdge::RightBorderEdge)85 || (flags & (BorderEdge::RightBorderEdge | BorderEdge::BottomBorderEdge)) == (BorderEdge::RightBorderEdge | BorderEdge::BottomBorderEdge)86 || (flags & (BorderEdge::BottomBorderEdge | BorderEdge::LeftBorderEdge)) == (BorderEdge::BottomBorderEdge | BorderEdge::LeftBorderEdge)87 || (flags & (BorderEdge::LeftBorderEdge | BorderEdge::TopBorderEdge)) == (BorderEdge::LeftBorderEdge | BorderEdge::TopBorderEdge);78 return flags.containsAll({ BoxSideFlag::Top, BoxSideFlag::Right }) 79 || flags.containsAll({ BoxSideFlag::Right, BoxSideFlag::Bottom }) 80 || flags.containsAll({ BoxSideFlag::Bottom, BoxSideFlag::Left }) 81 || flags.containsAll({ BoxSideFlag::Left, BoxSideFlag::Top }); 88 82 } 89 83 -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r268919 r269228 1456 1456 } 1457 1457 1458 static bool borderWillArcInnerEdge(const LayoutSize& firstRadius, const FloatSize& secondRadius)1458 static bool borderWillArcInnerEdge(const LayoutSize& firstRadius, const LayoutSize& secondRadius) 1459 1459 { 1460 1460 return !firstRadius.isZero() || !secondRadius.isZero(); … … 1487 1487 // These styles match at the top/left and bottom/right. 1488 1488 if (style == BorderStyle::Inset || style == BorderStyle::Groove || style == BorderStyle::Ridge || style == BorderStyle::Outset) { 1489 const BorderEdgeFlags topRightFlags = edgeFlagForSide(BSTop) | edgeFlagForSide(BSRight);1490 const BorderEdgeFlags bottomLeftFlags = edgeFlagForSide(BSBottom) | edgeFlagForSide(BSLeft);1491 1492 Bo rderEdgeFlags flags = edgeFlagForSide(side) | edgeFlagForSide(adjacentSide);1493 return flags == topRightFlags || flags == bottomLeftFlags;1489 BoxSideSet topRightSides = { BoxSideFlag::Top, BoxSideFlag::Right }; 1490 BoxSideSet bottomLeftSides = { BoxSideFlag::Bottom, BoxSideFlag::Left }; 1491 1492 BoxSideSet usedSides { edgeFlagForSide(side), edgeFlagForSide(adjacentSide) }; 1493 return usedSides == topRightSides || usedSides == bottomLeftSides; 1494 1494 } 1495 1495 return false; 1496 1496 } 1497 1497 1498 static inline bool colorsMatchAtCorner(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[]) 1499 { 1500 if (edges[side].shouldRender() != edges[adjacentSide].shouldRender()) 1501 return false; 1502 1503 if (!edgesShareColor(edges[side], edges[adjacentSide])) 1504 return false; 1505 1506 return !borderStyleHasUnmatchedColorsAtCorner(edges[side].style(), side, adjacentSide); 1507 } 1508 1509 1510 static inline bool colorNeedsAntiAliasAtCorner(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[]) 1511 { 1512 if (edges[side].color().isOpaque()) 1513 return false; 1514 1515 if (edges[side].shouldRender() != edges[adjacentSide].shouldRender()) 1516 return false; 1517 1518 if (!edgesShareColor(edges[side], edges[adjacentSide])) 1498 static inline bool colorsMatchAtCorner(BoxSide side, BoxSide adjacentSide, const BorderEdges& edges) 1499 { 1500 auto& edge = edges.at(side); 1501 auto& adjacentEdge = edges.at(adjacentSide); 1502 1503 if (edge.shouldRender() != adjacentEdge.shouldRender()) 1504 return false; 1505 1506 if (!edgesShareColor(edge, adjacentEdge)) 1507 return false; 1508 1509 return !borderStyleHasUnmatchedColorsAtCorner(edge.style(), side, adjacentSide); 1510 } 1511 1512 1513 static inline bool colorNeedsAntiAliasAtCorner(BoxSide side, BoxSide adjacentSide, const BorderEdges& edges) 1514 { 1515 auto& edge = edges.at(side); 1516 auto& adjacentEdge = edges.at(adjacentSide); 1517 1518 if (edge.color().isOpaque()) 1519 return false; 1520 1521 if (edge.shouldRender() != adjacentEdge.shouldRender()) 1522 return false; 1523 1524 if (!edgesShareColor(edge, adjacentEdge)) 1519 1525 return true; 1520 1526 1521 return borderStyleHasUnmatchedColorsAtCorner(edge s[side].style(), side, adjacentSide);1527 return borderStyleHasUnmatchedColorsAtCorner(edge.style(), side, adjacentSide); 1522 1528 } 1523 1529 1524 1530 // This assumes that we draw in order: top, bottom, left, right. 1525 static inline bool willBeOverdrawn(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[])1531 static inline bool willBeOverdrawn(BoxSide side, BoxSide adjacentSide, const BorderEdges& edges) 1526 1532 { 1527 1533 switch (side) { 1528 case BSTop: 1529 case BSBottom: 1530 if (edges[adjacentSide].presentButInvisible()) 1534 case BoxSide::Top: 1535 case BoxSide::Bottom: { 1536 auto& edge = edges.at(side); 1537 auto& adjacentEdge = edges.at(adjacentSide); 1538 1539 if (adjacentEdge.presentButInvisible()) 1531 1540 return false; 1532 1541 1533 if (!edgesShareColor(edge s[side], edges[adjacentSide]) && !edges[adjacentSide].color().isOpaque())1542 if (!edgesShareColor(edge, adjacentEdge) && !adjacentEdge.color().isOpaque()) 1534 1543 return false; 1535 1544 1536 if (!borderStyleFillsBorderArea( edges[adjacentSide].style()))1545 if (!borderStyleFillsBorderArea(adjacentEdge.style())) 1537 1546 return false; 1538 1547 1539 1548 return true; 1540 1541 case B SLeft:1542 case B SRight:1549 } 1550 case BoxSide::Left: 1551 case BoxSide::Right: 1543 1552 // These draw last, so are never overdrawn. 1544 1553 return false; … … 1561 1570 } 1562 1571 1563 static bool joinRequiresMitre(BoxSide side, BoxSide adjacentSide, const BorderEdge edges[], bool allowOverdraw) 1564 { 1565 if ((edges[side].isTransparent() && edges[adjacentSide].isTransparent()) || !edges[adjacentSide].isPresent()) 1572 static bool joinRequiresMitre(BoxSide side, BoxSide adjacentSide, const BorderEdges& edges, bool allowOverdraw) 1573 { 1574 auto& edge = edges.at(side); 1575 auto& adjacentEdge = edges.at(adjacentSide); 1576 1577 if ((edge.isTransparent() && adjacentEdge.isTransparent()) || !adjacentEdge.isPresent()) 1566 1578 return false; 1567 1579 … … 1569 1581 return false; 1570 1582 1571 if (!edgesShareColor(edge s[side], edges[adjacentSide]))1583 if (!edgesShareColor(edge, adjacentEdge)) 1572 1584 return true; 1573 1585 1574 if (borderStylesRequireMitre(side, adjacentSide, edge s[side].style(), edges[adjacentSide].style()))1586 if (borderStylesRequireMitre(side, adjacentSide, edge.style(), adjacentEdge.style())) 1575 1587 return true; 1576 1588 … … 1590 1602 1591 1603 switch (side) { 1592 case B STop:1604 case BoxSide::Top: 1593 1605 overshoot = newRadii.topLeft().width() + newRadii.topRight().width() - newRect.width(); 1594 1606 if (overshoot > 0) { … … 1598 1610 newRect.move(-overshoot, 0); 1599 1611 } 1600 newRadii.setBottomLeft( IntSize(0, 0));1601 newRadii.setBottomRight( IntSize(0, 0));1612 newRadii.setBottomLeft({ }); 1613 newRadii.setBottomRight({ }); 1602 1614 maxRadii = std::max(newRadii.topLeft().height(), newRadii.topRight().height()); 1603 1615 if (maxRadii > newRect.height()) … … 1605 1617 break; 1606 1618 1607 case B SBottom:1619 case BoxSide::Bottom: 1608 1620 overshoot = newRadii.bottomLeft().width() + newRadii.bottomRight().width() - newRect.width(); 1609 1621 if (overshoot > 0) { … … 1613 1625 newRect.move(-overshoot, 0); 1614 1626 } 1615 newRadii.setTopLeft( IntSize(0, 0));1616 newRadii.setTopRight( IntSize(0, 0));1627 newRadii.setTopLeft({ }); 1628 newRadii.setTopRight({ }); 1617 1629 maxRadii = std::max(newRadii.bottomLeft().height(), newRadii.bottomRight().height()); 1618 1630 if (maxRadii > newRect.height()) { … … 1622 1634 break; 1623 1635 1624 case B SLeft:1636 case BoxSide::Left: 1625 1637 overshoot = newRadii.topLeft().height() + newRadii.bottomLeft().height() - newRect.height(); 1626 1638 if (overshoot > 0) { … … 1630 1642 newRect.move(0, -overshoot); 1631 1643 } 1632 newRadii.setTopRight( IntSize(0, 0));1633 newRadii.setBottomRight( IntSize(0, 0));1644 newRadii.setTopRight({ }); 1645 newRadii.setBottomRight({ }); 1634 1646 maxRadii = std::max(newRadii.topLeft().width(), newRadii.bottomLeft().width()); 1635 1647 if (maxRadii > newRect.width()) … … 1637 1649 break; 1638 1650 1639 case B SRight:1651 case BoxSide::Right: 1640 1652 overshoot = newRadii.topRight().height() + newRadii.bottomRight().height() - newRect.height(); 1641 1653 if (overshoot > 0) { … … 1645 1657 newRect.move(0, -overshoot); 1646 1658 } 1647 newRadii.setTopLeft( IntSize(0, 0));1648 newRadii.setBottomLeft( IntSize(0, 0));1659 newRadii.setTopLeft({ }); 1660 newRadii.setBottomLeft({ }); 1649 1661 maxRadii = std::max(newRadii.topRight().width(), newRadii.bottomRight().width()); 1650 1662 if (maxRadii > newRect.width()) { … … 1659 1671 1660 1672 void RenderBoxModelObject::paintOneBorderSide(GraphicsContext& graphicsContext, const RenderStyle& style, const RoundedRect& outerBorder, const RoundedRect& innerBorder, 1661 const LayoutRect& sideRect, BoxSide side, BoxSide adjacentSide1, BoxSide adjacentSide2, const BorderEdge edges[], const Path* path,1673 const LayoutRect& sideRect, BoxSide side, BoxSide adjacentSide1, BoxSide adjacentSide2, const BorderEdges& edges, const Path* path, 1662 1674 BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias, const Color* overrideColor) 1663 1675 { 1664 const BorderEdge& edgeToRender = edges[side];1676 auto& edgeToRender = edges.at(side); 1665 1677 ASSERT(edgeToRender.widthForPainting()); 1666 const BorderEdge& adjacentEdge1 = edges[adjacentSide1];1667 const BorderEdge& adjacentEdge2 = edges[adjacentSide2];1678 auto& adjacentEdge1 = edges.at(adjacentSide1); 1679 auto& adjacentEdge2 = edges.at(adjacentSide2); 1668 1680 1669 1681 bool mitreAdjacentSide1 = joinRequiresMitre(side, adjacentSide1, edges, !antialias); … … 1705 1717 } 1706 1718 1707 static LayoutRect calculateSideRect(const RoundedRect& outerBorder, const BorderEdge edges[], intside)1719 static LayoutRect calculateSideRect(const RoundedRect& outerBorder, const BorderEdges& edges, BoxSide side) 1708 1720 { 1709 1721 LayoutRect sideRect = outerBorder.rect(); 1710 float width = edges[side].widthForPainting(); 1711 1712 if (side == BSTop) 1722 float width = edges.at(side).widthForPainting(); 1723 1724 switch (side) { 1725 case BoxSide::Top: 1713 1726 sideRect.setHeight(width); 1714 else if (side == BSBottom) 1727 break; 1728 case BoxSide::Right: 1729 sideRect.shiftXEdgeTo(sideRect.maxX() - width); 1730 break; 1731 case BoxSide::Bottom: 1715 1732 sideRect.shiftYEdgeTo(sideRect.maxY() - width); 1716 else if (side == BSLeft) 1733 break; 1734 case BoxSide::Left: 1717 1735 sideRect.setWidth(width); 1718 else1719 sideRect.shiftXEdgeTo(sideRect.maxX() - width);1736 break; 1737 } 1720 1738 1721 1739 return sideRect; … … 1723 1741 1724 1742 void RenderBoxModelObject::paintBorderSides(GraphicsContext& graphicsContext, const RenderStyle& style, const RoundedRect& outerBorder, const RoundedRect& innerBorder, 1725 const IntPoint& innerBorderAdjustment, const BorderEdge edges[], BorderEdgeFlagsedgeSet, BackgroundBleedAvoidance bleedAvoidance,1743 const IntPoint& innerBorderAdjustment, const BorderEdges& edges, BoxSideSet edgeSet, BackgroundBleedAvoidance bleedAvoidance, 1726 1744 bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias, const Color* overrideColor) 1727 1745 { … … 1737 1755 // only depends on sideRect when painting solid borders. 1738 1756 1739 if (edges[BSTop].shouldRender() && includesEdge(edgeSet, BSTop)) { 1757 auto paintOneSide = [&](BoxSide side, BoxSide adjacentSide1, BoxSide adjacentSide2) { 1758 auto& edge = edges.at(side); 1759 if (!edge.shouldRender() || !edgeSet.contains(edgeFlagForSide(side))) 1760 return; 1761 1740 1762 LayoutRect sideRect = outerBorder.rect(); 1741 sideRect.setHeight(edges[BSTop].widthForPainting() + innerBorderAdjustment.y()); 1742 1743 bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSTop].style()) || borderWillArcInnerEdge(innerBorder.radii().topLeft(), innerBorder.radii().topRight())); 1744 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, BSTop, BSLeft, BSRight, edges, usePath ? &roundedPath : nullptr, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); 1745 } 1746 1747 if (edges[BSBottom].shouldRender() && includesEdge(edgeSet, BSBottom)) { 1748 LayoutRect sideRect = outerBorder.rect(); 1749 sideRect.shiftYEdgeTo(sideRect.maxY() - edges[BSBottom].widthForPainting() - innerBorderAdjustment.y()); 1750 1751 bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSBottom].style()) || borderWillArcInnerEdge(innerBorder.radii().bottomLeft(), innerBorder.radii().bottomRight())); 1752 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, BSBottom, BSLeft, BSRight, edges, usePath ? &roundedPath : nullptr, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); 1753 } 1754 1755 if (edges[BSLeft].shouldRender() && includesEdge(edgeSet, BSLeft)) { 1756 LayoutRect sideRect = outerBorder.rect(); 1757 sideRect.setWidth(edges[BSLeft].widthForPainting() + innerBorderAdjustment.x()); 1758 1759 bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSLeft].style()) || borderWillArcInnerEdge(innerBorder.radii().bottomLeft(), innerBorder.radii().topLeft())); 1760 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, BSLeft, BSTop, BSBottom, edges, usePath ? &roundedPath : nullptr, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); 1761 } 1762 1763 if (edges[BSRight].shouldRender() && includesEdge(edgeSet, BSRight)) { 1764 LayoutRect sideRect = outerBorder.rect(); 1765 sideRect.shiftXEdgeTo(sideRect.maxX() - edges[BSRight].widthForPainting() - innerBorderAdjustment.x()); 1766 1767 bool usePath = renderRadii && (borderStyleHasInnerDetail(edges[BSRight].style()) || borderWillArcInnerEdge(innerBorder.radii().bottomRight(), innerBorder.radii().topRight())); 1768 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, BSRight, BSTop, BSBottom, edges, usePath ? &roundedPath : nullptr, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); 1769 } 1763 LayoutSize firstRadius; 1764 LayoutSize secondRadius; 1765 1766 switch (side) { 1767 case BoxSide::Top: 1768 sideRect.setHeight(edge.widthForPainting() + innerBorderAdjustment.y()); 1769 firstRadius = innerBorder.radii().topLeft(); 1770 secondRadius = innerBorder.radii().topRight(); 1771 break; 1772 case BoxSide::Right: 1773 sideRect.shiftXEdgeTo(sideRect.maxX() - edge.widthForPainting() - innerBorderAdjustment.x()); 1774 firstRadius = innerBorder.radii().bottomRight(); 1775 secondRadius = innerBorder.radii().topRight(); 1776 break; 1777 case BoxSide::Bottom: 1778 sideRect.shiftYEdgeTo(sideRect.maxY() - edge.widthForPainting() - innerBorderAdjustment.y()); 1779 firstRadius = innerBorder.radii().bottomLeft(); 1780 secondRadius = innerBorder.radii().bottomRight(); 1781 break; 1782 case BoxSide::Left: 1783 sideRect.setWidth(edge.widthForPainting() + innerBorderAdjustment.x()); 1784 firstRadius = innerBorder.radii().bottomLeft(); 1785 secondRadius = innerBorder.radii().topLeft(); 1786 break; 1787 } 1788 1789 bool usePath = renderRadii && (borderStyleHasInnerDetail(edge.style()) || borderWillArcInnerEdge(firstRadius, secondRadius)); 1790 paintOneBorderSide(graphicsContext, style, outerBorder, innerBorder, sideRect, side, adjacentSide1, adjacentSide2, edges, usePath ? &roundedPath : nullptr, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias, overrideColor); 1791 }; 1792 1793 paintOneSide(BoxSide::Top, BoxSide::Left, BoxSide::Right); 1794 paintOneSide(BoxSide::Bottom, BoxSide::Left, BoxSide::Right); 1795 paintOneSide(BoxSide::Left, BoxSide::Top, BoxSide::Bottom); 1796 paintOneSide(BoxSide::Right, BoxSide::Top, BoxSide::Bottom); 1770 1797 } 1771 1798 1772 1799 void RenderBoxModelObject::paintTranslucentBorderSides(GraphicsContext& graphicsContext, const RenderStyle& style, const RoundedRect& outerBorder, const RoundedRect& innerBorder, const IntPoint& innerBorderAdjustment, 1773 const BorderEdge edges[], BorderEdgeFlagsedgesToDraw, BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias)1800 const BorderEdges& edges, BoxSideSet edgesToDraw, BackgroundBleedAvoidance bleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias) 1774 1801 { 1775 1802 // willBeOverdrawn assumes that we draw in order: top, bottom, left, right. 1776 1803 // This is different from BoxSide enum order. 1777 static const BoxSide paintOrder[] = { BSTop, BSBottom, BSLeft, BSRight };1804 static constexpr std::array<BoxSide, 4> paintOrderSides = { BoxSide::Top, BoxSide::Bottom, BoxSide::Left, BoxSide::Right }; 1778 1805 1779 1806 while (edgesToDraw) { … … 1781 1808 Color commonColor; 1782 1809 1783 BorderEdgeFlags commonColorEdgeSet = 0; 1784 for (size_t i = 0; i < sizeof(paintOrder) / sizeof(paintOrder[0]); ++i) { 1785 BoxSide currSide = paintOrder[i]; 1786 if (!includesEdge(edgesToDraw, currSide)) 1810 BoxSideSet commonColorEdgeSet; 1811 for (auto side : paintOrderSides) { 1812 if (!edgesToDraw.contains(edgeFlagForSide(side))) 1787 1813 continue; 1788 1814 1815 auto& edge = edges.at(side); 1789 1816 bool includeEdge; 1790 if ( !commonColorEdgeSet) {1791 commonColor = edge s[currSide].color();1817 if (commonColorEdgeSet.isEmpty()) { 1818 commonColor = edge.color(); 1792 1819 includeEdge = true; 1793 1820 } else 1794 includeEdge = edge s[currSide].color() == commonColor;1821 includeEdge = edge.color() == commonColor; 1795 1822 1796 1823 if (includeEdge) 1797 commonColorEdgeSet |= edgeFlagForSide(currSide);1824 commonColorEdgeSet.add(edgeFlagForSide(side)); 1798 1825 } 1799 1826 … … 1809 1836 graphicsContext.endTransparencyLayer(); 1810 1837 1811 edgesToDraw &= ~commonColorEdgeSet;1838 edgesToDraw.remove(commonColorEdgeSet); 1812 1839 } 1813 1840 } … … 1834 1861 return; 1835 1862 1836 BorderEdge edges[4]; 1837 BorderEdge::getBorderEdgeInfo(edges, style, document().deviceScaleFactor(), includeLogicalLeftEdge, includeLogicalRightEdge); 1863 auto edges = borderEdges(style, document().deviceScaleFactor(), includeLogicalLeftEdge, includeLogicalRightEdge); 1838 1864 RoundedRect outerBorder = style.getRoundedBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge); 1839 1865 RoundedRect innerBorder = style.getRoundedInnerBorderFor(borderInnerRectAdjustedForBleedAvoidance(graphicsContext, rect, bleedAvoidance), includeLogicalLeftEdge, includeLogicalRightEdge); … … 1848 1874 int numEdgesVisible = 4; 1849 1875 bool allEdgesShareColor = true; 1850 int firstVisibleEdge = -1;1851 Bo rderEdgeFlags edgesToDraw = 0;1852 1853 for ( int i = BSTop; i <= BSLeft; ++i) {1854 const BorderEdge& currEdge = edges[i];1855 1856 if ( edges[i].shouldRender())1857 edgesToDraw |= edgeFlagForSide(static_cast<BoxSide>(i));1876 Optional<BoxSide> firstVisibleSide; 1877 BoxSideSet edgesToDraw; 1878 1879 for (auto side : allBoxSides) { 1880 auto& currEdge = edges.at(side); 1881 1882 if (currEdge.shouldRender()) 1883 edgesToDraw.add(edgeFlagForSide(side)); 1858 1884 1859 1885 if (currEdge.presentButInvisible()) { … … 1868 1894 } 1869 1895 1870 if ( firstVisibleEdge == -1)1871 firstVisible Edge = i;1872 else if (currEdge.color() != edges [firstVisibleEdge].color())1896 if (!firstVisibleSide) 1897 firstVisibleSide = side; 1898 else if (currEdge.color() != edges.at(*firstVisibleSide).color()) 1873 1899 allEdgesShareColor = false; 1874 1900 … … 1905 1931 LayoutRect innerThirdRect = outerBorder.rect(); 1906 1932 LayoutRect outerThirdRect = outerBorder.rect(); 1907 for ( int side = BSTop; side <= BSLeft; ++side) {1933 for (auto side : allBoxSides) { 1908 1934 LayoutUnit outerWidth; 1909 1935 LayoutUnit innerWidth; 1910 edges [side].getDoubleBorderStripeWidths(outerWidth, innerWidth);1911 1912 if (side == BSTop) {1936 edges.at(side).getDoubleBorderStripeWidths(outerWidth, innerWidth); 1937 switch (side) { 1938 case BoxSide::Top: 1913 1939 innerThirdRect.shiftYEdgeTo(innerThirdRect.y() + innerWidth); 1914 1940 outerThirdRect.shiftYEdgeTo(outerThirdRect.y() + outerWidth); 1915 } else if (side == BSBottom) { 1941 break; 1942 case BoxSide::Right: 1943 innerThirdRect.setWidth(innerThirdRect.width() - innerWidth); 1944 outerThirdRect.setWidth(outerThirdRect.width() - outerWidth); 1945 break; 1946 case BoxSide::Bottom: 1916 1947 innerThirdRect.setHeight(innerThirdRect.height() - innerWidth); 1917 1948 outerThirdRect.setHeight(outerThirdRect.height() - outerWidth); 1918 } else if (side == BSLeft) { 1949 break; 1950 case BoxSide::Left: 1919 1951 innerThirdRect.shiftXEdgeTo(innerThirdRect.x() + innerWidth); 1920 1952 outerThirdRect.shiftXEdgeTo(outerThirdRect.x() + outerWidth); 1921 } else { 1922 innerThirdRect.setWidth(innerThirdRect.width() - innerWidth); 1923 outerThirdRect.setWidth(outerThirdRect.width() - outerWidth); 1953 break; 1924 1954 } 1925 1955 } … … 1948 1978 1949 1979 graphicsContext.setFillRule(WindRule::EvenOdd); 1950 graphicsContext.setFillColor(edges [firstVisibleEdge].color());1980 graphicsContext.setFillColor(edges.at(*firstVisibleSide).color()); 1951 1981 graphicsContext.fillPath(path); 1952 1982 return; … … 1956 1986 Path path; 1957 1987 1958 for (int i = BSTop; i <= BSLeft; ++i) { 1959 const BorderEdge& currEdge = edges[i]; 1960 if (currEdge.shouldRender()) { 1961 LayoutRect sideRect = calculateSideRect(outerBorder, edges, i); 1962 path.addRect(sideRect); 1988 for (auto side : allBoxSides) { 1989 if (edges.at(side).shouldRender()) { 1990 auto sideRect = calculateSideRect(outerBorder, edges, side); 1991 path.addRect(sideRect); // FIXME: Need pixel snapping here. 1963 1992 } 1964 1993 } 1965 1994 1966 1995 graphicsContext.setFillRule(WindRule::NonZero); 1967 graphicsContext.setFillColor(edges [firstVisibleEdge].color());1996 graphicsContext.setFillColor(edges.at(*firstVisibleSide).color()); 1968 1997 graphicsContext.fillPath(path); 1969 1998 return; … … 1993 2022 } 1994 2023 1995 void RenderBoxModelObject::drawBoxSideFromPath(GraphicsContext& graphicsContext, const LayoutRect& borderRect, const Path& borderPath, const BorderEdge edges[],2024 void RenderBoxModelObject::drawBoxSideFromPath(GraphicsContext& graphicsContext, const LayoutRect& borderRect, const Path& borderPath, const BorderEdges& edges, 1996 2025 float thickness, float drawThickness, BoxSide side, const RenderStyle& style, Color color, BorderStyle borderStyle, BackgroundBleedAvoidance bleedAvoidance, 1997 2026 bool includeLogicalLeftEdge, bool includeLogicalRightEdge) … … 2052 2081 LayoutUnit outerBorderTopWidth; 2053 2082 LayoutUnit innerBorderTopWidth; 2054 edges [BSTop].getDoubleBorderStripeWidths(outerBorderTopWidth, innerBorderTopWidth);2083 edges.top().getDoubleBorderStripeWidths(outerBorderTopWidth, innerBorderTopWidth); 2055 2084 2056 2085 LayoutUnit outerBorderRightWidth; 2057 2086 LayoutUnit innerBorderRightWidth; 2058 edges [BSRight].getDoubleBorderStripeWidths(outerBorderRightWidth, innerBorderRightWidth);2087 edges.right().getDoubleBorderStripeWidths(outerBorderRightWidth, innerBorderRightWidth); 2059 2088 2060 2089 LayoutUnit outerBorderBottomWidth; 2061 2090 LayoutUnit innerBorderBottomWidth; 2062 edges [BSBottom].getDoubleBorderStripeWidths(outerBorderBottomWidth, innerBorderBottomWidth);2091 edges.bottom().getDoubleBorderStripeWidths(outerBorderBottomWidth, innerBorderBottomWidth); 2063 2092 2064 2093 LayoutUnit outerBorderLeftWidth; 2065 2094 LayoutUnit innerBorderLeftWidth; 2066 edges [BSLeft].getDoubleBorderStripeWidths(outerBorderLeftWidth, innerBorderLeftWidth);2095 edges.left().getDoubleBorderStripeWidths(outerBorderLeftWidth, innerBorderLeftWidth); 2067 2096 2068 2097 // Draw inner border line … … 2115 2144 // Paint inner only 2116 2145 GraphicsContextStateSaver stateSaver(graphicsContext); 2117 LayoutUnit topWidth { edges [BSTop].widthForPainting() / 2 };2118 LayoutUnit bottomWidth { edges [BSBottom].widthForPainting() / 2 };2119 LayoutUnit leftWidth { edges [BSLeft].widthForPainting() / 2 };2120 LayoutUnit rightWidth { edges [BSRight].widthForPainting() / 2 };2146 LayoutUnit topWidth { edges.top().widthForPainting() / 2 }; 2147 LayoutUnit bottomWidth { edges.bottom().widthForPainting() / 2 }; 2148 LayoutUnit leftWidth { edges.left().widthForPainting() / 2 }; 2149 LayoutUnit rightWidth { edges.right().widthForPainting() / 2 }; 2121 2150 2122 2151 RoundedRect clipRect = style.getRoundedInnerBorderFor(borderRect, … … 2165 2194 quad.reserveInitialCapacity(4); 2166 2195 switch (side) { 2167 case B STop:2196 case BoxSide::Top: 2168 2197 quad.uncheckedAppend(outerRect.minXMinYCorner()); 2169 2198 quad.uncheckedAppend(innerRect.minXMinYCorner()); … … 2178 2207 break; 2179 2208 2180 case B SLeft:2209 case BoxSide::Left: 2181 2210 quad.uncheckedAppend(outerRect.minXMinYCorner()); 2182 2211 quad.uncheckedAppend(innerRect.minXMinYCorner()); … … 2191 2220 break; 2192 2221 2193 case B SBottom:2222 case BoxSide::Bottom: 2194 2223 quad.uncheckedAppend(outerRect.minXMaxYCorner()); 2195 2224 quad.uncheckedAppend(innerRect.minXMaxYCorner()); … … 2204 2233 break; 2205 2234 2206 case B SRight:2235 case BoxSide::Right: 2207 2236 quad.uncheckedAppend(outerRect.maxXMinYCorner()); 2208 2237 quad.uncheckedAppend(innerRect.maxXMinYCorner()); … … 2233 2262 quad[1], 2234 2263 quad[2], 2235 side == B STop || side == BSBottom ? FloatPoint(quad[3].x(), quad[2].y()) : FloatPoint(quad[2].x(), quad[3].y()),2264 side == BoxSide::Top || side == BoxSide::Bottom ? FloatPoint(quad[3].x(), quad[2].y()) : FloatPoint(quad[2].x(), quad[3].y()), 2236 2265 quad[3] 2237 2266 }; … … 2242 2271 Vector<FloatPoint> secondQuad = { 2243 2272 quad[0], 2244 side == B STop || side == BSBottom ? FloatPoint(quad[0].x(), quad[1].y()) : FloatPoint(quad[1].x(), quad[0].y()),2273 side == BoxSide::Top || side == BoxSide::Bottom ? FloatPoint(quad[0].x(), quad[1].y()) : FloatPoint(quad[1].x(), quad[0].y()), 2245 2274 quad[1], 2246 2275 quad[2], … … 2256 2285 bool RenderBoxModelObject::borderObscuresBackgroundEdge(const FloatSize& contextScale) const 2257 2286 { 2258 BorderEdge edges[4]; 2259 BorderEdge::getBorderEdgeInfo(edges, style(), document().deviceScaleFactor()); 2260 2261 for (int i = BSTop; i <= BSLeft; ++i) { 2262 const BorderEdge& currEdge = edges[i]; 2287 auto edges = borderEdges(style(), document().deviceScaleFactor()); 2288 2289 for (auto side : allBoxSides) { 2290 auto& currEdge = edges.at(side); 2263 2291 // FIXME: for vertical text 2264 float axisScale = ( i == BSTop || i == BSBottom) ? contextScale.height() : contextScale.width();2292 float axisScale = (side == BoxSide::Top || side == BoxSide::Bottom) ? contextScale.height() : contextScale.width(); 2265 2293 if (!currEdge.obscuresBackgroundEdge(axisScale)) 2266 2294 return false; … … 2279 2307 return false; 2280 2308 2281 BorderEdge edges[4]; 2282 BorderEdge::getBorderEdgeInfo(edges, style(), document().deviceScaleFactor()); 2283 2284 for (int i = BSTop; i <= BSLeft; ++i) { 2285 const BorderEdge& currEdge = edges[i]; 2286 if (!currEdge.obscuresBackground()) 2309 auto edges = borderEdges(style(), document().deviceScaleFactor()); 2310 2311 for (auto side : allBoxSides) { 2312 if (!edges.at(side).obscuresBackground()) 2287 2313 return false; 2288 2314 } -
trunk/Source/WebCore/rendering/RenderBoxModelObject.h
r268919 r269228 26 26 #include "FontBaseline.h" 27 27 #include "LayoutRect.h" 28 #include "RectEdges.h" 28 29 #include "RenderLayerModelObject.h" 29 30 … … 33 34 enum LinePositionMode { PositionOnContainingLine, PositionOfInteriorLineBoxes }; 34 35 enum LineDirectionMode { HorizontalLine, VerticalLine }; 35 typedef unsigned BorderEdgeFlags;36 36 37 37 enum BackgroundBleedAvoidance { … … 63 63 class RenderTextFragment; 64 64 class StickyPositionViewportConstraints; 65 66 enum class BoxSideFlag : uint8_t; 67 using BoxSideSet = OptionSet<BoxSideFlag>; 68 using BorderEdges = RectEdges<BorderEdge>; 65 69 66 70 class BackgroundImageGeometry { … … 314 318 315 319 void paintOneBorderSide(GraphicsContext&, const RenderStyle&, const RoundedRect& outerBorder, const RoundedRect& innerBorder, 316 const LayoutRect& sideRect, BoxSide, BoxSide adjacentSide1, BoxSide adjacentSide2, const BorderEdge [],320 const LayoutRect& sideRect, BoxSide, BoxSide adjacentSide1, BoxSide adjacentSide2, const BorderEdges&, 317 321 const Path*, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias, const Color* overrideColor = nullptr); 318 322 void paintTranslucentBorderSides(GraphicsContext&, const RenderStyle&, const RoundedRect& outerBorder, const RoundedRect& innerBorder, const IntPoint& innerBorderAdjustment, 319 const BorderEdge [], BorderEdgeFlags, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias = false);323 const BorderEdges&, BoxSideSet, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias = false); 320 324 void paintBorderSides(GraphicsContext&, const RenderStyle&, const RoundedRect& outerBorder, const RoundedRect& innerBorder, 321 const IntPoint& innerBorderAdjustment, const BorderEdge [], BorderEdgeFlags, BackgroundBleedAvoidance,325 const IntPoint& innerBorderAdjustment, const BorderEdges&, BoxSideSet, BackgroundBleedAvoidance, 322 326 bool includeLogicalLeftEdge, bool includeLogicalRightEdge, bool antialias = false, const Color* overrideColor = nullptr); 323 void drawBoxSideFromPath(GraphicsContext&, const LayoutRect&, const Path&, const BorderEdge [],327 void drawBoxSideFromPath(GraphicsContext&, const LayoutRect&, const Path&, const BorderEdges&, 324 328 float thickness, float drawThickness, BoxSide, const RenderStyle&, 325 329 Color, BorderStyle, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge); -
trunk/Source/WebCore/rendering/RenderElement.cpp
r269144 r269228 1703 1703 float thickness; 1704 1704 float length; 1705 if (side == B STop || side == BSBottom) {1705 if (side == BoxSide::Top || side == BoxSide::Bottom) { 1706 1706 thickness = y2 - y1; 1707 1707 length = x2 - x1; … … 1749 1749 1750 1750 switch (side) { 1751 case B STop:1752 case B SBottom:1751 case BoxSide::Top: 1752 case BoxSide::Bottom: 1753 1753 drawBorderRect(snapRectToDevicePixels(LayoutRect(x1, y1, length, thirdOfThickness), deviceScaleFactor)); 1754 1754 drawBorderRect(snapRectToDevicePixels(LayoutRect(x1, y2 - thirdOfThickness, length, thirdOfThickness), deviceScaleFactor)); 1755 1755 break; 1756 case B SLeft:1757 case B SRight:1756 case BoxSide::Left: 1757 case BoxSide::Right: 1758 1758 drawBorderRect(snapRectToDevicePixels(LayoutRect(x1, y1, thirdOfThickness, length), deviceScaleFactor)); 1759 1759 drawBorderRect(snapRectToDevicePixels(LayoutRect(x2 - thirdOfThickness, y1, thirdOfThickness, length), deviceScaleFactor)); … … 1777 1777 FloatRect paintBorderRect; 1778 1778 switch (side) { 1779 case B STop:1779 case BoxSide::Top: 1780 1780 paintBorderRect = snapRectToDevicePixels(LayoutRect(x1 + mitreOffset1, y1, (x2 - mitreOffset3) - (x1 + mitreOffset1), thirdOfThickness), deviceScaleFactor); 1781 1781 drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird)); … … 1784 1784 drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird)); 1785 1785 break; 1786 case B SLeft:1786 case BoxSide::Left: 1787 1787 paintBorderRect = snapRectToDevicePixels(LayoutRect(x1, y1 + mitreOffset1, thirdOfThickness, (y2 - mitreOffset3) - (y1 + mitreOffset1)), deviceScaleFactor); 1788 1788 drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird)); … … 1791 1791 drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird)); 1792 1792 break; 1793 case B SBottom:1793 case BoxSide::Bottom: 1794 1794 paintBorderRect = snapRectToDevicePixels(LayoutRect(x1 + mitreOffset2, y1, (x2 - mitreOffset4) - (x1 + mitreOffset2), thirdOfThickness), deviceScaleFactor); 1795 1795 drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird)); … … 1798 1798 drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird)); 1799 1799 break; 1800 case B SRight:1800 case BoxSide::Right: 1801 1801 paintBorderRect = snapRectToDevicePixels(LayoutRect(x1, y1 + mitreOffset2, thirdOfThickness, (y2 - mitreOffset4) - (y1 + mitreOffset2)), deviceScaleFactor); 1802 1802 drawLineFor(paintBorderRect, side, BorderStyle::Solid, FloatSize(adjacent1BigThird, adjacent2BigThird)); … … 1834 1834 float offset4 = 0; 1835 1835 1836 if (((side == B STop || side == BSLeft) && adjacentWidth1 < 0) || ((side == BSBottom || side == BSRight) && adjacentWidth1 > 0))1836 if (((side == BoxSide::Top || side == BoxSide::Left) && adjacentWidth1 < 0) || ((side == BoxSide::Bottom || side == BoxSide::Right) && adjacentWidth1 > 0)) 1837 1837 offset1 = floorToDevicePixel(adjacentWidth1 / 2, deviceScaleFactor); 1838 1838 1839 if (((side == B STop || side == BSLeft) && adjacentWidth2 < 0) || ((side == BSBottom || side == BSRight) && adjacentWidth2 > 0))1839 if (((side == BoxSide::Top || side == BoxSide::Left) && adjacentWidth2 < 0) || ((side == BoxSide::Bottom || side == BoxSide::Right) && adjacentWidth2 > 0)) 1840 1840 offset2 = ceilToDevicePixel(adjacentWidth2 / 2, deviceScaleFactor); 1841 1841 1842 if (((side == B STop || side == BSLeft) && adjacentWidth1 > 0) || ((side == BSBottom || side == BSRight) && adjacentWidth1 < 0))1842 if (((side == BoxSide::Top || side == BoxSide::Left) && adjacentWidth1 > 0) || ((side == BoxSide::Bottom || side == BoxSide::Right) && adjacentWidth1 < 0)) 1843 1843 offset3 = floorToDevicePixel(fabs(adjacentWidth1) / 2, deviceScaleFactor); 1844 1844 1845 if (((side == B STop || side == BSLeft) && adjacentWidth2 > 0) || ((side == BSBottom || side == BSRight) && adjacentWidth2 < 0))1845 if (((side == BoxSide::Top || side == BoxSide::Left) && adjacentWidth2 > 0) || ((side == BoxSide::Bottom || side == BoxSide::Right) && adjacentWidth2 < 0)) 1846 1846 offset4 = ceilToDevicePixel(adjacentWidth2 / 2, deviceScaleFactor); 1847 1847 … … 1855 1855 1856 1856 switch (side) { 1857 case B STop:1857 case BoxSide::Top: 1858 1858 drawLineFor(FloatRect(FloatPoint(x1 + offset1, y1), FloatPoint(x2 - offset2, adjustedY)), side, s1, FloatSize(adjacent1BigHalf, adjacent2BigHalf)); 1859 1859 drawLineFor(FloatRect(FloatPoint(x1 + offset3, adjustedY), FloatPoint(x2 - offset4, y2)), side, s2, FloatSize(adjacent1SmallHalf, adjacent2SmallHalf)); 1860 1860 break; 1861 case B SLeft:1861 case BoxSide::Left: 1862 1862 drawLineFor(FloatRect(FloatPoint(x1, y1 + offset1), FloatPoint(adjustedX, y2 - offset2)), side, s1, FloatSize(adjacent1BigHalf, adjacent2BigHalf)); 1863 1863 drawLineFor(FloatRect(FloatPoint(adjustedX, y1 + offset3), FloatPoint(x2, y2 - offset4)), side, s2, FloatSize(adjacent1SmallHalf, adjacent2SmallHalf)); 1864 1864 break; 1865 case B SBottom:1865 case BoxSide::Bottom: 1866 1866 drawLineFor(FloatRect(FloatPoint(x1 + offset1, y1), FloatPoint(x2 - offset2, adjustedY)), side, s2, FloatSize(adjacent1BigHalf, adjacent2BigHalf)); 1867 1867 drawLineFor(FloatRect(FloatPoint(x1 + offset3, adjustedY), FloatPoint(x2 - offset4, y2)), side, s1, FloatSize(adjacent1SmallHalf, adjacent2SmallHalf)); 1868 1868 break; 1869 case B SRight:1869 case BoxSide::Right: 1870 1870 drawLineFor(FloatRect(FloatPoint(x1, y1 + offset1), FloatPoint(adjustedX, y2 - offset2)), side, s2, FloatSize(adjacent1BigHalf, adjacent2BigHalf)); 1871 1871 drawLineFor(FloatRect(FloatPoint(adjustedX, y1 + offset3), FloatPoint(x2, y2 - offset4)), side, s1, FloatSize(adjacent1SmallHalf, adjacent2SmallHalf)); … … 1902 1902 quad.reserveInitialCapacity(4); 1903 1903 switch (side) { 1904 case B STop:1904 case BoxSide::Top: 1905 1905 quad.uncheckedAppend({ x1 + std::max<float>(-adjacentWidth1, 0), y1 }); 1906 1906 quad.uncheckedAppend({ x1 + std::max<float>( adjacentWidth1, 0), y2 }); … … 1908 1908 quad.uncheckedAppend({ x2 - std::max<float>(-adjacentWidth2, 0), y1 }); 1909 1909 break; 1910 case B SBottom:1910 case BoxSide::Bottom: 1911 1911 quad.uncheckedAppend({ x1 + std::max<float>( adjacentWidth1, 0), y1 }); 1912 1912 quad.uncheckedAppend({ x1 + std::max<float>(-adjacentWidth1, 0), y2 }); … … 1914 1914 quad.uncheckedAppend({ x2 - std::max<float>( adjacentWidth2, 0), y1 }); 1915 1915 break; 1916 case B SLeft:1916 case BoxSide::Left: 1917 1917 quad.uncheckedAppend({ x1, y1 + std::max<float>(-adjacentWidth1, 0) }); 1918 1918 quad.uncheckedAppend({ x1, y2 - std::max<float>(-adjacentWidth2, 0) }); … … 1920 1920 quad.uncheckedAppend({ x2, y1 + std::max<float>( adjacentWidth1, 0) }); 1921 1921 break; 1922 case B SRight:1922 case BoxSide::Right: 1923 1923 quad.uncheckedAppend({ x1, y1 + std::max<float>( adjacentWidth1, 0) }); 1924 1924 quad.uncheckedAppend({ x1, y2 - std::max<float>( adjacentWidth2, 0) }); … … 2084 2084 float bottomInner = std::min(inner.maxY(), bottomOuter); 2085 2085 2086 drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(leftOuter, topOuter), FloatPoint(leftInner, bottomOuter)), B SLeft, outlineColor, outlineStyle, outlineWidth, outlineWidth);2087 drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(leftOuter, topOuter), FloatPoint(rightOuter, topInner)), B STop, outlineColor, outlineStyle, outlineWidth, outlineWidth);2088 drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(rightInner, topOuter), FloatPoint(rightOuter, bottomOuter)), B SRight, outlineColor, outlineStyle, outlineWidth, outlineWidth);2089 drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(leftOuter, bottomInner), FloatPoint(rightOuter, bottomOuter)), B SBottom, outlineColor, outlineStyle, outlineWidth, outlineWidth);2086 drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(leftOuter, topOuter), FloatPoint(leftInner, bottomOuter)), BoxSide::Left, outlineColor, outlineStyle, outlineWidth, outlineWidth); 2087 drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(leftOuter, topOuter), FloatPoint(rightOuter, topInner)), BoxSide::Top, outlineColor, outlineStyle, outlineWidth, outlineWidth); 2088 drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(rightInner, topOuter), FloatPoint(rightOuter, bottomOuter)), BoxSide::Right, outlineColor, outlineStyle, outlineWidth, outlineWidth); 2089 drawLineForBoxSide(graphicsContext, FloatRect(FloatPoint(leftOuter, bottomInner), FloatPoint(rightOuter, bottomOuter)), BoxSide::Bottom, outlineColor, outlineStyle, outlineWidth, outlineWidth); 2090 2090 2091 2091 if (useTransparencyLayer) -
trunk/Source/WebCore/rendering/RenderInline.cpp
r261941 r269228 1285 1285 adjacentWidth2 = -outlineWidth; 1286 1286 } 1287 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), B SLeft, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);1287 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Left, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1288 1288 1289 1289 // right edge … … 1304 1304 adjacentWidth2 = -outlineWidth; 1305 1305 } 1306 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), B SRight, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);1306 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Right, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1307 1307 1308 1308 // upper edge … … 1318 1318 } else 1319 1319 adjacentWidth2 = outlineWidth; 1320 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), B STop, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);1320 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Top, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1321 1321 } 1322 1322 … … 1332 1332 bottomRight.move(outlineWidth, 0); 1333 1333 adjacentWidth2 = outlineWidth; 1334 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), B STop, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);1334 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Top, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1335 1335 } 1336 1336 … … 1342 1342 bottomRight.move(outlineWidth, 0); 1343 1343 adjacentWidth2 = outlineWidth; 1344 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), B STop, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);1344 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Top, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1345 1345 } 1346 1346 … … 1357 1357 } else 1358 1358 adjacentWidth2 = outlineWidth; 1359 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), B SBottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);1359 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Bottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1360 1360 } 1361 1361 … … 1371 1371 bottomRight.move(outlineWidth, outlineWidth); 1372 1372 adjacentWidth2 = outlineWidth; 1373 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), B SBottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);1373 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Bottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1374 1374 } 1375 1375 … … 1381 1381 bottomRight.move(outlineWidth, outlineWidth); 1382 1382 adjacentWidth2 = outlineWidth; 1383 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), B SBottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias);1383 drawLineForBoxSide(graphicsContext, FloatRect(topLeft, bottomRight), BoxSide::Bottom, outlineColor, outlineStyle, adjacentWidth1, adjacentWidth2, antialias); 1384 1384 } 1385 1385 } -
trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp
r258508 r269228 604 604 LayoutUnit inlineDirectionSize = computedColumnWidth(); 605 605 BoxSide boxSide = isHorizontalWritingMode() 606 ? leftToRight ? B SLeft : BSRight607 : leftToRight ? B STop : BSBottom;606 ? leftToRight ? BoxSide::Left : BoxSide::Right 607 : leftToRight ? BoxSide::Top : BoxSide::Bottom; 608 608 609 609 for (unsigned i = 0; i < colCount; i++) { … … 646 646 ruleRect.moveBy(paintOffset); 647 647 648 BoxSide boxSide = isHorizontalWritingMode() ? topToBottom ? B STop : BSBottom : topToBottom ? BSLeft : BSRight;648 BoxSide boxSide = isHorizontalWritingMode() ? topToBottom ? BoxSide::Top : BoxSide::Bottom : topToBottom ? BoxSide::Left : BoxSide::Right; 649 649 650 650 LayoutSize step(0_lu, topToBottom ? computedColumnHeight() + colGap : -(computedColumnHeight() + colGap)); -
trunk/Source/WebCore/rendering/RenderObject.cpp
r267363 r269228 1827 1827 enum Operation { Darken, Lighten }; 1828 1828 1829 Operation operation = (side == B STop || side == BSLeft) == (style == BorderStyle::Inset) ? Darken : Lighten;1829 Operation operation = (side == BoxSide::Top || side == BoxSide::Left) == (style == BorderStyle::Inset) ? Darken : Lighten; 1830 1830 1831 1831 // Here we will darken the border decoration color when needed. This will yield a similar behavior as in FF. -
trunk/Source/WebCore/rendering/RenderObjectEnums.h
r202167 r269228 48 48 }; 49 49 50 // Sides used when drawing borders and outlines. The values should run clockwise from top.51 enum BoxSide {52 BSTop,53 BSRight,54 BSBottom,55 BSLeft56 };57 58 50 enum MarkingBehavior { 59 51 MarkOnlyThis, -
trunk/Source/WebCore/rendering/RenderTableCell.cpp
r268919 r269228 1252 1252 // precedence paint on top of borders with lower precedence. 1253 1253 CollapsedBorders borders; 1254 borders.addBorder(topVal, B STop, renderTop, borderRect.x(), borderRect.y(), borderRect.maxX(), borderRect.y() + topWidth, topStyle);1255 borders.addBorder(bottomVal, B SBottom, renderBottom, borderRect.x(), borderRect.maxY() - bottomWidth, borderRect.maxX(), borderRect.maxY(), bottomStyle);1256 borders.addBorder(leftVal, B SLeft, renderLeft, borderRect.x(), borderRect.y(), borderRect.x() + leftWidth, borderRect.maxY(), leftStyle);1257 borders.addBorder(rightVal, B SRight, renderRight, borderRect.maxX() - rightWidth, borderRect.y(), borderRect.maxX(), borderRect.maxY(), rightStyle);1254 borders.addBorder(topVal, BoxSide::Top, renderTop, borderRect.x(), borderRect.y(), borderRect.maxX(), borderRect.y() + topWidth, topStyle); 1255 borders.addBorder(bottomVal, BoxSide::Bottom, renderBottom, borderRect.x(), borderRect.maxY() - bottomWidth, borderRect.maxX(), borderRect.maxY(), bottomStyle); 1256 borders.addBorder(leftVal, BoxSide::Left, renderLeft, borderRect.x(), borderRect.y(), borderRect.x() + leftWidth, borderRect.maxY(), leftStyle); 1257 borders.addBorder(rightVal, BoxSide::Right, renderRight, borderRect.maxX() - rightWidth, borderRect.y(), borderRect.maxX(), borderRect.maxY(), rightStyle); 1258 1258 1259 1259 bool antialias = shouldAntialiasLines(graphicsContext); -
trunk/Source/WebCore/rendering/RenderTableSection.cpp
r268919 r269228 1097 1097 bool isLastRow = row + 1 == m_grid.size(); 1098 1098 if (style().isHorizontalWritingMode()) 1099 return m_rowPos[row] + (!row && borderSide == B SRight ? -outerBorderTop(&style()) : isLastRow && borderSide == BSLeft ? outerBorderTop(&style()) : 0_lu);1099 return m_rowPos[row] + (!row && borderSide == BoxSide::Right ? -outerBorderTop(&style()) : isLastRow && borderSide == BoxSide::Left ? outerBorderTop(&style()) : 0_lu); 1100 1100 if (style().isLeftToRightDirection()) 1101 return (cell ? cell->y() + cell->height() : 0_lu) + (borderSide == B SLeft ? outerBorderTop(&style()) : 0_lu);1102 return borderSide == B SRight ? -outerBorderTop(&style()) : 0_lu;1101 return (cell ? cell->y() + cell->height() : 0_lu) + (borderSide == BoxSide::Left ? outerBorderTop(&style()) : 0_lu); 1102 return borderSide == BoxSide::Right ? -outerBorderTop(&style()) : 0_lu; 1103 1103 } 1104 1104 … … 1134 1134 bool antialias = shouldAntialiasLines(paintInfo.context()); 1135 1135 LayoutRect rowGroupRect = LayoutRect(paintOffset, size()); 1136 rowGroupRect.moveBy(-LayoutPoint(outerBorderLeft(&style), (borderSide == B SRight) ? 0_lu : outerBorderTop(&style)));1136 rowGroupRect.moveBy(-LayoutPoint(outerBorderLeft(&style), (borderSide == BoxSide::Right) ? 0_lu : outerBorderTop(&style))); 1137 1137 1138 1138 switch (borderSide) { 1139 case B STop:1139 case BoxSide::Top: 1140 1140 paintRowGroupBorder(paintInfo, antialias, LayoutRect(paintOffset.x() + offsetLeftForRowGroupBorder(cell, rowGroupRect, row), rowGroupRect.y(), 1141 horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), LayoutUnit(style.borderTop().width())), B STop, CSSPropertyBorderTopColor, style.borderTopStyle(), table()->style().borderTopStyle());1141 horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), LayoutUnit(style.borderTop().width())), BoxSide::Top, CSSPropertyBorderTopColor, style.borderTopStyle(), table()->style().borderTopStyle()); 1142 1142 break; 1143 case B SBottom:1143 case BoxSide::Bottom: 1144 1144 paintRowGroupBorder(paintInfo, antialias, LayoutRect(paintOffset.x() + offsetLeftForRowGroupBorder(cell, rowGroupRect, row), rowGroupRect.y() + rowGroupRect.height(), 1145 horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), LayoutUnit(style.borderBottom().width())), B SBottom, CSSPropertyBorderBottomColor, style.borderBottomStyle(), table()->style().borderBottomStyle());1145 horizontalRowGroupBorderWidth(cell, rowGroupRect, row, column), LayoutUnit(style.borderBottom().width())), BoxSide::Bottom, CSSPropertyBorderBottomColor, style.borderBottomStyle(), table()->style().borderBottomStyle()); 1146 1146 break; 1147 case B SLeft:1147 case BoxSide::Left: 1148 1148 paintRowGroupBorder(paintInfo, antialias, LayoutRect(rowGroupRect.x(), rowGroupRect.y() + offsetTopForRowGroupBorder(cell, borderSide, row), LayoutUnit(style.borderLeft().width()), 1149 verticalRowGroupBorderHeight(cell, rowGroupRect, row)), B SLeft, CSSPropertyBorderLeftColor, style.borderLeftStyle(), table()->style().borderLeftStyle());1149 verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BoxSide::Left, CSSPropertyBorderLeftColor, style.borderLeftStyle(), table()->style().borderLeftStyle()); 1150 1150 break; 1151 case B SRight:1151 case BoxSide::Right: 1152 1152 paintRowGroupBorder(paintInfo, antialias, LayoutRect(rowGroupRect.x() + rowGroupRect.width(), rowGroupRect.y() + offsetTopForRowGroupBorder(cell, borderSide, row), LayoutUnit(style.borderRight().width()), 1153 verticalRowGroupBorderHeight(cell, rowGroupRect, row)), B SRight, CSSPropertyBorderRightColor, style.borderRightStyle(), table()->style().borderRightStyle());1153 verticalRowGroupBorderHeight(cell, rowGroupRect, row)), BoxSide::Right, CSSPropertyBorderRightColor, style.borderRightStyle(), table()->style().borderRightStyle()); 1154 1154 break; 1155 1155 default: … … 1165 1165 case CBSStart: 1166 1166 if (styleForCellFlow->isHorizontalWritingMode()) 1167 return styleForCellFlow->isLeftToRightDirection() ? B SLeft : BSRight;1168 return styleForCellFlow->isLeftToRightDirection() ? B STop : BSBottom;1167 return styleForCellFlow->isLeftToRightDirection() ? BoxSide::Left : BoxSide::Right; 1168 return styleForCellFlow->isLeftToRightDirection() ? BoxSide::Top : BoxSide::Bottom; 1169 1169 case CBSEnd: 1170 1170 if (styleForCellFlow->isHorizontalWritingMode()) 1171 return styleForCellFlow->isLeftToRightDirection() ? B SRight : BSLeft;1172 return styleForCellFlow->isLeftToRightDirection() ? B SBottom : BSTop;1171 return styleForCellFlow->isLeftToRightDirection() ? BoxSide::Right : BoxSide::Left; 1172 return styleForCellFlow->isLeftToRightDirection() ? BoxSide::Bottom : BoxSide::Top; 1173 1173 case CBSBefore: 1174 1174 if (styleForCellFlow->isHorizontalWritingMode()) 1175 return B STop;1176 return styleForCellFlow->isLeftToRightDirection() ? B SRight : BSLeft;1175 return BoxSide::Top; 1176 return styleForCellFlow->isLeftToRightDirection() ? BoxSide::Right : BoxSide::Left; 1177 1177 case CBSAfter: 1178 1178 if (styleForCellFlow->isHorizontalWritingMode()) 1179 return B SBottom;1180 return styleForCellFlow->isLeftToRightDirection() ? B SLeft : BSRight;1179 return BoxSide::Bottom; 1180 return styleForCellFlow->isLeftToRightDirection() ? BoxSide::Left : BoxSide::Right; 1181 1181 default: 1182 1182 ASSERT_NOT_REACHED(); 1183 return B SLeft;1183 return BoxSide::Left; 1184 1184 } 1185 1185 } -
trunk/Source/WebCore/rendering/RenderThemeIOS.mm
r267760 r269228 696 696 float separatorPosition = isRTL ? (clip.x() + MenuListButtonPaddingAfter) : (clip.maxX() - MenuListButtonPaddingAfter); 697 697 698 box.drawLineForBoxSide(paintInfo.context(), FloatRect(FloatPoint(separatorPosition - borderTopWidth, clip.y()), FloatPoint(separatorPosition, clip.maxY())), B SRight, style.visitedDependentColor(CSSPropertyBorderTopColor), style.borderTopStyle(), 0, 0);698 box.drawLineForBoxSide(paintInfo.context(), FloatRect(FloatPoint(separatorPosition - borderTopWidth, clip.y()), FloatPoint(separatorPosition, clip.maxY())), BoxSide::Right, style.visitedDependentColor(CSSPropertyBorderTopColor), style.borderTopStyle(), 0, 0); 699 699 700 700 FloatRect buttonClip; -
trunk/Source/WebCore/rendering/style/NinePieceImage.h
r260311 r269228 83 83 } 84 84 85 inline Optional< PhysicalBoxSide> imagePieceHorizontalSide(ImagePiece piece)85 inline Optional<BoxSide> imagePieceHorizontalSide(ImagePiece piece) 86 86 { 87 87 if (piece == TopLeftPiece || piece == TopPiece || piece == TopRightPiece) 88 return PhysicalBoxSide::Top;88 return BoxSide::Top; 89 89 90 90 if (piece == BottomLeftPiece || piece == BottomPiece || piece == BottomRightPiece) 91 return PhysicalBoxSide::Bottom;91 return BoxSide::Bottom; 92 92 93 93 return WTF::nullopt; 94 94 } 95 95 96 inline Optional< PhysicalBoxSide> imagePieceVerticalSide(ImagePiece piece)96 inline Optional<BoxSide> imagePieceVerticalSide(ImagePiece piece) 97 97 { 98 98 if (piece == TopLeftPiece || piece == LeftPiece || piece == BottomLeftPiece) 99 return PhysicalBoxSide::Left;99 return BoxSide::Left; 100 100 101 101 if (piece == TopRightPiece || piece == RightPiece || piece == BottomRightPiece) 102 return PhysicalBoxSide::Right;102 return BoxSide::Right; 103 103 104 104 return WTF::nullopt; -
trunk/Source/WebKit/ChangeLog
r269210 r269228 1 2020-10-31 Simon Fraser <simon.fraser@apple.com> 2 3 Clean up BoxSide and BorderEdge code 4 https://bugs.webkit.org/show_bug.cgi?id=218197 5 6 Reviewed by Sam Weinig. 7 8 * UIProcess/ios/WKKeyboardScrollingAnimator.mm: 9 (boxSide): 10 1 11 2020-10-30 Brian Burg <bburg@apple.com> 2 12 -
trunk/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.mm
r261436 r269228 164 164 } 165 165 166 static WebCore:: PhysicalBoxSide boxSide(WebKit::ScrollingDirection direction)166 static WebCore::BoxSide boxSide(WebKit::ScrollingDirection direction) 167 167 { 168 168 switch (direction) { 169 169 case WebKit::ScrollingDirection::Up: 170 return WebCore:: PhysicalBoxSide::Top;170 return WebCore::BoxSide::Top; 171 171 case WebKit::ScrollingDirection::Down: 172 return WebCore:: PhysicalBoxSide::Bottom;172 return WebCore::BoxSide::Bottom; 173 173 case WebKit::ScrollingDirection::Left: 174 return WebCore:: PhysicalBoxSide::Left;174 return WebCore::BoxSide::Left; 175 175 case WebKit::ScrollingDirection::Right: 176 return WebCore:: PhysicalBoxSide::Right;176 return WebCore::BoxSide::Right; 177 177 } 178 178 }
Note:
See TracChangeset
for help on using the changeset viewer.