Changeset 232154 in webkit
- Timestamp:
- May 24, 2018, 9:57:24 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
layout/blockformatting/BlockFormattingContext.cpp (modified) (1 diff)
-
layout/blockformatting/BlockFormattingContext.h (modified) (2 diffs)
-
layout/blockformatting/BlockFormattingContextGeometry.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r232152 r232154 1 2018-05-24 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Implement position computation for inflow positioned elements 4 https://bugs.webkit.org/show_bug.cgi?id=185936 5 6 Reviewed by Antti Koivisto. 7 8 * layout/blockformatting/BlockFormattingContext.cpp: 9 (WebCore::Layout::BlockFormattingContext::computeInFlowPositionedPosition const): 10 * layout/blockformatting/BlockFormattingContext.h: 11 * layout/blockformatting/BlockFormattingContextGeometry.cpp: 12 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowPositionedPosition): 13 1 14 2018-05-24 Zalan Bujtas <zalan@apple.com> 2 15 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
r232152 r232154 135 135 } 136 136 137 void BlockFormattingContext::computeInFlowPositionedPosition(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const 138 { 139 auto topLeft = Geometry::inFlowPositionedPosition(layoutContext, layoutBox); 140 displayBox.setTopLeft(topLeft); 141 } 142 137 143 void BlockFormattingContext::computeInFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const 138 144 { -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
r232114 r232154 53 53 private: 54 54 void computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const override; 55 void computeInFlowPositionedPosition(LayoutContext&, const Box&, Display::Box&) const override; 55 56 void computeInFlowWidth(LayoutContext&, const Box&, Display::Box&) const override; 56 57 void computeInFlowHeight(LayoutContext&, const Box&, Display::Box&) const override; … … 66 67 67 68 static LayoutPoint staticPosition(LayoutContext&, const Box&); 69 static LayoutPoint inFlowPositionedPosition(LayoutContext&, const Box&); 68 70 }; 69 71 }; -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
r232114 r232154 138 138 } 139 139 140 LayoutPoint BlockFormattingContext::Geometry::inFlowPositionedPosition(LayoutContext& layoutContext, const Box& layoutBox) 141 { 142 ASSERT(layoutBox.isInFlowPositioned()); 143 // 9.4.3 Relative positioning 144 // 145 // The 'top' and 'bottom' properties move relatively positioned element(s) up or down without changing their size. 146 // Top' moves the boxes down, and 'bottom' moves them up. Since boxes are not split or stretched as a result of 'top' or 'bottom', the used values are always: top = -bottom. 147 // 148 // 1. If both are 'auto', their used values are both '0'. 149 // 2. If one of them is 'auto', it becomes the negative of the other. 150 // 3. If neither is 'auto', 'bottom' is ignored (i.e., the used value of 'bottom' will be minus the value of 'top'). 151 auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox); 152 auto& style = layoutBox.style(); 153 154 auto top = style.logicalTop(); 155 auto bottom = style.logicalBottom(); 156 LayoutUnit topDelta; 157 158 if (top.isAuto() && bottom.isAuto()) { 159 // #1 160 topDelta = 0; 161 } else if (top.isAuto()) { 162 // #2 163 topDelta = -bottom.value(); 164 } else if (bottom.isAuto()) { 165 // #3 #4 166 topDelta = top.value(); 167 } 168 169 // For relatively positioned elements, 'left' and 'right' move the box(es) horizontally, without changing their size. 170 // 'Left' moves the boxes to the right, and 'right' moves them to the left. 171 // Since boxes are not split or stretched as a result of 'left' or 'right', the used values are always: left = -right. 172 // 173 // 1. If both 'left' and 'right' are 'auto' (their initial values), the used values are '0' (i.e., the boxes stay in their original position). 174 // 2. If 'left' is 'auto', its used value is minus the value of 'right' (i.e., the boxes move to the left by the value of 'right'). 175 // 3. If 'right' is specified as 'auto', its used value is minus the value of 'left'. 176 // 4. If neither 'left' nor 'right' is 'auto', the position is over-constrained, and one of them has to be ignored. 177 // If the 'direction' property of the containing block is 'ltr', the value of 'left' wins and 'right' becomes -'left'. 178 // If 'direction' of the containing block is 'rtl', 'right' wins and 'left' is ignored. 179 // 180 auto left = style.logicalLeft(); 181 auto right = style.logicalRight(); 182 LayoutUnit leftDelta; 183 184 if (left.isAuto() && right.isAuto()) { 185 // #1 186 leftDelta = 0; 187 } else if (left.isAuto()) { 188 // #2 189 leftDelta = -right.value(); 190 } else if (right.isAuto()) { 191 // #3 192 leftDelta = left.value(); 193 } else { 194 // #4 195 // FIXME: take direction into account 196 leftDelta = left.value(); 197 } 198 199 return { displayBox.left() + leftDelta, displayBox.top() + topDelta }; 200 } 201 140 202 } 141 203 }
Note:
See TracChangeset
for help on using the changeset viewer.