PositionWithAffinity RenderReplaced::positionForPoint(const LayoutPoint& point) { // FIXME: This code is buggy if the replaced element is relative positioned. InlineBox* box = inlineBoxWrapper(); RootInlineBox* rootBox = box ? &box->root() : 0; LayoutUnit top = rootBox ? rootBox->selectionTop() : logicalTop(); LayoutUnit bottom = rootBox ? rootBox->selectionBottom() : logicalBottom(); LayoutUnit blockDirectionPosition = isHorizontalWritingMode() ? point.y() + y() : point.x() + x(); LayoutUnit lineDirectionPosition = isHorizontalWritingMode() ? point.x() + x() : point.y() + y(); if (blockDirectionPosition < top) return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); // coordinates are above if (blockDirectionPosition >= bottom) return createPositionWithAffinity(caretMaxOffset(), DOWNSTREAM); // coordinates are below if (node()) { if (lineDirectionPosition <= logicalLeft() + (logicalWidth() / 2)) return createPositionWithAffinity(0, DOWNSTREAM); return createPositionWithAffinity(1, DOWNSTREAM); } return RenderBox::positionForPoint(point); }
IntRect RenderReplaced::selectionRect(bool clipToVisibleContent) { ASSERT(!needsLayout()); if (!isSelected()) return IntRect(); if (!m_inlineBoxWrapper) // We're a block-level replaced element. Just return our own dimensions. return absoluteBoundingBoxRect(); RenderBlock* cb = containingBlock(); if (!cb) return IntRect(); RootInlineBox* root = m_inlineBoxWrapper->root(); IntRect rect(0, root->selectionTop() - yPos(), width(), root->selectionHeight()); if (clipToVisibleContent) computeAbsoluteRepaintRect(rect); else { int absx, absy; absolutePositionForContent(absx, absy); rect.move(absx, absy); } return rect; }
VisiblePosition RenderReplaced::positionForPoint(const IntPoint& point) { InlineBox* box = inlineBoxWrapper(); if (!box) return createVisiblePosition(0, DOWNSTREAM); // FIXME: This code is buggy if the replaced element is relative positioned. RootInlineBox* root = box->root(); int top = root->selectionTop(); int bottom = root->selectionBottom(); int blockDirectionPosition = box->isHorizontal() ? point.y() + y() : point.x() + x(); int lineDirectionPosition = box->isHorizontal() ? point.x() + x() : point.y() + y(); if (blockDirectionPosition < top) return createVisiblePosition(caretMinOffset(), DOWNSTREAM); // coordinates are above if (blockDirectionPosition >= bottom) return createVisiblePosition(caretMaxOffset(), DOWNSTREAM); // coordinates are below if (node()) { if (lineDirectionPosition <= box->logicalLeft() + (box->logicalWidth() / 2)) return createVisiblePosition(0, DOWNSTREAM); return createVisiblePosition(1, DOWNSTREAM); } return RenderBox::positionForPoint(point); }
IntRect RenderReplaced::selectionRect() { if (!isSelected()) return IntRect(); if (!m_inlineBoxWrapper) // We're a block-level replaced element. Just return our own dimensions. return absoluteBoundingBoxRect(); RenderBlock* cb = containingBlock(); if (!cb) return IntRect(); RootInlineBox* root = m_inlineBoxWrapper->root(); int selectionTop = root->selectionTop(); int selectionHeight = root->selectionHeight(); int selectionLeft = xPos(); int selectionRight = xPos() + width(); int absx, absy; cb->absolutePosition(absx, absy); if (cb->hasOverflowClip()) cb->layer()->subtractScrollOffset(absx, absy); return IntRect(selectionLeft + absx, selectionTop + absy, selectionRight - selectionLeft, selectionHeight); }
IntRect RenderReplaced::localSelectionRect(bool checkWhetherSelected) const { if (checkWhetherSelected && !isSelected()) return IntRect(); if (!m_inlineBoxWrapper) // We're a block-level replaced element. Just return our own dimensions. return IntRect(0, 0, width(), height()); RenderBlock* cb = containingBlock(); if (!cb) return IntRect(); RootInlineBox* root = m_inlineBoxWrapper->root(); return IntRect(0, root->selectionTop() - y(), width(), root->selectionHeight()); }
IntRect RenderListMarker::selectionRect(bool clipToVisibleContent) { ASSERT(!needsLayout()); if (selectionState() == SelectionNone || !inlineBoxWrapper()) return IntRect(); RootInlineBox* root = inlineBoxWrapper()->root(); IntRect rect(0, root->selectionTop() - yPos(), width(), root->selectionHeight()); if (clipToVisibleContent) computeAbsoluteRepaintRect(rect); else { int absx, absy; absolutePosition(absx, absy); rect.move(absx, absy); } return rect; }
QRect RenderReplaced::selectionRect() { if (selectionState() == SelectionNone) return QRect(); if (!m_inlineBoxWrapper) // We're a block-level replaced element. Just return our own dimensions. return absoluteBoundingBoxRect(); RenderBlock* cb = containingBlock(); if (!cb) return QRect(); RootInlineBox* root = m_inlineBoxWrapper->root(); int selectionTop = root->selectionTop(); int selectionHeight = root->selectionHeight(); int selectionLeft = xPos(); int selectionRight = xPos() + width(); int absx, absy; cb->absolutePosition(absx, absy); return QRect(selectionLeft + absx, selectionTop + absy, selectionRight - selectionLeft, selectionHeight); }
IntRect RenderReplaced::localSelectionRect(bool checkWhetherSelected) const { if (checkWhetherSelected && !isSelected()) return IntRect(); if (!m_inlineBoxWrapper) // We're a block-level replaced element. Just return our own dimensions. return IntRect(0, 0, width(), height()); RootInlineBox* root = m_inlineBoxWrapper->root(); int newLogicalTop = root->block()->style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop(); if (root->block()->style()->isHorizontalWritingMode()) return IntRect(0, newLogicalTop, width(), root->selectionHeight()); return IntRect(newLogicalTop, 0, root->selectionHeight(), height()); }
bool RenderLineBoxList::lineIntersectsDirtyRect(RenderBoxModelObject* renderer, InlineFlowBox* box, const PaintInfo& paintInfo, const LayoutPoint& offset) const { RootInlineBox* root = box->root(); LayoutUnit logicalTop = min<LayoutUnit>(box->logicalTopVisualOverflow(root->lineTop()), root->selectionTop()) - renderer->maximalOutlineSize(paintInfo.phase); LayoutUnit logicalBottom = box->logicalBottomVisualOverflow(root->lineBottom()) + renderer->maximalOutlineSize(paintInfo.phase); return rangeIntersectsRect(renderer, logicalTop, logicalBottom, paintInfo.rect, offset); }