Commit 74191dd9 authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

[layoutng] Make NGBaseFragmentBuilder match the members of NGPhysicalFragment

This is a precondition for the next step I want to do, which is initialize
fragments by passing the builder to their constructor, like we already
do for constraint spaces.

R=eae@chromium.org

Change-Id: I626fe15da8d9643a3152f7a1cb0d4e556fb0d22a
Reviewed-on: https://chromium-review.googlesource.com/c/1289720
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601288}
parent 5decbd7f
...@@ -196,8 +196,6 @@ class CORE_EXPORT NGLineBoxFragmentBuilder final ...@@ -196,8 +196,6 @@ class CORE_EXPORT NGLineBoxFragmentBuilder final
NGLineHeightMetrics metrics_; NGLineHeightMetrics metrics_;
Vector<NGPositionedFloat> positioned_floats_; Vector<NGPositionedFloat> positioned_floats_;
scoped_refptr<NGInlineBreakToken> break_token_;
TextDirection base_direction_; TextDirection base_direction_;
DISALLOW_COPY_AND_ASSIGN(NGLineBoxFragmentBuilder); DISALLOW_COPY_AND_ASSIGN(NGLineBoxFragmentBuilder);
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_logical_size.h"
#include "third_party/blink/renderer/core/layout/ng/ng_break_token.h"
#include "third_party/blink/renderer/core/layout/ng/ng_style_variant.h" #include "third_party/blink/renderer/core/layout/ng/ng_style_variant.h"
#include "third_party/blink/renderer/platform/text/text_direction.h" #include "third_party/blink/renderer/platform/text/text_direction.h"
#include "third_party/blink/renderer/platform/text/writing_mode.h" #include "third_party/blink/renderer/platform/text/writing_mode.h"
...@@ -15,6 +17,8 @@ ...@@ -15,6 +17,8 @@
namespace blink { namespace blink {
class ComputedStyle; class ComputedStyle;
class LayoutObject;
class NGBreakToken;
class CORE_EXPORT NGBaseFragmentBuilder { class CORE_EXPORT NGBaseFragmentBuilder {
STACK_ALLOCATED(); STACK_ALLOCATED();
...@@ -35,6 +39,18 @@ class CORE_EXPORT NGBaseFragmentBuilder { ...@@ -35,6 +39,18 @@ class CORE_EXPORT NGBaseFragmentBuilder {
WritingMode GetWritingMode() const { return writing_mode_; } WritingMode GetWritingMode() const { return writing_mode_; }
TextDirection Direction() const { return direction_; } TextDirection Direction() const { return direction_; }
LayoutUnit InlineSize() const { return size_.inline_size; }
LayoutUnit BlockSize() const { return size_.block_size; }
const NGLogicalSize& Size() const { return size_; }
NGBaseFragmentBuilder& SetInlineSize(LayoutUnit inline_size) {
DCHECK_GE(inline_size, LayoutUnit());
size_.inline_size = inline_size;
return *this;
}
void SetBlockSize(LayoutUnit block_size) { size_.block_size = block_size; }
LayoutObject* GetLayoutObject() { return layout_object_; }
protected: protected:
NGBaseFragmentBuilder(scoped_refptr<const ComputedStyle>, NGBaseFragmentBuilder(scoped_refptr<const ComputedStyle>,
WritingMode, WritingMode,
...@@ -48,6 +64,9 @@ class CORE_EXPORT NGBaseFragmentBuilder { ...@@ -48,6 +64,9 @@ class CORE_EXPORT NGBaseFragmentBuilder {
protected: protected:
NGStyleVariant style_variant_; NGStyleVariant style_variant_;
NGLogicalSize size_;
LayoutObject* layout_object_ = nullptr;
scoped_refptr<NGBreakToken> break_token_;
}; };
} // namespace blink } // namespace blink
......
...@@ -36,16 +36,6 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGBaseFragmentBuilder { ...@@ -36,16 +36,6 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGBaseFragmentBuilder {
~NGContainerFragmentBuilder() override; ~NGContainerFragmentBuilder() override;
LayoutUnit InlineSize() const { return size_.inline_size; }
LayoutUnit BlockSize() const { return size_.block_size; }
const NGLogicalSize& Size() const { return size_; }
NGContainerFragmentBuilder& SetInlineSize(LayoutUnit inline_size) {
DCHECK_GE(inline_size, LayoutUnit());
size_.inline_size = inline_size;
return *this;
}
void SetBlockSize(LayoutUnit block_size) { size_.block_size = block_size; }
LayoutUnit BfcLineOffset() const { return bfc_line_offset_; } LayoutUnit BfcLineOffset() const { return bfc_line_offset_; }
NGContainerFragmentBuilder& SetBfcLineOffset(LayoutUnit bfc_line_offset) { NGContainerFragmentBuilder& SetBfcLineOffset(LayoutUnit bfc_line_offset) {
bfc_line_offset_ = bfc_line_offset; bfc_line_offset_ = bfc_line_offset;
...@@ -213,7 +203,6 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGBaseFragmentBuilder { ...@@ -213,7 +203,6 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGBaseFragmentBuilder {
WritingMode, WritingMode,
TextDirection); TextDirection);
NGLogicalSize size_;
LayoutUnit bfc_line_offset_; LayoutUnit bfc_line_offset_;
base::Optional<LayoutUnit> bfc_block_offset_; base::Optional<LayoutUnit> bfc_block_offset_;
......
...@@ -47,10 +47,11 @@ NGFragmentBuilder::NGFragmentBuilder(NGLayoutInputNode node, ...@@ -47,10 +47,11 @@ NGFragmentBuilder::NGFragmentBuilder(NGLayoutInputNode node,
TextDirection direction) TextDirection direction)
: NGContainerFragmentBuilder(std::move(style), writing_mode, direction), : NGContainerFragmentBuilder(std::move(style), writing_mode, direction),
node_(node), node_(node),
layout_object_(node.GetLayoutBox()),
box_type_(NGPhysicalFragment::NGBoxType::kNormalBox), box_type_(NGPhysicalFragment::NGBoxType::kNormalBox),
is_old_layout_root_(false), is_old_layout_root_(false),
did_break_(false) {} did_break_(false) {
layout_object_ = node.GetLayoutBox();
}
NGFragmentBuilder::NGFragmentBuilder(LayoutObject* layout_object, NGFragmentBuilder::NGFragmentBuilder(LayoutObject* layout_object,
scoped_refptr<const ComputedStyle> style, scoped_refptr<const ComputedStyle> style,
...@@ -58,10 +59,11 @@ NGFragmentBuilder::NGFragmentBuilder(LayoutObject* layout_object, ...@@ -58,10 +59,11 @@ NGFragmentBuilder::NGFragmentBuilder(LayoutObject* layout_object,
TextDirection direction) TextDirection direction)
: NGContainerFragmentBuilder(std::move(style), writing_mode, direction), : NGContainerFragmentBuilder(std::move(style), writing_mode, direction),
node_(nullptr), node_(nullptr),
layout_object_(layout_object),
box_type_(NGPhysicalFragment::NGBoxType::kNormalBox), box_type_(NGPhysicalFragment::NGBoxType::kNormalBox),
is_old_layout_root_(false), is_old_layout_root_(false),
did_break_(false) {} did_break_(false) {
layout_object_ = layout_object;
}
NGFragmentBuilder::~NGFragmentBuilder() = default; NGFragmentBuilder::~NGFragmentBuilder() = default;
......
...@@ -213,13 +213,10 @@ class CORE_EXPORT NGFragmentBuilder final : public NGContainerFragmentBuilder { ...@@ -213,13 +213,10 @@ class CORE_EXPORT NGFragmentBuilder final : public NGContainerFragmentBuilder {
HashMap<const LayoutObject*, FragmentPair>* inline_container_fragments, HashMap<const LayoutObject*, FragmentPair>* inline_container_fragments,
NGLogicalSize* container_size); NGLogicalSize* container_size);
LayoutObject* GetLayoutObject() { return layout_object_; }
private: private:
scoped_refptr<NGLayoutResult> ToBoxFragment(WritingMode); scoped_refptr<NGLayoutResult> ToBoxFragment(WritingMode);
NGLayoutInputNode node_; NGLayoutInputNode node_;
LayoutObject* layout_object_;
LayoutUnit intrinsic_block_size_; LayoutUnit intrinsic_block_size_;
NGBoxStrut borders_; NGBoxStrut borders_;
......
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