Title: [175197] trunk
Revision
175197
Author
za...@apple.com
Date
2014-10-24 19:37:41 -0700 (Fri, 24 Oct 2014)

Log Message

Clamp wordSpacing percentage value.
https://bugs.webkit.org/show_bug.cgi?id=129350.

Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2014-10-24
Reviewed by Zalan Bujtas.

Source/WebCore:

When the CSS wordSpacing property is percentage, its value has to be within the
pre-defined min/max values for the CSS length type. This is done the same way
the wordSpacing of type <length> is handled.

Tests: css3/infinite-word-spacing.html.

Move the definitions of minValueForCssLength and maxValueForCssLength from the
.cpp file to the .h file.
* css/CSSPrimitiveValue.cpp:
* css/CSSPrimitiveValue.h:

Clamp the wordSpacing value to minValueForCssLength and maxValueForCssLength when
its type is percentage.
* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyWordSpacing::applyValue):

LayoutTests:

Make sure that setting the CSS style wordSpacing property to very huge percentage
value and blending this value with other values for animating key frames does
not assert or crash. The expectation is to have this huge value to be clamped to
the pre-defined min/max values for the CSS length type. So when blending the clamped
value with other wordSpacing values, the result can't be NaN. This should be very
similar to the case when it is set to a huge <length> value.

* css3/infinite-word-spacing-expected.txt: Added.
* css3/infinite-word-spacing.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (175196 => 175197)


--- trunk/LayoutTests/ChangeLog	2014-10-25 02:15:31 UTC (rev 175196)
+++ trunk/LayoutTests/ChangeLog	2014-10-25 02:37:41 UTC (rev 175197)
@@ -1,3 +1,20 @@
+2014-10-24  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        Clamp wordSpacing percentage value.
+        https://bugs.webkit.org/show_bug.cgi?id=129350.
+
+        Reviewed by Zalan Bujtas.
+
+        Make sure that setting the CSS style wordSpacing property to very huge percentage
+        value and blending this value with other values for animating key frames does
+        not assert or crash. The expectation is to have this huge value to be clamped to
+        the pre-defined min/max values for the CSS length type. So when blending the clamped
+        value with other wordSpacing values, the result can't be NaN. This should be very
+        similar to the case when it is set to a huge <length> value.
+
+        * css3/infinite-word-spacing-expected.txt: Added.
+        * css3/infinite-word-spacing.html: Added.
+
 2014-10-24  Alexey Proskuryakov  <a...@apple.com>
 
         Update Yosemite results for fast/block/float/overhanging-tall-block.html for

Added: trunk/LayoutTests/css3/infinite-word-spacing-expected.txt (0 => 175197)


--- trunk/LayoutTests/css3/infinite-word-spacing-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/infinite-word-spacing-expected.txt	2014-10-25 02:37:41 UTC (rev 175197)
@@ -0,0 +1 @@
+PASS if no assert or crash in debug.

Added: trunk/LayoutTests/css3/infinite-word-spacing.html (0 => 175197)


--- trunk/LayoutTests/css3/infinite-word-spacing.html	                        (rev 0)
+++ trunk/LayoutTests/css3/infinite-word-spacing.html	2014-10-25 02:37:41 UTC (rev 175197)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style>
+    h1 {
+        -webkit-animation-name: spacing;
+        -webkit-animation-duration: 1s;
+    }
+    @-webkit-keyframes spacing {
+      0%  {
+        word-spacing: normal
+      }
+      20%  {
+        word-spacing: 11111111111111111111111111111111111111111111111111%
+      }
+      40%  {
+        word-spacing: 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111%
+      }
+      60%  {
+        word-spacing: 200%
+      }
+      80%  {
+        word-spacing: 300%
+      }
+      100% { }
+    }
+  </style>
+</head>
+<script>
+if (window.testRunner)
+  testRunner.dumpAsText();
+</script>
+<body>
+<h1>PASS if no assert or crash in debug.</h1>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (175196 => 175197)


--- trunk/Source/WebCore/ChangeLog	2014-10-25 02:15:31 UTC (rev 175196)
+++ trunk/Source/WebCore/ChangeLog	2014-10-25 02:37:41 UTC (rev 175197)
@@ -1,3 +1,26 @@
+2014-10-24  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        Clamp wordSpacing percentage value.
+        https://bugs.webkit.org/show_bug.cgi?id=129350.
+
+        Reviewed by Zalan Bujtas.
+
+        When the CSS wordSpacing property is percentage, its value has to be within the
+        pre-defined min/max values for the CSS length type. This is done the same way
+        the wordSpacing of type <length> is handled.
+
+        Tests: css3/infinite-word-spacing.html.
+
+        Move the definitions of minValueForCssLength and maxValueForCssLength from the
+        .cpp file to the .h file.
+        * css/CSSPrimitiveValue.cpp:
+        * css/CSSPrimitiveValue.h:
+
+        Clamp the wordSpacing value to minValueForCssLength and maxValueForCssLength when
+        its type is percentage.
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::ApplyPropertyWordSpacing::applyValue):
+
 2014-10-24  Chris Dumez  <cdu...@apple.com>
 
         [Mac] Use modern loops in ResourceRequestCocoa.mm

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (175196 => 175197)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp	2014-10-25 02:15:31 UTC (rev 175196)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp	2014-10-25 02:37:41 UTC (rev 175197)
@@ -33,7 +33,6 @@
 #include "Counter.h"
 #include "ExceptionCode.h"
 #include "Font.h"
-#include "LayoutUnit.h"
 #include "Node.h"
 #include "Pair.h"
 #include "RGBColor.h"
@@ -59,11 +58,6 @@
 
 namespace WebCore {
 
-// Max/min values for CSS, needs to slightly smaller/larger than the true max/min values to allow for rounding without overflowing.
-// Subtract two (rather than one) to allow for values to be converted to float and back without exceeding the LayoutUnit::max.
-const int maxValueForCssLength = intMaxForLayoutUnit - 2;
-const int minValueForCssLength = intMinForLayoutUnit + 2;
-
 static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::UnitTypes unitType)
 {
     switch (unitType) {

Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (175196 => 175197)


--- trunk/Source/WebCore/css/CSSPrimitiveValue.h	2014-10-25 02:15:31 UTC (rev 175196)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h	2014-10-25 02:37:41 UTC (rev 175197)
@@ -26,6 +26,7 @@
 #include "CSSValue.h"
 #include "CSSValueKeywords.h"
 #include "Color.h"
+#include "LayoutUnit.h"
 #include <wtf/Forward.h>
 #include <wtf/MathExtras.h>
 #include <wtf/PassRefPtr.h>
@@ -50,6 +51,11 @@
 struct Length;
 struct LengthSize;
 
+// Max/min values for CSS, needs to slightly smaller/larger than the true max/min values to allow for rounding without overflowing.
+// Subtract two (rather than one) to allow for values to be converted to float and back without exceeding the LayoutUnit::max.
+const int maxValueForCssLength = intMaxForLayoutUnit - 2;
+const int minValueForCssLength = intMinForLayoutUnit + 2;
+
 // Dimension calculations are imprecise, often resulting in values of e.g.
 // 44.99998. We need to go ahead and round if we're really close to the next
 // integer value.

Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (175196 => 175197)


--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-10-25 02:15:31 UTC (rev 175196)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-10-25 02:37:41 UTC (rev 175197)
@@ -1496,7 +1496,7 @@
         else if (primitiveValue.isLength()) {
             wordSpacing = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
         } else if (primitiveValue.isPercentage())
-            wordSpacing = Length(primitiveValue.getDoubleValue(), Percent);
+            wordSpacing = Length(clampTo<float>(primitiveValue.getDoubleValue(), minValueForCssLength, maxValueForCssLength), Percent);
         else if (primitiveValue.isNumber())
             wordSpacing = Length(primitiveValue.getDoubleValue(), Fixed);
         else
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to