Pass the right color space over to the web process so we can set it on our CA context
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jun 2012 00:29:34 +0000 (00:29 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jun 2012 00:29:34 +0000 (00:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=88819
<rdar://problem/11629050>

Reviewed by John Sullivan.

Source/WebKit2:

* Platform/mac/LayerHostingContext.h:
(LayerHostingContext):
* Platform/mac/LayerHostingContext.mm:
(WebKit::LayerHostingContext::createForPort):
(WebKit::LayerHostingContext::createForWindowServer):
Use a single constructor and explicitly set up the parameters of the constructed object.

(WebKit::LayerHostingContext::setColorSpace):
(WebKit::LayerHostingContext::colorSpace):
Add getter and setter.

* Scripts/webkit2/messages.py:
(struct_or_class):
WebKit::ColorSpaceData is a struct.

* Shared/WebPageCreationParameters.cpp:
Encode and decode the color space parameter.

* Shared/WebPageCreationParameters.h:
Add the color space.

* Shared/mac/ColorSpaceData.h: Added.
* Shared/mac/ColorSpaceData.mm: Added.
Add a new class that represents a color space that can be sent over the wire.

* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::colorSpace):
Call through to the WKView.

* UIProcess/API/mac/WKView.mm:
(-[WKView _windowDidChangeBackingProperties:]):
Fix whitespace.

(-[WKView viewDidChangeBackingProperties]):
Check if our new color space is different from the current one and null the current one out if that is the case,
it will be reinitialized by the next call to -[WKView _colorSpace].

(-[WKView _colorSpace:]):
Compute the color space. If we're not in a window we'll get the main screen's color space.

* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::colorSpaceDidChange):
Add empty stub.

* UIProcess/PageClient.h:
Add colorSpace getter.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
Initialize the color space.

* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
(WebKit::TiledCoreAnimationDrawingAreaProxy::colorSpaceDidChange):
Send the new color space over to the web process.

* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::colorSpace):
Call through to the page client.

* WebKit2.xcodeproj/project.pbxproj:
Add ColorSpaceData.h and ColorSpaceData.mm.

* WebProcess/WebPage/DrawingArea.h:
* WebProcess/WebPage/DrawingArea.messages.in:
Add SetColorSpace message.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
Set the color space from the creation parameters.

(WebKit::TiledCoreAnimationDrawingArea::setColorSpace):
Set the color space on the layer hosting context.

(WebKit::TiledCoreAnimationDrawingArea::updateLayerHostingContext):
Make sure we apply the color space from the previous layer hosting context if one exists.

WebKitLibraries:

Add WKCAContextSetColorSpace and WKCAContextGetColorSpace.

* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLion.a:
* libWebKitSystemInterfaceSnowLeopard.a:

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

28 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/mac/LayerHostingContext.h
Source/WebKit2/Platform/mac/LayerHostingContext.mm
Source/WebKit2/Scripts/webkit2/messages.py
Source/WebKit2/Shared/WebPageCreationParameters.cpp
Source/WebKit2/Shared/WebPageCreationParameters.h
Source/WebKit2/Shared/mac/ColorSpaceData.h [new file with mode: 0644]
Source/WebKit2/Shared/mac/ColorSpaceData.mm [new file with mode: 0644]
Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
Source/WebKit2/UIProcess/DrawingAreaProxy.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h
Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebPage/DrawingArea.h
Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLion.a
WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a

index 2c071f5..7a19cca 100644 (file)
@@ -1,5 +1,91 @@
 2012-06-11  Anders Carlsson  <andersca@apple.com>
 
+        Pass the right color space over to the web process so we can set it on our CA context
+        https://bugs.webkit.org/show_bug.cgi?id=88819
+        <rdar://problem/11629050>
+
+        Reviewed by John Sullivan.
+
+        * Platform/mac/LayerHostingContext.h:
+        (LayerHostingContext):
+        * Platform/mac/LayerHostingContext.mm:
+        (WebKit::LayerHostingContext::createForPort):
+        (WebKit::LayerHostingContext::createForWindowServer):
+        Use a single constructor and explicitly set up the parameters of the constructed object.
+
+        (WebKit::LayerHostingContext::setColorSpace):
+        (WebKit::LayerHostingContext::colorSpace):
+        Add getter and setter.
+
+        * Scripts/webkit2/messages.py:
+        (struct_or_class):
+        WebKit::ColorSpaceData is a struct.
+
+        * Shared/WebPageCreationParameters.cpp:
+        Encode and decode the color space parameter.
+
+        * Shared/WebPageCreationParameters.h:
+        Add the color space.
+
+        * Shared/mac/ColorSpaceData.h: Added.
+        * Shared/mac/ColorSpaceData.mm: Added.
+        Add a new class that represents a color space that can be sent over the wire.
+
+        * UIProcess/API/mac/PageClientImpl.h:
+        * UIProcess/API/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::colorSpace):
+        Call through to the WKView.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _windowDidChangeBackingProperties:]):
+        Fix whitespace.
+
+        (-[WKView viewDidChangeBackingProperties]):
+        Check if our new color space is different from the current one and null the current one out if that is the case,
+        it will be reinitialized by the next call to -[WKView _colorSpace].
+        
+        (-[WKView _colorSpace:]):
+        Compute the color space. If we're not in a window we'll get the main screen's color space.
+
+        * UIProcess/DrawingAreaProxy.h:
+        (WebKit::DrawingAreaProxy::colorSpaceDidChange):
+        Add empty stub.
+
+        * UIProcess/PageClient.h:
+        Add colorSpace getter.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        Initialize the color space.
+
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
+        (WebKit::TiledCoreAnimationDrawingAreaProxy::colorSpaceDidChange):
+        Send the new color space over to the web process.
+
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::colorSpace):
+        Call through to the page client.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add ColorSpaceData.h and ColorSpaceData.mm.
+
+        * WebProcess/WebPage/DrawingArea.h:
+        * WebProcess/WebPage/DrawingArea.messages.in:
+        Add SetColorSpace message.
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
+        Set the color space from the creation parameters.
+
+        (WebKit::TiledCoreAnimationDrawingArea::setColorSpace):
+        Set the color space on the layer hosting context.
+
+        (WebKit::TiledCoreAnimationDrawingArea::updateLayerHostingContext):
+        Make sure we apply the color space from the previous layer hosting context if one exists.
+
+2012-06-11  Anders Carlsson  <andersca@apple.com>
+
         Crash when a plug-in tries to use the NPRuntime API with JavaScript disabled
         https://bugs.webkit.org/show_bug.cgi?id=88797
         <rdar://problem/11574844>
index 50c3adf..c380403 100644 (file)
@@ -53,11 +53,11 @@ public:
 
     LayerHostingMode layerHostingMode() { return m_layerHostingMode; }
 
+    void setColorSpace(CGColorSpaceRef);
+    CGColorSpaceRef colorSpace() const;
+
 private:
-    LayerHostingContext(mach_port_t serverPort);
-#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
     LayerHostingContext();
-#endif
 
     LayerHostingMode m_layerHostingMode;
     RetainPtr<WKCAContextRef> m_context;
index 874b35f..54fc1a1 100644 (file)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "LayerHostingContext.h"
 
+#import <wtf/OwnPtr.h>
 #import <wtf/PassOwnPtr.h>
 #import <WebKitSystemInterface.h>
 
@@ -33,27 +34,29 @@ namespace WebKit {
 
 PassOwnPtr<LayerHostingContext> LayerHostingContext::createForPort(mach_port_t serverPort)
 {
-    return adoptPtr(new LayerHostingContext(serverPort));
-}
+    OwnPtr<LayerHostingContext> layerHostingContext = adoptPtr(new LayerHostingContext);
 
-LayerHostingContext::LayerHostingContext(mach_port_t serverPort)
-{
-    m_layerHostingMode = LayerHostingModeDefault;
-    m_context = WKCAContextMakeRemoteWithServerPort(serverPort);
+    layerHostingContext->m_layerHostingMode = LayerHostingModeDefault;
+    layerHostingContext->m_context = WKCAContextMakeRemoteWithServerPort(serverPort);
+
+    return layerHostingContext.release();
 }
 
 #if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
 PassOwnPtr<LayerHostingContext> LayerHostingContext::createForWindowServer()
 {
-    return adoptPtr(new LayerHostingContext);
+    OwnPtr<LayerHostingContext> layerHostingContext = adoptPtr(new LayerHostingContext);
+
+    layerHostingContext->m_layerHostingMode = LayerHostingModeInWindowServer;
+    layerHostingContext->m_context = WKCAContextMakeRemoteForWindowServer();
+
+    return layerHostingContext.release();
 }
+#endif
 
 LayerHostingContext::LayerHostingContext()
 {
-    m_layerHostingMode = LayerHostingModeInWindowServer;
-    m_context = WKCAContextMakeRemoteForWindowServer();
 }
-#endif
 
 LayerHostingContext::~LayerHostingContext()
 {
@@ -79,4 +82,14 @@ void LayerHostingContext::invalidate()
     WKCAContextInvalidate(m_context.get());
 }
 
+void LayerHostingContext::setColorSpace(CGColorSpaceRef colorSpace)
+{
+    WKCAContextSetColorSpace(m_context.get(), colorSpace);
+}
+
+CGColorSpaceRef LayerHostingContext::colorSpace() const
+{
+    return WKCAContextGetColorSpace(m_context.get());
+}
+
 } // namespace WebKit
index ed8b508..2a87d62 100644 (file)
@@ -194,6 +194,7 @@ def struct_or_class(namespace, type):
         'WebCore::ViewportAttributes',
         'WebCore::WindowFeatures',
         'WebKit::AttributedString',
+        'WebKit::ColorSpaceData',
         'WebKit::ContextMenuState',
         'WebKit::DictionaryPopupInfo',
         'WebKit::DrawingAreaInfo',
index eb72ed5..27d5543 100644 (file)
@@ -61,6 +61,7 @@ void WebPageCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) const
 #if PLATFORM(MAC)
     encoder->encode(isSmartInsertDeleteEnabled);
     encoder->encodeEnum(layerHostingMode);
+    encoder->encode(colorSpace);
 #endif
 
 #if PLATFORM(WIN)
@@ -124,6 +125,8 @@ bool WebPageCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, WebPag
         return false;
     if (!decoder->decodeEnum(parameters.layerHostingMode))
         return false;
+    if (!decoder->decode(parameters.colorSpace))
+        return false;
 #endif
 
 #if PLATFORM(WIN)
index 54845b8..ce85dce 100644 (file)
 #include <WebCore/IntSize.h>
 #include <wtf/text/WTFString.h>
 
+#if PLATFORM(MAC)
+#include "ColorSpaceData.h"
+#endif
+
 namespace CoreIPC {
     class ArgumentDecoder;
     class ArgumentEncoder;
@@ -83,6 +87,7 @@ struct WebPageCreationParameters {
 #if PLATFORM(MAC)
     bool isSmartInsertDeleteEnabled;
     LayerHostingMode layerHostingMode;
+    ColorSpaceData colorSpace;
 #endif
 
 #if PLATFORM(WIN)
diff --git a/Source/WebKit2/Shared/mac/ColorSpaceData.h b/Source/WebKit2/Shared/mac/ColorSpaceData.h
new file mode 100644 (file)
index 0000000..cdea86e
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2012 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+ */
+
+#ifndef ColorSpaceData_h
+#define ColorSpaceData_h
+
+#include <wtf/RetainPtr.h>
+
+namespace CoreIPC {
+    class ArgumentDecoder;
+    class ArgumentEncoder;
+}
+
+namespace WebKit {
+
+struct ColorSpaceData {
+    void encode(CoreIPC::ArgumentEncoder*) const;
+    static bool decode(CoreIPC::ArgumentDecoder*, ColorSpaceData&);
+
+    RetainPtr<CGColorSpaceRef> cgColorSpace;
+};
+
+} // namespace WebKit
+
+#endif // ColorSpaceData_h
diff --git a/Source/WebKit2/Shared/mac/ColorSpaceData.mm b/Source/WebKit2/Shared/mac/ColorSpaceData.mm
new file mode 100644 (file)
index 0000000..796c06d
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2012 Apple 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:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "ColorSpaceData.h"
+
+#include "ArgumentCodersCF.h"
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
+
+namespace WebKit {
+
+enum EncodedDataType {
+    Null,
+    Name,
+    Data,
+};
+
+void ColorSpaceData::encode(CoreIPC::ArgumentEncoder* encoder) const
+{
+    if (cgColorSpace) {
+        // Try to encode the name.
+        if (RetainPtr<CFStringRef> name = adoptCF(CGColorSpaceCopyName(cgColorSpace.get()))) {
+            encoder->encodeEnum(Name);
+            CoreIPC::encode(encoder, name.get());
+            return;
+        }
+
+        // Failing that, just encode the ICC data.
+        if (RetainPtr<CFDataRef> profileData = adoptCF(CGColorSpaceCopyICCProfile(cgColorSpace.get()))) {
+            encoder->encodeEnum(Data);
+            CoreIPC::encode(encoder, profileData.get());
+            return;
+        }
+    }
+
+    // The color space was null or failed to be encoded.
+    encoder->encodeEnum(Null);
+}
+
+bool ColorSpaceData::decode(CoreIPC::ArgumentDecoder* decoder, ColorSpaceData& colorSpaceData)
+{
+    EncodedDataType dataType;
+    if (!decoder->decodeEnum(dataType))
+        return false;
+
+    switch (dataType) {
+    case Null:
+        colorSpaceData.cgColorSpace = nullptr;
+        return true;
+    case Name: {
+        RetainPtr<CFStringRef> name;
+        if (!CoreIPC::decode(decoder, name))
+            return false;
+
+        colorSpaceData.cgColorSpace = adoptCF(CGColorSpaceCreateWithName(name.get()));
+        return true;
+    }
+    case Data: {
+        RetainPtr<CFDataRef> data;
+        if (!CoreIPC::decode(decoder, data))
+            return false;
+
+        colorSpaceData.cgColorSpace = adoptCF(CGColorSpaceCreateWithICCProfile(data.get()));
+        return true;
+    }
+
+    default:
+        return false;
+    }
+}
+
+} // namespace WebKit
index 14288ff..52dd050 100644 (file)
@@ -56,6 +56,7 @@ private:
     virtual bool isViewVisible();
     virtual bool isViewInWindow();
     virtual LayerHostingMode viewLayerHostingMode() OVERRIDE;
+    virtual ColorSpaceData colorSpace() OVERRIDE;
 
     virtual void processDidCrash();
     virtual void pageClosed();
index aa7e538..783c328 100644 (file)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "PageClientImpl.h"
 
+#import "ColorSpaceData.h"
 #import "DataReference.h"
 #import "DictionaryPopupInfo.h"
 #import "FindIndicator.h"
@@ -205,6 +206,11 @@ LayerHostingMode PageClientImpl::viewLayerHostingMode()
 #endif
 }
 
+ColorSpaceData PageClientImpl::colorSpace()
+{
+    return [m_wkView _colorSpace];
+}
+
 void PageClientImpl::processDidCrash()
 {
     [m_wkView _processDidCrash];
index 78da5dc..2924553 100644 (file)
@@ -27,6 +27,7 @@
 #import "WKView.h"
 
 #import "AttributedString.h"
+#import "ColorSpaceData.h"
 #import "DataReference.h"
 #import "DrawingAreaProxyImpl.h"
 #import "EditorState.h"
@@ -201,6 +202,9 @@ struct WKViewInterpretKeyEventsParameters {
     // We use this flag to determine when we need to paint the background (white or clear)
     // when the web process is unresponsive or takes too long to paint.
     BOOL _windowHasValidBackingStore;
+
+    RetainPtr<NSColorSpace> _colorSpace;
+
     RefPtr<WebCore::Image> _promisedImage;
     String _promisedFilename;
     String _promisedURL;
@@ -1987,9 +1991,9 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
 
 - (void)_windowDidChangeBackingProperties:(NSNotification *)notification
 {
-    CGFloat oldBackingScaleFactor = [[notification.userInfo objectForKey:backingPropertyOldScaleFactorKey] doubleValue]; 
+    CGFloat oldBackingScaleFactor = [[notification.userInfo objectForKey:backingPropertyOldScaleFactorKey] doubleValue];
     CGFloat newBackingScaleFactor = [self _intrinsicDeviceScaleFactor]; 
-    if (oldBackingScaleFactor == newBackingScaleFactor) 
+    if (oldBackingScaleFactor == newBackingScaleFactor)
         return; 
 
     _data->_windowHasValidBackingStore = NO;
@@ -2074,6 +2078,17 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
     _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
 }
 
+- (void)viewDidChangeBackingProperties
+{
+    NSColorSpace *colorSpace = [[self window] colorSpace];
+    if ([colorSpace isEqualTo:_data->_colorSpace.get()])
+        return;
+
+    _data->_colorSpace = nullptr;
+    if (DrawingAreaProxy *drawingArea = _data->_page->drawingArea())
+        drawingArea->colorSpaceDidChange();
+}
+
 - (void)_accessibilityRegisterUIProcessTokens
 {
     // Initialize remote accessibility when the window connection has been established.
@@ -2229,6 +2244,21 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
     return [[self window] firstResponder] == self;
 }
 
+- (WebKit::ColorSpaceData)_colorSpace
+{
+    if (!_data->_colorSpace) {
+        if ([self window])
+            _data->_colorSpace = [[self window] colorSpace];
+        else
+            _data->_colorSpace = [[NSScreen mainScreen] colorSpace];
+    }
+        
+    ColorSpaceData colorSpaceData;
+    colorSpaceData.cgColorSpace = [_data->_colorSpace.get() CGColorSpace];
+
+    return colorSpaceData;    
+}
+
 - (void)_processDidCrash
 {
     if (_data->_layerHostingView)
index 6b6eb6b..08cff14 100644 (file)
@@ -43,6 +43,7 @@ namespace WebKit {
     class DrawingAreaProxy;
     class FindIndicator;
     class LayerTreeContext;
+    struct ColorSpaceData;
     struct EditorState;
 }
 
@@ -87,6 +88,8 @@ namespace WebKit {
 
 - (void)_didChangeScrollbarsForMainFrame;
 
+- (WebKit::ColorSpaceData)_colorSpace;
+
 #if ENABLE(FULLSCREEN_API)
 - (BOOL)hasFullScreenWindowController;
 - (WKFullScreenWindowController*)fullScreenWindowController;
@@ -97,5 +100,4 @@ namespace WebKit {
 
 - (NSInteger)spellCheckerDocumentTag;
 - (void)handleCorrectionPanelResult:(NSString*)result;
-
 @end
index e86ee8c..9f1705d 100644 (file)
@@ -86,6 +86,8 @@ public:
     virtual void pageCustomRepresentationChanged() { }
     virtual void waitForPossibleGeometryUpdate() { }
 
+    virtual void colorSpaceDidChange() { }
+
 #if USE(UI_SIDE_COMPOSITING)
     virtual void updateViewport();
     virtual WebCore::IntRect viewportVisibleRect() const { return contentsRect(); }
index 08cdd94..62058fd 100644 (file)
@@ -65,6 +65,10 @@ class WebPopupMenuProxy;
 struct WindowGeometry;
 #endif
 
+#if PLATFORM(MAC)
+struct ColorSpaceData;
+#endif
+
 class PageClient {
 public:
     virtual ~PageClient() { }
@@ -192,7 +196,9 @@ public:
     virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText) = 0;
     virtual void recordAutocorrectionResponse(WebCore::AutocorrectionResponseType, const String& replacedString, const String& replacementString) = 0;
     virtual void recommendedScrollbarStyleDidChange(int32_t newStyle) = 0;
-    
+
+    virtual ColorSpaceData colorSpace() = 0;
+
 #if USE(APPKIT)
     virtual WKView* wkView() const = 0;
 #endif
index 2b538e5..a84c467 100644 (file)
@@ -3468,6 +3468,7 @@ WebPageCreationParameters WebPageProxy::creationParameters() const
 #if PLATFORM(MAC)
     parameters.isSmartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled;
     parameters.layerHostingMode = m_layerHostingMode;
+    parameters.colorSpace = m_pageClient->colorSpace();
 #endif
 
 #if PLATFORM(WIN)
index 826c3ab..6d98598 100644 (file)
@@ -140,6 +140,7 @@ class WebProcessProxy;
 class WebURLRequest;
 class WebWheelEvent;
 struct AttributedString;
+struct ColorSpaceData;
 struct DictionaryPopupInfo;
 struct EditorState;
 struct PlatformPopupMenuData;
@@ -479,6 +480,8 @@ public:
     String stringSelectionForPasteboard();
     PassRefPtr<WebCore::SharedBuffer> dataSelectionForPasteboard(const String& pasteboardType);
     void makeFirstResponder();
+
+    ColorSpaceData colorSpace();
 #endif
 
     void pageScaleFactorDidChange(double);
index c5b6f0e..08b1650 100644 (file)
@@ -47,6 +47,7 @@ private:
     virtual void visibilityDidChange() OVERRIDE;
     virtual void sizeDidChange() OVERRIDE;
     virtual void waitForPossibleGeometryUpdate() OVERRIDE;
+    virtual void colorSpaceDidChange() OVERRIDE;
 
     virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) OVERRIDE;
     virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) OVERRIDE;
index 747ed11..a0c1817 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(THREADED_SCROLLING)
 
+#import "ColorSpaceData.h"
 #import "DrawingAreaMessages.h"
 #import "DrawingAreaProxyMessages.h"
 #import "LayerTreeContext.h"
@@ -97,6 +98,11 @@ void TiledCoreAnimationDrawingAreaProxy::waitForPossibleGeometryUpdate()
     m_webPageProxy->process()->connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidUpdateGeometry>(m_webPageProxy->pageID(), didUpdateBackingStoreStateTimeout);
 }
 
+void TiledCoreAnimationDrawingAreaProxy::colorSpaceDidChange()
+{
+    m_webPageProxy->process()->send(Messages::DrawingArea::SetColorSpace(m_webPageProxy->colorSpace()), m_webPageProxy->pageID());
+}
+
 void TiledCoreAnimationDrawingAreaProxy::enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext& layerTreeContext)
 {
     m_webPageProxy->enterAcceleratedCompositingMode(layerTreeContext);
index 438bb65..ea7e5ef 100644 (file)
@@ -27,6 +27,7 @@
 #import "WebPageProxy.h"
 
 #import "AttributedString.h"
+#import "ColorSpaceData.h"
 #import "DataReference.h"
 #import "DictionaryPopupInfo.h"
 #import "EditorState.h"
@@ -381,7 +382,12 @@ void WebPageProxy::makeFirstResponder()
 {
     m_pageClient->makeFirstResponder();
 }
-    
+
+ColorSpaceData WebPageProxy::colorSpace()
+{
+    return m_pageClient->colorSpace();
+}
+
 void WebPageProxy::registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elementToken, const CoreIPC::DataReference& windowToken)
 {
     if (!isValid())
index 8119614..3f98e9b 100644 (file)
@@ -77,6 +77,8 @@
                1A24B5F311F531E800C38269 /* MachUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A24B5F111F531E800C38269 /* MachUtilities.h */; };
                1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A24BED3120894D100FBB059 /* SharedMemory.h */; };
                1A24BF3A120896A600FBB059 /* SharedMemoryMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24BF39120896A600FBB059 /* SharedMemoryMac.cpp */; };
+               1A2A4B00158693920090C9E9 /* ColorSpaceData.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1A2A4AFE158693920090C9E9 /* ColorSpaceData.h */; };
+               1A2A4B0E1586A2240090C9E9 /* ColorSpaceData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A4AFD158693920090C9E9 /* ColorSpaceData.mm */; };
                1A2BB6D014117B4D000F35D4 /* PluginProcessConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2BB6CE14117B4D000F35D4 /* PluginProcessConnectionMessageReceiver.cpp */; };
                1A2BB6D114117B4D000F35D4 /* PluginProcessConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2BB6CF14117B4D000F35D4 /* PluginProcessConnectionMessages.h */; };
                1A2D82A4127F4EAB001EB962 /* NPObjectMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1FA35C127A45BF0050E709 /* NPObjectMessageReceiver.cpp */; };
                        files = (
                                BCDE0ABF13272708001259FB /* PluginProcess.app in CopyFiles */,
                                1A50DB66110A3D57000D3FE5 /* WebProcess.app in CopyFiles */,
+                               1A2A4B00158693920090C9E9 /* ColorSpaceData.h in CopyFiles */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                1A24B5F111F531E800C38269 /* MachUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MachUtilities.h; sourceTree = "<group>"; };
                1A24BED3120894D100FBB059 /* SharedMemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedMemory.h; sourceTree = "<group>"; };
                1A24BF39120896A600FBB059 /* SharedMemoryMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedMemoryMac.cpp; sourceTree = "<group>"; };
+               1A2A4AFD158693920090C9E9 /* ColorSpaceData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ColorSpaceData.mm; sourceTree = "<group>"; };
+               1A2A4AFE158693920090C9E9 /* ColorSpaceData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorSpaceData.h; sourceTree = "<group>"; };
                1A2BB6CC14117A5F000F35D4 /* PluginProcessConnection.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PluginProcessConnection.messages.in; sourceTree = "<group>"; };
                1A2BB6CE14117B4D000F35D4 /* PluginProcessConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginProcessConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
                1A2BB6CF14117B4D000F35D4 /* PluginProcessConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginProcessConnectionMessages.h; sourceTree = "<group>"; };
                                E179FD9E134D38250015B883 /* ArgumentCodersMac.mm */,
                                E1A31731134CEA6C007C9A4F /* AttributedString.h */,
                                E1A31734134CEA80007C9A4F /* AttributedString.mm */,
+                               1A2A4AFE158693920090C9E9 /* ColorSpaceData.h */,
+                               1A2A4AFD158693920090C9E9 /* ColorSpaceData.mm */,
                                1A6F9FB611E1408500DB1371 /* CommandLineMac.cpp */,
                                5112CB071385B97B0030867D /* KeychainAttribute.cpp */,
                                5112CB051385B8D90030867D /* KeychainAttribute.h */,
                                E19582D6153CC05400B60875 /* PDFKitImports.mm in Sources */,
                                51FA2D7415212DF100C1BA0B /* InjectedBundleDOMWindowExtension.cpp in Sources */,
                                51FA2D7715212E2600C1BA0B /* WKBundleDOMWindowExtension.cpp in Sources */,
+                               1A2A4B0E1586A2240090C9E9 /* ColorSpaceData.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 30026e7..685cb83 100644 (file)
@@ -45,6 +45,7 @@ namespace WebCore {
 
 namespace WebKit {
 
+struct ColorSpaceData;
 class LayerTreeHost;
 class WebPage;
 struct WebPageCreationParameters;
@@ -118,6 +119,7 @@ private:
     // Used by TiledCoreAnimationDrawingArea.
     virtual void updateGeometry(const WebCore::IntSize& viewSize) { }
     virtual void setDeviceScaleFactor(float) { }
+    virtual void setColorSpace(const ColorSpaceData&) { }
 #endif
 };
 
index 9de8113..fe98c73 100644 (file)
@@ -32,5 +32,6 @@ messages -> DrawingArea {
     // Used by TiledCoreAnimationDrawingArea.
     UpdateGeometry(WebCore::IntSize viewSize)
     SetDeviceScaleFactor(float deviceScaleFactor)
+    SetColorSpace(WebKit::ColorSpaceData colorSpace)
 #endif
 }
index 9d0b077..4a4e067 100644 (file)
@@ -85,6 +85,7 @@ private:
     virtual void updateGeometry(const WebCore::IntSize& viewSize) OVERRIDE;
     virtual void setDeviceScaleFactor(float) OVERRIDE;
     virtual void setLayerHostingMode(uint32_t) OVERRIDE;
+    virtual void setColorSpace(const ColorSpaceData&) OVERRIDE;
 
     void updateLayerHostingContext();
 
@@ -97,7 +98,7 @@ private:
     WebCore::LayerFlushScheduler m_layerFlushScheduler;
 
     OwnPtr<LayerHostingContext> m_layerHostingContext;
-    
+
     RetainPtr<CALayer> m_rootLayer;
     RetainPtr<CALayer> m_pendingRootCompositingLayer;
 
index 2018677..2254152 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(THREADED_SCROLLING)
 
+#import "ColorSpaceData.h"
 #import "DrawingAreaProxyMessages.h"
 #import "EventDispatcher.h"
 #import "LayerHostingContext.h"
@@ -85,7 +86,8 @@ TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea(WebPage* webPage, c
     m_rootLayer.get().geometryFlipped = YES;
 
     updateLayerHostingContext();
-    
+    setColorSpace(parameters.colorSpace);
+
     LayerTreeContext layerTreeContext;
     layerTreeContext.contextID = m_layerHostingContext->contextID();
     m_webPage->send(Messages::DrawingAreaProxy::EnterAcceleratedCompositingMode(0, layerTreeContext));
@@ -365,10 +367,18 @@ void TiledCoreAnimationDrawingArea::setLayerHostingMode(uint32_t opaqueLayerHost
     m_webPage->send(Messages::DrawingAreaProxy::UpdateAcceleratedCompositingMode(0, layerTreeContext));
 }
 
+void TiledCoreAnimationDrawingArea::setColorSpace(const ColorSpaceData& colorSpace)
+{
+    m_layerHostingContext->setColorSpace(colorSpace.cgColorSpace.get());
+}
+
 void TiledCoreAnimationDrawingArea::updateLayerHostingContext()
 {
+    RetainPtr<CGColorSpaceRef> colorSpace;
+
     // Invalidate the old context.
     if (m_layerHostingContext) {
+        colorSpace = m_layerHostingContext->colorSpace();
         m_layerHostingContext->invalidate();
         m_layerHostingContext = nullptr;
     }
@@ -386,6 +396,8 @@ void TiledCoreAnimationDrawingArea::updateLayerHostingContext()
     }
 
     m_layerHostingContext->setRootLayer(m_rootLayer.get());
+    if (colorSpace)
+        m_layerHostingContext->setColorSpace(colorSpace.get());
 }
 
 void TiledCoreAnimationDrawingArea::setRootCompositingLayer(CALayer *layer)
index 2f97424..04a9b09 100644 (file)
@@ -1,3 +1,17 @@
+2012-06-11  Anders Carlsson  <andersca@apple.com>
+
+        Pass the right color space over to the web process so we can set it on our CA context
+        https://bugs.webkit.org/show_bug.cgi?id=88819
+        <rdar://problem/11629050>
+
+        Reviewed by John Sullivan.
+
+        Add WKCAContextSetColorSpace and WKCAContextGetColorSpace.
+
+        * WebKitSystemInterface.h:
+        * libWebKitSystemInterfaceLion.a:
+        * libWebKitSystemInterfaceSnowLeopard.a:
+
 2012-06-09  Sukolsak Sakshuwong  <sukolsak@google.com>
 
         Add UNDO_MANAGER flag
index 0351a8e..c388f34 100644 (file)
@@ -348,6 +348,8 @@ void WKCAContextInvalidate(WKCAContextRef);
 uint32_t WKCAContextGetContextId(WKCAContextRef);
 void WKCAContextSetLayer(WKCAContextRef, CALayer *);
 CALayer *WKCAContextGetLayer(WKCAContextRef);
+void WKCAContextSetColorSpace(WKCAContextRef, CGColorSpaceRef);
+CGColorSpaceRef WKCAContextGetColorSpace(WKCAContextRef);
 
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
 void WKCALayerEnumerateRectsBeingDrawnWithBlock(CALayer *layer, CGContextRef context, void (^block)(CGRect rect));
@@ -502,6 +504,10 @@ void WKFilterRelease(WebFilterEvaluator *);
 BOOL WKFilterWasBlocked(WebFilterEvaluator *);
 const char* WKFilterAddData(WebFilterEvaluator *, const char* data, int* length);
 const char* WKFilterDataComplete(WebFilterEvaluator *, int* length);
+
+CGFloat WKNSElasticDeltaForTimeDelta(CGFloat initialPosition, CGFloat initialVelocity, CGFloat elapsedTime);
+CGFloat WKNSElasticDeltaForReboundDelta(CGFloat delta);
+CGFloat WKNSReboundDeltaForElasticDelta(CGFloat delta);
 #endif
 
 #ifdef __cplusplus
index 0252234..f7e2a9c 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLion.a and b/WebKitLibraries/libWebKitSystemInterfaceLion.a differ
index c59fc98..0518a46 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a differ