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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 unsigned length() const override { return m_styleSheet->length(); } | 63 unsigned length() const override { return m_styleSheet->length(); } |
64 CSSRule* item(unsigned index) const override { return m_styleSheet->item(ind
ex); } | 64 CSSRule* item(unsigned index) const override { return m_styleSheet->item(ind
ex); } |
65 | 65 |
66 CSSStyleSheet* styleSheet() const override { return m_styleSheet; } | 66 CSSStyleSheet* styleSheet() const override { return m_styleSheet; } |
67 | 67 |
68 Member<CSSStyleSheet> m_styleSheet; | 68 Member<CSSStyleSheet> m_styleSheet; |
69 }; | 69 }; |
70 | 70 |
71 #if DCHECK_IS_ON() | 71 #if DCHECK_IS_ON() |
72 static bool isAcceptableCSSStyleSheetParent(Node* parentNode) | 72 static bool isAcceptableCSSStyleSheetParent(const Node& parentNode) |
73 { | 73 { |
74 // Only these nodes can be parents of StyleSheets, and they need to call | 74 // Only these nodes can be parents of StyleSheets, and they need to call |
75 // clearOwnerNode() when moved out of document. Note that destructor of | 75 // clearOwnerNode() when moved out of document. Note that destructor of |
76 // the nodes don't call clearOwnerNode() with Oilpan. | 76 // the nodes don't call clearOwnerNode() with Oilpan. |
77 return !parentNode | 77 return parentNode.isDocumentNode() |
78 || parentNode->isDocumentNode() | 78 || isHTMLLinkElement(parentNode) |
79 || isHTMLLinkElement(*parentNode) | 79 || isHTMLStyleElement(parentNode) |
80 || isHTMLStyleElement(*parentNode) | 80 || isSVGStyleElement(parentNode) |
81 || isSVGStyleElement(*parentNode) | 81 || parentNode.getNodeType() == Node::kProcessingInstructionNode; |
82 || parentNode->getNodeType() == Node::kProcessingInstructionNode; | |
83 } | 82 } |
84 #endif | 83 #endif |
85 | 84 |
86 CSSStyleSheet* CSSStyleSheet::create(StyleSheetContents* sheet, CSSImportRule* o
wnerRule) | 85 CSSStyleSheet* CSSStyleSheet::create(StyleSheetContents* sheet, CSSImportRule* o
wnerRule) |
87 { | 86 { |
88 return new CSSStyleSheet(sheet, ownerRule); | 87 return new CSSStyleSheet(sheet, ownerRule); |
89 } | 88 } |
90 | 89 |
91 CSSStyleSheet* CSSStyleSheet::create(StyleSheetContents* sheet, Node* ownerNode) | 90 CSSStyleSheet* CSSStyleSheet::create(StyleSheetContents* sheet, Node& ownerNode) |
92 { | 91 { |
93 return new CSSStyleSheet(sheet, ownerNode, false, TextPosition::minimumPosit
ion()); | 92 return new CSSStyleSheet(sheet, ownerNode, false, TextPosition::minimumPosit
ion()); |
94 } | 93 } |
95 | 94 |
96 CSSStyleSheet* CSSStyleSheet::createInline(StyleSheetContents* sheet, Node* owne
rNode, const TextPosition& startPosition) | 95 CSSStyleSheet* CSSStyleSheet::createInline(StyleSheetContents* sheet, Node& owne
rNode, const TextPosition& startPosition) |
97 { | 96 { |
98 DCHECK(sheet); | 97 DCHECK(sheet); |
99 return new CSSStyleSheet(sheet, ownerNode, true, startPosition); | 98 return new CSSStyleSheet(sheet, ownerNode, true, startPosition); |
100 } | 99 } |
101 | 100 |
102 CSSStyleSheet* CSSStyleSheet::createInline(Node* ownerNode, const KURL& baseURL,
const TextPosition& startPosition, const String& encoding) | 101 CSSStyleSheet* CSSStyleSheet::createInline(Node& ownerNode, const KURL& baseURL,
const TextPosition& startPosition, const String& encoding) |
103 { | 102 { |
104 CSSParserContext parserContext(ownerNode->document(), nullptr, baseURL, enco
ding); | 103 CSSParserContext parserContext(ownerNode.document(), nullptr, baseURL, encod
ing); |
105 StyleSheetContents* sheet = StyleSheetContents::create(baseURL.getString(),
parserContext); | 104 StyleSheetContents* sheet = StyleSheetContents::create(baseURL.getString(),
parserContext); |
106 return new CSSStyleSheet(sheet, ownerNode, true, startPosition); | 105 return new CSSStyleSheet(sheet, ownerNode, true, startPosition); |
107 } | 106 } |
108 | 107 |
109 CSSStyleSheet::CSSStyleSheet(StyleSheetContents* contents, CSSImportRule* ownerR
ule) | 108 CSSStyleSheet::CSSStyleSheet(StyleSheetContents* contents, CSSImportRule* ownerR
ule) |
110 : m_contents(contents) | 109 : m_contents(contents) |
111 , m_isInlineStylesheet(false) | 110 , m_isInlineStylesheet(false) |
112 , m_isDisabled(false) | 111 , m_isDisabled(false) |
113 , m_ownerNode(nullptr) | 112 , m_ownerNode(nullptr) |
114 , m_ownerRule(ownerRule) | 113 , m_ownerRule(ownerRule) |
115 , m_startPosition(TextPosition::minimumPosition()) | 114 , m_startPosition(TextPosition::minimumPosition()) |
116 , m_loadCompleted(false) | 115 , m_loadCompleted(false) |
117 { | 116 { |
118 m_contents->registerClient(this); | 117 m_contents->registerClient(this); |
119 } | 118 } |
120 | 119 |
121 CSSStyleSheet::CSSStyleSheet(StyleSheetContents* contents, Node* ownerNode, bool
isInlineStylesheet, const TextPosition& startPosition) | 120 CSSStyleSheet::CSSStyleSheet(StyleSheetContents* contents, Node& ownerNode, bool
isInlineStylesheet, const TextPosition& startPosition) |
122 : m_contents(contents) | 121 : m_contents(contents) |
123 , m_isInlineStylesheet(isInlineStylesheet) | 122 , m_isInlineStylesheet(isInlineStylesheet) |
124 , m_isDisabled(false) | 123 , m_isDisabled(false) |
125 , m_ownerNode(ownerNode) | 124 , m_ownerNode(&ownerNode) |
126 , m_ownerRule(nullptr) | 125 , m_ownerRule(nullptr) |
127 , m_startPosition(startPosition) | 126 , m_startPosition(startPosition) |
128 , m_loadCompleted(false) | 127 , m_loadCompleted(false) |
129 { | 128 { |
130 #if DCHECK_IS_ON() | 129 #if DCHECK_IS_ON() |
131 DCHECK(isAcceptableCSSStyleSheetParent(ownerNode)); | 130 DCHECK(isAcceptableCSSStyleSheetParent(ownerNode)); |
132 #endif | 131 #endif |
133 m_contents->registerClient(this); | 132 m_contents->registerClient(this); |
134 } | 133 } |
135 | 134 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 visitor->trace(m_mediaQueries); | 429 visitor->trace(m_mediaQueries); |
431 visitor->trace(m_ownerNode); | 430 visitor->trace(m_ownerNode); |
432 visitor->trace(m_ownerRule); | 431 visitor->trace(m_ownerRule); |
433 visitor->trace(m_mediaCSSOMWrapper); | 432 visitor->trace(m_mediaCSSOMWrapper); |
434 visitor->trace(m_childRuleCSSOMWrappers); | 433 visitor->trace(m_childRuleCSSOMWrappers); |
435 visitor->trace(m_ruleListCSSOMWrapper); | 434 visitor->trace(m_ruleListCSSOMWrapper); |
436 StyleSheet::trace(visitor); | 435 StyleSheet::trace(visitor); |
437 } | 436 } |
438 | 437 |
439 } // namespace blink | 438 } // namespace blink |
OLD | NEW |