Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pass the right color space over to the web process so we can set it o…
…n our CA context

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:

Canonical link: https://commits.webkit.org/106654@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@120021 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Jun 12, 2012
1 parent 9298ae1 commit 8078050
Show file tree
Hide file tree
Showing 28 changed files with 378 additions and 20 deletions.
86 changes: 86 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,89 @@
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
Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit2/Platform/mac/LayerHostingContext.h
Expand Up @@ -53,11 +53,11 @@ class LayerHostingContext {

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;
Expand Down
33 changes: 23 additions & 10 deletions Source/WebKit2/Platform/mac/LayerHostingContext.mm
Expand Up @@ -26,34 +26,37 @@
#import "config.h"
#import "LayerHostingContext.h"

#import <wtf/OwnPtr.h>
#import <wtf/PassOwnPtr.h>
#import <WebKitSystemInterface.h>

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()
{
Expand All @@ -79,4 +82,14 @@
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
1 change: 1 addition & 0 deletions Source/WebKit2/Scripts/webkit2/messages.py
Expand Up @@ -194,6 +194,7 @@ def struct_or_class(namespace, type):
'WebCore::ViewportAttributes',
'WebCore::WindowFeatures',
'WebKit::AttributedString',
'WebKit::ColorSpaceData',
'WebKit::ContextMenuState',
'WebKit::DictionaryPopupInfo',
'WebKit::DrawingAreaInfo',
Expand Down
3 changes: 3 additions & 0 deletions Source/WebKit2/Shared/WebPageCreationParameters.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit2/Shared/WebPageCreationParameters.h
Expand Up @@ -33,6 +33,10 @@
#include <WebCore/IntSize.h>
#include <wtf/text/WTFString.h>

#if PLATFORM(MAC)
#include "ColorSpaceData.h"
#endif

namespace CoreIPC {
class ArgumentDecoder;
class ArgumentEncoder;
Expand Down Expand Up @@ -83,6 +87,7 @@ struct WebPageCreationParameters {
#if PLATFORM(MAC)
bool isSmartInsertDeleteEnabled;
LayerHostingMode layerHostingMode;
ColorSpaceData colorSpace;
#endif

#if PLATFORM(WIN)
Expand Down
47 changes: 47 additions & 0 deletions Source/WebKit2/Shared/mac/ColorSpaceData.h
@@ -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
95 changes: 95 additions & 0 deletions Source/WebKit2/Shared/mac/ColorSpaceData.mm
@@ -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
1 change: 1 addition & 0 deletions Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
Expand Up @@ -56,6 +56,7 @@ class PageClientImpl : public PageClient {
virtual bool isViewVisible();
virtual bool isViewInWindow();
virtual LayerHostingMode viewLayerHostingMode() OVERRIDE;
virtual ColorSpaceData colorSpace() OVERRIDE;

virtual void processDidCrash();
virtual void pageClosed();
Expand Down
6 changes: 6 additions & 0 deletions Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
Expand Up @@ -26,6 +26,7 @@
#import "config.h"
#import "PageClientImpl.h"

#import "ColorSpaceData.h"
#import "DataReference.h"
#import "DictionaryPopupInfo.h"
#import "FindIndicator.h"
Expand Down Expand Up @@ -205,6 +206,11 @@ - (void)redoEditing:(id)sender
#endif
}

ColorSpaceData PageClientImpl::colorSpace()
{
return [m_wkView _colorSpace];
}

void PageClientImpl::processDidCrash()
{
[m_wkView _processDidCrash];
Expand Down

0 comments on commit 8078050

Please sign in to comment.