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

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

Issue 2857173003: Remove DocumentMarkerController::MarkersInRange() (Closed)
Patch Set: Remove MarkersInRange() 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 Node* container_node = marker_position.ComputeContainerNode();
522 DocumentMarkerVector markers = 523 DocumentMarkerVector markers =
523 inner_node->GetDocument().Markers().MarkersInRange( 524 inner_node->GetDocument().Markers().MarkersFor(
524 EphemeralRange(ToPositionInDOMTree(marker_position)), 525 container_node, DocumentMarker::MisspellingMarkers());
525 DocumentMarker::MisspellingMarkers());
526 if (markers.size() == 1) { 526 if (markers.size() == 1) {
Xiaocheng 2017/05/09 21:55:15 This can break something if there are multiple mar
rlanday 2017/05/09 22:04:17 This seems like something we should push back to D
yosin_UTC9 2017/05/10 01:46:59 Good catch! MarkesForNode() isn't equivalent to Ma
527 Node* container_node = marker_position.ComputeContainerNode();
528 const PositionInFlatTree start(container_node, markers[0]->StartOffset()); 527 const PositionInFlatTree start(container_node, markers[0]->StartOffset());
529 const PositionInFlatTree end(container_node, markers[0]->EndOffset()); 528 const PositionInFlatTree end(container_node, markers[0]->EndOffset());
530 new_selection = CreateVisibleSelection( 529 new_selection = CreateVisibleSelection(
531 SelectionInFlatTree::Builder().Collapse(start).Extend(end).Build()); 530 SelectionInFlatTree::Builder().Collapse(start).Extend(end).Build());
532 } 531 }
533 } 532 }
534 533
535 if (append_trailing_whitespace == AppendTrailingWhitespace::kShouldAppend) 534 if (append_trailing_whitespace == AppendTrailingWhitespace::kShouldAppend)
536 new_selection.AppendTrailingWhitespace(); 535 new_selection.AppendTrailingWhitespace();
537 536
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 } 1010 }
1012 1011
1013 static bool HitTestResultIsMisspelled(const HitTestResult& result) { 1012 static bool HitTestResultIsMisspelled(const HitTestResult& result) {
1014 Node* inner_node = result.InnerNode(); 1013 Node* inner_node = result.InnerNode();
1015 if (!inner_node || !inner_node->GetLayoutObject()) 1014 if (!inner_node || !inner_node->GetLayoutObject())
1016 return false; 1015 return false;
1017 VisiblePosition pos = CreateVisiblePosition( 1016 VisiblePosition pos = CreateVisiblePosition(
1018 inner_node->GetLayoutObject()->PositionForPoint(result.LocalPoint())); 1017 inner_node->GetLayoutObject()->PositionForPoint(result.LocalPoint()));
1019 if (pos.IsNull()) 1018 if (pos.IsNull())
1020 return false; 1019 return false;
1020 const Position& marker_position =
1021 pos.DeepEquivalent().ParentAnchoredEquivalent();
1022 Node* container_node = marker_position.ComputeContainerNode();
1021 return inner_node->GetDocument() 1023 return inner_node->GetDocument()
1022 .Markers() 1024 .Markers()
1023 .MarkersInRange( 1025 .MarkersFor(container_node, DocumentMarker::MisspellingMarkers())
1024 EphemeralRange(
1025 pos.DeepEquivalent().ParentAnchoredEquivalent()),
1026 DocumentMarker::MisspellingMarkers())
1027 .size() > 0; 1026 .size() > 0;
1028 } 1027 }
1029 1028
1030 void SelectionController::SendContextMenuEvent( 1029 void SelectionController::SendContextMenuEvent(
1031 const MouseEventWithHitTestResults& mev, 1030 const MouseEventWithHitTestResults& mev,
1032 const LayoutPoint& position) { 1031 const LayoutPoint& position) {
1033 if (!Selection().IsAvailable()) 1032 if (!Selection().IsAvailable())
1034 return; 1033 return;
1035 if (Selection().Contains(position) || mev.GetScrollbar() || 1034 if (Selection().Contains(position) || mev.GetScrollbar() ||
1036 // FIXME: In the editable case, word selection sometimes selects content 1035 // FIXME: In the editable case, word selection sometimes selects content
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 1133
1135 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) { 1134 bool IsExtendingSelection(const MouseEventWithHitTestResults& event) {
1136 bool is_mouse_down_on_link_or_image = 1135 bool is_mouse_down_on_link_or_image =
1137 event.IsOverLink() || event.GetHitTestResult().GetImage(); 1136 event.IsOverLink() || event.GetHitTestResult().GetImage();
1138 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) != 1137 return (event.Event().GetModifiers() & WebInputEvent::Modifiers::kShiftKey) !=
1139 0 && 1138 0 &&
1140 !is_mouse_down_on_link_or_image; 1139 !is_mouse_down_on_link_or_image;
1141 } 1140 }
1142 1141
1143 } // namespace blink 1142 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698