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 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 { | 63 { |
64 if (Node* node = m_position.deepEquivalent().deprecatedNode()) | 64 if (Node* node = m_position.deepEquivalent().deprecatedNode()) |
65 invalidateCaretRect(node); | 65 invalidateCaretRect(node); |
66 m_position = position; | 66 m_position = position; |
67 setCaretRectNeedsUpdate(); | 67 setCaretRectNeedsUpdate(); |
68 Document* document = 0; | 68 Document* document = 0; |
69 if (Node* node = m_position.deepEquivalent().deprecatedNode()) { | 69 if (Node* node = m_position.deepEquivalent().deprecatedNode()) { |
70 invalidateCaretRect(node); | 70 invalidateCaretRect(node); |
71 document = &node->document(); | 71 document = &node->document(); |
72 } | 72 } |
73 if (m_position.isNull() || m_position.isOrphan()) | 73 if (m_position.isNull() || m_position.isOrphan()) { |
74 clearCaretRect(); | 74 clearCaretRect(); |
75 else | 75 } else { |
| 76 document->updateRenderTreeIfNeeded(); |
76 updateCaretRect(document, m_position); | 77 updateCaretRect(document, m_position); |
| 78 } |
77 } | 79 } |
78 | 80 |
79 static bool removingNodeRemovesPosition(Node& node, const Position& position) | 81 static bool removingNodeRemovesPosition(Node& node, const Position& position) |
80 { | 82 { |
81 if (!position.anchorNode()) | 83 if (!position.anchorNode()) |
82 return false; | 84 return false; |
83 | 85 |
84 if (position.anchorNode() == node) | 86 if (position.anchorNode() == node) |
85 return true; | 87 return true; |
86 | 88 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 if (!renderer) | 129 if (!renderer) |
128 return 0; | 130 return 0; |
129 | 131 |
130 // if caretNode is a block and caret is inside it then caret should be paint
ed by that block | 132 // if caretNode is a block and caret is inside it then caret should be paint
ed by that block |
131 bool paintedByBlock = renderer->isRenderBlock() && caretRendersInsideNode(no
de); | 133 bool paintedByBlock = renderer->isRenderBlock() && caretRendersInsideNode(no
de); |
132 return paintedByBlock ? toRenderBlock(renderer) : renderer->containingBlock(
); | 134 return paintedByBlock ? toRenderBlock(renderer) : renderer->containingBlock(
); |
133 } | 135 } |
134 | 136 |
135 bool CaretBase::updateCaretRect(Document* document, const PositionWithAffinity&
caretPosition) | 137 bool CaretBase::updateCaretRect(Document* document, const PositionWithAffinity&
caretPosition) |
136 { | 138 { |
137 document->updateRenderTreeIfNeeded(); | |
138 m_caretLocalRect = LayoutRect(); | 139 m_caretLocalRect = LayoutRect(); |
139 | 140 |
140 m_caretRectNeedsUpdate = false; | 141 m_caretRectNeedsUpdate = false; |
141 | 142 |
142 if (caretPosition.position().isNull()) | 143 if (caretPosition.position().isNull()) |
143 return false; | 144 return false; |
144 | 145 |
145 ASSERT(caretPosition.position().deprecatedNode()->renderer()); | 146 ASSERT(caretPosition.position().deprecatedNode()->renderer()); |
146 | 147 |
147 // First compute a rect local to the renderer at the selection start. | 148 // First compute a rect local to the renderer at the selection start. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 context->fillRect(caret, caretColor); | 268 context->fillRect(caret, caretColor); |
268 } | 269 } |
269 | 270 |
270 void DragCaretController::paintDragCaret(LocalFrame* frame, GraphicsContext* p,
const LayoutPoint& paintOffset, const LayoutRect& clipRect) const | 271 void DragCaretController::paintDragCaret(LocalFrame* frame, GraphicsContext* p,
const LayoutPoint& paintOffset, const LayoutRect& clipRect) const |
271 { | 272 { |
272 if (m_position.deepEquivalent().deprecatedNode()->document().frame() == fram
e) | 273 if (m_position.deepEquivalent().deprecatedNode()->document().frame() == fram
e) |
273 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, paintOffset,
clipRect); | 274 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, paintOffset,
clipRect); |
274 } | 275 } |
275 | 276 |
276 } | 277 } |
OLD | NEW |