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 30 matching lines...) Expand all Loading... |
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_WILL_BE_REMOVED; |
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 |
| 52 // PositionWithAffinity version if possible. |
| 53 // A position in HTMLTextFromControlElement is a typical example. |
51 bool updateCaretRect(Document*, const PositionWithAffinity& caretPosition); | 54 bool updateCaretRect(Document*, const PositionWithAffinity& caretPosition); |
52 // Simply calls above updateCaretRect using deepEquivalent() and affinity(). | |
53 bool updateCaretRect(Document*, const VisiblePosition& caretPosition); | 55 bool updateCaretRect(Document*, const VisiblePosition& caretPosition); |
54 IntRect absoluteBoundsForLocalRect(Node*, const LayoutRect&) const; | 56 IntRect absoluteBoundsForLocalRect(Node*, const LayoutRect&) const; |
55 bool shouldRepaintCaret(const RenderView*, bool isContentEditable) const; | 57 bool shouldRepaintCaret(const RenderView*, bool isContentEditable) const; |
56 void paintCaret(Node*, GraphicsContext*, const LayoutPoint&, const LayoutRec
t& clipRect) const; | 58 void paintCaret(Node*, GraphicsContext*, const LayoutPoint&, const LayoutRec
t& clipRect) const; |
57 | 59 |
58 const LayoutRect& localCaretRectWithoutUpdate() const { return m_caretLocalR
ect; } | 60 const LayoutRect& localCaretRectWithoutUpdate() const { return m_caretLocalR
ect; } |
59 | 61 |
60 bool shouldUpdateCaretRect() const { return m_caretRectNeedsUpdate; } | 62 bool shouldUpdateCaretRect() const { return m_caretRectNeedsUpdate; } |
61 void setCaretRectNeedsUpdate() { m_caretRectNeedsUpdate = true; } | 63 void setCaretRectNeedsUpdate() { m_caretRectNeedsUpdate = true; } |
62 | 64 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 private: | 100 private: |
99 DragCaretController(); | 101 DragCaretController(); |
100 | 102 |
101 VisiblePosition m_position; | 103 VisiblePosition m_position; |
102 }; | 104 }; |
103 | 105 |
104 } // namespace blink | 106 } // namespace blink |
105 | 107 |
106 | 108 |
107 #endif // Caret_h | 109 #endif // Caret_h |
OLD | NEW |