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

[mathml] Introduce LayoutNGMathMLBlockFlow

Introduce LayoutNGMathMLBlockFlow to mark the block flow as a MathML
layout class, currently only used for operators (mo).

A follow-up CL will introduce an UpdateFromElement method on it to
deal with operator attribute changes.

This CL does not yet introduce an operator layout algorithm (which will
allow things like stretching) and falls back to the block layout
algorithm for operators.

Bug: 6606
Change-Id: I5ed10f7e27bdd08be2eb576d297067ac790241bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2382601
Commit-Queue: Rob Buis <rbuis@igalia.com>
Reviewed-by: default avatarFrédéric Wang <fwang@igalia.com>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803086}
parent 41ecc1ca
......@@ -47,7 +47,7 @@ math[display="block"] {
outline: auto 1px -webkit-focus-ring-color;
}
maction, merror, mfrac, mmultiscripts, mover, mpadded, mphantom, mprescripts, mroot, mrow, msqrt, mspace, mstyle, msub, msup, msubsup, munder, munderover, none
maction, merror, mfrac, mmultiscripts, mo, mover, mpadded, mphantom, mprescripts, mroot, mrow, msqrt, mspace, mstyle, msub, msup, msubsup, munder, munderover, none
{
display: math;
}
......
......@@ -441,6 +441,8 @@ blink_core_sources("layout") {
"ng/list/ng_unpositioned_list_marker.h",
"ng/mathml/layout_ng_mathml_block.cc",
"ng/mathml/layout_ng_mathml_block.h",
"ng/mathml/layout_ng_mathml_block_flow.cc",
"ng/mathml/layout_ng_mathml_block_flow.h",
"ng/mathml/layout_ng_mathml_block_with_anonymous_mrow.cc",
"ng/mathml/layout_ng_mathml_block_with_anonymous_mrow.h",
"ng/mathml/ng_math_fraction_layout_algorithm.cc",
......
......@@ -39,6 +39,7 @@
#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/layout/ng/mathml/layout_ng_mathml_block_flow.h"
#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table.h"
#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_caption.h"
#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_cell.h"
......@@ -46,6 +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_row.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/style/computed_style.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
......@@ -138,6 +140,11 @@ LayoutBlock* LayoutObjectFactory::CreateMath(Node& node,
const ComputedStyle& style,
LegacyLayout legacy) {
bool disable_ng_for_type = !RuntimeEnabledFeatures::MathMLCoreEnabled();
if (IsA<MathMLOperatorElement>(node)) {
return CreateObject<LayoutBlockFlow, LayoutNGMathMLBlockFlow,
LayoutBlockFlow>(node, style, legacy,
disable_ng_for_type);
}
return CreateObject<LayoutBlock, LayoutNGMathMLBlock, LayoutBlockFlow>(
node, style, legacy, disable_ng_for_type);
}
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/layout/ng/mathml/layout_ng_mathml_block_flow.h"
namespace blink {
LayoutNGMathMLBlockFlow::LayoutNGMathMLBlockFlow(Element* element)
: LayoutNGBlockFlow(element) {
DCHECK(element);
}
bool LayoutNGMathMLBlockFlow::IsOfType(LayoutObjectType type) const {
return type == kLayoutObjectMathML || LayoutNGBlockFlow::IsOfType(type);
}
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_MATHML_LAYOUT_NG_MATHML_BLOCK_FLOW_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_MATHML_LAYOUT_NG_MATHML_BLOCK_FLOW_H_
#include "third_party/blink/renderer/core/layout/ng/layout_ng_block_flow.h"
namespace blink {
class Element;
class LayoutNGMathMLBlockFlow final : public LayoutNGBlockFlow {
public:
explicit LayoutNGMathMLBlockFlow(Element*);
const char* GetName() const final { return "LayoutNGMathMLBlockFlow"; }
private:
bool IsOfType(LayoutObjectType) const final;
bool IsChildAllowed(LayoutObject*, const ComputedStyle&) const final {
return true;
}
bool CreatesNewFormattingContext() const final { return true; }
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_MATHML_LAYOUT_NG_MATHML_BLOCK_FLOW_H_
......@@ -131,6 +131,9 @@ NOINLINE void DetermineMathMLAlgorithmAndRun(
} else if (IsA<MathMLPaddedElement>(element)) {
CreateAlgorithmAndRun<NGMathPaddedLayoutAlgorithm>(params, callback);
return;
} else if (IsA<MathMLOperatorElement>(element)) {
CreateAlgorithmAndRun<NGBlockLayoutAlgorithm>(params, callback);
return;
} else if (IsA<MathMLScriptsElement>(element) &&
IsValidMathMLScript(params.node)) {
// TODO(rbuis): take into account movablelimits.
......
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