LayoutRect LayoutListMarker::selectionRectForPaintInvalidation(const LayoutBoxModelObject* paintInvalidationContainer) const
{
    ASSERT(!needsLayout());

    if (getSelectionState() == SelectionNone || !inlineBoxWrapper())
        return LayoutRect();

    RootInlineBox& root = inlineBoxWrapper()->root();
    LayoutRect rect(LayoutUnit(), root.selectionTop() - location().y(), size().width(), root.selectionHeight());
    mapToVisibleRectInAncestorSpace(paintInvalidationContainer, rect, nullptr);
    // FIXME: groupedMapping() leaks the squashing abstraction.
    if (paintInvalidationContainer->layer()->groupedMapping())
        PaintLayer::mapRectToPaintBackingCoordinates(paintInvalidationContainer, rect);
    return rect;
}
예제 #2
0
bool InlineTextBox::hasWrappedSelectionNewline() const {
  // TODO(wkorman): We shouldn't need layout at this point and it should be
  // enforced by DocumentLifecycle. http://crbug.com/537821
  // Bail out as currently looking up selection state can cause the editing code
  // can force a re-layout while scrutinizing the editing position, and
  // InlineTextBox instances are not guaranteed to survive a re-layout.
  if (getLineLayoutItem().needsLayout())
    return false;

  SelectionState state = getSelectionState();
  return (state == SelectionStart || state == SelectionInside)
         // Checking last leaf child can be slow, so we make sure to do this
         // only after the other simple conditionals.
         && (root().lastLeafChild() == this)
         // It's possible to have mixed LTR/RTL on a single line, and we only
         // want to paint a newline when we're the last leaf child and we make
         // sure there isn't a differently-directioned box following us.
         && ((!isLeftToRightDirection() && root().firstSelectedBox() == this) ||
             (isLeftToRightDirection() && root().lastSelectedBox() == this));
}
예제 #3
0
LayoutRect LayoutReplaced::localSelectionRect() const {
    if (getSelectionState() == SelectionNone)
        return LayoutRect();

    if (!inlineBoxWrapper()) {
        // We're a block-level replaced element.  Just return our own dimensions.
        return LayoutRect(LayoutPoint(), size());
    }

    RootInlineBox& root = inlineBoxWrapper()->root();
    LayoutUnit newLogicalTop =
        root.block().style()->isFlippedBlocksWritingMode()
        ? inlineBoxWrapper()->logicalBottom() - root.selectionBottom()
        : root.selectionTop() - inlineBoxWrapper()->logicalTop();
    if (root.block().style()->isHorizontalWritingMode())
        return LayoutRect(LayoutUnit(), newLogicalTop, size().width(),
                          root.selectionHeight());
    return LayoutRect(newLogicalTop, LayoutUnit(), root.selectionHeight(),
                      size().height());
}