| OLD | NEW |
| 1 /** | 1 /** |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2006 Apple Computer, Inc. | 3 * Copyright (C) 2004, 2006 Apple Computer, Inc. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 , m_originalURL(originalURL) | 49 , m_originalURL(originalURL) |
| 50 , m_finalURL(finalURL) | 50 , m_finalURL(finalURL) |
| 51 , m_disabled(false) | 51 , m_disabled(false) |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 StyleSheet::~StyleSheet() | 55 StyleSheet::~StyleSheet() |
| 56 { | 56 { |
| 57 if (m_media) | 57 if (m_media) |
| 58 m_media->setParent(0); | 58 m_media->setParent(0); |
| 59 |
| 60 // For style rules outside the document, .parentStyleSheet can become null e
ven if the style rule |
| 61 // is still observable from JavaScript. This matches the behavior of .parent
Node for nodes, but |
| 62 // it's not ideal because it makes the CSSOM's behavior depend on the timing
of garbage collection. |
| 63 for (unsigned i = 0; i < length(); ++i) { |
| 64 ASSERT(item(i)->parent() == this); |
| 65 item(i)->setParent(0); |
| 66 } |
| 59 } | 67 } |
| 60 | 68 |
| 61 StyleSheet* StyleSheet::parentStyleSheet() const | 69 StyleSheet* StyleSheet::parentStyleSheet() const |
| 62 { | 70 { |
| 63 return (parent() && parent()->isStyleSheet()) ? static_cast<StyleSheet*>(par
ent()) : 0; | 71 return (parent() && parent()->isStyleSheet()) ? static_cast<StyleSheet*>(par
ent()) : 0; |
| 64 } | 72 } |
| 65 | 73 |
| 66 void StyleSheet::setMedia(PassRefPtr<MediaList> media) | 74 void StyleSheet::setMedia(PassRefPtr<MediaList> media) |
| 67 { | 75 { |
| 68 if (m_media) | 76 if (m_media) |
| 69 m_media->setParent(0); | 77 m_media->setParent(0); |
| 70 | 78 |
| 71 m_media = media; | 79 m_media = media; |
| 72 m_media->setParent(this); | 80 m_media->setParent(this); |
| 73 } | 81 } |
| 74 | 82 |
| 75 KURL StyleSheet::completeURL(const String& url) const | 83 KURL StyleSheet::completeURL(const String& url) const |
| 76 { | 84 { |
| 77 // Always return a null URL when passed a null string. | 85 // Always return a null URL when passed a null string. |
| 78 // FIXME: Should we change the KURL constructor to have this behavior? | 86 // FIXME: Should we change the KURL constructor to have this behavior? |
| 79 // See also Document::completeURL(const String&) | 87 // See also Document::completeURL(const String&) |
| 80 if (url.isNull()) | 88 if (url.isNull()) |
| 81 return KURL(); | 89 return KURL(); |
| 82 return KURL(baseURL(), url); | 90 return KURL(baseURL(), url); |
| 83 } | 91 } |
| 84 | 92 |
| 85 } | 93 } |
| OLD | NEW |