Skip to content

Commit

Permalink
Merge r241942 - Fix unitless usage of mathsize
Browse files Browse the repository at this point in the history
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:
  • Loading branch information
rwlbuis authored and carlosgcampos committed Mar 5, 2019
1 parent ff521f5 commit aae72a0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
11 changes: 11 additions & 0 deletions LayoutTests/ChangeLog
@@ -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 Darin Adler <darin@apple.com>

Some refinements for Node and Document
Expand Down
2 changes: 0 additions & 2 deletions LayoutTests/TestExpectations
Expand Up @@ -727,9 +727,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 ]
Expand Down
14 changes: 14 additions & 0 deletions Source/WebCore/ChangeLog
@@ -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 Darin Adler <darin@apple.com>

Some refinements for Node and Document
Expand Down
11 changes: 10 additions & 1 deletion Source/WebCore/mathml/MathMLElement.cpp
Expand Up @@ -97,14 +97,23 @@ 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)
addPropertyToPresentationAttributeStyle(style, CSSPropertyBackgroundColor, value);
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
Expand Down

0 comments on commit aae72a0

Please sign in to comment.