| 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 |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 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 CaretBase_h | 27 #ifndef CaretBase_h |
| 28 #define CaretBase_h | 28 #define CaretBase_h |
| 29 | 29 |
| 30 #include "core/CoreExport.h" | |
| 31 #include "core/editing/VisiblePosition.h" | 30 #include "core/editing/VisiblePosition.h" |
| 32 #include "platform/geometry/IntRect.h" | 31 #include "platform/geometry/IntRect.h" |
| 33 #include "platform/geometry/LayoutRect.h" | 32 #include "platform/geometry/LayoutRect.h" |
| 34 #include "platform/graphics/paint/DisplayItem.h" | 33 #include "platform/graphics/paint/DisplayItem.h" |
| 35 #include "wtf/Noncopyable.h" | 34 #include "wtf/Noncopyable.h" |
| 36 | 35 |
| 37 namespace blink { | 36 namespace blink { |
| 38 | 37 |
| 39 class DisplayItemClient; | |
| 40 class GraphicsContext; | 38 class GraphicsContext; |
| 41 class LayoutBlock; | 39 class LayoutBlock; |
| 42 | 40 |
| 43 class CORE_EXPORT CaretBase : public GarbageCollectedFinalized<CaretBase>, | 41 class CaretBase final : public DisplayItemClient { |
| 44 public DisplayItemClient { | |
| 45 WTF_MAKE_NONCOPYABLE(CaretBase); | 42 WTF_MAKE_NONCOPYABLE(CaretBase); |
| 46 | 43 |
| 47 public: | 44 public: |
| 48 CaretBase(); | 45 CaretBase(); |
| 49 virtual ~CaretBase(); | 46 virtual ~CaretBase(); |
| 50 | 47 |
| 51 void invalidateCaretRect(Node*, const LayoutRect&); | 48 void invalidateCaretRect(Node*, const LayoutRect&); |
| 52 // Creating VisiblePosition causes synchronous layout so we should use the | 49 // Creating VisiblePosition causes synchronous layout so we should use the |
| 53 // PositionWithAffinity version if possible. | 50 // PositionWithAffinity version if possible. |
| 54 // A position in HTMLTextFromControlElement is a typical example. | 51 // A position in HTMLTextFromControlElement is a typical example. |
| 55 static LayoutRect computeCaretRect(const PositionWithAffinity& caretPosition); | 52 static LayoutRect computeCaretRect(const PositionWithAffinity& caretPosition); |
| 56 | 53 |
| 57 // TODO(yosin): We should move |computeCaretRect()| with |VisiblePosition| to | 54 // TODO(yosin): We should move |computeCaretRect()| with |VisiblePosition| to |
| 58 // "FrameCaret.cpp" as static file local function. | 55 // "FrameCaret.cpp" as static file local function. |
| 59 static LayoutRect computeCaretRect(const VisiblePosition& caretPosition); | 56 static LayoutRect computeCaretRect(const VisiblePosition& caretPosition); |
| 60 | 57 |
| 61 // TODO(yosin): We should move |absoluteBoundsForLocalRect()| with | 58 // TODO(yosin): We should move |absoluteBoundsForLocalRect()| with |
| 62 // |VisiblePosition| to "FrameCaret.cpp" as static file local function. | 59 // |VisiblePosition| to "FrameCaret.cpp" as static file local function. |
| 63 IntRect absoluteBoundsForLocalRect(Node*, const LayoutRect&) const; | 60 static IntRect absoluteBoundsForLocalRect(Node*, const LayoutRect&); |
| 64 | 61 |
| 65 // TODO(yosin): We should move |shouldRepaintCaret()| to "FrameCaret.cpp" as | 62 // TODO(yosin): We should move |shouldRepaintCaret()| to "FrameCaret.cpp" as |
| 66 // static file local function. | 63 // static file local function. |
| 67 bool shouldRepaintCaret(Node&) const; | 64 static bool shouldRepaintCaret(Node&); |
| 65 // TODO(yosin): We should make |paintCaret()| to non-static member and get rid |
| 66 // |DisplayItemClient| parameter. |
| 68 static void paintCaret(Node*, | 67 static void paintCaret(Node*, |
| 69 GraphicsContext&, | 68 GraphicsContext&, |
| 70 const DisplayItemClient&, | 69 const DisplayItemClient&, |
| 71 const LayoutRect& caretLocalRect, | 70 const LayoutRect& caretLocalRect, |
| 72 const LayoutPoint&, | 71 const LayoutPoint&, |
| 73 DisplayItem::Type); | 72 DisplayItem::Type); |
| 74 | 73 |
| 75 static LayoutBlock* caretLayoutObject(Node*); | 74 static LayoutBlock* caretLayoutObject(Node*); |
| 76 void invalidateLocalCaretRect(Node*, const LayoutRect&); | 75 void invalidateLocalCaretRect(Node*, const LayoutRect&); |
| 77 | 76 |
| 78 // DisplayItemClient methods. | 77 // DisplayItemClient methods. |
| 79 LayoutRect visualRect() const override; | 78 LayoutRect visualRect() const final; |
| 80 String debugName() const final; | 79 String debugName() const final; |
| 81 | 80 |
| 82 DECLARE_VIRTUAL_TRACE(); | |
| 83 | |
| 84 private: | 81 private: |
| 85 LayoutRect m_visualRect; | 82 LayoutRect m_visualRect; |
| 86 }; | 83 }; |
| 87 | 84 |
| 88 } // namespace blink | 85 } // namespace blink |
| 89 | 86 |
| 90 #endif // CaretBase_h | 87 #endif // CaretBase_h |
| OLD | NEW |