Commit 8cf29d47 authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

[mathml] Add helper methods to NGLayoutInputNode

Add helper methods to NGLayoutInputNode to test whether the
input node is MathML and to get the DOM node for the
wrapped layout object.

Bug: 6606

Change-Id: I4b12e81b2c044e9bd98479c1ab0cf8f0c7cea898
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424183
Commit-Queue: Rob Buis <rbuis@igalia.com>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809398}
parent 6518d0d4
...@@ -71,7 +71,7 @@ bool IsValidMathMLFraction(const NGBlockNode& node) { ...@@ -71,7 +71,7 @@ bool IsValidMathMLFraction(const NGBlockNode& node) {
} }
static bool IsPrescriptDelimiter(const NGBlockNode& block_node) { static bool IsPrescriptDelimiter(const NGBlockNode& block_node) {
auto* node = block_node.GetLayoutBox()->GetNode(); auto* node = block_node.GetDOMNode();
return node && IsA<MathMLElement>(node) && return node && IsA<MathMLElement>(node) &&
node->HasTagName(mathml_names::kMprescriptsTag); node->HasTagName(mathml_names::kMprescriptsTag);
} }
...@@ -116,7 +116,7 @@ bool IsValidMathMLScript(const NGBlockNode& node) { ...@@ -116,7 +116,7 @@ bool IsValidMathMLScript(const NGBlockNode& node) {
bool IsValidMathMLRadical(const NGBlockNode& node) { bool IsValidMathMLRadical(const NGBlockNode& node) {
auto* radical = auto* radical =
DynamicTo<MathMLRadicalElement>(node.GetLayoutBox()->GetNode()); DynamicTo<MathMLRadicalElement>(node.GetDOMNode());
return !radical->HasIndex() || InFlowChildCountIs(node, 2); return !radical->HasIndex() || InFlowChildCountIs(node, 2);
} }
...@@ -201,13 +201,13 @@ bool IsUnderOverLaidOutAsSubSup(const NGBlockNode& node) { ...@@ -201,13 +201,13 @@ bool IsUnderOverLaidOutAsSubSup(const NGBlockNode& node) {
DCHECK(IsValidMathMLScript(node)); DCHECK(IsValidMathMLScript(node));
if (HasDisplayStyle(node.Style())) if (HasDisplayStyle(node.Style()))
return false; return false;
if (!node.IsBlock() || !node.GetLayoutBox()->IsMathML()) if (!node.IsBlock() || !node.IsMathML())
return false; return false;
auto base = To<NGBlockNode>(FirstChildInFlow(node)); auto base = To<NGBlockNode>(FirstChildInFlow(node));
// TODO(crbug.com/1124298)): // TODO(crbug.com/1124298)):
// https://mathml-refresh.github.io/mathml-core/#embellished-operators // https://mathml-refresh.github.io/mathml-core/#embellished-operators
if (auto* element = if (auto* element =
DynamicTo<MathMLOperatorElement>(base.GetLayoutBox()->GetNode())) { DynamicTo<MathMLOperatorElement>(base.GetDOMNode())) {
return element->HasBooleanProperty(MathMLOperatorElement::kMovableLimits); return element->HasBooleanProperty(MathMLOperatorElement::kMovableLimits);
} }
return false; return false;
......
...@@ -30,7 +30,7 @@ static void DetermineOperatorSpacing(const NGLayoutInputNode& node, ...@@ -30,7 +30,7 @@ static void DetermineOperatorSpacing(const NGLayoutInputNode& node,
LayoutUnit* lspace, LayoutUnit* lspace,
LayoutUnit* rspace) { LayoutUnit* rspace) {
auto* core_operator = auto* core_operator =
DynamicTo<MathMLOperatorElement>(node.GetLayoutBox()->GetNode()); DynamicTo<MathMLOperatorElement>(node.GetDOMNode());
if (core_operator) { if (core_operator) {
// TODO(crbug.com/1124298): Implement embellished operators. // TODO(crbug.com/1124298): Implement embellished operators.
LayoutUnit leading_space(core_operator->DefaultLeadingSpace() * LayoutUnit leading_space(core_operator->DefaultLeadingSpace() *
......
...@@ -16,7 +16,7 @@ namespace { ...@@ -16,7 +16,7 @@ namespace {
using MathConstants = OpenTypeMathSupport::MathConstants; using MathConstants = OpenTypeMathSupport::MathConstants;
static bool IsPrescriptDelimiter(const NGBlockNode& blockNode) { static bool IsPrescriptDelimiter(const NGBlockNode& blockNode) {
auto* node = blockNode.GetLayoutBox()->GetNode(); auto* node = blockNode.GetDOMNode();
return node && IsA<MathMLElement>(node) && return node && IsA<MathMLElement>(node) &&
node->HasTagName(mathml_names::kMprescriptsTag); node->HasTagName(mathml_names::kMprescriptsTag);
} }
......
...@@ -124,7 +124,7 @@ UnderOverVerticalParameters GetUnderOverVerticalParameters( ...@@ -124,7 +124,7 @@ UnderOverVerticalParameters GetUnderOverVerticalParameters(
// https://mathml-refresh.github.io/mathml-core/#underscripts-and-overscripts-munder-mover-munderover // https://mathml-refresh.github.io/mathml-core/#underscripts-and-overscripts-munder-mover-munderover
bool HasAccent(const NGBlockNode& node, bool accent_under) { bool HasAccent(const NGBlockNode& node, bool accent_under) {
DCHECK(node); DCHECK(node);
auto* underover = To<MathMLUnderOverElement>(node.GetLayoutBox()->GetNode()); auto* underover = To<MathMLUnderOverElement>(node.GetDOMNode());
auto script_type = underover->GetScriptType(); auto script_type = underover->GetScriptType();
DCHECK(script_type == MathScriptType::kUnderOver || DCHECK(script_type == MathScriptType::kUnderOver ||
(accent_under && script_type == MathScriptType::kUnder) || (accent_under && script_type == MathScriptType::kUnder) ||
...@@ -203,7 +203,7 @@ scoped_refptr<const NGLayoutResult> NGMathUnderOverLayoutAlgorithm::Layout() { ...@@ -203,7 +203,7 @@ scoped_refptr<const NGLayoutResult> NGMathUnderOverLayoutAlgorithm::Layout() {
bool is_base_large_operator = false; bool is_base_large_operator = false;
bool is_base_stretchy_in_inline_axis = false; bool is_base_stretchy_in_inline_axis = false;
if (auto* core_operator = if (auto* core_operator =
DynamicTo<MathMLOperatorElement>(base.GetLayoutBox()->GetNode())) { DynamicTo<MathMLOperatorElement>(base.GetDOMNode())) {
// TODO(crbug.com/1124298): Implement embellished operators. // TODO(crbug.com/1124298): Implement embellished operators.
is_base_large_operator = is_base_large_operator =
core_operator->HasBooleanProperty(MathMLOperatorElement::kLargeOp); core_operator->HasBooleanProperty(MathMLOperatorElement::kLargeOp);
......
...@@ -391,7 +391,7 @@ bool CanUseCachedIntrinsicInlineSizes(const MinMaxSizesInput& input, ...@@ -391,7 +391,7 @@ bool CanUseCachedIntrinsicInlineSizes(const MinMaxSizesInput& input,
} }
bool IsContentMinimumInlineSizeZero(const NGBlockNode& block_node) { bool IsContentMinimumInlineSizeZero(const NGBlockNode& block_node) {
const auto* node = block_node.GetLayoutBox()->GetNode(); const auto* node = block_node.GetDOMNode();
const auto* marquee_element = DynamicTo<HTMLMarqueeElement>(node); const auto* marquee_element = DynamicTo<HTMLMarqueeElement>(node);
if (marquee_element && marquee_element->IsHorizontal()) if (marquee_element && marquee_element->IsHorizontal())
return true; return true;
...@@ -1391,13 +1391,13 @@ bool NGBlockNode::IsCustomLayoutLoaded() const { ...@@ -1391,13 +1391,13 @@ bool NGBlockNode::IsCustomLayoutLoaded() const {
} }
MathScriptType NGBlockNode::ScriptType() const { MathScriptType NGBlockNode::ScriptType() const {
DCHECK(IsA<MathMLScriptsElement>(GetLayoutBox()->GetNode())); DCHECK(IsA<MathMLScriptsElement>(GetDOMNode()));
return To<MathMLScriptsElement>(GetLayoutBox()->GetNode())->GetScriptType(); return To<MathMLScriptsElement>(GetDOMNode())->GetScriptType();
} }
bool NGBlockNode::HasIndex() const { bool NGBlockNode::HasIndex() const {
DCHECK(IsA<MathMLRadicalElement>(GetLayoutBox()->GetNode())); DCHECK(IsA<MathMLRadicalElement>(GetDOMNode()));
return To<MathMLRadicalElement>(GetLayoutBox()->GetNode())->HasIndex(); return To<MathMLRadicalElement>(GetDOMNode())->HasIndex();
} }
scoped_refptr<const NGLayoutResult> NGBlockNode::LayoutAtomicInline( scoped_refptr<const NGLayoutResult> NGBlockNode::LayoutAtomicInline(
......
...@@ -157,6 +157,7 @@ class CORE_EXPORT NGLayoutInputNode { ...@@ -157,6 +157,7 @@ class CORE_EXPORT NGLayoutInputNode {
wtf_size_t TableCellRowspan() const; wtf_size_t TableCellRowspan() const;
bool IsMathRoot() const { return box_->IsMathMLRoot(); } bool IsMathRoot() const { return box_->IsMathMLRoot(); }
bool IsMathML() const { return box_->IsMathML(); }
bool IsAnonymousBlock() const { return box_->IsAnonymousBlock(); } bool IsAnonymousBlock() const { return box_->IsAnonymousBlock(); }
...@@ -210,6 +211,8 @@ class CORE_EXPORT NGLayoutInputNode { ...@@ -210,6 +211,8 @@ class CORE_EXPORT NGLayoutInputNode {
Document& GetDocument() const { return box_->GetDocument(); } Document& GetDocument() const { return box_->GetDocument(); }
Node* GetDOMNode() const { return box_->GetNode(); }
PhysicalSize InitialContainingBlockSize() const; PhysicalSize InitialContainingBlockSize() const;
// Returns the LayoutObject which is associated with this node. // Returns the LayoutObject which is associated with this node.
......
...@@ -155,7 +155,7 @@ NGTableTypes::CellInlineConstraint NGTableTypes::CreateCellInlineConstraint( ...@@ -155,7 +155,7 @@ NGTableTypes::CellInlineConstraint NGTableTypes::CreateCellInlineConstraint(
// Has not worked in Legacy, might be pulled out. // Has not worked in Legacy, might be pulled out.
if (css_inline_size && node.GetDocument().InQuirksMode()) { if (css_inline_size && node.GetDocument().InQuirksMode()) {
bool has_nowrap_attribute = bool has_nowrap_attribute =
!To<Element>(node.GetLayoutBox()->GetNode()) !To<Element>(node.GetDOMNode())
->FastGetAttribute(html_names::kNowrapAttr) ->FastGetAttribute(html_names::kNowrapAttr)
.IsNull(); .IsNull();
if (has_nowrap_attribute && node.Style().AutoWrap()) { if (has_nowrap_attribute && node.Style().AutoWrap()) {
...@@ -210,7 +210,7 @@ NGTableTypes::Section NGTableTypes::CreateSection( ...@@ -210,7 +210,7 @@ NGTableTypes::Section NGTableTypes::CreateSection(
if (section_css_block_size.IsPercent()) if (section_css_block_size.IsPercent())
percent = section_css_block_size.Percent(); percent = section_css_block_size.Percent();
bool is_tbody = bool is_tbody =
section.GetLayoutBox()->GetNode()->HasTagName(html_names::kTbodyTag); section.GetDOMNode()->HasTagName(html_names::kTbodyTag);
return Section{start_row, return Section{start_row,
rows, rows,
block_size, block_size,
......
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