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

Side by Side Diff: third_party/WebKit/Source/core/dom/Node.cpp

Issue 2814603002: Move LayoutObject to satellite NodeLayoutData that hangs from a Node. (Closed)
Patch Set: Review's comments Created 3 years, 8 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 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 #if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS) 291 #if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS)
292 TrackForDebugging(); 292 TrackForDebugging();
293 #endif 293 #endif
294 InstanceCounters::IncrementNodeCounter(); 294 InstanceCounters::IncrementNodeCounter();
295 } 295 }
296 296
297 Node::~Node() { 297 Node::~Node() {
298 // With Oilpan, the rare data finalizer also asserts for 298 // With Oilpan, the rare data finalizer also asserts for
299 // this condition (we cannot directly access it here.) 299 // this condition (we cannot directly access it here.)
300 CHECK(HasRareData() || !GetLayoutObject()); 300 CHECK(HasRareData() || !GetLayoutObject());
301 if (!HasRareData() && !data_.node_layout_data_->IsSharedEmptyData())
302 delete data_.node_layout_data_;
301 InstanceCounters::DecrementNodeCounter(); 303 InstanceCounters::DecrementNodeCounter();
302 } 304 }
303 305
304 NodeRareData* Node::RareData() const { 306 NodeRareData* Node::RareData() const {
305 SECURITY_DCHECK(HasRareData()); 307 SECURITY_DCHECK(HasRareData());
306 return static_cast<NodeRareData*>(data_.rare_data_); 308 return static_cast<NodeRareData*>(data_.rare_data_);
307 } 309 }
308 310
309 NodeRareData& Node::EnsureRareData() { 311 NodeRareData& Node::EnsureRareData() {
310 if (HasRareData()) 312 if (HasRareData())
311 return *RareData(); 313 return *RareData();
312 314
313 if (IsElementNode()) 315 if (IsElementNode())
314 data_.rare_data_ = ElementRareData::Create(data_.layout_object_); 316 data_.rare_data_ = ElementRareData::Create(data_.node_layout_data_);
315 else 317 else
316 data_.rare_data_ = NodeRareData::Create(data_.layout_object_); 318 data_.rare_data_ = NodeRareData::Create(data_.node_layout_data_);
317 319
318 DCHECK(data_.rare_data_); 320 DCHECK(data_.rare_data_);
319 SetFlag(kHasRareDataFlag); 321 SetFlag(kHasRareDataFlag);
320 ScriptWrappableVisitor::WriteBarrier(this, RareData()); 322 ScriptWrappableVisitor::WriteBarrier(this, RareData());
321 return *RareData(); 323 return *RareData();
322 } 324 }
323 325
324 Node* Node::ToNode() { 326 Node* Node::ToNode() {
325 return this; 327 return this;
326 } 328 }
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 node = NodeTraversal::NextPostOrder(*node); 584 node = NodeTraversal::NextPostOrder(*node);
583 } 585 }
584 } 586 }
585 587
586 LayoutBox* Node::GetLayoutBox() const { 588 LayoutBox* Node::GetLayoutBox() const {
587 LayoutObject* layout_object = this->GetLayoutObject(); 589 LayoutObject* layout_object = this->GetLayoutObject();
588 return layout_object && layout_object->IsBox() ? ToLayoutBox(layout_object) 590 return layout_object && layout_object->IsBox() ? ToLayoutBox(layout_object)
589 : nullptr; 591 : nullptr;
590 } 592 }
591 593
594 void Node::SetLayoutObject(LayoutObject* layout_object) {
esprehn 2017/04/13 18:41:08 This allocates a NodeLayoutData when setting a nul
nainar 2017/04/13 20:21:03 Done. Also commented inline.
595 if (HasRareData()) {
596 if (data_.rare_data_->GetNodeLayoutData()->IsSharedEmptyData())
597 data_.rare_data_->SetNodeLayoutData(new NodeLayoutData(layout_object));
598 else
599 data_.rare_data_->GetNodeLayoutData()->SetLayoutObject(layout_object);
600 } else {
601 if (data_.node_layout_data_->IsSharedEmptyData())
602 data_.node_layout_data_ = new NodeLayoutData(layout_object);
603 else
604 data_.node_layout_data_->SetLayoutObject(layout_object);
605 }
606 }
607
592 LayoutBoxModelObject* Node::GetLayoutBoxModelObject() const { 608 LayoutBoxModelObject* Node::GetLayoutBoxModelObject() const {
593 LayoutObject* layout_object = this->GetLayoutObject(); 609 LayoutObject* layout_object = this->GetLayoutObject();
594 return layout_object && layout_object->IsBoxModelObject() 610 return layout_object && layout_object->IsBoxModelObject()
595 ? ToLayoutBoxModelObject(layout_object) 611 ? ToLayoutBoxModelObject(layout_object)
596 : nullptr; 612 : nullptr;
597 } 613 }
598 614
599 LayoutRect Node::BoundingBox() const { 615 LayoutRect Node::BoundingBox() const {
600 if (GetLayoutObject()) 616 if (GetLayoutObject())
601 return LayoutRect(GetLayoutObject()->AbsoluteBoundingBoxRect()); 617 return LayoutRect(GetLayoutObject()->AbsoluteBoundingBoxRect());
(...skipping 1938 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 if (node) { 2556 if (node) {
2541 std::stringstream stream; 2557 std::stringstream stream;
2542 node->PrintNodePathTo(stream); 2558 node->PrintNodePathTo(stream);
2543 LOG(INFO) << stream.str(); 2559 LOG(INFO) << stream.str();
2544 } else { 2560 } else {
2545 LOG(INFO) << "Cannot showNodePath for <null>"; 2561 LOG(INFO) << "Cannot showNodePath for <null>";
2546 } 2562 }
2547 } 2563 }
2548 2564
2549 #endif 2565 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698