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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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, 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, 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 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 EphemeralRange VisibleSelection::InDOMTree::asRange(const VisibleSelection& sele ction) 1131 EphemeralRange VisibleSelection::InDOMTree::asRange(const VisibleSelection& sele ction)
1132 { 1132 {
1133 return EphemeralRange(selectionStart(selection), selectionEnd(selection)); 1133 return EphemeralRange(selectionStart(selection), selectionEnd(selection));
1134 } 1134 }
1135 1135
1136 EphemeralRangeInComposedTree VisibleSelection::InComposedTree::asRange(const Vis ibleSelection& selection) 1136 EphemeralRangeInComposedTree VisibleSelection::InComposedTree::asRange(const Vis ibleSelection& selection)
1137 { 1137 {
1138 return EphemeralRangeInComposedTree(selectionStart(selection), selectionEnd( selection)); 1138 return EphemeralRangeInComposedTree(selectionStart(selection), selectionEnd( selection));
1139 } 1139 }
1140 1140
1141 bool VisibleSelection::InDOMTree::equalSelections(const VisibleSelection& select ion1, const VisibleSelection& selection2) 1141 template <typename Strategy>
1142 static bool equalSelectionsAlgorithm(const VisibleSelection& selection1, const V isibleSelection& selection2)
1142 { 1143 {
1143 if (selection1.affinity() != selection2.affinity() || selection1.isDirection al() != selection2.isDirectional()) 1144 if (selection1.affinity() != selection2.affinity() || selection1.isDirection al() != selection2.isDirectional())
1144 return false; 1145 return false;
1145 1146
1146 if (selection1.isNone()) 1147 if (selection1.isNone())
1147 return selection2.isNone(); 1148 return selection2.isNone();
1148 1149
1149 return selection1.start() == selection2.start() && selection1.end() == selec tion2.end() && selection1.affinity() == selection2.affinity() 1150 return Strategy::selectionStart(selection1) == Strategy::selectionStart(sele ction2)
1150 && selection1.isDirectional() == selection2.isDirectional() && selection 1.base() == selection2.base() && selection1.extent() == selection2.extent(); 1151 && Strategy::selectionEnd(selection1) == Strategy::selectionEnd(selectio n2)
1152 && Strategy::selectionBase(selection1) == Strategy::selectionBase(select ion2)
1153 && Strategy::selectionExtent(selection1) == Strategy::selectionExtent(se lection2);
1151 } 1154 }
1152 1155
1153 bool VisibleSelection::InComposedTree::equalSelections(const VisibleSelection& a , const VisibleSelection& b) 1156 bool VisibleSelection::InDOMTree::equalSelections(const VisibleSelection& select ion1, const VisibleSelection& selection2)
1154 { 1157 {
1155 return a.startInComposedTree() == b.startInComposedTree() && a.endInComposed Tree() == b.endInComposedTree() && a.affinity() == b.affinity() && a.isBaseFirst () == b.isBaseFirst() && a.isDirectional() == b.isDirectional(); 1158 return equalSelectionsAlgorithm<InDOMTree>(selection1, selection2);
1159 }
1160
1161 bool VisibleSelection::InComposedTree::equalSelections(const VisibleSelection& s election1, const VisibleSelection& selection2)
1162 {
1163 return equalSelectionsAlgorithm<InComposedTree>(selection1, selection2);
1156 } 1164 }
1157 1165
1158 #ifndef NDEBUG 1166 #ifndef NDEBUG
1159 1167
1160 void VisibleSelection::debugPosition(const char* message) const 1168 void VisibleSelection::debugPosition(const char* message) const
1161 { 1169 {
1162 fprintf(stderr, "VisibleSelection (%s) ===============\n", message); 1170 fprintf(stderr, "VisibleSelection (%s) ===============\n", message);
1163 1171
1164 if (m_baseIsFirst) { 1172 if (m_baseIsFirst) {
1165 m_start.debugPosition("start: "); 1173 m_start.debugPosition("start: ");
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 sel.showTreeForThis(); 1240 sel.showTreeForThis();
1233 } 1241 }
1234 1242
1235 void showTree(const blink::VisibleSelection* sel) 1243 void showTree(const blink::VisibleSelection* sel)
1236 { 1244 {
1237 if (sel) 1245 if (sel)
1238 sel->showTreeForThis(); 1246 sel->showTreeForThis();
1239 } 1247 }
1240 1248
1241 #endif 1249 #endif
OLDNEW
« 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