[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

barraclough at apple.com barraclough at apple.com
Thu Feb 4 21:35:55 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 521cb20b5594d3a00252a8992c16ab8d4c4b619f
Author: barraclough at apple.com <barraclough at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Feb 2 01:20:12 2010 +0000

    Bug 34346 - With JSC bindings, make processingUserGesture work with events in Isolated Worlds
    
    WebCore:
    
    Reviewed by Sam Weinig + Oliver Hunt.
    
    Change HTMLMediaElement methods that require checking whether the event is a user gesture to
    be passed a boolean.  This may be passed from the JSC bindings (where we have an exec state),
    or read from the event.  Add a Flag to the IDL to mark this information is required.
    
    * WebCore.Video.exp:
    * bindings/js/JSDOMBinding.cpp:
    (WebCore::processingUserGesture):
    * bindings/js/JSDOMWindowCustom.cpp:
    (WebCore::domWindowAllowPopUp):
    (WebCore::JSDOMWindow::open):
    (WebCore::JSDOMWindow::showModalDialog):
    * bindings/js/JSDocumentCustom.cpp:
    (WebCore::JSDocument::setLocation):
    * bindings/js/ScriptController.cpp:
    (WebCore::ScriptController::processingUserGesture):
    (WebCore::ScriptController::processingUserGestureEvent):
    (WebCore::ScriptController::anyPageIsProcessingUserGesture):
    * bindings/js/ScriptController.h:
    * bindings/scripts/CodeGeneratorJS.pm:
    * dom/Event.cpp:
    (WebCore::Event::isUserEvent):
    * dom/Event.h:
    * html/HTMLMediaElement.cpp:
    (WebCore::HTMLMediaElement::removedFromDocument):
    (WebCore::HTMLMediaElement::load):
    (WebCore::HTMLMediaElement::play):
    (WebCore::HTMLMediaElement::pause):
    (WebCore::HTMLMediaElement::beginScrubbing):
    (WebCore::HTMLMediaElement::documentDidBecomeActive):
    (WebCore::HTMLMediaElement::webkitEnterFullScreen):
    * html/HTMLMediaElement.h:
    * html/HTMLMediaElement.idl:
    * loader/FrameLoader.cpp:
    (WebCore::FrameLoader::isProcessingUserGesture):
    * loader/MediaDocument.cpp:
    (WebCore::MediaDocument::defaultEventHandler):
    * page/DOMWindow.cpp:
    (WebCore::DOMWindow::allowPopUp):
    * rendering/MediaControlElements.cpp:
    (WebCore::MediaControlSeekButtonElement::defaultEventHandler):
    
    WebKit/mac:
    
    Reviewed by Sam Weinig + Oliver Hunt.
    
    Pass processeing user gensture flag to media play/pause methods.
    
    * WebView/WebVideoFullscreenHUDWindowController.mm:
    (-[WebVideoFullscreenHUDWindowController setPlaying:]):
    
    WebKit/win:
    
    Reviewed by Sam Weinig + Oliver Hunt.
    
    Pass processeing user gensture flag to media play/pause methods.
    
    * FullscreenVideoController.cpp:
    (FullscreenVideoController::play):
    (FullscreenVideoController::pause):
    
    LayoutTests:
    
    Reviewed by Sam Weinig.
    
    * http/tests/security/isolatedWorld/resources/userGestureEvents-second-window.html: Added.
    * http/tests/security/isolatedWorld/userGestureEvents-expected.txt: Added.
    * http/tests/security/isolatedWorld/userGestureEvents.html: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54182 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 4c5fc88..5c56114 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-02-01  Gavin Barraclough  <barraclough at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Bug 34346 - With JSC bindings, make processingUserGesture work with events in Isolated Worlds
+
+        * http/tests/security/isolatedWorld/resources/userGestureEvents-second-window.html: Added.
+        * http/tests/security/isolatedWorld/userGestureEvents-expected.txt: Added.
+        * http/tests/security/isolatedWorld/userGestureEvents.html: Added.
+
 2010-02-01  Shinichiro Hamaji  <hamaji at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/http/tests/security/isolatedWorld/resources/userGestureEvents-second-window.html b/LayoutTests/http/tests/security/isolatedWorld/resources/userGestureEvents-second-window.html
new file mode 100644
index 0000000..0b420be
--- /dev/null
+++ b/LayoutTests/http/tests/security/isolatedWorld/resources/userGestureEvents-second-window.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<title>Event handlers in isolated worlds for user gesture generated events should should the same permissions as handlers within the page (resource)</title>
+<script>
+
+// success!
+window.opener.pass();
+window.close();
+
+</script>
+<body>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/security/isolatedWorld/userGestureEvents-expected.txt b/LayoutTests/http/tests/security/isolatedWorld/userGestureEvents-expected.txt
new file mode 100644
index 0000000..3a5977b
--- /dev/null
+++ b/LayoutTests/http/tests/security/isolatedWorld/userGestureEvents-expected.txt
@@ -0,0 +1,3 @@
+
+
+Event handlers in isolated worlds for user gesture generated events should should the same permissions as handlers within the page.: PASS
diff --git a/LayoutTests/http/tests/security/isolatedWorld/userGestureEvents.html b/LayoutTests/http/tests/security/isolatedWorld/userGestureEvents.html
new file mode 100644
index 0000000..910aceb
--- /dev/null
+++ b/LayoutTests/http/tests/security/isolatedWorld/userGestureEvents.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html>
+<title>Event handlers in isolated worlds for user gesture generated events should should the same permissions as handlers within the page</title>
+<script>
+
+// This test is meaningless without a layoutTestController.
+if (!window.layoutTestController && !window.eventSender) {
+    document.getElementById("log").innerHTML += "FAIL\n";
+    return;
+}
+
+layoutTestController.setCanOpenWindows(true);
+layoutTestController.waitUntilDone();
+layoutTestController.dumpAsText();
+
+function newTest(title)
+{
+    document.getElementById("log").innerHTML += "<br>" + title + ": ";
+}
+
+function pass()
+{
+    document.getElementById("log").innerHTML += "PASS\n";
+    layoutTestController.notifyDone();
+}
+
+// (This function is run within an isolated world)
+function userGestureEventListener()
+{
+    // Register an event handler that will try to perform an action that can only be initiated by a user gesture (opening a window).
+    document.getElementById("button1").onclick = function()
+    {
+        window.open("resources/userGestureEvents-second-window.html", "resources/userGestureEvents-second-window.html");
+    }
+}
+
+function runTestInWorld(worldId, funcName)
+{
+    layoutTestController.evaluateScriptInIsolatedWorld(worldId, String(eval(funcName)) + "\n" + funcName + "();");
+}
+
+function runTest() 
+{
+    newTest("Event handlers in isolated worlds for user gesture generated events should should the same permissions as handlers within the page.");
+    runTestInWorld(1, "userGestureEventListener");
+
+    // Click somewhere on the button!
+    var testDiv = document.getElementById("test");
+    eventSender.mouseMoveTo(testDiv.offsetLeft + 5, testDiv.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+</script>
+<body onload="runTest()">
+    <div id="test"><button id='button1'></button></div>
+    <div id="log"></div>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9662be7..c8134e7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,50 @@
+2010-01-29  Gavin Barraclough  <barraclough at apple.com>
+
+        Reviewed by Sam Weinig + Oliver Hunt.
+
+        Bug 34346 - With JSC bindings, make processingUserGesture work with events in Isolated Worlds
+
+        Change HTMLMediaElement methods that require checking whether the event is a user gesture to
+        be passed a boolean.  This may be passed from the JSC bindings (where we have an exec state),
+        or read from the event.  Add a Flag to the IDL to mark this information is required.
+
+        * WebCore.Video.exp:
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::processingUserGesture):
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::domWindowAllowPopUp):
+        (WebCore::JSDOMWindow::open):
+        (WebCore::JSDOMWindow::showModalDialog):
+        * bindings/js/JSDocumentCustom.cpp:
+        (WebCore::JSDocument::setLocation):
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::processingUserGesture):
+        (WebCore::ScriptController::processingUserGestureEvent):
+        (WebCore::ScriptController::anyPageIsProcessingUserGesture):
+        * bindings/js/ScriptController.h:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        * dom/Event.cpp:
+        (WebCore::Event::isUserEvent):
+        * dom/Event.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::removedFromDocument):
+        (WebCore::HTMLMediaElement::load):
+        (WebCore::HTMLMediaElement::play):
+        (WebCore::HTMLMediaElement::pause):
+        (WebCore::HTMLMediaElement::beginScrubbing):
+        (WebCore::HTMLMediaElement::documentDidBecomeActive):
+        (WebCore::HTMLMediaElement::webkitEnterFullScreen):
+        * html/HTMLMediaElement.h:
+        * html/HTMLMediaElement.idl:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::isProcessingUserGesture):
+        * loader/MediaDocument.cpp:
+        (WebCore::MediaDocument::defaultEventHandler):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::allowPopUp):
+        * rendering/MediaControlElements.cpp:
+        (WebCore::MediaControlSeekButtonElement::defaultEventHandler):
+
 2010-02-01  Andreas Kling  <andreas.kling at nokia.com>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebCore/WebCore.Video.exp b/WebCore/WebCore.Video.exp
index 57619b4..da79150 100644
--- a/WebCore/WebCore.Video.exp
+++ b/WebCore/WebCore.Video.exp
@@ -3,13 +3,14 @@ __ZN7WebCore16HTMLMediaElement12endScrubbingEv
 __ZN7WebCore16HTMLMediaElement14beginScrubbingEv
 __ZN7WebCore16HTMLMediaElement14exitFullscreenEv
 __ZN7WebCore16HTMLMediaElement14setCurrentTimeEfRi
-__ZN7WebCore16HTMLMediaElement4playEv
-__ZN7WebCore16HTMLMediaElement5pauseEv
+__ZN7WebCore16HTMLMediaElement4playEb
+__ZN7WebCore16HTMLMediaElement5pauseEb
 __ZN7WebCore16HTMLMediaElement6rewindEf
 __ZN7WebCore16HTMLMediaElement8setMutedEb
 __ZN7WebCore16HTMLMediaElement9setVolumeEfRi
 __ZNK7WebCore16HTMLMediaElement11currentTimeEv
 __ZNK7WebCore16HTMLMediaElement13platformMediaEv
+__ZNK7WebCore16HTMLMediaElement21processingUserGestureEv
 __ZNK7WebCore16HTMLMediaElement5mutedEv
 __ZNK7WebCore16HTMLMediaElement6volumeEv
 __ZNK7WebCore16HTMLMediaElement7canPlayEv
diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp
index 04b6dc9..abba405 100644
--- a/WebCore/bindings/js/JSDOMBinding.cpp
+++ b/WebCore/bindings/js/JSDOMBinding.cpp
@@ -776,7 +776,7 @@ Frame* toDynamicFrame(ExecState* exec)
 bool processingUserGesture(ExecState* exec)
 {
     Frame* frame = toDynamicFrame(exec);
-    return frame && frame->script()->processingUserGesture();
+    return frame && frame->script()->processingUserGesture(currentWorld(exec));
 }
 
 KURL completeURL(ExecState* exec, const String& relativeURL)
diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp
index 1da5af2..f7be2c5 100644
--- a/WebCore/bindings/js/JSDOMWindowCustom.cpp
+++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp
@@ -716,6 +716,14 @@ static Frame* createWindow(ExecState* exec, Frame* lexicalFrame, Frame* dynamicF
     return newFrame;
 }
 
+static bool domWindowAllowPopUp(Frame* activeFrame, ExecState* exec)
+{
+    ASSERT(activeFrame);
+    if (activeFrame->script()->processingUserGesture(currentWorld(exec)))
+        return true;
+    return DOMWindow::allowPopUp(activeFrame);
+}
+
 JSValue JSDOMWindow::open(ExecState* exec, const ArgList& args)
 {
     String urlString = valueToStringWithUndefinedOrNullCheck(exec, args.at(0));
@@ -736,7 +744,7 @@ JSValue JSDOMWindow::open(ExecState* exec, const ArgList& args)
 
     // Because FrameTree::find() returns true for empty strings, we must check for empty framenames.
     // Otherwise, illegitimate window.open() calls with no name will pass right through the popup blocker.
-    if (!DOMWindow::allowPopUp(dynamicFrame) && (frameName.isEmpty() || !frame->tree()->find(frameName)))
+    if (!domWindowAllowPopUp(dynamicFrame, exec) && (frameName.isEmpty() || !frame->tree()->find(frameName)))
         return jsUndefined();
 
     // Get the target frame for the special cases of _top and _parent.  In those
@@ -806,7 +814,7 @@ JSValue JSDOMWindow::showModalDialog(ExecState* exec, const ArgList& args)
     if (!dynamicFrame)
         return jsUndefined();
 
-    if (!DOMWindow::canShowModalDialogNow(frame) || !DOMWindow::allowPopUp(dynamicFrame))
+    if (!DOMWindow::canShowModalDialogNow(frame) || !domWindowAllowPopUp(dynamicFrame, exec))
         return jsUndefined();
 
     HashMap<String, String> features;
diff --git a/WebCore/bindings/js/JSDocumentCustom.cpp b/WebCore/bindings/js/JSDocumentCustom.cpp
index 9366399..eda153e 100644
--- a/WebCore/bindings/js/JSDocumentCustom.cpp
+++ b/WebCore/bindings/js/JSDocumentCustom.cpp
@@ -87,7 +87,7 @@ void JSDocument::setLocation(ExecState* exec, JSValue value)
     if (activeFrame)
         str = activeFrame->document()->completeURL(str).string();
 
-    bool userGesture = activeFrame->script()->processingUserGesture();
+    bool userGesture = activeFrame->script()->processingUserGesture(currentWorld(exec));
     frame->redirectScheduler()->scheduleLocationChange(str, activeFrame->loader()->outgoingReferrer(), !activeFrame->script()->anyPageIsProcessingUserGesture(), false, userGesture);
 }
 
diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp
index 083e931..bd36689 100644
--- a/WebCore/bindings/js/ScriptController.cpp
+++ b/WebCore/bindings/js/ScriptController.cpp
@@ -222,39 +222,19 @@ JSDOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world)
     return windowShell;
 }
 
-bool ScriptController::processingUserGesture() const
+bool ScriptController::processingUserGesture(DOMWrapperWorld* world) const
 {
-    return m_allowPopupsFromPlugin || processingUserGestureEvent() || isJavaScriptAnchorNavigation();
+    return m_allowPopupsFromPlugin || processingUserGestureEvent(world) || isJavaScriptAnchorNavigation();
 }
 
-bool ScriptController::processingUserGestureEvent() const
+bool ScriptController::processingUserGestureEvent(DOMWrapperWorld* world) const
 {
-    JSDOMWindowShell* shell = existingWindowShell(mainThreadNormalWorld());
+    JSDOMWindowShell* shell = existingWindowShell(world);
     if (!shell)
         return false;
 
-    if (Event* event = shell->window()->currentEvent()) {
-        if (event->createdByDOM())
-            return false;
-
-        const AtomicString& type = event->type();
-        if ( // mouse events
-            type == eventNames().clickEvent || type == eventNames().mousedownEvent 
-            || type == eventNames().mouseupEvent || type == eventNames().dblclickEvent 
-            // keyboard events
-            || type == eventNames().keydownEvent || type == eventNames().keypressEvent
-            || type == eventNames().keyupEvent
-#if ENABLE(TOUCH_EVENTS)
-            // touch events
-            || type == eventNames().touchstartEvent || type == eventNames().touchmoveEvent
-            || type == eventNames().touchendEvent || type == eventNames().touchcancelEvent
-#endif
-            // other accepted events
-            || type == eventNames().selectEvent || type == eventNames().changeEvent
-            || type == eventNames().focusEvent || type == eventNames().blurEvent
-            || type == eventNames().submitEvent)
-            return true;
-    }
+    if (Event* event = shell->window()->currentEvent())
+        return event->fromUserGesture();
     
     return false;
 }
@@ -280,7 +260,20 @@ bool ScriptController::anyPageIsProcessingUserGesture() const
     HashSet<Page*>::const_iterator end = pages.end();
     for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) {
         for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
-            if (frame->script()->processingUserGesture())
+            ScriptController* script = frame->script();
+
+            if (script->m_allowPopupsFromPlugin)
+                return true;
+
+            const ShellMap::const_iterator iterEnd = m_windowShells.end();
+            for (ShellMap::const_iterator iter = m_windowShells.begin(); iter != iterEnd; ++iter) {
+                JSDOMWindowShell* shell = iter->second.get();
+                Event* event = shell->window()->currentEvent();
+                if (event && event->fromUserGesture())
+                    return true;
+            }
+
+            if (isJavaScriptAnchorNavigation())
                 return true;
         }
     }
diff --git a/WebCore/bindings/js/ScriptController.h b/WebCore/bindings/js/ScriptController.h
index f3e5adf..1cbb56d 100644
--- a/WebCore/bindings/js/ScriptController.h
+++ b/WebCore/bindings/js/ScriptController.h
@@ -107,7 +107,7 @@ public:
     int eventHandlerLineNumber() { return m_handlerLineNumber; }
 
     void setProcessingTimerCallback(bool b) { m_processingTimerCallback = b; }
-    bool processingUserGesture() const;
+    bool processingUserGesture(DOMWrapperWorld*) const;
     bool anyPageIsProcessingUserGesture() const;
 
     bool canExecuteScripts();
@@ -164,7 +164,7 @@ private:
 
     void disconnectPlatformScriptObjects();
 
-    bool processingUserGestureEvent() const;
+    bool processingUserGestureEvent(DOMWrapperWorld*) const;
     bool isJavaScriptAnchorNavigation() const;
 
     ShellMap m_windowShells;
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index 7a55a3d..c774a57 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -1676,7 +1676,12 @@ sub GenerateImplementation
                     } else {
                         $functionString .= $name;
                     }
+                    $paramIndex++;
+                }
 
+                if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) {
+                    $functionString .= ", " if $paramIndex;
+                    $functionString .= "processingUserGesture(exec)";
                     $paramIndex++;
                 }
 
diff --git a/WebCore/dom/Event.cpp b/WebCore/dom/Event.cpp
index be2b37b..b6abb2a 100644
--- a/WebCore/dom/Event.cpp
+++ b/WebCore/dom/Event.cpp
@@ -194,6 +194,30 @@ bool Event::isTouchEvent() const
 }
 #endif
 
+bool Event::fromUserGesture()
+{
+    if (createdByDOM())
+        return false;
+
+    const AtomicString& type = this->type();
+    return
+        // mouse events
+        type == eventNames().clickEvent || type == eventNames().mousedownEvent 
+        || type == eventNames().mouseupEvent || type == eventNames().dblclickEvent 
+        // keyboard events
+        || type == eventNames().keydownEvent || type == eventNames().keypressEvent
+        || type == eventNames().keyupEvent
+#if ENABLE(TOUCH_EVENTS)
+        // touch events
+        || type == eventNames().touchstartEvent || type == eventNames().touchmoveEvent
+        || type == eventNames().touchendEvent || type == eventNames().touchcancelEvent
+#endif
+        // other accepted events
+        || type == eventNames().selectEvent || type == eventNames().changeEvent
+        || type == eventNames().focusEvent || type == eventNames().blurEvent
+        || type == eventNames().submitEvent;
+}
+
 bool Event::storesResultAsString() const
 {
     return false;
diff --git a/WebCore/dom/Event.h b/WebCore/dom/Event.h
index 4624663..0a05863 100644
--- a/WebCore/dom/Event.h
+++ b/WebCore/dom/Event.h
@@ -129,6 +129,7 @@ namespace WebCore {
 #if ENABLE(TOUCH_EVENTS)
         virtual bool isTouchEvent() const;
 #endif
+        bool fromUserGesture();
         
         bool propagationStopped() const { return m_propagationStopped; }
 
diff --git a/WebCore/html/HTMLMediaElement.cpp b/WebCore/html/HTMLMediaElement.cpp
index aad8268..279aac7 100644
--- a/WebCore/html/HTMLMediaElement.cpp
+++ b/WebCore/html/HTMLMediaElement.cpp
@@ -270,7 +270,7 @@ void HTMLMediaElement::insertedIntoDocument()
 void HTMLMediaElement::removedFromDocument()
 {
     if (m_networkState > NETWORK_EMPTY)
-        pause();
+        pause(processingUserGesture());
     if (m_isFullscreen)
         exitFullscreen();
     HTMLElement::removedFromDocument();
@@ -421,9 +421,9 @@ String HTMLMediaElement::canPlayType(const String& mimeType) const
     return canPlay;
 }
 
-void HTMLMediaElement::load(ExceptionCode& ec)
+void HTMLMediaElement::load(bool isUserGesture, ExceptionCode& ec)
 {
-    if (m_restrictions & RequireUserGestureForLoadRestriction && !processingUserGesture())
+    if (m_restrictions & RequireUserGestureForLoadRestriction && !isUserGesture)
         ec = INVALID_STATE_ERR;
     else {
         prepareForLoad();
@@ -1120,9 +1120,9 @@ void HTMLMediaElement::setAutobuffer(bool b)
     setBooleanAttribute(autobufferAttr, b);
 }
 
-void HTMLMediaElement::play()
+void HTMLMediaElement::play(bool isUserGesture)
 {
-    if (m_restrictions & RequireUserGestureForRateChangeRestriction && !processingUserGesture())
+    if (m_restrictions & RequireUserGestureForRateChangeRestriction && !isUserGesture)
         return;
 
     playInternal();
@@ -1155,9 +1155,9 @@ void HTMLMediaElement::playInternal()
     updatePlayState();
 }
 
-void HTMLMediaElement::pause()
+void HTMLMediaElement::pause(bool isUserGesture)
 {
-    if (m_restrictions & RequireUserGestureForRateChangeRestriction && !processingUserGesture())
+    if (m_restrictions & RequireUserGestureForRateChangeRestriction && !isUserGesture)
         return;
 
     pauseInternal();
@@ -1265,7 +1265,7 @@ void HTMLMediaElement::beginScrubbing()
             // Because a media element stays in non-paused state when it reaches end, playback resumes 
             // when the slider is dragged from the end to another position unless we pause first. Do 
             // a "hard pause" so an event is generated, since we want to stay paused after scrubbing finishes.
-            pause();
+            pause(processingUserGesture());
         } else {
             // Not at the end but we still want to pause playback so the media engine doesn't try to
             // continue playing during scrubbing. Pause without generating an event as we will 
@@ -1761,7 +1761,7 @@ void HTMLMediaElement::documentDidBecomeActive()
         //  MEDIA_ERR_ABORTED while the abortEvent is being sent, but cleared immediately afterwards).
         // This behavior is not specified but it seems like a sensible thing to do.
         ExceptionCode ec;
-        load(ec);
+        load(processingUserGesture(), ec);
     }
 
     if (renderer())
diff --git a/WebCore/html/HTMLMediaElement.h b/WebCore/html/HTMLMediaElement.h
index 2dd0514..45a41c6 100644
--- a/WebCore/html/HTMLMediaElement.h
+++ b/WebCore/html/HTMLMediaElement.h
@@ -102,7 +102,7 @@ public:
     void setAutobuffer(bool);
 
     PassRefPtr<TimeRanges> buffered() const;
-    void load(ExceptionCode&);
+    void load(bool isUserGesture, ExceptionCode&);
     String canPlayType(const String& mimeType) const;
 
 // ready state
@@ -129,8 +129,8 @@ public:
     void setAutoplay(bool b);
     bool loop() const;    
     void setLoop(bool b);
-    void play();
-    void pause();
+    void play(bool isUserGesture);
+    void pause(bool isUserGesture);
 
 // captions
     bool webkitHasClosedCaptions() const;
@@ -171,6 +171,8 @@ public:
     bool closedCaptionsVisible() const;
     void setClosedCaptionsVisible(bool);
 
+    bool processingUserGesture() const;
+
 protected:
     float getTimeOffsetAttribute(const QualifiedName&, float valueOnError) const;
     void setTimeOffsetAttribute(const QualifiedName&, float value);
@@ -185,8 +187,6 @@ protected:
     virtual void willMoveToNewOwnerDocument();
     virtual void didMoveToNewOwnerDocument();
 
-    bool processingUserGesture() const;
-
 private: // MediaPlayerClient
     virtual void mediaPlayerNetworkStateChanged(MediaPlayer*);
     virtual void mediaPlayerReadyStateChanged(MediaPlayer*);
diff --git a/WebCore/html/HTMLMediaElement.idl b/WebCore/html/HTMLMediaElement.idl
index 865ca5b..46a2b86 100644
--- a/WebCore/html/HTMLMediaElement.idl
+++ b/WebCore/html/HTMLMediaElement.idl
@@ -42,7 +42,7 @@ interface [Conditional=VIDEO] HTMLMediaElement : HTMLElement {
     attribute boolean autobuffer;
 
     readonly attribute TimeRanges buffered;
-    void load() 
+    [NeedsUserGestureCheck] void load() 
         raises (DOMException);
     DOMString canPlayType(in DOMString type);
 
@@ -68,8 +68,8 @@ interface [Conditional=VIDEO] HTMLMediaElement : HTMLElement {
     readonly attribute boolean ended;
     attribute boolean autoplay;
     attribute boolean loop;
-    void play();
-    void pause();
+    [NeedsUserGestureCheck] void play();
+    [NeedsUserGestureCheck] void pause();
 
     // controls
     attribute boolean controls;
diff --git a/WebCore/html/HTMLVideoElement.cpp b/WebCore/html/HTMLVideoElement.cpp
index 994a829..be8f884 100644
--- a/WebCore/html/HTMLVideoElement.cpp
+++ b/WebCore/html/HTMLVideoElement.cpp
@@ -224,14 +224,14 @@ bool HTMLVideoElement::hasAvailableVideoFrame() const
     return m_player->hasAvailableVideoFrame();
 }
 
-void HTMLVideoElement::webkitEnterFullScreen(ExceptionCode& ec)
+void HTMLVideoElement::webkitEnterFullScreen(bool isUserGesture, ExceptionCode& ec)
 {
     if (m_isFullscreen)
         return;
 
     // Generate an exception if this isn't called in response to a user gesture, or if the 
     // element does not support fullscreen.
-    if (!processingUserGesture() || !supportsFullscreen()) {
+    if (!isUserGesture || !supportsFullscreen()) {
         ec = INVALID_STATE_ERR;
         return;
     }
diff --git a/WebCore/html/HTMLVideoElement.h b/WebCore/html/HTMLVideoElement.h
index c49ba02..a5c005c 100644
--- a/WebCore/html/HTMLVideoElement.h
+++ b/WebCore/html/HTMLVideoElement.h
@@ -65,7 +65,7 @@ public:
     void setPoster(const String&);
 
 // fullscreen
-    void webkitEnterFullScreen(ExceptionCode&);
+    void webkitEnterFullScreen(bool isUserGesture, ExceptionCode&);
     void webkitExitFullScreen();
     bool webkitSupportsFullscreen();
     bool webkitDisplayingFullscreen();
diff --git a/WebCore/html/HTMLVideoElement.idl b/WebCore/html/HTMLVideoElement.idl
index 3d630b6..c4764ac 100644
--- a/WebCore/html/HTMLVideoElement.idl
+++ b/WebCore/html/HTMLVideoElement.idl
@@ -34,7 +34,7 @@ module html {
         readonly attribute boolean webkitSupportsFullscreen;
         readonly attribute boolean webkitDisplayingFullscreen;
     
-        void webkitEnterFullScreen()
+        [NeedsUserGestureCheck] void webkitEnterFullScreen()
             raises (DOMException);
         void webkitExitFullScreen();
 
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index 0f3b46e..4bd4de3 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -1467,7 +1467,7 @@ bool FrameLoader::isProcessingUserGesture()
     Frame* frame = m_frame->tree()->top();
     if (!frame->script()->canExecuteScripts())
         return true; // If JavaScript is disabled, a user gesture must have initiated the navigation.
-    return frame->script()->processingUserGesture(); // FIXME: Use pageIsProcessingUserGesture.
+    return frame->script()->processingUserGesture(mainThreadNormalWorld()); // FIXME: Use pageIsProcessingUserGesture.
 }
 
 void FrameLoader::resetMultipleFormSubmissionProtection()
diff --git a/WebCore/loader/MediaDocument.cpp b/WebCore/loader/MediaDocument.cpp
index 656d0a0..a2d6276 100644
--- a/WebCore/loader/MediaDocument.cpp
+++ b/WebCore/loader/MediaDocument.cpp
@@ -159,12 +159,12 @@ void MediaDocument::defaultEventHandler(Event* event)
         HTMLVideoElement* video = static_cast<HTMLVideoElement*>(targetNode);
         if (event->type() == eventNames().clickEvent) {
             if (!video->canPlay()) {
-                video->pause();
+                video->pause(event->fromUserGesture());
                 event->setDefaultHandled();
             }
         } else if (event->type() == eventNames().dblclickEvent) {
             if (video->canPlay()) {
-                video->play();
+                video->play(event->fromUserGesture());
                 event->setDefaultHandled();
             }
         }
@@ -186,9 +186,9 @@ void MediaDocument::defaultEventHandler(Event* event)
             if (keyboardEvent->keyIdentifier() == "U+0020") { // space
                 if (video->paused()) {
                     if (video->canPlay())
-                        video->play();
+                        video->play(event->fromUserGesture());
                 } else
-                    video->pause();
+                    video->pause(event->fromUserGesture());
                 event->setDefaultHandled();
             }
         }
diff --git a/WebCore/page/DOMWindow.cpp b/WebCore/page/DOMWindow.cpp
index 3eb2b8e..2f0f84f 100644
--- a/WebCore/page/DOMWindow.cpp
+++ b/WebCore/page/DOMWindow.cpp
@@ -342,8 +342,6 @@ void DOMWindow::parseModalDialogFeatures(const String& featuresArg, HashMap<Stri
 bool DOMWindow::allowPopUp(Frame* activeFrame)
 {
     ASSERT(activeFrame);
-    if (activeFrame->script()->processingUserGesture())
-        return true;
     Settings* settings = activeFrame->settings();
     return settings && settings->javaScriptCanOpenWindowsAutomatically();
 }
diff --git a/WebCore/rendering/MediaControlElements.cpp b/WebCore/rendering/MediaControlElements.cpp
index 9c56756..31a91ab 100644
--- a/WebCore/rendering/MediaControlElements.cpp
+++ b/WebCore/rendering/MediaControlElements.cpp
@@ -504,7 +504,7 @@ void MediaControlSeekButtonElement::defaultEventHandler(Event* event)
             m_capturing = true;
             frame->eventHandler()->setCapturingMouseEventsNode(this);
         }
-        m_mediaElement->pause();
+        m_mediaElement->pause(event->fromUserGesture());
         m_seekTimer.startRepeating(cSeekRepeatDelay);
         event->setDefaultHandled();
     } else if (event->type() == eventNames().mouseupEvent) {
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 6f82668..c5023f8 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,14 @@
+2010-01-29  Gavin Barraclough  <barraclough at apple.com>
+
+        Reviewed by Sam Weinig + Oliver Hunt.
+
+        Bug 34346 - With JSC bindings, make processingUserGesture work with events in Isolated Worlds
+
+        Pass processeing user gensture flag to media play/pause methods.
+
+        * WebView/WebVideoFullscreenHUDWindowController.mm:
+        (-[WebVideoFullscreenHUDWindowController setPlaying:]):
+
 2010-02-01  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Anders Carlsson.
diff --git a/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm b/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm
index 82cb1bf..83e2d09 100644
--- a/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm
+++ b/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm
@@ -578,13 +578,15 @@ static NSTextField *createTimeTextField(NSRect frame)
 
 - (void)setPlaying:(BOOL)playing
 {
-    if (![_delegate mediaElement])
+    HTMLMediaElement* mediaElement = [_delegate mediaElement];
+
+    if (!mediaElement)
         return;
 
     if (playing)
-        [_delegate mediaElement]->play();
+        mediaElement->play(mediaElement->processingUserGesture());
     else
-        [_delegate mediaElement]->pause();
+        mediaElement->pause(mediaElement->processingUserGesture());
 }
 
 static NSString *timeToString(double time)
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index 6cc5d6e..4a5338d 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,15 @@
+2010-01-29  Gavin Barraclough  <barraclough at apple.com>
+
+        Reviewed by Sam Weinig + Oliver Hunt.
+
+        Bug 34346 - With JSC bindings, make processingUserGesture work with events in Isolated Worlds
+
+        Pass processeing user gensture flag to media play/pause methods.
+
+        * FullscreenVideoController.cpp:
+        (FullscreenVideoController::play):
+        (FullscreenVideoController::pause):
+
 2010-01-29  Brian Weinstein  <bweinstein at apple.com>
 
         Reviewed by Adam Roben.
diff --git a/WebKit/win/FullscreenVideoController.cpp b/WebKit/win/FullscreenVideoController.cpp
index 6b8e5ac..dbfc794 100644
--- a/WebKit/win/FullscreenVideoController.cpp
+++ b/WebKit/win/FullscreenVideoController.cpp
@@ -243,13 +243,13 @@ bool FullscreenVideoController::canPlay() const
 void FullscreenVideoController::play()
 {
     if (m_mediaElement)
-        m_mediaElement->play();
+        m_mediaElement->play(m_mediaElement->processingUserGesture());
 }
 
 void FullscreenVideoController::pause()
 {
     if (m_mediaElement)
-        m_mediaElement->pause();
+        m_mediaElement->pause(m_mediaElement->processingUserGesture());
 }
 
 float FullscreenVideoController::volume() const

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list