Changeset 231953 in webkit
- Timestamp:
- May 18, 2018 7:31:02 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r231952 r231953 1 2018-05-18 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Implement height computation for replaced elements. 4 https://bugs.webkit.org/show_bug.cgi?id=185756 5 6 Reviewed by Antti Koivisto. 7 8 * layout/FormattingContext.cpp: 9 (WebCore::Layout::FormattingContext::computeHeight const): 10 (WebCore::Layout::FormattingContext::computeOutOfFlowWidth const): 11 (WebCore::Layout::FormattingContext::computeOutOfFlowHeight const): 12 (WebCore::Layout::FormattingContext::computeFloatingHeight const): 13 (WebCore::Layout::FormattingContext::computeReplacedHeight const): 14 (WebCore::Layout::FormattingContext::computeReplacedWidth const): 15 (WebCore::Layout::FormattingContext::computeOutOfFlowReplacedHeight const): 16 * layout/FormattingContext.h: 17 1 18 2018-05-18 Zalan Bujtas <zalan@apple.com> 2 19 -
trunk/Source/WebCore/layout/FormattingContext.cpp
r231952 r231953 75 75 return computeOutOfFlowHeight(layoutContext, layoutBox, displayBox); 76 76 if (layoutBox.isFloatingPositioned()) 77 return computeFloatingHeight(layout Box, displayBox);77 return computeFloatingHeight(layoutContext, layoutBox, displayBox); 78 78 return computeInFlowHeight(layoutContext, layoutBox, displayBox); 79 79 } … … 85 85 return; 86 86 } 87 ASSERT_NOT_IMPLEMENTED_YET();87 computeOutOfFlowReplacedWidth(layoutContext, layoutBox, displayBox); 88 88 } 89 89 … … 103 103 return; 104 104 } 105 ASSERT_NOT_IMPLEMENTED_YET(); 106 } 107 108 void FormattingContext::computeFloatingHeight(const Box&, Display::Box&) const 109 { 105 computeOutOfFlowReplacedHeight(layoutContext, layoutBox, displayBox); 106 } 107 108 void FormattingContext::computeFloatingHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const 109 { 110 if (!layoutBox.replaced()) { 111 ASSERT_NOT_IMPLEMENTED_YET(); 112 return; 113 } 114 computeReplacedHeight(layoutContext, layoutBox, displayBox); 110 115 } 111 116 … … 209 214 else 210 215 ASSERT_NOT_REACHED(); 216 217 displayBox.setHeight(computedHeightValue); 218 } 219 220 void FormattingContext::computeReplacedHeight(LayoutContext&, const Box& layoutBox, Display::Box& displayBox) const 221 { 222 ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced()); 223 // 10.6.5 Absolutely positioned, replaced elements. The used value of 'height' is determined as for inline replaced elements. 224 225 // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' replaced elements in normal flow and floating replaced elements 226 // 227 // 1. If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic height, then that intrinsic height is the used value of 'height'. 228 // 229 // 2. Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is: 230 // (used width) / (intrinsic ratio) 231 // 232 // 3. Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'. 233 // 234 // 4. Otherwise, if 'height' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'height' must be set to 235 // the height of the largest rectangle that has a 2:1 ratio, has a height not greater than 150px, and has a width not greater than the device width. 236 auto& style = layoutBox.style(); 237 auto width = style.logicalWidth(); 238 auto height = style.logicalHeight(); 239 240 LayoutUnit computedHeightValue; 241 auto replaced = layoutBox.replaced(); 242 ASSERT(replaced); 243 244 if (height.isAuto()) { 245 if (width.isAuto() && replaced->hasIntrinsicHeight()) { 246 // #1 247 computedHeightValue = replaced->intrinsicHeight(); 248 } else if (replaced->hasIntrinsicRatio()) { 249 // #2 250 computedHeightValue = width.value() / replaced->intrinsicRatio(); 251 } else if (replaced->hasIntrinsicHeight()) { 252 // #3 253 computedHeightValue = replaced->intrinsicHeight(); 254 } else { 255 // #4 256 computedHeightValue = 150; 257 } 258 } else 259 computedHeightValue = height.value(); 211 260 212 261 displayBox.setHeight(computedHeightValue); … … 264 313 } 265 314 266 displayBox.setWidth(computedWidthValue); 315 displayBox.setWidth(computedWidthValue); 267 316 } 268 317 … … 360 409 } 361 410 411 void FormattingContext::computeOutOfFlowReplacedHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const 412 { 413 ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced()); 414 // 10.6.5 Absolutely positioned, replaced elements 415 // 416 // The used value of 'height' is determined as for inline replaced elements. 417 computeReplacedHeight(layoutContext, layoutBox, displayBox); 418 } 419 362 420 void FormattingContext::computeOutOfFlowReplacedWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const 363 421 { -
trunk/Source/WebCore/layout/FormattingContext.h
r231952 r231953 77 77 78 78 virtual void computeOutOfFlowHeight(LayoutContext&, const Box&, Display::Box&) const; 79 virtual void computeFloatingHeight( const Box&, Display::Box&) const;79 virtual void computeFloatingHeight(LayoutContext&, const Box&, Display::Box&) const; 80 80 virtual void computeInFlowHeight(LayoutContext&, const Box&, Display::Box&) const = 0; 81 81 … … 88 88 void layoutOutOfFlowDescendants(LayoutContext&s) const; 89 89 90 void computeReplacedHeight(LayoutContext&, const Box&, Display::Box&) const; 90 91 void computeReplacedWidth(LayoutContext&, const Box&, Display::Box&) const; 91 92 … … 93 94 void computeOutOfFlowNonReplacedHeight(LayoutContext&, const Box&, Display::Box&) const; 94 95 void computeOutOfFlowNonReplacedWidth(LayoutContext&, const Box&, Display::Box&) const; 96 void computeOutOfFlowReplacedHeight(LayoutContext&, const Box&, Display::Box&) const; 95 97 void computeOutOfFlowReplacedWidth(LayoutContext&, const Box&, Display::Box&) const; 96 98 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
r231897 r231953 190 190 return; 191 191 } 192 ASSERT_NOT_IMPLEMENTED_YET();192 computeReplacedHeight(layoutContext, layoutBox, displayBox); 193 193 } 194 194
Note: See TracChangeset
for help on using the changeset viewer.