Fix unitless usage of mathsize
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2019 10:42:43 +0000 (10:42 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2019 10:42:43 +0000 (10:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194940

Patch by Rob Buis <rbuis@igalia.com> on 2019-02-22
Reviewed by Frédéric Wang.

Source/WebCore:

Convert unitless lengths to percentage values to correct the computed
font size.

* mathml/MathMLElement.cpp:
(WebCore::convertToPercentageIfNeeded):
(WebCore::MathMLElement::collectStyleForPresentationAttribute):

LayoutTests:

Tests lengths-1.html and length-3.html now pass.

* TestExpectations:

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

LayoutTests/ChangeLog
LayoutTests/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/mathml/MathMLElement.cpp

index 82b3882..6756494 100644 (file)
@@ -1,3 +1,14 @@
+2019-02-22  Rob Buis  <rbuis@igalia.com>
+
+        Fix unitless usage of mathsize
+        https://bugs.webkit.org/show_bug.cgi?id=194940
+
+        Reviewed by Frédéric Wang.
+
+        Tests lengths-1.html and length-3.html now pass.
+
+        * TestExpectations:
+
 2019-02-21  Simon Fraser  <simon.fraser@apple.com>
 
         Hardcode Visual Viewports on everywhere except iOS WK1
index 878faae..29817de 100644 (file)
@@ -719,9 +719,7 @@ imported/w3c/web-platform-tests/html/browsers/windows/nested-browsing-contexts/f
 imported/w3c/web-platform-tests/html/browsers/windows/targeting-cross-origin-nested-browsing-contexts.sub.html [ Pass Failure ]
 
 # These MathML WPT tests fail.
-webkit.org/b/180013 imported/w3c/web-platform-tests/mathml/relations/css-styling/lengths-1.html [ ImageOnlyFailure ]
 webkit.org/b/180013 imported/w3c/web-platform-tests/mathml/relations/css-styling/lengths-2.html [ ImageOnlyFailure ]
-webkit.org/b/180013 imported/w3c/web-platform-tests/mathml/relations/css-styling/lengths-3.html [ Failure ]
 
 # These webmessaging WPT tests time out.
 webkit.org/b/187034 imported/w3c/web-platform-tests/webmessaging/MessageEvent_onmessage_postMessage_infinite_loop.html [ Skip ]
index 78d8fb8..206ac23 100644 (file)
@@ -1,3 +1,17 @@
+2019-02-22  Rob Buis  <rbuis@igalia.com>
+
+        Fix unitless usage of mathsize
+        https://bugs.webkit.org/show_bug.cgi?id=194940
+
+        Reviewed by Frédéric Wang.
+
+        Convert unitless lengths to percentage values to correct the computed
+        font size.
+
+        * mathml/MathMLElement.cpp:
+        (WebCore::convertToPercentageIfNeeded):
+        (WebCore::MathMLElement::collectStyleForPresentationAttribute):
+
 2019-02-21  Simon Fraser  <simon.fraser@apple.com>
 
         Hardcode Visual Viewports on everywhere except iOS WK1
index 5ffa23f..d8cb1c4 100644 (file)
@@ -97,6 +97,15 @@ bool MathMLElement::isPresentationAttribute(const QualifiedName& name) const
     return StyledElement::isPresentationAttribute(name);
 }
 
+static String convertToPercentageIfNeeded(const AtomicString& value)
+{
+    bool ok = false;
+    float unitlessValue = value.toFloat(&ok);
+    if (ok)
+        return String::format("%.3f%%", unitlessValue * 100.0);
+    return value;
+}
+
 void MathMLElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStyleProperties& style)
 {
     if (name == mathbackgroundAttr)
@@ -104,7 +113,7 @@ void MathMLElement::collectStyleForPresentationAttribute(const QualifiedName& na
     else if (name == mathsizeAttr) {
         // The following three values of mathsize are handled in WebCore/css/mathml.css
         if (value != "normal" && value != "small" && value != "big")
-            addPropertyToPresentationAttributeStyle(style, CSSPropertyFontSize, value);
+            addPropertyToPresentationAttributeStyle(style, CSSPropertyFontSize, convertToPercentageIfNeeded(value));
     } else if (name == mathcolorAttr)
         addPropertyToPresentationAttributeStyle(style, CSSPropertyColor, value);
     // FIXME: deprecated attributes that should loose in a conflict with a non deprecated attribute