Title: [156318] trunk
Revision
156318
Author
commit-qu...@webkit.org
Date
2013-09-23 21:00:29 -0700 (Mon, 23 Sep 2013)

Log Message

CSS Unit vh, vw, vmin and vmax in box-shadow are not applied.
https://bugs.webkit.org/show_bug.cgi?id=121422

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

Source/WebCore:

Box-shadow properties were not applied incase its values
were given in vh, vw, vmax, vmin unit.

Tests: fast/css/box-shadow-negative-viewportlength.html
       fast/css/box-shadow-viewport-height.html
       fast/css/box-shadow-viewport-vmax.html
       fast/css/box-shadow-viewport-vmin.html
       fast/css/box-shadow-viewport-width.html

* css/CSSParser.cpp:
(WebCore::CSSParser::parseShadow):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyProperty):
(WebCore::StyleResolver::MatchedProperties::~MatchedProperties):
(WebCore::StyleResolver::viewportPercentageHeight):
(WebCore::StyleResolver::viewportPercentageWidth):
(WebCore::StyleResolver::viewportPercentageMax):
(WebCore::StyleResolver::viewportPercentageMin):
* css/StyleResolver.h:
Parsing and calculating the shadow values which has been specified
in viewport units.The vh/vw units are calcultated as percent of
viewport height and viewport width respectively. 1vmax: 1vw or 1vh,
whatever is largest.1vmin: 1vw or 1vh, whatever is smallest.

LayoutTests:

* fast/css/box-shadow-negative-viewportlength-expected-mismatch.html: Added.
* fast/css/box-shadow-negative-viewportlength.html: Added.
* fast/css/box-shadow-viewport-height-expected-mismatch.html: Added.
* fast/css/box-shadow-viewport-height.html: Added.
* fast/css/box-shadow-viewport-vmax-expected-mismatch.html: Added.
* fast/css/box-shadow-viewport-vmax.html: Added.
* fast/css/box-shadow-viewport-vmin-expected-mismatch.html: Added.
* fast/css/box-shadow-viewport-vmin.html: Added.
* fast/css/box-shadow-viewport-width-expected-mismatch.html: Added.
* fast/css/box-shadow-viewport-width.html: Added.
Added new tests for verifying that box-shadow properties are
applied when its values are viewport units.
* fast/css/shadow-viewport-units-expected.txt:
* fast/css/shadow-viewport-units.html:
Rebaselining existing tests as per the new behavior. Support for shadow
properties with viewport units is added so modified the test case.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (156317 => 156318)


--- trunk/LayoutTests/ChangeLog	2013-09-24 02:48:14 UTC (rev 156317)
+++ trunk/LayoutTests/ChangeLog	2013-09-24 04:00:29 UTC (rev 156318)
@@ -1,3 +1,27 @@
+2013-09-23  Gurpreet Kaur  <k.gurpr...@samsung.com>
+
+        CSS Unit vh, vw, vmin and vmax in box-shadow are not applied.
+        https://bugs.webkit.org/show_bug.cgi?id=121422
+
+        Reviewed by Darin Adler.
+
+        * fast/css/box-shadow-negative-viewportlength-expected-mismatch.html: Added.
+        * fast/css/box-shadow-negative-viewportlength.html: Added.
+        * fast/css/box-shadow-viewport-height-expected-mismatch.html: Added.
+        * fast/css/box-shadow-viewport-height.html: Added.
+        * fast/css/box-shadow-viewport-vmax-expected-mismatch.html: Added.
+        * fast/css/box-shadow-viewport-vmax.html: Added.
+        * fast/css/box-shadow-viewport-vmin-expected-mismatch.html: Added.
+        * fast/css/box-shadow-viewport-vmin.html: Added.
+        * fast/css/box-shadow-viewport-width-expected-mismatch.html: Added.
+        * fast/css/box-shadow-viewport-width.html: Added.
+        Added new tests for verifying that box-shadow properties are
+        applied when its values are viewport units.
+        * fast/css/shadow-viewport-units-expected.txt:
+        * fast/css/shadow-viewport-units.html:
+        Rebaselining existing tests as per the new behavior. Support for shadow
+        properties with viewport units is added so modified the test case.
+
 2013-09-23  Simon Fraser  <simon.fra...@apple.com>
 
         REGRESSION (r155998): when zooming in, tiles are too small

Added: trunk/LayoutTests/fast/css/box-shadow-negative-viewportlength-expected-mismatch.html (0 => 156318)


--- trunk/LayoutTests/fast/css/box-shadow-negative-viewportlength-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/box-shadow-negative-viewportlength-expected-mismatch.html	2013-09-24 04:00:29 UTC (rev 156318)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #boxshadowDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;                         
+            }
+        </style>
+    </head>
+    <body>
+		<div id="boxshadowDiv"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/box-shadow-negative-viewportlength-expected-mismatch.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/css/box-shadow-negative-viewportlength.html (0 => 156318)


--- trunk/LayoutTests/fast/css/box-shadow-negative-viewportlength.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/box-shadow-negative-viewportlength.html	2013-09-24 04:00:29 UTC (rev 156318)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #boxshadowDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                box-shadow: -5vh -2vw 1vh 1vw orange;
+            }
+        </style>
+    </head>
+    <body>
+		<div id="boxshadowDiv"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/box-shadow-negative-viewportlength.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/css/box-shadow-viewport-height-expected-mismatch.html (0 => 156318)


--- trunk/LayoutTests/fast/css/box-shadow-viewport-height-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/box-shadow-viewport-height-expected-mismatch.html	2013-09-24 04:00:29 UTC (rev 156318)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #boxshadowDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                background: #555;                
+            }
+        </style>
+    </head>
+    <body>
+		<div id="boxshadowDiv"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/box-shadow-viewport-height-expected-mismatch.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/css/box-shadow-viewport-height.html (0 => 156318)


--- trunk/LayoutTests/fast/css/box-shadow-viewport-height.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/box-shadow-viewport-height.html	2013-09-24 04:00:29 UTC (rev 156318)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #boxshadowDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                box-shadow: 5vh 5vh 1vh 1vh orange;
+            }
+        </style>
+    </head>
+    <body>  
+		<div id="boxshadowDiv"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/box-shadow-viewport-height.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/css/box-shadow-viewport-vmax-expected-mismatch.html (0 => 156318)


--- trunk/LayoutTests/fast/css/box-shadow-viewport-vmax-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/box-shadow-viewport-vmax-expected-mismatch.html	2013-09-24 04:00:29 UTC (rev 156318)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #boxshadowDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                background: #555;                
+            }
+        </style>
+    </head>
+    <body>
+		<div id="boxshadowDiv"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/box-shadow-viewport-vmax-expected-mismatch.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/css/box-shadow-viewport-vmax.html (0 => 156318)


--- trunk/LayoutTests/fast/css/box-shadow-viewport-vmax.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/box-shadow-viewport-vmax.html	2013-09-24 04:00:29 UTC (rev 156318)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #boxshadowDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                box-shadow: 5vmax 5vmax 1vmax 1vmax orange;
+            }
+        </style>
+    </head>
+    <body>  
+		<div id="boxshadowDiv"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/box-shadow-viewport-vmax.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/css/box-shadow-viewport-vmin-expected-mismatch.html (0 => 156318)


--- trunk/LayoutTests/fast/css/box-shadow-viewport-vmin-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/box-shadow-viewport-vmin-expected-mismatch.html	2013-09-24 04:00:29 UTC (rev 156318)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #boxshadowDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                background: #555;                
+            }
+        </style>
+    </head>
+    <body>
+		<div id="boxshadowDiv"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/box-shadow-viewport-vmin-expected-mismatch.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/css/box-shadow-viewport-vmin.html (0 => 156318)


--- trunk/LayoutTests/fast/css/box-shadow-viewport-vmin.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/box-shadow-viewport-vmin.html	2013-09-24 04:00:29 UTC (rev 156318)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #boxshadowDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                box-shadow: 5vmin 5vmin 1vmin 1vmin orange;
+            }
+        </style>
+    </head>
+    <body>  
+		<div id="boxshadowDiv"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/box-shadow-viewport-vmin.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/css/box-shadow-viewport-width-expected-mismatch.html (0 => 156318)


--- trunk/LayoutTests/fast/css/box-shadow-viewport-width-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/box-shadow-viewport-width-expected-mismatch.html	2013-09-24 04:00:29 UTC (rev 156318)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #boxshadowDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                background: #555;                
+            }
+        </style>
+    </head>
+    <body>
+		<div id="boxshadowDiv"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/box-shadow-viewport-width-expected-mismatch.html
___________________________________________________________________

Added: svn:executable

Added: trunk/LayoutTests/fast/css/box-shadow-viewport-width.html (0 => 156318)


--- trunk/LayoutTests/fast/css/box-shadow-viewport-width.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/box-shadow-viewport-width.html	2013-09-24 04:00:29 UTC (rev 156318)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #boxshadowDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                box-shadow: 5vw 5vw 1vw 1vw orange;
+            }
+        </style>
+    </head>
+    <body>  
+		<div id="boxshadowDiv"></div>
+    </body>
+</html>
\ No newline at end of file
Property changes on: trunk/LayoutTests/fast/css/box-shadow-viewport-width.html
___________________________________________________________________

Added: svn:executable

Modified: trunk/LayoutTests/fast/css/shadow-viewport-units-expected.txt (156317 => 156318)


--- trunk/LayoutTests/fast/css/shadow-viewport-units-expected.txt	2013-09-24 02:48:14 UTC (rev 156317)
+++ trunk/LayoutTests/fast/css/shadow-viewport-units-expected.txt	2013-09-24 04:00:29 UTC (rev 156318)
@@ -1 +1 @@
-PASS: No shadow style
+PASS: Shadow style: rgb(0, 0, 0) 0px 0px 0px

Modified: trunk/LayoutTests/fast/css/shadow-viewport-units.html (156317 => 156318)


--- trunk/LayoutTests/fast/css/shadow-viewport-units.html	2013-09-24 02:48:14 UTC (rev 156317)
+++ trunk/LayoutTests/fast/css/shadow-viewport-units.html	2013-09-24 04:00:29 UTC (rev 156318)
@@ -1,5 +1,5 @@
 <style>
-#a { text-shadow: 0px 0px 0vh black; } /* Should be invalid - we don't yet support viewport units in shadow */
+#a { text-shadow: 0px 0px 0vh black; } /* Should be valid - we support viewport units in shadow */
 </style>
 <div id="a"></div>
 <script>
@@ -11,8 +11,8 @@
     var output = document.createElement("p");
     document.body.appendChild(output);
     if (window.getComputedStyle(a).textShadow == "none")
-        output.innerText = "PASS: No shadow style";
+        output.innerText = "FAIL: No shadow style";
     else
-        output.innerText = "FAIL: Shadow style: " + window.getComputedStyle(a).textShadow;
+        output.innerText = "PASS: Shadow style: " + window.getComputedStyle(a).textShadow;
 }, false);
 </script>

Modified: trunk/Source/WebCore/ChangeLog (156317 => 156318)


--- trunk/Source/WebCore/ChangeLog	2013-09-24 02:48:14 UTC (rev 156317)
+++ trunk/Source/WebCore/ChangeLog	2013-09-24 04:00:29 UTC (rev 156318)
@@ -1,3 +1,34 @@
+2013-09-23  Gurpreet Kaur  <k.gurpr...@samsung.com>
+
+        CSS Unit vh, vw, vmin and vmax in box-shadow are not applied.
+        https://bugs.webkit.org/show_bug.cgi?id=121422
+
+        Reviewed by Darin Adler.
+
+        Box-shadow properties were not applied incase its values
+        were given in vh, vw, vmax, vmin unit.
+
+        Tests: fast/css/box-shadow-negative-viewportlength.html
+               fast/css/box-shadow-viewport-height.html
+               fast/css/box-shadow-viewport-vmax.html
+               fast/css/box-shadow-viewport-vmin.html
+               fast/css/box-shadow-viewport-width.html
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseShadow):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::applyProperty):
+        (WebCore::StyleResolver::MatchedProperties::~MatchedProperties):
+        (WebCore::StyleResolver::viewportPercentageHeight):
+        (WebCore::StyleResolver::viewportPercentageWidth):
+        (WebCore::StyleResolver::viewportPercentageMax):
+        (WebCore::StyleResolver::viewportPercentageMin):
+        * css/StyleResolver.h:
+        Parsing and calculating the shadow values which has been specified
+        in viewport units.The vh/vw units are calcultated as percent of
+        viewport height and viewport width respectively. 1vmax: 1vw or 1vh,
+        whatever is largest.1vmin: 1vw or 1vh, whatever is smallest.
+
 2013-09-23  Ryuan Choi  <ryuan.c...@samsung.com>
 
         Unreviewed build fix for CMake ports with INDEXED_DATABASE after r156296

Modified: trunk/Source/WebCore/css/CSSParser.cpp (156317 => 156318)


--- trunk/Source/WebCore/css/CSSParser.cpp	2013-09-24 02:48:14 UTC (rev 156317)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2013-09-24 04:00:29 UTC (rev 156318)
@@ -6606,13 +6606,6 @@
             if (!context.allowLength())
                 return 0;
 
-            // We don't support viewport units for shadow values.
-            if (val->unit == CSSPrimitiveValue::CSS_VW
-                || val->unit == CSSPrimitiveValue::CSS_VH
-                || val->unit == CSSPrimitiveValue::CSS_VMIN
-                || val->unit == CSSPrimitiveValue::CSS_VMAX)
-                return 0;
-
             // Blur radius must be non-negative.
             if (context.allowBlur && !validUnit(val, FLength | FNonNeg, CSSStrictMode))
                 return 0;

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (156317 => 156318)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2013-09-24 02:48:14 UTC (rev 156317)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2013-09-24 04:00:29 UTC (rev 156318)
@@ -2387,9 +2387,17 @@
                 continue;
             ShadowValue* item = static_cast<ShadowValue*>(currValue);
             int x = item->x->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor);
+            if (item->x->isViewportPercentageLength())
+                x = viewportPercentageValue(*item->x, x);
             int y = item->y->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor);
+            if (item->y->isViewportPercentageLength())
+                y = viewportPercentageValue(*item->y, y);
             int blur = item->blur ? item->blur->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor) : 0;
+            if (item->blur && item->blur->isViewportPercentageLength())
+                blur = viewportPercentageValue(*item->blur, blur);
             int spread = item->spread ? item->spread->computeLength<int>(state.style(), state.rootElementStyle(), zoomFactor) : 0;
+            if (item->spread && item->spread->isViewportPercentageLength())
+                spread = viewportPercentageValue(*item->spread, spread);
             ShadowStyle shadowStyle = item->style && item->style->getValueID() == CSSValueInset ? Inset : Normal;
             Color color;
             if (item->color)
@@ -4057,4 +4065,22 @@
 {
 }
 
+int StyleResolver::viewportPercentageValue(CSSPrimitiveValue& unit, int percentage)
+{
+    int viewPortHeight = document().renderView()->viewportSize().height() * percentage / 100.0f;
+    int viewPortWidth = document().renderView()->viewportSize().width() * percentage / 100.0f;
+
+    if (unit.isViewportPercentageHeight())
+        return viewPortHeight;
+    if (unit.isViewportPercentageWidth())
+        return viewPortWidth;
+    if (unit.isViewportPercentageMax())
+        return max(viewPortWidth, viewPortHeight);
+    if (unit.isViewportPercentageMin())
+        return min(viewPortWidth, viewPortHeight);
+
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/css/StyleResolver.h (156317 => 156318)


--- trunk/Source/WebCore/css/StyleResolver.h	2013-09-24 02:48:14 UTC (rev 156317)
+++ trunk/Source/WebCore/css/StyleResolver.h	2013-09-24 04:00:29 UTC (rev 156318)
@@ -585,6 +585,8 @@
     bool classNamesAffectedByRules(const SpaceSplitString&) const;
     bool sharingCandidateHasIdenticalStyleAffectingAttributes(StyledElement*) const;
 
+    int viewportPercentageValue(CSSPrimitiveValue& unit, int percentage);
+
     unsigned m_matchedPropertiesCacheAdditionsSinceLastSweep;
 
     typedef HashMap<unsigned, MatchedPropertiesCacheItem> MatchedPropertiesCache;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to