Skip to content

Commit

Permalink
Source/WebCore: Add support for consumable user gestures
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=94867

Reviewed by Adam Barth.

Adds a static counter of the number of consumable gestures. This is decremented either when
a gestures falls out of scope or is consumed via a call to consumeUserGesture().

Planned usage in Chromium is to prevent the piggybacking of multiple popup windows on a
single user gesture.

No new tests as this should not change behavior. The platform must implement consumable
gestures for this to do anything.

* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::consumeUserGesture):
(WebCore):
* bindings/v8/ScriptController.h:
(ScriptController):
* dom/UserGestureIndicator.cpp:
(WebCore):
(WebCore::UserGestureIndicator::UserGestureIndicator):
(WebCore::UserGestureIndicator::~UserGestureIndicator):
(WebCore::UserGestureIndicator::consumeUserGesture):
* dom/UserGestureIndicator.h:
(WebCore::UserGestureIndicator::processingUserGesture):
(UserGestureIndicator):

Source/WebKit/chromium: Plumb consumeUserGesture() to the chromium platform layer.
https://bugs.webkit.org/show_bug.cgi?id=9475294867

Reviewed by Adam Barth.

* public/WebFrame.h:
(WebFrame):
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::consumeUserGesture):
(WebKit):
* src/WebFrameImpl.h:
(WebFrameImpl):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@126609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Cris Neckar committed Aug 24, 2012
1 parent d91b10f commit d038605
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 1 deletion.
30 changes: 30 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
2012-08-24 Cris Neckar <cdn@chromium.org>

Add support for consumable user gestures
https://bugs.webkit.org/show_bug.cgi?id=94867

Reviewed by Adam Barth.

Adds a static counter of the number of consumable gestures. This is decremented either when
a gestures falls out of scope or is consumed via a call to consumeUserGesture().

Planned usage in Chromium is to prevent the piggybacking of multiple popup windows on a
single user gesture.

No new tests as this should not change behavior. The platform must implement consumable
gestures for this to do anything.

* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::consumeUserGesture):
(WebCore):
* bindings/v8/ScriptController.h:
(ScriptController):
* dom/UserGestureIndicator.cpp:
(WebCore):
(WebCore::UserGestureIndicator::UserGestureIndicator):
(WebCore::UserGestureIndicator::~UserGestureIndicator):
(WebCore::UserGestureIndicator::consumeUserGesture):
* dom/UserGestureIndicator.h:
(WebCore::UserGestureIndicator::processingUserGesture):
(UserGestureIndicator):

2012-08-24 Bear Travis <betravis@adobe.com>

[CSS Exclusions] Enable shape-inside for simple rectangles
Expand Down
14 changes: 14 additions & 0 deletions Source/WebCore/dom/UserGestureIndicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,34 @@ static bool isDefinite(ProcessingUserGestureState state)
}

ProcessingUserGestureState UserGestureIndicator::s_state = DefinitelyNotProcessingUserGesture;
size_t UserGestureIndicator::s_consumableGestures = 0;

UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state)
: m_previousState(s_state)
{
// We overwrite s_state only if the caller is definite about the gesture state.
if (isDefinite(state))
s_state = state;

if (s_state == DefinitelyProcessingUserGesture)
s_consumableGestures++;
ASSERT(isDefinite(s_state));
}

UserGestureIndicator::~UserGestureIndicator()
{
if (s_consumableGestures && s_state == DefinitelyProcessingUserGesture)
s_consumableGestures--;
s_state = m_previousState;
ASSERT(isDefinite(s_state));
}

bool UserGestureIndicator::consumeUserGesture()
{
if (!s_consumableGestures)
return false;
s_consumableGestures--;
return true;
}

}
4 changes: 3 additions & 1 deletion Source/WebCore/dom/UserGestureIndicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ enum ProcessingUserGestureState {
class UserGestureIndicator {
WTF_MAKE_NONCOPYABLE(UserGestureIndicator);
public:
static bool processingUserGesture() { return s_state == DefinitelyProcessingUserGesture; }
static bool processingUserGesture() { return s_consumableGestures && s_state == DefinitelyProcessingUserGesture; }
static bool consumeUserGesture();

explicit UserGestureIndicator(ProcessingUserGestureState);
~UserGestureIndicator();

private:
static ProcessingUserGestureState s_state;
static size_t s_consumableGestures;
ProcessingUserGestureState m_previousState;
};

Expand Down
15 changes: 15 additions & 0 deletions Source/WebKit/chromium/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2012-08-24 Cris Neckar <cdn@chromium.org>

Plumb consumeUserGesture() to the chromium platform layer.
https://bugs.webkit.org/show_bug.cgi?id=9475294867

Reviewed by Adam Barth.

* public/WebFrame.h:
(WebFrame):
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::consumeUserGesture):
(WebKit):
* src/WebFrameImpl.h:
(WebFrameImpl):

2012-08-24 W. James MacLean <wjmaclean@chromium.org>

[chromium] gestureTapDown should not select a RenderView node as target.
Expand Down
3 changes: 3 additions & 0 deletions Source/WebKit/chromium/public/WebFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ class WebFrame {
// Returns true if a user gesture is currently being processed.
virtual bool isProcessingUserGesture() const = 0;

// Returns true if a consumable gesture exists and has been successfully consumed.
virtual bool consumeUserGesture() const = 0;

// Returns true if this frame is in the process of opening a new frame
// with a suppressed opener.
virtual bool willSuppressOpenerInNewFrame() const = 0;
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit/chromium/src/WebFrameImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,11 @@ bool WebFrameImpl::isProcessingUserGesture() const
return ScriptController::processingUserGesture();
}

bool WebFrameImpl::consumeUserGesture() const
{
return UserGestureIndicator::consumeUserGesture();
}

bool WebFrameImpl::willSuppressOpenerInNewFrame() const
{
return frame()->loader()->suppressOpenerInNewFrame();
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/chromium/src/WebFrameImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class WebFrameImpl : public WebFrame, public RefCounted<WebFrameImpl> {
virtual void commitDocumentData(const char* data, size_t length);
virtual unsigned unloadListenerCount() const;
virtual bool isProcessingUserGesture() const;
virtual bool consumeUserGesture() const;
virtual bool willSuppressOpenerInNewFrame() const;
virtual void replaceSelection(const WebString&);
virtual void insertText(const WebString&);
Expand Down

0 comments on commit d038605

Please sign in to comment.