Commit 62633805 authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

[mathml] Implement MathML token elements (<mtext>, <mi>, <mo>, etc)

These elements are generally text containers for operators, numbers,
variables, comments etc. However, they are also integration points for
foreign markup (SVG and HTML).

See
https://mathml-refresh.github.io/mathml-core/#token-elements
https://mathml-refresh.github.io/mathml-core/#html-and-svg

Bug: 6606
Change-Id: I595222fec2e1d9d582ee3c01f76f4771506e8994
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391150
Commit-Queue: Rob Buis <rbuis@igalia.com>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarFrédéric Wang <fwang@igalia.com>
Cr-Commit-Position: refs/heads/master@{#804754}
parent cf002f92
...@@ -47,7 +47,7 @@ math[display="block"] { ...@@ -47,7 +47,7 @@ math[display="block"] {
outline: auto 1px -webkit-focus-ring-color; outline: auto 1px -webkit-focus-ring-color;
} }
maction, merror, mfrac, mmultiscripts, mo, mover, mpadded, mphantom, mprescripts, mroot, mrow, msqrt, mspace, mstyle, msub, msup, msubsup, munder, munderover, none maction, merror, mfrac, mi, mmultiscripts, mn, mo, mover, mpadded, mphantom, mprescripts, mroot, mrow, ms, msqrt, mspace, mstyle, msub, msup, msubsup, mtext, munder, munderover, none
{ {
display: math; display: math;
} }
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_column.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_column.h"
#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_row.h"
#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_section.h" #include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_section.h"
#include "third_party/blink/renderer/core/mathml/mathml_operator_element.h" #include "third_party/blink/renderer/core/mathml/mathml_element.h"
#include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h"
...@@ -140,7 +140,7 @@ LayoutBlock* LayoutObjectFactory::CreateMath(Node& node, ...@@ -140,7 +140,7 @@ LayoutBlock* LayoutObjectFactory::CreateMath(Node& node,
const ComputedStyle& style, const ComputedStyle& style,
LegacyLayout legacy) { LegacyLayout legacy) {
bool disable_ng_for_type = !RuntimeEnabledFeatures::MathMLCoreEnabled(); bool disable_ng_for_type = !RuntimeEnabledFeatures::MathMLCoreEnabled();
if (IsA<MathMLOperatorElement>(node)) { if (IsA<MathMLElement>(node) && To<MathMLElement>(node).IsTokenElement()) {
return CreateObject<LayoutBlockFlow, LayoutNGMathMLBlockFlow, return CreateObject<LayoutBlockFlow, LayoutNGMathMLBlockFlow,
LayoutBlockFlow>(node, style, legacy, LayoutBlockFlow>(node, style, legacy,
disable_ng_for_type); disable_ng_for_type);
......
...@@ -131,7 +131,8 @@ NOINLINE void DetermineMathMLAlgorithmAndRun( ...@@ -131,7 +131,8 @@ NOINLINE void DetermineMathMLAlgorithmAndRun(
} else if (IsA<MathMLPaddedElement>(element)) { } else if (IsA<MathMLPaddedElement>(element)) {
CreateAlgorithmAndRun<NGMathPaddedLayoutAlgorithm>(params, callback); CreateAlgorithmAndRun<NGMathPaddedLayoutAlgorithm>(params, callback);
return; return;
} else if (IsA<MathMLOperatorElement>(element)) { } else if (IsA<MathMLElement>(element) &&
To<MathMLElement>(*element).IsTokenElement()) {
CreateAlgorithmAndRun<NGBlockLayoutAlgorithm>(params, callback); CreateAlgorithmAndRun<NGBlockLayoutAlgorithm>(params, callback);
return; return;
} else if (IsA<MathMLScriptsElement>(element) && } else if (IsA<MathMLScriptsElement>(element) &&
......
...@@ -137,4 +137,11 @@ base::Optional<Length> MathMLElement::AddMathLengthToComputedStyle( ...@@ -137,4 +137,11 @@ base::Optional<Length> MathMLElement::AddMathLengthToComputedStyle(
return parsed_value->ConvertToLength(conversion_data); return parsed_value->ConvertToLength(conversion_data);
} }
bool MathMLElement::IsTokenElement() const {
return HasTagName(mathml_names::kMiTag) || HasTagName(mathml_names::kMoTag) ||
HasTagName(mathml_names::kMnTag) ||
HasTagName(mathml_names::kMtextTag) ||
HasTagName(mathml_names::kMsTag);
}
} // namespace blink } // namespace blink
...@@ -33,6 +33,8 @@ class CORE_EXPORT MathMLElement : public Element { ...@@ -33,6 +33,8 @@ class CORE_EXPORT MathMLElement : public Element {
bool IsMathMLElement() const = bool IsMathMLElement() const =
delete; // This will catch anyone doing an unnecessary check. delete; // This will catch anyone doing an unnecessary check.
bool IsTokenElement() const;
protected: protected:
bool IsPresentationAttribute(const QualifiedName&) const override; bool IsPresentationAttribute(const QualifiedName&) const override;
void CollectStyleForPresentationAttribute( void CollectStyleForPresentationAttribute(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment