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

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

Issue 2920733002: Rename VisibleSelection::end() to End() (Closed)
Patch Set: 2017-06-01T18:31:38 Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 5 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
6 * Copyright (C) 2015 Google Inc. All rights reserved. 6 * Copyright (C) 2015 Google Inc. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 ExpandSelectionToRespectUserSelectAll( 141 ExpandSelectionToRespectUserSelectAll(
142 inner_node, 142 inner_node,
143 position.IsNull() 143 position.IsNull()
144 ? VisibleSelectionInFlatTree() 144 ? VisibleSelectionInFlatTree()
145 : CreateVisibleSelection( 145 : CreateVisibleSelection(
146 SelectionInFlatTree::Builder().Collapse(position).Build())); 146 SelectionInFlatTree::Builder().Collapse(position).Build()));
147 if (!selection_in_user_select_all.IsRange()) 147 if (!selection_in_user_select_all.IsRange())
148 return position; 148 return position;
149 if (selection_in_user_select_all.Start().CompareTo(selection_start) < 0) 149 if (selection_in_user_select_all.Start().CompareTo(selection_start) < 0)
150 return selection_in_user_select_all.Start(); 150 return selection_in_user_select_all.Start();
151 if (selection_end.CompareTo(selection_in_user_select_all.end()) < 0) 151 if (selection_end.CompareTo(selection_in_user_select_all.End()) < 0)
152 return selection_in_user_select_all.end(); 152 return selection_in_user_select_all.End();
153 return position; 153 return position;
154 } 154 }
155 155
156 // Updating the selection is considered side-effect of the event and so it 156 // Updating the selection is considered side-effect of the event and so it
157 // doesn't impact the handled state. 157 // doesn't impact the handled state.
158 bool SelectionController::HandleSingleClick( 158 bool SelectionController::HandleSingleClick(
159 const MouseEventWithHitTestResults& event) { 159 const MouseEventWithHitTestResults& event) {
160 TRACE_EVENT0("blink", 160 TRACE_EVENT0("blink",
161 "SelectionController::handleMousePressEventSingleClick"); 161 "SelectionController::handleMousePressEventSingleClick");
162 162
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 HandleVisibility::kVisible); 196 HandleVisibility::kVisible);
197 return false; 197 return false;
198 } 198 }
199 } 199 }
200 } 200 }
201 201
202 if (extend_selection && !selection.IsNone()) { 202 if (extend_selection && !selection.IsNone()) {
203 // Note: "fast/events/shift-click-user-select-none.html" makes 203 // Note: "fast/events/shift-click-user-select-none.html" makes
204 // |pos.isNull()| true. 204 // |pos.isNull()| true.
205 const PositionInFlatTree& pos = AdjustPositionRespectUserSelectAll( 205 const PositionInFlatTree& pos = AdjustPositionRespectUserSelectAll(
206 inner_node, selection.Start(), selection.end(), 206 inner_node, selection.Start(), selection.End(),
207 visible_pos.DeepEquivalent()); 207 visible_pos.DeepEquivalent());
208 SelectionInFlatTree::Builder builder; 208 SelectionInFlatTree::Builder builder;
209 builder.SetGranularity(this->Selection().Granularity()); 209 builder.SetGranularity(this->Selection().Granularity());
210 if (frame_->GetEditor().Behavior().ShouldConsiderSelectionAsDirectional()) { 210 if (frame_->GetEditor().Behavior().ShouldConsiderSelectionAsDirectional()) {
211 builder.SetBaseAndExtent(selection.Base(), pos); 211 builder.SetBaseAndExtent(selection.Base(), pos);
212 } else if (pos.IsNull()) { 212 } else if (pos.IsNull()) {
213 builder.SetBaseAndExtent(selection.Base(), selection.Extent()); 213 builder.SetBaseAndExtent(selection.Base(), selection.Extent());
214 } else { 214 } else {
215 // Shift+Click deselects when selection was created right-to-left 215 // Shift+Click deselects when selection was created right-to-left
216 const PositionInFlatTree& start = selection.Start(); 216 const PositionInFlatTree& start = selection.Start();
217 const PositionInFlatTree& end = selection.end(); 217 const PositionInFlatTree& end = selection.End();
218 if (pos < start) { 218 if (pos < start) {
219 // |distance_to_start < distance_to_end|. 219 // |distance_to_start < distance_to_end|.
220 builder.SetBaseAndExtent(end, pos); 220 builder.SetBaseAndExtent(end, pos);
221 } else if (end < pos) { 221 } else if (end < pos) {
222 // |distance_to_start > distance_to_end|. 222 // |distance_to_start > distance_to_end|.
223 builder.SetBaseAndExtent(start, pos); 223 builder.SetBaseAndExtent(start, pos);
224 } else { 224 } else {
225 const int distance_to_start = TextDistance(start, pos); 225 const int distance_to_start = TextDistance(start, pos);
226 const int distance_to_end = TextDistance(pos, end); 226 const int distance_to_end = TextDistance(pos, end);
227 builder.SetBaseAndExtent( 227 builder.SetBaseAndExtent(
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 CreateVisibleSelection(SelectionInFlatTree::Builder() 482 CreateVisibleSelection(SelectionInFlatTree::Builder()
483 .Collapse(pos.ToPositionWithAffinity()) 483 .Collapse(pos.ToPositionWithAffinity())
484 .SetGranularity(kWordGranularity) 484 .SetGranularity(kWordGranularity)
485 .Build()); 485 .Build());
486 } 486 }
487 487
488 HandleVisibility visibility = HandleVisibility::kNotVisible; 488 HandleVisibility visibility = HandleVisibility::kNotVisible;
489 if (select_input_event_type == SelectInputEventType::kTouch) { 489 if (select_input_event_type == SelectInputEventType::kTouch) {
490 // If node doesn't have text except space, tab or line break, do not 490 // If node doesn't have text except space, tab or line break, do not
491 // select that 'empty' area. 491 // select that 'empty' area.
492 EphemeralRangeInFlatTree range(new_selection.Start(), new_selection.end()); 492 EphemeralRangeInFlatTree range(new_selection.Start(), new_selection.End());
493 const String& str = PlainText( 493 const String& str = PlainText(
494 range, 494 range,
495 TextIteratorBehavior::Builder() 495 TextIteratorBehavior::Builder()
496 .SetEmitsObjectReplacementCharacter(HasEditableStyle(*inner_node)) 496 .SetEmitsObjectReplacementCharacter(HasEditableStyle(*inner_node))
497 .Build()); 497 .Build());
498 if (str.IsEmpty() || str.SimplifyWhiteSpace().ContainsOnlyWhitespace()) 498 if (str.IsEmpty() || str.SimplifyWhiteSpace().ContainsOnlyWhitespace())
499 return false; 499 return false;
500 500
501 if (new_selection.RootEditableElement() && 501 if (new_selection.RootEditableElement() &&
502 pos.DeepEquivalent() == VisiblePositionInFlatTree::LastPositionInNode( 502 pos.DeepEquivalent() == VisiblePositionInFlatTree::LastPositionInNode(
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 1142
1143 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { 1143 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) {
1144 bool is_mouse_down_on_link_or_image = 1144 bool is_mouse_down_on_link_or_image =
1145 event.IsOverLink() || event.GetHitTestResult().GetImage(); 1145 event.IsOverLink() || event.GetHitTestResult().GetImage();
1146 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != 1146 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) !=
1147 0 && 1147 0 &&
1148 !is_mouse_down_on_link_or_image; 1148 !is_mouse_down_on_link_or_image;
1149 } 1149 }
1150 1150
1151 } // namespace blink 1151 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698