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

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

Issue 2821193003: Store nonAttachedStyle on NodeLayoutData instead of on HashMap in Document. (Closed)
Patch Set: Revert back to rune@'s lgtmed patch Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 if (!node_layout_data->IsSharedEmptyData()) { 599 if (!node_layout_data->IsSharedEmptyData()) {
600 node_layout_data->SetLayoutObject(layout_object); 600 node_layout_data->SetLayoutObject(layout_object);
601 return; 601 return;
602 } 602 }
603 603
604 if (!layout_object) 604 if (!layout_object)
605 return; 605 return;
606 606
607 // Swap the NodeLayoutData to point to a new NodeLayoutData instead of the 607 // Swap the NodeLayoutData to point to a new NodeLayoutData instead of the
608 // static SharedEmptyData instance. 608 // static SharedEmptyData instance.
609 node_layout_data = new NodeLayoutData(layout_object); 609 DCHECK(!node_layout_data->GetNonAttachedStyle());
610 node_layout_data = new NodeLayoutData(layout_object, nullptr);
610 if (HasRareData()) 611 if (HasRareData())
611 data_.rare_data_->SetNodeLayoutData(node_layout_data); 612 data_.rare_data_->SetNodeLayoutData(node_layout_data);
612 else 613 else
614 data_.node_layout_data_ = node_layout_data;
615 }
616
617 void Node::SetNonAttachedStyle(RefPtr<ComputedStyle> non_attached_style) {
618 NodeLayoutData* node_layout_data = HasRareData()
619 ? data_.rare_data_->GetNodeLayoutData()
620 : data_.node_layout_data_;
621
622 // Already pointing to a non empty NodeLayoutData so just set the pointer to
623 // the new LayoutObject.
624 if (!node_layout_data->IsSharedEmptyData()) {
625 node_layout_data->SetNonAttachedStyle(non_attached_style);
626 return;
627 }
628
629 if (!non_attached_style)
630 return;
631
632 // Swap the NodeLayoutData to point to a new NodeLayoutData instead of the
633 // static SharedEmptyData instance.
634 DCHECK(!node_layout_data->GetLayoutObject());
635 node_layout_data = new NodeLayoutData(nullptr, non_attached_style);
636 if (HasRareData())
637 data_.rare_data_->SetNodeLayoutData(node_layout_data);
638 else
613 data_.node_layout_data_ = node_layout_data; 639 data_.node_layout_data_ = node_layout_data;
614 } 640 }
615 641
616 LayoutBoxModelObject* Node::GetLayoutBoxModelObject() const { 642 LayoutBoxModelObject* Node::GetLayoutBoxModelObject() const {
617 LayoutObject* layout_object = this->GetLayoutObject(); 643 LayoutObject* layout_object = this->GetLayoutObject();
618 return layout_object && layout_object->IsBoxModelObject() 644 return layout_object && layout_object->IsBoxModelObject()
619 ? ToLayoutBoxModelObject(layout_object) 645 ? ToLayoutBoxModelObject(layout_object)
620 : nullptr; 646 : nullptr;
621 } 647 }
622 648
(...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 if (node) { 2593 if (node) {
2568 std::stringstream stream; 2594 std::stringstream stream;
2569 node->PrintNodePathTo(stream); 2595 node->PrintNodePathTo(stream);
2570 LOG(INFO) << stream.str(); 2596 LOG(INFO) << stream.str();
2571 } else { 2597 } else {
2572 LOG(INFO) << "Cannot showNodePath for <null>"; 2598 LOG(INFO) << "Cannot showNodePath for <null>";
2573 } 2599 }
2574 } 2600 }
2575 2601
2576 #endif 2602 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698