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

[mathml] Use LayoutObjectFactory for MathML layout object creation

Use LayoutObjectFactory for MathML layout object creation where
possible.

Bug: 1070600
Change-Id: I1f02ca9ab4018798559ad3334fd4b316f31330d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2162927
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762029}
parent 8a91dcfb
......@@ -242,8 +242,6 @@ LayoutObject* LayoutObject::CreateObject(Element* element,
case EDisplay::kFlowRoot:
case EDisplay::kInlineBlock:
case EDisplay::kListItem:
case EDisplay::kMath:
case EDisplay::kInlineMath:
return LayoutObjectFactory::CreateBlockFlow(*element, style, legacy);
case EDisplay::kTable:
case EDisplay::kInlineTable:
......@@ -292,6 +290,9 @@ LayoutObject* LayoutObject::CreateObject(Element* element,
case EDisplay::kInlineGrid:
UseCounter::Count(element->GetDocument(), WebFeature::kCSSGridLayout);
return LayoutObjectFactory::CreateGrid(*element, style, legacy);
case EDisplay::kMath:
case EDisplay::kInlineMath:
return LayoutObjectFactory::CreateMath(*element, style, legacy);
case EDisplay::kLayoutCustom:
case EDisplay::kInlineLayoutCustom:
DCHECK(RuntimeEnabledFeatures::LayoutNGEnabled());
......
......@@ -33,6 +33,7 @@
#include "third_party/blink/renderer/core/layout/ng/list/layout_ng_inside_list_marker.h"
#include "third_party/blink/renderer/core/layout/ng/list/layout_ng_list_item.h"
#include "third_party/blink/renderer/core/layout/ng/list/layout_ng_outside_list_marker.h"
#include "third_party/blink/renderer/core/layout/ng/mathml/layout_ng_mathml_block.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
......@@ -122,6 +123,14 @@ LayoutBlock* LayoutObjectFactory::CreateGrid(Node& node,
node, style, legacy, disable_ng_for_type);
}
LayoutBlock* LayoutObjectFactory::CreateMath(Node& node,
const ComputedStyle& style,
LegacyLayout legacy) {
bool disable_ng_for_type = !RuntimeEnabledFeatures::MathMLCoreEnabled();
return CreateObject<LayoutBlock, LayoutNGMathMLBlock, LayoutBlockFlow>(
node, style, legacy, disable_ng_for_type);
}
LayoutObject* LayoutObjectFactory::CreateListMarker(Node& node,
const ComputedStyle& style,
LegacyLayout legacy) {
......
......@@ -46,6 +46,7 @@ class LayoutObjectFactory {
const ComputedStyle&,
LegacyLayout);
static LayoutBlock* CreateGrid(Node&, const ComputedStyle&, LegacyLayout);
static LayoutBlock* CreateMath(Node&, const ComputedStyle&, LegacyLayout);
static LayoutObject* CreateListMarker(Node&,
const ComputedStyle&,
LegacyLayout);
......
......@@ -10,7 +10,7 @@
namespace blink {
LayoutNGMathMLBlock::LayoutNGMathMLBlock(MathMLElement* element)
LayoutNGMathMLBlock::LayoutNGMathMLBlock(Element* element)
: LayoutNGMixin<LayoutBlock>(element) {
DCHECK(element);
}
......
......@@ -9,11 +9,9 @@
namespace blink {
class MathMLElement;
class LayoutNGMathMLBlock : public LayoutNGMixin<LayoutBlock> {
public:
explicit LayoutNGMathMLBlock(MathMLElement*);
explicit LayoutNGMathMLBlock(Element*);
const char* GetName() const override { return "LayoutNGMathMLBlock"; }
......
......@@ -4,8 +4,7 @@
#include "third_party/blink/renderer/core/mathml/mathml_fraction_element.h"
#include "third_party/blink/renderer/core/layout/ng/mathml/layout_ng_mathml_block.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
namespace blink {
......@@ -20,13 +19,4 @@ void MathMLFractionElement::AddMathFractionBarThicknessIfNeeded(
style.SetMathFractionBarThickness(std::move(*length_or_percentage_value));
}
LayoutObject* MathMLFractionElement::CreateLayoutObject(
const ComputedStyle& style,
LegacyLayout legacy) {
if (!RuntimeEnabledFeatures::MathMLCoreEnabled() ||
!style.IsDisplayMathType() || legacy == LegacyLayout::kForce)
return MathMLElement::CreateLayoutObject(style, legacy);
return new LayoutNGMathMLBlock(this);
}
} // namespace blink
......@@ -11,7 +11,6 @@ namespace blink {
class ComputedStyle;
class CSSToLengthConversionData;
class LayoutObject;
class MathMLFractionElement final : public MathMLElement {
public:
......@@ -19,10 +18,6 @@ class MathMLFractionElement final : public MathMLElement {
void AddMathFractionBarThicknessIfNeeded(ComputedStyle&,
const CSSToLengthConversionData&);
private:
LayoutObject* CreateLayoutObject(const ComputedStyle&,
LegacyLayout legacy) final;
};
} // namespace blink
......
......@@ -4,9 +4,6 @@
#include "third_party/blink/renderer/core/mathml/mathml_scripts_element.h"
#include "third_party/blink/renderer/core/layout/ng/mathml/layout_ng_mathml_block.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink {
static MathScriptType ScriptTypeOf(const QualifiedName& tagName) {
......@@ -28,15 +25,4 @@ MathMLScriptsElement::MathMLScriptsElement(const QualifiedName& tagName,
Document& document)
: MathMLElement(tagName, document), script_type_(ScriptTypeOf(tagName)) {}
LayoutObject* MathMLScriptsElement::CreateLayoutObject(
const ComputedStyle& style,
LegacyLayout legacy) {
// TODO(crbug.com/1070600): Use LayoutObjectFactory for MathML layout object
// creation.
if (!RuntimeEnabledFeatures::MathMLCoreEnabled() ||
legacy == LegacyLayout::kForce || !style.IsDisplayMathType())
return MathMLElement::CreateLayoutObject(style, legacy);
return new LayoutNGMathMLBlock(this);
}
} // namespace blink
......@@ -21,8 +21,6 @@ class CORE_EXPORT MathMLScriptsElement : public MathMLElement {
private:
const MathScriptType script_type_;
LayoutObject* CreateLayoutObject(const ComputedStyle&,
LegacyLayout legacy) override;
};
template <>
......
......@@ -4,8 +4,7 @@
#include "third_party/blink/renderer/core/mathml/mathml_space_element.h"
#include "third_party/blink/renderer/core/layout/ng/mathml/layout_ng_mathml_block.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
namespace blink {
......@@ -54,12 +53,4 @@ void MathMLSpaceElement::CollectStyleForPresentationAttribute(
}
}
LayoutObject* MathMLSpaceElement::CreateLayoutObject(const ComputedStyle& style,
LegacyLayout legacy) {
if (!RuntimeEnabledFeatures::MathMLCoreEnabled() ||
!style.IsDisplayMathType() || legacy == LegacyLayout::kForce)
return MathMLElement::CreateLayoutObject(style, legacy);
return new LayoutNGMathMLBlock(this);
}
} // namespace blink
......@@ -9,7 +9,6 @@
namespace blink {
class LayoutObject;
class ComputedStyle;
class CSSToLengthConversionData;
......@@ -21,8 +20,6 @@ class MathMLSpaceElement final : public MathMLElement {
const CSSToLengthConversionData&);
private:
LayoutObject* CreateLayoutObject(const ComputedStyle&,
LegacyLayout legacy) override;
bool IsPresentationAttribute(const QualifiedName&) const override;
void CollectStyleForPresentationAttribute(
const QualifiedName&,
......
......@@ -4,22 +4,10 @@
#include "third_party/blink/renderer/core/mathml/mathml_under_over_element.h"
#include "third_party/blink/renderer/core/layout/ng/mathml/layout_ng_mathml_block.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink {
MathMLUnderOverElement::MathMLUnderOverElement(const QualifiedName& tagName,
Document& document)
: MathMLScriptsElement(tagName, document) {}
LayoutObject* MathMLUnderOverElement::CreateLayoutObject(
const ComputedStyle& style,
LegacyLayout legacy) {
if (!RuntimeEnabledFeatures::MathMLCoreEnabled() ||
!style.IsDisplayMathType() || legacy == LegacyLayout::kForce)
return MathMLElement::CreateLayoutObject(style, legacy);
return new LayoutNGMathMLBlock(this);
}
} // namespace blink
......@@ -14,10 +14,6 @@ class Document;
class CORE_EXPORT MathMLUnderOverElement final : public MathMLScriptsElement {
public:
MathMLUnderOverElement(const QualifiedName& tagName, Document& document);
private:
LayoutObject* CreateLayoutObject(const ComputedStyle&,
LegacyLayout legacy) override;
};
template <>
......
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