| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 inline const ComputedStyle* Node::computedStyle() const | 37 inline const ComputedStyle* Node::computedStyle() const |
| 38 { | 38 { |
| 39 return mutableComputedStyle(); | 39 return mutableComputedStyle(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 inline ComputedStyle* Node::mutableComputedStyle() const | 42 inline ComputedStyle* Node::mutableComputedStyle() const |
| 43 { | 43 { |
| 44 if (LayoutObject* layoutObject = this->layoutObject()) | 44 if (hasLayoutObject()) |
| 45 return layoutObject->mutableStyle(); | 45 return this->layoutObject()->mutableStyle(); |
| 46 // <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, |
| 47 // 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(). |
| 48 // 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. |
| 49 if (isHTMLOptGroupElement(*this) || isHTMLOptionElement(this)) | 49 if (isHTMLOptGroupElement(*this) || isHTMLOptionElement(this)) |
| 50 return nonLayoutObjectComputedStyle(); | 50 return nonLayoutObjectComputedStyle(); |
| 51 return 0; | 51 if (hasRareData()) |
| 52 return m_data.m_rareData->computedStyle(); |
| 53 return m_data.m_computedStyle; |
| 54 } |
| 55 |
| 56 inline void Node::setComputedStyle(ComputedStyle* computedStyle) |
| 57 { |
| 58 if (hasRareData()) |
| 59 m_data.m_rareData->setComputedStyle(computedStyle); |
| 60 else if (hasLayoutObject()) |
| 61 m_data.m_layoutObject->setStyleInternal(computedStyle); |
| 62 else |
| 63 m_data.m_computedStyle = computedStyle; |
| 52 } | 64 } |
| 53 | 65 |
| 54 inline const ComputedStyle* Node::parentComputedStyle() const | 66 inline const ComputedStyle* Node::parentComputedStyle() const |
| 55 { | 67 { |
| 56 if (isSlotOrActiveInsertionPoint()) | 68 if (isSlotOrActiveInsertionPoint()) |
| 57 return 0; | 69 return 0; |
| 58 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this); | 70 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this); |
| 59 return parent ? parent->computedStyle() : 0; | 71 return parent ? parent->computedStyle() : 0; |
| 60 } | 72 } |
| 61 | 73 |
| 62 inline const ComputedStyle& Node::computedStyleRef() const | 74 inline const ComputedStyle& Node::computedStyleRef() const |
| 63 { | 75 { |
| 64 const ComputedStyle* style = computedStyle(); | 76 const ComputedStyle* style = computedStyle(); |
| 65 DCHECK(style); | 77 DCHECK(style); |
| 66 return *style; | 78 return *style; |
| 67 } | 79 } |
| 68 | 80 |
| 69 } // namespace blink | 81 } // namespace blink |
| 70 #endif // NodeComputedStyle_h | 82 #endif // NodeComputedStyle_h |
| OLD | NEW |