void CaretBase::invalidateCaretRect(Node* node, bool caretRectChanged)
{
    if (caretRectChanged)
        return;

    if (LayoutView* view = node->document().layoutView()) {
        if (node->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable) || shouldRepaintCaret(view))
            invalidateLocalCaretRect(node, localCaretRectWithoutUpdate());
    }
}
Example #2
0
void CaretBase::paintCaret(Node* node,
                           GraphicsContext& context,
                           const LayoutPoint& paintOffset,
                           DisplayItem::Type displayItemType) const {
    if (DrawingRecorder::useCachedDrawingIfPossible(context, *this,
            displayItemType))
        return;

    LayoutRect drawingRect = localCaretRectWithoutUpdate();
    if (LayoutBlock* layoutObject = caretLayoutObject(node))
        layoutObject->flipForWritingMode(drawingRect);
    drawingRect.moveBy(paintOffset);

    const Color caretColor = node->layoutObject()->resolveColor(CSSPropertyColor);
    IntRect paintRect = pixelSnappedIntRect(drawingRect);
    DrawingRecorder drawingRecorder(context, *this, DisplayItem::kCaret,
                                    paintRect);
    context.fillRect(paintRect, caretColor);
}
Example #3
0
IntRect FrameCaret::absoluteCaretBounds() {
  DCHECK_NE(m_frame->document()->lifecycle().state(),
            DocumentLifecycle::InPaintInvalidation);
  DCHECK(!m_frame->document()->needsLayoutTreeUpdate());
  DocumentLifecycle::DisallowTransitionScope disallowTransition(
      m_frame->document()->lifecycle());

  if (!isActive()) {
    clearCaretRect();
  } else {
    if (enclosingTextFormControl(caretPosition().position())) {
      if (isVisuallyEquivalentCandidate(caretPosition().position()))
        updateCaretRect(caretPosition());
      else
        updateCaretRect(createVisiblePosition(caretPosition()));
    } else {
      updateCaretRect(createVisiblePosition(caretPosition()));
    }
  }
  return absoluteBoundsForLocalRect(caretPosition().anchorNode(),
                                    localCaretRectWithoutUpdate());
}
void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoint& paintOffset) const
{
    if (m_caretVisibility == Hidden)
        return;

    LayoutRect drawingRect = localCaretRectWithoutUpdate();
    if (LayoutBlock* layoutObject = caretLayoutObject(node))
        layoutObject->flipForWritingMode(drawingRect);
    drawingRect.moveBy(roundedIntPoint(paintOffset));

    Color caretColor = Color::black;

    Element* element;
    if (node->isElementNode())
        element = toElement(node);
    else
        element = node->parentElement();

    if (element && element->layoutObject())
        caretColor = element->layoutObject()->resolveColor(CSSPropertyColor);

    context->fillRect(FloatRect(drawingRect), caretColor);
}
Example #5
0
void CaretBase::paintCaret(Node* node, GraphicsContext* context, const LayoutPoint& paintOffset, const LayoutRect& clipRect) const
{
    if (m_caretVisibility == Hidden)
        return;

    LayoutRect drawingRect = localCaretRectWithoutUpdate();
    drawingRect.moveBy(roundedIntPoint(paintOffset));
    LayoutRect caret = intersection(drawingRect, clipRect);
    if (caret.isEmpty())
        return;

    Color caretColor = Color::black;

    Element* element;
    if (node->isElementNode())
        element = toElement(node);
    else
        element = node->parentElement();

    if (element && element->renderer())
        caretColor = element->renderer()->resolveColor(CSSPropertyColor);

    context->fillRect(caret, caretColor);
}
Example #6
0
void CaretBase::invalidateCaretRect(Node* node) {
    node->document().updateStyleAndLayoutTree();
    if (hasEditableStyle(*node))
        invalidateLocalCaretRect(node, localCaretRectWithoutUpdate());
}