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

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

Issue 2291273002: [layoutng] Allow testing NGBox without a LayoutObject (Closed)
Patch Set: fix bad merge -- private: was duplicated 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_box.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/ng/ng_box.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_box.cc b/third_party/WebKit/Source/core/layout/ng/ng_box.cc
index 14ded2f9a622666a86f800ac25917f32d644b887..a0eee39b2e28e8177b85dcd067eded44da8080ba 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_box.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_box.cc
@@ -21,6 +21,10 @@ NGBox::NGBox(LayoutObject* layout_object)
DCHECK(layout_box_);
}
+NGBox::NGBox(ComputedStyle* style) : style_(style) {
+ DCHECK(style_);
+}
+
bool NGBox::Layout(const NGConstraintSpace* constraint_space,
NGFragment** out) {
// We can either use the new layout code to do the layout and then copy the
@@ -38,20 +42,23 @@ bool NGBox::Layout(const NGConstraintSpace* constraint_space,
return false;
fragment_ = fragment;
- layout_box_->setWidth(fragment_->Width());
- layout_box_->setHeight(fragment_->Height());
+ if (layout_box_) {
+ layout_box_->setWidth(fragment_->Width());
+ layout_box_->setHeight(fragment_->Height());
- // Ensure the position of the children are copied across to the
- // LayoutObject tree.
- for (NGBox* box = FirstChild(); box; box = box->NextSibling()) {
- if (box->fragment_)
- box->PositionUpdated();
- }
+ // Ensure the position of the children are copied across to the
+ // LayoutObject tree.
+ for (NGBox* box = FirstChild(); box; box = box->NextSibling()) {
+ if (box->fragment_)
+ box->PositionUpdated();
+ }
- if (layout_box_->isLayoutBlock())
- toLayoutBlock(layout_box_)->layoutPositionedObjects(true);
- layout_box_->clearNeedsLayout();
+ if (layout_box_->isLayoutBlock())
+ toLayoutBlock(layout_box_)->layoutPositionedObjects(true);
+ layout_box_->clearNeedsLayout();
+ }
} else {
+ DCHECK(layout_box_);
// TODO(layout-ng): If fixedSize is true, set the override width/height too
NGLogicalSize container_size = constraint_space->ContainerSize();
layout_box_->setOverrideContainingBlockContentLogicalWidth(
@@ -82,23 +89,45 @@ bool NGBox::Layout(const NGConstraintSpace* constraint_space,
}
const ComputedStyle* NGBox::Style() const {
+ if (style_)
+ return style_.get();
+ DCHECK(layout_box_);
return layout_box_->style();
}
NGBox* NGBox::NextSibling() const {
+ if (style_)
+ return next_sibling_;
+ DCHECK(layout_box_);
LayoutObject* next_sibling = layout_box_->nextSibling();
return next_sibling ? new NGBox(next_sibling) : nullptr;
}
NGBox* NGBox::FirstChild() const {
+ if (style_)
+ return first_child_;
+ DCHECK(layout_box_);
LayoutObject* child = layout_box_->slowFirstChild();
return child ? new NGBox(child) : nullptr;
}
+void NGBox::SetNextSibling(NGBox* sibling) {
+ DCHECK(!layout_box_);
+ DCHECK(style_);
+ next_sibling_ = sibling;
+}
+
+void NGBox::SetFirstChild(NGBox* child) {
+ DCHECK(!layout_box_);
+ DCHECK(style_);
+ first_child_ = child;
+}
+
void NGBox::PositionUpdated() {
- DCHECK(fragment_);
- layout_box_->setX(fragment_->LeftOffset());
- layout_box_->setY(fragment_->TopOffset());
+ if (layout_box_) {
+ layout_box_->setX(fragment_->LeftOffset());
+ layout_box_->setY(fragment_->TopOffset());
+ }
}
bool NGBox::CanUseNewLayout() {
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_box.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698