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

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

Issue 2972863003: Introduce CreateVisibleSelectionWithGranularity() (Closed)
Patch Set: 2017-07-06T16:26:15 Created 3 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 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 // and isn't desirable for touch). 528 // and isn't desirable for touch).
529 HitTestResult adjusted_hit_test_result = result; 529 HitTestResult adjusted_hit_test_result = result;
530 if (select_input_event_type == SelectInputEventType::kTouch && 530 if (select_input_event_type == SelectInputEventType::kTouch &&
531 result.GetImage()) 531 result.GetImage())
532 adjusted_hit_test_result.SetNodeAndPosition(result.InnerNode(), 532 adjusted_hit_test_result.SetNodeAndPosition(result.InnerNode(),
533 LayoutPoint(0, 0)); 533 LayoutPoint(0, 0));
534 534
535 const VisiblePositionInFlatTree& pos = 535 const VisiblePositionInFlatTree& pos =
536 VisiblePositionOfHitTestResult(adjusted_hit_test_result); 536 VisiblePositionOfHitTestResult(adjusted_hit_test_result);
537 const VisibleSelectionInFlatTree& new_selection = 537 const VisibleSelectionInFlatTree& new_selection =
538 pos.IsNotNull() 538 pos.IsNotNull() ? CreateVisibleSelectionWithGranularity(
539 ? CreateVisibleSelection(SelectionInFlatTree::Builder() 539 SelectionInFlatTree::Builder()
540 .Collapse(pos.ToPositionWithAffinity()) 540 .Collapse(pos.ToPositionWithAffinity())
541 .SetGranularity(kWordGranularity) 541 .Build(),
542 .Build()) 542 kWordGranularity)
543 : VisibleSelectionInFlatTree(); 543 : VisibleSelectionInFlatTree();
544 544
545 HandleVisibility visibility = HandleVisibility::kNotVisible; 545 HandleVisibility visibility = HandleVisibility::kNotVisible;
546 if (select_input_event_type == SelectInputEventType::kTouch) { 546 if (select_input_event_type == SelectInputEventType::kTouch) {
547 // If node doesn't have text except space, tab or line break, do not 547 // If node doesn't have text except space, tab or line break, do not
548 // select that 'empty' area. 548 // select that 'empty' area.
549 EphemeralRangeInFlatTree range(new_selection.Start(), new_selection.End()); 549 EphemeralRangeInFlatTree range(new_selection.Start(), new_selection.End());
550 const String& str = PlainText( 550 const String& str = PlainText(
551 range, 551 range,
552 TextIteratorBehavior::Builder() 552 TextIteratorBehavior::Builder()
553 .SetEmitsObjectReplacementCharacter(HasEditableStyle(*inner_node)) 553 .SetEmitsObjectReplacementCharacter(HasEditableStyle(*inner_node))
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 return false; 896 return false;
897 897
898 Node* const inner_node = event.InnerNode(); 898 Node* const inner_node = event.InnerNode();
899 if (!(inner_node && inner_node->GetLayoutObject() && 899 if (!(inner_node && inner_node->GetLayoutObject() &&
900 mouse_down_may_start_select_)) 900 mouse_down_may_start_select_))
901 return false; 901 return false;
902 902
903 const VisiblePositionInFlatTree& pos = 903 const VisiblePositionInFlatTree& pos =
904 VisiblePositionOfHitTestResult(event.GetHitTestResult()); 904 VisiblePositionOfHitTestResult(event.GetHitTestResult());
905 const VisibleSelectionInFlatTree new_selection = 905 const VisibleSelectionInFlatTree new_selection =
906 pos.IsNotNull() 906 pos.IsNotNull() ? CreateVisibleSelectionWithGranularity(
907 ? CreateVisibleSelection(SelectionInFlatTree::Builder() 907 SelectionInFlatTree::Builder()
908 .Collapse(pos.ToPositionWithAffinity()) 908 .Collapse(pos.ToPositionWithAffinity())
909 .SetGranularity(kParagraphGranularity) 909 .Build(),
910 .Build()) 910 kParagraphGranularity)
911 : VisibleSelectionInFlatTree(); 911 : VisibleSelectionInFlatTree();
912 912
913 const bool is_handle_visible = 913 const bool is_handle_visible =
914 event.Event().FromTouch() && new_selection.IsRange(); 914 event.Event().FromTouch() && new_selection.IsRange();
915 915
916 const bool did_select = UpdateSelectionForMouseDownDispatchingSelectStart( 916 const bool did_select = UpdateSelectionForMouseDownDispatchingSelectStart(
917 inner_node, 917 inner_node,
918 ExpandSelectionToRespectUserSelectAll(inner_node, new_selection), 918 ExpandSelectionToRespectUserSelectAll(inner_node, new_selection),
919 kParagraphGranularity, 919 kParagraphGranularity,
920 is_handle_visible ? HandleVisibility::kVisible 920 is_handle_visible ? HandleVisibility::kVisible
921 : HandleVisibility::kNotVisible); 921 : HandleVisibility::kNotVisible);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 1252
1253 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { 1253 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) {
1254 bool is_mouse_down_on_link_or_image = 1254 bool is_mouse_down_on_link_or_image =
1255 event.IsOverLink() || event.GetHitTestResult().GetImage(); 1255 event.IsOverLink() || event.GetHitTestResult().GetImage();
1256 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != 1256 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) !=
1257 0 && 1257 0 &&
1258 !is_mouse_down_on_link_or_image; 1258 !is_mouse_down_on_link_or_image;
1259 } 1259 }
1260 1260
1261 } // namespace blink 1261 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/FrameSelection.cpp ('k') | third_party/WebKit/Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698