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

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

Issue 2292353003: Cherry-pick r415013 to M53. (Closed)
Patch Set: 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 8cbc6be27bc5cf73e5e2888f1d3f59ca49c1635f..ce41efa74b02480e48a3e83ac35ad2a363469b70 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())
+ 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
DisablePaintInvalidationStateAsserts disabler;
- caretPainter.invalidatePaintRectangle(inflatedRect);
+
+ node->layoutObject()->invalidatePaintRectangle(inflatedRect, displayItemClientForCaret(node));
}
bool CaretBase::shouldRepaintCaret(Node& node) const
@@ -190,11 +199,14 @@ void CaretBase::invalidateCaretRect(Node* node, bool caretRectChanged)
}
}
-void CaretBase::paintCaret(Node* node, GraphicsContext& context, const LayoutPoint& paintOffset) const
+void CaretBase::paintCaret(Node* node, GraphicsContext& context, const LayoutPoint& paintOffset, DisplayItem::Type displayItemType) const
{
if (m_caretVisibility == CaretVisibility::Hidden)
return;
+ if (DrawingRecorder::useCachedDrawingIfPossible(context, *displayItemClientForCaret(node), displayItemType))
+ return;
+
LayoutRect drawingRect = localCaretRectWithoutUpdate();
if (LayoutBlock* layoutObject = caretLayoutObject(node))
layoutObject->flipForWritingMode(drawingRect);
@@ -211,6 +223,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);
}
« no previous file with comments | « third_party/WebKit/Source/core/editing/CaretBase.h ('k') | third_party/WebKit/Source/core/editing/DragCaretController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698