InlineBox* RootInlineBox::closestLeafChildForXPos(int x, bool onlyEditableLeaves) { InlineBox* firstLeaf = firstLeafChild(); InlineBox* lastLeaf = lastLeafChild(); if (firstLeaf == lastLeaf && (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) return firstLeaf; // Avoid returning a list marker when possible. if (x <= firstLeaf->m_x && !firstLeaf->renderer()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) // The x coordinate is less or equal to left edge of the firstLeaf. // Return it. return firstLeaf; if (x >= lastLeaf->m_x + lastLeaf->m_width && !lastLeaf->renderer()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf))) // The x coordinate is greater or equal to right edge of the lastLeaf. // Return it. return lastLeaf; InlineBox* closestLeaf = 0; for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChild()) { if (!leaf->renderer()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(leaf))) { closestLeaf = leaf; if (x < leaf->m_x + leaf->m_width) // The x coordinate is less than the right edge of the box. // Return it. return leaf; } } return closestLeaf ? closestLeaf : lastLeaf; }
InlineBox* RootInlineBox::firstSelectedBox() { for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { if (box->selectionState() != RenderObject::SelectionNone) return box; } return 0; }
bool SVGRootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction hitTestAction) { for (InlineBox* leaf = firstLeafChild(); leaf; leaf = leaf->nextLeafChild()) { if (!leaf->isSVGInlineTextBox()) continue; if (leaf->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, lineTop, lineBottom, hitTestAction)) return true; } return false; }
bool RootInlineBox::isHyphenated() const { for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { if (box->isInlineTextBox()) { if (toInlineTextBox(box)->hasHyphen()) return true; } } return false; }
RenderObject::SelectionState RootInlineBox::selectionState() { // Walk over all of the selected boxes. RenderObject::SelectionState state = RenderObject::SelectionNone; for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { RenderObject::SelectionState boxState = box->selectionState(); if ((boxState == RenderObject::SelectionStart && state == RenderObject::SelectionEnd) || (boxState == RenderObject::SelectionEnd && state == RenderObject::SelectionStart)) state = RenderObject::SelectionBoth; else if (state == RenderObject::SelectionNone || ((boxState == RenderObject::SelectionStart || boxState == RenderObject::SelectionEnd) && (state == RenderObject::SelectionNone || state == RenderObject::SelectionInside))) state = boxState; if (state == RenderObject::SelectionBoth) break; } return state; }
InlineBox* SVGRootInlineBox::closestLeafChildForPosition(const IntPoint& point) { InlineBox* firstLeaf = firstLeafChild(); InlineBox* lastLeaf = lastLeafChild(); if (firstLeaf == lastLeaf) return firstLeaf; // FIXME: Check for vertical text! InlineBox* closestLeaf = 0; for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChild()) { if (point.y() < leaf->m_y) continue; if (point.y() > leaf->m_y + leaf->virtualLogicalHeight()) continue; closestLeaf = leaf; if (point.x() < leaf->m_x + leaf->m_logicalWidth) return leaf; } return closestLeaf ? closestLeaf : lastLeaf; }
InlineBox* RootInlineBox::closestLeafChildForLogicalLeftPosition(int leftPosition, bool onlyEditableLeaves) { InlineBox* firstLeaf = firstLeafChild(); InlineBox* lastLeaf = lastLeafChild(); if (firstLeaf != lastLeaf) { if (firstLeaf->isLineBreak()) firstLeaf = firstLeaf->nextLeafChildIgnoringLineBreak(); else if (lastLeaf->isLineBreak()) lastLeaf = lastLeaf->prevLeafChildIgnoringLineBreak(); } if (firstLeaf == lastLeaf && (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) return firstLeaf; // Avoid returning a list marker when possible. if (leftPosition <= firstLeaf->logicalLeft() && !firstLeaf->renderer().isListMarker() && (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) // The leftPosition coordinate is less or equal to left edge of the firstLeaf. // Return it. return firstLeaf; if (leftPosition >= lastLeaf->logicalRight() && !lastLeaf->renderer().isListMarker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf))) // The leftPosition coordinate is greater or equal to right edge of the lastLeaf. // Return it. return lastLeaf; InlineBox* closestLeaf = 0; for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChildIgnoringLineBreak()) { if (!leaf->renderer().isListMarker() && (!onlyEditableLeaves || isEditableLeaf(leaf))) { closestLeaf = leaf; if (leftPosition < leaf->logicalRight()) // The x coordinate is less than the right edge of the box. // Return it. return leaf; } } return closestLeaf ? closestLeaf : lastLeaf; }
InlineBox* SVGRootInlineBox::closestLeafChildForPosition(const LayoutPoint& point) { InlineBox* firstLeaf = firstLeafChild(); InlineBox* lastLeaf = lastLeafChild(); if (firstLeaf == lastLeaf) return firstLeaf; // FIXME: Check for vertical text! InlineBox* closestLeaf = nullptr; for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChild()) { if (!leaf->isSVGInlineTextBox()) continue; if (point.y() < leaf->y()) continue; if (point.y() > leaf->y() + leaf->virtualLogicalHeight()) continue; closestLeaf = leaf; if (point.x() < leaf->left() + leaf->logicalWidth()) return leaf; } return closestLeaf ? closestLeaf : lastLeaf; }