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

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

Issue 2971563002: Use PositionInFlatTreeWithAffinty for SelectionController::original_base_in_flat_tree_ (Closed)
Patch Set: 2017-07-03T16:48:36 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/SelectionController.h ('k') | no next file » | 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 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } // namespace 133 } // namespace
134 134
135 SelectionController::~SelectionController() = default; 135 SelectionController::~SelectionController() = default;
136 136
137 Document& SelectionController::GetDocument() const { 137 Document& SelectionController::GetDocument() const {
138 DCHECK(frame_->GetDocument()); 138 DCHECK(frame_->GetDocument());
139 return *frame_->GetDocument(); 139 return *frame_->GetDocument();
140 } 140 }
141 141
142 void SelectionController::ContextDestroyed(Document*) { 142 void SelectionController::ContextDestroyed(Document*) {
143 original_base_in_flat_tree_ = VisiblePositionInFlatTree(); 143 original_base_in_flat_tree_ = PositionInFlatTreeWithAffinity();
144 } 144 }
145 145
146 static PositionInFlatTree AdjustPositionRespectUserSelectAll( 146 static PositionInFlatTree AdjustPositionRespectUserSelectAll(
147 Node* inner_node, 147 Node* inner_node,
148 const PositionInFlatTree& selection_start, 148 const PositionInFlatTree& selection_start,
149 const PositionInFlatTree& selection_end, 149 const PositionInFlatTree& selection_end,
150 const PositionInFlatTree& position) { 150 const PositionInFlatTree& position) {
151 const VisibleSelectionInFlatTree& selection_in_user_select_all = 151 const VisibleSelectionInFlatTree& selection_in_user_select_all =
152 CreateVisibleSelection(ExpandSelectionToRespectUserSelectAll( 152 CreateVisibleSelection(ExpandSelectionToRespectUserSelectAll(
153 inner_node, position.IsNull() ? VisibleSelectionInFlatTree() 153 inner_node, position.IsNull() ? VisibleSelectionInFlatTree()
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 const SelectionInFlatTree& passed_selection, 722 const SelectionInFlatTree& passed_selection,
723 TextGranularity granularity, 723 TextGranularity granularity,
724 EndPointsAdjustmentMode endpoints_adjustment_mode, 724 EndPointsAdjustmentMode endpoints_adjustment_mode,
725 HandleVisibility handle_visibility) { 725 HandleVisibility handle_visibility) {
726 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets 726 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets
727 // needs to be audited. See http://crbug.com/590369 for more details. 727 // needs to be audited. See http://crbug.com/590369 for more details.
728 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); 728 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets();
729 729
730 const VisibleSelectionInFlatTree& new_selection = 730 const VisibleSelectionInFlatTree& new_selection =
731 CreateVisibleSelection(passed_selection); 731 CreateVisibleSelection(passed_selection);
732 // TODO(editing-dev): We should use |PositionWithAffinity| to pass affinity
733 // to |CreateVisiblePosition()| for |original_base|.
732 const PositionInFlatTree& base_position = 734 const PositionInFlatTree& base_position =
733 original_base_in_flat_tree_.DeepEquivalent(); 735 original_base_in_flat_tree_.GetPosition();
734 const VisiblePositionInFlatTree& original_base = 736 const VisiblePositionInFlatTree& original_base =
735 base_position.IsConnected() ? CreateVisiblePosition(base_position) 737 base_position.IsConnected() ? CreateVisiblePosition(base_position)
736 : VisiblePositionInFlatTree(); 738 : VisiblePositionInFlatTree();
737 const VisiblePositionInFlatTree& base = 739 const VisiblePositionInFlatTree& base =
738 original_base.IsNotNull() ? original_base 740 original_base.IsNotNull() ? original_base
739 : CreateVisiblePosition(new_selection.Base()); 741 : CreateVisiblePosition(new_selection.Base());
740 const VisiblePositionInFlatTree& extent = 742 const VisiblePositionInFlatTree& extent =
741 CreateVisiblePosition(new_selection.Extent()); 743 CreateVisiblePosition(new_selection.Extent());
742 const SelectionInFlatTree& adjusted_selection = 744 const SelectionInFlatTree& adjusted_selection =
743 endpoints_adjustment_mode == kAdjustEndpointsAtBidiBoundary 745 endpoints_adjustment_mode == kAdjustEndpointsAtBidiBoundary
744 ? AdjustEndpointsAtBidiBoundary(base, extent) 746 ? AdjustEndpointsAtBidiBoundary(base, extent)
745 : SelectionInFlatTree::Builder() 747 : SelectionInFlatTree::Builder()
746 .SetBaseAndExtent(base.DeepEquivalent(), 748 .SetBaseAndExtent(base.DeepEquivalent(),
747 extent.DeepEquivalent()) 749 extent.DeepEquivalent())
748 .Build(); 750 .Build();
749 751
750 SelectionInFlatTree::Builder builder(new_selection.AsSelection()); 752 SelectionInFlatTree::Builder builder(new_selection.AsSelection());
751 if (adjusted_selection.Base() != base.DeepEquivalent() || 753 if (adjusted_selection.Base() != base.DeepEquivalent() ||
752 adjusted_selection.Extent() != extent.DeepEquivalent()) { 754 adjusted_selection.Extent() != extent.DeepEquivalent()) {
753 original_base_in_flat_tree_ = base; 755 original_base_in_flat_tree_ = base.ToPositionWithAffinity();
754 SetContext(&GetDocument()); 756 SetContext(&GetDocument());
755 builder.SetBaseAndExtent(adjusted_selection.Base(), 757 builder.SetBaseAndExtent(adjusted_selection.Base(),
756 adjusted_selection.Extent()); 758 adjusted_selection.Extent());
757 } else if (original_base.IsNotNull()) { 759 } else if (original_base.IsNotNull()) {
758 if (Selection().ComputeVisibleSelectionInFlatTree().Base() == 760 if (Selection().ComputeVisibleSelectionInFlatTree().Base() ==
759 new_selection.Base()) { 761 new_selection.Base()) {
760 builder.SetBaseAndExtent(original_base.DeepEquivalent(), 762 builder.SetBaseAndExtent(original_base.DeepEquivalent(),
761 new_selection.Extent()); 763 new_selection.Extent());
762 } 764 }
763 original_base_in_flat_tree_ = VisiblePositionInFlatTree(); 765 original_base_in_flat_tree_ = PositionInFlatTreeWithAffinity();
764 } 766 }
765 767
766 builder.SetIsHandleVisible(handle_visibility == HandleVisibility::kVisible) 768 builder.SetIsHandleVisible(handle_visibility == HandleVisibility::kVisible)
767 .SetIsDirectional(frame_->GetEditor() 769 .SetIsDirectional(frame_->GetEditor()
768 .Behavior() 770 .Behavior()
769 .ShouldConsiderSelectionAsDirectional() || 771 .ShouldConsiderSelectionAsDirectional() ||
770 new_selection.IsDirectional()); 772 new_selection.IsDirectional());
771 const SelectionInFlatTree& selection_in_flat_tree = builder.Build(); 773 const SelectionInFlatTree& selection_in_flat_tree = builder.Build();
772 if (Selection().ComputeVisibleSelectionInFlatTree() == 774 if (Selection().ComputeVisibleSelectionInFlatTree() ==
773 CreateVisibleSelection(selection_in_flat_tree) && 775 CreateVisibleSelection(selection_in_flat_tree) &&
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 1213
1212 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { 1214 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) {
1213 bool is_mouse_down_on_link_or_image = 1215 bool is_mouse_down_on_link_or_image =
1214 event.IsOverLink() || event.GetHitTestResult().GetImage(); 1216 event.IsOverLink() || event.GetHitTestResult().GetImage();
1215 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != 1217 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) !=
1216 0 && 1218 0 &&
1217 !is_mouse_down_on_link_or_image; 1219 !is_mouse_down_on_link_or_image;
1218 } 1220 }
1219 1221
1220 } // namespace blink 1222 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/SelectionController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698