Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: Source/core/editing/Caret.cpp

Issue 48803004: Have Document::nodeWillBeRemoved() take a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/editing/Caret.h ('k') | Source/core/editing/FrameSelection.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « Source/core/editing/Caret.h ('k') | Source/core/editing/FrameSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698