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

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

Issue 2950053002: Make Position::BeforeNode() to take const Node& instead of Node* (Closed)
Patch Set: 2017-06-21T17:56:36 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 Node* target_node, 82 Node* target_node,
83 const VisibleSelectionInFlatTree& selection) { 83 const VisibleSelectionInFlatTree& selection) {
84 Node* const root_user_select_all = 84 Node* const root_user_select_all =
85 EditingInFlatTreeStrategy::RootUserSelectAllForNode(target_node); 85 EditingInFlatTreeStrategy::RootUserSelectAllForNode(target_node);
86 if (!root_user_select_all) 86 if (!root_user_select_all)
87 return selection; 87 return selection;
88 88
89 return CreateVisibleSelection( 89 return CreateVisibleSelection(
90 SelectionInFlatTree::Builder(selection.AsSelection()) 90 SelectionInFlatTree::Builder(selection.AsSelection())
91 .Collapse(MostBackwardCaretPosition( 91 .Collapse(MostBackwardCaretPosition(
92 PositionInFlatTree::BeforeNode(root_user_select_all), 92 PositionInFlatTree::BeforeNode(*root_user_select_all),
93 kCanCrossEditingBoundary)) 93 kCanCrossEditingBoundary))
94 .Extend(MostForwardCaretPosition( 94 .Extend(MostForwardCaretPosition(
95 PositionInFlatTree::AfterNode(root_user_select_all), 95 PositionInFlatTree::AfterNode(root_user_select_all),
96 kCanCrossEditingBoundary)) 96 kCanCrossEditingBoundary))
97 .Build()); 97 .Build());
98 } 98 }
99 99
100 static int TextDistance(const PositionInFlatTree& start, 100 static int TextDistance(const PositionInFlatTree& start,
101 const PositionInFlatTree& end) { 101 const PositionInFlatTree& end) {
102 return TextIteratorInFlatTree::RangeLength( 102 return TextIteratorInFlatTree::RangeLength(
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 Node* const root_user_select_all_for_mouse_press_node = 309 Node* const root_user_select_all_for_mouse_press_node =
310 EditingInFlatTreeStrategy::RootUserSelectAllForNode(mouse_press_node); 310 EditingInFlatTreeStrategy::RootUserSelectAllForNode(mouse_press_node);
311 Node* const root_user_select_all_for_target = 311 Node* const root_user_select_all_for_target =
312 EditingInFlatTreeStrategy::RootUserSelectAllForNode(target); 312 EditingInFlatTreeStrategy::RootUserSelectAllForNode(target);
313 313
314 if (root_user_select_all_for_mouse_press_node && 314 if (root_user_select_all_for_mouse_press_node &&
315 root_user_select_all_for_mouse_press_node == 315 root_user_select_all_for_mouse_press_node ==
316 root_user_select_all_for_target) { 316 root_user_select_all_for_target) {
317 return SelectionInFlatTree::Builder() 317 return SelectionInFlatTree::Builder()
318 .SetBaseAndExtent(PositionInFlatTree::BeforeNode( 318 .SetBaseAndExtent(PositionInFlatTree::BeforeNode(
319 root_user_select_all_for_mouse_press_node), 319 *root_user_select_all_for_mouse_press_node),
320 PositionInFlatTree::AfterNode( 320 PositionInFlatTree::AfterNode(
321 root_user_select_all_for_mouse_press_node)) 321 root_user_select_all_for_mouse_press_node))
322 .Build(); 322 .Build();
323 } 323 }
324 324
325 SelectionInFlatTree::Builder builder; 325 SelectionInFlatTree::Builder builder;
326 // Reset base for user select all when base is inside user-select-all area 326 // Reset base for user select all when base is inside user-select-all area
327 // and extent < base. 327 // and extent < base.
328 if (root_user_select_all_for_mouse_press_node && 328 if (root_user_select_all_for_mouse_press_node &&
329 TargetPositionIsBeforeDragStartPosition( 329 TargetPositionIsBeforeDragStartPosition(
330 mouse_press_node, drag_start_point, target, hit_test_point)) { 330 mouse_press_node, drag_start_point, target, hit_test_point)) {
331 builder.Collapse(PositionInFlatTree::AfterNode( 331 builder.Collapse(PositionInFlatTree::AfterNode(
332 root_user_select_all_for_mouse_press_node)); 332 root_user_select_all_for_mouse_press_node));
333 } else { 333 } else {
334 builder.Collapse(base_position); 334 builder.Collapse(base_position);
335 } 335 }
336 336
337 if (root_user_select_all_for_target && mouse_press_node->GetLayoutObject()) { 337 if (root_user_select_all_for_target && mouse_press_node->GetLayoutObject()) {
338 if (TargetPositionIsBeforeDragStartPosition( 338 if (TargetPositionIsBeforeDragStartPosition(
339 mouse_press_node, drag_start_point, target, hit_test_point)) { 339 mouse_press_node, drag_start_point, target, hit_test_point)) {
340 builder.Extend( 340 builder.Extend(
341 PositionInFlatTree::BeforeNode(root_user_select_all_for_target)); 341 PositionInFlatTree::BeforeNode(*root_user_select_all_for_target));
342 return builder.Build(); 342 return builder.Build();
343 } 343 }
344 344
345 builder.Extend( 345 builder.Extend(
346 PositionInFlatTree::AfterNode(root_user_select_all_for_target)); 346 PositionInFlatTree::AfterNode(root_user_select_all_for_target));
347 return builder.Build(); 347 return builder.Build();
348 } 348 }
349 349
350 builder.Extend(target_position); 350 builder.Extend(target_position);
351 return builder.Build(); 351 return builder.Build();
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 1188
1189 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { 1189 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) {
1190 bool is_mouse_down_on_link_or_image = 1190 bool is_mouse_down_on_link_or_image =
1191 event.IsOverLink() || event.GetHitTestResult().GetImage(); 1191 event.IsOverLink() || event.GetHitTestResult().GetImage();
1192 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != 1192 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) !=
1193 0 && 1193 0 &&
1194 !is_mouse_down_on_link_or_image; 1194 !is_mouse_down_on_link_or_image;
1195 } 1195 }
1196 1196
1197 } // namespace blink 1197 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698