CSS Unit vmax and vmin in border-width not handled.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Sep 2013 11:03:32 +0000 (11:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Sep 2013 11:03:32 +0000 (11:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=121421

Patch by Gurpreet Kaur <k.gurpreet@samsung.com> on 2013-09-19
Reviewed by Darin Adler.

Source/WebCore:

Border properties were not applied incase its values
were given in vmax/vmin units.

Tests: fast/css/viewport-vmax-border.html
       fast/css/viewport-vmin-border.html

* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::computeLengthDouble):
* css/CSSPrimitiveValue.h:
(WebCore::CSSPrimitiveValue::isViewportPercentageMax):
(WebCore::CSSPrimitiveValue::isViewportPercentageMin):
* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyComputeLength::applyValue):
Calculating the border values which has been specified in
vmax/vmin units. 1vmax: 1vw or 1vh, whatever is largest.
1vmin: 1vw or 1vh, whatever is smallest. The vh/vw units are
calcultated as percent of viewport height and viewport width respectively.

LayoutTests:

* fast/css/viewport-vmax-border-expected.txt: Added.
* fast/css/viewport-vmax-border.html: Added.
* fast/css/viewport-vmin-border-expected.txt: Added.
* fast/css/viewport-vmin-border.html: Added.
Added new tests for verifying that border properties are
applied when its values are given in vmax/vmin units.

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

LayoutTests/ChangeLog
LayoutTests/fast/css/viewport-vmax-border-expected.txt [new file with mode: 0755]
LayoutTests/fast/css/viewport-vmax-border.html [new file with mode: 0755]
LayoutTests/fast/css/viewport-vmin-border-expected.txt [new file with mode: 0755]
LayoutTests/fast/css/viewport-vmin-border.html [new file with mode: 0755]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSPrimitiveValue.cpp
Source/WebCore/css/CSSPrimitiveValue.h
Source/WebCore/css/DeprecatedStyleBuilder.cpp

index 1f986d3..f99341a 100644 (file)
@@ -1,3 +1,17 @@
+2013-09-19  Gurpreet Kaur  <k.gurpreet@samsung.com>
+
+        CSS Unit vmax and vmin in border-width not handled.
+        https://bugs.webkit.org/show_bug.cgi?id=121421
+
+        Reviewed by Darin Adler.
+
+        * fast/css/viewport-vmax-border-expected.txt: Added.
+        * fast/css/viewport-vmax-border.html: Added.
+        * fast/css/viewport-vmin-border-expected.txt: Added.
+        * fast/css/viewport-vmin-border.html: Added.
+        Added new tests for verifying that border properties are
+        applied when its values are given in vmax/vmin units.
+
 2013-09-19  Antti Koivisto  <antti@apple.com>
 
         [CTTE] RenderText is always anonymous or associated with Text node
diff --git a/LayoutTests/fast/css/viewport-vmax-border-expected.txt b/LayoutTests/fast/css/viewport-vmax-border-expected.txt
new file mode 100755 (executable)
index 0000000..eca4ee7
--- /dev/null
@@ -0,0 +1,10 @@
+Tests that vmax unit works for border-width property
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementById('borderDiv').offsetHeight > 100 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/viewport-vmax-border.html b/LayoutTests/fast/css/viewport-vmax-border.html
new file mode 100755 (executable)
index 0000000..61b088b
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src="../../resources/js-test-pre.js"></script>
+        <script>
+            function runTest() {
+                description('Tests that vmax unit works for border-width property');
+                               
+                shouldBeTrue("document.getElementById('borderDiv').offsetHeight > 100");
+                isSuccessfullyParsed();
+            }
+        </script>
+        <style>
+            #borderDiv{
+                width: 100px;
+                height: 100px;
+                background: green;
+                border: 5vmax solid red;
+            }
+        </style>
+    </head>
+    <body onload="runTest()">
+        <div id="borderDiv"></div>
+    </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/viewport-vmin-border-expected.txt b/LayoutTests/fast/css/viewport-vmin-border-expected.txt
new file mode 100755 (executable)
index 0000000..eca4ee7
--- /dev/null
@@ -0,0 +1,10 @@
+Tests that vmax unit works for border-width property
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementById('borderDiv').offsetHeight > 100 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/viewport-vmin-border.html b/LayoutTests/fast/css/viewport-vmin-border.html
new file mode 100755 (executable)
index 0000000..1349090
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src="../../resources/js-test-pre.js"></script>
+        <script>
+            function runTest() {
+                description('Tests that vmax unit works for border-width property');
+                               
+                shouldBeTrue("document.getElementById('borderDiv').offsetHeight > 100");
+                isSuccessfullyParsed();
+            }
+        </script>
+        <style>
+            #borderDiv{
+                width: 100px;
+                height: 100px;
+                background: green;
+                border: 5vmin solid red;
+            }
+        </style>
+    </head>
+    <body onload="runTest()">
+        <div id="borderDiv"></div>
+    </body>
+</html>
\ No newline at end of file
index 8800a68..5f448e9 100644 (file)
@@ -1,3 +1,28 @@
+2013-09-19  Gurpreet Kaur  <k.gurpreet@samsung.com>
+
+        CSS Unit vmax and vmin in border-width not handled.
+        https://bugs.webkit.org/show_bug.cgi?id=121421
+
+        Reviewed by Darin Adler.
+
+        Border properties were not applied incase its values 
+        were given in vmax/vmin units.
+
+        Tests: fast/css/viewport-vmax-border.html
+               fast/css/viewport-vmin-border.html
+
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::computeLengthDouble):
+        * css/CSSPrimitiveValue.h:
+        (WebCore::CSSPrimitiveValue::isViewportPercentageMax):
+        (WebCore::CSSPrimitiveValue::isViewportPercentageMin):
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::ApplyPropertyComputeLength::applyValue):
+        Calculating the border values which has been specified in
+        vmax/vmin units. 1vmax: 1vw or 1vh, whatever is largest.
+        1vmin: 1vw or 1vh, whatever is smallest. The vh/vw units are 
+        calcultated as percent of viewport height and viewport width respectively.
+
 2013-09-19  Antti Koivisto  <antti@apple.com>
 
         [CTTE] RenderText is always anonymous or associated with Text node
index 0f24181..bf220cf 100644 (file)
@@ -602,6 +602,8 @@ double CSSPrimitiveValue::computeLengthDouble(const RenderStyle* style, const Re
             return -1.0;
         case CSS_VH:
         case CSS_VW:
+        case CSS_VMAX:
+        case CSS_VMIN:
             factor = 1.0;
             break;
         default:
index 1ab3208..64206f8 100644 (file)
@@ -204,6 +204,8 @@ public:
     bool isViewportPercentageLength() const { return m_primitiveUnitType >= CSS_VW && m_primitiveUnitType <= CSS_VMAX; }
     bool isViewportPercentageWidth() const { return m_primitiveUnitType == CSS_VW; }
     bool isViewportPercentageHeight() const { return m_primitiveUnitType == CSS_VH; }
+    bool isViewportPercentageMax() const { return m_primitiveUnitType == CSS_VMAX; }
+    bool isViewportPercentageMin() const { return m_primitiveUnitType == CSS_VMIN; }
     bool isValueID() const { return m_primitiveUnitType == CSS_VALUE_ID; }
     
     static PassRefPtr<CSSPrimitiveValue> createIdentifier(CSSValueID valueID) { return adoptRef(new CSSPrimitiveValue(valueID)); }
index b103c44..11957d8 100644 (file)
@@ -615,10 +615,18 @@ public:
                 if (originalLength >= 1.0)
                     length = 1.0;
             }
-            if (primitiveValue->isViewportPercentageHeight())
-                length = styleResolver->document().renderView()->viewportSize().height() * length / 100.0f;
-            else if (primitiveValue->isViewportPercentageWidth())
-                length = styleResolver->document().renderView()->viewportSize().width() * length / 100.0f;
+            if (primitiveValue->isViewportPercentageLength()) { 
+                int viewPortHeight = styleResolver->document().renderView()->viewportSize().height() * length / 100.0f;
+                int viewPortWidth = styleResolver->document().renderView()->viewportSize().width() * length / 100.0f;
+                if (primitiveValue->isViewportPercentageHeight())
+                    length = viewPortHeight;
+                else if (primitiveValue->isViewportPercentageWidth())
+                    length = viewPortWidth;
+                else if (primitiveValue->isViewportPercentageMax())
+                    length = max(viewPortWidth, viewPortHeight);
+                else if (primitiveValue->isViewportPercentageMin())
+                    length = min(viewPortWidth, viewPortHeight);
+            }
         } else {
             ASSERT_NOT_REACHED();
             length = 0;