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, ...@@ -242,8 +242,6 @@ LayoutObject* LayoutObject::CreateObject(Element* element,
case EDisplay::kFlowRoot: case EDisplay::kFlowRoot:
case EDisplay::kInlineBlock: case EDisplay::kInlineBlock:
case EDisplay::kListItem: case EDisplay::kListItem:
case EDisplay::kMath:
case EDisplay::kInlineMath:
return LayoutObjectFactory::CreateBlockFlow(*element, style, legacy); return LayoutObjectFactory::CreateBlockFlow(*element, style, legacy);
case EDisplay::kTable: case EDisplay::kTable:
case EDisplay::kInlineTable: case EDisplay::kInlineTable:
...@@ -292,6 +290,9 @@ LayoutObject* LayoutObject::CreateObject(Element* element, ...@@ -292,6 +290,9 @@ LayoutObject* LayoutObject::CreateObject(Element* element,
case EDisplay::kInlineGrid: case EDisplay::kInlineGrid:
UseCounter::Count(element->GetDocument(), WebFeature::kCSSGridLayout); UseCounter::Count(element->GetDocument(), WebFeature::kCSSGridLayout);
return LayoutObjectFactory::CreateGrid(*element, style, legacy); return LayoutObjectFactory::CreateGrid(*element, style, legacy);
case EDisplay::kMath:
case EDisplay::kInlineMath:
return LayoutObjectFactory::CreateMath(*element, style, legacy);
case EDisplay::kLayoutCustom: case EDisplay::kLayoutCustom:
case EDisplay::kInlineLayoutCustom: case EDisplay::kInlineLayoutCustom:
DCHECK(RuntimeEnabledFeatures::LayoutNGEnabled()); DCHECK(RuntimeEnabledFeatures::LayoutNGEnabled());
......
...@@ -33,6 +33,7 @@ ...@@ -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_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_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/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/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"
...@@ -122,6 +123,14 @@ LayoutBlock* LayoutObjectFactory::CreateGrid(Node& node, ...@@ -122,6 +123,14 @@ LayoutBlock* LayoutObjectFactory::CreateGrid(Node& node,
node, style, legacy, disable_ng_for_type); 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, LayoutObject* LayoutObjectFactory::CreateListMarker(Node& node,
const ComputedStyle& style, const ComputedStyle& style,
LegacyLayout legacy) { LegacyLayout legacy) {
......
...@@ -46,6 +46,7 @@ class LayoutObjectFactory { ...@@ -46,6 +46,7 @@ class LayoutObjectFactory {
const ComputedStyle&, const ComputedStyle&,
LegacyLayout); LegacyLayout);
static LayoutBlock* CreateGrid(Node&, const ComputedStyle&, LegacyLayout); static LayoutBlock* CreateGrid(Node&, const ComputedStyle&, LegacyLayout);
static LayoutBlock* CreateMath(Node&, const ComputedStyle&, LegacyLayout);
static LayoutObject* CreateListMarker(Node&, static LayoutObject* CreateListMarker(Node&,
const ComputedStyle&, const ComputedStyle&,
LegacyLayout); LegacyLayout);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
namespace blink { namespace blink {
LayoutNGMathMLBlock::LayoutNGMathMLBlock(MathMLElement* element) LayoutNGMathMLBlock::LayoutNGMathMLBlock(Element* element)
: LayoutNGMixin<LayoutBlock>(element) { : LayoutNGMixin<LayoutBlock>(element) {
DCHECK(element); DCHECK(element);
} }
......
...@@ -9,11 +9,9 @@ ...@@ -9,11 +9,9 @@
namespace blink { namespace blink {
class MathMLElement;
class LayoutNGMathMLBlock : public LayoutNGMixin<LayoutBlock> { class LayoutNGMathMLBlock : public LayoutNGMixin<LayoutBlock> {
public: public:
explicit LayoutNGMathMLBlock(MathMLElement*); explicit LayoutNGMathMLBlock(Element*);
const char* GetName() const override { return "LayoutNGMathMLBlock"; } const char* GetName() const override { return "LayoutNGMathMLBlock"; }
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
#include "third_party/blink/renderer/core/mathml/mathml_fraction_element.h" #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/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink { namespace blink {
...@@ -20,13 +19,4 @@ void MathMLFractionElement::AddMathFractionBarThicknessIfNeeded( ...@@ -20,13 +19,4 @@ void MathMLFractionElement::AddMathFractionBarThicknessIfNeeded(
style.SetMathFractionBarThickness(std::move(*length_or_percentage_value)); 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 } // namespace blink
...@@ -11,7 +11,6 @@ namespace blink { ...@@ -11,7 +11,6 @@ namespace blink {
class ComputedStyle; class ComputedStyle;
class CSSToLengthConversionData; class CSSToLengthConversionData;
class LayoutObject;
class MathMLFractionElement final : public MathMLElement { class MathMLFractionElement final : public MathMLElement {
public: public:
...@@ -19,10 +18,6 @@ class MathMLFractionElement final : public MathMLElement { ...@@ -19,10 +18,6 @@ class MathMLFractionElement final : public MathMLElement {
void AddMathFractionBarThicknessIfNeeded(ComputedStyle&, void AddMathFractionBarThicknessIfNeeded(ComputedStyle&,
const CSSToLengthConversionData&); const CSSToLengthConversionData&);
private:
LayoutObject* CreateLayoutObject(const ComputedStyle&,
LegacyLayout legacy) final;
}; };
} // namespace blink } // namespace blink
......
...@@ -4,9 +4,6 @@ ...@@ -4,9 +4,6 @@
#include "third_party/blink/renderer/core/mathml/mathml_scripts_element.h" #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 { namespace blink {
static MathScriptType ScriptTypeOf(const QualifiedName& tagName) { static MathScriptType ScriptTypeOf(const QualifiedName& tagName) {
...@@ -28,15 +25,4 @@ MathMLScriptsElement::MathMLScriptsElement(const QualifiedName& tagName, ...@@ -28,15 +25,4 @@ MathMLScriptsElement::MathMLScriptsElement(const QualifiedName& tagName,
Document& document) Document& document)
: MathMLElement(tagName, document), script_type_(ScriptTypeOf(tagName)) {} : 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 } // namespace blink
...@@ -21,8 +21,6 @@ class CORE_EXPORT MathMLScriptsElement : public MathMLElement { ...@@ -21,8 +21,6 @@ class CORE_EXPORT MathMLScriptsElement : public MathMLElement {
private: private:
const MathScriptType script_type_; const MathScriptType script_type_;
LayoutObject* CreateLayoutObject(const ComputedStyle&,
LegacyLayout legacy) override;
}; };
template <> template <>
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
#include "third_party/blink/renderer/core/mathml/mathml_space_element.h" #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/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
namespace blink { namespace blink {
...@@ -54,12 +53,4 @@ void MathMLSpaceElement::CollectStyleForPresentationAttribute( ...@@ -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 } // namespace blink
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
namespace blink { namespace blink {
class LayoutObject;
class ComputedStyle; class ComputedStyle;
class CSSToLengthConversionData; class CSSToLengthConversionData;
...@@ -21,8 +20,6 @@ class MathMLSpaceElement final : public MathMLElement { ...@@ -21,8 +20,6 @@ class MathMLSpaceElement final : public MathMLElement {
const CSSToLengthConversionData&); const CSSToLengthConversionData&);
private: private:
LayoutObject* CreateLayoutObject(const ComputedStyle&,
LegacyLayout legacy) override;
bool IsPresentationAttribute(const QualifiedName&) const override; bool IsPresentationAttribute(const QualifiedName&) const override;
void CollectStyleForPresentationAttribute( void CollectStyleForPresentationAttribute(
const QualifiedName&, const QualifiedName&,
......
...@@ -4,22 +4,10 @@ ...@@ -4,22 +4,10 @@
#include "third_party/blink/renderer/core/mathml/mathml_under_over_element.h" #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 { namespace blink {
MathMLUnderOverElement::MathMLUnderOverElement(const QualifiedName& tagName, MathMLUnderOverElement::MathMLUnderOverElement(const QualifiedName& tagName,
Document& document) Document& document)
: MathMLScriptsElement(tagName, 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 } // namespace blink
...@@ -14,10 +14,6 @@ class Document; ...@@ -14,10 +14,6 @@ class Document;
class CORE_EXPORT MathMLUnderOverElement final : public MathMLScriptsElement { class CORE_EXPORT MathMLUnderOverElement final : public MathMLScriptsElement {
public: public:
MathMLUnderOverElement(const QualifiedName& tagName, Document& document); MathMLUnderOverElement(const QualifiedName& tagName, Document& document);
private:
LayoutObject* CreateLayoutObject(const ComputedStyle&,
LegacyLayout legacy) override;
}; };
template <> 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