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

Unified Diff: Source/core/editing/FrameSelection.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, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | Source/core/page/EventHandler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/FrameSelection.cpp
diff --git a/Source/core/editing/FrameSelection.cpp b/Source/core/editing/FrameSelection.cpp
index 649efb9bae0e55feb73eeb9735ea76f1d73dd022..09f71ff12222702e4717450ee6fe9fb939660a8d 100644
--- a/Source/core/editing/FrameSelection.cpp
+++ b/Source/core/editing/FrameSelection.cpp
@@ -298,7 +298,7 @@ void FrameSelection::setSelection(const VisibleSelection& newSelection, SetSelec
m_frame->domWindow()->enqueueDocumentEvent(Event::create(EventTypeNames::selectionchange));
}
-static bool removingNodeRemovesPosition(Node* node, const Position& position)
+static bool removingNodeRemovesPosition(Node& node, const Position& position)
{
if (!position.anchorNode())
return false;
@@ -306,11 +306,11 @@ static bool removingNodeRemovesPosition(Node* node, const Position& position)
if (position.anchorNode() == node)
return true;
- if (!node->isElementNode())
+ if (!node.isElementNode())
return false;
- Element* element = toElement(node);
- return element->containsIncludingShadowDOM(position.anchorNode());
+ Element& element = toElement(node);
+ return element.containsIncludingShadowDOM(position.anchorNode());
}
static void clearRenderViewSelection(const Position& position)
@@ -321,18 +321,18 @@ static void clearRenderViewSelection(const Position& position)
view->clearSelection();
}
-void FrameSelection::nodeWillBeRemoved(Node* node)
+void FrameSelection::nodeWillBeRemoved(Node& node)
{
// There can't be a selection inside a fragment, so if a fragment's node is being removed,
// the selection in the document that created the fragment needs no adjustment.
- if (isNone() || (node && !node->inDocument()))
+ if (isNone() || !node.inDocument())
return;
respondToNodeModification(node, removingNodeRemovesPosition(node, m_selection.base()), removingNodeRemovesPosition(node, m_selection.extent()),
removingNodeRemovesPosition(node, m_selection.start()), removingNodeRemovesPosition(node, m_selection.end()));
}
-void FrameSelection::respondToNodeModification(Node* node, bool baseRemoved, bool extentRemoved, bool startRemoved, bool endRemoved)
+void FrameSelection::respondToNodeModification(Node& node, bool baseRemoved, bool extentRemoved, bool startRemoved, bool endRemoved)
{
bool clearRenderTreeSelection = false;
bool clearDOMTreeSelection = false;
@@ -341,9 +341,9 @@ void FrameSelection::respondToNodeModification(Node* node, bool baseRemoved, boo
Position start = m_selection.start();
Position end = m_selection.end();
if (startRemoved)
- updatePositionForNodeRemoval(start, node);
+ updatePositionForNodeRemoval(start, &node);
if (endRemoved)
- updatePositionForNodeRemoval(end, node);
+ updatePositionForNodeRemoval(end, &node);
if (start.isNotNull() && end.isNotNull()) {
if (m_selection.isBaseFirst())
@@ -365,7 +365,7 @@ void FrameSelection::respondToNodeModification(Node* node, bool baseRemoved, boo
m_selection.setWithoutValidation(m_selection.end(), m_selection.start());
} else if (RefPtr<Range> range = m_selection.firstRange()) {
TrackExceptionState es;
- Range::CompareResults compareResult = range->compareNode(node, es);
+ Range::CompareResults compareResult = range->compareNode(&node, es);
if (!es.hadException() && (compareResult == Range::NODE_BEFORE_AND_AFTER || compareResult == Range::NODE_INSIDE)) {
// If we did nothing here, when this node's renderer was destroyed, the rect that it
// occupied would be invalidated, but, selection gaps that change as a result of
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | Source/core/page/EventHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698