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

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

Issue 64323002: Minor optimization in FrameSelection::setNonDirectionalSelectionIfNeeded(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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, 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 190 }
191 191
192 void FrameSelection::setNonDirectionalSelectionIfNeeded(const VisibleSelection& passedNewSelection, TextGranularity granularity, 192 void FrameSelection::setNonDirectionalSelectionIfNeeded(const VisibleSelection& passedNewSelection, TextGranularity granularity,
193 EndPointsAdjustmentMode endpointsAdjustmentMode) 193 EndPointsAdjustmentMode endpointsAdjustmentMode)
194 { 194 {
195 VisibleSelection newSelection = passedNewSelection; 195 VisibleSelection newSelection = passedNewSelection;
196 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || newSele ction.isDirectional(); 196 bool isDirectional = shouldAlwaysUseDirectionalSelection(m_frame) || newSele ction.isDirectional();
197 197
198 VisiblePosition base = m_originalBase.isNotNull() ? m_originalBase : newSele ction.visibleBase(); 198 VisiblePosition base = m_originalBase.isNotNull() ? m_originalBase : newSele ction.visibleBase();
199 VisiblePosition newBase = base; 199 VisiblePosition newBase = base;
200 VisiblePosition newExtent = newSelection.visibleExtent(); 200 VisiblePosition extent = newSelection.visibleExtent();
201 VisiblePosition newExtent = extent;
201 if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary) 202 if (endpointsAdjustmentMode == AdjustEndpointsAtBidiBoundary)
202 adjustEndpointsAtBidiBoundary(newBase, newExtent); 203 adjustEndpointsAtBidiBoundary(newBase, newExtent);
203 204
204 if (newBase != base || newExtent != newSelection.visibleExtent()) { 205 if (newBase != base || newExtent != extent) {
205 m_originalBase = base; 206 m_originalBase = base;
206 newSelection.setBase(newBase); 207 newSelection.setBase(newBase);
207 newSelection.setExtent(newExtent); 208 newSelection.setExtent(newExtent);
208 } else if (m_originalBase.isNotNull()) { 209 } else if (m_originalBase.isNotNull()) {
209 if (m_selection.base() == newSelection.base()) 210 if (m_selection.base() == newSelection.base())
210 newSelection.setBase(m_originalBase); 211 newSelection.setBase(m_originalBase);
211 m_originalBase.clear(); 212 m_originalBase.clear();
212 } 213 }
213 214
214 newSelection.setIsDirectional(isDirectional); // Adjusting base and extent w ill make newSelection always directional 215 newSelection.setIsDirectional(isDirectional); // Adjusting base and extent w ill make newSelection always directional
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 sel.showTreeForThis(); 1868 sel.showTreeForThis();
1868 } 1869 }
1869 1870
1870 void showTree(const WebCore::FrameSelection* sel) 1871 void showTree(const WebCore::FrameSelection* sel)
1871 { 1872 {
1872 if (sel) 1873 if (sel)
1873 sel->showTreeForThis(); 1874 sel->showTreeForThis();
1874 } 1875 }
1875 1876
1876 #endif 1877 #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