OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 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 |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 #include "core/editing/VisiblePosition.h" | 29 #include "core/editing/VisiblePosition.h" |
30 #include "platform/geometry/IntRect.h" | 30 #include "platform/geometry/IntRect.h" |
31 #include "platform/geometry/LayoutRect.h" | 31 #include "platform/geometry/LayoutRect.h" |
32 #include "wtf/Noncopyable.h" | 32 #include "wtf/Noncopyable.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 class LocalFrame; | 36 class LocalFrame; |
37 class GraphicsContext; | 37 class GraphicsContext; |
38 class RenderObject; | 38 class RenderBlock; |
39 class RenderView; | 39 class RenderView; |
40 | 40 |
41 class CaretBase { | 41 class CaretBase { |
42 WTF_MAKE_NONCOPYABLE(CaretBase); | 42 WTF_MAKE_NONCOPYABLE(CaretBase); |
43 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 43 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
44 protected: | 44 protected: |
45 enum CaretVisibility { Visible, Hidden }; | 45 enum CaretVisibility { Visible, Hidden }; |
46 explicit CaretBase(CaretVisibility = Hidden); | 46 explicit CaretBase(CaretVisibility = Hidden); |
47 | 47 |
48 void invalidateCaretRect(Node*, bool caretRectChanged = false); | 48 void invalidateCaretRect(Node*, bool caretRectChanged = false); |
49 void clearCaretRect(); | 49 void clearCaretRect(); |
50 bool updateCaretRect(Document*, const VisiblePosition& caretPosition); | 50 bool updateCaretRect(Document*, const VisiblePosition& caretPosition); |
51 IntRect absoluteBoundsForLocalRect(Node*, const LayoutRect&) const; | 51 IntRect absoluteBoundsForLocalRect(Node*, const LayoutRect&) const; |
52 bool shouldRepaintCaret(const RenderView*, bool isContentEditable) const; | 52 bool shouldRepaintCaret(const RenderView*, bool isContentEditable) const; |
53 void paintCaret(Node*, GraphicsContext*, const LayoutPoint&, const LayoutRec
t& clipRect) const; | 53 void paintCaret(Node*, GraphicsContext*, const LayoutPoint&, const LayoutRec
t& clipRect) const; |
54 | 54 |
55 const LayoutRect& localCaretRectWithoutUpdate() const { return m_caretLocalR
ect; } | 55 const LayoutRect& localCaretRectWithoutUpdate() const { return m_caretLocalR
ect; } |
56 | 56 |
57 bool shouldUpdateCaretRect() const { return m_caretRectNeedsUpdate; } | 57 bool shouldUpdateCaretRect() const { return m_caretRectNeedsUpdate; } |
58 void setCaretRectNeedsUpdate() { m_caretRectNeedsUpdate = true; } | 58 void setCaretRectNeedsUpdate() { m_caretRectNeedsUpdate = true; } |
59 | 59 |
60 void setCaretVisibility(CaretVisibility visibility) { m_caretVisibility = vi
sibility; } | 60 void setCaretVisibility(CaretVisibility visibility) { m_caretVisibility = vi
sibility; } |
61 bool caretIsVisible() const { return m_caretVisibility == Visible; } | 61 bool caretIsVisible() const { return m_caretVisibility == Visible; } |
62 CaretVisibility caretVisibility() const { return m_caretVisibility; } | 62 CaretVisibility caretVisibility() const { return m_caretVisibility; } |
63 | 63 |
64 protected: | 64 protected: |
65 static RenderObject* caretRenderer(Node*); | 65 static RenderBlock* caretRenderer(Node*); |
66 static void repaintCaretForLocalRect(Node*, const LayoutRect&); | 66 static void repaintCaretForLocalRect(Node*, const LayoutRect&); |
67 | 67 |
68 private: | 68 private: |
69 LayoutRect m_caretLocalRect; // caret rect in coords local to the renderer r
esponsible for painting the caret | 69 LayoutRect m_caretLocalRect; // caret rect in coords local to the renderer r
esponsible for painting the caret |
70 bool m_caretRectNeedsUpdate; // true if m_caretRect (and m_absCaretBounds in
FrameSelection) need to be calculated | 70 bool m_caretRectNeedsUpdate; // true if m_caretRect (and m_absCaretBounds in
FrameSelection) need to be calculated |
71 CaretVisibility m_caretVisibility; | 71 CaretVisibility m_caretVisibility; |
72 }; | 72 }; |
73 | 73 |
74 class DragCaretController FINAL : public NoBaseWillBeGarbageCollected<DragCaretC
ontroller>, private CaretBase { | 74 class DragCaretController FINAL : public NoBaseWillBeGarbageCollected<DragCaretC
ontroller>, private CaretBase { |
75 WTF_MAKE_NONCOPYABLE(DragCaretController); | 75 WTF_MAKE_NONCOPYABLE(DragCaretController); |
76 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 76 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
77 public: | 77 public: |
78 static PassOwnPtrWillBeRawPtr<DragCaretController> create(); | 78 static PassOwnPtrWillBeRawPtr<DragCaretController> create(); |
79 | 79 |
80 RenderObject* caretRenderer() const; | 80 RenderBlock* caretRenderer() const; |
81 void paintDragCaret(LocalFrame*, GraphicsContext*, const LayoutPoint&, const
LayoutRect& clipRect) const; | 81 void paintDragCaret(LocalFrame*, GraphicsContext*, const LayoutPoint&, const
LayoutRect& clipRect) const; |
82 | 82 |
83 bool isContentEditable() const { return m_position.rootEditableElement(); } | 83 bool isContentEditable() const { return m_position.rootEditableElement(); } |
84 bool isContentRichlyEditable() const; | 84 bool isContentRichlyEditable() const; |
85 | 85 |
86 bool hasCaret() const { return m_position.isNotNull(); } | 86 bool hasCaret() const { return m_position.isNotNull(); } |
87 const VisiblePosition& caretPosition() { return m_position; } | 87 const VisiblePosition& caretPosition() { return m_position; } |
88 void setCaretPosition(const VisiblePosition&); | 88 void setCaretPosition(const VisiblePosition&); |
89 void clear() { setCaretPosition(VisiblePosition()); } | 89 void clear() { setCaretPosition(VisiblePosition()); } |
90 | 90 |
91 void nodeWillBeRemoved(Node&); | 91 void nodeWillBeRemoved(Node&); |
92 | 92 |
93 void trace(Visitor*); | 93 void trace(Visitor*); |
94 | 94 |
95 private: | 95 private: |
96 DragCaretController(); | 96 DragCaretController(); |
97 | 97 |
98 VisiblePosition m_position; | 98 VisiblePosition m_position; |
99 }; | 99 }; |
100 | 100 |
101 } // namespace blink | 101 } // namespace blink |
102 | 102 |
103 | 103 |
104 #endif // Caret_h | 104 #endif // Caret_h |
OLD | NEW |