Commit 99c82be6 authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

[mathml] Fix mo-form-dynamic.html

When an mrow programmatically has a child added or removed, any
direct operator children may need to recompute the lspace/rspace
values in case no form value was given, since the fallback logic
to compute the form value depends on the previous and next sibling [1].
Add the method CheckFormAfterSiblingChange to implement this update logic.

Bug: 6606

[1] https://mathml-refresh.github.io/mathml-core/#dfn-algorithm-for-determining-the-form-of-an-embellished-operator

Change-Id: I8c641fda6c3d32a263430aba474c409dc3e56fd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2467957
Commit-Queue: Rob Buis <rbuis@igalia.com>
Reviewed-by: default avatarFrédéric Wang <fwang@igalia.com>
Cr-Commit-Position: refs/heads/master@{#816588}
parent 0e84a572
...@@ -254,6 +254,13 @@ bool MathMLOperatorElement::HasBooleanProperty(OperatorPropertyFlag flag) { ...@@ -254,6 +254,13 @@ bool MathMLOperatorElement::HasBooleanProperty(OperatorPropertyFlag flag) {
return properties_.flags & flag; return properties_.flags & flag;
} }
void MathMLOperatorElement::CheckFormAfterSiblingChange() {
if (properties_.dictionary_category !=
MathMLOperatorDictionaryCategory::kUndefined &&
!FastHasAttribute(mathml_names::kFormAttr))
SetOperatorFormDirty();
}
void MathMLOperatorElement::SetOperatorFormDirty() { void MathMLOperatorElement::SetOperatorFormDirty() {
properties_.dictionary_category = properties_.dictionary_category =
MathMLOperatorDictionaryCategory::kUndefined; MathMLOperatorDictionaryCategory::kUndefined;
......
...@@ -44,6 +44,8 @@ class CORE_EXPORT MathMLOperatorElement final : public MathMLElement { ...@@ -44,6 +44,8 @@ class CORE_EXPORT MathMLOperatorElement final : public MathMLElement {
double DefaultLeadingSpace(); double DefaultLeadingSpace();
double DefaultTrailingSpace(); double DefaultTrailingSpace();
void CheckFormAfterSiblingChange();
private: private:
base::Optional<OperatorContent> operator_content_; base::Optional<OperatorContent> operator_content_;
// Operator properties calculated from dictionary and attributes. // Operator properties calculated from dictionary and attributes.
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/core/mathml/mathml_row_element.h" #include "third_party/blink/renderer/core/mathml/mathml_row_element.h"
#include "third_party/blink/renderer/core/layout/ng/mathml/layout_ng_mathml_block.h" #include "third_party/blink/renderer/core/layout/ng/mathml/layout_ng_mathml_block.h"
#include "third_party/blink/renderer/core/mathml/mathml_operator_element.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink { namespace blink {
...@@ -22,4 +23,18 @@ LayoutObject* MathMLRowElement::CreateLayoutObject(const ComputedStyle& style, ...@@ -22,4 +23,18 @@ LayoutObject* MathMLRowElement::CreateLayoutObject(const ComputedStyle& style,
return new LayoutNGMathMLBlock(this); return new LayoutNGMathMLBlock(this);
} }
void MathMLRowElement::ChildrenChanged(const ChildrenChange& change) {
if (change.by_parser == ChildrenChangeSource::kAPI) {
for (auto* child = firstChild(); child; child = child->nextSibling()) {
if (child->HasTagName(mathml_names::kMoTag)) {
// TODO(crbug.com/1124298): make this work for embellished operators.
static_cast<MathMLOperatorElement*>(child)
->CheckFormAfterSiblingChange();
}
}
}
MathMLElement::ChildrenChanged(change);
}
} // namespace blink } // namespace blink
...@@ -16,6 +16,8 @@ class CORE_EXPORT MathMLRowElement : public MathMLElement { ...@@ -16,6 +16,8 @@ class CORE_EXPORT MathMLRowElement : public MathMLElement {
public: public:
explicit MathMLRowElement(const QualifiedName&, Document&); explicit MathMLRowElement(const QualifiedName&, Document&);
void ChildrenChanged(const ChildrenChange&) override;
private: private:
LayoutObject* CreateLayoutObject(const ComputedStyle&, LayoutObject* CreateLayoutObject(const ComputedStyle&,
LegacyLayout legacy) override; LegacyLayout legacy) override;
......
...@@ -1228,7 +1228,6 @@ crbug.com/6606 external/wpt/mathml/presentation-markup/mrow/legacy-mrow-like-ele ...@@ -1228,7 +1228,6 @@ crbug.com/6606 external/wpt/mathml/presentation-markup/mrow/legacy-mrow-like-ele
crbug.com/6606 external/wpt/mathml/presentation-markup/operators/embellished-operator-001.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/operators/embellished-operator-001.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/operators/embellished-operator-002.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/operators/embellished-operator-002.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-axis-height-1.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-axis-height-1.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/operators/mo-form-dynamic.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/cramped-001.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/scripts/cramped-001.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/spaces/space-like-001.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/spaces/space-like-001.html [ Failure ]
crbug.com/6606 external/wpt/mathml/presentation-markup/spaces/space-like-002.html [ Failure ] crbug.com/6606 external/wpt/mathml/presentation-markup/spaces/space-like-002.html [ Failure ]
......
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