Inset box-shadows fail to round around corners when border-radius is set in vh/vw...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Sep 2013 16:57:42 +0000 (16:57 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Sep 2013 16:57:42 +0000 (16:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=119187

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

Source/WebCore:

Border-radius properties were not applied incase its values
were given in vh, vw, vmax, vmin units.

Tests: fast/css/border-radius-inset-box-shadow-viewportlength.html
       fast/css/border-radius-viewport-height.html
       fast/css/border-radius-viewport-vmax.html
       fast/css/border-radius-viewport-vmin.html

* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyBorderRadius::applyValue):
(WebCore::ApplyPropertyComputeLength::applyValue):
* css/StyleResolver.h:
Calculating the border-radius 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/border-radius-inset-box-shadow-viewportlength-expected-mismatch.html: Added.
* fast/css/border-radius-inset-box-shadow-viewportlength.html: Added.
* fast/css/border-radius-viewport-height-expected-mismatch.html: Added.
* fast/css/border-radius-viewport-height.html: Added.
* fast/css/border-radius-viewport-vmax-expected-mismatch.html: Added.
* fast/css/border-radius-viewport-vmax.html: Added.
* fast/css/border-radius-viewport-vmin-expected-mismatch.html: Added.
* fast/css/border-radius-viewport-vmin.html: Added.
Added new tests for verifying that box-shadow and border-radius properties
are applied when its values are viewport units.

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/border-radius-inset-box-shadow-viewportlength-expected-mismatch.html [new file with mode: 0755]
LayoutTests/fast/css/border-radius-inset-box-shadow-viewportlength.html [new file with mode: 0755]
LayoutTests/fast/css/border-radius-viewport-height-expected-mismatch.html [new file with mode: 0755]
LayoutTests/fast/css/border-radius-viewport-height.html [new file with mode: 0755]
LayoutTests/fast/css/border-radius-viewport-vmax-expected-mismatch.html [new file with mode: 0755]
LayoutTests/fast/css/border-radius-viewport-vmax.html [new file with mode: 0755]
LayoutTests/fast/css/border-radius-viewport-vmin-expected-mismatch.html [new file with mode: 0755]
LayoutTests/fast/css/border-radius-viewport-vmin.html [new file with mode: 0755]
Source/WebCore/ChangeLog
Source/WebCore/css/DeprecatedStyleBuilder.cpp
Source/WebCore/css/StyleResolver.h

index 5a6d4d678d865d1777f8ad8b188bb87ce3373042..53a1a47c30214e1c13122fef15d2b798263492a0 100644 (file)
@@ -1,3 +1,21 @@
+2013-09-26  Gurpreet Kaur  <k.gurpreet@samsung.com>
+
+        Inset box-shadows fail to round around corners when border-radius is set in vh/vw units.
+        https://bugs.webkit.org/show_bug.cgi?id=119187
+
+        Reviewed by Darin Adler.
+
+        * fast/css/border-radius-inset-box-shadow-viewportlength-expected-mismatch.html: Added.
+        * fast/css/border-radius-inset-box-shadow-viewportlength.html: Added.
+        * fast/css/border-radius-viewport-height-expected-mismatch.html: Added.
+        * fast/css/border-radius-viewport-height.html: Added.
+        * fast/css/border-radius-viewport-vmax-expected-mismatch.html: Added.
+        * fast/css/border-radius-viewport-vmax.html: Added.
+        * fast/css/border-radius-viewport-vmin-expected-mismatch.html: Added.
+        * fast/css/border-radius-viewport-vmin.html: Added.
+        Added new tests for verifying that box-shadow and border-radius properties
+        are applied when its values are viewport units.
+
 2013-09-25  Oliver Hunt  <oliver@apple.com>
 
         Implement prefixed-destructuring assignment
diff --git a/LayoutTests/fast/css/border-radius-inset-box-shadow-viewportlength-expected-mismatch.html b/LayoutTests/fast/css/border-radius-inset-box-shadow-viewportlength-expected-mismatch.html
new file mode 100755 (executable)
index 0000000..5132977
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #borderradiusDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+            }
+        </style>
+    </head>
+    <body>        
+               <div id="borderradiusDiv"></div>
+    </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/border-radius-inset-box-shadow-viewportlength.html b/LayoutTests/fast/css/border-radius-inset-box-shadow-viewportlength.html
new file mode 100755 (executable)
index 0000000..6c72f2c
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #borderradiusDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                border-radius: 5vw;
+                box-shadow: inset -2vh 2vw 0 orange;
+            }
+        </style>
+    </head>
+    <body>        
+               <div id="borderradiusDiv"></div>
+    </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/border-radius-viewport-height-expected-mismatch.html b/LayoutTests/fast/css/border-radius-viewport-height-expected-mismatch.html
new file mode 100755 (executable)
index 0000000..5132977
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #borderradiusDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+            }
+        </style>
+    </head>
+    <body>        
+               <div id="borderradiusDiv"></div>
+    </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/border-radius-viewport-height.html b/LayoutTests/fast/css/border-radius-viewport-height.html
new file mode 100755 (executable)
index 0000000..5dc3c2b
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #borderradiusDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                border-radius: 5vh;
+                box-shadow: 2vh 2vw 1vh 1vw orange;
+            }
+        </style>
+    </head>
+    <body>        
+               <div id="borderradiusDiv"></div>
+    </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/border-radius-viewport-vmax-expected-mismatch.html b/LayoutTests/fast/css/border-radius-viewport-vmax-expected-mismatch.html
new file mode 100755 (executable)
index 0000000..5132977
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #borderradiusDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+            }
+        </style>
+    </head>
+    <body>        
+               <div id="borderradiusDiv"></div>
+    </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/border-radius-viewport-vmax.html b/LayoutTests/fast/css/border-radius-viewport-vmax.html
new file mode 100755 (executable)
index 0000000..b323eff
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #borderradiusDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                border-radius: 5vmax;
+                box-shadow: 1vh 1vw 1vh 1vw orange;
+            }
+        </style>
+    </head>
+    <body>        
+               <div id="borderradiusDiv"></div>
+    </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/border-radius-viewport-vmin-expected-mismatch.html b/LayoutTests/fast/css/border-radius-viewport-vmin-expected-mismatch.html
new file mode 100755 (executable)
index 0000000..5132977
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #borderradiusDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+            }
+        </style>
+    </head>
+    <body>        
+               <div id="borderradiusDiv"></div>
+    </body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/css/border-radius-viewport-vmin.html b/LayoutTests/fast/css/border-radius-viewport-vmin.html
new file mode 100755 (executable)
index 0000000..ebc937f
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            #borderradiusDiv{
+                margin-bottom: 10px;
+                height: 100px;
+                width: 100px;
+                background: #555;
+                border-radius: 3vmax;
+                box-shadow: 3vh 3vw 1vh 1vw orange;
+            }
+        </style>
+    </head>
+    <body>        
+               <div id="borderradiusDiv"></div>
+    </body>
+</html>
\ No newline at end of file
index 8817c4c75ed3fd03cde9c989d99fa34e9aac0b7c..b01a03a1c29017b61ae793e06e28745efde8430e 100644 (file)
@@ -1,3 +1,27 @@
+2013-09-26  Gurpreet Kaur  <k.gurpreet@samsung.com>
+
+        Inset box-shadows fail to round around corners when border-radius is set in vh/vw units.
+        https://bugs.webkit.org/show_bug.cgi?id=119187
+
+        Reviewed by Darin Adler.
+
+        Border-radius properties were not applied incase its values
+        were given in vh, vw, vmax, vmin units.
+
+        Tests: fast/css/border-radius-inset-box-shadow-viewportlength.html
+               fast/css/border-radius-viewport-height.html
+               fast/css/border-radius-viewport-vmax.html
+               fast/css/border-radius-viewport-vmin.html
+
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::ApplyPropertyBorderRadius::applyValue):
+        (WebCore::ApplyPropertyComputeLength::applyValue):
+        * css/StyleResolver.h:
+        Calculating the border-radius 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-26  Seokju Kwon  <seokju@webkit.org>
 
         Fix ordered comparison warnings in BitmapImage::drawPattern
index ff5852057f2913830c51a89f4ef3e4a45e640e7d..711dafdd4c75b5183ccc621081d85de239b8cb99 100644 (file)
@@ -449,7 +449,7 @@ public:
         if (pair->first()->isPercentage())
             radiusWidth = Length(pair->first()->getDoubleValue(), Percent);
         else if (pair->first()->isViewportPercentageLength())
-            radiusWidth = pair->first()->viewportPercentageLength();
+            radiusWidth = Length(styleResolver->viewportPercentageValue(*pair->first(), pair->first()->getIntValue()), Fixed);
         else if (pair->first()->isCalculatedPercentageWithLength())
             radiusWidth = Length((pair->first()->cssCalcValue()->toCalcValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom())));
         else
@@ -457,7 +457,7 @@ public:
         if (pair->second()->isPercentage())
             radiusHeight = Length(pair->second()->getDoubleValue(), Percent);
         else if (pair->second()->isViewportPercentageLength())
-            radiusHeight = pair->second()->viewportPercentageLength();
+            radiusHeight = Length(styleResolver->viewportPercentageValue(*pair->second(), pair->second()->getIntValue()), Fixed);
         else if (pair->second()->isCalculatedPercentageWithLength())
             radiusHeight = Length((pair->second()->cssCalcValue()->toCalcValue(styleResolver->style(), styleResolver->rootElementStyle(), styleResolver->style()->effectiveZoom())));
         else
@@ -625,18 +625,8 @@ public:
                 if (originalLength >= 1.0)
                     length = 1.0;
             }
-            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);
-            }
+            if (primitiveValue->isViewportPercentageLength())
+                length = styleResolver->viewportPercentageValue(*primitiveValue, length);
         } else {
             ASSERT_NOT_REACHED();
             length = 0;
index 9fe49f67af1fd5f188482f86a2945aa33f76236f..f652f55ea2e1796b9dad27a4c2518d8c6e0bebba 100644 (file)
@@ -310,6 +310,8 @@ public:
 
     void loadPendingResources();
 
+    int viewportPercentageValue(CSSPrimitiveValue& unit, int percentage);
+
     struct RuleRange {
         RuleRange(int& firstRuleIndex, int& lastRuleIndex): firstRuleIndex(firstRuleIndex), lastRuleIndex(lastRuleIndex) { }
         int& firstRuleIndex;
@@ -585,7 +587,6 @@ private:
     bool classNamesAffectedByRules(const SpaceSplitString&) const;
     bool sharingCandidateHasIdenticalStyleAffectingAttributes(StyledElement*) const;
 
-    int viewportPercentageValue(CSSPrimitiveValue& unit, int percentage);
 
     unsigned m_matchedPropertiesCacheAdditionsSinceLastSweep;