Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Unified Diff: third_party/WebKit/Source/core/editing/CaretBase.cpp

Issue 2271883002: Fix paint invalidation and painting for composited-scrolling input elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: none Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/CaretBase.cpp
diff --git a/third_party/WebKit/Source/core/editing/CaretBase.cpp b/third_party/WebKit/Source/core/editing/CaretBase.cpp
index 9781217137343403d52c8a7a8792b44c9c4e04f2..c464127f8984c808251c992f0e0944ab876e67a0 100644
--- a/third_party/WebKit/Source/core/editing/CaretBase.cpp
+++ b/third_party/WebKit/Source/core/editing/CaretBase.cpp
@@ -34,7 +34,10 @@
#include "core/layout/api/LayoutBlockItem.h"
#include "core/layout/api/LayoutItem.h"
#include "core/paint/PaintInfo.h"
+#include "core/paint/PaintLayer.h"
#include "platform/graphics/GraphicsContext.h"
+#include "platform/graphics/GraphicsLayer.h"
+#include "platform/graphics/paint/DrawingRecorder.h"
namespace blink {
@@ -139,13 +142,21 @@ IntRect CaretBase::absoluteBoundsForLocalRect(Node* node, const LayoutRect& rect
return caretPainter->localToAbsoluteQuad(FloatRect(localRect)).enclosingBoundingBox();
}
+DisplayItemClient* CaretBase::displayItemClientForCaret(Node* node)
+{
+ LayoutBlock* caretLayoutBlock = caretLayoutObject(node);
+ if (caretLayoutBlock->usesCompositedScrolling())
pdr. 2016/08/25 22:07:11 usesCompositedScrolling() can change dynamically.
+ return static_cast<DisplayItemClient*>(caretLayoutBlock->layer()->graphicsLayerBackingForScrolling());
+ return caretLayoutBlock;
+}
+
// TODO(yoichio): |node| is FrameSelection::m_previousCaretNode and this is bad
// design. We should use only previous layoutObject or Rectangle to invalidate
// old caret.
void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect)
{
- LayoutBlockItem caretPainter = LayoutBlockItem(caretLayoutObject(node));
- if (!caretPainter)
+ LayoutBlock* caretLayoutBlock = caretLayoutObject(node);
+ if (!caretLayoutBlock)
return;
// FIXME: Need to over-paint 1 pixel to workaround some rounding problems.
@@ -153,12 +164,10 @@ void CaretBase::invalidateLocalCaretRect(Node* node, const LayoutRect& rect)
LayoutRect inflatedRect = rect;
inflatedRect.inflate(LayoutUnit(1));
- // FIXME: We should use mapLocalToAncestor() since we know we're not un-rooted.
- mapCaretRectToCaretPainter(LayoutItem(node->layoutObject()), caretPainter, inflatedRect);
-
- // FIXME: We should not allow paint invalidation out of paint invalidation state. crbug.com/457415
+ // // FIXME: We should not allow paint invalidation out of paint invalidation state. crbug.com/457415
pdr. 2016/08/25 22:07:11 Nit: Your comment has a comment
chrishtr 2016/08/26 16:02:25 Done.
DisablePaintInvalidationStateAsserts disabler;
- caretPainter.invalidatePaintRectangle(inflatedRect);
+
+ node->layoutObject()->invalidatePaintRectangle(inflatedRect, displayItemClientForCaret(node));
}
bool CaretBase::shouldRepaintCaret(Node& node) const
@@ -197,6 +206,9 @@ void CaretBase::paintCaret(Node* node, GraphicsContext& context, const LayoutPoi
if (m_caretVisibility == CaretVisibility::Hidden)
return;
+ if (DrawingRecorder::useCachedDrawingIfPossible(context, *displayItemClientForCaret(node), DisplayItem::Caret))
+ return;
+
LayoutRect drawingRect = localCaretRectWithoutUpdate();
if (LayoutBlock* layoutObject = caretLayoutObject(node))
layoutObject->flipForWritingMode(drawingRect);
@@ -213,6 +225,8 @@ void CaretBase::paintCaret(Node* node, GraphicsContext& context, const LayoutPoi
if (element && element->layoutObject())
caretColor = element->layoutObject()->resolveColor(CSSPropertyColor);
+ DrawingRecorder drawingRecorder(context, *displayItemClientForCaret(node), DisplayItem::Caret, FloatRect(drawingRect));
+
context.fillRect(FloatRect(drawingRect), caretColor);
}

Powered by Google App Engine
This is Rietveld 408576698