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/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: Initial review 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)
62 {
63 if (hasRareData()) {
sashab 2016/07/06 04:22:02 Is hasRareData() the check you want here? Maybe yo
nainar 2016/07/06 04:51:53 Yup. The ComputedStyle on Node can be stored in th
sashab 2016/07/06 05:10:40 Could you re-write this as a single if-statement w
64 if (hasLayoutObject()) {
Bugs Nash 2016/07/06 04:30:42 this isn't necessary
nainar 2016/07/06 04:51:53 Agreed in a screen-to-screen conversation that: Q
65 m_data.m_rareData->layoutObject()->setStyleInternal(computedStyle);
66 } else {
67 NodeRareData* rareData = this->rareData();
68 DCHECK(rareData->isElementRareData());
69 static_cast<ElementRareData*>(rareData)->setComputedStyle(computedSt yle);
70 }
71 } else {
72 if (hasLayoutObject()) {
73 m_data.m_layoutObject->setStyleInternal(computedStyle);
74 } else {
75 if (m_data.m_computedStyle)
76 m_data.m_computedStyle->deref();
77 m_data.m_computedStyle = computedStyle.leakRef();
78 }
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

Powered by Google App Engine
This is Rietveld 408576698