Title: [94196] trunk/Source/WebCore
Revision
94196
Author
eric.carl...@apple.com
Date
2011-08-31 09:31:24 -0700 (Wed, 31 Aug 2011)

Log Message

Clean up HTMLMediaElement behavior restrictions
https://bugs.webkit.org/show_bug.cgi?id=67231

Reviewed by Darin Adler.

No new tests, cleanup only.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Deal with enum and function renaming.
(WebCore::HTMLMediaElement::load): Call userGestureRequiredForLoad() instead of testing bits
    directly.
(WebCore::HTMLMediaElement::loadInternal): Deal with enum and function renaming.
(WebCore::HTMLMediaElement::play): Call userGestureRequiredForRateChange() instead of testing bits
    directly.
(WebCore::HTMLMediaElement::pause): Ditto.
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::userGestureRequiredForLoad): Renamed.
(WebCore::HTMLMediaElement::userGestureRequiredForRateChange):
(WebCore::HTMLMediaElement::userGestureRequiredForFullscreen):
(WebCore::HTMLMediaElement::pageConsentRequiredForLoad):
(WebCore::HTMLMediaElement::addBehaviorRestriction):
(WebCore::HTMLMediaElement::removeBehaviorRestriction):

* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::webkitEnterFullscreen): requireUserGestureForFullScreen renamed to
    userGestureRequiredForFullscreen.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (94195 => 94196)


--- trunk/Source/WebCore/ChangeLog	2011-08-31 16:20:20 UTC (rev 94195)
+++ trunk/Source/WebCore/ChangeLog	2011-08-31 16:31:24 UTC (rev 94196)
@@ -1,3 +1,32 @@
+2011-08-31  Eric Carlson  <eric.carl...@apple.com>
+
+        Clean up HTMLMediaElement behavior restrictions
+        https://bugs.webkit.org/show_bug.cgi?id=67231
+
+        Reviewed by Darin Adler.
+
+        No new tests, cleanup only.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement): Deal with enum and function renaming.
+        (WebCore::HTMLMediaElement::load): Call userGestureRequiredForLoad() instead of testing bits
+            directly.
+        (WebCore::HTMLMediaElement::loadInternal): Deal with enum and function renaming.
+        (WebCore::HTMLMediaElement::play): Call userGestureRequiredForRateChange() instead of testing bits
+            directly.
+        (WebCore::HTMLMediaElement::pause): Ditto.
+        * html/HTMLMediaElement.h:
+        (WebCore::HTMLMediaElement::userGestureRequiredForLoad): Renamed.
+        (WebCore::HTMLMediaElement::userGestureRequiredForRateChange):
+        (WebCore::HTMLMediaElement::userGestureRequiredForFullscreen):
+        (WebCore::HTMLMediaElement::pageConsentRequiredForLoad):
+        (WebCore::HTMLMediaElement::addBehaviorRestriction):
+        (WebCore::HTMLMediaElement::removeBehaviorRestriction):
+
+        * html/HTMLVideoElement.cpp:
+        (WebCore::HTMLVideoElement::webkitEnterFullscreen): requireUserGestureForFullScreen renamed to
+            userGestureRequiredForFullscreen.
+
 2011-08-31  Andrei Popescu  <andr...@google.com>
 
         Investigate current uses of OS(ANDROID)

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (94195 => 94196)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2011-08-31 16:20:20 UTC (rev 94195)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2011-08-31 16:31:24 UTC (rev 94196)
@@ -161,7 +161,7 @@
 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
     , m_proxyWidget(0)
 #endif
-    , m_restrictions(RequireUserGestureForFullScreenRestriction | RequirePageConsentToLoadMedia)
+    , m_restrictions(RequireUserGestureForFullscreenRestriction | RequirePageConsentToLoadMediaRestriction)
     , m_preload(MediaPlayer::Auto)
     , m_displayMode(Unknown)
     , m_processingMediaPlayerCallback(0)
@@ -203,7 +203,7 @@
     document->registerForPrivateBrowsingStateChangedCallbacks(this);
     
     if (document->settings() && document->settings()->mediaPlaybackRequiresUserGesture())
-        m_restrictions |= RequireUserGestureForRateChangeRestriction;
+        addBehaviorRestriction(RequireUserGestureForRateChangeRestriction);
 
 #if ENABLE(MEDIA_SOURCE)
     m_mediaSourceURL.setProtocol(mediaSourceURLProtocol);
@@ -515,7 +515,7 @@
 {
     LOG(Media, "HTMLMediaElement::load()");
 
-    if (m_restrictions & RequireUserGestureForLoadRestriction && !ScriptController::processingUserGesture())
+    if (userGestureRequiredForLoad() && !ScriptController::processingUserGesture())
         ec = INVALID_STATE_ERR;
     else {
         m_loadInitiatedByUserGesture = ScriptController::processingUserGesture();
@@ -611,7 +611,7 @@
 {
     // If we can't start a load right away, start it later.
     Page* page = document()->page();
-    if (requirePageConsentToLoadMedia() && page && !page->canStartMedia()) {
+    if (pageConsentRequiredForLoad() && page && !page->canStartMedia()) {
         if (m_isWaitingUntilMediaCanStart)
             return;
         document()->addMediaCanStartListener(this);
@@ -622,7 +622,7 @@
     // Once the page has allowed an element to load media, it is free to load at will. This allows a 
     // playlist that starts in a foreground tab to continue automatically if the tab is subsequently 
     // put in the the background.
-    removeBehaviorRestriction(RequirePageConsentToLoadMedia);
+    removeBehaviorRestriction(RequirePageConsentToLoadMediaRestriction);
 
     selectMediaResource();
 #if ENABLE(VIDEO_TRACK)
@@ -1567,7 +1567,7 @@
 {
     LOG(Media, "HTMLMediaElement::play()");
 
-    if (m_restrictions & RequireUserGestureForRateChangeRestriction && !ScriptController::processingUserGesture())
+    if (userGestureRequiredForRateChange() && !ScriptController::processingUserGesture())
         return;
 
     Settings* settings = document()->settings();
@@ -1615,7 +1615,7 @@
 {
     LOG(Media, "HTMLMediaElement::pause()");
 
-    if (m_restrictions & RequireUserGestureForRateChangeRestriction && !ScriptController::processingUserGesture())
+    if (userGestureRequiredForRateChange() && !ScriptController::processingUserGesture())
         return;
 
     pauseInternal();

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (94195 => 94196)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2011-08-31 16:20:20 UTC (rev 94195)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2011-08-31 16:31:24 UTC (rev 94196)
@@ -195,23 +195,6 @@
 
     void privateBrowsingStateDidChange();
 
-    // Restrictions to change default behaviors.
-    enum BehaviorRestrictionFlags {
-        NoRestrictions = 0,
-        RequireUserGestureForLoadRestriction = 1 << 0,
-        RequireUserGestureForRateChangeRestriction = 1 << 1,
-        RequireUserGestureForFullScreenRestriction = 1 << 2,
-        RequirePageConsentToLoadMedia = 1 << 3,
-    };
-    typedef unsigned BehaviorRestrictions;
-    
-    bool requireUserGestureForLoad() const { return m_restrictions & RequireUserGestureForLoadRestriction; }
-    bool requireUserGestureForRateChange() const { return m_restrictions & RequireUserGestureForRateChangeRestriction; }
-    bool requireUserGestureForFullScreen() const { return m_restrictions & RequireUserGestureForFullScreenRestriction; }
-    bool requirePageConsentToLoadMedia() const { return m_restrictions & RequirePageConsentToLoadMedia; }
-
-    void setBehaviorRestrictions(BehaviorRestrictions restrictions) { m_restrictions = restrictions; }
-
     // Media cache management.
     static void getSitesInMediaCache(Vector<String>&);
     static void clearMediaCache();
@@ -243,6 +226,24 @@
     
     virtual bool isMediaElement() const { return true; }
 
+    // Restrictions to change default behaviors.
+    enum BehaviorRestrictionFlags {
+        NoRestrictions = 0,
+        RequireUserGestureForLoadRestriction = 1 << 0,
+        RequireUserGestureForRateChangeRestriction = 1 << 1,
+        RequireUserGestureForFullscreenRestriction = 1 << 2,
+        RequirePageConsentToLoadMediaRestriction = 1 << 3,
+    };
+    typedef unsigned BehaviorRestrictions;
+    
+    bool userGestureRequiredForLoad() const { return m_restrictions & RequireUserGestureForLoadRestriction; }
+    bool userGestureRequiredForRateChange() const { return m_restrictions & RequireUserGestureForRateChangeRestriction; }
+    bool userGestureRequiredForFullscreen() const { return m_restrictions & RequireUserGestureForFullscreenRestriction; }
+    bool pageConsentRequiredForLoad() const { return m_restrictions & RequirePageConsentToLoadMediaRestriction; }
+    
+    void addBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions |= restriction; }
+    void removeBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions &= ~restriction; }
+    
 private:
     void createMediaPlayer();
 
@@ -364,8 +365,6 @@
 
     virtual void mediaCanStart();
 
-    void removeBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions &= ~restriction; }
-
     void setShouldDelayLoadEvent(bool);
 
     void invalidateCachedTime();

Modified: trunk/Source/WebCore/html/HTMLVideoElement.cpp (94195 => 94196)


--- trunk/Source/WebCore/html/HTMLVideoElement.cpp	2011-08-31 16:20:20 UTC (rev 94195)
+++ trunk/Source/WebCore/html/HTMLVideoElement.cpp	2011-08-31 16:31:24 UTC (rev 94196)
@@ -247,7 +247,7 @@
 
     // Generate an exception if this isn't called in response to a user gesture, or if the 
     // element does not support fullscreen.
-    if ((requireUserGestureForFullScreen() && !ScriptController::processingUserGesture()) || !supportsFullscreen()) {
+    if ((userGestureRequiredForFullscreen() && !ScriptController::processingUserGesture()) || !supportsFullscreen()) {
         ec = INVALID_STATE_ERR;
         return;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to