Diff
Modified: trunk/Source/WebKit2/ChangeLog (98587 => 98588)
--- trunk/Source/WebKit2/ChangeLog 2011-10-27 16:18:11 UTC (rev 98587)
+++ trunk/Source/WebKit2/ChangeLog 2011-10-27 16:24:41 UTC (rev 98588)
@@ -1,3 +1,23 @@
+2011-10-27 Adam Roben <aro...@apple.com>
+
+ Add WKBundlePageGetBackingScaleFactor
+
+ Fixes <http://webkit.org/b/71025> <rdar://problem/10355037> REGRESSION (r97191): Clients
+ can't reliably determine the scale factor of snapshots returned via
+ WKBundlePageCreateSnapshot* API
+
+ Reviewed by Sam Weinig.
+
+ * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+ (WKBundlePageGetBackingScaleFactor):
+ * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
+ Added. Calls through to WebPage::deviceScaleFactor.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::deviceScaleFactor):
+ * WebProcess/WebPage/WebPage.h:
+ Added. Calls through to Page::deviceScaleFactor.
+
2011-10-27 Zalan Bujtas <zbuj...@gmail.com>
[Qt][WK2]Add setViewportSize API to WebKit2.
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp (98587 => 98588)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp 2011-10-27 16:18:11 UTC (rev 98587)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp 2011-10-27 16:24:41 UTC (rev 98588)
@@ -239,6 +239,11 @@
return toAPI(webImage.release().leakRef());
}
+double WKBundlePageGetBackingScaleFactor(WKBundlePageRef pageRef)
+{
+ return toImpl(pageRef)->deviceScaleFactor();
+}
+
#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR
WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef pageRef)
{
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h (98587 => 98588)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h 2011-10-27 16:18:11 UTC (rev 98587)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h 2011-10-27 16:24:41 UTC (rev 98588)
@@ -339,6 +339,8 @@
WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInDocumentCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options);
WK_EXPORT WKImageRef WKBundlePageCreateScaledSnapshotInDocumentCoordinates(WKBundlePageRef page, WKRect rect, double scaleFactor, WKImageOptions options);
+WK_EXPORT double WKBundlePageGetBackingScaleFactor(WKBundlePageRef page);
+
#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR
WK_EXPORT WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef page);
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (98587 => 98588)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2011-10-27 16:18:11 UTC (rev 98587)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2011-10-27 16:24:41 UTC (rev 98588)
@@ -872,6 +872,11 @@
#endif
}
+float WebPage::deviceScaleFactor() const
+{
+ return m_page->deviceScaleFactor();
+}
+
void WebPage::setUseFixedLayout(bool fixed)
{
Frame* frame = m_mainFrame->coreFrame();
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (98587 => 98588)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2011-10-27 16:18:11 UTC (rev 98587)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2011-10-27 16:24:41 UTC (rev 98588)
@@ -431,6 +431,7 @@
void runModal();
void setDeviceScaleFactor(float);
+ float deviceScaleFactor() const;
void setMemoryCacheMessagesEnabled(bool);
Modified: trunk/Tools/ChangeLog (98587 => 98588)
--- trunk/Tools/ChangeLog 2011-10-27 16:18:11 UTC (rev 98587)
+++ trunk/Tools/ChangeLog 2011-10-27 16:24:41 UTC (rev 98588)
@@ -1,3 +1,31 @@
+2011-10-27 Adam Roben <aro...@apple.com>
+
+ Test WKBundlePageGetBackingScaleFactor
+
+ Test for <http://webkit.org/b/71025> <rdar://problem/10355037> REGRESSION (r97191): Clients
+ can't reliably determine the scale factor of snapshots returned via
+ WKBundlePageCreateSnapshot* API
+
+ Reviewed by Sam Weinig.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Added new files.
+
+ * TestWebKitAPI/Tests/WebKit2/mac/GetBackingScaleFactor.mm: Added.
+ (TestWebKitAPI::didReceiveMessageFromInjectedBundle): Record the passed-back scale factor.
+ (TestWebKitAPI::setInjectedBundleClient): Hook up our didReceiveMessage callback.
+ (TestWebKitAPI::createWindow): Conjure up a window.
+ (TestWebKitAPI::TEST): Ask the injected bundle code to call the new
+ WKBundlePageGetBackingScaleFactor API when the WKView is in windows with various scale
+ factors and when using a custom scale factor, and check that we get those same scale factors
+ back.
+
+ * TestWebKitAPI/Tests/WebKit2/mac/GetBackingScaleFactor_Bundle.mm: Added.
+ (TestWebKitAPI::GetBackingScaleFactorTest::GetBackingScaleFactorTest): Just initialize our
+ members.
+ (TestWebKitAPI::GetBackingScaleFactorTest::didCreatePage): Store the page for later.
+ (TestWebKitAPI::GetBackingScaleFactorTest::didReceiveMessage): Get the backing scale factor
+ from the page using the new API and send it back.
+
2011-10-27 Balazs Kelemen <kbal...@webkit.org>
[Qt][WK2] MiniBrowser crashes when started with 0 arguments
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (98587 => 98588)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2011-10-27 16:18:11 UTC (rev 98587)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2011-10-27 16:24:41 UTC (rev 98588)
@@ -90,6 +90,8 @@
C0ADBE9612FCA79B00D2C129 /* simple-form.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C0ADBE8412FCA6B600D2C129 /* simple-form.html */; };
C0BD669D131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */; };
C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */; };
+ C0C5D3BE14598B6F00A802A6 /* GetBackingScaleFactor.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */; };
+ C0C5D3C61459912900A802A6 /* GetBackingScaleFactor_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */; };
F3FC3EE313678B7300126A65 /* libgtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F3FC3EE213678B7300126A65 /* libgtest.a */; };
F6F3F29113342FEB00A6BF19 /* CookieManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */; };
F6FDDDD314241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */; };
@@ -239,6 +241,8 @@
C0ADBE8412FCA6B600D2C129 /* simple-form.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-form.html"; sourceTree = "<group>"; };
C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimerDoesntFireEarly.cpp; sourceTree = "<group>"; };
C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimerDoesntFireEarly_Bundle.cpp; sourceTree = "<group>"; };
+ C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor.mm; sourceTree = "<group>"; };
+ C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetBackingScaleFactor_Bundle.mm; sourceTree = "<group>"; };
F3FC3EE213678B7300126A65 /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };
F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CookieManager.cpp; sourceTree = "<group>"; };
F6FDDDD214241AD4004F1729 /* PrivateBrowsingPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateBrowsingPushStateNoHistoryCallback.cpp; sourceTree = "<group>"; };
@@ -360,6 +364,7 @@
BC9096411255616000083756 /* WebKit2 */ = {
isa = PBXGroup;
children = (
+ C0C5D3BB14598B6F00A802A6 /* mac */,
BC90977B125571AE00083756 /* Resources */,
BC246D8C132F115A00B56D7C /* AboutBlankLoad.cpp */,
BC246D97132F1FE100B56D7C /* CanHandleRequest_Bundle.cpp */,
@@ -509,6 +514,15 @@
path = WTF/cf;
sourceTree = "<group>";
};
+ C0C5D3BB14598B6F00A802A6 /* mac */ = {
+ isa = PBXGroup;
+ children = (
+ C0C5D3BC14598B6F00A802A6 /* GetBackingScaleFactor.mm */,
+ C0C5D3BD14598B6F00A802A6 /* GetBackingScaleFactor_Bundle.mm */,
+ );
+ path = mac;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -641,6 +655,7 @@
52CB47411448FB9300873995 /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp in Sources */,
BC3C4C7214575B6A0025FB62 /* WKBrowsingContextLoadDelegateTest.mm in Sources */,
BC3C4C7F14587AA60025FB62 /* WKBrowsingContextGroupTest.mm in Sources */,
+ C0C5D3BE14598B6F00A802A6 /* GetBackingScaleFactor.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -661,6 +676,7 @@
1AEDE22613E5E7E700E62FE8 /* InjectedBundleControllerMac.mm in Sources */,
33DC89141419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp in Sources */,
520BCF4C141EB09E00937EA8 /* WebArchive_Bundle.cpp in Sources */,
+ C0C5D3C61459912900A802A6 /* GetBackingScaleFactor_Bundle.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/mac/GetBackingScaleFactor.mm (0 => 98588)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/mac/GetBackingScaleFactor.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/mac/GetBackingScaleFactor.mm 2011-10-27 16:24:41 UTC (rev 98588)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import "config.h"
+
+#import "PlatformUtilities.h"
+#import "SyntheticBackingScaleFactorWindow.h"
+#import "Test.h"
+#import <WebKit2/WKViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+namespace TestWebKitAPI {
+
+static bool messageReceived;
+static double backingScaleFactor;
+
+static void didReceiveMessageFromInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody, const void*)
+{
+ messageReceived = true;
+ EXPECT_WK_STREQ("DidGetBackingScaleFactor", messageName);
+ ASSERT_NOT_NULL(messageBody);
+ EXPECT_EQ(WKDoubleGetTypeID(), WKGetTypeID(messageBody));
+ backingScaleFactor = WKDoubleGetValue(static_cast<WKDoubleRef>(messageBody));
+}
+
+static void setInjectedBundleClient(WKContextRef context)
+{
+ WKContextInjectedBundleClient injectedBundleClient;
+ memset(&injectedBundleClient, 0, sizeof(injectedBundleClient));
+ injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle;
+ WKContextSetInjectedBundleClient(context, &injectedBundleClient);
+}
+
+static RetainPtr<SyntheticBackingScaleFactorWindow> createWindow()
+{
+ RetainPtr<SyntheticBackingScaleFactorWindow> window(AdoptNS, [[SyntheticBackingScaleFactorWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+ [window.get() setReleasedWhenClosed:NO];
+ return window;
+}
+
+TEST(WebKit2, GetBackingScaleFactor)
+{
+ WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("GetBackingScaleFactorTest"));
+ setInjectedBundleClient(context.get());
+ RetainPtr<WKView> view(AdoptNS, [[WKView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) contextRef:context.get() pageGroupRef:0]);
+
+ RetainPtr<SyntheticBackingScaleFactorWindow> window1 = createWindow();
+ [window1.get() setBackingScaleFactor:1];
+
+ [[window1.get() contentView] addSubview:view.get()];
+ WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("GetBackingScaleFactor").get(), 0);
+ Util::run(&messageReceived);
+ messageReceived = false;
+ EXPECT_EQ(1, backingScaleFactor);
+
+ RetainPtr<SyntheticBackingScaleFactorWindow> window2 = createWindow();
+ [window2.get() setBackingScaleFactor:2];
+
+ [[window2.get() contentView] addSubview:view.get()];
+ WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("GetBackingScaleFactor").get(), 0);
+ Util::run(&messageReceived);
+ messageReceived = false;
+ EXPECT_EQ(2, backingScaleFactor);
+
+ WKPageSetCustomBackingScaleFactor(view.get().pageRef, 3);
+ WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("GetBackingScaleFactor").get(), 0);
+ Util::run(&messageReceived);
+ messageReceived = false;
+ EXPECT_EQ(3, backingScaleFactor);
+}
+
+} // namespace TestWebKitAPI
Property changes on: trunk/Tools/TestWebKitAPI/Tests/WebKit2/mac/GetBackingScaleFactor.mm
___________________________________________________________________
Added: svn:eol-style
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/mac/GetBackingScaleFactor_Bundle.mm (0 => 98588)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/mac/GetBackingScaleFactor_Bundle.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/mac/GetBackingScaleFactor_Bundle.mm 2011-10-27 16:24:41 UTC (rev 98588)
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import "config.h"
+
+#import "InjectedBundleTest.h"
+#import "PlatformUtilities.h"
+#import <WebKit2/WKBundlePage.h>
+#import <assert.h>
+
+namespace TestWebKitAPI {
+
+class GetBackingScaleFactorTest : public InjectedBundleTest {
+public:
+ GetBackingScaleFactorTest(const std::string&);
+
+private:
+ virtual void didCreatePage(WKBundleRef, WKBundlePageRef);
+ virtual void didReceiveMessage(WKBundleRef, WKStringRef messageName, WKTypeRef messageBody);
+
+ WKBundlePageRef m_page;
+};
+
+static InjectedBundleTest::Register<GetBackingScaleFactorTest> registrar("GetBackingScaleFactorTest");
+
+GetBackingScaleFactorTest::GetBackingScaleFactorTest(const std::string& identifier)
+ : InjectedBundleTest(identifier)
+ , m_page(0)
+{
+}
+
+void GetBackingScaleFactorTest::didCreatePage(WKBundleRef, WKBundlePageRef page)
+{
+ assert(!m_page);
+ m_page = page;
+}
+
+void GetBackingScaleFactorTest::didReceiveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef messageBody)
+{
+ if (!WKStringIsEqualToUTF8CString(messageName, "GetBackingScaleFactor"))
+ return;
+
+ WKRetainPtr<WKDoubleRef> backingScaleFactor = adoptWK(WKDoubleCreate(WKBundlePageGetBackingScaleFactor(m_page)));
+ WKBundlePostMessage(bundle, Util::toWK("DidGetBackingScaleFactor").get(), backingScaleFactor.get());
+}
+
+} // namespace TestWebKitAPI
Property changes on: trunk/Tools/TestWebKitAPI/Tests/WebKit2/mac/GetBackingScaleFactor_Bundle.mm
___________________________________________________________________
Added: svn:eol-style