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

Unified Diff: third_party/WebKit/Source/core/editing/FrameSelection.cpp

Issue 2212293002: Use LayoutObject::selectionState() to check whether selection contains node or not (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-08-08T11:10:01 Created 4 years, 4 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 | « third_party/WebKit/PerformanceTests/DOM/remove_child_with_selection.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/FrameSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/FrameSelection.cpp b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
index 8c7f0a8448b37586d6d33161c389506e1f954ff7..e8f172812f75a69e9d83b6ac28354215a087cc0c 100644
--- a/third_party/WebKit/Source/core/editing/FrameSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/FrameSelection.cpp
@@ -419,15 +419,12 @@ void FrameSelection::nodeWillBeRemoved(Node& node)
m_frameCaret->nodeWillBeRemoved(node);
}
-static bool intersectsNode(const VisibleSelection& selection, Node* node)
+static SelectionState selectionStateOf(const Node& node)
{
- if (selection.isNone())
- return false;
- Position start = selection.start().parentAnchoredEquivalent();
- Position end = selection.end().parentAnchoredEquivalent();
- TrackExceptionState exceptionState;
- // TODO(yosin) We should avoid to use |Range::intersectsNode()|.
- return Range::intersectsNode(node, start, end, exceptionState) && !exceptionState.hadException();
+ const LayoutObject* layoutObject = node.layoutObject();
+ if (!layoutObject)
+ return SelectionNone;
+ return layoutObject->getSelectionState();
}
void FrameSelection::respondToNodeModification(Node& node, bool baseRemoved, bool extentRemoved, bool startRemoved, bool endRemoved)
@@ -464,11 +461,11 @@ void FrameSelection::respondToNodeModification(Node& node, bool baseRemoved, boo
m_selectionEditor->setWithoutValidation(selection().start(), selection().end());
else
m_selectionEditor->setWithoutValidation(selection().end(), selection().start());
- } else if (intersectsNode(selection(), &node)) {
- // If we did nothing here, when this node's layoutObject was destroyed, the rect that it
- // occupied would be invalidated, but, selection gaps that change as a result of
- // the removal wouldn't be invalidated.
- // FIXME: Don't do so much unnecessary invalidation.
+ } else if (selectionStateOf(node) != SelectionNone) {
+ // When node to be removed is part of selection, we invalidate
+ // selection to paint again.
+ // TODO(yosin): We should paint changed area only rather than whole
+ // selected range.
clearLayoutTreeSelection = true;
}
« no previous file with comments | « third_party/WebKit/PerformanceTests/DOM/remove_child_with_selection.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698