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

Unified Diff: Source/core/editing/VisibleSelection.cpp

Issue 1234513004: Make follow the same pattern for equalSelections() in VisibleSelection. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make follow the same pattern for equalSelections() in visibleSelection. Created 5 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/VisibleSelection.cpp
diff --git a/Source/core/editing/VisibleSelection.cpp b/Source/core/editing/VisibleSelection.cpp
index b37baddacdcde8b6dddd213f92b4106b0e51e6a4..3ea806fa8b614f4e467502c60db6ef0d579c9a4a 100644
--- a/Source/core/editing/VisibleSelection.cpp
+++ b/Source/core/editing/VisibleSelection.cpp
@@ -1138,7 +1138,8 @@ EphemeralRangeInComposedTree VisibleSelection::InComposedTree::asRange(const Vis
return EphemeralRangeInComposedTree(selectionStart(selection), selectionEnd(selection));
}
-bool VisibleSelection::InDOMTree::equalSelections(const VisibleSelection& selection1, const VisibleSelection& selection2)
+template <typename Strategy>
+static bool equalSelectionsAlgorithm(const VisibleSelection& selection1, const VisibleSelection& selection2)
{
if (selection1.affinity() != selection2.affinity() || selection1.isDirectional() != selection2.isDirectional())
return false;
@@ -1146,13 +1147,20 @@ bool VisibleSelection::InDOMTree::equalSelections(const VisibleSelection& select
if (selection1.isNone())
return selection2.isNone();
- return selection1.start() == selection2.start() && selection1.end() == selection2.end() && selection1.affinity() == selection2.affinity()
- && selection1.isDirectional() == selection2.isDirectional() && selection1.base() == selection2.base() && selection1.extent() == selection2.extent();
+ return Strategy::selectionStart(selection1) == Strategy::selectionStart(selection2)
+ && Strategy::selectionEnd(selection1) == Strategy::selectionEnd(selection2)
+ && Strategy::selectionBase(selection1) == Strategy::selectionBase(selection2)
+ && Strategy::selectionExtent(selection1) == Strategy::selectionExtent(selection2);
+}
+
+bool VisibleSelection::InDOMTree::equalSelections(const VisibleSelection& selection1, const VisibleSelection& selection2)
+{
+ return equalSelectionsAlgorithm<InDOMTree>(selection1, selection2);
}
-bool VisibleSelection::InComposedTree::equalSelections(const VisibleSelection& a, const VisibleSelection& b)
+bool VisibleSelection::InComposedTree::equalSelections(const VisibleSelection& selection1, const VisibleSelection& selection2)
{
- return a.startInComposedTree() == b.startInComposedTree() && a.endInComposedTree() == b.endInComposedTree() && a.affinity() == b.affinity() && a.isBaseFirst() == b.isBaseFirst() && a.isDirectional() == b.isDirectional();
+ return equalSelectionsAlgorithm<InComposedTree>(selection1, selection2);
}
#ifndef NDEBUG
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698