Title: [147554] trunk/Source/WebCore
Revision
147554
Author
kei...@webkit.org
Date
2013-04-03 08:04:28 -0700 (Wed, 03 Apr 2013)

Log Message

Actions that require user gesture don't work in window.showModalDialog in Chromium
https://bugs.webkit.org/show_bug.cgi?id=113777

Reviewed by Jochen Eisinger.

In Chromium the window for showModalDialog is not modal which causes the
UserGestureIndicator to block actions in the sub window. We introduce a
RAII that saves the UserGestureIndicator and state, then resets it before
runModalDialog, and restore it when it's done.

No new tests. Can't cause user gesture inside modal dialog.

* dom/UserGestureIndicator.cpp:
(WebCore::UserGestureIndicatorDisabler::UserGestureIndicatorDisabler): Saves and resets the topmost indicator and state.
(WebCore):
(WebCore::UserGestureIndicatorDisabler::~UserGestureIndicatorDisabler): Restores topmost indicator and state.
* dom/UserGestureIndicator.h:
(WebCore):
(UserGestureIndicatorDisabler): RAII to temporarily disable UserGestureIndicator.
(UserGestureIndicator): Allow access to UserGestureIndicatorDisabler.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::showModalDialog): Disable UserGestureIndicator while runModalDialog.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (147553 => 147554)


--- trunk/Source/WebCore/ChangeLog	2013-04-03 15:02:37 UTC (rev 147553)
+++ trunk/Source/WebCore/ChangeLog	2013-04-03 15:04:28 UTC (rev 147554)
@@ -1,3 +1,28 @@
+2013-04-03  Keishi Hattori  <kei...@webkit.org>
+
+        Actions that require user gesture don't work in window.showModalDialog in Chromium
+        https://bugs.webkit.org/show_bug.cgi?id=113777
+
+        Reviewed by Jochen Eisinger.
+
+        In Chromium the window for showModalDialog is not modal which causes the
+        UserGestureIndicator to block actions in the sub window. We introduce a
+        RAII that saves the UserGestureIndicator and state, then resets it before
+        runModalDialog, and restore it when it's done.
+
+        No new tests. Can't cause user gesture inside modal dialog.
+
+        * dom/UserGestureIndicator.cpp:
+        (WebCore::UserGestureIndicatorDisabler::UserGestureIndicatorDisabler): Saves and resets the topmost indicator and state.
+        (WebCore):
+        (WebCore::UserGestureIndicatorDisabler::~UserGestureIndicatorDisabler): Restores topmost indicator and state.
+        * dom/UserGestureIndicator.h:
+        (WebCore):
+        (UserGestureIndicatorDisabler): RAII to temporarily disable UserGestureIndicator.
+        (UserGestureIndicator): Allow access to UserGestureIndicatorDisabler.
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::showModalDialog): Disable UserGestureIndicator while runModalDialog.
+
 2013-04-03  Zeno Albisser  <z...@webkit.org>
 
         [Qt] Fail gracefully if an OpenGL context could not be created.

Modified: trunk/Source/WebCore/dom/UserGestureIndicator.cpp (147553 => 147554)


--- trunk/Source/WebCore/dom/UserGestureIndicator.cpp	2013-04-03 15:02:37 UTC (rev 147553)
+++ trunk/Source/WebCore/dom/UserGestureIndicator.cpp	2013-04-03 15:04:28 UTC (rev 147554)
@@ -130,4 +130,18 @@
     return s_topmostIndicator->m_token.get();
 }
 
+UserGestureIndicatorDisabler::UserGestureIndicatorDisabler()
+    : m_savedState(UserGestureIndicator::s_state)
+    , m_savedIndicator(UserGestureIndicator::s_topmostIndicator)
+{
+    UserGestureIndicator::s_state = DefinitelyNotProcessingUserGesture;
+    UserGestureIndicator::s_topmostIndicator = 0;
 }
+
+UserGestureIndicatorDisabler::~UserGestureIndicatorDisabler()
+{
+    UserGestureIndicator::s_state = m_savedState;
+    UserGestureIndicator::s_topmostIndicator = m_savedIndicator;
+}
+
+}

Modified: trunk/Source/WebCore/dom/UserGestureIndicator.h (147553 => 147554)


--- trunk/Source/WebCore/dom/UserGestureIndicator.h	2013-04-03 15:02:37 UTC (rev 147553)
+++ trunk/Source/WebCore/dom/UserGestureIndicator.h	2013-04-03 15:04:28 UTC (rev 147554)
@@ -32,6 +32,8 @@
 
 namespace WebCore {
 
+class UserGestureIndicator;
+
 enum ProcessingUserGestureState {
     DefinitelyProcessingNewUserGesture,
     DefinitelyProcessingUserGesture,
@@ -45,9 +47,20 @@
     virtual bool hasGestures() const = 0;
 };
 
+class UserGestureIndicatorDisabler {
+    WTF_MAKE_NONCOPYABLE(UserGestureIndicatorDisabler);
+public:
+    UserGestureIndicatorDisabler();
+    ~UserGestureIndicatorDisabler();
 
+private:
+    ProcessingUserGestureState m_savedState;
+    UserGestureIndicator* m_savedIndicator;
+};
+
 class UserGestureIndicator {
     WTF_MAKE_NONCOPYABLE(UserGestureIndicator);
+    friend class UserGestureIndicatorDisabler;
 public:
     static bool processingUserGesture();
     static bool consumeUserGesture();

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (147553 => 147554)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2013-04-03 15:02:37 UTC (rev 147553)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2013-04-03 15:04:28 UTC (rev 147554)
@@ -1998,7 +1998,7 @@
         activeWindow, firstFrame, m_frame, function, functionContext);
     if (!dialogFrame)
         return;
-
+    UserGestureIndicatorDisabler disabler;
     dialogFrame->page()->chrome()->runModal();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to