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

Side by Side 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, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef PaintDataCache_h
6 #define PaintDataCache_h
7
8 #include "core/layout/LayoutBlock.h"
9
10 namespace blink {
11
12 class LocalFrame;
13
14 // Caches information computed during paint which is likely to be reused again.
15 // Purely an optimization, and not expected to outlive a high-level paint.
16 class PaintDataCache {
17 public:
18 bool layoutBlockHasCaret(const LayoutBlock& layoutBlock)
19 {
20 LocalFrame* frame = layoutBlock.frame();
21 if (m_caretFrame != frame)
22 updateCaretCacheForFrame(frame);
23 return &layoutBlock == m_cursorCaretLayoutObject || &layoutBlock == m_dr agCaretLayoutObject;
24 }
25
26 void getLayoutBlockCarets(const LayoutBlock& layoutBlock, bool* hasCursorCar et, bool* hasDragCaret)
27 {
28 LocalFrame* frame = layoutBlock.frame();
29 if (m_caretFrame != frame)
30 updateCaretCacheForFrame(frame);
31 *hasCursorCaret = &layoutBlock == m_cursorCaretLayoutObject;
32 *hasDragCaret = &layoutBlock == m_dragCaretLayoutObject;
33 }
34
35 private:
36 void updateCaretCacheForFrame(const LocalFrame*);
37
38 // Used to quickly check which layout objects paint carets.
39 const LocalFrame* m_caretFrame = nullptr;
40 const LayoutBlock* m_cursorCaretLayoutObject = nullptr;
41 const LayoutBlock* m_dragCaretLayoutObject = nullptr;
42 };
43
44 } // namespace blink
45
46 #endif // PaintDataCache_h
OLDNEW
« 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