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

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 268993002: For non-editable content, selection editor commands are disabled Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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 | « Source/core/editing/EditorCommand.cpp ('k') | no next file » | 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 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 m_capturesDragging = false; 767 m_capturesDragging = false;
768 m_mouseDownMayStartDrag = false; 768 m_mouseDownMayStartDrag = false;
769 m_mouseDownMayStartSelect = false; 769 m_mouseDownMayStartSelect = false;
770 m_mouseDownMayStartAutoscroll = false; 770 m_mouseDownMayStartAutoscroll = false;
771 m_mouseDownWasInSubframe = false; 771 m_mouseDownWasInSubframe = false;
772 772
773 bool handled = false; 773 bool handled = false;
774 774
775 // Clear the selection if the mouse didn't move after the last mouse 775 // Clear the selection if the mouse didn't move after the last mouse
776 // press and it's not a context menu click. We do this so when clicking 776 // press and it's not a context menu click. We do this so when clicking
777 // on the selection, the selection goes away. However, if we are 777 // on the selection, the selection goes away. For readonly texts
778 // editing, place the caret. 778 // we do need to know the position of the caret for any selection
779 // using keyboard shortcuts as its currently working in non-webkit
780 // based browsers for ex: firefox. Therefore, place the caret even
781 // for non-editable texts.
779 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex tendedSelection 782 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex tendedSelection
780 && m_dragStartPos == event.event().position() 783 && m_dragStartPos == event.event().position()
781 && m_frame->selection().isRange() 784 && m_frame->selection().isRange()
782 && event.event().button() != RightButton) { 785 && event.event().button() != RightButton) {
783 VisibleSelection newSelection; 786 VisibleSelection newSelection;
784 Node* node = event.targetNode(); 787 Node* node = event.targetNode();
785 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr owsingEnabled(); 788 if (node && node->renderer()) {
786 if (node && node->renderer() && (caretBrowsing || node->hasEditableStyle ())) {
787 VisiblePosition pos = VisiblePosition(node->renderer()->positionForP oint(event.localPoint())); 789 VisiblePosition pos = VisiblePosition(node->renderer()->positionForP oint(event.localPoint()));
788 newSelection = VisibleSelection(pos); 790 newSelection = VisibleSelection(pos);
789 } 791 }
790 792
791 setSelectionIfNeeded(m_frame->selection(), newSelection); 793 setSelectionIfNeeded(m_frame->selection(), newSelection);
792 794
793 handled = true; 795 handled = true;
794 } 796 }
795 797
796 m_frame->selection().notifyRendererOfSelectionChange(UserTriggered); 798 m_frame->selection().notifyRendererOfSelectionChange(UserTriggered);
(...skipping 3023 matching lines...) Expand 10 before | Expand all | Expand 10 after
3820 unsigned EventHandler::accessKeyModifiers() 3822 unsigned EventHandler::accessKeyModifiers()
3821 { 3823 {
3822 #if OS(MACOSX) 3824 #if OS(MACOSX)
3823 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3825 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3824 #else 3826 #else
3825 return PlatformEvent::AltKey; 3827 return PlatformEvent::AltKey;
3826 #endif 3828 #endif
3827 } 3829 }
3828 3830
3829 } // namespace WebCore 3831 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/EditorCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698