| 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 23 matching lines...) Expand all Loading... |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 class LocalFrame; | 36 class LocalFrame; |
| 37 class GraphicsContext; | 37 class GraphicsContext; |
| 38 class PositionWithAffinity; | 38 class PositionWithAffinity; |
| 39 class RenderBlock; | 39 class RenderBlock; |
| 40 class RenderView; | 40 class RenderView; |
| 41 | 41 |
| 42 class CaretBase { | 42 class CaretBase { |
| 43 WTF_MAKE_NONCOPYABLE(CaretBase); | 43 WTF_MAKE_NONCOPYABLE(CaretBase); |
| 44 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 44 WTF_MAKE_FAST_ALLOCATED; |
| 45 protected: | 45 protected: |
| 46 enum CaretVisibility { Visible, Hidden }; | 46 enum CaretVisibility { Visible, Hidden }; |
| 47 explicit CaretBase(CaretVisibility = Hidden); | 47 explicit CaretBase(CaretVisibility = Hidden); |
| 48 | 48 |
| 49 void invalidateCaretRect(Node*, bool caretRectChanged = false); | 49 void invalidateCaretRect(Node*, bool caretRectChanged = false); |
| 50 void clearCaretRect(); | 50 void clearCaretRect(); |
| 51 // Creating VisiblePosition causes synchronous layout so we should use the | 51 // Creating VisiblePosition causes synchronous layout so we should use the |
| 52 // PositionWithAffinity version if possible. | 52 // PositionWithAffinity version if possible. |
| 53 // A position in HTMLTextFromControlElement is a typical example. | 53 // A position in HTMLTextFromControlElement is a typical example. |
| 54 bool updateCaretRect(Document*, const PositionWithAffinity& caretPosition); | 54 bool updateCaretRect(Document*, const PositionWithAffinity& caretPosition); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 68 protected: | 68 protected: |
| 69 static RenderBlock* caretRenderer(Node*); | 69 static RenderBlock* caretRenderer(Node*); |
| 70 static void invalidateLocalCaretRect(Node*, const LayoutRect&); | 70 static void invalidateLocalCaretRect(Node*, const LayoutRect&); |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 LayoutRect m_caretLocalRect; // caret rect in coords local to the renderer r
esponsible for painting the caret | 73 LayoutRect m_caretLocalRect; // caret rect in coords local to the renderer r
esponsible for painting the caret |
| 74 bool m_caretRectNeedsUpdate; // true if m_caretRect (and m_absCaretBounds in
FrameSelection) need to be calculated | 74 bool m_caretRectNeedsUpdate; // true if m_caretRect (and m_absCaretBounds in
FrameSelection) need to be calculated |
| 75 CaretVisibility m_caretVisibility; | 75 CaretVisibility m_caretVisibility; |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 class DragCaretController final : public DummyBase<DragCaretController>, private
CaretBase { | 78 class DragCaretController final : private CaretBase { |
| 79 WTF_MAKE_NONCOPYABLE(DragCaretController); | 79 WTF_MAKE_NONCOPYABLE(DragCaretController); |
| 80 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 80 WTF_MAKE_FAST_ALLOCATED; |
| 81 public: | 81 public: |
| 82 static PassOwnPtr<DragCaretController> create(); | 82 static PassOwnPtr<DragCaretController> create(); |
| 83 | 83 |
| 84 RenderBlock* caretRenderer() const; | 84 RenderBlock* caretRenderer() const; |
| 85 void paintDragCaret(LocalFrame*, GraphicsContext*, const LayoutPoint&, const
LayoutRect& clipRect) const; | 85 void paintDragCaret(LocalFrame*, GraphicsContext*, const LayoutPoint&, const
LayoutRect& clipRect) const; |
| 86 | 86 |
| 87 bool isContentEditable() const { return m_position.rootEditableElement(); } | 87 bool isContentEditable() const { return m_position.rootEditableElement(); } |
| 88 bool isContentRichlyEditable() const; | 88 bool isContentRichlyEditable() const; |
| 89 | 89 |
| 90 bool hasCaret() const { return m_position.isNotNull(); } | 90 bool hasCaret() const { return m_position.isNotNull(); } |
| 91 const VisiblePosition& caretPosition() { return m_position; } | 91 const VisiblePosition& caretPosition() { return m_position; } |
| 92 void setCaretPosition(const VisiblePosition&); | 92 void setCaretPosition(const VisiblePosition&); |
| 93 void clear() { setCaretPosition(VisiblePosition()); } | 93 void clear() { setCaretPosition(VisiblePosition()); } |
| 94 | 94 |
| 95 void nodeWillBeRemoved(Node&); | 95 void nodeWillBeRemoved(Node&); |
| 96 | 96 |
| 97 void trace(Visitor*); | 97 void trace(Visitor*); |
| 98 | 98 |
| 99 private: | 99 private: |
| 100 DragCaretController(); | 100 DragCaretController(); |
| 101 | 101 |
| 102 VisiblePosition m_position; | 102 VisiblePosition m_position; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 } // namespace blink | 105 } // namespace blink |
| 106 | 106 |
| 107 | 107 |
| 108 #endif // Caret_h | 108 #endif // Caret_h |
| OLD | NEW |