Changeset 238667 in webkit
- Timestamp:
- Nov 29, 2018, 7:28:20 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 11 edited
-
ChangeLog (modified) (1 diff)
-
Sources.txt (modified) (2 diffs)
-
WebCore.xcodeproj/project.pbxproj (modified) (3 diffs)
-
layout/FormattingContext.h (modified) (1 diff)
-
layout/FormattingContextGeometry.cpp (modified) (1 diff)
-
layout/FormattingContextQuirks.cpp (added)
-
layout/blockformatting/BlockFormattingContext.h (modified) (2 diffs)
-
layout/blockformatting/BlockFormattingContextGeometry.cpp (modified) (3 diffs)
-
layout/blockformatting/BlockFormattingContextQuirks.cpp (added)
-
layout/blockformatting/BlockFormattingState.cpp (modified) (1 diff)
-
layout/blockformatting/BlockMarginCollapse.cpp (modified) (4 diffs)
-
layout/inlineformatting/InlineFormattingContext.cpp (modified) (1 diff)
-
layout/inlineformatting/text/TextUtil.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r238666 r238667 1 2018-11-29 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][Quirk] Move quirk functions to dedicated classes. 4 https://bugs.webkit.org/show_bug.cgi?id=192133 5 6 Reviewed by Antti Koivisto. 7 8 * Sources.txt: 9 * WebCore.xcodeproj/project.pbxproj: 10 * layout/FormattingContext.h: 11 * layout/FormattingContextGeometry.cpp: 12 (WebCore::Layout::FormattingContext::Geometry::computedHeightValue): 13 * layout/blockformatting/BlockFormattingContext.h: 14 * layout/blockformatting/BlockFormattingContextGeometry.cpp: 15 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin): 16 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin): 17 (WebCore::Layout::initialContainingBlock): Deleted. 18 (WebCore::Layout::isStretchedToInitialContainingBlock): Deleted. 19 (WebCore::Layout::stretchHeightToInitialContainingBlockQuirk): Deleted. 20 (WebCore::Layout::stretchWidthToInitialContainingBlock): Deleted. 21 * layout/blockformatting/BlockFormattingState.cpp: 22 * layout/blockformatting/BlockMarginCollapse.cpp: 23 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::isMarginTopCollapsedWithParent): 24 (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginTop): 25 (WebCore::Layout::isQuirkContainer): Deleted. 26 (WebCore::Layout::hasMarginTopQuirkValue): Deleted. 27 (WebCore::Layout::shouldIgnoreMarginTopInQuirkContext): Deleted. 28 (WebCore::Layout::isMarginTopCollapsedWithParent): Deleted. 29 * layout/inlineformatting/InlineFormattingContext.cpp: 30 * layout/inlineformatting/text/TextUtil.h: 31 1 32 2018-11-29 Rob Buis <rbuis@igalia.com> 2 33 -
trunk/Source/WebCore/Sources.txt
r238629 r238667 1263 1263 layout/FormattingContext.cpp 1264 1264 layout/FormattingContextGeometry.cpp 1265 layout/FormattingContextQuirks.cpp 1265 1266 layout/FormattingState.cpp 1266 1267 layout/LayoutFormattingState.cpp … … 1268 1269 layout/blockformatting/BlockFormattingContext.cpp 1269 1270 layout/blockformatting/BlockFormattingContextGeometry.cpp 1271 layout/blockformatting/BlockFormattingContextQuirks.cpp 1270 1272 layout/blockformatting/BlockFormattingState.cpp 1271 1273 layout/blockformatting/BlockMarginCollapse.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r238657 r238667 9186 9186 6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InlineFormattingContext.h; sourceTree = "<group>"; }; 9187 9187 6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineFormattingContext.cpp; sourceTree = "<group>"; }; 9188 6F8F460121B03BB40041AC3A /* FormattingContextQuirks.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FormattingContextQuirks.cpp; sourceTree = "<group>"; }; 9189 6F8F460321B03BC60041AC3A /* BlockFormattingContextQuirks.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BlockFormattingContextQuirks.cpp; sourceTree = "<group>"; }; 9188 9190 6F995A091A7070E600A735F4 /* WebGLQuery.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLQuery.idl; sourceTree = "<group>"; }; 9189 9191 6F995A0A1A7070E600A735F4 /* WebGLSampler.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebGLSampler.idl; sourceTree = "<group>"; }; … … 16166 16168 115CFA68208AF7D0001E6991 /* FormattingContext.h */, 16167 16169 6FBB860520B464B600DAD938 /* FormattingContextGeometry.cpp */, 16170 6F8F460121B03BB40041AC3A /* FormattingContextQuirks.cpp */, 16168 16171 115CFA75208AFE30001E6991 /* FormattingState.cpp */, 16169 16172 115CFA74208AFE30001E6991 /* FormattingState.h */, … … 16210 16213 115CFA6C208AFAB6001E6991 /* BlockFormattingContext.h */, 16211 16214 6F0830DF20B46951008A945B /* BlockFormattingContextGeometry.cpp */, 16215 6F8F460321B03BC60041AC3A /* BlockFormattingContextQuirks.cpp */, 16212 16216 115CFA79208B8D9D001E6991 /* BlockFormattingState.cpp */, 16213 16217 115CFA78208B8D9D001E6991 /* BlockFormattingState.h */, -
trunk/Source/WebCore/layout/FormattingContext.h
r238481 r238667 123 123 }; 124 124 125 class Quirks { 126 public: 127 static LayoutUnit heightValueOfNearestContainingBlockWithFixedHeight(const LayoutState&, const Box&); 128 }; 129 125 130 private: 126 131 void computeOutOfFlowVerticalGeometry(const Box&) const; -
trunk/Source/WebCore/layout/FormattingContextGeometry.cpp
r238482 r238667 73 73 containingBlockHeightValue = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).height(); 74 74 } else { 75 auto computedHeightValueForQuirksMode = [&]() -> LayoutUnit {76 // In quirks mode, we go and travers the containing block chain to find a block level box with fixed height value, even if it means leaving77 // the current formatting context. FIXME: surely we need to do some tricks here when block direction support is added.78 auto* containingBlock = layoutBox.containingBlock();79 LayoutUnit bodyAndDocumentVerticalMarginsPaddingsAndBorders;80 while (containingBlock) {81 auto containingBlockHeight = containingBlock->style().logicalHeight();82 if (containingBlockHeight.isFixed())83 return containingBlockHeight.value() - bodyAndDocumentVerticalMarginsPaddingsAndBorders;84 85 // If the only fixed value box we find is the ICB, then ignore the body and the document (vertical) margin, padding and border. So much quirkiness.86 // -and it's totally insane because now we freely travel across formatting context boundaries and computed margins are nonexistent.87 if (containingBlock->isBodyBox() || containingBlock->isDocumentBox()) {88 auto& displayBox = layoutState.displayBoxForLayoutBox(*containingBlock);89 90 auto verticalMargins = computedNonCollapsedVerticalMarginValue(layoutState, *containingBlock);91 auto verticalPaddings = displayBox.paddingTop().value_or(0) + displayBox.paddingBottom().value_or(0);92 auto verticalBorders = displayBox.borderTop() + displayBox.borderBottom();93 bodyAndDocumentVerticalMarginsPaddingsAndBorders += verticalMargins.top + verticalMargins.bottom + verticalPaddings + verticalBorders;94 }95 96 containingBlock = containingBlock->containingBlock();97 }98 // Initial containing block has to have a height.99 return layoutState.displayBoxForLayoutBox(layoutBox.initialContainingBlock()).contentBox().height() - bodyAndDocumentVerticalMarginsPaddingsAndBorders;100 };101 102 75 if (layoutState.inQuirksMode()) 103 containingBlockHeightValue = computedHeightValueForQuirksMode();76 containingBlockHeightValue = FormattingContext::Quirks::heightValueOfNearestContainingBlockWithFixedHeight(layoutState, layoutBox); 104 77 else { 105 78 auto containingBlockHeight = layoutBox.containingBlock()->style().logicalHeight(); -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
r238481 r238667 101 101 static LayoutUnit collapsedMarginTopFromFirstChild(const LayoutState&, const Box&); 102 102 static LayoutUnit nonCollapsedMarginTop(const LayoutState&, const Box&); 103 104 static bool isMarginTopCollapsedWithParent(const LayoutState&, const Box&); 103 105 }; 104 106 … … 108 110 static Point staticPositionForOutOfFlowPositioned(const LayoutState&, const Box&); 109 111 }; 112 113 class Quirks { 114 public: 115 static bool isStretchedToInitialContainingBlock(const LayoutState&, const Box&); 116 static HeightAndMargin stretchedHeight(const LayoutState&, const Box&, HeightAndMargin); 117 static WidthAndMargin stretchedWidth(const LayoutState&, const Box&, WidthAndMargin); 118 static bool shouldIgnoreMarginTop(const LayoutState&, const Box&); 119 }; 110 120 }; 111 121 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
r238613 r238667 38 38 namespace Layout { 39 39 40 static const Container& initialContainingBlock(const Box& layoutBox)41 {42 auto* containingBlock = layoutBox.containingBlock();43 while (containingBlock->containingBlock())44 containingBlock = containingBlock->containingBlock();45 return *containingBlock;46 }47 48 static bool isStretchedToInitialContainingBlock(const LayoutState& layoutState, const Box& layoutBox)49 {50 ASSERT(layoutBox.isInFlow());51 // In quirks mode, body and html stretch to the viewport.52 if (!layoutState.inQuirksMode())53 return false;54 55 if (!layoutBox.isDocumentBox() && !layoutBox.isBodyBox())56 return false;57 58 return layoutBox.style().logicalHeight().isAuto();59 }60 61 static HeightAndMargin stretchHeightToInitialContainingBlockQuirk(HeightAndMargin heightAndMargin, LayoutUnit initialContainingBlockHeight)62 {63 // This quirk happens when the body height is 0 which means its vertical margins collapse through (top and bottom margins are adjoining).64 // However now that we stretch the body they don't collapse through anymore, so we need to use the non-collapsed values instead.65 ASSERT(initialContainingBlockHeight);66 auto verticalMargins = heightAndMargin.height ? heightAndMargin.usedMarginValues() : heightAndMargin.margin;67 auto totalVerticalMargins = verticalMargins.top + verticalMargins.bottom;68 // Stretch but never overstretch with the margins.69 if (heightAndMargin.height + totalVerticalMargins < initialContainingBlockHeight)70 heightAndMargin.height = initialContainingBlockHeight - totalVerticalMargins;71 72 return heightAndMargin;73 }74 75 static WidthAndMargin stretchWidthToInitialContainingBlock(WidthAndMargin widthAndMargin, LayoutUnit initialContainingBlockWidth)76 {77 auto horizontalMargins = widthAndMargin.margin.left + widthAndMargin.margin.right;78 // Stretch but never overstretch with the margins.79 if (widthAndMargin.width + horizontalMargins < initialContainingBlockWidth)80 widthAndMargin.width = initialContainingBlockWidth - horizontalMargins;81 82 return widthAndMargin;83 }84 85 40 HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, std::optional<LayoutUnit> usedHeight) 86 41 { … … 241 196 242 197 auto widthAndMargin = compute(); 243 if (! isStretchedToInitialContainingBlock(layoutState, layoutBox)) {198 if (!Quirks::isStretchedToInitialContainingBlock(layoutState, layoutBox)) { 244 199 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> width(" << widthAndMargin.width << "px) margin(" << widthAndMargin.margin.left << "px, " << widthAndMargin.margin.right << "px) -> layoutBox(" << &layoutBox << ")"); 245 200 return widthAndMargin; 246 201 } 247 202 248 auto initialContainingBlockWidth = layoutState.displayBoxForLayoutBox(initialContainingBlock(layoutBox)).contentBoxWidth(); 249 widthAndMargin = stretchWidthToInitialContainingBlock(widthAndMargin, initialContainingBlockWidth); 203 widthAndMargin = Quirks::stretchedWidth(layoutState, layoutBox, widthAndMargin); 250 204 251 205 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> streched to viewport-> width(" << widthAndMargin.width << "px) margin(" << widthAndMargin.margin.left << "px, " << widthAndMargin.margin.right << "px) -> layoutBox(" << &layoutBox << ")"); … … 311 265 } 312 266 313 if (! isStretchedToInitialContainingBlock(layoutState, layoutBox))267 if (!Quirks::isStretchedToInitialContainingBlock(layoutState, layoutBox)) 314 268 return heightAndMargin; 315 269 316 auto initialContainingBlockHeight = layoutState.displayBoxForLayoutBox(initialContainingBlock(layoutBox)).contentBoxHeight(); 317 heightAndMargin = stretchHeightToInitialContainingBlockQuirk(heightAndMargin, initialContainingBlockHeight); 270 heightAndMargin = Quirks::stretchedHeight(layoutState, layoutBox, heightAndMargin); 318 271 319 272 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> streched to viewport -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.margin.top << "px, " << heightAndMargin.margin.bottom << "px) -> layoutBox(" << &layoutBox << ")"); -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.cpp
r237633 r238667 29 29 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 30 30 31 #include " FormattingContext.h"31 #include "BlockFormattingContext.h" 32 32 #include "LayoutBox.h" 33 33 #include <wtf/IsoMallocInlines.h> -
trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
r238611 r238667 37 37 namespace Layout { 38 38 39 static bool isQuirkContainer(const Box& layoutBox)40 {41 return layoutBox.isBodyBox() || layoutBox.isDocumentBox() || layoutBox.isTableCell();42 }43 44 static bool hasMarginTopQuirkValue(const Box& layoutBox)45 {46 return layoutBox.style().hasMarginBeforeQuirk();47 }48 49 static bool shouldIgnoreMarginTopInQuirkContext(const LayoutState& layoutState, const Box& layoutBox)50 {51 if (!layoutBox.parent())52 return false;53 return layoutState.inQuirksMode() && isQuirkContainer(*layoutBox.parent()) && hasMarginTopQuirkValue(layoutBox);54 }55 56 39 static LayoutUnit marginValue(LayoutUnit currentMarginValue, LayoutUnit candidateMarginValue) 57 40 { … … 100 83 } 101 84 102 static boolisMarginTopCollapsedWithParent(const LayoutState& layoutState, const Box& layoutBox)85 bool BlockFormattingContext::Geometry::MarginCollapse::isMarginTopCollapsedWithParent(const LayoutState& layoutState, const Box& layoutBox) 103 86 { 104 87 // The first inflow child could propagate its top margin to parent. … … 133 116 return false; 134 117 135 if ( shouldIgnoreMarginTopInQuirkContext(layoutState, layoutBox))118 if (BlockFormattingContext::Quirks::shouldIgnoreMarginTop(layoutState, layoutBox)) 136 119 return false; 137 120 … … 233 216 234 217 // FIXME: Find out the logic behind this. 235 if ( shouldIgnoreMarginTopInQuirkContext(layoutState, layoutBox))218 if (BlockFormattingContext::Quirks::shouldIgnoreMarginTop(layoutState, layoutBox)) 236 219 return 0; 237 220 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r238493 r238667 29 29 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 30 30 31 #include "FloatingContext.h" 31 32 #include "FloatingState.h" 32 33 #include "InlineFormattingState.h" -
trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.h
r238403 r238667 29 29 30 30 #include "InlineItem.h" 31 #include "InlineRunProvider.h" 31 32 32 33 namespace WebCore {
Note:
See TracChangeset
for help on using the changeset viewer.