<rdar://problem/10981173> Dashboard regions should not be in device space
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Mar 2012 21:20:30 +0000 (21:20 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Mar 2012 21:20:30 +0000 (21:20 +0000)
Reviewed by John Sullivan.

Source/WebCore:

Test: TestWebKitAPI/Tests/mac/DeviceScaleFactorInDashboardRegions.mm

* rendering/RenderInline.cpp:
(WebCore::RenderInline::addDashboardRegions): Stop applying the device scale factor to
Dashboard regions.
* rendering/RenderObject.cpp:
(WebCore::RenderObject::addDashboardRegions): Ditto.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/DeviceScaleFactorInDashboardRegions.mm: Added.
(-[DeviceScaleFactorInDashboardRegionsUIDelegate webView:dashboardRegionsChanged:]):
(TestWebKitAPI):
(TestWebKitAPI::TEST):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderObject.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorInDashboardRegions.mm [new file with mode: 0644]

index ab91c8970e4e96a1348f150d2186d20a17697b22..c0075988cfcf6f0de33c26a9c31e8d14550dbec2 100644 (file)
@@ -1,3 +1,17 @@
+2012-03-08  Dan Bernstein  <mitz@apple.com>
+
+        <rdar://problem/10981173> Dashboard regions should not be in device space
+
+        Reviewed by John Sullivan.
+
+        Test: TestWebKitAPI/Tests/mac/DeviceScaleFactorInDashboardRegions.mm
+
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::addDashboardRegions): Stop applying the device scale factor to
+        Dashboard regions.
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::addDashboardRegions): Ditto.
+
 2012-03-08  Cem Kocagil  <cem.kocagil@gmail.com>
 
         Web Inspector: Cannot insert right curly bracket on some keyboards
index a5d582436236b446becf6fdb0ac1ebee6e7cbd05..3f12ed6e0e86337f53711baa1286804ffbdfe602 100644 (file)
@@ -1587,14 +1587,6 @@ void RenderInline::addDashboardRegions(Vector<DashboardRegionValue>& regions)
         region.bounds.setX(absPos.x() + region.bounds.x());
         region.bounds.setY(absPos.y() + region.bounds.y());
 
-        if (frame()) {
-            float deviceScaleFactor = frame()->page()->deviceScaleFactor();
-            if (deviceScaleFactor != 1.0f) {
-                region.bounds.scale(deviceScaleFactor);
-                region.clip.scale(deviceScaleFactor);
-            }
-        }
-
         regions.append(region);
     }
 }
index e1e333f42596ecf569a18c47a9e2cfe3f43189b3..f797840b66740c720932fbde831c29be15f8579b 100755 (executable)
@@ -2631,14 +2631,6 @@ void RenderObject::addDashboardRegions(Vector<DashboardRegionValue>& regions)
         region.bounds.setX(absPos.x() + styleRegion.offset.left().value());
         region.bounds.setY(absPos.y() + styleRegion.offset.top().value());
 
-        if (frame()) {
-            float deviceScaleFactor = frame()->page()->deviceScaleFactor();
-            if (deviceScaleFactor != 1.0f) {
-                region.bounds.scale(deviceScaleFactor);
-                region.clip.scale(deviceScaleFactor);
-            }
-        }
-
         regions.append(region);
     }
 }
index cd38ea309d4e88e145fdc2674e1f1983065df485..296f2586769f3fde86f9bd80e734a7286209c90a 100644 (file)
@@ -1,3 +1,15 @@
+2012-03-08  Dan Bernstein  <mitz@apple.com>
+
+        <rdar://problem/10981173> Dashboard regions should not be in device space
+
+        Reviewed by John Sullivan.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/mac/DeviceScaleFactorInDashboardRegions.mm: Added.
+        (-[DeviceScaleFactorInDashboardRegionsUIDelegate webView:dashboardRegionsChanged:]):
+        (TestWebKitAPI):
+        (TestWebKitAPI::TEST):
+
 2012-03-08  Dirk Pranke  <dpranke@chromium.org>
 
         webkit-patch works oddly on local Git branches
index 8107d08d779b2196eaf1dda72bed312b795a692b..b86444001e5e746028f281e032645bb55cd4c06f 100644 (file)
@@ -28,6 +28,7 @@
                33E79E06137B5FD900E32D99 /* mouse-move-listener.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */; };
                37200B9213A16230007A4FAD /* VectorReverse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37200B9113A16230007A4FAD /* VectorReverse.cpp */; };
                3722C8691461E03E00C45D00 /* RenderedImageFromDOMRange.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */; };
+               3776BC63150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3776BC62150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm */; };
                379028B614FABD92007E6B43 /* AcceptsFirstMouse.mm in Sources */ = {isa = PBXBuildFile; fileRef = 379028B514FABD92007E6B43 /* AcceptsFirstMouse.mm */; };
                379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 379028B814FABE49007E6B43 /* acceptsFirstMouse.html */; };
                3799AD3A14120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3799AD3914120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm */; };
                33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "mouse-move-listener.html"; sourceTree = "<group>"; };
                37200B9113A16230007A4FAD /* VectorReverse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VectorReverse.cpp; path = WTF/VectorReverse.cpp; sourceTree = "<group>"; };
                3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderedImageFromDOMRange.mm; sourceTree = "<group>"; };
+               3776BC62150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeviceScaleFactorInDashboardRegions.mm; sourceTree = "<group>"; };
                379028B514FABD92007E6B43 /* AcceptsFirstMouse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AcceptsFirstMouse.mm; sourceTree = "<group>"; };
                379028B814FABE49007E6B43 /* acceptsFirstMouse.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = acceptsFirstMouse.html; sourceTree = "<group>"; };
                3799AD3914120A43005EB0C6 /* StringByEvaluatingJavaScriptFromString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StringByEvaluatingJavaScriptFromString.mm; sourceTree = "<group>"; };
                                379028B514FABD92007E6B43 /* AcceptsFirstMouse.mm */,
                                37DC678B140D7C5000ABCCDB /* DOMRangeOfString.mm */,
                                C07E6CAE13FD67650038B22B /* DynamicDeviceScaleFactor.mm */,
+                               3776BC62150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm */,
                                939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */,
                                C507E8A614C6545B005D6B3B /* InspectorBar.mm */,
                                3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */,
                                BC22D31514DC689800FFB1DD /* UserMessage.cpp in Sources */,
                                E490296814E2E3A4002BEDD1 /* TypingStyleCrash.mm in Sources */,
                                379028B614FABD92007E6B43 /* AcceptsFirstMouse.mm in Sources */,
+                               3776BC63150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorInDashboardRegions.mm b/Tools/TestWebKitAPI/Tests/mac/DeviceScaleFactorInDashboardRegions.mm
new file mode 100644 (file)
index 0000000..f203564
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+#import "config.h"
+
+#import "PlatformUtilities.h"
+#import "SyntheticBackingScaleFactorWindow.h"
+#import "Test.h"
+#import <WebKit/WebDashboardRegion.h>
+#import <wtf/RetainPtr.h>
+
+static bool gotDashboardRegions;
+static NSDictionary *regions;
+
+@interface DeviceScaleFactorInDashboardRegionsUIDelegate : NSObject {
+}
+@end
+
+@implementation DeviceScaleFactorInDashboardRegionsUIDelegate
+
+- (void)webView:(WebView *)webView dashboardRegionsChanged:(NSDictionary *)newRegions
+{
+    gotDashboardRegions = true;
+    regions = [newRegions retain];
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, DeviceScaleFactorInDashboardRegions)
+{
+    NSRect viewFrame = NSMakeRect(0, 0, 800, 600);
+    RetainPtr<SyntheticBackingScaleFactorWindow> window(AdoptNS, [[SyntheticBackingScaleFactorWindow alloc] initWithContentRect:viewFrame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+    [window.get() setReleasedWhenClosed:NO];
+    [window.get() setBackingScaleFactor:2];
+
+    RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:viewFrame frameName:nil groupName:nil]);
+    RetainPtr<DeviceScaleFactorInDashboardRegionsUIDelegate> uiDelegate(AdoptNS, [DeviceScaleFactorInDashboardRegionsUIDelegate new]);
+    webView.get().UIDelegate = uiDelegate.get();
+    [window.get().contentView addSubview:webView.get()];
+
+    [webView.get().mainFrame loadHTMLString:@"<div style='position: absolute; top: 10px; left: 10px; width: 50px; height: 50px; -webkit-dashboard-region: dashboard-region(control rectangle);'></div>" baseURL:[NSURL URLWithString:@"about:blank"]];
+
+    Util::run(&gotDashboardRegions);
+
+    NSRect controlRegionRect = [[[regions objectForKey:@"control"] objectAtIndex:0] dashboardRegionRect];
+
+    EXPECT_EQ(10, controlRegionRect.origin.x);
+    EXPECT_EQ(10, controlRegionRect.origin.y);
+    EXPECT_EQ(50, controlRegionRect.size.width);
+    EXPECT_EQ(50, controlRegionRect.size.height);
+
+    [regions release];
+}
+
+} // namespace TestWebKitAPI