OLD | NEW |
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 { | 45 { |
46 if (hasLayoutObject()) | 46 if (hasLayoutObject()) |
47 return layoutObject()->mutableStyle(); | 47 return layoutObject()->mutableStyle(); |
48 // <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, |
49 // 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(). |
50 // 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. |
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 if (!rareData->isElementRareData()) |
| 56 return nullptr; |
56 return static_cast<ElementRareData*>(rareData)->computedStyle(); | 57 return static_cast<ElementRareData*>(rareData)->computedStyle(); |
57 } | 58 } |
58 return m_data.m_computedStyle; | 59 return m_data.m_computedStyle; |
59 } | 60 } |
60 | 61 |
61 inline const ComputedStyle* Node::parentComputedStyle() const | 62 inline const ComputedStyle* Node::parentComputedStyle() const |
62 { | 63 { |
63 if (isSlotOrActiveInsertionPoint()) | 64 if (isSlotOrActiveInsertionPoint()) |
64 return 0; | 65 return 0; |
65 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this); | 66 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this); |
66 return parent ? parent->computedStyle() : 0; | 67 return parent ? parent->computedStyle() : 0; |
67 } | 68 } |
68 | 69 |
69 inline const ComputedStyle& Node::computedStyleRef() const | 70 inline const ComputedStyle& Node::computedStyleRef() const |
70 { | 71 { |
71 const ComputedStyle* style = computedStyle(); | 72 const ComputedStyle* style = computedStyle(); |
72 DCHECK(style); | 73 DCHECK(style); |
73 return *style; | 74 return *style; |
74 } | 75 } |
75 | 76 |
76 } // namespace blink | 77 } // namespace blink |
77 #endif // NodeComputedStyle_h | 78 #endif // NodeComputedStyle_h |
OLD | NEW |