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

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

Issue 1302353002: Get rid of redundant member function PositionAlgorithm<Strategy>::{upstream,downstream} (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-22T04:51:20 Rebase Created 5 years, 4 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 | « Source/core/editing/PositionTest.cpp ('k') | Source/core/editing/VisiblePosition.cpp » ('j') | 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) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * Copyright (C) 2015 Google Inc. All rights reserved. 5 * Copyright (C) 2015 Google Inc. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 template <typename SelectionType> 84 template <typename SelectionType>
85 VisibleSelection expandSelectionToRespectUserSelectAllAlgorithm(Node* targetNode , const VisibleSelection& selection) 85 VisibleSelection expandSelectionToRespectUserSelectAllAlgorithm(Node* targetNode , const VisibleSelection& selection)
86 { 86 {
87 using PositionType = typename SelectionType::PositionType; 87 using PositionType = typename SelectionType::PositionType;
88 88
89 Node* rootUserSelectAll = SelectionType::Strategy::rootUserSelectAllForNode( targetNode); 89 Node* rootUserSelectAll = SelectionType::Strategy::rootUserSelectAllForNode( targetNode);
90 if (!rootUserSelectAll) 90 if (!rootUserSelectAll)
91 return selection; 91 return selection;
92 92
93 VisibleSelection newSelection(selection); 93 VisibleSelection newSelection(selection);
94 newSelection.setBase(PositionType::beforeNode(rootUserSelectAll).upstream(Ca nCrossEditingBoundary)); 94 newSelection.setBase(mostBackwardCaretPosition(PositionType::beforeNode(root UserSelectAll), CanCrossEditingBoundary));
95 newSelection.setExtent(PositionType::afterNode(rootUserSelectAll).downstream (CanCrossEditingBoundary)); 95 newSelection.setExtent(mostForwardCaretPosition(PositionType::afterNode(root UserSelectAll), CanCrossEditingBoundary));
96 96
97 return newSelection; 97 return newSelection;
98 } 98 }
99 99
100 VisibleSelection expandSelectionToRespectUserSelectAll(Node* targetNode, const V isibleSelection& selection) 100 VisibleSelection expandSelectionToRespectUserSelectAll(Node* targetNode, const V isibleSelection& selection)
101 { 101 {
102 if (RuntimeEnabledFeatures::selectionForComposedTreeEnabled()) 102 if (RuntimeEnabledFeatures::selectionForComposedTreeEnabled())
103 return expandSelectionToRespectUserSelectAllAlgorithm<VisibleSelection:: InComposedTree>(targetNode, selection); 103 return expandSelectionToRespectUserSelectAllAlgorithm<VisibleSelection:: InComposedTree>(targetNode, selection);
104 return expandSelectionToRespectUserSelectAllAlgorithm<VisibleSelection::InDO MTree>(targetNode, selection); 104 return expandSelectionToRespectUserSelectAllAlgorithm<VisibleSelection::InDO MTree>(targetNode, selection);
105 } 105 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 if (m_selectionState != SelectionState::ExtendedSelection) { 245 if (m_selectionState != SelectionState::ExtendedSelection) {
246 // Always extend selection here because it's caused by a mouse drag 246 // Always extend selection here because it's caused by a mouse drag
247 m_selectionState = SelectionState::ExtendedSelection; 247 m_selectionState = SelectionState::ExtendedSelection;
248 newSelection = VisibleSelection(targetPosition); 248 newSelection = VisibleSelection(targetPosition);
249 } 249 }
250 250
251 if (RuntimeEnabledFeatures::userSelectAllEnabled()) { 251 if (RuntimeEnabledFeatures::userSelectAllEnabled()) {
252 // TODO(yosin) Should we use |Strategy::rootUserSelectAllForNode()|? 252 // TODO(yosin) Should we use |Strategy::rootUserSelectAllForNode()|?
253 Node* rootUserSelectAllForMousePressNode = EditingStrategy::rootUserSele ctAllForNode(mousePressNode); 253 Node* rootUserSelectAllForMousePressNode = EditingStrategy::rootUserSele ctAllForNode(mousePressNode);
254 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePress Node == EditingStrategy::rootUserSelectAllForNode(target)) { 254 if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePress Node == EditingStrategy::rootUserSelectAllForNode(target)) {
255 newSelection.setBase(PositionType::beforeNode(rootUserSelectAllForMo usePressNode).upstream(CanCrossEditingBoundary)); 255 newSelection.setBase(mostBackwardCaretPosition(PositionType::beforeN ode(rootUserSelectAllForMousePressNode), CanCrossEditingBoundary));
256 newSelection.setExtent(PositionType::afterNode(rootUserSelectAllForM ousePressNode).downstream(CanCrossEditingBoundary)); 256 newSelection.setExtent(mostForwardCaretPosition(PositionType::afterN ode(rootUserSelectAllForMousePressNode), CanCrossEditingBoundary));
257 } else { 257 } else {
258 // Reset base for user select all when base is inside user-select-al l area and extent < base. 258 // Reset base for user select all when base is inside user-select-al l area and extent < base.
259 if (rootUserSelectAllForMousePressNode) { 259 if (rootUserSelectAllForMousePressNode) {
260 PositionType eventPosition = Strategy::toPositionType(target->la youtObject()->positionForPoint(hitTestResult.localPoint()).position()); 260 PositionType eventPosition = Strategy::toPositionType(target->la youtObject()->positionForPoint(hitTestResult.localPoint()).position());
261 PositionType dragStartPosition = Strategy::toPositionType(mouseP ressNode->layoutObject()->positionForPoint(dragStartPos).position()); 261 PositionType dragStartPosition = Strategy::toPositionType(mouseP ressNode->layoutObject()->positionForPoint(dragStartPos).position());
262 if (eventPosition.compareTo(dragStartPosition) < 0) 262 if (eventPosition.compareTo(dragStartPosition) < 0)
263 newSelection.setBase(PositionType::afterNode(rootUserSelectA llForMousePressNode).downstream(CanCrossEditingBoundary)); 263 newSelection.setBase(mostForwardCaretPosition(PositionType:: afterNode(rootUserSelectAllForMousePressNode), CanCrossEditingBoundary));
264 } 264 }
265 265
266 Node* rootUserSelectAllForTarget = EditingStrategy::rootUserSelectAl lForNode(target); 266 Node* rootUserSelectAllForTarget = EditingStrategy::rootUserSelectAl lForNode(target);
267 if (rootUserSelectAllForTarget && mousePressNode->layoutObject() && Strategy::toPositionType(target->layoutObject()->positionForPoint(hitTestResult. localPoint()).position()).compareTo(Strategy::toPositionType(mousePressNode->lay outObject()->positionForPoint(dragStartPos).position())) < 0) 267 if (rootUserSelectAllForTarget && mousePressNode->layoutObject() && Strategy::toPositionType(target->layoutObject()->positionForPoint(hitTestResult. localPoint()).position()).compareTo(Strategy::toPositionType(mousePressNode->lay outObject()->positionForPoint(dragStartPos).position())) < 0)
268 newSelection.setExtent(PositionType::beforeNode(rootUserSelectAl lForTarget).upstream(CanCrossEditingBoundary)); 268 newSelection.setExtent(mostBackwardCaretPosition(PositionType::b eforeNode(rootUserSelectAllForTarget), CanCrossEditingBoundary));
269 else if (rootUserSelectAllForTarget && mousePressNode->layoutObject( )) 269 else if (rootUserSelectAllForTarget && mousePressNode->layoutObject( ))
270 newSelection.setExtent(PositionType::afterNode(rootUserSelectAll ForTarget).downstream(CanCrossEditingBoundary)); 270 newSelection.setExtent(mostForwardCaretPosition(PositionType::af terNode(rootUserSelectAllForTarget), CanCrossEditingBoundary));
271 else 271 else
272 newSelection.setExtent(targetPosition); 272 newSelection.setExtent(targetPosition);
273 } 273 }
274 } else { 274 } else {
275 newSelection.setExtent(targetPosition); 275 newSelection.setExtent(targetPosition);
276 } 276 }
277 277
278 if (selection().granularity() != CharacterGranularity) 278 if (selection().granularity() != CharacterGranularity)
279 expandSelectionUsingGranularity(newSelection, selection().granularity()) ; 279 expandSelectionUsingGranularity(newSelection, selection().granularity()) ;
280 280
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 else 650 else
651 m_selectionState = SelectionState::HaveNotStartedSelection; 651 m_selectionState = SelectionState::HaveNotStartedSelection;
652 } 652 }
653 653
654 FrameSelection& SelectionController::selection() const 654 FrameSelection& SelectionController::selection() const
655 { 655 {
656 return m_frame->selection(); 656 return m_frame->selection();
657 } 657 }
658 658
659 } // namespace blink 659 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/PositionTest.cpp ('k') | Source/core/editing/VisiblePosition.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698