Changeset 269146 in webkit
- Timestamp:
- Oct 29, 2020, 7:21:34 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
-
ChangeLog (modified) (1 diff)
-
layout/integration/LayoutIntegrationLineIterator.h (modified) (5 diffs)
-
layout/integration/LayoutIntegrationLineIteratorLegacyPath.h (modified) (2 diffs)
-
layout/integration/LayoutIntegrationLineIteratorModernPath.h (modified) (2 diffs)
-
layout/integration/LayoutIntegrationRunIteratorModernPath.h (modified) (1 diff)
-
rendering/RenderBlockFlow.cpp (modified) (5 diffs)
-
rendering/RenderBlockFlow.h (modified) (1 diff)
-
rendering/RootInlineBox.cpp (modified) (1 diff)
-
rendering/RootInlineBox.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r269145 r269146 1 2020-10-29 Antti Koivisto <antti@apple.com> 2 3 [LFC][Integration] RenderBlockFlow::positionForPointWithInlineChildren should use iterator 4 https://bugs.webkit.org/show_bug.cgi?id=218283 5 6 Reviewed by Zalan Bujtas. 7 8 Reduce InlineBox access and eliminate one ensureLineBoxes() call. 9 10 * layout/integration/LayoutIntegrationLineIterator.h: 11 (WebCore::LayoutIntegration::PathLine::topWithLeading const): 12 (WebCore::LayoutIntegration::PathLine::bottomWithLeading const): 13 (WebCore::LayoutIntegration::PathLine::legacyRootInlineBox const): 14 * layout/integration/LayoutIntegrationLineIteratorLegacyPath.h: 15 (WebCore::LayoutIntegration::LineIteratorLegacyPath::topWithLeading const): 16 (WebCore::LayoutIntegration::LineIteratorLegacyPath::bottomWithLeading const): 17 (WebCore::LayoutIntegration::LineIteratorLegacyPath::legacyRootInlineBox const): 18 * layout/integration/LayoutIntegrationLineIteratorModernPath.h: 19 (WebCore::LayoutIntegration::LineIteratorModernPath::topWithLeading const): 20 (WebCore::LayoutIntegration::LineIteratorModernPath::bottomWithLeading const): 21 (WebCore::LayoutIntegration::LineIteratorModernPath::legacyRootInlineBox const): 22 * layout/integration/LayoutIntegrationRunIteratorModernPath.h: 23 (WebCore::LayoutIntegration::RunIteratorModernPath::legacyInlineBox const): 24 * rendering/RenderBlockFlow.cpp: 25 (WebCore::positionForRun): 26 (WebCore::RenderBlockFlow::positionForPointWithInlineChildren): 27 (WebCore::RenderBlockFlow::positionForBox const): Deleted. 28 * rendering/RenderBlockFlow.h: 29 1 30 2020-10-29 Zalan Bujtas <zalan@apple.com> 2 31 -
trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.h
r269041 r269146 56 56 LayoutUnit selectionTopForHitTesting() const; 57 57 LayoutUnit selectionBottom() const; 58 LayoutUnit topWithLeading() const; 59 LayoutUnit bottomWithLeading() const; 58 60 59 61 float y() const; … … 65 67 66 68 const RenderBlockFlow& containingBlock() const; 69 const RootInlineBox* legacyRootInlineBox() const; 67 70 68 71 protected: … … 129 132 { 130 133 return WTF::switchOn(m_pathVariant, [](const auto& path) { 131 return path. top();134 return path.bottom(); 132 135 }); 133 136 } … … 151 154 return WTF::switchOn(m_pathVariant, [](const auto& path) { 152 155 return path.selectionBottom(); 156 }); 157 } 158 159 inline LayoutUnit PathLine::topWithLeading() const 160 { 161 return WTF::switchOn(m_pathVariant, [](const auto& path) { 162 return path.topWithLeading(); 163 }); 164 } 165 166 inline LayoutUnit PathLine::bottomWithLeading() const 167 { 168 return WTF::switchOn(m_pathVariant, [](const auto& path) { 169 return path.bottomWithLeading(); 153 170 }); 154 171 } … … 182 199 } 183 200 184 } 185 } 186 201 inline const RootInlineBox* PathLine::legacyRootInlineBox() const 202 { 203 return WTF::switchOn(m_pathVariant, [](const auto& path) { 204 return path.legacyRootInlineBox(); 205 }); 206 } 207 208 } 209 } 210 -
trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorLegacyPath.h
r269041 r269146 50 50 LayoutUnit selectionTopForHitTesting() const { return m_rootInlineBox->selectionTop(RootInlineBox::ForHitTesting::Yes); } 51 51 LayoutUnit selectionBottom() const { return m_rootInlineBox->selectionBottom(); } 52 LayoutUnit topWithLeading() const { return m_rootInlineBox->lineTopWithLeading(); } 53 LayoutUnit bottomWithLeading() const { return m_rootInlineBox->lineBottomWithLeading(); } 52 54 53 55 float y() const { return m_rootInlineBox->y(); } … … 56 58 57 59 const RenderBlockFlow& containingBlock() const { return m_rootInlineBox->blockFlow(); } 60 const RootInlineBox* legacyRootInlineBox() const { return m_rootInlineBox; } 58 61 59 62 void traverseNext() -
trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h
r269041 r269146 52 52 LayoutUnit top() const { return LayoutUnit::fromFloatRound(line().rect().y()); } 53 53 LayoutUnit bottom() const { return LayoutUnit::fromFloatRound(line().rect().maxY()); } 54 // FIXME: What should these really be? 54 55 LayoutUnit selectionTop() const { return top(); } 55 56 LayoutUnit selectionTopForHitTesting() const { return top(); } 56 57 LayoutUnit selectionBottom() const { return bottom(); } 58 LayoutUnit topWithLeading() const { return top(); } 59 LayoutUnit bottomWithLeading() const { return bottom(); } 57 60 58 61 float y() const { return top(); } … … 61 64 62 65 const RenderBlockFlow& containingBlock() const { return m_inlineContent->containingBlock(); } 66 const RootInlineBox* legacyRootInlineBox() const { return nullptr; } 63 67 64 68 void traverseNext() -
trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h
r268817 r269146 171 171 InlineBox* legacyInlineBox() const 172 172 { 173 ASSERT_NOT_REACHED();174 173 return nullptr; 175 174 } -
trunk/Source/WebCore/rendering/RenderBlockFlow.cpp
r269145 r269146 3307 3307 } 3308 3308 3309 Position RenderBlockFlow::positionForBox(InlineBox *box, bool start) const 3310 { 3311 if (! box)3309 static Position positionForRun(const RenderBlockFlow& flow, LayoutIntegration::RunIterator run, bool start) 3310 { 3311 if (!run) 3312 3312 return Position(); 3313 3313 3314 if (! box->renderer().nonPseudoNode())3315 return makeDeprecatedLegacyPosition( nonPseudoElement(), start ? caretMinOffset() :caretMaxOffset());3316 3317 if (!is< InlineTextBox>(*box))3318 return makeDeprecatedLegacyPosition( box->renderer().nonPseudoNode(), start ? box->renderer().caretMinOffset() : box->renderer().caretMaxOffset());3319 3320 auto& text Box = downcast<InlineTextBox>(*box);3321 return makeDeprecatedLegacyPosition(text Box.renderer().nonPseudoNode(), start ? textBox.start() : textBox.start() + textBox.len());3314 if (!run->renderer().nonPseudoNode()) 3315 return makeDeprecatedLegacyPosition(flow.nonPseudoElement(), start ? flow.caretMinOffset() : flow.caretMaxOffset()); 3316 3317 if (!is<LayoutIntegration::TextRunIterator>(run)) 3318 return makeDeprecatedLegacyPosition(run->renderer().nonPseudoNode(), start ? run->renderer().caretMinOffset() : run->renderer().caretMaxOffset()); 3319 3320 auto& textRun = downcast<LayoutIntegration::TextRunIterator>(run); 3321 return makeDeprecatedLegacyPosition(textRun->renderer().nonPseudoNode(), start ? textRun->localStartOffset() : textRun->localEndOffset()); 3322 3322 } 3323 3323 … … 3391 3391 ASSERT(childrenInline()); 3392 3392 3393 ensureLineBoxes();3394 3395 if (!first RootBox())3393 auto firstLine = LayoutIntegration::firstLineFor(*this); 3394 3395 if (!firstLine) 3396 3396 return createVisiblePosition(0, Affinity::Downstream); 3397 3397 … … 3400 3400 3401 3401 // look for the closest line box in the root box which is at the passed-in y coordinate 3402 InlineBox* closestBox = 0;3403 RootInlineBox* firstRootBoxWithChildren = 0;3404 RootInlineBox* lastRootBoxWithChildren = 0;3405 for ( RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox()) {3406 if (fragment && root->containingFragment() != fragment)3402 LayoutIntegration::RunIterator closestRun; 3403 LayoutIntegration::LineIterator firstLineWithChildren; 3404 LayoutIntegration::LineIterator lastLineWithChildren; 3405 for (auto line = firstLine; line; line.traverseNext()) { 3406 if (fragment && line->legacyRootInlineBox() && line->legacyRootInlineBox()->containingFragment() != fragment) 3407 3407 continue; 3408 3408 3409 if (! root->firstLeafDescendant())3409 if (!line.firstRun()) 3410 3410 continue; 3411 if (!first RootBoxWithChildren)3412 first RootBoxWithChildren = root;3413 3414 if (!linesAreFlipped && root->isFirstAfterPageBreak() && (pointInLogicalContents.y() < root->lineTopWithLeading()3415 || (blocksAreFlipped && pointInLogicalContents.y() == root->lineTopWithLeading())))3411 if (!firstLineWithChildren) 3412 firstLineWithChildren = line; 3413 3414 if (!linesAreFlipped && line->legacyRootInlineBox() && line->legacyRootInlineBox()->isFirstAfterPageBreak() 3415 && (pointInLogicalContents.y() < line->topWithLeading() || (blocksAreFlipped && pointInLogicalContents.y() == line->topWithLeading()))) 3416 3416 break; 3417 3417 3418 last RootBoxWithChildren = root;3418 lastLineWithChildren = line; 3419 3419 3420 3420 // check if this root line box is located at this y coordinate 3421 if (pointInLogicalContents.y() < root->selectionBottom() || (blocksAreFlipped && pointInLogicalContents.y() == root->selectionBottom())) {3421 if (pointInLogicalContents.y() < line->selectionBottom() || (blocksAreFlipped && pointInLogicalContents.y() == line->selectionBottom())) { 3422 3422 if (linesAreFlipped) { 3423 RootInlineBox* nextRootBoxWithChildren = root->nextRootBox();3424 while (next RootBoxWithChildren && !nextRootBoxWithChildren->firstLeafDescendant())3425 next RootBoxWithChildren = nextRootBoxWithChildren->nextRootBox();3426 3427 if (next RootBoxWithChildren && nextRootBoxWithChildren->isFirstAfterPageBreak() && (pointInLogicalContents.y() > nextRootBoxWithChildren->lineTopWithLeading()3428 || (!blocksAreFlipped && pointInLogicalContents.y() == nextRootBoxWithChildren->lineTopWithLeading())))3423 auto nextLineWithChildren = line.next(); 3424 while (nextLineWithChildren && !nextLineWithChildren.firstRun()) 3425 nextLineWithChildren.traverseNext(); 3426 3427 if (nextLineWithChildren && nextLineWithChildren->legacyRootInlineBox() && nextLineWithChildren->legacyRootInlineBox()->isFirstAfterPageBreak() 3428 && (pointInLogicalContents.y() > nextLineWithChildren->topWithLeading() || (!blocksAreFlipped && pointInLogicalContents.y() == nextLineWithChildren->topWithLeading()))) 3429 3429 continue; 3430 3430 } 3431 if (auto closestRun = LayoutIntegration::LineIterator(root).closestRunForLogicalLeftPosition(pointInLogicalContents.x())) 3432 closestBox = closestRun->legacyInlineBox(); 3433 if (closestBox) 3431 closestRun = line.closestRunForLogicalLeftPosition(pointInLogicalContents.x()); 3432 if (closestRun) 3434 3433 break; 3435 3434 } … … 3438 3437 bool moveCaretToBoundary = frame().editor().behavior().shouldMoveCaretToHorizontalBoundaryWhenPastTopOrBottom(); 3439 3438 3440 if (!moveCaretToBoundary && !closest Box && lastRootBoxWithChildren) {3439 if (!moveCaretToBoundary && !closestRun && lastLineWithChildren) { 3441 3440 // y coordinate is below last root line box, pretend we hit it 3442 auto closestRun = LayoutIntegration::LineIterator(lastRootBoxWithChildren).closestRunForLogicalLeftPosition(pointInLogicalContents.x()); 3443 closestBox = closestRun ? closestRun->legacyInlineBox() : nullptr; 3444 } 3445 3446 if (closestBox) { 3441 closestRun = lastLineWithChildren.closestRunForLogicalLeftPosition(pointInLogicalContents.x()); 3442 } 3443 3444 if (closestRun) { 3447 3445 if (moveCaretToBoundary) { 3448 LayoutUnit first RootBoxWithChildrenTop = std::min(firstRootBoxWithChildren->selectionTop(RootInlineBox::ForHitTesting::Yes), LayoutUnit(firstRootBoxWithChildren->logicalTop()));3449 if (pointInLogicalContents.y() < first RootBoxWithChildrenTop3450 || (blocksAreFlipped && pointInLogicalContents.y() == first RootBoxWithChildrenTop)) {3451 InlineBox* box = firstRootBoxWithChildren->firstLeafDescendant();3452 if ( box->isLineBreak()) {3453 if ( InlineBox* newBox = box->nextLeafOnLineIgnoringLineBreak())3454 box = newBox;3446 LayoutUnit firstLineWithChildrenTop = std::min(firstLineWithChildren->selectionTopForHitTesting(), LayoutUnit(firstLineWithChildren->top())); 3447 if (pointInLogicalContents.y() < firstLineWithChildrenTop 3448 || (blocksAreFlipped && pointInLogicalContents.y() == firstLineWithChildrenTop)) { 3449 auto run = firstLineWithChildren.firstRun(); 3450 if (run->isLineBreak()) { 3451 if (auto next = run.nextOnLineIgnoringLineBreak()) 3452 run = next; 3455 3453 } 3456 3454 // y coordinate is above first root line box, so return the start of the first 3457 return positionFor Box(box, true);3455 return positionForRun(*this, run, true); 3458 3456 } 3459 3457 } 3460 3458 3461 3459 // pass the box a top position that is inside it 3462 LayoutPoint point(pointInLogicalContents.x(), closest Box->root().blockDirectionPointInLine());3460 LayoutPoint point(pointInLogicalContents.x(), closestRun.line()->blockDirectionPointInLine()); 3463 3461 if (!isHorizontalWritingMode()) 3464 3462 point = point.transposedPoint(); 3465 if (closest Box->renderer().isReplaced())3466 return positionForPointRespectingEditingBoundaries(*this, downcast<RenderBox>(closestBox->renderer()), point);3467 return c losestBox->renderer().positionForPoint(point, nullptr);3468 } 3469 3470 if (last RootBoxWithChildren) {3463 if (closestRun->renderer().isReplaced()) 3464 return positionForPointRespectingEditingBoundaries(*this, const_cast<RenderBox&>(downcast<RenderBox>(closestRun->renderer())), point); 3465 return const_cast<RenderObject&>(closestRun->renderer()).positionForPoint(point, nullptr); 3466 } 3467 3468 if (lastLineWithChildren) { 3471 3469 // We hit this case for Mac behavior when the Y coordinate is below the last box. 3472 3470 ASSERT(moveCaretToBoundary); 3473 InlineBox* logicallyLastBox; 3474 if (lastRootBoxWithChildren->getLogicalEndBoxWithNode(logicallyLastBox)) 3475 return positionForBox(logicallyLastBox, false); 3471 if (auto logicallyLastRun = lastLineWithChildren.logicalEndRunWithNode()) 3472 return positionForRun(*this, logicallyLastRun, false); 3476 3473 } 3477 3474 … … 3484 3481 Position RenderBlockFlow::positionForPoint(const LayoutPoint& point) 3485 3482 { 3486 // FIXME: This forces Complex Line Layout.3487 3483 return positionForPoint(point, nullptr).deepEquivalent(); 3488 3484 } -
trunk/Source/WebCore/rendering/RenderBlockFlow.h
r268994 r269146 528 528 LayoutUnit& lastLogicalTop, LayoutUnit& lastLogicalLeft, LayoutUnit& lastLogicalRight, const LogicalSelectionOffsetCaches&, const PaintInfo*) override; 529 529 530 Position positionForBox(InlineBox*, bool start = true) const;531 530 VisiblePosition positionForPointWithInlineChildren(const LayoutPoint& pointInLogicalContents, const RenderFragmentContainer*) override; 532 531 void addFocusRingRectsForInlineChildren(Vector<LayoutRect>& rects, const LayoutPoint& additionalOffset, const RenderLayerModelObject*) override; -
trunk/Source/WebCore/rendering/RootInlineBox.cpp
r269064 r269146 751 751 } 752 752 753 int RootInlineBox::blockDirectionPointInLine() const754 {755 return !blockFlow().style().isFlippedBlocksWritingMode() ? std::max(lineTop(), selectionTop()) : std::min(lineBottom(), selectionBottom());756 }757 758 753 RenderBlockFlow& RootInlineBox::blockFlow() const 759 754 { -
trunk/Source/WebCore/rendering/RootInlineBox.h
r269064 r269146 80 80 LayoutUnit selectionTopAdjustedForPrecedingBlock() const; 81 81 LayoutUnit selectionHeightAdjustedForPrecedingBlock() const { return std::max<LayoutUnit>(0, selectionBottom() - selectionTopAdjustedForPrecedingBlock()); } 82 83 int blockDirectionPointInLine() const;84 82 85 83 LayoutUnit alignBoxesInBlockDirection(LayoutUnit heightOfBlock, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
Note:
See TracChangeset
for help on using the changeset viewer.