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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 return UpdateSelectionForMouseDownDispatchingSelectStart( | 520 return UpdateSelectionForMouseDownDispatchingSelectStart( |
521 inner_node, | 521 inner_node, |
522 ExpandSelectionToRespectUserSelectAll(inner_node, new_selection), | 522 ExpandSelectionToRespectUserSelectAll(inner_node, new_selection), |
523 kWordGranularity, visibility); | 523 kWordGranularity, visibility); |
524 } | 524 } |
525 | 525 |
526 void SelectionController::SelectClosestMisspellingFromHitTestResult( | 526 void SelectionController::SelectClosestMisspellingFromHitTestResult( |
527 const HitTestResult& result, | 527 const HitTestResult& result, |
528 AppendTrailingWhitespace append_trailing_whitespace) { | 528 AppendTrailingWhitespace append_trailing_whitespace) { |
529 Node* inner_node = result.InnerNode(); | 529 Node* inner_node = result.InnerNode(); |
530 VisibleSelectionInFlatTree new_selection; | |
531 | 530 |
532 if (!inner_node || !inner_node->GetLayoutObject()) | 531 if (!inner_node || !inner_node->GetLayoutObject()) |
533 return; | 532 return; |
534 | 533 |
535 const VisiblePositionInFlatTree& pos = VisiblePositionOfHitTestResult(result); | 534 const VisiblePositionInFlatTree& pos = VisiblePositionOfHitTestResult(result); |
536 if (pos.IsNotNull()) { | 535 if (pos.IsNull()) { |
537 const PositionInFlatTree& marker_position = | 536 UpdateSelectionForMouseDownDispatchingSelectStart( |
538 pos.DeepEquivalent().ParentAnchoredEquivalent(); | 537 inner_node, VisibleSelectionInFlatTree(), kWordGranularity, |
539 const DocumentMarker* const marker = | 538 HandleVisibility::kNotVisible); |
540 inner_node->GetDocument().Markers().MarkerAtPosition( | 539 return; |
541 ToPositionInDOMTree(marker_position), | |
542 DocumentMarker::MisspellingMarkers()); | |
543 if (marker) { | |
544 Node* container_node = marker_position.ComputeContainerNode(); | |
545 const PositionInFlatTree start(container_node, marker->StartOffset()); | |
546 const PositionInFlatTree end(container_node, marker->EndOffset()); | |
547 new_selection = CreateVisibleSelection( | |
548 SelectionInFlatTree::Builder().Collapse(start).Extend(end).Build()); | |
549 } | |
550 } | 540 } |
551 | 541 |
| 542 const PositionInFlatTree& marker_position = |
| 543 pos.DeepEquivalent().ParentAnchoredEquivalent(); |
| 544 const DocumentMarker* const marker = |
| 545 inner_node->GetDocument().Markers().MarkerAtPosition( |
| 546 ToPositionInDOMTree(marker_position), |
| 547 DocumentMarker::MisspellingMarkers()); |
| 548 if (!marker) { |
| 549 UpdateSelectionForMouseDownDispatchingSelectStart( |
| 550 inner_node, VisibleSelectionInFlatTree(), kWordGranularity, |
| 551 HandleVisibility::kNotVisible); |
| 552 return; |
| 553 } |
| 554 |
| 555 Node* container_node = marker_position.ComputeContainerNode(); |
| 556 const PositionInFlatTree start(container_node, marker->StartOffset()); |
| 557 const PositionInFlatTree end(container_node, marker->EndOffset()); |
| 558 VisibleSelectionInFlatTree new_selection = CreateVisibleSelection( |
| 559 SelectionInFlatTree::Builder().Collapse(start).Extend(end).Build()); |
| 560 |
552 if (append_trailing_whitespace == AppendTrailingWhitespace::kShouldAppend) | 561 if (append_trailing_whitespace == AppendTrailingWhitespace::kShouldAppend) |
553 new_selection.AppendTrailingWhitespace(); | 562 new_selection.AppendTrailingWhitespace(); |
554 | 563 |
555 UpdateSelectionForMouseDownDispatchingSelectStart( | 564 UpdateSelectionForMouseDownDispatchingSelectStart( |
556 inner_node, | 565 inner_node, |
557 ExpandSelectionToRespectUserSelectAll(inner_node, new_selection), | 566 ExpandSelectionToRespectUserSelectAll(inner_node, new_selection), |
558 kWordGranularity, HandleVisibility::kNotVisible); | 567 kWordGranularity, HandleVisibility::kNotVisible); |
559 } | 568 } |
560 | 569 |
561 bool SelectionController::SelectClosestWordFromMouseEvent( | 570 bool SelectionController::SelectClosestWordFromMouseEvent( |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 | 1197 |
1189 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { | 1198 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { |
1190 bool is_mouse_down_on_link_or_image = | 1199 bool is_mouse_down_on_link_or_image = |
1191 event.IsOverLink() || event.GetHitTestResult().GetImage(); | 1200 event.IsOverLink() || event.GetHitTestResult().GetImage(); |
1192 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != | 1201 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != |
1193 0 && | 1202 0 && |
1194 !is_mouse_down_on_link_or_image; | 1203 !is_mouse_down_on_link_or_image; |
1195 } | 1204 } |
1196 | 1205 |
1197 } // namespace blink | 1206 } // namespace blink |
OLD | NEW |