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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 Node* inner_node = result.InnerNode(); | 512 Node* inner_node = result.InnerNode(); |
513 VisibleSelectionInFlatTree new_selection; | 513 VisibleSelectionInFlatTree new_selection; |
514 | 514 |
515 if (!inner_node || !inner_node->GetLayoutObject()) | 515 if (!inner_node || !inner_node->GetLayoutObject()) |
516 return; | 516 return; |
517 | 517 |
518 const VisiblePositionInFlatTree& pos = VisiblePositionOfHitTestResult(result); | 518 const VisiblePositionInFlatTree& pos = VisiblePositionOfHitTestResult(result); |
519 if (pos.IsNotNull()) { | 519 if (pos.IsNotNull()) { |
520 const PositionInFlatTree& marker_position = | 520 const PositionInFlatTree& marker_position = |
521 pos.DeepEquivalent().ParentAnchoredEquivalent(); | 521 pos.DeepEquivalent().ParentAnchoredEquivalent(); |
522 DocumentMarkerVector markers = | 522 const DocumentMarker* const marker = |
523 inner_node->GetDocument().Markers().MarkersInRange( | 523 inner_node->GetDocument().Markers().MarkerAtPosition( |
524 EphemeralRange(ToPositionInDOMTree(marker_position)), | 524 ToPositionInDOMTree(marker_position), |
525 DocumentMarker::MisspellingMarkers()); | 525 DocumentMarker::MisspellingMarkers()); |
526 if (markers.size() == 1) { | 526 if (marker) { |
527 Node* container_node = marker_position.ComputeContainerNode(); | 527 Node* container_node = marker_position.ComputeContainerNode(); |
528 const PositionInFlatTree start(container_node, markers[0]->StartOffset()); | 528 const PositionInFlatTree start(container_node, marker->StartOffset()); |
529 const PositionInFlatTree end(container_node, markers[0]->EndOffset()); | 529 const PositionInFlatTree end(container_node, marker->EndOffset()); |
530 new_selection = CreateVisibleSelection( | 530 new_selection = CreateVisibleSelection( |
531 SelectionInFlatTree::Builder().Collapse(start).Extend(end).Build()); | 531 SelectionInFlatTree::Builder().Collapse(start).Extend(end).Build()); |
532 } | 532 } |
533 } | 533 } |
534 | 534 |
535 if (append_trailing_whitespace == AppendTrailingWhitespace::kShouldAppend) | 535 if (append_trailing_whitespace == AppendTrailingWhitespace::kShouldAppend) |
536 new_selection.AppendTrailingWhitespace(); | 536 new_selection.AppendTrailingWhitespace(); |
537 | 537 |
538 UpdateSelectionForMouseDownDispatchingSelectStart( | 538 UpdateSelectionForMouseDownDispatchingSelectStart( |
539 inner_node, | 539 inner_node, |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 } | 1011 } |
1012 | 1012 |
1013 static bool HitTestResultIsMisspelled(const HitTestResult& result) { | 1013 static bool HitTestResultIsMisspelled(const HitTestResult& result) { |
1014 Node* inner_node = result.InnerNode(); | 1014 Node* inner_node = result.InnerNode(); |
1015 if (!inner_node || !inner_node->GetLayoutObject()) | 1015 if (!inner_node || !inner_node->GetLayoutObject()) |
1016 return false; | 1016 return false; |
1017 VisiblePosition pos = CreateVisiblePosition( | 1017 VisiblePosition pos = CreateVisiblePosition( |
1018 inner_node->GetLayoutObject()->PositionForPoint(result.LocalPoint())); | 1018 inner_node->GetLayoutObject()->PositionForPoint(result.LocalPoint())); |
1019 if (pos.IsNull()) | 1019 if (pos.IsNull()) |
1020 return false; | 1020 return false; |
1021 return inner_node->GetDocument() | 1021 const Position& marker_position = |
1022 .Markers() | 1022 pos.DeepEquivalent().ParentAnchoredEquivalent(); |
1023 .MarkersInRange( | 1023 return inner_node->GetDocument().Markers().MarkerAtPosition( |
1024 EphemeralRange( | 1024 marker_position, DocumentMarker::MisspellingMarkers()); |
1025 pos.DeepEquivalent().ParentAnchoredEquivalent()), | |
1026 DocumentMarker::MisspellingMarkers()) | |
1027 .size() > 0; | |
1028 } | 1025 } |
1029 | 1026 |
1030 void SelectionController::SendContextMenuEvent( | 1027 void SelectionController::SendContextMenuEvent( |
1031 const MouseEventWithHitTestResults& mev, | 1028 const MouseEventWithHitTestResults& mev, |
1032 const LayoutPoint& position) { | 1029 const LayoutPoint& position) { |
1033 if (!Selection().IsAvailable()) | 1030 if (!Selection().IsAvailable()) |
1034 return; | 1031 return; |
1035 if (Selection().Contains(position) || mev.GetScrollbar() || | 1032 if (Selection().Contains(position) || mev.GetScrollbar() || |
1036 // FIXME: In the editable case, word selection sometimes selects content | 1033 // FIXME: In the editable case, word selection sometimes selects content |
1037 // that isn't underneath the mouse. | 1034 // that isn't underneath the mouse. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 | 1131 |
1135 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { | 1132 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { |
1136 bool is_mouse_down_on_link_or_image = | 1133 bool is_mouse_down_on_link_or_image = |
1137 event.IsOverLink() || event.GetHitTestResult().GetImage(); | 1134 event.IsOverLink() || event.GetHitTestResult().GetImage(); |
1138 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != | 1135 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != |
1139 0 && | 1136 0 && |
1140 !is_mouse_down_on_link_or_image; | 1137 !is_mouse_down_on_link_or_image; |
1141 } | 1138 } |
1142 | 1139 |
1143 } // namespace blink | 1140 } // namespace blink |
OLD | NEW |