| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef DragCaret_h | 27 #ifndef DragCaret_h |
| 28 #define DragCaret_h | 28 #define DragCaret_h |
| 29 | 29 |
| 30 #include "core/dom/SynchronousMutationObserver.h" | 30 #include "core/dom/SynchronousMutationObserver.h" |
| 31 #include "core/editing/CaretDisplayItemClient.h" | 31 #include "core/editing/CaretDisplayItemClient.h" |
| 32 #include "platform/graphics/PaintInvalidationReason.h" |
| 32 #include <memory> | 33 #include <memory> |
| 33 | 34 |
| 34 namespace blink { | 35 namespace blink { |
| 35 | 36 |
| 37 class LayoutBlock; |
| 38 struct PaintInvalidatorContext; |
| 39 |
| 36 class DragCaret final : public GarbageCollectedFinalized<DragCaret>, | 40 class DragCaret final : public GarbageCollectedFinalized<DragCaret>, |
| 37 public SynchronousMutationObserver { | 41 public SynchronousMutationObserver { |
| 38 WTF_MAKE_NONCOPYABLE(DragCaret); | 42 WTF_MAKE_NONCOPYABLE(DragCaret); |
| 39 USING_GARBAGE_COLLECTED_MIXIN(DragCaret); | 43 USING_GARBAGE_COLLECTED_MIXIN(DragCaret); |
| 40 | 44 |
| 41 public: | 45 public: |
| 42 static DragCaret* create(); | 46 static DragCaret* create(); |
| 43 | 47 |
| 44 virtual ~DragCaret(); | 48 virtual ~DragCaret(); |
| 45 | 49 |
| 46 void paintDragCaret(LocalFrame*, GraphicsContext&, const LayoutPoint&) const; | 50 // Paint invalidation methods delegating to CaretDisplayItemClient. |
| 51 void clearPreviousVisualRect(const LayoutBlock&); |
| 52 void layoutBlockWillBeDestroyed(const LayoutBlock&); |
| 53 void updateForPaintInvalidation(); |
| 54 void invalidatePaintIfNeeded(const LayoutBlock&, |
| 55 const PaintInvalidatorContext&, |
| 56 PaintInvalidationReason); |
| 47 | 57 |
| 48 bool hasCaretIn(const LayoutBlock&) const; | 58 bool shouldPaintCaret(const LayoutBlock&) const; |
| 59 void paintDragCaret(const LocalFrame*, |
| 60 GraphicsContext&, |
| 61 const LayoutPoint&) const; |
| 62 |
| 49 bool isContentRichlyEditable() const; | 63 bool isContentRichlyEditable() const; |
| 50 | 64 |
| 51 bool hasCaret() const { return m_position.isNotNull(); } | 65 bool hasCaret() const { return m_position.isNotNull(); } |
| 52 const PositionWithAffinity& caretPosition() { return m_position; } | 66 const PositionWithAffinity& caretPosition() { return m_position; } |
| 53 void setCaretPosition(const PositionWithAffinity&); | 67 void setCaretPosition(const PositionWithAffinity&); |
| 54 void clear() { setCaretPosition(PositionWithAffinity()); } | 68 void clear() { setCaretPosition(PositionWithAffinity()); } |
| 55 | 69 |
| 56 DECLARE_TRACE(); | 70 DECLARE_TRACE(); |
| 57 | 71 |
| 58 private: | 72 private: |
| 59 DragCaret(); | 73 DragCaret(); |
| 60 | 74 |
| 61 void invalidateCaretRect(Node*, const LayoutRect&); | |
| 62 | |
| 63 // Implementations of |SynchronousMutationObserver| | 75 // Implementations of |SynchronousMutationObserver| |
| 64 void nodeChildrenWillBeRemoved(ContainerNode&) final; | 76 void nodeChildrenWillBeRemoved(ContainerNode&) final; |
| 65 void nodeWillBeRemoved(Node&) final; | 77 void nodeWillBeRemoved(Node&) final; |
| 66 | 78 |
| 67 PositionWithAffinity m_position; | 79 PositionWithAffinity m_position; |
| 68 // caret rect in coords local to the layoutObject responsible for painting the | |
| 69 // caret | |
| 70 LayoutRect m_caretLocalRect; | |
| 71 const std::unique_ptr<CaretDisplayItemClient> m_caretBase; | 80 const std::unique_ptr<CaretDisplayItemClient> m_caretBase; |
| 72 }; | 81 }; |
| 73 | 82 |
| 74 } // namespace blink | 83 } // namespace blink |
| 75 | 84 |
| 76 #endif // DragCaret_h | 85 #endif // DragCaret_h |
| OLD | NEW |