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

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: Clear NonAttachedStyle in (Attach/Detach)LayoutTree 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 if (!node_layout_data->IsSharedEmptyData()) {
623 if (non_attached_style) {
624 node_layout_data->SetNonAttachedStyle(non_attached_style);
625 } else {
626 if (node_layout_data->GetLayoutObject()) {
627 node_layout_data->SetNonAttachedStyle(nullptr);
628 } else {
629 if (HasRareData()) {
630 data_.rare_data_->SetNodeLayoutData(
631 &NodeLayoutData::SharedEmptyData());
632 } else {
633 data_.node_layout_data_ = &NodeLayoutData::SharedEmptyData();
rune 2017/04/26 08:47:28 Won't this leak the previously set node_layout_dat
nainar 2017/04/27 01:50:06 Yup, I see what you mean. I have reverted the CL b
634 }
635 }
636 }
637 return;
638 }
639
640 if (!non_attached_style)
641 return;
642
643 // Swap the NodeLayoutData to point to a new NodeLayoutData instead of the
644 // static SharedEmptyData instance.
645 DCHECK(!node_layout_data->GetLayoutObject());
646 node_layout_data = new NodeLayoutData(nullptr, non_attached_style);
647 if (HasRareData())
648 data_.rare_data_->SetNodeLayoutData(node_layout_data);
649 else
613 data_.node_layout_data_ = node_layout_data; 650 data_.node_layout_data_ = node_layout_data;
614 } 651 }
615 652
616 LayoutBoxModelObject* Node::GetLayoutBoxModelObject() const { 653 LayoutBoxModelObject* Node::GetLayoutBoxModelObject() const {
617 LayoutObject* layout_object = this->GetLayoutObject(); 654 LayoutObject* layout_object = this->GetLayoutObject();
618 return layout_object && layout_object->IsBoxModelObject() 655 return layout_object && layout_object->IsBoxModelObject()
619 ? ToLayoutBoxModelObject(layout_object) 656 ? ToLayoutBoxModelObject(layout_object)
620 : nullptr; 657 : nullptr;
621 } 658 }
622 659
(...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after
2567 if (node) { 2604 if (node) {
2568 std::stringstream stream; 2605 std::stringstream stream;
2569 node->PrintNodePathTo(stream); 2606 node->PrintNodePathTo(stream);
2570 LOG(INFO) << stream.str(); 2607 LOG(INFO) << stream.str();
2571 } else { 2608 } else {
2572 LOG(INFO) << "Cannot showNodePath for <null>"; 2609 LOG(INFO) << "Cannot showNodePath for <null>";
2573 } 2610 }
2574 } 2611 }
2575 2612
2576 #endif 2613 #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