OLD | NEW |
(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 |
OLD | NEW |