[WK2] Use is<>() / downcast<>() for DrawingAreaProxy subclasses
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Oct 2014 18:41:49 +0000 (18:41 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Oct 2014 18:41:49 +0000 (18:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137477

Reviewed by Andreas Kling.

Source/WebCore:

Include TypeCastsCF.h now that the header was renamed.

No new tests, no behavior change.

* platform/cf/SharedBufferCF.cpp:

Source/WebKit2:

Use is<>() / downcast<>() for DrawingAreaProxy subclasses.

* Shared/cf/KeyedDecoder.cpp:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _didCommitLoadForMainFrame]):
(-[WKWebView _restorePageStateToExposedRect:scale:]):
(-[WKWebView _restorePageStateToUnobscuredCenter:scale:]):
* UIProcess/Cocoa/WebPageProxyCocoa.mm:
* UIProcess/DrawingAreaProxy.h:
* UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::layerTreeHost):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::updateVisibleContentRects):
(WebKit::WebPageProxy::dynamicViewportUpdateChangedTarget):
* UIProcess/ios/WebVideoFullscreenManagerProxy.mm:
(WebKit::WebVideoFullscreenManagerProxy::setupFullscreenWithID):
* UIProcess/mac/LegacySessionStateCoding.cpp:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:

Source/WTF:

Rename wtf/cf/TypeCasts.h to wtf/cf/TypeCastsCF.h to avoid conflict
with wtf/TypeCasts.h. They were using the same #ifndef guard and it
was causing problems when both were included in the same context.

* WTF.xcodeproj/project.pbxproj:
* wtf/cf/TypeCastsCF.h: Renamed from Source/WTF/wtf/cf/TypeCasts.h.
(WTF::dynamic_cf_cast):
(WTF::checked_cf_cast):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174400 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
Source/WTF/ChangeLog
Source/WTF/WTF.xcodeproj/project.pbxproj
Source/WTF/wtf/cf/TypeCastsCF.h [moved from Source/WTF/wtf/cf/TypeCasts.h with 97% similarity]
Source/WebCore/ChangeLog
Source/WebCore/platform/cf/SharedBufferCF.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/cf/KeyedDecoder.cpp
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/Cocoa/WebPageProxyCocoa.mm
Source/WebKit2/UIProcess/DrawingAreaProxy.h
Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/UIProcess/ios/WebVideoFullscreenManagerProxy.mm
Source/WebKit2/UIProcess/mac/LegacySessionStateCoding.cpp
Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h
Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h

index 0164dcb..1854dae 100644 (file)
@@ -1,3 +1,19 @@
+2014-10-07  Christophe Dumez  <cdumez@apple.com>
+
+        [WK2] Use is<>() / downcast<>() for DrawingAreaProxy subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137477
+
+        Reviewed by Andreas Kling.
+
+        Rename wtf/cf/TypeCasts.h to wtf/cf/TypeCastsCF.h to avoid conflict
+        with wtf/TypeCasts.h. They were using the same #ifndef guard and it
+        was causing problems when both were included in the same context.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/cf/TypeCastsCF.h: Renamed from Source/WTF/wtf/cf/TypeCasts.h.
+        (WTF::dynamic_cf_cast):
+        (WTF::checked_cf_cast):
+
 2014-10-07  Anders Carlsson  <andersca@apple.com>
 
         Try to fix the Mountain Lion build.
index 138a140..512e0e2 100644 (file)
@@ -62,7 +62,7 @@
                1A6BB769162F300500DD16DB /* StreamBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6BB768162F300500DD16DB /* StreamBuffer.h */; };
                1A6EB1E0187D0BD30030126F /* StringView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6EB1DF187D0BD30030126F /* StringView.h */; };
                1ACADD841884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */; };
-               1AFDE648195201C300C48FFA /* TypeCasts.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFDE647195201C300C48FFA /* TypeCasts.h */; };
+               1AFDE648195201C300C48FFA /* TypeCastsCF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFDE647195201C300C48FFA /* TypeCastsCF.h */; };
                1AFDE6531953B23D00C48FFA /* Optional.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFDE6521953B23D00C48FFA /* Optional.h */; };
                1FA47C8A152502DA00568D1B /* WebCoreThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FA47C88152502DA00568D1B /* WebCoreThread.cpp */; };
                1FA47C8B152502DA00568D1B /* WebCoreThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FA47C89152502DA00568D1B /* WebCoreThread.h */; };
                1A6BB768162F300500DD16DB /* StreamBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamBuffer.h; sourceTree = "<group>"; };
                1A6EB1DF187D0BD30030126F /* StringView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringView.h; sourceTree = "<group>"; };
                1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeprecatedSymbolsUsedBySafari.mm; sourceTree = "<group>"; };
-               1AFDE647195201C300C48FFA /* TypeCasts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeCasts.h; sourceTree = "<group>"; };
+               1AFDE647195201C300C48FFA /* TypeCastsCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeCastsCF.h; sourceTree = "<group>"; };
                1AFDE6521953B23D00C48FFA /* Optional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Optional.h; sourceTree = "<group>"; };
                1FA47C88152502DA00568D1B /* WebCoreThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreThread.cpp; sourceTree = "<group>"; };
                1FA47C89152502DA00568D1B /* WebCoreThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreThread.h; sourceTree = "<group>"; };
                        isa = PBXGroup;
                        children = (
                                2CDED0EE18115C38004DBA70 /* RunLoopCF.cpp */,
-                               1AFDE647195201C300C48FFA /* TypeCasts.h */,
+                               1AFDE647195201C300C48FFA /* TypeCastsCF.h */,
                        );
                        path = cf;
                        sourceTree = "<group>";
                                A8A4741F151A825B004123FF /* SegmentedVector.h in Headers */,
                                A8A47420151A825B004123FF /* SentinelLinkedList.h in Headers */,
                                A8A47422151A825B004123FF /* SHA1.h in Headers */,
-                               1AFDE648195201C300C48FFA /* TypeCasts.h in Headers */,
+                               1AFDE648195201C300C48FFA /* TypeCastsCF.h in Headers */,
                                A8A47423151A825B004123FF /* SimpleStats.h in Headers */,
                                A8A47424151A825B004123FF /* SinglyLinkedList.h in Headers */,
                                A748745317A0BDAE00FA04CB /* SixCharacterHash.h in Headers */,
similarity index 97%
rename from Source/WTF/wtf/cf/TypeCasts.h
rename to Source/WTF/wtf/cf/TypeCastsCF.h
index 175ca4d..d525894 100644 (file)
@@ -23,8 +23,8 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TypeCasts_h
-#define TypeCasts_h
+#ifndef TypeCastsCF_h
+#define TypeCastsCF_h
 
 #include <CoreFoundation/CoreFoundation.h>
 #include <wtf/Assertions.h>
@@ -72,4 +72,4 @@ template<typename T> T checked_cf_cast(CFTypeRef object)
 using WTF::checked_cf_cast;
 using WTF::dynamic_cf_cast;
 
-#endif // TypeCasts_h
+#endif // TypeCastsCF_h
index e99bbb9..33dfbbe 100644 (file)
@@ -1,3 +1,16 @@
+2014-10-07  Christophe Dumez  <cdumez@apple.com>
+
+        [WK2] Use is<>() / downcast<>() for DrawingAreaProxy subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137477
+
+        Reviewed by Andreas Kling.
+
+        Include TypeCastsCF.h now that the header was renamed.
+
+        No new tests, no behavior change.
+
+        * platform/cf/SharedBufferCF.cpp:
+
 2014-10-07  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [SOUP] TLS errors should take precedence over HTTP authentication
index ac19870..567707b 100644 (file)
@@ -28,7 +28,7 @@
 #include "config.h"
 #include "SharedBuffer.h"
 
-#include <wtf/cf/TypeCasts.h>
+#include <wtf/cf/TypeCastsCF.h>
 
 namespace WebCore {
 
index 630f5ec..a498e7b 100644 (file)
@@ -1,3 +1,30 @@
+2014-10-07  Christophe Dumez  <cdumez@apple.com>
+
+        [WK2] Use is<>() / downcast<>() for DrawingAreaProxy subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=137477
+
+        Reviewed by Andreas Kling.
+
+        Use is<>() / downcast<>() for DrawingAreaProxy subclasses.
+
+        * Shared/cf/KeyedDecoder.cpp:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _didCommitLoadForMainFrame]):
+        (-[WKWebView _restorePageStateToExposedRect:scale:]):
+        (-[WKWebView _restorePageStateToUnobscuredCenter:scale:]):
+        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
+        * UIProcess/DrawingAreaProxy.h:
+        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
+        (WebKit::RemoteScrollingCoordinatorProxy::layerTreeHost):
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::updateVisibleContentRects):
+        (WebKit::WebPageProxy::dynamicViewportUpdateChangedTarget):
+        * UIProcess/ios/WebVideoFullscreenManagerProxy.mm:
+        (WebKit::WebVideoFullscreenManagerProxy::setupFullscreenWithID):
+        * UIProcess/mac/LegacySessionStateCoding.cpp:
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
+
 2014-10-06  Vivek Galatage  <vivek.vg@samsung.com>
 
         Remove unused warning in WebPageOverlay
index 4769226..2ba3fc1 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "KeyedDecoder.h"
 
-#include <wtf/cf/TypeCasts.h>
+#include <wtf/cf/TypeCastsCF.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebKit {
index 8af4a65..4588f48 100644 (file)
@@ -799,7 +799,7 @@ static WebCore::Color scrollViewBackgroundColor(WKWebView *webView)
 
 - (void)_didCommitLoadForMainFrame
 {
-    _firstPaintAfterCommitLoadTransactionID = toRemoteLayerTreeDrawingAreaProxy(_page->drawingArea())->nextLayerTreeTransactionID();
+    _firstPaintAfterCommitLoadTransactionID = downcast<RemoteLayerTreeDrawingAreaProxy>(*_page->drawingArea()).nextLayerTreeTransactionID();
 
     _hasCommittedLoadForMainFrame = YES;
     _needsResetViewStateAfterCommitLoadForMainFrame = YES;
@@ -935,7 +935,7 @@ static inline bool withinEpsilon(TypeA a, TypeB b)
 
     _needsToRestoreUnobscuredCenter = NO;
     _needsToRestoreExposedRect = YES;
-    _firstTransactionIDAfterPageRestore = toRemoteLayerTreeDrawingAreaProxy(_page->drawingArea())->nextLayerTreeTransactionID();
+    _firstTransactionIDAfterPageRestore = downcast<RemoteLayerTreeDrawingAreaProxy>(*_page->drawingArea()).nextLayerTreeTransactionID();
     _exposedRectToRestore = exposedRect;
     _scaleToRestore = scale;
 }
@@ -950,7 +950,7 @@ static inline bool withinEpsilon(TypeA a, TypeB b)
 
     _needsToRestoreExposedRect = NO;
     _needsToRestoreUnobscuredCenter = YES;
-    _firstTransactionIDAfterPageRestore = toRemoteLayerTreeDrawingAreaProxy(_page->drawingArea())->nextLayerTreeTransactionID();
+    _firstTransactionIDAfterPageRestore = downcast<RemoteLayerTreeDrawingAreaProxy>(*_page->drawingArea()).nextLayerTreeTransactionID();
     _unobscuredCenterToRestore = center;
     _scaleToRestore = scale;
 }
index 3824884..fca09c6 100644 (file)
@@ -26,7 +26,7 @@
 #import "config.h"
 #import "WebProcessProxy.h"
 
-#import <wtf/cf/TypeCasts.h>
+#import <wtf/cf/TypeCastsCF.h>
 
 namespace WebKit {
 
index 9b23764..bab8264 100644 (file)
@@ -37,6 +37,7 @@
 #include <stdint.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/RunLoop.h>
+#include <wtf/TypeCasts.h>
 
 namespace WebKit {
 
@@ -125,9 +126,11 @@ private:
 #endif
 };
 
-#define DRAWING_AREA_PROXY_TYPE_CASTS(ToValueTypeName, predicate) \
-    TYPE_CASTS_BASE(ToValueTypeName, DrawingAreaProxy, value, value->predicate, value.predicate)
-
 } // namespace WebKit
 
+#define SPECIALIZE_TYPE_TRAITS_DRAWING_AREA_PROXY(ToValueTypeName, ProxyType) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebKit::ToValueTypeName) \
+    static bool isType(const WebKit::DrawingAreaProxy& proxy) { return proxy.type() == WebKit::ProxyType; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
 #endif // DrawingAreaProxy_h
index 1526fde..19a0694 100644 (file)
@@ -69,13 +69,13 @@ ScrollingNodeID RemoteScrollingCoordinatorProxy::rootScrollingNodeID() const
 const RemoteLayerTreeHost* RemoteScrollingCoordinatorProxy::layerTreeHost() const
 {
     DrawingAreaProxy* drawingArea = m_webPageProxy.drawingArea();
-    if (!drawingArea || drawingArea->type() != DrawingAreaTypeRemoteLayerTree) {
+    if (!is<RemoteLayerTreeDrawingAreaProxy>(drawingArea)) {
         ASSERT_NOT_REACHED();
         return nullptr;
     }
 
-    RemoteLayerTreeDrawingAreaProxy* remoteDrawingArea = toRemoteLayerTreeDrawingAreaProxy(drawingArea);
-    return &remoteDrawingArea->remoteLayerTreeHost();
+    RemoteLayerTreeDrawingAreaProxy& remoteDrawingArea = downcast<RemoteLayerTreeDrawingAreaProxy>(*drawingArea);
+    return &remoteDrawingArea.remoteLayerTreeHost();
 }
 
 void RemoteScrollingCoordinatorProxy::updateScrollingTree(const RemoteScrollingCoordinatorTransaction& transaction, RequestedScrollInfo& requestedScrollInfo)
index f73f537..0ac86a1 100644 (file)
@@ -184,7 +184,7 @@ void WebPageProxy::updateVisibleContentRects(const WebCore::FloatRect& exposedRe
     if (!isValid())
         return;
 
-    VisibleContentRectUpdateInfo visibleContentRectUpdateInfo(exposedRect, unobscuredRect, unobscuredRectInScrollViewCoordinates, customFixedPositionRect, scale, inStableState, isChangingObscuredInsetsInteractively, timestamp, horizontalVelocity, verticalVelocity, scaleChangeRate, toRemoteLayerTreeDrawingAreaProxy(drawingArea())->lastCommittedLayerTreeTransactionID());
+    VisibleContentRectUpdateInfo visibleContentRectUpdateInfo(exposedRect, unobscuredRect, unobscuredRectInScrollViewCoordinates, customFixedPositionRect, scale, inStableState, isChangingObscuredInsetsInteractively, timestamp, horizontalVelocity, verticalVelocity, scaleChangeRate, downcast<RemoteLayerTreeDrawingAreaProxy>(*drawingArea()).lastCommittedLayerTreeTransactionID());
 
     if (visibleContentRectUpdateInfo == m_lastVisibleContentRectUpdate)
         return;
@@ -662,7 +662,7 @@ float WebPageProxy::textAutosizingWidth()
 void WebPageProxy::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition)
 {
     if (m_dynamicViewportSizeUpdateWaitingForTarget) {
-        m_dynamicViewportSizeUpdateLayerTreeTransactionID = toRemoteLayerTreeDrawingAreaProxy(drawingArea())->nextLayerTreeTransactionID();
+        m_dynamicViewportSizeUpdateLayerTreeTransactionID = downcast<RemoteLayerTreeDrawingAreaProxy>(*drawingArea()).nextLayerTreeTransactionID();
         m_dynamicViewportSizeUpdateWaitingForTarget = false;
         m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition, m_dynamicViewportSizeUpdateLayerTreeTransactionID);
     }
index 6ae1b02..ec7bfdb 100644 (file)
@@ -91,7 +91,7 @@ void WebVideoFullscreenManagerProxy::setupFullscreenWithID(uint32_t videoLayerID
         [m_layerHost setTransform:CATransform3DMakeScale(inverseScale, inverseScale, 1)];
     }
 
-    UIView *parentView = toRemoteLayerTreeDrawingAreaProxy(m_page->drawingArea())->remoteLayerTreeHost().rootLayer();
+    UIView *parentView = downcast<RemoteLayerTreeDrawingAreaProxy>(*m_page->drawingArea()).remoteLayerTreeHost().rootLayer();
     setupFullscreen(*m_layerHost.get(), initialRect, parentView);
 }
     
index 094e0d8..7dc6898 100644 (file)
@@ -30,7 +30,7 @@
 #include "SessionState.h"
 #include <mutex>
 #include <wtf/MallocPtr.h>
-#include <wtf/cf/TypeCasts.h>
+#include <wtf/cf/TypeCastsCF.h>
 #include <wtf/text/StringView.h>
 
 namespace WebKit {
index 7029c14..d874d6b 100644 (file)
@@ -108,8 +108,8 @@ private:
     RetainPtr<OneShotDisplayLinkHandler> m_displayLinkHandler;
 };
 
-DRAWING_AREA_PROXY_TYPE_CASTS(RemoteLayerTreeDrawingAreaProxy, type() == DrawingAreaTypeRemoteLayerTree);
-
 } // namespace WebKit
 
+SPECIALIZE_TYPE_TRAITS_DRAWING_AREA_PROXY(RemoteLayerTreeDrawingAreaProxy, DrawingAreaTypeRemoteLayerTree)
+
 #endif // RemoteLayerTreeDrawingAreaProxy_h
index 869f62e..50d93c9 100644 (file)
@@ -71,10 +71,10 @@ private:
     WebCore::IntSize m_lastSentMinimumLayoutSize;
 };
 
-DRAWING_AREA_PROXY_TYPE_CASTS(TiledCoreAnimationDrawingAreaProxy, type() == DrawingAreaTypeTiledCoreAnimation);
-
 } // namespace WebKit
 
+SPECIALIZE_TYPE_TRAITS_DRAWING_AREA_PROXY(TiledCoreAnimationDrawingAreaProxy, DrawingAreaTypeTiledCoreAnimation)
+
 #endif // !PLATFORM(IOS)
 
 #endif // TiledCoreAnimationDrawingAreaProxy_h