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

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

Issue 2093143002: Revert of Storage of ComputedStyle separate from LayoutObject. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details. 16 * Library General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Library General Public License 18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to 19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 * 22 *
23 */ 23 */
24 24
25 #ifndef NodeComputedStyle_h 25 #ifndef NodeComputedStyle_h
26 #define NodeComputedStyle_h 26 #define NodeComputedStyle_h
27 27
28 #include "core/dom/ElementRareData.h"
29 #include "core/dom/LayoutTreeBuilderTraversal.h" 28 #include "core/dom/LayoutTreeBuilderTraversal.h"
30 #include "core/dom/Node.h" 29 #include "core/dom/Node.h"
31 #include "core/dom/NodeRareData.h"
32 #include "core/dom/shadow/InsertionPoint.h" 30 #include "core/dom/shadow/InsertionPoint.h"
33 #include "core/html/HTMLOptGroupElement.h" 31 #include "core/html/HTMLOptGroupElement.h"
34 #include "core/layout/LayoutObject.h" 32 #include "core/layout/LayoutObject.h"
35 #include "core/style/ComputedStyle.h" 33 #include "core/style/ComputedStyle.h"
36 34
37 namespace blink { 35 namespace blink {
38 36
39 inline const ComputedStyle* Node::computedStyle() const 37 inline const ComputedStyle* Node::computedStyle() const
40 { 38 {
41 return mutableComputedStyle(); 39 return mutableComputedStyle();
42 } 40 }
43 41
44 inline ComputedStyle* Node::mutableComputedStyle() const 42 inline ComputedStyle* Node::mutableComputedStyle() const
45 { 43 {
46 if (hasLayoutObject()) 44 if (LayoutObject* layoutObject = this->layoutObject())
47 return layoutObject()->mutableStyle(); 45 return layoutObject->mutableStyle();
48 // <option> and <optgroup> can be styled even if they don't get layout objec ts, 46 // <option> and <optgroup> can be styled even if they don't get layout objec ts,
49 // so they store their style internally and return it through nonLayoutObjec tComputedStyle(). 47 // so they store their style internally and return it through nonLayoutObjec tComputedStyle().
50 // We check here explicitly to avoid the virtual call in the common case. 48 // We check here explicitly to avoid the virtual call in the common case.
51 if (isHTMLOptGroupElement(*this) || isHTMLOptionElement(this)) 49 if (isHTMLOptGroupElement(*this) || isHTMLOptionElement(this))
52 return nonLayoutObjectComputedStyle(); 50 return nonLayoutObjectComputedStyle();
53 if (hasRareData()) { 51 return 0;
54 NodeRareData* rareData = this->rareData();
55 DCHECK(rareData->isElementRareData());
56 return static_cast<ElementRareData*>(rareData)->ensureComputedStyle();
57 }
58 return m_data.m_computedStyle;
59 } 52 }
60 53
61 inline const ComputedStyle* Node::parentComputedStyle() const 54 inline const ComputedStyle* Node::parentComputedStyle() const
62 { 55 {
63 if (isSlotOrActiveInsertionPoint()) 56 if (isSlotOrActiveInsertionPoint())
64 return 0; 57 return 0;
65 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this); 58 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this);
66 return parent ? parent->computedStyle() : 0; 59 return parent ? parent->computedStyle() : 0;
67 } 60 }
68 61
69 inline const ComputedStyle& Node::computedStyleRef() const 62 inline const ComputedStyle& Node::computedStyleRef() const
70 { 63 {
71 const ComputedStyle* style = computedStyle(); 64 const ComputedStyle* style = computedStyle();
72 DCHECK(style); 65 DCHECK(style);
73 return *style; 66 return *style;
74 } 67 }
75 68
76 } // namespace blink 69 } // namespace blink
77 #endif // NodeComputedStyle_h 70 #endif // NodeComputedStyle_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.cpp ('k') | third_party/WebKit/Source/core/dom/NodeRareData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698