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

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

Issue 2616623002: Do not send redundant selectionchange-events (decouple focus) (Closed)
Patch Set: Move isSelectionInDocument() and selectionHasFocus() to EditingUtilities Created 3 years, 9 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
Index: third_party/WebKit/Source/core/editing/PendingSelection.cpp
diff --git a/third_party/WebKit/Source/core/editing/PendingSelection.cpp b/third_party/WebKit/Source/core/editing/PendingSelection.cpp
index 1b106656d49673990d8f12016ed2f04fad889264..6317e9a83b714e578d9016c6384677ea3b644ee6 100644
--- a/third_party/WebKit/Source/core/editing/PendingSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/PendingSelection.cpp
@@ -38,23 +38,6 @@ const VisibleSelection& PendingSelection::visibleSelection() const {
return m_frameSelection->computeVisibleSelectionInDOMTree();
}
-static bool isSelectionInDocument(
- const VisibleSelectionInFlatTree& visibleSelection,
- const Document& document) {
- const PositionInFlatTree& start = visibleSelection.start();
- if (start.isNotNull() &&
- (!start.isConnected() || start.document() != document))
- return false;
- const PositionInFlatTree& end = visibleSelection.end();
- if (end.isNotNull() && (!end.isConnected() || end.document() != document))
- return false;
- const PositionInFlatTree extent = visibleSelection.extent();
- if (extent.isNotNull() &&
- (!extent.isConnected() || extent.document() != document))
- return false;
- return true;
-}
-
SelectionInFlatTree PendingSelection::calcVisibleSelection(
const VisibleSelectionInFlatTree& originalSelection) const {
const PositionInFlatTree& start = originalSelection.start();
@@ -126,7 +109,8 @@ void PendingSelection::commit(LayoutView& layoutView) {
const VisibleSelectionInFlatTree& selection =
createVisibleSelection(calcVisibleSelection(originalSelection));
- if (!selection.isRange()) {
+ const LocalFrame& frame = *layoutView.document().frame();
+ if (!selection.isRange() || !selectionHasFocus(frame)) {
layoutView.clearSelection();
return;
}

Powered by Google App Engine
This is Rietveld 408576698