Changeset 63927 in webkit


Ignore:
Timestamp:
Jul 22, 2010 5:37:03 PM (14 years ago)
Author:
weinig@apple.com
Message:

Fix for <rdar://problem/8222626>
Send textDidChangeInTextField delegate callback only in response to typing or other forms of user text input.

Reviewed by Maciej Stachowiak.

WebCore:

  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:

Update project files.

  • dom/UserTypingGestureIndicator.cpp: Copied from dom/UserGestureIndicator.cpp.

(WebCore::UserTypingGestureIndicator::processingUserTypingGesture):
(WebCore::focusedNode):
(WebCore::UserTypingGestureIndicator::focusedElementAtGestureStart):
(WebCore::UserTypingGestureIndicator::UserTypingGestureIndicator):
(WebCore::UserTypingGestureIndicator::~UserTypingGestureIndicator):

  • dom/UserTypingGestureIndicator.h: Copied from dom/UserGestureIndicator.h.

Version of UserGestureIndicator that just tracks keyboard gestures and the focused
node they were targeting.

  • editing/Editor.cpp:

(WebCore::Editor::confirmComposition):
(WebCore::Editor::setComposition):

  • page/EventHandler.cpp:

(WebCore::EventHandler::keyEvent):
Put UserTypingGestureIndicator on the stack for user generated keyboard events.

WebKit/mac:

The function name no longer perfectly matches the behavior, but I didn't want to break any existing clients. Maybe we
should migrate to a new function name eventually

  • WebCoreSupport/WebEditorClient.mm:

(WebEditorClient::textDidChangeInTextField):

WebKit/win:

The function name no longer perfectly matches the behavior, but I didn't want to break any existing clients. Maybe we
should migrate to a new function name eventually

  • WebCoreSupport/WebEditorClient.cpp:

(WebEditorClient::textDidChangeInTextField):

Location:
trunk
Files:
14 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r63926 r63927  
     12010-07-22  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Fix for <rdar://problem/8222626>
     6        Send textDidChangeInTextField delegate callback only in response to typing or other forms of user text input.
     7
     8        * GNUmakefile.am:
     9        * WebCore.gypi:
     10        * WebCore.pro:
     11        * WebCore.vcproj/WebCore.vcproj:
     12        * WebCore.xcodeproj/project.pbxproj:
     13        Update project files.
     14       
     15        * dom/UserTypingGestureIndicator.cpp: Copied from dom/UserGestureIndicator.cpp.
     16        (WebCore::UserTypingGestureIndicator::processingUserTypingGesture):
     17        (WebCore::focusedNode):
     18        (WebCore::UserTypingGestureIndicator::focusedElementAtGestureStart):
     19        (WebCore::UserTypingGestureIndicator::UserTypingGestureIndicator):
     20        (WebCore::UserTypingGestureIndicator::~UserTypingGestureIndicator):
     21        * dom/UserTypingGestureIndicator.h: Copied from dom/UserGestureIndicator.h.
     22        Version of UserGestureIndicator that just tracks keyboard gestures and the focused
     23        node they were targeting.
     24       
     25        * editing/Editor.cpp:
     26        (WebCore::Editor::confirmComposition):
     27        (WebCore::Editor::setComposition):
     28        * page/EventHandler.cpp:
     29        (WebCore::EventHandler::keyEvent):
     30        Put UserTypingGestureIndicator on the stack for user generated keyboard events.
     31
    1322010-07-22  Kent Tamura  <tkent@chromium.org>
    233
  • trunk/WebCore/GNUmakefile.am

    r63863 r63927  
    11651165        WebCore/dom/UserGestureIndicator.cpp \
    11661166        WebCore/dom/UserGestureIndicator.h \
     1167        WebCore/dom/UserTypingGestureIndicator.cpp \
     1168        WebCore/dom/UserTypingGestureIndicator.h \
    11671169        WebCore/dom/ViewportArguments.cpp \
    11681170        WebCore/dom/ViewportArguments.h \
  • trunk/WebCore/WebCore.exp.in

    r63904 r63927  
    311311__ZN7WebCore14ResourceLoader19setShouldBufferDataEb
    312312__ZN7WebCore14SVGSMILElement13isSMILElementEPNS_4NodeE
     313__ZN7WebCore14SchemeRegistry24registerURLSchemeAsLocalERKNS_6StringE
    313314__ZN7WebCore14SchemeRegistry25registerURLSchemeAsSecureERKNS_6StringE
    314 __ZN7WebCore14SchemeRegistry24registerURLSchemeAsLocalERKNS_6StringE
    315315__ZN7WebCore14SecurityOrigin16createFromStringERKNS_6StringE
    316316__ZN7WebCore14SecurityOrigin18setLocalLoadPolicyENS0_15LocalLoadPolicyE
     
    481481__ZN7WebCore26CSSMutableStyleDeclarationC1Ev
    482482__ZN7WebCore26NetscapePlugInStreamLoader6createEPNS_5FrameEPNS_32NetscapePlugInStreamLoaderClientE
     483__ZN7WebCore26UserTypingGestureIndicator27processingUserTypingGestureEv
     484__ZN7WebCore26UserTypingGestureIndicator28focusedElementAtGestureStartEv
    483485__ZN7WebCore26contextMenuItemTagFontMenuEv
    484486__ZN7WebCore26contextMenuItemTagOpenLinkEv
     
    762764__ZN7WebCore9FrameView20enterCompositingModeEv
    763765__ZN7WebCore9FrameView21flushDeferredRepaintsEv
    764 __ZN7WebCore9FrameView38scrollPositionChangedViaPlatformWidgetEv
    765766__ZN7WebCore9FrameView22setBaseBackgroundColorENS_5ColorE
    766767__ZN7WebCore9FrameView23layoutIfNeededRecursiveEv
     
    769770__ZN7WebCore9FrameView29setShouldUpdateWhileOffscreenEb
    770771__ZN7WebCore9FrameView29syncCompositingStateRecursiveEv
     772__ZN7WebCore9FrameView38scrollPositionChangedViaPlatformWidgetEv
    771773__ZN7WebCore9FrameView6createEPNS_5FrameE
    772774__ZN7WebCore9FrameView6createEPNS_5FrameERKNS_7IntSizeE
  • trunk/WebCore/WebCore.gypi

    r63919 r63927  
    12741274            'dom/UserGestureIndicator.cpp',
    12751275            'dom/UserGestureIndicator.h',
     1276            'dom/UserTypingGestureIndicator.cpp',
     1277            'dom/UserTypingGestureIndicator.h',
    12761278            'dom/ViewportArguments.cpp',
    12771279            'dom/ViewportArguments.h',
  • trunk/WebCore/WebCore.pro

    r63902 r63927  
    550550    dom/UIEventWithKeyState.cpp \
    551551    dom/UserGestureIndicator.cpp \
     552    dom/UserTypingGestureIndicator.cpp \
    552553    dom/ViewportArguments.cpp \
    553554    dom/WebKitAnimationEvent.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r63863 r63927  
    3301433014                        </File>
    3301533015                        <File
     33016                                RelativePath="..\dom\UserTypingGestureIndicator.cpp"
     33017                                >
     33018                        </File>
     33019                        <File
     33020                                RelativePath="..\dom\UserTypingGestureIndicator.h"
     33021                                >
     33022                        </File>
     33023                        <File
    3301633024                                RelativePath="..\dom\ViewportArguments.cpp"
    3301733025                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r63904 r63927  
    47864786                BCDBB8CD0E08958400C60FF6 /* File.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDBB8CB0E08958400C60FF6 /* File.h */; };
    47874787                BCDBB8CE0E08958400C60FF6 /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCDBB8CC0E08958400C60FF6 /* File.cpp */; };
     4788                BCDF317B11F8D683003C5BF8 /* UserTypingGestureIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCDF317911F8D683003C5BF8 /* UserTypingGestureIndicator.cpp */; };
     4789                BCDF317C11F8D683003C5BF8 /* UserTypingGestureIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDF317A11F8D683003C5BF8 /* UserTypingGestureIndicator.h */; settings = {ATTRIBUTES = (Private, ); }; };
    47884790                BCDFD48E0E305290009D10AD /* XMLHttpRequestUpload.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDFD48C0E305290009D10AD /* XMLHttpRequestUpload.h */; };
    47894791                BCDFD48F0E305290009D10AD /* XMLHttpRequestUpload.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCDFD48D0E305290009D10AD /* XMLHttpRequestUpload.cpp */; };
     
    1042910431                BCDBB8CB0E08958400C60FF6 /* File.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = File.h; sourceTree = "<group>"; };
    1043010432                BCDBB8CC0E08958400C60FF6 /* File.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = File.cpp; sourceTree = "<group>"; };
     10433                BCDF317911F8D683003C5BF8 /* UserTypingGestureIndicator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserTypingGestureIndicator.cpp; sourceTree = "<group>"; };
     10434                BCDF317A11F8D683003C5BF8 /* UserTypingGestureIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserTypingGestureIndicator.h; sourceTree = "<group>"; };
    1043110435                BCDFD48C0E305290009D10AD /* XMLHttpRequestUpload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLHttpRequestUpload.h; sourceTree = "<group>"; };
    1043210436                BCDFD48D0E305290009D10AD /* XMLHttpRequestUpload.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLHttpRequestUpload.cpp; sourceTree = "<group>"; };
     
    1712817132                                2542F4D81166C25A00E89A86 /* UserGestureIndicator.cpp */,
    1712917133                                2542F4D91166C25A00E89A86 /* UserGestureIndicator.h */,
     17134                                BCDF317911F8D683003C5BF8 /* UserTypingGestureIndicator.cpp */,
     17135                                BCDF317A11F8D683003C5BF8 /* UserTypingGestureIndicator.h */,
    1713017136                                CEF418CC1179678C009D112C /* ViewportArguments.cpp */,
    1713117137                                CEF418CD1179678C009D112C /* ViewportArguments.h */,
     
    1984419850                                BC5CFCA911F793320099ED09 /* LocalizationStrategy.h in Headers */,
    1984519851                                5162C7F511F77EFB00612EFE /* SchemeRegistry.h in Headers */,
     19852                                BCDF317C11F8D683003C5BF8 /* UserTypingGestureIndicator.h in Headers */,
    1984619853                        );
    1984719854                        runOnlyForDeploymentPostprocessing = 0;
     
    1990319910                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
    1990419911                        compatibilityVersion = "Xcode 2.4";
    19905                         developmentRegion = English;
    1990619912                        hasScannedForEncodings = 1;
    1990719913                        knownRegions = (
     
    2223922245                                8C6EA61911EF7E0400FD8EE3 /* RuntimeEnabledFeatures.cpp in Sources */,
    2224022246                                5162C7F411F77EFB00612EFE /* SchemeRegistry.cpp in Sources */,
     22247                                BCDF317B11F8D683003C5BF8 /* UserTypingGestureIndicator.cpp in Sources */,
    2224122248                        );
    2224222249                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/dom/UserTypingGestureIndicator.cpp

    r63905 r63927  
    2525
    2626#include "config.h"
    27 #include "UserGestureIndicator.h"
     27#include "UserTypingGestureIndicator.h"
     28
     29#include "Frame.h"
     30#include "Node.h"
     31#include <wtf/StdLibExtras.h>
    2832
    2933namespace WebCore {
    3034
    31 ProcessingUserGestureState UserGestureIndicator::s_processingUserGesture = PossiblyProcessingUserGesture;
    32 
    33 UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state)
    34     : m_previousValue(s_processingUserGesture)
     35static bool s_processingUserTypingGesture;
     36bool UserTypingGestureIndicator::processingUserTypingGesture()
    3537{
    36     s_processingUserGesture = state;
     38    return s_processingUserTypingGesture;
    3739}
    3840
    39 UserGestureIndicator::~UserGestureIndicator()
     41static RefPtr<Node>& focusedNode()
    4042{
    41     s_processingUserGesture = m_previousValue;
     43    DEFINE_STATIC_LOCAL(RefPtr<Node>, node, ());
     44    return node;
     45}
     46
     47Node* UserTypingGestureIndicator::focusedElementAtGestureStart()
     48{
     49    return focusedNode().get();
     50}
     51
     52UserTypingGestureIndicator::UserTypingGestureIndicator(Frame* frame)
     53    : m_previousProcessingUserTypingGesture(s_processingUserTypingGesture)
     54    , m_previousFocusedNode(focusedNode())
     55{
     56    s_processingUserTypingGesture = true;
     57    focusedNode() = frame->document() ? frame->document()->focusedNode() : 0;
     58}
     59
     60UserTypingGestureIndicator::~UserTypingGestureIndicator()
     61{
     62    s_processingUserTypingGesture = m_previousProcessingUserTypingGesture;
     63    focusedNode() = m_previousFocusedNode;
    4264}
    4365
  • trunk/WebCore/dom/UserTypingGestureIndicator.h

    r63905 r63927  
    2424 */
    2525
    26 #ifndef UserGestureIndicator_h
    27 #define UserGestureIndicator_h
     26#ifndef UserTypingGestureIndicator_h
     27#define UserTypingGestureIndicator_h
    2828
    2929#include <wtf/Noncopyable.h>
     30#include <wtf/RefPtr.h>
    3031
    3132namespace WebCore {
    3233
    33 enum ProcessingUserGestureState {
    34     DefinitelyProcessingUserGesture,
    35     PossiblyProcessingUserGesture,
    36     DefinitelyNotProcessingUserGesture
    37 };
     34class Frame;
     35class Node;
    3836
    39 class UserGestureIndicator : public Noncopyable {
     37class UserTypingGestureIndicator : public Noncopyable {
    4038public:
    41     static bool processingUserGesture() { return s_processingUserGesture == DefinitelyProcessingUserGesture; }
    42     static ProcessingUserGestureState getUserGestureState() { return s_processingUserGesture; }
     39    static bool processingUserTypingGesture();
     40    static Node* focusedElementAtGestureStart();
    4341
    44     explicit UserGestureIndicator(ProcessingUserGestureState);
    45     ~UserGestureIndicator();
     42    explicit UserTypingGestureIndicator(Frame*);
     43    ~UserTypingGestureIndicator();
    4644
    4745private:
    48     static ProcessingUserGestureState s_processingUserGesture;
    49     ProcessingUserGestureState m_previousValue;
     46    bool m_previousProcessingUserTypingGesture;
     47    RefPtr<Node> m_previousFocusedNode;
    5048};   
    5149
    5250} // namespace WebCore
    5351
    54 #endif // UserGestureIndicator_h
     52#endif // UserTypingGestureIndicator_h
  • trunk/WebCore/editing/Editor.cpp

    r61418 r63927  
    6969#include "TextIterator.h"
    7070#include "TypingCommand.h"
     71#include "UserTypingGestureIndicator.h"
    7172#include "htmlediting.h"
    7273#include "markup.h"
     
    13711372void Editor::confirmComposition(const String& text, bool preserveSelection)
    13721373{
     1374    UserTypingGestureIndicator typingGestureIndicator(m_frame);
     1375
    13731376    setIgnoreCompositionSelectionChange(true);
    13741377
     
    14131416void Editor::setComposition(const String& text, const Vector<CompositionUnderline>& underlines, unsigned selectionStart, unsigned selectionEnd)
    14141417{
     1418    UserTypingGestureIndicator typingGestureIndicator(m_frame);
     1419
    14151420    setIgnoreCompositionSelectionChange(true);
    14161421
  • trunk/WebCore/page/EventHandler.cpp

    r63888 r63927  
    7070#include "TextIterator.h"
    7171#include "UserGestureIndicator.h"
     72#include "UserTypingGestureIndicator.h"
    7273#include "WheelEvent.h"
    7374#include "htmlediting.h" // for comparePositions()
     
    22672268
    22682269    UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
     2270    UserTypingGestureIndicator typingGestureIndicator(m_frame);
    22692271
    22702272    if (FrameView* view = m_frame->view())
  • trunk/WebCore/page/Frame.cpp

    r63847 r63927  
    7878#include "TextResourceDecoder.h"
    7979#include "UserContentURLPattern.h"
     80#include "UserTypingGestureIndicator.h"
    8081#include "XMLNSNames.h"
    8182#include "XMLNames.h"
  • trunk/WebKit/mac/ChangeLog

    r63904 r63927  
     12010-07-22  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Fix for <rdar://problem/8222626>
     6        Send textDidChangeInTextField delegate callback only in response to typing or other forms of user text input.
     7
     8        The function name no longer perfectly matches the behavior, but I didn't want to break any existing clients. Maybe we
     9        should migrate to a new function name eventually
     10
     11        * WebCoreSupport/WebEditorClient.mm:
     12        (WebEditorClient::textDidChangeInTextField):
     13
    1142010-07-22  Sam Weinig  <sam@webkit.org>
    215
  • trunk/WebKit/mac/WebCoreSupport/WebEditorClient.mm

    r63602 r63927  
    6060#import <WebCore/PlatformKeyboardEvent.h>
    6161#import <WebCore/PlatformString.h>
     62#import <WebCore/UserTypingGestureIndicator.h>
    6263#import <WebCore/WebCoreObjCExtras.h>
    6364#import <runtime/InitializeThreading.h>
     
    558559    CallFormDelegate(m_webView, @selector(textFieldDidEndEditing:inFrame:), inputElement, kit(element->document()->frame()));
    559560}
    560    
     561
    561562void WebEditorClient::textDidChangeInTextField(Element* element)
    562563{
    563564    if (!element->hasTagName(inputTag))
     565        return;
     566
     567    if (!UserTypingGestureIndicator::processingUserTypingGesture() || UserTypingGestureIndicator::focusedElementAtGestureStart() != element)
    564568        return;
    565569
  • trunk/WebKit/win/ChangeLog

    r63863 r63927  
     12010-07-22  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Fix for <rdar://problem/8222626>
     6        Send textDidChangeInTextField delegate callback only in response to typing or other forms of user text input.
     7
     8        The function name no longer perfectly matches the behavior, but I didn't want to break any existing clients. Maybe we
     9        should migrate to a new function name eventually
     10
     11        * WebCoreSupport/WebEditorClient.cpp:
     12        (WebEditorClient::textDidChangeInTextField):
     13
    1142010-07-21  Brady Eidson  <beidson@apple.com>
    215
  • trunk/WebKit/win/WebCoreSupport/WebEditorClient.cpp

    r63602 r63927  
    4242#include <WebCore/HTMLNames.h>
    4343#include <WebCore/KeyboardEvent.h>
     44#include <WebCore/NotImplemented.h>
    4445#include <WebCore/PlatformKeyboardEvent.h>
    45 #include <WebCore/NotImplemented.h>
    4646#include <WebCore/Range.h>
     47#include <WebCore/UserTypingGestureIndicator.h>
    4748#pragma warning(pop)
    4849
     
    348349void WebEditorClient::textDidChangeInTextField(Element* e)
    349350{
     351    if (!UserTypingGestureIndicator::processingUserTypingGesture() || UserTypingGestureIndicator::focusedElementAtGestureStart() != e)
     352        return;
     353
    350354    IWebFormDelegate* formDelegate;
    351355    if (SUCCEEDED(m_webView->formDelegate(&formDelegate)) && formDelegate) {
Note: See TracChangeset for help on using the changeset viewer.