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

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

Issue 1190283002: Make textDistance() in SelectionController not to create a redundant Range object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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) 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (pos.isNotNull()) { 233 if (pos.isNotNull()) {
234 newSelection = VisibleSelection(pos); 234 newSelection = VisibleSelection(pos);
235 newSelection.expandUsingGranularity(ParagraphGranularity); 235 newSelection.expandUsingGranularity(ParagraphGranularity);
236 } 236 }
237 237
238 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity); 238 return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSe lectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity);
239 } 239 }
240 240
241 static int textDistance(const Position& start, const Position& end) 241 static int textDistance(const Position& start, const Position& end)
242 { 242 {
243 RefPtrWillBeRawPtr<Range> range = Range::create(*start.document(), start, en d); 243 return TextIterator::rangeLength(start, end, true);
244 return TextIterator::rangeLength(range->startPosition(), range->endPosition( ), true);
245 } 244 }
246 245
247 bool SelectionController::handleMousePressEventSingleClick(const MouseEventWithH itTestResults& event) 246 bool SelectionController::handleMousePressEventSingleClick(const MouseEventWithH itTestResults& event)
248 { 247 {
249 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventSingleClick "); 248 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventSingleClick ");
250 249
251 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 250 m_frame->document()->updateLayoutIgnorePendingStylesheets();
252 Node* innerNode = event.innerNode(); 251 Node* innerNode = event.innerNode();
253 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect)) 252 if (!(innerNode && innerNode->layoutObject() && m_mouseDownMayStartSelect))
254 return false; 253 return false;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 { 564 {
566 return m_mouseDownMayStartSelect; 565 return m_mouseDownMayStartSelect;
567 } 566 }
568 567
569 bool SelectionController::mouseDownWasSingleClickInSelection() const 568 bool SelectionController::mouseDownWasSingleClickInSelection() const
570 { 569 {
571 return m_mouseDownWasSingleClickInSelection; 570 return m_mouseDownWasSingleClickInSelection;
572 } 571 }
573 572
574 } // namespace blink 573 } // namespace blink
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