| 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, 2007, 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 PassRefPtr<CSSStyleSheet> CSSStyleSheet::create(PassRefPtr<StyleSheetContents> s
heet, Node* ownerNode) | 46 PassRefPtr<CSSStyleSheet> CSSStyleSheet::create(PassRefPtr<StyleSheetContents> s
heet, Node* ownerNode) |
| 47 { | 47 { |
| 48 ASSERT(sheet); | 48 ASSERT(sheet); |
| 49 return adoptRef(new CSSStyleSheet(sheet, ownerNode)); | 49 return adoptRef(new CSSStyleSheet(sheet, ownerNode)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 PassRefPtr<CSSStyleSheet> CSSStyleSheet::create(Node* ownerNode, const KURL& bas
eURL) | 52 PassRefPtr<CSSStyleSheet> CSSStyleSheet::create(Node* ownerNode, const KURL& bas
eURL) |
| 53 { | 53 { |
| 54 CSSParserContext parserContext(ownerNode->document(), 0, baseURL); | 54 CSSParserContext parserContext(ownerNode->document(), 0, baseURL); |
| 55 RefPtr<StyleSheetContents> sheet = StyleSheetContents::create(parserContext)
; | 55 RefPtr<StyleSheetContents> sheet = StyleSheetContents::create(&ownerNode->do
cument(), parserContext); |
| 56 return adoptRef(new CSSStyleSheet(sheet.release(), ownerNode)); | 56 return adoptRef(new CSSStyleSheet(sheet.release(), ownerNode)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 CSSStyleSheet::CSSStyleSheet(PassRefPtr<StyleSheetContents> contents, Node* owne
rNode) | 59 CSSStyleSheet::CSSStyleSheet(PassRefPtr<StyleSheetContents> contents, Node* owne
rNode) |
| 60 : m_contents(contents) | 60 : m_contents(contents) |
| 61 , m_ownerNode(ownerNode) | 61 , m_ownerNode(ownerNode) |
| 62 { | 62 { |
| 63 ASSERT(isAcceptableCSSStyleSheetParent(ownerNode)); | 63 ASSERT(isAcceptableCSSStyleSheetParent(ownerNode)); |
| 64 m_contents->registerClient(this); | |
| 65 } | 64 } |
| 66 | 65 |
| 67 CSSStyleSheet::~CSSStyleSheet() | 66 CSSStyleSheet::~CSSStyleSheet() |
| 68 { | 67 { |
| 69 m_contents->unregisterClient(this); | |
| 70 } | 68 } |
| 71 | 69 |
| 72 void CSSStyleSheet::setMediaQueries(PassRefPtr<MediaQuerySet> mediaQueries) | 70 void CSSStyleSheet::setMediaQueries(PassRefPtr<MediaQuerySet> mediaQueries) |
| 73 { | 71 { |
| 74 m_mediaQueries = mediaQueries; | 72 m_mediaQueries = mediaQueries; |
| 75 | 73 |
| 76 // Add warning message to inspector whenever dpi/dpcm values are used for "s
creen" media. | 74 // Add warning message to inspector whenever dpi/dpcm values are used for "s
creen" media. |
| 77 reportMediaQueryWarningIfNeeded(ownerDocument(), m_mediaQueries.get()); | 75 reportMediaQueryWarningIfNeeded(ownerDocument(), m_mediaQueries.get()); |
| 78 } | 76 } |
| 79 | 77 |
| 80 void CSSStyleSheet::clearOwnerNode() | 78 void CSSStyleSheet::clearOwnerNode() |
| 81 { | 79 { |
| 82 if (Document* owner = ownerDocument()) | 80 if (Document* owner = ownerDocument()) |
| 83 owner->modifiedStyleSheet(this); | 81 owner->modifiedStyleSheet(this); |
| 84 if (m_ownerNode) | |
| 85 m_contents->unregisterClient(this); | |
| 86 m_ownerNode = nullptr; | 82 m_ownerNode = nullptr; |
| 87 } | 83 } |
| 88 | 84 |
| 89 Document* CSSStyleSheet::ownerDocument() const | 85 Document* CSSStyleSheet::ownerDocument() const |
| 90 { | 86 { |
| 91 return ownerNode() ? &ownerNode()->document() : 0; | 87 return ownerNode() ? &ownerNode()->document() : 0; |
| 92 } | 88 } |
| 93 | 89 |
| 94 } // namespace blink | 90 } // namespace blink |
| OLD | NEW |