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

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

Issue 2119263002: [DO NOT LAND: Dummy CL] Storage of ComputedStyle separate from LayoutObject. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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"
28 #include "core/dom/LayoutTreeBuilderTraversal.h" 29 #include "core/dom/LayoutTreeBuilderTraversal.h"
29 #include "core/dom/Node.h" 30 #include "core/dom/Node.h"
31 #include "core/dom/NodeRareData.h"
30 #include "core/dom/shadow/InsertionPoint.h" 32 #include "core/dom/shadow/InsertionPoint.h"
31 #include "core/html/HTMLOptGroupElement.h" 33 #include "core/html/HTMLOptGroupElement.h"
32 #include "core/layout/LayoutObject.h" 34 #include "core/layout/LayoutObject.h"
33 #include "core/style/ComputedStyle.h" 35 #include "core/style/ComputedStyle.h"
34 36
35 namespace blink { 37 namespace blink {
36 38
37 inline const ComputedStyle* Node::computedStyle() const 39 inline const ComputedStyle* Node::computedStyle() const
38 { 40 {
39 return mutableComputedStyle(); 41 return mutableComputedStyle();
40 } 42 }
41 43
42 inline ComputedStyle* Node::mutableComputedStyle() const 44 inline ComputedStyle* Node::mutableComputedStyle() const
43 { 45 {
44 if (LayoutObject* layoutObject = this->layoutObject()) 46 if (hasLayoutObject())
45 return layoutObject->mutableStyle(); 47 return layoutObject()->mutableStyle();
46 // <option> and <optgroup> can be styled even if they don't get layout objec ts, 48 // <option> and <optgroup> can be styled even if they don't get layout objec ts,
47 // so they store their style internally and return it through nonLayoutObjec tComputedStyle(). 49 // so they store their style internally and return it through nonLayoutObjec tComputedStyle().
48 // We check here explicitly to avoid the virtual call in the common case. 50 // We check here explicitly to avoid the virtual call in the common case.
49 if (isHTMLOptGroupElement(*this) || isHTMLOptionElement(this)) 51 if (isHTMLOptGroupElement(*this) || isHTMLOptionElement(this))
50 return nonLayoutObjectComputedStyle(); 52 return nonLayoutObjectComputedStyle();
51 return 0; 53 if (hasRareData()) {
54 NodeRareData* rareData = this->rareData();
55 DCHECK(rareData->isElementRareData());
56 return static_cast<ElementRareData*>(rareData)->computedStyle();
57 }
58 return m_data.m_computedStyle;
52 } 59 }
53 60
54 inline const ComputedStyle* Node::parentComputedStyle() const 61 inline const ComputedStyle* Node::parentComputedStyle() const
55 { 62 {
56 if (isSlotOrActiveInsertionPoint()) 63 if (isSlotOrActiveInsertionPoint())
57 return 0; 64 return 0;
58 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this); 65 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this);
59 return parent ? parent->computedStyle() : 0; 66 return parent ? parent->computedStyle() : 0;
60 } 67 }
61 68
62 inline const ComputedStyle& Node::computedStyleRef() const 69 inline const ComputedStyle& Node::computedStyleRef() const
63 { 70 {
64 const ComputedStyle* style = computedStyle(); 71 const ComputedStyle* style = computedStyle();
65 DCHECK(style); 72 DCHECK(style);
66 return *style; 73 return *style;
67 } 74 }
68 75
69 } // namespace blink 76 } // namespace blink
70 #endif // NodeComputedStyle_h 77 #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