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

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

Issue 1752933002: [InputEvent] Fire 'beforeinput' during typing, pressing hot keys and IME composition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2009 Igalia S.L. 4 * Copyright (C) 2009 Igalia S.L.
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 30 matching lines...) Expand all
41 #include "core/editing/commands/CreateLinkCommand.h" 41 #include "core/editing/commands/CreateLinkCommand.h"
42 #include "core/editing/commands/FormatBlockCommand.h" 42 #include "core/editing/commands/FormatBlockCommand.h"
43 #include "core/editing/commands/IndentOutdentCommand.h" 43 #include "core/editing/commands/IndentOutdentCommand.h"
44 #include "core/editing/commands/InsertListCommand.h" 44 #include "core/editing/commands/InsertListCommand.h"
45 #include "core/editing/commands/ReplaceSelectionCommand.h" 45 #include "core/editing/commands/ReplaceSelectionCommand.h"
46 #include "core/editing/commands/TypingCommand.h" 46 #include "core/editing/commands/TypingCommand.h"
47 #include "core/editing/commands/UnlinkCommand.h" 47 #include "core/editing/commands/UnlinkCommand.h"
48 #include "core/editing/serializers/Serialization.h" 48 #include "core/editing/serializers/Serialization.h"
49 #include "core/editing/spellcheck/SpellChecker.h" 49 #include "core/editing/spellcheck/SpellChecker.h"
50 #include "core/events/Event.h" 50 #include "core/events/Event.h"
51 #include "core/events/InputEvent.h"
51 #include "core/frame/FrameHost.h" 52 #include "core/frame/FrameHost.h"
52 #include "core/frame/FrameView.h" 53 #include "core/frame/FrameView.h"
53 #include "core/frame/LocalFrame.h" 54 #include "core/frame/LocalFrame.h"
54 #include "core/frame/Settings.h" 55 #include "core/frame/Settings.h"
55 #include "core/html/HTMLFontElement.h" 56 #include "core/html/HTMLFontElement.h"
56 #include "core/html/HTMLHRElement.h" 57 #include "core/html/HTMLHRElement.h"
57 #include "core/html/HTMLImageElement.h" 58 #include "core/html/HTMLImageElement.h"
58 #include "core/input/EventHandler.h" 59 #include "core/input/EventHandler.h"
59 #include "core/layout/LayoutBox.h" 60 #include "core/layout/LayoutBox.h"
60 #include "core/page/ChromeClient.h" 61 #include "core/page/ChromeClient.h"
(...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 { 1773 {
1773 // TODO(yosin) We should move this logic into |canExecute()| member function 1774 // TODO(yosin) We should move this logic into |canExecute()| member function
1774 // in |EditorInternalCommand| to replace |allowExecutionWhenDisabled|. 1775 // in |EditorInternalCommand| to replace |allowExecutionWhenDisabled|.
1775 // |allowExecutionWhenDisabled| is for "Copy", "Cut" and "Paste" commands 1776 // |allowExecutionWhenDisabled| is for "Copy", "Cut" and "Paste" commands
1776 // only. 1777 // only.
1777 if (!isEnabled(triggeringEvent)) { 1778 if (!isEnabled(triggeringEvent)) {
1778 // Let certain commands be executed when performed explicitly even if th ey are disabled. 1779 // Let certain commands be executed when performed explicitly even if th ey are disabled.
1779 if (!isSupported() || !m_frame || !m_command->allowExecutionWhenDisabled ) 1780 if (!isSupported() || !m_frame || !m_command->allowExecutionWhenDisabled )
1780 return false; 1781 return false;
1781 } 1782 }
1783
1784 if (RuntimeEnabledFeatures::inputEventEnabled()) {
1785 if (EventTarget* target = eventTargetNodeForDocument(m_frame->document() )) {
1786 RefPtrWillBeRawPtr<InputEvent> beforeInputEvent = InputEvent::create BeforeInput("executeCommand", "");
chongz 2016/03/01 20:41:10 Didn't find a way to get command name from Editor:
dtapuska 2016/03/01 21:49:51 Ya I think you'd want to load it from the EditorIn
1787 DispatchEventResult dispatchResult = target->dispatchEvent(beforeInp utEvent);
1788 if (dispatchResult != DispatchEventResult::NotCanceled)
1789 return true;
1790 }
1791 }
1792
1782 frame().document()->updateLayoutIgnorePendingStylesheets(); 1793 frame().document()->updateLayoutIgnorePendingStylesheets();
1783 DEFINE_STATIC_LOCAL(SparseHistogram, commandHistogram, ("WebCore.Editing.Com mands")); 1794 DEFINE_STATIC_LOCAL(SparseHistogram, commandHistogram, ("WebCore.Editing.Com mands"));
1784 commandHistogram.sample(m_command->idForUserMetrics); 1795 commandHistogram.sample(m_command->idForUserMetrics);
1785 return m_command->execute(*m_frame, triggeringEvent, m_source, parameter); 1796 return m_command->execute(*m_frame, triggeringEvent, m_source, parameter);
1786 } 1797 }
1787 1798
1788 bool Editor::Command::execute(Event* triggeringEvent) const 1799 bool Editor::Command::execute(Event* triggeringEvent) const
1789 { 1800 {
1790 return execute(String(), triggeringEvent); 1801 return execute(String(), triggeringEvent);
1791 } 1802 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 { 1842 {
1832 return m_command && m_command->isTextInsertion; 1843 return m_command && m_command->isTextInsertion;
1833 } 1844 }
1834 1845
1835 int Editor::Command::idForHistogram() const 1846 int Editor::Command::idForHistogram() const
1836 { 1847 {
1837 return isSupported() ? m_command->idForUserMetrics : 0; 1848 return isSupported() ? m_command->idForUserMetrics : 0;
1838 } 1849 }
1839 1850
1840 } // namespace blink 1851 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698