summaryrefslogtreecommitdiff
path: root/Source/WebCore/mathml/MathMLMathElement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/mathml/MathMLMathElement.cpp')
-rw-r--r--Source/WebCore/mathml/MathMLMathElement.cpp53
1 files changed, 42 insertions, 11 deletions
diff --git a/Source/WebCore/mathml/MathMLMathElement.cpp b/Source/WebCore/mathml/MathMLMathElement.cpp
index 6f2f389ba..783e9ff95 100644
--- a/Source/WebCore/mathml/MathMLMathElement.cpp
+++ b/Source/WebCore/mathml/MathMLMathElement.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved.
* Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2016 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,35 +26,65 @@
*/
#include "config.h"
+#include "MathMLMathElement.h"
#if ENABLE(MATHML)
-#include "MathMLMathElement.h"
+#include "MathMLNames.h"
#include "RenderMathMLMath.h"
namespace WebCore {
+using namespace MathMLNames;
+
inline MathMLMathElement::MathMLMathElement(const QualifiedName& tagName, Document& document)
- : MathMLInlineContainerElement(tagName, document)
+ : MathMLRowElement(tagName, document)
+{
+ setHasCustomStyleResolveCallbacks();
+}
+
+Ref<MathMLMathElement> MathMLMathElement::create(const QualifiedName& tagName, Document& document)
{
+ return adoptRef(*new MathMLMathElement(tagName, document));
}
-PassRefPtr<MathMLMathElement> MathMLMathElement::create(const QualifiedName& tagName, Document& document)
+RenderPtr<RenderElement> MathMLMathElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
- return adoptRef(new MathMLMathElement(tagName, document));
+ return createRenderer<RenderMathMLMath>(*this, WTFMove(style));
}
-Node::InsertionNotificationRequest MathMLMathElement::insertedInto(ContainerNode& insertionPoint)
+std::optional<bool> MathMLMathElement::specifiedDisplayStyle()
{
- // There are sibling rules in the MathML default style.
- if (insertionPoint.inDocument())
- document().styleSheetCollection().setUsesSiblingRulesOverride(true);
- return MathMLInlineContainerElement::insertedInto(insertionPoint);
+ if (cachedBooleanAttribute(displaystyleAttr, m_displayStyle) == BooleanValue::Default) {
+ // The default displaystyle value of the <math> depends on the display attribute, so we parse it here.
+ auto& value = attributeWithoutSynchronization(displayAttr);
+ if (value == "block")
+ m_displayStyle = BooleanValue::True;
+ else if (value == "inline")
+ m_displayStyle = BooleanValue::False;
+ }
+ return toOptionalBool(m_displayStyle.value());
}
-RenderPtr<RenderElement> MathMLMathElement::createElementRenderer(PassRef<RenderStyle> style)
+void MathMLMathElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
- return createRenderer<RenderMathMLMath>(*this, std::move(style));
+ bool displayStyleAttribute = (name == displaystyleAttr || name == displayAttr);
+ bool mathVariantAttribute = name == mathvariantAttr;
+ if (displayStyleAttribute)
+ m_displayStyle = std::nullopt;
+ if (mathVariantAttribute)
+ m_mathVariant = std::nullopt;
+ if ((displayStyleAttribute || mathVariantAttribute) && renderer())
+ MathMLStyle::resolveMathMLStyleTree(renderer());
+
+ MathMLElement::parseAttribute(name, value);
+}
+
+void MathMLMathElement::didAttachRenderers()
+{
+ MathMLRowElement::didAttachRenderers();
+
+ MathMLStyle::resolveMathMLStyleTree(renderer());
}
}