Changeset 246483 in webkit
- Timestamp:
- Jun 16, 2019, 1:19:24 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
-
ChangeLog (modified) (1 diff)
-
layout/FormattingContext.cpp (modified) (1 diff)
-
layout/FormattingContext.h (modified) (1 diff)
-
layout/LayoutUnits.h (modified) (1 diff)
-
layout/inlineformatting/InlineFormattingContext.h (modified) (1 diff)
-
layout/inlineformatting/InlineFormattingContextLineLayout.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r246482 r246483 1 2019-06-16 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Intruding float may prevent adding any inline box 4 https://bugs.webkit.org/show_bug.cgi?id=198891 5 <rdar://problem/51779956> 6 7 Reviewed by Antti Koivisto. 8 9 Take the intruding left/right float pair and find the vertical position where the next line might go 10 if these floats prevent us from adding even one inline box to the current line. 11 12 * layout/FormattingContext.cpp: 13 (WebCore::Layout::FormattingContext::mapPointToAncestor): 14 (WebCore::Layout::FormattingContext::mapPointToDescendent): 15 * layout/FormattingContext.h: 16 * layout/LayoutUnits.h: 17 (WebCore::Layout::Point::max): 18 * layout/inlineformatting/InlineFormattingContext.h: 19 * layout/inlineformatting/InlineFormattingContextLineLayout.cpp: 20 (WebCore::Layout::InlineFormattingContext::LineLayout::placeInlineItems const): 21 (WebCore::Layout::InlineFormattingContext::LineLayout::layout const): 22 1 23 2019-06-16 Zalan Bujtas <zalan@apple.com> 2 24 -
trunk/Source/WebCore/layout/FormattingContext.cpp
r246479 r246483 212 212 } 213 213 214 Point FormattingContext::mapPointToAncestor(const LayoutState& layoutState, Point position, const Container& containingBlock, const Container& ancestor)215 { 216 if (& containingBlock == &ancestor)214 Point FormattingContext::mapPointToAncestor(const LayoutState& layoutState, Point position, const Container& from, const Container& to) 215 { 216 if (&from == &to) 217 217 return position; 218 ASSERT( containingBlock.isContainingBlockDescendantOf(ancestor));218 ASSERT(from.isContainingBlockDescendantOf(to)); 219 219 auto mappedPosition = position; 220 for (auto* container = & containingBlock; container && container != &ancestor; container = container->containingBlock())220 for (auto* container = &from; container && container != &to; container = container->containingBlock()) 221 221 mappedPosition.moveBy(layoutState.displayBoxForLayoutBox(*container).topLeft()); 222 222 return mappedPosition; 223 } 224 225 Point FormattingContext::mapPointToDescendent(const LayoutState& layoutState, Point point, const Container& from, const Container& to) 226 { 227 // "point" is in the coordinate system of the "from" container. 228 if (&from == &to) 229 return point; 230 ASSERT(to.isContainingBlockDescendantOf(from)); 231 for (auto* container = &to; container && container != &from; container = container->containingBlock()) 232 point.moveBy(-layoutState.displayBoxForLayoutBox(*container).topLeft()); 233 return point; 223 234 } 224 235 -
trunk/Source/WebCore/layout/FormattingContext.h
r246468 r246483 63 63 static LayoutUnit mapLeftToAncestor(const LayoutState&, const Box&, const Container& ancestor); 64 64 static LayoutUnit mapRightToAncestor(const LayoutState&, const Box&, const Container& ancestor); 65 static Point mapPointToAncestor(const LayoutState&, Point, const Container& containingBlock, const Container& ancestor); 65 static Point mapPointToAncestor(const LayoutState&, Point, const Container& from, const Container& to); 66 static Point mapPointToDescendent(const LayoutState&, Point, const Container& from, const Container& to); 66 67 67 68 protected: -
trunk/Source/WebCore/layout/LayoutUnits.h
r246482 r246483 60 60 Point(LayoutUnit, LayoutUnit); 61 61 Point(LayoutPoint); 62 static Point max() { return { LayoutUnit::max(), LayoutUnit::max() }; } 63 62 64 void move(LayoutSize); 63 65 void moveBy(LayoutPoint); -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h
r246154 r246483 80 80 unsigned firstInlineItemIndex { 0 }; 81 81 const InlineItems& inlineItems; 82 Optional<LayoutUnit> floatMinimumLogicalBottom; 82 83 }; 83 84 LineContent placeInlineItems(const LineInput&) const; -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp
r246482 r246483 162 162 }; 163 163 164 auto lineHasFloatBox = lineInput.floatMinimumLogicalBottom.hasValue(); 164 165 auto closeLine = [&] { 165 // This might change at some point.166 ASSERT(committedInlineItemCount);167 return LineContent { l ineInput.firstInlineItemIndex + (committedInlineItemCount - 1), WTFMove(floats), line->close() };166 ASSERT(committedInlineItemCount || lineHasFloatBox); 167 auto lastCommittedIndex = committedInlineItemCount ? Optional<unsigned> { lineInput.firstInlineItemIndex + (committedInlineItemCount - 1) } : WTF::nullopt; 168 return LineContent { lastCommittedIndex, WTFMove(floats), line->close() }; 168 169 }; 169 170 LineBreaker lineBreaker; … … 176 177 177 178 // FIXME: Ensure LineContext::trimmableWidth includes uncommitted content if needed. 178 auto breakingContext = lineBreaker.breakingContext(*inlineItem, itemLogicalWidth, { availableWidth, currentLogicalRight, line->trailingTrimmableWidth(), !line->hasContent() }); 179 auto lineIsConsideredEmpty = !line->hasContent() && !lineHasFloatBox; 180 auto breakingContext = lineBreaker.breakingContext(*inlineItem, itemLogicalWidth, { availableWidth, currentLogicalRight, line->trailingTrimmableWidth(), lineIsConsideredEmpty }); 179 181 if (breakingContext.isAtBreakingOpportunity) 180 182 commitPendingContent(); … … 201 203 floats.append(makeWeakPtr(*inlineItem)); 202 204 ++committedInlineItemCount; 205 lineHasFloatBox = true; 203 206 continue; 204 207 } … … 223 226 auto lineLogicalLeft = formattingRootDisplayBox.contentBoxLeft(); 224 227 225 auto applyFloatConstraint = [&](auto& line HorizontalConstraint) {228 auto applyFloatConstraint = [&](auto& lineInput) { 226 229 // Check for intruding floats and adjust logical left/available width for this line accordingly. 227 230 if (m_floatingState.isEmpty()) 228 231 return; 229 auto availableWidth = line HorizontalConstraint.availableLogicalWidth;230 auto lineLogicalLeft = line HorizontalConstraint.logicalTopLeft.x();232 auto availableWidth = lineInput.horizontalConstraint.availableLogicalWidth; 233 auto lineLogicalLeft = lineInput.horizontalConstraint.logicalTopLeft.x(); 231 234 auto floatConstraints = m_floatingState.constraints({ lineLogicalTop }, m_formattingRoot); 232 235 // Check if these constraints actually put limitation on the line. … … 237 240 floatConstraints.right = { }; 238 241 242 // Set the minimum float bottom value as a hint for the next line if needed. 243 static auto inifitePoint = PointInContextRoot::max(); 244 auto floatMinimumLogicalBottom = std::min(floatConstraints.left.valueOr(inifitePoint).y, floatConstraints.right.valueOr(inifitePoint).y); 245 if (floatMinimumLogicalBottom != inifitePoint.y) 246 lineInput.floatMinimumLogicalBottom = floatMinimumLogicalBottom; 247 239 248 if (floatConstraints.left && floatConstraints.right) { 240 ASSERT(floatConstraints.left->x < floatConstraints.right->x);249 ASSERT(floatConstraints.left->x <= floatConstraints.right->x); 241 250 availableWidth = floatConstraints.right->x - floatConstraints.left->x; 242 251 lineLogicalLeft = floatConstraints.left->x; 243 252 } else if (floatConstraints.left) { 244 ASSERT(floatConstraints.left->x > lineLogicalLeft);253 ASSERT(floatConstraints.left->x >= lineLogicalLeft); 245 254 availableWidth -= (floatConstraints.left->x - lineLogicalLeft); 246 255 lineLogicalLeft = floatConstraints.left->x; 247 256 } else if (floatConstraints.right) { 248 ASSERT(floatConstraints.right->x > lineLogicalLeft);257 ASSERT(floatConstraints.right->x >= lineLogicalLeft); 249 258 availableWidth = floatConstraints.right->x - lineLogicalLeft; 250 259 } 251 line HorizontalConstraint.availableLogicalWidth = availableWidth;252 line HorizontalConstraint.logicalTopLeft.setX(lineLogicalLeft);260 lineInput.horizontalConstraint.availableLogicalWidth = availableWidth; 261 lineInput.horizontalConstraint.logicalTopLeft.setX(lineLogicalLeft); 253 262 }; 254 263 … … 257 266 while (currentInlineItemIndex < inlineItems.size()) { 258 267 auto lineInput = LineInput { { lineLogicalLeft, lineLogicalTop }, widthConstraint, LineInput::SkipVerticalAligment::No, currentInlineItemIndex, inlineItems }; 259 applyFloatConstraint(lineInput .horizontalConstraint);268 applyFloatConstraint(lineInput); 260 269 auto lineContent = placeInlineItems(lineInput); 261 270 createDisplayRuns(*lineContent.runs, lineContent.floats, widthConstraint); 262 // We should always put at least one run on the line atm. This might change later on though. 263 ASSERT(lineContent.lastInlineItemIndex); 264 currentInlineItemIndex = *lineContent.lastInlineItemIndex + 1; 265 lineLogicalTop = lineContent.runs->logicalBottom(); 271 if (!lineContent.lastInlineItemIndex) { 272 // Floats prevented us putting any content on the line. 273 ASSERT(lineInput.floatMinimumLogicalBottom); 274 ASSERT(lineContent.runs->isEmpty()); 275 lineLogicalTop = *lineInput.floatMinimumLogicalBottom; 276 } else { 277 currentInlineItemIndex = *lineContent.lastInlineItemIndex + 1; 278 lineLogicalTop = lineContent.runs->logicalBottom(); 279 } 266 280 } 267 281 }
Note:
See TracChangeset
for help on using the changeset viewer.