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

Side by Side Diff: third_party/WebKit/Source/core/dom/NodeComputedStyle.h

Issue 2001453002: Set ComputedStyle on Node and use that in buildOwnLayout() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@storage
Patch Set: Send over for review Created 4 years, 3 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 * (C) 2008 David Smith (catfish.man@gmail.com) 5 * (C) 2008 David Smith (catfish.man@gmail.com)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return nonLayoutObjectComputedStyle(); 52 return nonLayoutObjectComputedStyle();
53 if (hasRareData()) { 53 if (hasRareData()) {
54 NodeRareData* rareData = this->rareData(); 54 NodeRareData* rareData = this->rareData();
55 if (!rareData->isElementRareData()) 55 if (!rareData->isElementRareData())
56 return nullptr; 56 return nullptr;
57 return static_cast<ElementRareData*>(rareData)->computedStyle(); 57 return static_cast<ElementRareData*>(rareData)->computedStyle();
58 } 58 }
59 return m_data.m_computedStyle; 59 return m_data.m_computedStyle;
60 } 60 }
61 61
62 inline void Node::setComputedStyle(PassRefPtr<ComputedStyle> computedStyle)
63 {
64 if (mutableComputedStyle() == computedStyle.get())
65 return;
66
67 if (hasRareData()) {
68 // If the DataUnion is an ElementRareData - set the ComputedStyle on tha t ElementRareData.
69 NodeRareData* rareData = this->rareData();
70 if (rareData->isElementRareData())
71 static_cast<ElementRareData*>(rareData)->setComputedStyle(computedSt yle);
72 } else if (hasLayoutObject()) {
73 // If the DataUnion is a LayoutObject - set the ComputedStyle on that La youtObject.
74 m_data.m_layoutObject->setStyleFromNodeOrElement(computedStyle);
75 } else {
76 // If the DataUnion is a ComputedStyle - make it point to the new Comput edStyle passed in.
77 if (m_data.m_computedStyle)
78 m_data.m_computedStyle->deref();
79 m_data.m_computedStyle = computedStyle.leakRef();
80 }
81 }
82
62 inline const ComputedStyle* Node::parentComputedStyle() const 83 inline const ComputedStyle* Node::parentComputedStyle() const
63 { 84 {
64 if (isSlotOrActiveInsertionPoint()) 85 if (isSlotOrActiveInsertionPoint())
65 return 0; 86 return 0;
66 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this); 87 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this);
67 return parent ? parent->computedStyle() : 0; 88 return parent ? parent->computedStyle() : 0;
68 } 89 }
69 90
70 inline const ComputedStyle& Node::computedStyleRef() const 91 inline const ComputedStyle& Node::computedStyleRef() const
71 { 92 {
72 const ComputedStyle* style = computedStyle(); 93 const ComputedStyle* style = computedStyle();
73 DCHECK(style); 94 DCHECK(style);
74 return *style; 95 return *style;
75 } 96 }
76 97
77 } // namespace blink 98 } // namespace blink
78 #endif // NodeComputedStyle_h 99 #endif // NodeComputedStyle_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698