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

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

Issue 2350773004: Move HitTestResult::isMisspelled to SelectionController (Closed)
Patch Set: Remove DocumentMarkerController.h from include Created 4 years, 3 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/HitTestResult.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * Copyright (C) 2015 Google Inc. All rights reserved. 5 * Copyright (C) 2015 Google Inc. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 588
589 selectClosestWordFromHitTestResult(hitTestResult, AppendTrailingWhitespace:: DontAppend, SelectInputEventType::Touch); 589 selectClosestWordFromHitTestResult(hitTestResult, AppendTrailingWhitespace:: DontAppend, SelectInputEventType::Touch);
590 if (!selection().isAvailable()) { 590 if (!selection().isAvailable()) {
591 // "editing/selection/longpress-selection-in-iframe-removed-crash.html" 591 // "editing/selection/longpress-selection-in-iframe-removed-crash.html"
592 // reach here. 592 // reach here.
593 return false; 593 return false;
594 } 594 }
595 return selection().isRange(); 595 return selection().isRange();
596 } 596 }
597 597
598 static bool hitTestResultIsMisspelled(const HitTestResult& result)
599 {
600 Node* innerNode = result.innerNode();
601 if (!innerNode || !innerNode->layoutObject())
602 return false;
603 VisiblePosition pos = createVisiblePosition(innerNode->layoutObject()->posit ionForPoint(result.localPoint()));
604 if (pos.isNull())
605 return false;
606 return innerNode->document().markers().markersInRange(
607 EphemeralRange(pos.deepEquivalent().parentAnchoredEquivalent()), Documen tMarker::MisspellingMarkers()).size() > 0;
608 }
609
598 void SelectionController::sendContextMenuEvent(const MouseEventWithHitTestResult s& mev, const LayoutPoint& position) 610 void SelectionController::sendContextMenuEvent(const MouseEventWithHitTestResult s& mev, const LayoutPoint& position)
599 { 611 {
600 if (!selection().isAvailable()) 612 if (!selection().isAvailable())
601 return; 613 return;
602 if (selection().contains(position) 614 if (selection().contains(position)
603 || mev.scrollbar() 615 || mev.scrollbar()
604 // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse. 616 // FIXME: In the editable case, word selection sometimes selects content that isn't underneath the mouse.
605 // If the selection is non-editable, we do word selection to make it eas ier to use the contextual menu items 617 // If the selection is non-editable, we do word selection to make it eas ier to use the contextual menu items
606 // available for text selections. But only if we're above text. 618 // available for text selections. But only if we're above text.
607 || !(selection().isContentEditable() || (mev.innerNode() && mev.innerNod e()->isTextNode()))) 619 || !(selection().isContentEditable() || (mev.innerNode() && mev.innerNod e()->isTextNode())))
608 return; 620 return;
609 621
610 // Context menu events are always allowed to perform a selection. 622 // Context menu events are always allowed to perform a selection.
611 AutoReset<bool> mouseDownMayStartSelectChange(&m_mouseDownMayStartSelect, tr ue); 623 AutoReset<bool> mouseDownMayStartSelectChange(&m_mouseDownMayStartSelect, tr ue);
612 624
613 if (mev.hitTestResult().isMisspelled()) 625 if (hitTestResultIsMisspelled(mev.hitTestResult()))
614 return selectClosestMisspellingFromMouseEvent(mev); 626 return selectClosestMisspellingFromMouseEvent(mev);
615 627
616 if (!m_frame->editor().behavior().shouldSelectOnContextualMenuClick()) 628 if (!m_frame->editor().behavior().shouldSelectOnContextualMenuClick())
617 return; 629 return;
618 630
619 selectClosestWordOrLinkFromMouseEvent(mev); 631 selectClosestWordOrLinkFromMouseEvent(mev);
620 } 632 }
621 633
622 void SelectionController::passMousePressEventToSubframe(const MouseEventWithHitT estResults& mev) 634 void SelectionController::passMousePressEventToSubframe(const MouseEventWithHitT estResults& mev)
623 { 635 {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 return event.event().altKey() && event.isOverLink(); 686 return event.event().altKey() && event.isOverLink();
675 } 687 }
676 688
677 bool isExtendingSelection(const MouseEventWithHitTestResults& event) 689 bool isExtendingSelection(const MouseEventWithHitTestResults& event)
678 { 690 {
679 bool isMouseDownOnLinkOrImage = event.isOverLink() || event.hitTestResult(). image(); 691 bool isMouseDownOnLinkOrImage = event.isOverLink() || event.hitTestResult(). image();
680 return event.event().shiftKey() && !isMouseDownOnLinkOrImage; 692 return event.event().shiftKey() && !isMouseDownOnLinkOrImage;
681 } 693 }
682 694
683 } // namespace blink 695 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/HitTestResult.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698