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

Side by Side Diff: third_party/WebKit/Source/core/editing/EditingUtilities.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: dtapuska's review, also add layout tests 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) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 23 matching lines...) Expand all
34 #include "core/dom/shadow/ShadowRoot.h" 34 #include "core/dom/shadow/ShadowRoot.h"
35 #include "core/editing/EditingStrategy.h" 35 #include "core/editing/EditingStrategy.h"
36 #include "core/editing/Editor.h" 36 #include "core/editing/Editor.h"
37 #include "core/editing/PlainTextRange.h" 37 #include "core/editing/PlainTextRange.h"
38 #include "core/editing/PositionIterator.h" 38 #include "core/editing/PositionIterator.h"
39 #include "core/editing/VisiblePosition.h" 39 #include "core/editing/VisiblePosition.h"
40 #include "core/editing/VisibleSelection.h" 40 #include "core/editing/VisibleSelection.h"
41 #include "core/editing/VisibleUnits.h" 41 #include "core/editing/VisibleUnits.h"
42 #include "core/editing/iterators/TextIterator.h" 42 #include "core/editing/iterators/TextIterator.h"
43 #include "core/editing/serializers/HTMLInterchange.h" 43 #include "core/editing/serializers/HTMLInterchange.h"
44 #include "core/events/InputEvent.h"
44 #include "core/frame/LocalFrame.h" 45 #include "core/frame/LocalFrame.h"
45 #include "core/frame/UseCounter.h" 46 #include "core/frame/UseCounter.h"
46 #include "core/html/HTMLBRElement.h" 47 #include "core/html/HTMLBRElement.h"
47 #include "core/html/HTMLDivElement.h" 48 #include "core/html/HTMLDivElement.h"
48 #include "core/html/HTMLLIElement.h" 49 #include "core/html/HTMLLIElement.h"
49 #include "core/html/HTMLParagraphElement.h" 50 #include "core/html/HTMLParagraphElement.h"
50 #include "core/html/HTMLSpanElement.h" 51 #include "core/html/HTMLSpanElement.h"
51 #include "core/html/HTMLTableCellElement.h" 52 #include "core/html/HTMLTableCellElement.h"
52 #include "core/html/HTMLUListElement.h" 53 #include "core/html/HTMLUListElement.h"
53 #include "core/layout/LayoutObject.h" 54 #include "core/layout/LayoutObject.h"
(...skipping 1591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 // otherwise, make sure to be at the start of the first selected node, 1646 // otherwise, make sure to be at the start of the first selected node,
1646 // instead of possibly at the end of the last node before the selection 1647 // instead of possibly at the end of the last node before the selection
1647 return mostForwardCaretPosition(visiblePosition.deepEquivalent()); 1648 return mostForwardCaretPosition(visiblePosition.deepEquivalent());
1648 } 1649 }
1649 1650
1650 bool isTextSecurityNode(const Node* node) 1651 bool isTextSecurityNode(const Node* node)
1651 { 1652 {
1652 return node && node->layoutObject() && node->layoutObject()->style()->textSe curity() != TSNONE; 1653 return node && node->layoutObject() && node->layoutObject()->style()->textSe curity() != TSNONE;
1653 } 1654 }
1654 1655
1656 DispatchEventResult dispatchBeforeInputInsertText(EventTarget* target, const Str ing& data)
1657 {
1658 static const char* kInputTypeInsertText = "insertText";
yosin_UTC9 2016/03/15 08:32:32 Could you move |kInputTypeXXX| into "InputEvent.h"
1659 return dispatchBeforeInputEditorCommand(target, kInputTypeInsertText, data);
1660 }
1661
1662 DispatchEventResult dispatchBeforeInputEditorCommand(EventTarget* target, const char* commandName, const String& data)
1663 {
1664 if (RuntimeEnabledFeatures::inputEventEnabled()) {
1665 if (target) {
1666 RefPtrWillBeRawPtr<InputEvent> beforeInputEvent = InputEvent::create CancelableBeforeInput(commandName, data);
1667 return target->dispatchEvent(beforeInputEvent);
1668 }
1669 }
1670 return DispatchEventResult::NotCanceled;
1671 }
1672
1673 DispatchEventResult dispatchBeforeInputCompositionUpdate(EventTarget* target, co nst String& data)
1674 {
1675 if (RuntimeEnabledFeatures::inputEventEnabled()) {
1676 if (target) {
1677 static const char* kInputTypeReplaceText = "replaceText";
1678 RefPtrWillBeRawPtr<InputEvent> beforeInputEvent = InputEvent::create BeforeInput(kInputTypeReplaceText, data);
chongz 2016/03/04 19:46:50 I'm not so sure about the inputType we want to use
1679 return target->dispatchEvent(beforeInputEvent);
1680 }
1681 }
1682 return DispatchEventResult::NotCanceled;
1683 }
1684
1655 } // namespace blink 1685 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698