Changeset 89007 in webkit


Ignore:
Timestamp:
Jun 15, 2011 11:15:29 PM (13 years ago)
Author:
abarth@webkit.org
Message:

2011-06-15 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Remove Event::fromUserGesture
https://bugs.webkit.org/show_bug.cgi?id=62778

This function is a remnant from the old user-gesture design. The list
of events here is redundant with our selection of call sites for
setting the user gesture indicator.

As part of this patch, I've also cleaned up the implementation of
UserGestureIndicator itself to always be definite about whether we're
processing a user gesture. We now start out in a definite state (no
user gesture) and inductively state in a definite state.

  • WebCore.exp.in:
  • bindings/js/ScriptController.cpp: (WebCore::ScriptController::processingUserGesture):
  • bindings/v8/ScriptController.cpp: (WebCore::ScriptController::processingUserGesture):
  • dom/Event.cpp:
  • dom/Event.h:
  • dom/UserGestureIndicator.cpp: (WebCore::isDefinite): (WebCore::UserGestureIndicator::UserGestureIndicator): (WebCore::UserGestureIndicator::~UserGestureIndicator):
  • dom/UserGestureIndicator.h: (WebCore::UserGestureIndicator::processingUserGesture):
  • html/MediaDocument.cpp: (WebCore::MediaDocument::defaultEventHandler):
  • html/shadow/MediaControlElements.cpp: (WebCore::MediaControlSeekButtonElement::defaultEventHandler):
  • html/shadow/TextControlInnerElements.cpp: (WebCore::InputFieldSpeechButtonElement::defaultEventHandler):

2011-06-15 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Remove Event::fromUserGesture
https://bugs.webkit.org/show_bug.cgi?id=62778

This call site is not definite about there not being a user gesture.

  • src/WebPluginContainerImpl.cpp: (WebKit::WebPluginContainerImpl::loadFrameRequest):
Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r89006 r89007  
     12011-06-15  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Remove Event::fromUserGesture
     6        https://bugs.webkit.org/show_bug.cgi?id=62778
     7
     8        This function is a remnant from the old user-gesture design.  The list
     9        of events here is redundant with our selection of call sites for
     10        setting the user gesture indicator.
     11
     12        As part of this patch, I've also cleaned up the implementation of
     13        UserGestureIndicator itself to always be definite about whether we're
     14        processing a user gesture.  We now start out in a definite state (no
     15        user gesture) and inductively state in a definite state.
     16
     17        * WebCore.exp.in:
     18        * bindings/js/ScriptController.cpp:
     19        (WebCore::ScriptController::processingUserGesture):
     20        * bindings/v8/ScriptController.cpp:
     21        (WebCore::ScriptController::processingUserGesture):
     22        * dom/Event.cpp:
     23        * dom/Event.h:
     24        * dom/UserGestureIndicator.cpp:
     25        (WebCore::isDefinite):
     26        (WebCore::UserGestureIndicator::UserGestureIndicator):
     27        (WebCore::UserGestureIndicator::~UserGestureIndicator):
     28        * dom/UserGestureIndicator.h:
     29        (WebCore::UserGestureIndicator::processingUserGesture):
     30        * html/MediaDocument.cpp:
     31        (WebCore::MediaDocument::defaultEventHandler):
     32        * html/shadow/MediaControlElements.cpp:
     33        (WebCore::MediaControlSeekButtonElement::defaultEventHandler):
     34        * html/shadow/TextControlInnerElements.cpp:
     35        (WebCore::InputFieldSpeechButtonElement::defaultEventHandler):
     36
    1372011-06-08  Keishi Hattori  <keishi@webkit.org>
    238
  • trunk/Source/WebCore/WebCore.exp.in

    r88737 r89007  
    543543__ZN7WebCore20ResourceResponseBaseC2Ev
    544544__ZN7WebCore20SpaceSplitStringData12createVectorEv
    545 __ZN7WebCore20UserGestureIndicator23s_processingUserGestureE
     545__ZN7WebCore20UserGestureIndicator7s_stateE
    546546__ZN7WebCore20UserGestureIndicatorC1ENS_26ProcessingUserGestureStateE
    547547__ZN7WebCore20UserGestureIndicatorD1Ev
  • trunk/Source/WebCore/bindings/js/ScriptController.cpp

    r89005 r89007  
    244244bool ScriptController::processingUserGesture()
    245245{
    246     ExecState* exec = JSMainThreadExecState::currentState();
    247     Frame* frame = exec ? toDynamicFrame(exec) : 0;
    248     // No script is running, so it is user-initiated unless the gesture stack
    249     // explicitly says it is not.
    250     if (!frame)
    251         return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture;
    252 
    253     // If a DOM event is being processed, check that it was initiated by the user
    254     // and that it is in the whitelist of event types allowed to generate pop-ups.
    255     if (JSDOMWindowShell* shell = frame->script()->existingWindowShell(currentWorld(exec)))
    256         if (Event* event = shell->window()->currentEvent())
    257             return event->fromUserGesture();
    258 
    259246    return UserGestureIndicator::processingUserGesture();
    260247}
  • trunk/Source/WebCore/bindings/v8/ScriptController.cpp

    r89005 r89007  
    154154bool ScriptController::processingUserGesture()
    155155{
    156     Frame* firstFrame = V8Proxy::retrieveFrameForEnteredContext();
    157     if (!firstFrame)
    158         return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture;
    159 
    160     v8::HandleScope handleScope;
    161     v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(firstFrame);
    162     if (v8Context.IsEmpty())
    163         return true;
    164     v8::Context::Scope scope(v8Context);
    165     v8::Handle<v8::Object> global = v8Context->Global();
    166     v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event();
    167     v8::Handle<v8::Value> jsEvent = global->GetHiddenValue(eventSymbol);
    168     Event* event = V8DOMWrapper::isValidDOMObject(jsEvent) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0;
    169     if (event)
    170         return event->fromUserGesture();
    171 
    172156    return UserGestureIndicator::processingUserGesture();
    173157}
  • trunk/Source/WebCore/dom/Event.cpp

    r88343 r89007  
    258258#endif
    259259
    260 bool Event::fromUserGesture()
    261 {
    262     if (!UserGestureIndicator::processingUserGesture())
    263         return false;
    264 
    265     const AtomicString& type = this->type();
    266     return
    267         // mouse events
    268         type == eventNames().clickEvent || type == eventNames().mousedownEvent
    269         || type == eventNames().mouseupEvent || type == eventNames().dblclickEvent
    270         // keyboard events
    271         || type == eventNames().keydownEvent || type == eventNames().keypressEvent
    272         || type == eventNames().keyupEvent
    273 #if ENABLE(TOUCH_EVENTS)
    274         // touch events
    275         || type == eventNames().touchstartEvent || type == eventNames().touchmoveEvent
    276         || type == eventNames().touchendEvent || type == eventNames().touchcancelEvent
    277 #endif
    278         // other accepted events
    279         || type == eventNames().selectEvent || type == eventNames().changeEvent
    280         || type == eventNames().focusEvent || type == eventNames().blurEvent
    281         || type == eventNames().submitEvent;
    282 }
    283 
    284260bool Event::storesResultAsString() const
    285261{
  • trunk/Source/WebCore/dom/Event.h

    r88343 r89007  
    151151        virtual bool isStreamEvent() const;
    152152#endif
    153         bool fromUserGesture();
    154        
    155153        bool propagationStopped() const { return m_propagationStopped || m_immediatePropagationStopped; }
    156154        bool immediatePropagationStopped() const { return m_immediatePropagationStopped; }
  • trunk/Source/WebCore/dom/UserGestureIndicator.cpp

    r59462 r89007  
    2929namespace WebCore {
    3030
    31 ProcessingUserGestureState UserGestureIndicator::s_processingUserGesture = PossiblyProcessingUserGesture;
     31static bool isDefinite(ProcessingUserGestureState state)
     32{
     33    return state == DefinitelyProcessingUserGesture || state == DefinitelyNotProcessingUserGesture;
     34}
     35
     36ProcessingUserGestureState UserGestureIndicator::s_state = DefinitelyNotProcessingUserGesture;
    3237
    3338UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state)
    34     : m_previousValue(s_processingUserGesture)
     39    : m_previousState(s_state)
    3540{
    36     s_processingUserGesture = state;
     41    // We overwrite s_state only if the caller is definite about the gesture state.
     42    if (isDefinite(state))
     43        s_state = state;
     44    ASSERT(isDefinite(s_state));
    3745}
    3846
    3947UserGestureIndicator::~UserGestureIndicator()
    4048{
    41     s_processingUserGesture = m_previousValue;
     49    s_state = m_previousState;
     50    ASSERT(isDefinite(s_state));
    4251}
    4352
    44 } // namespace WebCore
     53}
  • trunk/Source/WebCore/dom/UserGestureIndicator.h

    r76248 r89007  
    4040    WTF_MAKE_NONCOPYABLE(UserGestureIndicator);
    4141public:
    42     static bool processingUserGesture() { return s_processingUserGesture == DefinitelyProcessingUserGesture; }
    43     static ProcessingUserGestureState getUserGestureState() { return s_processingUserGesture; }
     42    static bool processingUserGesture() { return s_state == DefinitelyProcessingUserGesture; }
    4443
    4544    explicit UserGestureIndicator(ProcessingUserGestureState);
     
    4746
    4847private:
    49     static ProcessingUserGestureState s_processingUserGesture;
    50     ProcessingUserGestureState m_previousValue;
    51 };   
     48    static ProcessingUserGestureState s_state;
     49    ProcessingUserGestureState m_previousState;
     50};
    5251
    53 } // namespace WebCore
     52}
    5453
    55 #endif // UserGestureIndicator_h
     54#endif
  • trunk/Source/WebCore/html/MediaDocument.cpp

    r88623 r89007  
    4141#include "NodeList.h"
    4242#include "RawDataDocumentParser.h"
     43#include "ScriptController.h"
    4344
    4445namespace WebCore {
     
    165166        if (event->type() == eventNames().clickEvent) {
    166167            if (!video->canPlay()) {
    167                 video->pause(event->fromUserGesture());
     168                video->pause(ScriptController::processingUserGesture());
    168169                event->setDefaultHandled();
    169170            }
    170171        } else if (event->type() == eventNames().dblclickEvent) {
    171172            if (video->canPlay()) {
    172                 video->play(event->fromUserGesture());
     173                video->play(ScriptController::processingUserGesture());
    173174                event->setDefaultHandled();
    174175            }
     
    185186            if (video->paused()) {
    186187                if (video->canPlay())
    187                     video->play(event->fromUserGesture());
     188                    video->play(ScriptController::processingUserGesture());
    188189            } else
    189                 video->pause(event->fromUserGesture());
     190                video->pause(ScriptController::processingUserGesture());
    190191            event->setDefaultHandled();
    191192        }
  • trunk/Source/WebCore/html/shadow/MediaControlElements.cpp

    r88952 r89007  
    4848#include "RenderTheme.h"
    4949#include "RenderView.h"
     50#include "ScriptController.h"
    5051#include "Settings.h"
    5152
     
    548549            frame->eventHandler()->setCapturingMouseEventsNode(this);
    549550        }
    550         mediaElement()->pause(event->fromUserGesture());
     551        mediaElement()->pause(ScriptController::processingUserGesture());
    551552        m_seekTimer.startRepeating(cSeekRepeatDelay);
    552553        event->setDefaultHandled();
  • trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp

    r88216 r89007  
    4040#include "RenderLayer.h"
    4141#include "RenderTextControlSingleLine.h"
     42#include "ScriptController.h"
    4243#include "ScrollbarTheme.h"
    4344#include "SpeechInput.h"
     
    389390{
    390391    // For privacy reasons, only allow clicks directly coming from the user.
    391     if (!event->fromUserGesture()) {
     392    if (!ScriptController::processingUserGesture()) {
    392393        HTMLDivElement::defaultEventHandler(event);
    393394        return;
  • trunk/Source/WebKit/chromium/ChangeLog

    r88988 r89007  
     12011-06-15  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Remove Event::fromUserGesture
     6        https://bugs.webkit.org/show_bug.cgi?id=62778
     7
     8        This call site is not definite about there not being a user gesture.
     9
     10        * src/WebPluginContainerImpl.cpp:
     11        (WebKit::WebPluginContainerImpl::loadFrameRequest):
     12
    1132011-06-15  Darin Adler  <darin@apple.com>
    214
  • trunk/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp

    r86067 r89007  
    366366}
    367367
    368 void WebPluginContainerImpl::loadFrameRequest(
    369     const WebURLRequest& request, const WebString& target, bool notifyNeeded, void* notifyData)
     368void WebPluginContainerImpl::loadFrameRequest(const WebURLRequest& request, const WebString& target, bool notifyNeeded, void* notifyData)
    370369{
    371370    Frame* frame = m_element->document()->frame();
     
    383382    }
    384383
    385     FrameLoadRequest frameRequest(frame->document()->securityOrigin(),
    386         request.toResourceRequest(), target);
    387 
    388     UserGestureIndicator gestureIndicator(request.hasUserGesture() ?
    389         DefinitelyProcessingUserGesture : DefinitelyNotProcessingUserGesture);
    390 
    391     frame->loader()->loadFrameRequest(
    392         frameRequest,
    393         false,  // lock history
    394         false,  // lock back forward list
    395         0,      // event
    396         0,     // form state
    397         SendReferrer);
     384    FrameLoadRequest frameRequest(frame->document()->securityOrigin(), request.toResourceRequest(), target);
     385    UserGestureIndicator gestureIndicator(request.hasUserGesture() ? DefinitelyProcessingUserGesture : PossiblyProcessingUserGesture);
     386    frame->loader()->loadFrameRequest(frameRequest, false, false, 0, 0, SendReferrer);
    398387}
    399388
Note: See TracChangeset for help on using the changeset viewer.