forked from mirror/chromium
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
224 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
third_party/WebKit/Source/core/layout/mathml/layout_ng_mathml_space.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2017 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 "layout_ng_mathml_space.h" | ||
|
||
#include "core/mathml/MathMLSpaceElement.h" | ||
|
||
namespace blink { | ||
|
||
LayoutNGMathMLSpace::LayoutNGMathMLSpace(MathMLSpaceElement* element) | ||
: LayoutNGMathMLBlock(element) { | ||
DCHECK(element); | ||
} | ||
|
||
void LayoutNGMathMLSpace::layoutBlock(bool relayoutChildren) { | ||
ASSERT_NOT_REACHED(); // Should use LayoutNG instead | ||
clearNeedsLayout(); | ||
} | ||
|
||
NGMathMLSpaceNode* LayoutNGMathMLSpace::toNGLayoutInputNode( | ||
const ComputedStyle& style) { | ||
MathMLSpaceElement* spaceElement = toMathMLSpaceElement(node()); | ||
return new NGMathMLSpaceNode(this, spaceElement->width(), | ||
spaceElement->height(), spaceElement->depth()); | ||
} | ||
|
||
} // namespace blink |
28 changes: 28 additions & 0 deletions
28
third_party/WebKit/Source/core/layout/mathml/layout_ng_mathml_space.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2017 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 LayoutNGMathMLSpace_h | ||
#define LayoutNGMathMLSpace_h | ||
|
||
#include "core/layout/mathml/ng_mathml_space_node.h" | ||
|
||
#include "core/layout/LayoutBlock.h" | ||
#include "core/layout/mathml/layout_ng_mathml_block.h" | ||
|
||
namespace blink { | ||
|
||
class MathMLSpaceElement; | ||
|
||
class LayoutNGMathMLSpace final : public LayoutNGMathMLBlock { | ||
public: | ||
explicit LayoutNGMathMLSpace(MathMLSpaceElement*); | ||
~LayoutNGMathMLSpace() override = default; | ||
void layoutBlock(bool relayoutChildren) override; | ||
const char* name() const override { return "LayoutNGMathMLSpace"; } | ||
|
||
NGMathMLSpaceNode* toNGLayoutInputNode(const ComputedStyle&) override; | ||
}; | ||
} | ||
|
||
#endif // LayoutNGMathMLSpace_h |
30 changes: 30 additions & 0 deletions
30
third_party/WebKit/Source/core/layout/mathml/ng_mathml_space_node.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2017 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 "core/layout/mathml/ng_mathml_space_node.h" | ||
|
||
#include "core/layout/ng/ng_fragment_builder.h" | ||
|
||
namespace blink { | ||
|
||
RefPtr<NGLayoutResult> NGMathMLSpaceNode::Layout( | ||
NGConstraintSpace* constraint_space, | ||
NGBreakToken* break_token) { | ||
NGFragmentBuilder builder(NGPhysicalFragment::kFragmentBox, this); | ||
|
||
// FIXME: We should use height & depth to set NGFragment's alignmentBaseline. | ||
LayoutUnit blockSize = toUserUnits(m_height, LayoutUnit(0)) + | ||
toUserUnits(m_depth, LayoutUnit(0)); | ||
|
||
RefPtr<NGLayoutResult> result = | ||
builder.SetBlockSize(blockSize) | ||
.SetInlineSize(toUserUnits(m_width, LayoutUnit(0))) | ||
.ToBoxFragment(); | ||
|
||
CopyFragmentDataToLayoutBox(*constraint_space, result.get()); | ||
|
||
return result; | ||
} | ||
|
||
} // namespace blink |
43 changes: 43 additions & 0 deletions
43
third_party/WebKit/Source/core/layout/mathml/ng_mathml_space_node.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2017 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 NGMathMLSpaceNode_h | ||
#define NGMathMLSpaceNode_h | ||
|
||
#include "core/layout/mathml/ng_mathml_input_node.h" | ||
|
||
#include "core/mathml/MathMLElement.h" | ||
|
||
namespace blink { | ||
|
||
// Let's assume we're a block so our parent can layout us as such, but override | ||
// our layout algorithm so new we layout the children using a simplified | ||
// algorithm for MathML. | ||
// | ||
// FIXME(emilio): This might need more care, but right now LayoutNG only does | ||
// Block and a simplified version of inline layout, so making it quack like a | ||
// block is probably ok. | ||
class NGMathMLSpaceNode final : public NGMathMLInputNode { | ||
public: | ||
explicit NGMathMLSpaceNode(LayoutObject* flow, | ||
const MathMLElement::Length& width, | ||
const MathMLElement::Length& height, | ||
const MathMLElement::Length& depth) | ||
: NGMathMLInputNode(flow), | ||
m_width(width), | ||
m_height(height), | ||
m_depth(depth) {} | ||
|
||
RefPtr<NGLayoutResult> Layout(NGConstraintSpace* constraint_space, | ||
NGBreakToken* break_token) final; | ||
|
||
private: | ||
const MathMLElement::Length& m_width; | ||
const MathMLElement::Length& m_height; | ||
const MathMLElement::Length& m_depth; | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
third_party/WebKit/Source/core/mathml/MathMLSpaceElement.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2017 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 "core/mathml/MathMLSpaceElement.h" | ||
|
||
#include "core/layout/mathml/layout_ng_mathml_space.h" | ||
|
||
namespace blink { | ||
|
||
using namespace MathMLNames; | ||
|
||
MathMLSpaceElement::MathMLSpaceElement(Document& doc) | ||
: MathMLElement(MathMLNames::mspaceTag, doc) {} | ||
|
||
DEFINE_NODE_FACTORY(MathMLSpaceElement) | ||
|
||
void MathMLSpaceElement::parseAttribute( | ||
const AttributeModificationParams& param) { | ||
if (param.name == widthAttr) | ||
m_width.dirty = true; | ||
else if (param.name == heightAttr) | ||
m_height.dirty = true; | ||
else if (param.name == depthAttr) | ||
m_depth.dirty = true; | ||
|
||
MathMLElement::parseAttribute(param); | ||
} | ||
|
||
/* | ||
* TODO(emilio): We could consider writing our custom paint code for MathML | ||
* stuff, and then we'd only need to create LayoutNGNodes. | ||
* | ||
* But meanwhile... | ||
*/ | ||
LayoutObject* MathMLSpaceElement::createLayoutObject(const ComputedStyle&) { | ||
return new LayoutNGMathMLSpace(this); | ||
} | ||
|
||
} // namespace blink |
46 changes: 46 additions & 0 deletions
46
third_party/WebKit/Source/core/mathml/MathMLSpaceElement.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2017 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 MathMLMSpaceElement_h | ||
#define MathMLMSpaceElement_h | ||
|
||
#include "core/MathMLNames.h" | ||
#include "core/mathml/MathMLElement.h" | ||
|
||
namespace blink { | ||
|
||
class LayoutObject; | ||
class ComputedStyle; | ||
|
||
class MathMLSpaceElement final : public MathMLElement { | ||
public: | ||
DECLARE_NODE_FACTORY(MathMLSpaceElement); | ||
|
||
const Length& width() { | ||
return cachedMathMLLength(MathMLNames::widthAttr, m_width); | ||
} | ||
const Length& height() { | ||
return cachedMathMLLength(MathMLNames::heightAttr, m_height); | ||
} | ||
const Length& depth() { | ||
return cachedMathMLLength(MathMLNames::depthAttr, m_depth); | ||
} | ||
|
||
protected: | ||
explicit MathMLSpaceElement(Document&); | ||
|
||
private: | ||
LayoutObject* createLayoutObject(const ComputedStyle&) override; | ||
virtual void parseAttribute(const AttributeModificationParams&); | ||
|
||
Length m_width; | ||
Length m_height; | ||
Length m_depth; | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif // MathMLMSpaceElement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters