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

Side by Side Diff: third_party/WebKit/Source/core/editing/FrameSelection.cpp

Issue 1793093006: [Editing][Stability] Recanonicalize m_originalbase in FrameSelection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit pick Created 4 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 visibleExtent = createVisiblePosition(fromPositionInDOMTree<Strategy>(ex tent.positionAtLeftBoundaryOfBiDiRun())); 216 visibleExtent = createVisiblePosition(fromPositionInDOMTree<Strategy>(ex tent.positionAtLeftBoundaryOfBiDiRun()));
217 return; 217 return;
218 } 218 }
219 219
220 if (extent.atRightBoundaryOfBidiRun() && extent.isEquivalent(base.rightBound aryOfBidiRun(extent.bidiLevelOnLeft()))) { 220 if (extent.atRightBoundaryOfBidiRun() && extent.isEquivalent(base.rightBound aryOfBidiRun(extent.bidiLevelOnLeft()))) {
221 visibleExtent = createVisiblePosition(fromPositionInDOMTree<Strategy>(ex tent.positionAtRightBoundaryOfBiDiRun())); 221 visibleExtent = createVisiblePosition(fromPositionInDOMTree<Strategy>(ex tent.positionAtRightBoundaryOfBiDiRun()));
222 return; 222 return;
223 } 223 }
224 } 224 }
225 225
226 void FrameSelection::setOriginalBase(const VisiblePosition& newBase)
227 {
228 m_originalBase = newBase;
229 m_originalBaseInFlatTree = createVisiblePosition(toPositionInFlatTree(newBas e.deepEquivalent()));
230 }
231
232 void FrameSelection::setOriginalBase(const VisiblePositionInFlatTree& newBase)
233 {
234 m_originalBaseInFlatTree = newBase;
235 m_originalBase = createVisiblePosition(toPositionInDOMTree(newBase.deepEquiv alent()));
236 }
237
226 template <typename Strategy> 238 template <typename Strategy>
227 void FrameSelection::setNonDirectionalSelectionIfNeededAlgorithm(const VisibleSe lectionTemplate<Strategy>& passedNewSelection, TextGranularity granularity, 239 void FrameSelection::setNonDirectionalSelectionIfNeededAlgorithm(const VisibleSe lectionTemplate<Strategy>& passedNewSelection, TextGranularity granularity,
228 EndPointsAdjustmentMode endpointsAdjustmentMode) 240 EndPointsAdjustmentMode endpointsAdjustmentMode)
229 { 241 {
230 VisibleSelectionTemplate<Strategy> newSelection = passedNewSelection; 242 VisibleSelectionTemplate<Strategy> newSelection = passedNewSelection;
231 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || newSele ction.isDirectional(); 243 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || newSele ction.isDirectional();
232 244
233 const VisiblePositionTemplate<Strategy> originalBase = this->originalBase<St rategy>(); 245 const PositionTemplate<Strategy> basePosition = this->originalBase<Strategy> ().deepEquivalent();
246 const VisiblePositionTemplate<Strategy> originalBase = basePosition.inShadow IncludingDocument() ? createVisiblePosition(basePosition) : VisiblePositionTempl ate<Strategy>();
234 const VisiblePositionTemplate<Strategy> base = originalBase.isNotNull() ? or iginalBase : createVisiblePosition(newSelection.base()); 247 const VisiblePositionTemplate<Strategy> base = originalBase.isNotNull() ? or iginalBase : createVisiblePosition(newSelection.base());
235 VisiblePositionTemplate<Strategy> newBase = base; 248 VisiblePositionTemplate<Strategy> newBase = base;
236 const VisiblePositionTemplate<Strategy> extent = createVisiblePosition(newSe lection.extent()); 249 const VisiblePositionTemplate<Strategy> extent = createVisiblePosition(newSe lection.extent());
237 VisiblePositionTemplate<Strategy> newExtent = extent; 250 VisiblePositionTemplate<Strategy> newExtent = extent;
238 if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary) 251 if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary)
239 adjustEndpointsAtBidiBoundary(newBase, newExtent); 252 adjustEndpointsAtBidiBoundary(newBase, newExtent);
240 253
241 if (newBase.deepEquivalent() != base.deepEquivalent() || newExtent.deepEquiv alent() != extent.deepEquivalent()) { 254 if (newBase.deepEquivalent() != base.deepEquivalent() || newExtent.deepEquiv alent() != extent.deepEquivalent()) {
242 setOriginalBase(base); 255 setOriginalBase(base);
243 newSelection.setBase(newBase); 256 newSelection.setBase(newBase);
(...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 1442
1430 void showTree(const blink::FrameSelection* sel) 1443 void showTree(const blink::FrameSelection* sel)
1431 { 1444 {
1432 if (sel) 1445 if (sel)
1433 sel->showTreeForThis(); 1446 sel->showTreeForThis();
1434 else 1447 else
1435 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); 1448 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n");
1436 } 1449 }
1437 1450
1438 #endif 1451 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.h ('k') | third_party/WebKit/Source/core/editing/VisibleUnits.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698