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

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

Issue 1049233003: Keep the selection of the text field when changed by JS. (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
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 newSelection = VisibleSelection(start, pos); 186 newSelection = VisibleSelection(start, pos);
187 } 187 }
188 } else { 188 } else {
189 newSelection.setExtent(pos); 189 newSelection.setExtent(pos);
190 } 190 }
191 191
192 if (selection().granularity() != CharacterGranularity) { 192 if (selection().granularity() != CharacterGranularity) {
193 granularity = selection().granularity(); 193 granularity = selection().granularity();
194 expandSelectionUsingGranularity(newSelection, selection().granularit y()); 194 expandSelectionUsingGranularity(newSelection, selection().granularit y());
195 } 195 }
196 } else { 196 } else if (m_selectionState != SelectionState::ExtendedSelection) {
197 newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleS election(visiblePos)); 197 newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleS election(visiblePos));
198 } 198 }
199 199
200 // Updating the selection is considered side-effect of the event and so it d oesn't impact the handled state. 200 // Updating the selection is considered side-effect of the event and so it d oesn't impact the handled state.
201 updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, g ranularity); 201 updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection, g ranularity);
202 return false; 202 return false;
203 } 203 }
204 204
205 template <typename Strategy> 205 template <typename Strategy>
206 void SelectionController::updateSelectionForMouseDragAlgorithm(const HitTestResu lt& hitTestResult, Node* mousePressNode, const LayoutPoint& dragStartPos, const IntPoint& lastKnownMousePosition) 206 void SelectionController::updateSelectionForMouseDragAlgorithm(const HitTestResu lt& hitTestResult, Node* mousePressNode, const LayoutPoint& dragStartPos, const IntPoint& lastKnownMousePosition)
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 bool SelectionController::mouseDownMayStartSelect() const 611 bool SelectionController::mouseDownMayStartSelect() const
612 { 612 {
613 return m_mouseDownMayStartSelect; 613 return m_mouseDownMayStartSelect;
614 } 614 }
615 615
616 bool SelectionController::mouseDownWasSingleClickInSelection() const 616 bool SelectionController::mouseDownWasSingleClickInSelection() const
617 { 617 {
618 return m_mouseDownWasSingleClickInSelection; 618 return m_mouseDownWasSingleClickInSelection;
619 } 619 }
620 620
621 void SelectionController::notifySelectionChanged()
622 {
yosin_UTC9 2015/07/06 01:57:30 It is better to have a function which maps |Select
Miyoung Shin(g) 2015/07/13 03:32:57 Done.
623 if (selection().isRange())
624 m_selectionState = SelectionState::ExtendedSelection;
625 else if (selection().isCaret())
626 m_selectionState = SelectionState::PlacedCaret;
627 else
628 m_selectionState = SelectionState::HaveNotStartedSelection;
629 }
630
621 FrameSelection& SelectionController::selection() const 631 FrameSelection& SelectionController::selection() const
622 { 632 {
623 return m_frame->selection(); 633 return m_frame->selection();
624 } 634 }
625 635
626 } // namespace blink 636 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698