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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 if (Node* node = m_position.deepEquivalent().deprecatedNode()) { | 71 if (Node* node = m_position.deepEquivalent().deprecatedNode()) { |
72 invalidateCaretRect(node); | 72 invalidateCaretRect(node); |
73 document = &node->document(); | 73 document = &node->document(); |
74 } | 74 } |
75 if (m_position.isNull() || m_position.isOrphan()) | 75 if (m_position.isNull() || m_position.isOrphan()) |
76 clearCaretRect(); | 76 clearCaretRect(); |
77 else | 77 else |
78 updateCaretRect(document, m_position); | 78 updateCaretRect(document, m_position); |
79 } | 79 } |
80 | 80 |
81 static bool removingNodeRemovesPosition(Node* node, const Position& position) | 81 static bool removingNodeRemovesPosition(Node& node, const Position& position) |
82 { | 82 { |
83 if (!position.anchorNode()) | 83 if (!position.anchorNode()) |
84 return false; | 84 return false; |
85 | 85 |
86 if (position.anchorNode() == node) | 86 if (position.anchorNode() == node) |
87 return true; | 87 return true; |
88 | 88 |
89 if (!node->isElementNode()) | 89 if (!node.isElementNode()) |
90 return false; | 90 return false; |
91 | 91 |
92 Element* element = toElement(node); | 92 Element& element = toElement(node); |
93 return element->containsIncludingShadowDOM(position.anchorNode()); | 93 return element.containsIncludingShadowDOM(position.anchorNode()); |
94 } | 94 } |
95 | 95 |
96 static void clearRenderViewSelection(const Position& position) | 96 static void clearRenderViewSelection(const Position& position) |
97 { | 97 { |
98 RefPtr<Document> document = position.document(); | 98 RefPtr<Document> document = position.document(); |
99 document->updateStyleIfNeeded(); | 99 document->updateStyleIfNeeded(); |
100 if (RenderView* view = document->renderView()) | 100 if (RenderView* view = document->renderView()) |
101 view->clearSelection(); | 101 view->clearSelection(); |
102 } | 102 } |
103 | 103 |
104 void DragCaretController::nodeWillBeRemoved(Node* node) | 104 void DragCaretController::nodeWillBeRemoved(Node& node) |
105 { | 105 { |
106 if (!hasCaret() || (node && !node->inDocument())) | 106 if (!hasCaret() || !node.inDocument()) |
107 return; | 107 return; |
108 | 108 |
109 if (!removingNodeRemovesPosition(node, m_position.deepEquivalent())) | 109 if (!removingNodeRemovesPosition(node, m_position.deepEquivalent())) |
110 return; | 110 return; |
111 | 111 |
112 clearRenderViewSelection(m_position.deepEquivalent()); | 112 clearRenderViewSelection(m_position.deepEquivalent()); |
113 clear(); | 113 clear(); |
114 } | 114 } |
115 | 115 |
116 void CaretBase::clearCaretRect() | 116 void CaretBase::clearCaretRect() |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 context->fillRect(caret, caretColor); | 269 context->fillRect(caret, caretColor); |
270 } | 270 } |
271 | 271 |
272 void DragCaretController::paintDragCaret(Frame* frame, GraphicsContext* p, const
LayoutPoint& paintOffset, const LayoutRect& clipRect) const | 272 void DragCaretController::paintDragCaret(Frame* frame, GraphicsContext* p, const
LayoutPoint& paintOffset, const LayoutRect& clipRect) const |
273 { | 273 { |
274 if (m_position.deepEquivalent().deprecatedNode()->document().frame() == fram
e) | 274 if (m_position.deepEquivalent().deprecatedNode()->document().frame() == fram
e) |
275 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, paintOffset,
clipRect); | 275 paintCaret(m_position.deepEquivalent().deprecatedNode(), p, paintOffset,
clipRect); |
276 } | 276 } |
277 | 277 |
278 } | 278 } |
OLD | NEW |