Title: [209733] trunk/Source
Revision
209733
Author
[email protected]
Date
2016-12-12 15:27:13 -0800 (Mon, 12 Dec 2016)

Log Message

Document.visibilityState should use an IDL string enumeration
https://bugs.webkit.org/show_bug.cgi?id=165774

Reviewed by Daniel Bates.

Source/WebCore:

Document.visibilityState should use an IDL string enumeration:
- http://w3c.github.io/page-visibility/#extensions-to-the-document-interface

No new tests, there should be no Web-exposed behavior change.

* CMakeLists.txt:
* Modules/vibration/NavigatorVibration.cpp:
(WebCore::NavigatorVibration::vibrate):
* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::Document::hidden):
(WebCore::Document::pageVisibilityState): Deleted.
(WebCore::Document::visibilityState): Deleted.
* dom/Document.h:
* dom/Document.idl:
* page/Page.cpp:
(WebCore::Page::visibilityState):
* page/PageVisibilityState.cpp: Removed.
* page/PageVisibilityState.h:
(): Deleted.

Source/WebKit/mac:

* DOM/DOMDocument.mm:
(-[DOMDocument visibilityState]):
* WebView/WebView.mm:
(kit):

Source/WebKit2:

* Shared/API/c/WKSharedAPICast.h:
(WebKit::toPageVisibilityState):

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (209732 => 209733)


--- trunk/Source/WebCore/CMakeLists.txt	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-12-12 23:27:13 UTC (rev 209733)
@@ -2056,7 +2056,6 @@
     page/PageOverlay.cpp
     page/PageOverlayController.cpp
     page/PageSerializer.cpp
-    page/PageVisibilityState.cpp
     page/Performance.cpp
     page/PerformanceEntry.cpp
     page/PerformanceLogging.cpp

Modified: trunk/Source/WebCore/ChangeLog (209732 => 209733)


--- trunk/Source/WebCore/ChangeLog	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebCore/ChangeLog	2016-12-12 23:27:13 UTC (rev 209733)
@@ -1,3 +1,31 @@
+2016-12-12  Chris Dumez  <[email protected]>
+
+        Document.visibilityState should use an IDL string enumeration
+        https://bugs.webkit.org/show_bug.cgi?id=165774
+
+        Reviewed by Daniel Bates.
+
+        Document.visibilityState should use an IDL string enumeration:
+        - http://w3c.github.io/page-visibility/#extensions-to-the-document-interface
+
+        No new tests, there should be no Web-exposed behavior change.
+
+        * CMakeLists.txt:
+        * Modules/vibration/NavigatorVibration.cpp:
+        (WebCore::NavigatorVibration::vibrate):
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/Document.cpp:
+        (WebCore::Document::hidden):
+        (WebCore::Document::pageVisibilityState): Deleted.
+        (WebCore::Document::visibilityState): Deleted.
+        * dom/Document.h:
+        * dom/Document.idl:
+        * page/Page.cpp:
+        (WebCore::Page::visibilityState):
+        * page/PageVisibilityState.cpp: Removed.
+        * page/PageVisibilityState.h:
+        (): Deleted.
+
 2016-12-12  Jer Noble  <[email protected]>
 
         Remove implementation of legacy Mozilla-based Fullscreen API.

Modified: trunk/Source/WebCore/Modules/vibration/NavigatorVibration.cpp (209732 => 209733)


--- trunk/Source/WebCore/Modules/vibration/NavigatorVibration.cpp	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebCore/Modules/vibration/NavigatorVibration.cpp	2016-12-12 23:27:13 UTC (rev 209733)
@@ -48,7 +48,7 @@
     if (!navigator.frame()->page())
         return false;
 
-    if (navigator.frame()->page()->visibilityState() == PageVisibilityStateHidden)
+    if (navigator.frame()->page()->visibilityState() == PageVisibilityState::Hidden)
         return false;
 
     return Vibration::from(navigator.frame()->page())->vibrate(pattern);

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (209732 => 209733)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-12-12 23:27:13 UTC (rev 209733)
@@ -6859,7 +6859,6 @@
 		FFAC30FF184FB145008C4F1E /* TrailingObjects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FFAC30FD184FB145008C4F1E /* TrailingObjects.cpp */; };
 		FFB698CC1833EE0D00158A31 /* LineBreaker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FFB698CA1833EC3800158A31 /* LineBreaker.cpp */; };
 		FFB698CF183402BB00158A31 /* LineInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FFB698CD1833F17600158A31 /* LineInfo.cpp */; };
-		FFD5B97A135CC97800D5E92A /* PageVisibilityState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FFD5B977135CC97800D5E92A /* PageVisibilityState.cpp */; };
 		FFD5B97B135CC97800D5E92A /* PageVisibilityState.h in Headers */ = {isa = PBXBuildFile; fileRef = FFD5B978135CC97800D5E92A /* PageVisibilityState.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		FFDBC047183D27B700407109 /* LineWidth.h in Headers */ = {isa = PBXBuildFile; fileRef = FFDBC045183D27B700407109 /* LineWidth.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		FFDBC048183D27B700407109 /* LineWidth.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FFDBC046183D27B700407109 /* LineWidth.cpp */; };
@@ -14921,7 +14920,6 @@
 		FFB698CB1833EC3800158A31 /* LineBreaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineBreaker.h; sourceTree = "<group>"; };
 		FFB698CD1833F17600158A31 /* LineInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LineInfo.cpp; sourceTree = "<group>"; };
 		FFB698CE1833F17600158A31 /* LineInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineInfo.h; sourceTree = "<group>"; };
-		FFD5B977135CC97800D5E92A /* PageVisibilityState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageVisibilityState.cpp; sourceTree = "<group>"; };
 		FFD5B978135CC97800D5E92A /* PageVisibilityState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageVisibilityState.h; sourceTree = "<group>"; };
 		FFDBC045183D27B700407109 /* LineWidth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineWidth.h; sourceTree = "<group>"; };
 		FFDBC046183D27B700407109 /* LineWidth.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LineWidth.cpp; sourceTree = "<group>"; };
@@ -17923,7 +17921,6 @@
 				2D5C9CFE19C7B52E00B3C5C1 /* PageOverlayController.h */,
 				371E65CD13661EED00BEEDB0 /* PageSerializer.cpp */,
 				371E65CB13661EDC00BEEDB0 /* PageSerializer.h */,
-				FFD5B977135CC97800D5E92A /* PageVisibilityState.cpp */,
 				FFD5B978135CC97800D5E92A /* PageVisibilityState.h */,
 				E526AF3E1727F8F200E41781 /* Performance.cpp */,
 				8A844D0211D3C18E0014065C /* Performance.h */,
@@ -30740,7 +30737,6 @@
 				371E65CE13661EED00BEEDB0 /* PageSerializer.cpp in Sources */,
 				E1284AEA10447DEE00EAEB52 /* PageTransitionEvent.cpp in Sources */,
 				51E1ECC20C91C90400DC255B /* PageURLRecord.cpp in Sources */,
-				FFD5B97A135CC97800D5E92A /* PageVisibilityState.cpp in Sources */,
 				FD3160A212B026F700C1A359 /* Panner.cpp in Sources */,
 				FD31601912B0267600C1A359 /* PannerNode.cpp in Sources */,
 				A18890AE1AA13F250026C301 /* ParentalControlsContentFilter.mm in Sources */,

Modified: trunk/Source/WebCore/dom/Document.cpp (209732 => 209733)


--- trunk/Source/WebCore/dom/Document.cpp	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-12-12 23:27:13 UTC (rev 209733)
@@ -1622,7 +1622,7 @@
         element->visibilityStateChanged();
 }
 
-PageVisibilityState Document::pageVisibilityState() const
+auto Document::visibilityState() const -> VisibilityState
 {
     // The visibility of the document is inherited from the visibility of the
     // page. If there is no page associated with the document, we will assume
@@ -1629,18 +1629,13 @@
     // that the page is hidden, as specified by the spec:
     // http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html#dom-document-hidden
     if (!m_frame || !m_frame->page())
-        return PageVisibilityStateHidden;
+        return VisibilityState::Hidden;
     return m_frame->page()->visibilityState();
 }
 
-String Document::visibilityState() const
-{
-    return pageVisibilityStateString(pageVisibilityState());
-}
-
 bool Document::hidden() const
 {
-    return pageVisibilityState() != PageVisibilityStateVisible;
+    return visibilityState() != VisibilityState::Visible;
 }
 
 #if ENABLE(VIDEO)

Modified: trunk/Source/WebCore/dom/Document.h (209732 => 209733)


--- trunk/Source/WebCore/dom/Document.h	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebCore/dom/Document.h	2016-12-12 23:27:13 UTC (rev 209733)
@@ -444,8 +444,9 @@
     void setInputCursor(Ref<JSC::InputCursor>&&);
 #endif
 
+    using VisibilityState = PageVisibilityState;
+    WEBCORE_EXPORT VisibilityState visibilityState() const;
     void visibilityStateChanged();
-    WEBCORE_EXPORT String visibilityState() const;
     WEBCORE_EXPORT bool hidden() const;
 
     void setTimerThrottlingEnabled(bool);
@@ -1356,8 +1357,6 @@
     template <typename CharacterType>
     void displayBufferModifiedByEncodingInternal(CharacterType*, unsigned) const;
 
-    PageVisibilityState pageVisibilityState() const;
-
     template <CollectionType collectionType>
     Ref<HTMLCollection> ensureCachedCollection();
 

Modified: trunk/Source/WebCore/dom/Document.idl (209732 => 209733)


--- trunk/Source/WebCore/dom/Document.idl	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebCore/dom/Document.idl	2016-12-12 23:27:13 UTC (rev 209733)
@@ -170,8 +170,10 @@
 #endif
 
     // Page visibility API.
-    readonly attribute DOMString visibilityState;
+    readonly attribute VisibilityState visibilityState;
     readonly attribute boolean hidden;
+    // FIXME: We should implement this.
+    // attribute EventHandler onvisibilitychange;
 
     // currentscript API: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#dom-document-currentscript
     readonly attribute HTMLScriptElement? currentScript;
@@ -205,6 +207,12 @@
     [NotEnumerable, Conditional=POINTER_LOCK] attribute EventHandler onpointerlockerror;
 };
 
+enum VisibilityState {
+    "hidden",
+    "visible",
+    "prerender"
+};
+
 Document implements ParentNode;
 Document implements NonElementParentNode;
 Document implements DocumentOrShadowRoot;

Modified: trunk/Source/WebCore/page/Page.cpp (209732 => 209733)


--- trunk/Source/WebCore/page/Page.cpp	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebCore/page/Page.cpp	2016-12-12 23:27:13 UTC (rev 209733)
@@ -1534,10 +1534,10 @@
 PageVisibilityState Page::visibilityState() const
 {
     if (isVisible())
-        return PageVisibilityStateVisible;
+        return PageVisibilityState::Visible;
     if (m_isPrerender)
-        return PageVisibilityStatePrerender;
-    return PageVisibilityStateHidden;
+        return PageVisibilityState::Prerender;
+    return PageVisibilityState::Hidden;
 }
 
 #if ENABLE(RUBBER_BANDING)

Deleted: trunk/Source/WebCore/page/PageVisibilityState.cpp (209732 => 209733)


--- trunk/Source/WebCore/page/PageVisibilityState.cpp	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebCore/page/PageVisibilityState.cpp	2016-12-12 23:27:13 UTC (rev 209733)
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PageVisibilityState.h"
-
-#include <wtf/NeverDestroyed.h>
-
-namespace WebCore {
-
-String pageVisibilityStateString(PageVisibilityState state)
-{
-    static NeverDestroyed<const String> visible(ASCIILiteral("visible"));
-    static NeverDestroyed<const String> hidden(ASCIILiteral("hidden"));
-    static NeverDestroyed<const String> prerender(ASCIILiteral("prerender"));
-
-    switch (state) {
-    case PageVisibilityStateVisible:
-        return visible;
-    case PageVisibilityStateHidden:
-        return hidden;
-    case PageVisibilityStatePrerender:
-        return prerender;
-    }
-
-    ASSERT_NOT_REACHED();
-    return String();
-}
-
-} // namespace WebCore

Modified: trunk/Source/WebCore/page/PageVisibilityState.h (209732 => 209733)


--- trunk/Source/WebCore/page/PageVisibilityState.h	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebCore/page/PageVisibilityState.h	2016-12-12 23:27:13 UTC (rev 209733)
@@ -34,14 +34,10 @@
 
 namespace WebCore {
 
-// The enum is not flag protected as it is used in the WebKit chromium API
-// without flag protection.
-enum PageVisibilityState {
-    PageVisibilityStateVisible,
-    PageVisibilityStateHidden,
-    PageVisibilityStatePrerender
+enum class PageVisibilityState {
+    Hidden,
+    Visible,
+    Prerender
 };
 
-String pageVisibilityStateString(PageVisibilityState);
-
 } // namespace WebCore

Modified: trunk/Source/WebKit/mac/ChangeLog (209732 => 209733)


--- trunk/Source/WebKit/mac/ChangeLog	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-12-12 23:27:13 UTC (rev 209733)
@@ -1,3 +1,15 @@
+2016-12-12  Chris Dumez  <[email protected]>
+
+        Document.visibilityState should use an IDL string enumeration
+        https://bugs.webkit.org/show_bug.cgi?id=165774
+
+        Reviewed by Daniel Bates.
+
+        * DOM/DOMDocument.mm:
+        (-[DOMDocument visibilityState]):
+        * WebView/WebView.mm:
+        (kit):
+
 2016-12-12  Jer Noble  <[email protected]>
 
         Remove implementation of legacy Mozilla-based Fullscreen API.

Modified: trunk/Source/WebKit/mac/DOM/DOMDocument.mm (209732 => 209733)


--- trunk/Source/WebKit/mac/DOM/DOMDocument.mm	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebKit/mac/DOM/DOMDocument.mm	2016-12-12 23:27:13 UTC (rev 209733)
@@ -381,7 +381,14 @@
 - (NSString *)visibilityState
 {
     WebCore::JSMainThreadNullState state;
-    return IMPL->visibilityState();
+    switch (IMPL->visibilityState()) {
+    case WebCore::Document::VisibilityState::Hidden:
+        return @"hidden";
+    case WebCore::Document::VisibilityState::Visible:
+        return @"visible";
+    case WebCore::Document::VisibilityState::Prerender:
+        return @"prerender";
+    }
 }
 
 - (BOOL)hidden

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (209732 => 209733)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2016-12-12 23:27:13 UTC (rev 209733)
@@ -569,11 +569,11 @@
 static WebPageVisibilityState kit(PageVisibilityState visibilityState)
 {
     switch (visibilityState) {
-    case PageVisibilityStateVisible:
+    case PageVisibilityState::Visible:
         return WebPageVisibilityStateVisible;
-    case PageVisibilityStateHidden:
+    case PageVisibilityState::Hidden:
         return WebPageVisibilityStateHidden;
-    case PageVisibilityStatePrerender:
+    case PageVisibilityState::Prerender:
         return WebPageVisibilityStatePrerender;
     }
 

Modified: trunk/Source/WebKit2/ChangeLog (209732 => 209733)


--- trunk/Source/WebKit2/ChangeLog	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebKit2/ChangeLog	2016-12-12 23:27:13 UTC (rev 209733)
@@ -1,3 +1,13 @@
+2016-12-12  Chris Dumez  <[email protected]>
+
+        Document.visibilityState should use an IDL string enumeration
+        https://bugs.webkit.org/show_bug.cgi?id=165774
+
+        Reviewed by Daniel Bates.
+
+        * Shared/API/c/WKSharedAPICast.h:
+        (WebKit::toPageVisibilityState):
+
 2016-12-11  Konstantin Tokarev  <[email protected]>
 
         Unreviewed attempt to fix EFL and Mac/cmake builds after r209665.

Modified: trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h (209732 => 209733)


--- trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h	2016-12-12 23:25:45 UTC (rev 209732)
+++ trunk/Source/WebKit2/Shared/API/c/WKSharedAPICast.h	2016-12-12 23:27:13 UTC (rev 209733)
@@ -903,15 +903,15 @@
 {
     switch (wkPageVisibilityState) {
     case kWKPageVisibilityStateVisible:
-        return WebCore::PageVisibilityStateVisible;
+        return WebCore::PageVisibilityState::Visible;
     case kWKPageVisibilityStateHidden:
-        return WebCore::PageVisibilityStateHidden;
+        return WebCore::PageVisibilityState::Hidden;
     case kWKPageVisibilityStatePrerender:
-        return WebCore::PageVisibilityStatePrerender;
+        return WebCore::PageVisibilityState::Prerender;
     }
 
     ASSERT_NOT_REACHED();
-    return WebCore::PageVisibilityStateVisible;
+    return WebCore::PageVisibilityState::Visible;
 }
 
 inline ImageOptions toImageOptions(WKImageOptions wkImageOptions)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to