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

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, 6 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 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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 m_capturesDragging = false; 755 m_capturesDragging = false;
756 m_mouseDownMayStartDrag = false; 756 m_mouseDownMayStartDrag = false;
757 m_mouseDownMayStartSelect = false; 757 m_mouseDownMayStartSelect = false;
758 m_mouseDownMayStartAutoscroll = false; 758 m_mouseDownMayStartAutoscroll = false;
759 m_mouseDownWasInSubframe = false; 759 m_mouseDownWasInSubframe = false;
760 760
761 bool handled = false; 761 bool handled = false;
762 762
763 // Clear the selection if the mouse didn't move after the last mouse 763 // Clear the selection if the mouse didn't move after the last mouse
764 // press and it's not a context menu click. We do this so when clicking 764 // press and it's not a context menu click. We do this so when clicking
765 // on the selection, the selection goes away. However, if we are 765 // on the selection, the selection goes away. For readonly texts
766 // editing, place the caret. 766 // we do need to know the position of the caret for any selection
767 // using keyboard shortcuts as its currently working in non-webkit
768 // based browsers for ex: firefox. Therefore, place the caret even
769 // for non-editable texts.
767 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex tendedSelection 770 if (m_mouseDownWasSingleClickInSelection && m_selectionInitiationState != Ex tendedSelection
768 && m_dragStartPos == event.event().position() 771 && m_dragStartPos == event.event().position()
769 && m_frame->selection().isRange() 772 && m_frame->selection().isRange()
770 && event.event().button() != RightButton) { 773 && event.event().button() != RightButton) {
771 VisibleSelection newSelection; 774 VisibleSelection newSelection;
772 Node* node = event.targetNode(); 775 Node* node = event.targetNode();
773 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBr owsingEnabled(); 776 if (node && node->renderer()) {
Yuta Kitamura 2014/06/04 08:19:38 I think this change means that you will get a care
b.rout 2014/06/04 12:53:04 It will not show the caret, but it will set select
774 if (node && node->renderer() && (caretBrowsing || node->rendererIsEditab le())) {
775 VisiblePosition pos = VisiblePosition(node->renderer()->positionForP oint(event.localPoint())); 777 VisiblePosition pos = VisiblePosition(node->renderer()->positionForP oint(event.localPoint()));
776 newSelection = VisibleSelection(pos); 778 newSelection = VisibleSelection(pos);
777 } 779 }
778 780
779 setSelectionIfNeeded(m_frame->selection(), newSelection); 781 setSelectionIfNeeded(m_frame->selection(), newSelection);
780 782
781 handled = true; 783 handled = true;
782 } 784 }
783 785
784 m_frame->selection().notifyRendererOfSelectionChange(UserTriggered); 786 m_frame->selection().notifyRendererOfSelectionChange(UserTriggered);
(...skipping 2948 matching lines...) Expand 10 before | Expand all | Expand 10 after
3733 unsigned EventHandler::accessKeyModifiers() 3735 unsigned EventHandler::accessKeyModifiers()
3734 { 3736 {
3735 #if OS(MACOSX) 3737 #if OS(MACOSX)
3736 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3738 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
3737 #else 3739 #else
3738 return PlatformEvent::AltKey; 3740 return PlatformEvent::AltKey;
3739 #endif 3741 #endif
3740 } 3742 }
3741 3743
3742 } // namespace WebCore 3744 } // namespace WebCore
OLDNEW
« Source/core/editing/EditorCommand.cpp ('K') | « Source/core/editing/EditorCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698