OLD | NEW |
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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 const int distance_to_start = TextDistance(start, pos); | 218 if (pos < start) { |
219 const int distance_to_end = TextDistance(pos, end); | 219 // |distance_to_start < distance_to_end|. |
220 builder.SetBaseAndExtent( | 220 builder.SetBaseAndExtent(end, pos); |
221 distance_to_start <= distance_to_end ? end : start, pos); | 221 } else if (end < pos) { |
| 222 // |distance_to_start > distance_to_end|. |
| 223 builder.SetBaseAndExtent(start, pos); |
| 224 } else { |
| 225 const int distance_to_start = TextDistance(start, pos); |
| 226 const int distance_to_end = TextDistance(pos, end); |
| 227 builder.SetBaseAndExtent( |
| 228 distance_to_start <= distance_to_end ? end : start, pos); |
| 229 } |
222 } | 230 } |
223 | 231 |
224 UpdateSelectionForMouseDownDispatchingSelectStart( | 232 UpdateSelectionForMouseDownDispatchingSelectStart( |
225 inner_node, CreateVisibleSelection(builder.Build()), | 233 inner_node, CreateVisibleSelection(builder.Build()), |
226 this->Selection().Granularity(), HandleVisibility::kNotVisible); | 234 this->Selection().Granularity(), HandleVisibility::kNotVisible); |
227 return false; | 235 return false; |
228 } | 236 } |
229 | 237 |
230 if (selection_state_ == SelectionState::kExtendedSelection) { | 238 if (selection_state_ == SelectionState::kExtendedSelection) { |
231 UpdateSelectionForMouseDownDispatchingSelectStart( | 239 UpdateSelectionForMouseDownDispatchingSelectStart( |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 | 1142 |
1135 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { | 1143 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { |
1136 bool is_mouse_down_on_link_or_image = | 1144 bool is_mouse_down_on_link_or_image = |
1137 event.IsOverLink() || event.GetHitTestResult().GetImage(); | 1145 event.IsOverLink() || event.GetHitTestResult().GetImage(); |
1138 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != | 1146 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != |
1139 0 && | 1147 0 && |
1140 !is_mouse_down_on_link_or_image; | 1148 !is_mouse_down_on_link_or_image; |
1141 } | 1149 } |
1142 | 1150 |
1143 } // namespace blink | 1151 } // namespace blink |
OLD | NEW |