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

Unified Diff: Source/core/paint/PaintDataCache.h

Issue 1218013003: Keep a cache of caret painters to avoid recomputing all the time. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: a shade of deduplication blue Created 5 years, 6 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
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayerPaintingInfo.h ('k') | Source/core/paint/PaintDataCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/PaintDataCache.h
diff --git a/Source/core/paint/PaintDataCache.h b/Source/core/paint/PaintDataCache.h
new file mode 100644
index 0000000000000000000000000000000000000000..e7a0c54b7a275d062755cc7c5d84a9ce9ef091c7
--- /dev/null
+++ b/Source/core/paint/PaintDataCache.h
@@ -0,0 +1,46 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PaintDataCache_h
+#define PaintDataCache_h
+
+#include "core/layout/LayoutBlock.h"
+
+namespace blink {
+
+class LocalFrame;
+
+// Caches information computed during paint which is likely to be reused again.
+// Purely an optimization, and not expected to outlive a high-level paint.
+class PaintDataCache {
+public:
+ bool layoutBlockHasCaret(const LayoutBlock& layoutBlock)
+ {
+ LocalFrame* frame = layoutBlock.frame();
+ if (m_caretFrame != frame)
+ updateCaretCacheForFrame(frame);
+ return &layoutBlock == m_cursorCaretLayoutObject || &layoutBlock == m_dragCaretLayoutObject;
+ }
+
+ void getLayoutBlockCarets(const LayoutBlock& layoutBlock, bool* hasCursorCaret, bool* hasDragCaret)
+ {
+ LocalFrame* frame = layoutBlock.frame();
+ if (m_caretFrame != frame)
+ updateCaretCacheForFrame(frame);
+ *hasCursorCaret = &layoutBlock == m_cursorCaretLayoutObject;
+ *hasDragCaret = &layoutBlock == m_dragCaretLayoutObject;
+ }
+
+private:
+ void updateCaretCacheForFrame(const LocalFrame*);
+
+ // Used to quickly check which layout objects paint carets.
+ const LocalFrame* m_caretFrame = nullptr;
+ const LayoutBlock* m_cursorCaretLayoutObject = nullptr;
+ const LayoutBlock* m_dragCaretLayoutObject = nullptr;
+};
+
+} // namespace blink
+
+#endif // PaintDataCache_h
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayerPaintingInfo.h ('k') | Source/core/paint/PaintDataCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698