Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_constraint_space.cc

Issue 2299823002: [LayoutNG] Merge NGDerivedConstraintSpace into NGConstraintSpace (Closed)
Patch Set: Fix copy constructors Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/ng/ng_constraint_space.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_constraint_space.cc b/third_party/WebKit/Source/core/layout/ng/ng_constraint_space.cc
index 39d3e82ed2e48f02485ee417f1fd7124c50d6dbf..213ab834004ad54493b51470c5e9bc0e99dfb654 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_constraint_space.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_constraint_space.cc
@@ -13,21 +13,67 @@ namespace blink {
// NGPhysicalConstraintSpace.
NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode,
NGLogicalSize container_size)
- : physical_space_(new NGPhysicalConstraintSpace()),
- writing_mode_(writing_mode) {
- SetContainerSize(container_size);
-}
+ : physical_space_(new NGPhysicalConstraintSpace(
+ container_size.ConvertToPhysical(writing_mode))),
+ size_(container_size),
+ writing_mode_(writing_mode) {}
NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode,
NGPhysicalConstraintSpace* physical_space)
- : physical_space_(physical_space), writing_mode_(writing_mode) {
-}
+ : physical_space_(physical_space),
+ size_(physical_space->ContainerSize().ConvertToLogical(writing_mode)),
+ writing_mode_(writing_mode) {}
+
+NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode,
+ const NGConstraintSpace* constraint_space)
+ : physical_space_(constraint_space->PhysicalSpace()),
+ offset_(constraint_space->Offset()),
+ size_(constraint_space->Size()),
+ writing_mode_(writing_mode) {}
+
+NGConstraintSpace::NGConstraintSpace(NGWritingMode writing_mode,
+ const NGConstraintSpace& other,
+ NGLogicalOffset offset,
+ NGLogicalSize size)
+ : physical_space_(other.PhysicalSpace()),
+ offset_(offset),
+ size_(size),
+ writing_mode_(writing_mode) {}
NGConstraintSpace::NGConstraintSpace(const NGConstraintSpace& other,
- NGLogicalSize container_size)
- : physical_space_(*other.physical_space_),
- writing_mode_(other.writing_mode_) {
- SetContainerSize(container_size);
+ NGLogicalOffset offset,
+ NGLogicalSize size)
+ : physical_space_(other.PhysicalSpace()),
+ offset_(offset),
+ size_(size),
+ writing_mode_(other.WritingMode()) {}
+
+NGConstraintSpace* NGConstraintSpace::CreateFromLayoutObject(
+ const LayoutBox& box) {
+ bool fixed_inline = false, fixed_block = false;
+ // XXX for orthogonal writing mode this is not right
+ LayoutUnit container_logical_width =
+ std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent());
+ // XXX Make sure this height is correct
+ LayoutUnit container_logical_height =
+ box.containingBlockLogicalHeightForContent(ExcludeMarginBorderPadding);
+ if (box.hasOverrideLogicalContentWidth()) {
+ container_logical_width = box.overrideLogicalContentWidth();
+ fixed_inline = true;
+ }
+ if (box.hasOverrideLogicalContentHeight()) {
+ container_logical_width = box.overrideLogicalContentHeight();
+ fixed_block = true;
+ }
+
+ NGConstraintSpace* derived_constraint_space = new NGConstraintSpace(
+ FromPlatformWritingMode(box.styleRef().getWritingMode()),
+ NGLogicalSize(container_logical_width, container_logical_height));
+ derived_constraint_space->SetOverflowTriggersScrollbar(
+ box.styleRef().overflowInlineDirection() == OverflowAuto,
+ box.styleRef().overflowBlockDirection() == OverflowAuto);
+ derived_constraint_space->SetFixedSize(fixed_inline, fixed_block);
+ return derived_constraint_space;
}
NGLogicalSize NGConstraintSpace::ContainerSize() const {
@@ -75,11 +121,6 @@ NGLayoutOpportunityIterator NGConstraintSpace::LayoutOpportunities(
return iterator;
}
-void NGConstraintSpace::SetContainerSize(NGLogicalSize container_size) {
- physical_space_->container_size_ = container_size.ConvertToPhysical(
- static_cast<NGWritingMode>(writing_mode_));
-}
-
void NGConstraintSpace::SetOverflowTriggersScrollbar(bool inline_triggers,
bool block_triggers) {
if (writing_mode_ == HorizontalTopBottom) {

Powered by Google App Engine
This is Rietveld 408576698