Chromium Code Reviews| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 return nonLayoutObjectComputedStyle(); | 52 return nonLayoutObjectComputedStyle(); |
| 53 if (hasRareData()) { | 53 if (hasRareData()) { |
| 54 NodeRareData* rareData = this->rareData(); | 54 NodeRareData* rareData = this->rareData(); |
| 55 if (!rareData->isElementRareData()) | 55 if (!rareData->isElementRareData()) |
| 56 return nullptr; | 56 return nullptr; |
| 57 return static_cast<ElementRareData*>(rareData)->computedStyle(); | 57 return static_cast<ElementRareData*>(rareData)->computedStyle(); |
| 58 } | 58 } |
| 59 return m_data.m_computedStyle; | 59 return m_data.m_computedStyle; |
| 60 } | 60 } |
| 61 | 61 |
| 62 inline void Node::setComputedStyle(PassRefPtr<ComputedStyle> computedStyle) | |
| 63 { | |
| 64 // printf("In Node::setComputedStyle nodeName %s hasRareData %d hasLayoutObj ect %d computedStyle %p\n", nodeName().ascii().data(), hasRareData(), hasLayoutO bject(), mutableComputedStyle()); | |
|
Bugs Nash
2016/08/23 02:37:52
forgot to delete this?
| |
| 65 if (hasRareData() && hasLayoutObject()) { | |
| 66 // If the DataUnion is a NodeRareDataBase and has a LayoutObject - set t he ComputedStyle on that LayoutObject. | |
| 67 if (computedStyle->hasImage()) | |
| 68 m_data.m_rareData->layoutObject()->setStyle(computedStyle); | |
| 69 else | |
| 70 m_data.m_rareData->layoutObject()->setStyleInternal(computedStyle); | |
| 71 } else if (hasRareData() && !hasLayoutObject()) { | |
| 72 // If the DataUnion is an NodeRareDataBase (specifically an ElementRareD ata) without a LayoutObject- set the ComputedStyle on that LayoutObject. | |
|
Bugs Nash
2016/08/23 02:37:52
should be 'a NodeRareDataBase' and 'set the Comput
| |
| 73 NodeRareData* rareData = this->rareData(); | |
| 74 if (rareData->isElementRareData()) | |
|
Bugs Nash
2016/08/23 02:37:52
This should be a DCHECK. Since setComputedStyle is
| |
| 75 static_cast<ElementRareData*>(rareData)->setComputedStyle(computedSt yle); | |
| 76 } else if (!hasRareData() && hasLayoutObject()) { | |
| 77 // If the DataUnion is a LayoutObject - set the ComputedStyle on that La youtObject. | |
| 78 if (computedStyle->hasImage()) | |
| 79 m_data.m_layoutObject->setStyle(computedStyle); | |
| 80 else | |
| 81 m_data.m_layoutObject->setStyleInternal(computedStyle); | |
| 82 } else { | |
| 83 // If the DataUnion is a ComputedStyle - make it point to the new Comput edStyle passed in. | |
|
Bugs Nash
2016/08/23 02:40:20
this case also covers the DataUnion being null
| |
| 84 if (m_data.m_computedStyle) | |
| 85 m_data.m_computedStyle->deref(); | |
| 86 m_data.m_computedStyle = computedStyle.leakRef(); | |
| 87 } | |
| 88 } | |
| 89 | |
| 62 inline const ComputedStyle* Node::parentComputedStyle() const | 90 inline const ComputedStyle* Node::parentComputedStyle() const |
| 63 { | 91 { |
| 64 if (isSlotOrActiveInsertionPoint()) | 92 if (isSlotOrActiveInsertionPoint()) |
| 65 return 0; | 93 return 0; |
| 66 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this); | 94 ContainerNode* parent = LayoutTreeBuilderTraversal::parent(*this); |
| 67 return parent ? parent->computedStyle() : 0; | 95 return parent ? parent->computedStyle() : 0; |
| 68 } | 96 } |
| 69 | 97 |
| 70 inline const ComputedStyle& Node::computedStyleRef() const | 98 inline const ComputedStyle& Node::computedStyleRef() const |
| 71 { | 99 { |
| 72 const ComputedStyle* style = computedStyle(); | 100 const ComputedStyle* style = computedStyle(); |
| 73 DCHECK(style); | 101 DCHECK(style); |
| 74 return *style; | 102 return *style; |
| 75 } | 103 } |
| 76 | 104 |
| 77 } // namespace blink | 105 } // namespace blink |
| 78 #endif // NodeComputedStyle_h | 106 #endif // NodeComputedStyle_h |
| OLD | NEW |