| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef FrameCaret_h | 26 #ifndef FrameCaret_h |
| 27 #define FrameCaret_h | 27 #define FrameCaret_h |
| 28 | 28 |
| 29 #include "core/CoreExport.h" |
| 29 #include "core/editing/CaretBase.h" | 30 #include "core/editing/CaretBase.h" |
| 30 #include "platform/geometry/IntRect.h" | 31 #include "platform/geometry/IntRect.h" |
| 31 | 32 |
| 32 namespace blink { | 33 namespace blink { |
| 33 | 34 |
| 34 class FrameCaret final : public CaretBase { | 35 class SelectionEditor; |
| 36 |
| 37 class CORE_EXPORT FrameCaret final : public CaretBase { |
| 35 public: | 38 public: |
| 36 FrameCaret(LocalFrame*); | 39 FrameCaret(LocalFrame*, const SelectionEditor&); |
| 37 ~FrameCaret() override; | 40 ~FrameCaret() override; |
| 38 | 41 |
| 39 void setCaretPosition(const PositionWithAffinity&); | 42 bool isActive() const { return caretPosition().isNotNull(); } |
| 40 void clear(); | |
| 41 bool isActive() const { return m_caretPosition.isNotNull(); } | |
| 42 | 43 |
| 43 void updateAppearance(); | 44 void updateAppearance(); |
| 44 | 45 |
| 45 // Used to suspend caret blinking while the mouse is down. | 46 // Used to suspend caret blinking while the mouse is down. |
| 46 void setCaretBlinkingSuspended(bool suspended) { m_isCaretBlinkingSuspended
= suspended; } | 47 void setCaretBlinkingSuspended(bool suspended) { m_isCaretBlinkingSuspended
= suspended; } |
| 47 bool isCaretBlinkingSuspended() const { return m_isCaretBlinkingSuspended; } | 48 bool isCaretBlinkingSuspended() const { return m_isCaretBlinkingSuspended; } |
| 48 void stopCaretBlinkTimer(); | 49 void stopCaretBlinkTimer(); |
| 49 void startBlinkCaret(); | 50 void startBlinkCaret(); |
| 50 | 51 |
| 51 void setCaretVisibility(CaretVisibility) override; | 52 void setCaretVisibility(CaretVisibility) override; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 64 | 65 |
| 65 void documentDetached(); | 66 void documentDetached(); |
| 66 | 67 |
| 67 // For unittests | 68 // For unittests |
| 68 bool shouldPaintCaretForTesting() const { return m_shouldPaintCaret; } | 69 bool shouldPaintCaretForTesting() const { return m_shouldPaintCaret; } |
| 69 bool isPreviousCaretDirtyForTesting() const { return m_previousCaretNode; } | 70 bool isPreviousCaretDirtyForTesting() const { return m_previousCaretNode; } |
| 70 | 71 |
| 71 DECLARE_VIRTUAL_TRACE(); | 72 DECLARE_VIRTUAL_TRACE(); |
| 72 | 73 |
| 73 private: | 74 private: |
| 75 friend class FrameSelectionTest; |
| 76 |
| 77 const PositionWithAffinity caretPosition() const; |
| 78 |
| 74 bool shouldBlinkCaret() const; | 79 bool shouldBlinkCaret() const; |
| 75 void caretBlinkTimerFired(Timer<FrameCaret>*); | 80 void caretBlinkTimerFired(Timer<FrameCaret>*); |
| 76 bool caretPositionIsValidForDocument(const Document&) const; | 81 bool caretPositionIsValidForDocument(const Document&) const; |
| 77 | 82 |
| 78 PositionWithAffinity m_caretPosition; | 83 const Member<const SelectionEditor> m_selectionEditor; |
| 79 const Member<LocalFrame> m_frame; | 84 const Member<LocalFrame> m_frame; |
| 80 // The last node which painted the caret. Retained for clearing the old | 85 // The last node which painted the caret. Retained for clearing the old |
| 81 // caret when it moves. | 86 // caret when it moves. |
| 82 Member<Node> m_previousCaretNode; | 87 Member<Node> m_previousCaretNode; |
| 83 LayoutRect m_previousCaretRect; | 88 LayoutRect m_previousCaretRect; |
| 84 CaretVisibility m_previousCaretVisibility; | 89 CaretVisibility m_previousCaretVisibility; |
| 85 Timer<FrameCaret> m_caretBlinkTimer; | 90 Timer<FrameCaret> m_caretBlinkTimer; |
| 86 bool m_caretRectDirty : 1; | 91 bool m_caretRectDirty : 1; |
| 87 bool m_shouldPaintCaret : 1; | 92 bool m_shouldPaintCaret : 1; |
| 88 bool m_isCaretBlinkingSuspended : 1; | 93 bool m_isCaretBlinkingSuspended : 1; |
| 89 bool m_shouldShowBlockCursor : 1; | 94 bool m_shouldShowBlockCursor : 1; |
| 90 }; | 95 }; |
| 91 | 96 |
| 92 } // namespace blink | 97 } // namespace blink |
| 93 | 98 |
| 94 #endif // FrameCaret_h | 99 #endif // FrameCaret_h |
| OLD | NEW |