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

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

Issue 1202153004: Enable selection for the composed tree (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename the flag 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/FrameSelection.cpp ('k') | Source/core/editing/VisibleSelection.h » ('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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 VisibleSelection newSelection(selection); 90 VisibleSelection newSelection(selection);
91 newSelection.setBase(PositionType::beforeNode(rootUserSelectAll).upstream(Ca nCrossEditingBoundary)); 91 newSelection.setBase(PositionType::beforeNode(rootUserSelectAll).upstream(Ca nCrossEditingBoundary));
92 newSelection.setExtent(PositionType::afterNode(rootUserSelectAll).downstream (CanCrossEditingBoundary)); 92 newSelection.setExtent(PositionType::afterNode(rootUserSelectAll).downstream (CanCrossEditingBoundary));
93 93
94 return newSelection; 94 return newSelection;
95 } 95 }
96 96
97 static VisibleSelection expandSelectionToRespectUserSelectAll(Node* targetNode, const VisibleSelection& selection) 97 static VisibleSelection expandSelectionToRespectUserSelectAll(Node* targetNode, const VisibleSelection& selection)
98 { 98 {
99 if (RuntimeEnabledFeatures::selectionForComposedTreeEnabled())
100 return expandSelectionToRespectUserSelectAllAlgorithm<VisibleSelection:: InComposedTree>(targetNode, selection);
99 return expandSelectionToRespectUserSelectAllAlgorithm<VisibleSelection::InDO MTree>(targetNode, selection); 101 return expandSelectionToRespectUserSelectAllAlgorithm<VisibleSelection::InDO MTree>(targetNode, selection);
100 } 102 }
101 103
102 static bool expandSelectionUsingGranularity(VisibleSelection& selection, TextGra nularity granularity) 104 static bool expandSelectionUsingGranularity(VisibleSelection& selection, TextGra nularity granularity)
103 { 105 {
106 if (RuntimeEnabledFeatures::selectionForComposedTreeEnabled())
107 return selection.expandUsingGranularityInComposedTree(granularity);
104 return selection.expandUsingGranularity(granularity); 108 return selection.expandUsingGranularity(granularity);
105 } 109 }
106 110
107 bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(Node * targetNode, const VisibleSelection& selection, TextGranularity granularity) 111 bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(Node * targetNode, const VisibleSelection& selection, TextGranularity granularity)
108 { 112 {
109 if (Position::nodeIsUserSelectNone(targetNode)) 113 if (Position::nodeIsUserSelectNone(targetNode))
110 return false; 114 return false;
111 115
112 if (!dispatchSelectStart(targetNode)) 116 if (!dispatchSelectStart(targetNode))
113 return false; 117 return false;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 248 }
245 249
246 template <typename PositionType> 250 template <typename PositionType>
247 static int textDistance(const PositionType& start, const PositionType& end) 251 static int textDistance(const PositionType& start, const PositionType& end)
248 { 252 {
249 return TextIteratorAlgorithm<typename PositionType::StrategyType>::rangeLeng th(start, end, true); 253 return TextIteratorAlgorithm<typename PositionType::StrategyType>::rangeLeng th(start, end, true);
250 } 254 }
251 255
252 bool SelectionController::handleMousePressEventSingleClick(const MouseEventWithH itTestResults& event) 256 bool SelectionController::handleMousePressEventSingleClick(const MouseEventWithH itTestResults& event)
253 { 257 {
258 if (RuntimeEnabledFeatures::selectionForComposedTreeEnabled())
259 return handleMousePressEventSingleClickAlgorithm<VisibleSelection::InCom posedTree>(event);
254 return handleMousePressEventSingleClickAlgorithm<VisibleSelection::InDOMTree >(event); 260 return handleMousePressEventSingleClickAlgorithm<VisibleSelection::InDOMTree >(event);
255 } 261 }
256 262
257 template <typename Strategy> 263 template <typename Strategy>
258 bool SelectionController::handleMousePressEventSingleClickAlgorithm(const MouseE ventWithHitTestResults& event) 264 bool SelectionController::handleMousePressEventSingleClickAlgorithm(const MouseE ventWithHitTestResults& event)
259 { 265 {
260 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventSingleClick "); 266 TRACE_EVENT0("blink", "SelectionController::handleMousePressEventSingleClick ");
261 using PositionType = typename Strategy::PositionType; 267 using PositionType = typename Strategy::PositionType;
262 268
263 m_frame->document()->updateLayoutIgnorePendingStylesheets(); 269 m_frame->document()->updateLayoutIgnorePendingStylesheets();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 return; 373 return;
368 374
369 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H itTestRequest::Move); 375 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H itTestRequest::Move);
370 HitTestResult result(request, view->rootFrameToContents(lastKnownMousePositi on)); 376 HitTestResult result(request, view->rootFrameToContents(lastKnownMousePositi on));
371 layoutObject->hitTest(result); 377 layoutObject->hitTest(result);
372 updateSelectionForMouseDrag(result, mousePressNode, dragStartPos, lastKnownM ousePosition); 378 updateSelectionForMouseDrag(result, mousePressNode, dragStartPos, lastKnownM ousePosition);
373 } 379 }
374 380
375 void SelectionController::updateSelectionForMouseDrag(const HitTestResult& hitTe stResult, Node* mousePressNode, const LayoutPoint& dragStartPos, const IntPoint& lastKnownMousePosition) 381 void SelectionController::updateSelectionForMouseDrag(const HitTestResult& hitTe stResult, Node* mousePressNode, const LayoutPoint& dragStartPos, const IntPoint& lastKnownMousePosition)
376 { 382 {
383 if (RuntimeEnabledFeatures::selectionForComposedTreeEnabled())
384 return updateSelectionForMouseDragAlgorithm<VisibleSelection::InComposed Tree>(hitTestResult, mousePressNode, dragStartPos, lastKnownMousePosition);
377 updateSelectionForMouseDragAlgorithm<VisibleSelection::InDOMTree>(hitTestRes ult, mousePressNode, dragStartPos, lastKnownMousePosition); 385 updateSelectionForMouseDragAlgorithm<VisibleSelection::InDOMTree>(hitTestRes ult, mousePressNode, dragStartPos, lastKnownMousePosition);
378 } 386 }
379 387
380 template <typename Strategy> 388 template <typename Strategy>
381 void SelectionController::updateSelectionForMouseDragAlgorithm(const HitTestResu lt& hitTestResult, Node* mousePressNode, const LayoutPoint& dragStartPos, const IntPoint& lastKnownMousePosition) 389 void SelectionController::updateSelectionForMouseDragAlgorithm(const HitTestResu lt& hitTestResult, Node* mousePressNode, const LayoutPoint& dragStartPos, const IntPoint& lastKnownMousePosition)
382 { 390 {
383 using PositionType = typename Strategy::PositionType; 391 using PositionType = typename Strategy::PositionType;
384 392
385 if (!m_mouseDownMayStartSelect) 393 if (!m_mouseDownMayStartSelect)
386 return; 394 return;
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 { 599 {
592 return m_mouseDownMayStartSelect; 600 return m_mouseDownMayStartSelect;
593 } 601 }
594 602
595 bool SelectionController::mouseDownWasSingleClickInSelection() const 603 bool SelectionController::mouseDownWasSingleClickInSelection() const
596 { 604 {
597 return m_mouseDownWasSingleClickInSelection; 605 return m_mouseDownWasSingleClickInSelection;
598 } 606 }
599 607
600 } // namespace blink 608 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/editing/FrameSelection.cpp ('k') | Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698