| 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
|
|
|