Changeset 231846 in webkit
- Timestamp:
- May 16, 2018 7:49:55 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r231840 r231846 1 2018-05-16 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Make Display::Box box sizing aware 4 https://bugs.webkit.org/show_bug.cgi?id=185649 5 6 Reviewed by Antti Koivisto. 7 8 Display::Box::width() == Display::Box::contentBox().width() <= box-sizing: content-box; (initial and default value) 9 Display::Box::width() == Display::Box::borderBox().width() <= box-sizing: border-box; 10 11 * layout/LayoutContext.cpp: 12 (WebCore::Layout::LayoutContext::createDisplayBox): 13 * layout/displaytree/DisplayBox.cpp: 14 (WebCore::Display::Box::Box): 15 (WebCore::Display::Box::marginBox const): 16 (WebCore::Display::Box::borderBox const): 17 (WebCore::Display::Box::paddingBox const): 18 (WebCore::Display::Box::contentBox const): 19 * layout/displaytree/DisplayBox.h: 20 1 21 2018-05-16 Antoine Quint <graouts@apple.com> 2 22 -
trunk/Source/WebCore/layout/LayoutContext.cpp
r231480 r231846 65 65 Display::Box& LayoutContext::createDisplayBox(const Box& layoutBox) 66 66 { 67 std::unique_ptr<Display::Box> displayBox(new Display::Box( ));67 std::unique_ptr<Display::Box> displayBox(new Display::Box(layoutBox.style().boxSizing())); 68 68 auto* displayBoxPtr = displayBox.get(); 69 69 m_layoutToDisplayBox.add(&layoutBox, WTFMove(displayBox)); -
trunk/Source/WebCore/layout/displaytree/DisplayBox.cpp
r231401 r231846 36 36 WTF_MAKE_ISO_ALLOCATED_IMPL(Box); 37 37 38 Box::Box() 38 Box::Box(EBoxSizing boxSizing) 39 : m_boxSizing(boxSizing) 39 40 { 40 41 } … … 47 48 { 48 49 ASSERT(m_hasValidMargin); 49 auto marginBox = rect(); 50 auto topLeftMargin = LayoutSize(m_marginLeft, m_marginTop); 51 marginBox.inflate(topLeftMargin); 50 auto marginBox = borderBox(); 52 51 53 auto bottomRightMargin = LayoutSize(m_marginRight, m_marginBottom); 54 marginBox.expand(bottomRightMargin); 52 marginBox.shiftXEdgeTo(marginBox.x() + m_marginLeft); 53 marginBox.shiftYEdgeTo(marginBox.y() + m_marginTop); 54 marginBox.shiftMaxXEdgeTo(marginBox.maxX() - m_marginRight); 55 marginBox.shiftMaxYEdgeTo(marginBox.maxY() - m_marginBottom); 56 55 57 return marginBox; 56 58 } … … 58 60 LayoutRect Box::borderBox() const 59 61 { 60 return LayoutRect(LayoutPoint(0, 0), size()); 62 if (m_boxSizing == BORDER_BOX) 63 return LayoutRect( { }, size()); 64 65 // Width is content box. 66 ASSERT(m_hasValidBorder); 67 ASSERT(m_hasValidPadding); 68 auto borderBoxSize = size(); 69 borderBoxSize.expand(borderLeft() + paddingLeft() + paddingRight() + borderRight() , borderTop() + paddingTop() + paddingBottom() + borderBottom()); 70 return LayoutRect( { }, borderBoxSize); 61 71 } 62 72 … … 65 75 ASSERT(m_hasValidBorder); 66 76 auto paddingBox = borderBox(); 67 auto topLeftBorder = LayoutSize(m_borderLeft, m_borderTop);68 paddingBox.inflate(-topLeftBorder);69 77 70 auto bottomRightBorder = LayoutSize(m_borderRight, m_borderBottom); 71 paddingBox.expand(-bottomRightBorder); 78 paddingBox.shiftXEdgeTo(paddingBox.x() + m_borderLeft); 79 paddingBox.shiftYEdgeTo(paddingBox.y() + m_borderTop); 80 paddingBox.shiftMaxXEdgeTo(paddingBox.maxX() - m_borderRight); 81 paddingBox.shiftMaxYEdgeTo(paddingBox.maxY() - m_borderBottom); 82 72 83 return paddingBox; 73 84 } … … 75 86 LayoutRect Box::contentBox() const 76 87 { 88 if (m_boxSizing == CONTENT_BOX) 89 return LayoutRect(LayoutPoint(0, 0), size()); 90 91 // Width is border box. 77 92 ASSERT(m_hasValidPadding); 78 93 auto contentBox = paddingBox(); 79 auto topLeftPadding = LayoutSize(m_paddingLeft, m_paddingTop); 80 contentBox.inflate(-topLeftPadding); 81 82 auto bottomRightPadding = LayoutSize(m_paddingRight, m_paddingBottom); 83 contentBox.expand(-bottomRightPadding); 94 95 contentBox.shiftXEdgeTo(contentBox.x() + m_paddingLeft); 96 contentBox.shiftYEdgeTo(contentBox.y() + m_paddingTop); 97 contentBox.shiftMaxXEdgeTo(contentBox.maxX() - m_paddingRight); 98 contentBox.shiftMaxYEdgeTo(contentBox.maxY() - m_paddingBottom); 99 84 100 return contentBox; 85 101 } -
trunk/Source/WebCore/layout/displaytree/DisplayBox.h
r231780 r231846 31 31 #include "LayoutRect.h" 32 32 #include "LayoutUnit.h" 33 #include "RenderStyleConstants.h" 33 34 #include <wtf/IsoMalloc.h> 34 35 … … 87 88 88 89 private: 89 Box( );90 Box(EBoxSizing); 90 91 91 92 void setRect(const LayoutRect&); … … 142 143 LayoutUnit m_paddingRight; 143 144 145 EBoxSizing m_boxSizing { CONTENT_BOX }; 146 144 147 #if !ASSERT_DISABLED 145 148 bool m_hasValidTop { false };
Note: See TracChangeset
for help on using the changeset viewer.