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

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

Issue 1245843003: [CodeHealth] Use Position::anchorNode instead of deprecatedNode. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 | « Source/core/editing/ReplaceSelectionCommand.cpp ('k') | Source/core/editing/SpellChecker.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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // Don't modify the selection if we're not on a node. 219 // Don't modify the selection if we're not on a node.
220 if (targetPosition.isNull()) 220 if (targetPosition.isNull())
221 return; 221 return;
222 222
223 // Restart the selection if this is the first mouse move. This work is usual ly 223 // Restart the selection if this is the first mouse move. This work is usual ly
224 // done in handleMousePressEvent, but not if the mouse press was on an exist ing selection. 224 // done in handleMousePressEvent, but not if the mouse press was on an exist ing selection.
225 VisibleSelection newSelection = selection().selection(); 225 VisibleSelection newSelection = selection().selection();
226 226
227 // Special case to limit selection to the containing block for SVG text. 227 // Special case to limit selection to the containing block for SVG text.
228 // FIXME: Isn't there a better non-SVG-specific way to do this? 228 // FIXME: Isn't there a better non-SVG-specific way to do this?
229 if (Node* selectionBaseNode = Strategy::selectionBase(newSelection).deprecat edNode()) { 229 if (Node* selectionBaseNode = Strategy::selectionBase(newSelection).anchorNo de()) {
230 if (LayoutObject* selectionBaseLayoutObject = selectionBaseNode->layoutO bject()) { 230 if (LayoutObject* selectionBaseLayoutObject = selectionBaseNode->layoutO bject()) {
231 if (selectionBaseLayoutObject->isSVGText()) { 231 if (selectionBaseLayoutObject->isSVGText()) {
232 if (target->layoutObject()->containingBlock() != selectionBaseLa youtObject->containingBlock()) 232 if (target->layoutObject()->containingBlock() != selectionBaseLa youtObject->containingBlock())
233 return; 233 return;
234 } 234 }
235 } 235 }
236 } 236 }
237 237
238 if (m_selectionState == SelectionState::HaveNotStartedSelection && !dispatch SelectStart(target)) 238 if (m_selectionState == SelectionState::HaveNotStartedSelection && !dispatch SelectStart(target))
239 return; 239 return;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 return selectClosestWordFromMouseEvent(result); 368 return selectClosestWordFromMouseEvent(result);
369 369
370 Node* innerNode = result.innerNode(); 370 Node* innerNode = result.innerNode();
371 371
372 if (!innerNode || !innerNode->layoutObject() || !m_mouseDownMayStartSelect) 372 if (!innerNode || !innerNode->layoutObject() || !m_mouseDownMayStartSelect)
373 return; 373 return;
374 374
375 VisibleSelection newSelection; 375 VisibleSelection newSelection;
376 Element* URLElement = result.hitTestResult().URLElement(); 376 Element* URLElement = result.hitTestResult().URLElement();
377 VisiblePosition pos(innerNode->layoutObject()->positionForPoint(result.local Point())); 377 VisiblePosition pos(innerNode->layoutObject()->positionForPoint(result.local Point()));
378 if (pos.isNotNull() && pos.deepEquivalent().deprecatedNode()->isDescendantOf (URLElement)) 378 if (pos.isNotNull() && pos.deepEquivalent().anchorNode()->isDescendantOf(URL Element))
379 newSelection = VisibleSelection::selectionFromContentsOfNode(URLElement) ; 379 newSelection = VisibleSelection::selectionFromContentsOfNode(URLElement) ;
380 380
381 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelection ToRespectUserSelectAll(innerNode, newSelection), WordGranularity); 381 updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelection ToRespectUserSelectAll(innerNode, newSelection), WordGranularity);
382 } 382 }
383 383
384 bool SelectionController::handleMousePressEventDoubleClick(const MouseEventWithH itTestResults& event) 384 bool SelectionController::handleMousePressEventDoubleClick(const MouseEventWithH itTestResults& event)
385 { 385 {
386 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventDoubleClick "); 386 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventDoubleClick ");
387 387
388 if (event.event().button() != LeftButton) 388 if (event.event().button() != LeftButton)
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 else 627 else
628 m_selectionState = SelectionState::HaveNotStartedSelection; 628 m_selectionState = SelectionState::HaveNotStartedSelection;
629 } 629 }
630 630
631 FrameSelection& SelectionController::selection() const 631 FrameSelection& SelectionController::selection() const
632 { 632 {
633 return m_frame->selection(); 633 return m_frame->selection();
634 } 634 }
635 635
636 } // namespace blink 636 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/ReplaceSelectionCommand.cpp ('k') | Source/core/editing/SpellChecker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698