⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 269041 in webkit


Ignore:
Timestamp:
Oct 27, 2020, 8:57:15 AM (6 years ago)
Author:
Antti Koivisto
Message:

[LFC][Integration] Use iterator for next/previousLinePosition
​https://bugs.webkit.org/show_bug.cgi?id=218233

Reviewed by Zalan Bujtas.

Add the required capabilities to the line iterator and also use them in a few other places.

  • editing/VisibleUnits.cpp:

(WebCore::absoluteLineDirectionPointToLocalPointInBlock):
(WebCore::previousLinePosition):
(WebCore::nextLinePosition):

  • layout/integration/LayoutIntegrationInlineContent.cpp:

(WebCore::LayoutIntegration::InlineContent::containingBlock const):

  • layout/integration/LayoutIntegrationInlineContent.h:
  • layout/integration/LayoutIntegrationLineIterator.cpp:

(WebCore::LayoutIntegration::firstLineFor):
(WebCore::LayoutIntegration::lastLineFor):
(WebCore::LayoutIntegration::LineIterator::closestRunForPoint):
(WebCore::LayoutIntegration::LineIterator::closestRunForLogicalLeftPosition):
(WebCore::LayoutIntegration::PathLine::blockDirectionPointInLine const):

  • layout/integration/LayoutIntegrationLineIterator.h:

(WebCore::LayoutIntegration::LineIterator::LineIterator):
(WebCore::LayoutIntegration::PathLine::y const):
(WebCore::LayoutIntegration::PathLine::logicalHeight const):
(WebCore::LayoutIntegration::PathLine::isHorizontal const):
(WebCore::LayoutIntegration::PathLine::containingBlock const):

  • layout/integration/LayoutIntegrationLineIteratorLegacyPath.h:

(WebCore::LayoutIntegration::LineIteratorLegacyPath::y const):
(WebCore::LayoutIntegration::LineIteratorLegacyPath::logicalHeight const):
(WebCore::LayoutIntegration::LineIteratorLegacyPath::isHorizontal const):
(WebCore::LayoutIntegration::LineIteratorLegacyPath::containingBlock const):

  • layout/integration/LayoutIntegrationLineIteratorModernPath.h:

(WebCore::LayoutIntegration::LineIteratorModernPath::y const):
(WebCore::LayoutIntegration::LineIteratorModernPath::logicalHeight const):
(WebCore::LayoutIntegration::LineIteratorModernPath::isHorizontal const):
(WebCore::LayoutIntegration::LineIteratorModernPath::containingBlock const):

  • layout/integration/LayoutIntegrationLineLayout.cpp:

(WebCore::LayoutIntegration::LineLayout::firstLine const):
(WebCore::LayoutIntegration::LineLayout::lastLine const):

  • layout/integration/LayoutIntegrationLineLayout.h:

(WebCore::LayoutIntegration::LineLayout::flow const):
(WebCore::LayoutIntegration::LineLayout::flow):

  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::findClosestTextAtAbsolutePoint):
(WebCore::RenderBlockFlow::positionForPointWithInlineChildren):

  • rendering/RootInlineBox.cpp:

(WebCore::isEditableLeaf): Deleted.
(WebCore::RootInlineBox::closestLeafChildForPoint): Deleted.
(WebCore::RootInlineBox::closestLeafChildForLogicalLeftPosition): Deleted.

This functionality moves to the line iterator.

  • rendering/RootInlineBox.h:
Location:
trunk/Source/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r269040 r269041  
     12020-10-27  Antti Koivisto  <antti@apple.com>
     2
     3        [LFC][Integration] Use iterator for next/previousLinePosition
     4        https://bugs.webkit.org/show_bug.cgi?id=218233
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Add the required capabilities to the line iterator and also use them in a few other places.
     9
     10        * editing/VisibleUnits.cpp:
     11        (WebCore::absoluteLineDirectionPointToLocalPointInBlock):
     12        (WebCore::previousLinePosition):
     13        (WebCore::nextLinePosition):
     14        * layout/integration/LayoutIntegrationInlineContent.cpp:
     15        (WebCore::LayoutIntegration::InlineContent::containingBlock const):
     16        * layout/integration/LayoutIntegrationInlineContent.h:
     17        * layout/integration/LayoutIntegrationLineIterator.cpp:
     18        (WebCore::LayoutIntegration::firstLineFor):
     19        (WebCore::LayoutIntegration::lastLineFor):
     20        (WebCore::LayoutIntegration::LineIterator::closestRunForPoint):
     21        (WebCore::LayoutIntegration::LineIterator::closestRunForLogicalLeftPosition):
     22        (WebCore::LayoutIntegration::PathLine::blockDirectionPointInLine const):
     23        * layout/integration/LayoutIntegrationLineIterator.h:
     24        (WebCore::LayoutIntegration::LineIterator::LineIterator):
     25        (WebCore::LayoutIntegration::PathLine::y const):
     26        (WebCore::LayoutIntegration::PathLine::logicalHeight const):
     27        (WebCore::LayoutIntegration::PathLine::isHorizontal const):
     28        (WebCore::LayoutIntegration::PathLine::containingBlock const):
     29        * layout/integration/LayoutIntegrationLineIteratorLegacyPath.h:
     30        (WebCore::LayoutIntegration::LineIteratorLegacyPath::y const):
     31        (WebCore::LayoutIntegration::LineIteratorLegacyPath::logicalHeight const):
     32        (WebCore::LayoutIntegration::LineIteratorLegacyPath::isHorizontal const):
     33        (WebCore::LayoutIntegration::LineIteratorLegacyPath::containingBlock const):
     34        * layout/integration/LayoutIntegrationLineIteratorModernPath.h:
     35        (WebCore::LayoutIntegration::LineIteratorModernPath::y const):
     36        (WebCore::LayoutIntegration::LineIteratorModernPath::logicalHeight const):
     37        (WebCore::LayoutIntegration::LineIteratorModernPath::isHorizontal const):
     38        (WebCore::LayoutIntegration::LineIteratorModernPath::containingBlock const):
     39        * layout/integration/LayoutIntegrationLineLayout.cpp:
     40        (WebCore::LayoutIntegration::LineLayout::firstLine const):
     41        (WebCore::LayoutIntegration::LineLayout::lastLine const):
     42        * layout/integration/LayoutIntegrationLineLayout.h:
     43        (WebCore::LayoutIntegration::LineLayout::flow const):
     44        (WebCore::LayoutIntegration::LineLayout::flow):
     45        * rendering/RenderBlockFlow.cpp:
     46        (WebCore::RenderBlockFlow::findClosestTextAtAbsolutePoint):
     47        (WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
     48        * rendering/RootInlineBox.cpp:
     49        (WebCore::isEditableLeaf): Deleted.
     50        (WebCore::RootInlineBox::closestLeafChildForPoint): Deleted.
     51        (WebCore::RootInlineBox::closestLeafChildForLogicalLeftPosition): Deleted.
     52
     53        This functionality moves to the line iterator.
     54
     55        * rendering/RootInlineBox.h:
     56
    1572020-10-27  Miguel Gomez  <magomez@igalia.com>
    258
  • trunk/Source/WebCore/editing/VisibleUnits.cpp

    r268260 r269041  
    982982}
    983983
    984 static inline IntPoint absoluteLineDirectionPointToLocalPointInBlock(RootInlineBox& root, int lineDirectionPoint)
    985 {
    986     RenderBlockFlow& containingBlock = root.blockFlow();
     984static inline IntPoint absoluteLineDirectionPointToLocalPointInBlock(LayoutIntegration::LineIterator& line, int lineDirectionPoint)
     985{
     986    auto& containingBlock = line->containingBlock();
    987987    FloatPoint absoluteBlockPoint = containingBlock.localToAbsolute(FloatPoint()) - toFloatSize(containingBlock.scrollPosition());
    988988
    989989    if (containingBlock.isHorizontalWritingMode())
    990         return IntPoint(lineDirectionPoint - absoluteBlockPoint.x(), root.blockDirectionPointInLine());
    991 
    992     return IntPoint(root.blockDirectionPointInLine(), lineDirectionPoint - absoluteBlockPoint.y());
     990        return IntPoint(lineDirectionPoint - absoluteBlockPoint.x(), line->blockDirectionPointInLine());
     991
     992    return IntPoint(line->blockDirectionPointInLine(), lineDirectionPoint - absoluteBlockPoint.y());
    993993}
    994994
    … …  
    10141014        return VisiblePosition();
    10151015
    1016     RootInlineBox* root = nullptr;
    1017     if (auto box = visiblePosition.inlineBoxAndOffset().box) {
    1018         root = box->root().prevRootBox();
     1016    LayoutIntegration::LineIterator line;
     1017    if (auto run = visiblePosition.inlineRunAndOffset().run) {
     1018        line = run.line().previous();
    10191019        // We want to skip zero height boxes.
    10201020        // This could happen in case it is a TrailingFloatsRootInlineBox.
    1021         if (!root || !root->logicalHeight() || !root->firstLeafDescendant())
    1022             root = nullptr;
    1023     }
    1024 
    1025     if (!root) {
     1021        if (!line || !line->logicalHeight() || !line.firstRun())
     1022            line = { };
     1023    }
     1024
     1025    if (!line) {
    10261026        Position position = previousRootInlineBoxCandidatePosition(node, visiblePosition, editableType);
    10271027        if (position.isNotNull()) {
    10281028            RenderedPosition renderedPosition(position);
    1029             root = renderedPosition.rootBox();
    1030             if (!root)
     1029            line = renderedPosition.line();
     1030            if (!line)
    10311031                return position;
    10321032        }
    10331033    }
    10341034   
    1035     if (root) {
     1035    if (line) {
    10361036        // FIXME: Can be wrong for multi-column layout and with transforms.
    1037         IntPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(*root, lineDirectionPoint);
    1038         RenderObject& renderer = root->closestLeafChildForPoint(pointInLine, isEditablePosition(p))->renderer();
     1037        auto pointInLine = absoluteLineDirectionPointToLocalPointInBlock(line, lineDirectionPoint);
     1038        auto& renderer = line.closestRunForPoint(pointInLine, isEditablePosition(p))->renderer();
    10391039        Node* node = renderer.node();
    10401040        if (node && editingIgnoresContent(*node))
    10411041            return positionInParentBeforeNode(node);
    1042         return renderer.positionForPoint(pointInLine, nullptr);
     1042        return const_cast<RenderObject&>(renderer).positionForPoint(pointInLine, nullptr);
    10431043    }
    10441044   
    … …  
    10641064        return VisiblePosition();
    10651065
    1066     RootInlineBox* root = nullptr;
    1067     if (auto box = visiblePosition.inlineBoxAndOffset().box) {
    1068         root = box->root().nextRootBox();
     1066    LayoutIntegration::LineIterator line;
     1067    if (auto run = visiblePosition.inlineRunAndOffset().run) {
     1068        line = run.line().next();
    10691069        // We want to skip zero height boxes.
    10701070        // This could happen in case it is a TrailingFloatsRootInlineBox.
    1071         if (!root || !root->logicalHeight() || !root->firstLeafDescendant())
    1072             root = nullptr;
    1073     }
    1074 
    1075     if (!root) {
     1071        if (!line || !line->logicalHeight() || !line.firstRun())
     1072            line = { };
     1073    }
     1074
     1075    if (!line) {
    10761076        // FIXME: We need do the same in previousLinePosition.
    10771077        Node* child = node->traverseToChildAt(p.deprecatedEditingOffset());
    … …  
    10801080        if (position.isNotNull()) {
    10811081            RenderedPosition renderedPosition(position);
    1082             root = renderedPosition.rootBox();
    1083             if (!root)
     1082            line = renderedPosition.line();
     1083            if (!line)
    10841084                return position;
    10851085        }
    10861086    }
    10871087   
    1088     if (root) {
     1088    if (line) {
    10891089        // FIXME: Can be wrong for multi-column layout and with transforms.
    1090         IntPoint pointInLine = absoluteLineDirectionPointToLocalPointInBlock(*root, lineDirectionPoint);
    1091         RenderObject& renderer = root->closestLeafChildForPoint(pointInLine, isEditablePosition(p))->renderer();
     1090        auto pointInLine = absoluteLineDirectionPointToLocalPointInBlock(line, lineDirectionPoint);
     1091        auto& renderer = line.closestRunForPoint(pointInLine, isEditablePosition(p))->renderer();
    10921092        Node* node = renderer.node();
    10931093        if (node && editingIgnoresContent(*node))
    10941094            return positionInParentBeforeNode(node);
    1095         return renderer.positionForPoint(pointInLine, nullptr);
     1095        return const_cast<RenderObject&>(renderer).positionForPoint(pointInLine, nullptr);
    10961096    }
    10971097
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.cpp

    r268798 r269041  
    6767}
    6868
     69const RenderBlockFlow& InlineContent::containingBlock() const
     70{
     71    return m_lineLayout->flow();
     72}
    6973
    7074}
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.h

    r268798 r269041  
    3636namespace WebCore {
    3737
     38class RenderBlockFlow;
    3839class RenderObject;
    3940
    … …  
    6364    const LineLayout& lineLayout() const;
    6465    const RenderObject& rendererForLayoutBox(const Layout::Box&) const;
     66    const RenderBlockFlow& containingBlock() const;
    6567
    6668private:
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.cpp

    r268329 r269041  
    109109}
    110110
     111LineIterator firstLineFor(const RenderBlockFlow& flow)
     112{
     113#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
     114    if (auto* lineLayout = flow.modernLineLayout())
     115        return lineLayout->firstLine();
     116#endif
     117
     118    return { LineIteratorLegacyPath { flow.firstRootBox() } };
     119}
     120
     121LineIterator lastLineFor(const RenderBlockFlow& flow)
     122{
     123#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
     124    if (auto* lineLayout = flow.modernLineLayout())
     125        return lineLayout->lastLine();
     126#endif
     127
     128    return { LineIteratorLegacyPath { flow.lastRootBox() } };
     129}
     130
     131LineRunIterator LineIterator::closestRunForPoint(const IntPoint& pointInContents, bool editableOnly)
     132{
     133    if (atEnd())
     134        return { };
     135    return closestRunForLogicalLeftPosition(m_line.isHorizontal() ? pointInContents.x() : pointInContents.y(), editableOnly);
     136}
     137
     138LineRunIterator LineIterator::closestRunForLogicalLeftPosition(int leftPosition, bool editableOnly)
     139{
     140    auto isEditable = [&](auto run)
     141    {
     142        return run && run->renderer().node() && run->renderer().node()->hasEditableStyle();
     143    };
     144
     145    auto firstRun = this->firstRun();
     146    auto lastRun = this->lastRun();
     147
     148    if (firstRun != lastRun) {
     149        if (firstRun->isLineBreak())
     150            firstRun = firstRun.nextOnLineIgnoringLineBreak();
     151        else if (lastRun->isLineBreak())
     152            lastRun = lastRun.previousOnLineIgnoringLineBreak();
     153    }
     154
     155    if (firstRun == lastRun && (!editableOnly || isEditable(firstRun)))
     156        return firstRun;
     157
     158    if (firstRun && leftPosition <= firstRun->logicalLeft() && !firstRun->renderer().isListMarker() && (!editableOnly || isEditable(firstRun)))
     159        return firstRun;
     160
     161    if (lastRun && leftPosition >= lastRun->logicalRight() && !lastRun->renderer().isListMarker() && (!editableOnly || isEditable(lastRun)))
     162        return lastRun;
     163
     164    auto closestRun = lastRun;
     165    for (auto run = firstRun; run; run = run.traverseNextOnLineIgnoringLineBreak()) {
     166        if (!run->renderer().isListMarker() && (!editableOnly || isEditable(run))) {
     167            if (leftPosition < run->logicalRight())
     168                return run;
     169            closestRun = run;
     170        }
     171    }
     172
     173    return closestRun;
     174}
     175
     176int PathLine::blockDirectionPointInLine() const
     177{
     178    return !containingBlock().style().isFlippedBlocksWritingMode() ? std::max(top(), selectionTop()) : std::min(bottom(), selectionBottom());
     179}
    111180
    112181}
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.h

    r268260 r269041  
    5757    LayoutUnit selectionBottom() const;
    5858
     59    float y() const;
     60    float logicalHeight() const;
     61
     62    int blockDirectionPointInLine() const;
     63
     64    bool isHorizontal() const;
     65
     66    const RenderBlockFlow& containingBlock() const;
     67
    5968protected:
    6069    friend class LineIterator;
    … …  
    6675public:
    6776    LineIterator() : m_line(LineIteratorLegacyPath { nullptr }) { };
     77    LineIterator(const RootInlineBox* rootInlineBox) : m_line(LineIteratorLegacyPath { rootInlineBox }) { };
    6878    LineIterator(PathLine::PathVariant&&);
    6979
    … …  
    92102    LineRunIterator logicalStartRunWithNode() const;
    93103    LineRunIterator logicalEndRunWithNode() const;
     104    LineRunIterator closestRunForPoint(const IntPoint& pointInContents, bool editableOnly);
     105    LineRunIterator closestRunForLogicalLeftPosition(int position, bool editableOnly = false);
    94106
    95107private:
    … …  
    97109};
    98110
    99 LineIterator lineFor(const PathIterator&);
     111LineIterator firstLineFor(const RenderBlockFlow&);
     112LineIterator lastLineFor(const RenderBlockFlow&);
    100113
    101114// -----------------------------------------------
    … …  
    141154}
    142155
     156inline float PathLine::y() const
     157{
     158    return WTF::switchOn(m_pathVariant, [](const auto& path) {
     159        return path.y();
     160    });
     161}
     162
     163inline float PathLine::logicalHeight() const
     164{
     165    return WTF::switchOn(m_pathVariant, [](const auto& path) {
     166        return path.logicalHeight();
     167    });
     168}
     169
     170inline bool PathLine::isHorizontal() const
     171{
     172    return WTF::switchOn(m_pathVariant, [](const auto& path) {
     173        return path.isHorizontal();
     174    });
     175}
     176
     177inline const RenderBlockFlow& PathLine::containingBlock() const
     178{
     179    return WTF::switchOn(m_pathVariant, [](const auto& path) -> const RenderBlockFlow& {
     180        return path.containingBlock();
     181    });
     182}
     183
    143184}
    144185}
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorLegacyPath.h

    r268329 r269041  
    5151    LayoutUnit selectionBottom() const { return m_rootInlineBox->selectionBottom(); }
    5252
     53    float y() const { return m_rootInlineBox->y(); }
     54    float logicalHeight() const { return m_rootInlineBox->logicalHeight(); }
     55    bool isHorizontal() const { return m_rootInlineBox->isHorizontal(); }
     56
     57    const RenderBlockFlow& containingBlock() const { return m_rootInlineBox->blockFlow(); }
     58
    5359    void traverseNext()
    5460    {
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h

    r268798 r269041  
    5555    LayoutUnit selectionTopForHitTesting() const { return top(); }
    5656    LayoutUnit selectionBottom() const { return bottom(); }
     57
     58    float y() const { return top(); }
     59    float logicalHeight() const { return line().rect().height(); }
     60    bool isHorizontal() const { return true; }
     61
     62    const RenderBlockFlow& containingBlock() const { return m_inlineContent->containingBlock(); }
    5763
    5864    void traverseNext()
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp

    r269038 r269041  
    405405}
    406406
     407LineIterator LineLayout::firstLine() const
     408{
     409    if (!m_inlineContent)
     410        return { };
     411
     412    return { LineIteratorModernPath(*m_inlineContent, 0) };
     413}
     414
     415LineIterator LineLayout::lastLine() const
     416{
     417    if (!m_inlineContent)
     418        return { };
     419
     420    return { LineIteratorModernPath(*m_inlineContent, m_inlineContent->lines.isEmpty() ? 0 : m_inlineContent->lines.size() - 1) };
     421}
     422
    407423const RenderObject& LineLayout::rendererForLayoutBox(const Layout::Box& layoutBox) const
    408424{
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h

    r268798 r269041  
    2929
    3030#include "LayoutIntegrationBoxTree.h"
     31#include "LayoutIntegrationLineIterator.h"
    3132#include "LayoutIntegrationRunIterator.h"
    3233#include "LayoutPoint.h"
    … …  
    8485    TextRunIterator textRunsFor(const RenderText&) const;
    8586    RunIterator runFor(const RenderElement&) const;
     87    LineIterator firstLine() const;
     88    LineIterator lastLine() const;
    8689
    8790    const RenderObject& rendererForLayoutBox(const Layout::Box&) const;
     91    const RenderBlockFlow& flow() const { return m_boxTree.flow(); }
    8892
    8993    static void releaseCaches(RenderView&);
    … …  
    96100
    97101    RenderBlockFlow& flow() { return m_boxTree.flow(); }
    98     const RenderBlockFlow& flow() const { return m_boxTree.flow(); }
    99102
    100103    const Layout::ContainerBox& rootLayoutBox() const;
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r268994 r269041  
    33703370    // experience has shown that hit tests on an exploded text node can fail when within the
    33713371    // overflow fragment.
    3372     for (RootInlineBox* current = blockFlow.firstRootBox(); current && current != blockFlow.lastRootBox(); current = current->nextRootBox()) {
     3372    for (auto current = LayoutIntegration::firstLineFor(blockFlow), last = LayoutIntegration::lastLineFor(blockFlow); current && current != last; current.traverseNext()) {
    33733373        float currentBottom = current->y() + current->logicalHeight();
    33743374        if (localPoint.y() < currentBottom)
    33753375            return nullptr;
    33763376       
    3377         RootInlineBox* next = current->nextRootBox();
     3377        auto next = current.next();
    33783378        float nextTop = next->y();
    33793379        if (localPoint.y() < nextTop) {
    3380             InlineBox* inlineBox = current->closestLeafChildForLogicalLeftPosition(localPoint.x());
    3381             if (inlineBox && inlineBox->behavesLikeText() && is<RenderText>(inlineBox->renderer()))
    3382                 return &downcast<RenderText>(inlineBox->renderer());
     3380            auto run = current.closestRunForLogicalLeftPosition(localPoint.x());
     3381            if (run && is<RenderText>(run->renderer()))
     3382                return const_cast<RenderText*>(&downcast<RenderText>(run->renderer()));
    33833383        }
    33843384    }
    … …  
    34283428                    continue;
    34293429            }
    3430             closestBox = root->closestLeafChildForLogicalLeftPosition(pointInLogicalContents.x());
     3430            if (auto closestRun = LayoutIntegration::LineIterator(root).closestRunForLogicalLeftPosition(pointInLogicalContents.x()))
     3431                closestBox = closestRun->legacyInlineBox();
    34313432            if (closestBox)
    34323433                break;
    … …  
    34383439    if (!moveCaretToBoundary && !closestBox && lastRootBoxWithChildren) {
    34393440        // y coordinate is below last root line box, pretend we hit it
    3440         closestBox = lastRootBoxWithChildren->closestLeafChildForLogicalLeftPosition(pointInLogicalContents.x());
     3441        auto closestRun = LayoutIntegration::LineIterator(lastRootBoxWithChildren).closestRunForLogicalLeftPosition(pointInLogicalContents.x());
     3442        closestBox = closestRun ? closestRun->legacyInlineBox() : nullptr;
    34413443    }
    34423444
  • trunk/Source/WebCore/rendering/RootInlineBox.cpp

    r262127 r269041  
    761761}
    762762
    763 static bool isEditableLeaf(InlineBox* leaf)
    764 {
    765     return leaf && leaf->renderer().node() && leaf->renderer().node()->hasEditableStyle();
    766 }
    767 
    768 InlineBox* RootInlineBox::closestLeafChildForPoint(const IntPoint& pointInContents, bool onlyEditableLeaves)
    769 {
    770     return closestLeafChildForLogicalLeftPosition(blockFlow().isHorizontalWritingMode() ? pointInContents.x() : pointInContents.y(), onlyEditableLeaves);
    771 }
    772 
    773 InlineBox* RootInlineBox::closestLeafChildForLogicalLeftPosition(int leftPosition, bool onlyEditableLeaves)
    774 {
    775     InlineBox* firstLeaf = firstLeafDescendant();
    776     InlineBox* lastLeaf = lastLeafDescendant();
    777 
    778     if (firstLeaf != lastLeaf) {
    779         if (firstLeaf->isLineBreak())
    780             firstLeaf = firstLeaf->nextLeafOnLineIgnoringLineBreak();
    781         else if (lastLeaf->isLineBreak())
    782             lastLeaf = lastLeaf->previousLeafOnLineIgnoringLineBreak();
    783     }
    784 
    785     if (firstLeaf == lastLeaf && (!onlyEditableLeaves || isEditableLeaf(firstLeaf)))
    786         return firstLeaf;
    787 
    788     // Avoid returning a list marker when possible.
    789     if (firstLeaf && leftPosition <= firstLeaf->logicalLeft() && !firstLeaf->renderer().isListMarker() && (!onlyEditableLeaves || isEditableLeaf(firstLeaf)))
    790         // The leftPosition coordinate is less or equal to left edge of the firstLeaf.
    791         // Return it.
    792         return firstLeaf;
    793 
    794     if (lastLeaf && leftPosition >= lastLeaf->logicalRight() && !lastLeaf->renderer().isListMarker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf)))
    795         // The leftPosition coordinate is greater or equal to right edge of the lastLeaf.
    796         // Return it.
    797         return lastLeaf;
    798 
    799     InlineBox* closestLeaf = nullptr;
    800     for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafOnLineIgnoringLineBreak()) {
    801         if (!leaf->renderer().isListMarker() && (!onlyEditableLeaves || isEditableLeaf(leaf))) {
    802             closestLeaf = leaf;
    803             if (leftPosition < leaf->logicalRight())
    804                 // The x coordinate is less than the right edge of the box.
    805                 // Return it.
    806                 return leaf;
    807         }
    808     }
    809 
    810     return closestLeaf ? closestLeaf : lastLeaf;
    811 }
    812 
    813763BidiStatus RootInlineBox::lineBreakBidiStatus() const
    814764{
  • trunk/Source/WebCore/rendering/RootInlineBox.h

    r260367 r269041  
    137137    IntRect computeCaretRect(float logicalLeftPosition, unsigned caretWidth, LayoutUnit* extraWidthToEndOfLine) const;
    138138
    139     InlineBox* closestLeafChildForPoint(const IntPoint&, bool onlyEditableLeaves);
    140     InlineBox* closestLeafChildForLogicalLeftPosition(int, bool onlyEditableLeaves = false);
    141 
    142139    using CleanLineFloatList = Vector<WeakPtr<RenderBox>>;
    143140    void appendFloat(RenderBox& floatingBox)
Note: See TracChangeset for help on using the changeset viewer.