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

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_block_node.cc

Issue 2642823008: Introduce NGFloatingObject (Closed)
Patch Set: Update TestExpectations Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/ng/ng_block_node.h" 5 #include "core/layout/ng/ng_block_node.h"
6 6
7 #include "core/layout/LayoutBlockFlow.h" 7 #include "core/layout/LayoutBlockFlow.h"
8 #include "core/layout/api/LineLayoutAPIShim.h" 8 #include "core/layout/api/LineLayoutAPIShim.h"
9 #include "core/layout/line/InlineIterator.h" 9 #include "core/layout/line/InlineIterator.h"
10 #include "core/layout/ng/layout_ng_block_flow.h" 10 #include "core/layout/ng/layout_ng_block_flow.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 NGLayoutInputNode::trace(visitor); 175 NGLayoutInputNode::trace(visitor);
176 } 176 }
177 177
178 void NGBlockNode::PositionUpdated() { 178 void NGBlockNode::PositionUpdated() {
179 if (!layout_box_) 179 if (!layout_box_)
180 return; 180 return;
181 DCHECK(layout_box_->parent()) << "Should be called on children only."; 181 DCHECK(layout_box_->parent()) << "Should be called on children only.";
182 182
183 layout_box_->setX(fragment_->LeftOffset()); 183 layout_box_->setX(fragment_->LeftOffset());
184 layout_box_->setY(fragment_->TopOffset()); 184 layout_box_->setY(fragment_->TopOffset());
185 }
185 186
186 if (layout_box_->isFloating() && layout_box_->parent()->isLayoutBlockFlow()) { 187 void NGBlockNode::FloatPositionUpdated(LayoutObject* parent) {
187 FloatingObject* floating_object = toLayoutBlockFlow(layout_box_->parent()) 188 PositionUpdated();
188 ->insertFloatingObject(*layout_box_); 189
190 if (layout_box_->isFloating() && parent && parent->isLayoutBlockFlow()) {
191 FloatingObject* floating_object =
192 toLayoutBlockFlow(parent)->insertFloatingObject(*layout_box_);
193 // TODO(glebl): Fix floating_object's inline offset if it's attached to
194 // parent != layout_box_->parent
189 floating_object->setX(fragment_->LeftOffset()); 195 floating_object->setX(fragment_->LeftOffset());
190 floating_object->setY(fragment_->TopOffset()); 196 floating_object->setY(fragment_->TopOffset());
191 floating_object->setIsPlaced(true); 197 floating_object->setIsPlaced(true);
192 } 198 }
193 } 199 }
194 200
195 bool NGBlockNode::CanUseNewLayout() { 201 bool NGBlockNode::CanUseNewLayout() {
196 if (!layout_box_) 202 if (!layout_box_)
197 return true; 203 return true;
198 if (!layout_box_->isLayoutBlockFlow()) 204 if (!layout_box_->isLayoutBlockFlow())
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 !walker.atEnd(); walker.advance()) { 250 !walker.atEnd(); walker.advance()) {
245 LayoutObject* o = LineLayoutAPIShim::layoutObjectFrom(walker.current()); 251 LayoutObject* o = LineLayoutAPIShim::layoutObjectFrom(walker.current());
246 o->clearNeedsLayout(); 252 o->clearNeedsLayout();
247 } 253 }
248 254
249 // Ensure the position of the children are copied across to the 255 // Ensure the position of the children are copied across to the
250 // LayoutObject tree. 256 // LayoutObject tree.
251 } else { 257 } else {
252 for (NGBlockNode* box = toNGBlockNode(FirstChild()); box; 258 for (NGBlockNode* box = toNGBlockNode(FirstChild()); box;
253 box = box->NextSibling()) { 259 box = box->NextSibling()) {
254 if (box->fragment_) 260 if (box->fragment_ && box->fragment_->IsPlaced())
255 box->PositionUpdated(); 261 box->PositionUpdated();
262
263 for (const auto& floating_object : box->fragment_->PositionedFloats()) {
264 floating_object->node->FloatPositionUpdated(box->layout_box_);
265 }
256 } 266 }
257 } 267 }
258 268
259 if (layout_box_->isLayoutBlock()) 269 if (layout_box_->isLayoutBlock())
260 toLayoutBlock(layout_box_)->layoutPositionedObjects(true); 270 toLayoutBlock(layout_box_)->layoutPositionedObjects(true);
261 layout_box_->clearNeedsLayout(); 271 layout_box_->clearNeedsLayout();
262 if (layout_box_->isLayoutBlockFlow()) { 272 if (layout_box_->isLayoutBlockFlow()) {
263 toLayoutBlockFlow(layout_box_)->updateIsSelfCollapsing(); 273 toLayoutBlockFlow(layout_box_)->updateIsSelfCollapsing();
264 } 274 }
265 } 275 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // Save static position for legacy AbsPos layout. 321 // Save static position for legacy AbsPos layout.
312 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { 322 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) {
313 DCHECK(layout_box_); 323 DCHECK(layout_box_);
314 DCHECK(layout_box_->isOutOfFlowPositioned()); 324 DCHECK(layout_box_->isOutOfFlowPositioned());
315 DCHECK(layout_box_->layer()); 325 DCHECK(layout_box_->layer());
316 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); 326 layout_box_->layer()->setStaticBlockPosition(offset.block_offset);
317 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); 327 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset);
318 } 328 }
319 329
320 } // namespace blink 330 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698