OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. | 6 Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. |
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 | 52 |
53 CachedCSSStyleSheet::~CachedCSSStyleSheet() | 53 CachedCSSStyleSheet::~CachedCSSStyleSheet() |
54 { | 54 { |
55 if (m_parsedStyleSheetCache) | 55 if (m_parsedStyleSheetCache) |
56 m_parsedStyleSheetCache->removedFromMemoryCache(); | 56 m_parsedStyleSheetCache->removedFromMemoryCache(); |
57 } | 57 } |
58 | 58 |
59 void CachedCSSStyleSheet::didAddClient(CachedResourceClient* c) | 59 void CachedCSSStyleSheet::didAddClient(CachedResourceClient* c) |
60 { | 60 { |
61 ASSERT(c->resourceClientType() == CachedStyleSheetClient::expectedType()); | 61 ASSERT(c->resourceClientType() == CachedStyleSheetClient::expectedType()); |
| 62 // CachedResource::didAddClient() must be before setCSSStyleSheet(), |
| 63 // because setCSSStyleSheet() may cause scripts to be executed, which could
destroy 'c' if it is an instance of HTMLLinkElement. |
| 64 // see the comment of HTMLLinkElement::setCSSStyleSheet. |
| 65 CachedResource::didAddClient(c); |
| 66 |
62 if (!isLoading()) | 67 if (!isLoading()) |
63 static_cast<CachedStyleSheetClient*>(c)->setCSSStyleSheet(m_resourceRequ
est.url(), m_response.url(), m_decoder->encoding().name(), this); | 68 static_cast<CachedStyleSheetClient*>(c)->setCSSStyleSheet(m_resourceRequ
est.url(), m_response.url(), m_decoder->encoding().name(), this); |
64 | |
65 CachedResource::didAddClient(c); | |
66 } | 69 } |
67 | 70 |
68 void CachedCSSStyleSheet::setEncoding(const String& chs) | 71 void CachedCSSStyleSheet::setEncoding(const String& chs) |
69 { | 72 { |
70 m_decoder->setEncoding(chs, TextResourceDecoder::EncodingFromHTTPHeader); | 73 m_decoder->setEncoding(chs, TextResourceDecoder::EncodingFromHTTPHeader); |
71 } | 74 } |
72 | 75 |
73 String CachedCSSStyleSheet::encoding() const | 76 String CachedCSSStyleSheet::encoding() const |
74 { | 77 { |
75 return m_decoder->encoding().name(); | 78 return m_decoder->encoding().name(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 void CachedCSSStyleSheet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo)
const | 205 void CachedCSSStyleSheet::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo)
const |
203 { | 206 { |
204 MemoryClassInfo<CachedCSSStyleSheet> info(memoryObjectInfo, this, MemoryInst
rumentation::CachedResourceCSS); | 207 MemoryClassInfo<CachedCSSStyleSheet> info(memoryObjectInfo, this, MemoryInst
rumentation::CachedResourceCSS); |
205 CachedResource::reportMemoryUsage(memoryObjectInfo); | 208 CachedResource::reportMemoryUsage(memoryObjectInfo); |
206 info.addMember(m_decoder); | 209 info.addMember(m_decoder); |
207 info.addInstrumentedMember(m_parsedStyleSheetCache); | 210 info.addInstrumentedMember(m_parsedStyleSheetCache); |
208 info.addMember(m_decodedSheetText); | 211 info.addMember(m_decodedSheetText); |
209 } | 212 } |
210 | 213 |
211 } | 214 } |
OLD | NEW |