ASSERTION FAILED: m_fonts in &WebCore::FontCascade::primaryFont
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Oct 2016 07:23:28 +0000 (07:23 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Oct 2016 07:23:28 +0000 (07:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163459

Reviewed by Darin Adler.

Source/WebCore:

The CSS Units and Values spec states that font-relative units, when used
in the font-size property, are resolved against the parent element. When
calc() is specified, we were trying to resolve them against the current
element, which is impossible because of the circular dependency. Instead,
we should resolve against the parent style the same way as when calc()
isn't specified.

Test: fast/text/font-size-calc.html

* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyValueFontSize):

LayoutTests:

* fast/text/font-size-calc-expected.txt: Added.
* fast/text/font-size-calc.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/text/font-size-calc-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/font-size-calc.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/StyleBuilderCustom.h

index ad24a96..40406b9 100644 (file)
@@ -1,3 +1,13 @@
+2016-10-22  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        ASSERTION FAILED: m_fonts in &WebCore::FontCascade::primaryFont
+        https://bugs.webkit.org/show_bug.cgi?id=163459
+
+        Reviewed by Darin Adler.
+
+        * fast/text/font-size-calc-expected.txt: Added.
+        * fast/text/font-size-calc.html: Added.
+
 2016-10-22  Dan Bernstein  <mitz@apple.com>
 
         Dynamically-added backdrop filter to clip-path'd element with 3D transform renders incorrectly (without clip)
diff --git a/LayoutTests/fast/text/font-size-calc-expected.txt b/LayoutTests/fast/text/font-size-calc-expected.txt
new file mode 100644 (file)
index 0000000..22f9fe0
--- /dev/null
@@ -0,0 +1 @@
+This test passes if there is no crash.
diff --git a/LayoutTests/fast/text/font-size-calc.html b/LayoutTests/fast/text/font-size-calc.html
new file mode 100644 (file)
index 0000000..ec5ae2c
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+div {
+       font-size: calc(6% + 7ch);
+}
+</style>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+</script>
+</head>
+<body>
+<div style="font-family: 'Helvetica';">This test passes if there is no crash.</div>
+</body>
+</html>
index a571023..9dcd2b1 100644 (file)
@@ -1,3 +1,22 @@
+2016-10-22  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        ASSERTION FAILED: m_fonts in &WebCore::FontCascade::primaryFont
+        https://bugs.webkit.org/show_bug.cgi?id=163459
+
+        Reviewed by Darin Adler.
+
+        The CSS Units and Values spec states that font-relative units, when used
+        in the font-size property, are resolved against the parent element. When
+        calc() is specified, we were trying to resolve them against the current
+        element, which is impossible because of the circular dependency. Instead,
+        we should resolve against the parent style the same way as when calc() 
+        isn't specified.
+
+        Test: fast/text/font-size-calc.html
+
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyValueFontSize):
+
 2016-10-22  Chris Dumez  <cdumez@apple.com>
 
         [Web IDL] Two types are distinguishable for overload resolution if at most one of the two includes a nullable type
index 609aad5..d1021ed 100644 (file)
@@ -1587,9 +1587,11 @@ inline void StyleBuilderCustom::applyValueFontSize(StyleResolver& styleResolver,
             styleResolver.state().setFontSizeHasViewportUnits(primitiveValue.isViewportPercentageLength());
         } else if (primitiveValue.isPercentage())
             size = (primitiveValue.floatValue() * parentSize) / 100.0f;
-        else if (primitiveValue.isCalculatedPercentageWithLength())
-            size = primitiveValue.cssCalcValue()->createCalculationValue(styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f))->evaluate(parentSize);
-        else
+        else if (primitiveValue.isCalculatedPercentageWithLength()) {
+            const auto& conversionData = styleResolver.state().cssToLengthConversionData();
+            CSSToLengthConversionData parentConversionData { styleResolver.parentStyle(), conversionData.rootStyle(), styleResolver.document().renderView(), 1.0f, true };
+            size = primitiveValue.cssCalcValue()->createCalculationValue(parentConversionData)->evaluate(parentSize);
+        } else
             return;
     }