Viewport unit values affected by Comand-+ zoom
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Nov 2017 18:59:39 +0000 (18:59 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Nov 2017 18:59:39 +0000 (18:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145614

Reviewed by Zalan Bujtas.
Source/WebCore:

Don't apply zooming when resolving viewport-relative lengths, since they should not
change based on the zoom level.

Test: fast/css/viewport-units-zoom.html

* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble):

Tools:

Fix Command+ and Command- in MiniBrowser to do zooming, rather than being tied
to editing commands.

* MiniBrowser/mac/MainMenu.xib:

LayoutTests:

* fast/css/viewport-units-zoom-expected.html: Added.
* fast/css/viewport-units-zoom.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css/viewport-units-zoom-expected.html [new file with mode: 0644]
LayoutTests/fast/css/viewport-units-zoom.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSPrimitiveValue.cpp
Tools/ChangeLog
Tools/MiniBrowser/mac/MainMenu.xib

index 884a60f..d50804c 100644 (file)
@@ -1,3 +1,13 @@
+2017-11-29  Simon Fraser  <simon.fraser@apple.com>
+
+        Viewport unit values affected by Comand-+ zoom
+        https://bugs.webkit.org/show_bug.cgi?id=145614
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/css/viewport-units-zoom-expected.html: Added.
+        * fast/css/viewport-units-zoom.html: Added.
+
 2017-11-29  Ms2ger  <Ms2ger@igalia.com>
 
         Enable imported/w3c/web-platform-tests/resource-timing/single-entry-per-resource.html.
diff --git a/LayoutTests/fast/css/viewport-units-zoom-expected.html b/LayoutTests/fast/css/viewport-units-zoom-expected.html
new file mode 100644 (file)
index 0000000..f6bd46d
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            margin: 0;
+        }
+        .box {
+            background-color: green;
+            margin-top: 10px;
+        }
+        
+        .width {
+            width: 50vw;
+            height: 100px;
+        }
+    </style>
+</head>
+<body>
+<p>Both boxes should be the same width.</p>
+<div class="box width"></div>
+<div class="box width" style="height: 200px; margin-top: 20px"></div>
+</body>
+</html>
diff --git a/LayoutTests/fast/css/viewport-units-zoom.html b/LayoutTests/fast/css/viewport-units-zoom.html
new file mode 100644 (file)
index 0000000..0b38ba8
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            margin: 0;
+        }
+        .box {
+            background-color: green;
+            margin-top: 10px;
+        }
+        
+        .width {
+            width: 50vw;
+            height: 100px;
+        }
+    </style>
+</head>
+<body>
+<p>Both boxes should be the same width.</p>
+<div class="box width"></div>
+<div class="box width" style="zoom:2"></div>
+</body>
+</html>
index efd29b2..3066157 100644 (file)
@@ -1,3 +1,18 @@
+2017-11-29  Simon Fraser  <simon.fraser@apple.com>
+
+        Viewport unit values affected by Comand-+ zoom
+        https://bugs.webkit.org/show_bug.cgi?id=145614
+
+        Reviewed by Zalan Bujtas.
+        
+        Don't apply zooming when resolving viewport-relative lengths, since they should not
+        change based on the zoom level.
+
+        Test: fast/css/viewport-units-zoom.html
+
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble):
+
 2017-11-29  Brent Fulgham  <bfulgham@apple.com>
 
         Unreviewed test fix after r225264.
index 9c3e690..a761276 100644 (file)
@@ -640,6 +640,7 @@ double CSSPrimitiveValue::computeLengthDouble(const CSSToLengthConversionData& c
 double CSSPrimitiveValue::computeNonCalcLengthDouble(const CSSToLengthConversionData& conversionData, UnitType primitiveType, double value)
 {
     double factor;
+    bool applyZoom = true;
 
     switch (primitiveType) {
     case CSS_EMS:
@@ -692,15 +693,19 @@ double CSSPrimitiveValue::computeNonCalcLengthDouble(const CSSToLengthConversion
         return -1.0;
     case CSS_VH:
         factor = conversionData.viewportHeightFactor();
+        applyZoom = false;
         break;
     case CSS_VW:
         factor = conversionData.viewportWidthFactor();
+        applyZoom = false;
         break;
     case CSS_VMAX:
         factor = conversionData.viewportMaxFactor();
+        applyZoom = false;
         break;
     case CSS_VMIN:
         factor = conversionData.viewportMinFactor();
+        applyZoom = false;
         break;
     default:
         ASSERT_NOT_REACHED();
@@ -714,7 +719,10 @@ double CSSPrimitiveValue::computeNonCalcLengthDouble(const CSSToLengthConversion
     if (conversionData.computingFontSize() || isFontRelativeLength(primitiveType))
         return result;
 
-    return result * conversionData.zoom();
+    if (applyZoom)
+        result *= conversionData.zoom();
+
+    return result;
 }
 
 ExceptionOr<void> CSSPrimitiveValue::setFloatValue(unsigned short, double)
index b30c83c..1027017 100644 (file)
@@ -1,3 +1,15 @@
+2017-11-29  Simon Fraser  <simon.fraser@apple.com>
+
+        Viewport unit values affected by Comand-+ zoom
+        https://bugs.webkit.org/show_bug.cgi?id=145614
+
+        Reviewed by Zalan Bujtas.
+        
+        Fix Command+ and Command- in MiniBrowser to do zooming, rather than being tied
+        to editing commands.
+
+        * MiniBrowser/mac/MainMenu.xib:
+
 2017-11-29  Alex Christensen  <achristensen@webkit.org>
 
         Add test for _WKVisitedLinkStore.addVisitedLinkWithString
index 3fe2a1d..0ae3716 100644 (file)
@@ -1,8 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11521.1" systemVersion="16B2648a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13168.4" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
     <dependencies>
-        <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11521.1"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13168.4"/>
     </dependencies>
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
                                             </connections>
                                         </menuItem>
                                         <menuItem isSeparatorItem="YES" id="dKY-wH-ZAW"/>
-                                        <menuItem title="Bigger" tag="3" keyEquivalent="+" id="V0U-mA-5AK">
+                                        <menuItem title="Bigger" tag="3" id="V0U-mA-5AK">
+                                            <modifierMask key="keyEquivalentModifierMask"/>
                                             <connections>
                                                 <action selector="modifyFont:" target="420" id="hmF-PZ-vVH"/>
                                             </connections>
                                         </menuItem>
-                                        <menuItem title="Smaller" tag="4" keyEquivalent="-" id="hWP-7f-ZV3">
+                                        <menuItem title="Smaller" tag="4" id="hWP-7f-ZV3">
+                                            <modifierMask key="keyEquivalentModifierMask"/>
                                             <connections>
                                                 <action selector="modifyFont:" target="420" id="pnr-Yn-h6p"/>
                                             </connections>