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

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

Issue 2857173003: Remove DocumentMarkerController::MarkersInRange() (Closed)
Patch Set: Respond to comments Created 3 years, 7 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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 Optional<DocumentMarker*> marker =
Xiaocheng 2017/05/11 18:25:20 Please change type of |marker| to |const DocumentM
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.has_value()) {
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,
529 const PositionInFlatTree end(container_node, markers[0]->EndOffset()); 529 marker.value()->StartOffset());
530 const PositionInFlatTree end(container_node, marker.value()->EndOffset());
530 new_selection = CreateVisibleSelection( 531 new_selection = CreateVisibleSelection(
531 SelectionInFlatTree::Builder().Collapse(start).Extend(end).Build()); 532 SelectionInFlatTree::Builder().Collapse(start).Extend(end).Build());
532 } 533 }
533 } 534 }
534 535
535 if (append_trailing_whitespace == AppendTrailingWhitespace::kShouldAppend) 536 if (append_trailing_whitespace == AppendTrailingWhitespace::kShouldAppend)
536 new_selection.AppendTrailingWhitespace(); 537 new_selection.AppendTrailingWhitespace();
537 538
538 UpdateSelectionForMouseDownDispatchingSelectStart( 539 UpdateSelectionForMouseDownDispatchingSelectStart(
539 inner_node, 540 inner_node,
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 } 1012 }
1012 1013
1013 static bool HitTestResultIsMisspelled(const HitTestResult& result) { 1014 static bool HitTestResultIsMisspelled(const HitTestResult& result) {
1014 Node* inner_node = result.InnerNode(); 1015 Node* inner_node = result.InnerNode();
1015 if (!inner_node || !inner_node->GetLayoutObject()) 1016 if (!inner_node || !inner_node->GetLayoutObject())
1016 return false; 1017 return false;
1017 VisiblePosition pos = CreateVisiblePosition( 1018 VisiblePosition pos = CreateVisiblePosition(
1018 inner_node->GetLayoutObject()->PositionForPoint(result.LocalPoint())); 1019 inner_node->GetLayoutObject()->PositionForPoint(result.LocalPoint()));
1019 if (pos.IsNull()) 1020 if (pos.IsNull())
1020 return false; 1021 return false;
1021 return inner_node->GetDocument() 1022 const Position& marker_position =
1022 .Markers() 1023 pos.DeepEquivalent().ParentAnchoredEquivalent();
1023 .MarkersInRange( 1024 return inner_node->GetDocument().Markers().MarkerAtPosition(
1024 EphemeralRange( 1025 marker_position, DocumentMarker::MisspellingMarkers());
1025 pos.DeepEquivalent().ParentAnchoredEquivalent()),
1026 DocumentMarker::MisspellingMarkers())
1027 .size() > 0;
1028 } 1026 }
1029 1027
1030 void SelectionController::SendContextMenuEvent( 1028 void SelectionController::SendContextMenuEvent(
1031 const MouseEventWithHitTestResults& mev, 1029 const MouseEventWithHitTestResults& mev,
1032 const LayoutPoint& position) { 1030 const LayoutPoint& position) {
1033 if (!Selection().IsAvailable()) 1031 if (!Selection().IsAvailable())
1034 return; 1032 return;
1035 if (Selection().Contains(position) || mev.GetScrollbar() || 1033 if (Selection().Contains(position) || mev.GetScrollbar() ||
1036 // FIXME: In the editable case, word selection sometimes selects content 1034 // FIXME: In the editable case, word selection sometimes selects content
1037 // that isn't underneath the mouse. 1035 // that isn't underneath the mouse.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 1132
1135 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { 1133 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) {
1136 bool is_mouse_down_on_link_or_image = 1134 bool is_mouse_down_on_link_or_image =
1137 event.IsOverLink() || event.GetHitTestResult().GetImage(); 1135 event.IsOverLink() || event.GetHitTestResult().GetImage();
1138 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != 1136 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) !=
1139 0 && 1137 0 &&
1140 !is_mouse_down_on_link_or_image; 1138 !is_mouse_down_on_link_or_image;
1141 } 1139 }
1142 1140
1143 } // namespace blink 1141 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698