| Index: Source/WebCore/editing/FrameSelection.cpp
|
| ===================================================================
|
| --- Source/WebCore/editing/FrameSelection.cpp (revision 139576)
|
| +++ Source/WebCore/editing/FrameSelection.cpp (working copy)
|
| @@ -1219,6 +1219,25 @@
|
| m_caretLocalRect = LayoutRect();
|
| }
|
|
|
| +static inline bool caretRendersInsideNode(Node* node)
|
| +{
|
| + return node && !isTableElement(node) && !editingIgnoresContent(node);
|
| +}
|
| +
|
| +static RenderObject* caretRenderer(Node* node)
|
| +{
|
| + if (!node)
|
| + return 0;
|
| +
|
| + RenderObject* renderer = node->renderer();
|
| + if (!renderer)
|
| + return 0;
|
| +
|
| + // if caretNode is a block and caret is inside it then caret should be painted by that block
|
| + bool paintedByBlock = renderer->isBlockFlow() && caretRendersInsideNode(node);
|
| + return paintedByBlock ? renderer : renderer->containingBlock();
|
| +}
|
| +
|
| bool CaretBase::updateCaretRect(Document* document, const VisiblePosition& caretPosition)
|
| {
|
| document->updateStyleIfNeeded();
|
| @@ -1257,33 +1276,14 @@
|
| return true;
|
| }
|
|
|
| -static inline bool caretRendersInsideNode(Node* node)
|
| -{
|
| - return node && !isTableElement(node) && !editingIgnoresContent(node);
|
| -}
|
| -
|
| -RenderObject* CaretBase::caretRenderer(Node* node) const
|
| -{
|
| - if (!node)
|
| - return 0;
|
| -
|
| - RenderObject* renderer = node->renderer();
|
| - if (!renderer)
|
| - return 0;
|
| -
|
| - // if caretNode is a block and caret is inside it then caret should be painted by that block
|
| - bool paintedByBlock = renderer->isBlockFlow() && caretRendersInsideNode(node);
|
| - return paintedByBlock ? renderer : renderer->containingBlock();
|
| -}
|
| -
|
| RenderObject* FrameSelection::caretRenderer() const
|
| {
|
| - return CaretBase::caretRenderer(m_selection.start().deprecatedNode());
|
| + return WebCore::caretRenderer(m_selection.start().deprecatedNode());
|
| }
|
|
|
| RenderObject* DragCaretController::caretRenderer() const
|
| {
|
| - return CaretBase::caretRenderer(m_position.deepEquivalent().deprecatedNode());
|
| + return WebCore::caretRenderer(m_position.deepEquivalent().deprecatedNode());
|
| }
|
|
|
| static bool isNonOrphanedCaret(const VisibleSelection& selection)
|
| @@ -1321,20 +1321,13 @@
|
| return m_absCaretBounds;
|
| }
|
|
|
| -static LayoutRect repaintRectForCaret(LayoutRect caret)
|
| +static void repaintCaretForLocalRect(Node* node, const LayoutRect& rect)
|
| {
|
| - if (caret.isEmpty())
|
| - return LayoutRect();
|
| - // Ensure that the dirty rect intersects the block that paints the caret even in the case where
|
| - // the caret itself is just outside the block. See <https://bugs.webkit.org/show_bug.cgi?id=19086>.
|
| - caret.inflateX(1);
|
| - caret.inflateY(1);
|
| - return caret;
|
| -}
|
| + RenderObject* caretPainter = caretRenderer(node);
|
| + if (!caretPainter)
|
| + return;
|
|
|
| -IntRect CaretBase::caretRepaintRect(Node* node) const
|
| -{
|
| - return absoluteBoundsForLocalRect(node, repaintRectForCaret(localCaretRectWithoutUpdate()));
|
| + caretPainter->repaintRectangle(rect);
|
| }
|
|
|
| bool FrameSelection::recomputeCaretRect()
|
| @@ -1355,7 +1348,6 @@
|
| return false;
|
|
|
| IntRect oldAbsCaretBounds = m_absCaretBounds;
|
| - // FIXME: Rename m_caretRect to m_localCaretRect.
|
| m_absCaretBounds = absoluteBoundsForLocalRect(m_selection.start().deprecatedNode(), localCaretRectWithoutUpdate());
|
| m_absCaretBoundsDirty = false;
|
|
|
| @@ -1363,18 +1355,13 @@
|
| return false;
|
|
|
| #if ENABLE(TEXT_CARET)
|
| - IntRect oldAbsoluteCaretRepaintBounds = m_absoluteCaretRepaintBounds;
|
| -#endif
|
| -
|
| - // We believe that we need to inflate the local rect before transforming it to obtain the repaint bounds.
|
| - m_absoluteCaretRepaintBounds = caretRepaintRect(m_selection.start().deprecatedNode());
|
| -
|
| -#if ENABLE(TEXT_CARET)
|
| if (RenderView* view = m_frame->document()->renderView()) {
|
| - // FIXME: make caret repainting container-aware.
|
| - view->repaintRectangleInViewAndCompositedLayers(oldAbsoluteCaretRepaintBounds, false);
|
| + Node* node = m_selection.start().deprecatedNode();
|
| + if (m_previousCaretNode)
|
| + repaintCaretForLocalRect(m_previousCaretNode.get(), oldRect);
|
| + m_previousCaretNode = node;
|
| if (shouldRepaintCaret(view, isContentEditable()))
|
| - view->repaintRectangleInViewAndCompositedLayers(m_absoluteCaretRepaintBounds, false);
|
| + repaintCaretForLocalRect(node, newRect);
|
| }
|
| #endif
|
| return true;
|
| @@ -1416,7 +1403,7 @@
|
|
|
| if (RenderView* view = node->document()->renderView()) {
|
| if (shouldRepaintCaret(view, node->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable)))
|
| - view->repaintRectangleInViewAndCompositedLayers(caretRepaintRect(node), false);
|
| + repaintCaretForLocalRect(node, localCaretRectWithoutUpdate());
|
| }
|
| }
|
|
|
| @@ -1683,7 +1670,7 @@
|
| // RenderObject::selectionForegroundColor() check if the frame is active,
|
| // we have to update places those colors were painted.
|
| if (RenderView* view = m_frame->document()->renderView())
|
| - view->repaintRectangleInViewAndCompositedLayers(enclosingIntRect(bounds()));
|
| + view->repaintSelection();
|
|
|
| // Caret appears in the active frame.
|
| if (activeAndFocused)
|
|
|