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

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: Created 4 years, 5 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 if (isHTMLOptGroupElement(*this) || isHTMLOptionElement(this)) 51 if (isHTMLOptGroupElement(*this) || isHTMLOptionElement(this))
52 return nonLayoutObjectComputedStyle(); 52 return nonLayoutObjectComputedStyle();
53 if (hasRareData()) { 53 if (hasRareData()) {
54 NodeRareData* rareData = this->rareData(); 54 NodeRareData* rareData = this->rareData();
55 DCHECK(rareData->isElementRareData()); 55 DCHECK(rareData->isElementRareData());
56 return static_cast<ElementRareData*>(rareData)->ensureComputedStyle(); 56 return static_cast<ElementRareData*>(rareData)->ensureComputedStyle();
57 } 57 }
58 return m_data.m_computedStyle; 58 return m_data.m_computedStyle;
59 } 59 }
60 60
61 inline void Node::setComputedStyle(PassRefPtr<ComputedStyle> computedStyle)
sashab 2016/07/07 01:20:35 This is SO much easier to read now, thx.
62 {
63 if (hasRareData() && hasLayoutObject()) {
64 // If the DataUnion is a NodeRareDataBase and has a LayoutObject - set t he ComputedStyle on that LayoutObject.
65 m_data.m_rareData->layoutObject()->setStyleInternal(computedStyle);
66 } else if (hasRareData() && !hasLayoutObject()) {
67 // If the DataUnion is an NodeRareDataBase (specifically an ElementRareD ata) without a LayoutObject- set the ComputedStyle on that LayoutObject.
68 NodeRareData* rareData = this->rareData();
69 DCHECK(rareData->isElementRareData());
70 static_cast<ElementRareData*>(rareData)->setComputedStyle(computedStyle) ;
71 } else if (!hasRareData() && hasLayoutObject()) {
72 // If the DataUnion is a LayoutObject - set the ComputedStyle on that La youtObject.
73 m_data.m_layoutObject->setStyleInternal(computedStyle);
74 } else {
75 // If the DataUnion is a ComputedStyle - make it point to the new Comput edStyle passed in.
76 if (m_data.m_computedStyle)
77 m_data.m_computedStyle->deref();
78 m_data.m_computedStyle = computedStyle.leakRef();
79 }
80 }
81
61 inline const ComputedStyle* Node::parentComputedStyle() const 82 inline const ComputedStyle* Node::parentComputedStyle() const
62 { 83 {
63 if (isSlotOrActiveInsertionPoint()) 84 if (isSlotOrActiveInsertionPoint())
64 return 0; 85 return 0;
65 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this); 86 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this);
66 return parent ? parent->computedStyle() : 0; 87 return parent ? parent->computedStyle() : 0;
67 } 88 }
68 89
69 inline const ComputedStyle& Node::computedStyleRef() const 90 inline const ComputedStyle& Node::computedStyleRef() const
70 { 91 {
71 const ComputedStyle* style = computedStyle(); 92 const ComputedStyle* style = computedStyle();
72 DCHECK(style); 93 DCHECK(style);
73 return *style; 94 return *style;
74 } 95 }
75 96
76 } // namespace blink 97 } // namespace blink
77 #endif // NodeComputedStyle_h 98 #endif // NodeComputedStyle_h
OLDNEW
« third_party/WebKit/Source/core/dom/Node.cpp ('K') | « third_party/WebKit/Source/core/dom/Node.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698