Commit 5deb2c97 authored by Morten Stenshorne's avatar Morten Stenshorne Committed by Commit Bot

[LayoutNG] Stop using bitfields in NGConstraintSpaceBuilder.

NGConstraintSpaceBuilder is shortlived and we only have at most one of
them at any given time. Using bitfields just made the code bigger and
harder to maintain, and probably didn't save any memory at all.

Also make it STACK_ALLOCATED.

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: Ia30cd77f3babbffec182443060e12940d4e8e2af
Reviewed-on: https://chromium-review.googlesource.com/1069347Reviewed-by: default avatarChristian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarAleks Totic <atotic@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Morten Stenshorne <mstensho@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561023}
parent 96887d52
......@@ -19,23 +19,7 @@ NGConstraintSpaceBuilder::NGConstraintSpaceBuilder(
NGConstraintSpaceBuilder::NGConstraintSpaceBuilder(WritingMode writing_mode,
NGPhysicalSize icb_size)
: initial_containing_block_size_(icb_size),
fragmentainer_block_size_(NGSizeIndefinite),
fragmentainer_space_at_bfc_start_(NGSizeIndefinite),
parent_writing_mode_(static_cast<unsigned>(writing_mode)),
is_fixed_size_inline_(false),
is_fixed_size_block_(false),
fixed_size_block_is_definite_(true),
is_shrink_to_fit_(false),
is_intermediate_layout_(false),
fragmentation_type_(kFragmentNone),
separate_leading_fragmentainer_margins_(false),
is_new_fc_(false),
is_anonymous_(false),
use_first_line_style_(false),
should_force_clearance_(false),
adjoining_floats_(kFloatTypeNone),
text_direction_(static_cast<unsigned>(TextDirection::kLtr)),
exclusion_space_(nullptr) {}
parent_writing_mode_(writing_mode) {}
NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetAvailableSize(
NGLogicalSize available_size) {
......@@ -51,7 +35,7 @@ NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetPercentageResolutionSize(
NGConstraintSpaceBuilder& NGConstraintSpaceBuilder::SetTextDirection(
TextDirection text_direction) {
text_direction_ = static_cast<unsigned>(text_direction);
text_direction_ = text_direction;
return *this;
}
......@@ -159,8 +143,8 @@ scoped_refptr<NGConstraintSpace> NGConstraintSpaceBuilder::ToConstraintSpace(
WritingMode out_writing_mode) {
// Whether the child and the containing block are parallel to each other.
// Example: vertical-rl and vertical-lr
bool is_in_parallel_flow = IsParallelWritingMode(
static_cast<WritingMode>(parent_writing_mode_), out_writing_mode);
bool is_in_parallel_flow =
IsParallelWritingMode(parent_writing_mode_, out_writing_mode);
NGLogicalSize available_size = available_size_;
NGLogicalSize percentage_resolution_size = percentage_resolution_size_;
......@@ -219,14 +203,12 @@ scoped_refptr<NGConstraintSpace> NGConstraintSpaceBuilder::ToConstraintSpace(
}
return base::AdoptRef(new NGConstraintSpace(
out_writing_mode, !is_in_parallel_flow,
static_cast<TextDirection>(text_direction_), available_size,
out_writing_mode, !is_in_parallel_flow, text_direction_, available_size,
percentage_resolution_size, parent_percentage_resolution_size.inline_size,
initial_containing_block_size_, fragmentainer_block_size_,
fragmentainer_space_at_bfc_start_, is_fixed_size_inline,
is_fixed_size_block, fixed_size_block_is_definite, is_shrink_to_fit_,
is_intermediate_layout_,
static_cast<NGFragmentationType>(fragmentation_type_),
is_intermediate_layout_, fragmentation_type_,
separate_leading_fragmentainer_margins_, is_new_fc_, is_anonymous_,
use_first_line_style_, should_force_clearance_, adjoining_floats_,
margin_strut, bfc_offset, floats_bfc_offset, exclusion_space,
......
......@@ -7,15 +7,19 @@
#include "base/optional.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_bfc_offset.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_logical_size.h"
#include "third_party/blink/renderer/core/layout/ng/ng_constraint_space.h"
#include "third_party/blink/renderer/core/layout/ng/ng_exclusion.h"
#include "third_party/blink/renderer/core/layout/ng/ng_floats_utils.h"
#include "third_party/blink/renderer/core/layout/ng/ng_unpositioned_float.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/wtf/allocator.h"
namespace blink {
class CORE_EXPORT NGConstraintSpaceBuilder final {
DISALLOW_NEW();
STACK_ALLOCATED();
public:
// NOTE: This constructor doesn't act like a copy-constructor, it uses the
......@@ -104,28 +108,28 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
NGLogicalSize percentage_resolution_size_;
base::Optional<NGLogicalSize> parent_percentage_resolution_size_;
NGPhysicalSize initial_containing_block_size_;
LayoutUnit fragmentainer_block_size_;
LayoutUnit fragmentainer_space_at_bfc_start_;
unsigned parent_writing_mode_ : 3;
unsigned is_fixed_size_inline_ : 1;
unsigned is_fixed_size_block_ : 1;
unsigned fixed_size_block_is_definite_ : 1;
unsigned is_shrink_to_fit_ : 1;
unsigned is_intermediate_layout_ : 1;
unsigned fragmentation_type_ : 2;
unsigned separate_leading_fragmentainer_margins_ : 1;
unsigned is_new_fc_ : 1;
unsigned is_anonymous_ : 1;
unsigned use_first_line_style_ : 1;
unsigned should_force_clearance_ : 1;
unsigned adjoining_floats_ : 2; // NGFloatTypes
unsigned text_direction_ : 1;
LayoutUnit fragmentainer_block_size_ = NGSizeIndefinite;
LayoutUnit fragmentainer_space_at_bfc_start_ = NGSizeIndefinite;
WritingMode parent_writing_mode_;
NGFragmentationType fragmentation_type_ = kFragmentNone;
NGFloatTypes adjoining_floats_ = kFloatTypeNone;
TextDirection text_direction_ = TextDirection::kLtr;
bool is_fixed_size_inline_ = false;
bool is_fixed_size_block_ = false;
bool fixed_size_block_is_definite_ = true;
bool is_shrink_to_fit_ = false;
bool is_intermediate_layout_ = false;
bool separate_leading_fragmentainer_margins_ = false;
bool is_new_fc_ = false;
bool is_anonymous_ = false;
bool use_first_line_style_ = false;
bool should_force_clearance_ = false;
NGMarginStrut margin_strut_;
NGBfcOffset bfc_offset_;
base::Optional<NGBfcOffset> floats_bfc_offset_;
const NGExclusionSpace* exclusion_space_;
const NGExclusionSpace* exclusion_space_ = nullptr;
LayoutUnit clearance_offset_;
Vector<NGBaselineRequest> baseline_requests_;
};
......
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