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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBlock.h

Issue 2665823002: Invalidate caret during paint invalidation (Closed)
Patch Set: Rebaseline Created 3 years, 11 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/layout/LayoutBlock.h
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.h b/third_party/WebKit/Source/core/layout/LayoutBlock.h
index d2014ceca0ec4cc5096d16ab95235954deaecd7b..12154475ec18c10caf224b424869c15ac2513a42 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.h
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.h
@@ -490,12 +490,60 @@ class CORE_EXPORT LayoutBlock : public LayoutBox {
bool hasDragCaret() const;
bool hasCaret() const { return hasCursorCaret() || hasDragCaret(); }
+ class MutableForPainting : public LayoutBox::MutableForPainting {
+ public:
+ void setHasPreviousCaretVisualRects(bool b) {
+ static_cast<LayoutBlock&>(m_layoutObject).m_hasPreviousCaretVisualRects =
+ b;
+ }
+
+ protected:
+ friend class LayoutBlock;
+ MutableForPainting(const LayoutBlock& layoutBlock)
+ : LayoutBox::MutableForPainting(layoutBlock) {}
+ };
+
+ MutableForPainting getMutableForPainting() const {
+ return MutableForPainting(*this);
+ }
+
+ // Called when a cursor caret or drag caret in this LayoutBlock need paint
chrishtr 2017/01/31 22:51:04 Nit: "needs"
+ // invalidation, e.g. when its color or visibility changes. When a caret
+ // just changes location, use setMayNeedPaintInvalidation() instead.
+ void setCaretsNeedPaintInvalidation() {
+ if (m_caretsNeedPaintInvalidation)
+ return;
+ m_caretsNeedPaintInvalidation = true;
+ setMayNeedPaintInvalidation();
+ }
+ bool caretsNeedPaintInvalidation() const {
+ return m_caretsNeedPaintInvalidation;
+ }
+
+ bool hasPreviousCaretVisualRects() const {
+ return m_hasPreviousCaretVisualRects;
+ }
+
protected:
PaintInvalidationReason invalidatePaintIfNeeded(
const PaintInvalidationState&) override;
PaintInvalidationReason invalidatePaintIfNeeded(
const PaintInvalidatorContext&) const override;
+ void clearPaintInvalidationFlags() override {
+ LayoutBox::clearPaintInvalidationFlags();
+ m_caretsNeedPaintInvalidation = false;
+ }
+
+ void clearPreviousVisualRects() override;
+
+#if DCHECK_IS_ON()
+ bool paintInvalidationStateIsDirty() const override {
+ return LayoutBox::paintInvalidationStateIsDirty() ||
+ m_caretsNeedPaintInvalidation;
+ }
+#endif
+
private:
LayoutRect localCaretRect(InlineBox*,
int caretOffset,
@@ -552,6 +600,12 @@ class CORE_EXPORT LayoutBlock : public LayoutBox {
// to, for all we know.
unsigned m_paginationStateChanged : 1;
+ // Indicates if we have saved previous cursor and/or drag caret visual rects
+ // for the LayoutBlock in BlockPaintInvalidator.
+ unsigned m_hasPreviousCaretVisualRects : 1;
+
+ unsigned m_caretsNeedPaintInvalidation : 1;
+
// FIXME: This is temporary as we move code that accesses block flow
// member variables out of LayoutBlock and into LayoutBlockFlow.
friend class LayoutBlockFlow;

Powered by Google App Engine
This is Rietveld 408576698