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 26 matching lines...) Expand all Loading... | |
37 #include "core/dom/Node.h" | 37 #include "core/dom/Node.h" |
38 #include "core/frame/UseCounter.h" | 38 #include "core/frame/UseCounter.h" |
39 #include "core/inspector/InspectorInstrumentation.h" | 39 #include "core/inspector/InspectorInstrumentation.h" |
40 #include "platform/weborigin/SecurityOrigin.h" | 40 #include "platform/weborigin/SecurityOrigin.h" |
41 #include "wtf/text/StringBuilder.h" | 41 #include "wtf/text/StringBuilder.h" |
42 | 42 |
43 namespace WebCore { | 43 namespace WebCore { |
44 | 44 |
45 class StyleSheetCSSRuleList FINAL : public CSSRuleList { | 45 class StyleSheetCSSRuleList FINAL : public CSSRuleList { |
46 public: | 46 public: |
47 static PassOwnPtrWillBeRawPtr<StyleSheetCSSRuleList> create(CSSStyleSheet* s heet) | |
48 { | |
49 return adoptPtrWillBeNoop(new StyleSheetCSSRuleList(sheet)); | |
50 } | |
51 | |
52 virtual void trace(Visitor* visitor) OVERRIDE | |
53 { | |
54 visitor->trace(m_styleSheet); | |
Mads Ager (chromium)
2014/03/10 12:32:57
If you do not make CSSRuleList::trace pure virtual
Erik Corry
2014/03/12 10:36:41
Done.
| |
55 } | |
56 | |
57 private: | |
47 StyleSheetCSSRuleList(CSSStyleSheet* sheet) : m_styleSheet(sheet) { } | 58 StyleSheetCSSRuleList(CSSStyleSheet* sheet) : m_styleSheet(sheet) { } |
48 | 59 |
49 private: | 60 #if !ENABLE(OILPAN) |
50 virtual void ref() OVERRIDE { m_styleSheet->ref(); } | 61 virtual void ref() OVERRIDE { m_styleSheet->ref(); } |
51 virtual void deref() OVERRIDE { m_styleSheet->deref(); } | 62 virtual void deref() OVERRIDE { m_styleSheet->deref(); } |
63 #endif | |
52 | 64 |
53 virtual unsigned length() const OVERRIDE { return m_styleSheet->length(); } | 65 virtual unsigned length() const OVERRIDE { return m_styleSheet->length(); } |
54 virtual CSSRule* item(unsigned index) const OVERRIDE { return m_styleSheet-> item(index); } | 66 virtual CSSRule* item(unsigned index) const OVERRIDE { return m_styleSheet-> item(index); } |
55 | 67 |
56 virtual CSSStyleSheet* styleSheet() const OVERRIDE { return m_styleSheet; } | 68 virtual CSSStyleSheet* styleSheet() const OVERRIDE { return m_styleSheet; } |
57 | 69 |
58 CSSStyleSheet* m_styleSheet; | 70 RawPtrWillBeMember<CSSStyleSheet> m_styleSheet; |
59 }; | 71 }; |
60 | 72 |
61 #if !ASSERT_DISABLED | 73 #if !ASSERT_DISABLED |
62 static bool isAcceptableCSSStyleSheetParent(Node* parentNode) | 74 static bool isAcceptableCSSStyleSheetParent(Node* parentNode) |
63 { | 75 { |
64 // Only these nodes can be parents of StyleSheets, and they need to call cle arOwnerNode() when moved out of document. | 76 // Only these nodes can be parents of StyleSheets, and they need to call cle arOwnerNode() when moved out of document. |
65 return !parentNode | 77 return !parentNode |
66 || parentNode->isDocumentNode() | 78 || parentNode->isDocumentNode() |
67 || parentNode->hasTagName(HTMLNames::linkTag) | 79 || parentNode->hasTagName(HTMLNames::linkTag) |
68 || parentNode->hasTagName(HTMLNames::styleTag) | 80 || parentNode->hasTagName(HTMLNames::styleTag) |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 if (baseURL.isEmpty()) | 261 if (baseURL.isEmpty()) |
250 return true; | 262 return true; |
251 Document* document = ownerDocument(); | 263 Document* document = ownerDocument(); |
252 if (!document) | 264 if (!document) |
253 return true; | 265 return true; |
254 if (document->securityOrigin()->canRequest(baseURL)) | 266 if (document->securityOrigin()->canRequest(baseURL)) |
255 return true; | 267 return true; |
256 return false; | 268 return false; |
257 } | 269 } |
258 | 270 |
259 PassRefPtr<CSSRuleList> CSSStyleSheet::rules() | 271 PassRefPtrWillBeRawPtr<CSSRuleList> CSSStyleSheet::rules() |
260 { | 272 { |
261 if (!canAccessRules()) | 273 if (!canAccessRules()) |
262 return nullptr; | 274 return nullptr; |
263 // IE behavior. | 275 // IE behavior. |
264 RefPtr<StaticCSSRuleList> nonCharsetRules = StaticCSSRuleList::create(); | 276 RefPtrWillBeRawPtr<StaticCSSRuleList> nonCharsetRules(StaticCSSRuleList::cre ate()); |
265 unsigned ruleCount = length(); | 277 unsigned ruleCount = length(); |
266 for (unsigned i = 0; i < ruleCount; ++i) { | 278 for (unsigned i = 0; i < ruleCount; ++i) { |
267 CSSRule* rule = item(i); | 279 CSSRule* rule = item(i); |
268 if (rule->type() == CSSRule::CHARSET_RULE) | 280 if (rule->type() == CSSRule::CHARSET_RULE) |
269 continue; | 281 continue; |
270 nonCharsetRules->rules().append(rule); | 282 nonCharsetRules->rules().append(rule); |
271 } | 283 } |
272 return nonCharsetRules.release(); | 284 return nonCharsetRules.release(); |
273 } | 285 } |
274 | 286 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 // As per Microsoft documentation, always return -1. | 352 // As per Microsoft documentation, always return -1. |
341 return -1; | 353 return -1; |
342 } | 354 } |
343 | 355 |
344 int CSSStyleSheet::addRule(const String& selector, const String& style, Exceptio nState& exceptionState) | 356 int CSSStyleSheet::addRule(const String& selector, const String& style, Exceptio nState& exceptionState) |
345 { | 357 { |
346 return addRule(selector, style, length(), exceptionState); | 358 return addRule(selector, style, length(), exceptionState); |
347 } | 359 } |
348 | 360 |
349 | 361 |
350 PassRefPtr<CSSRuleList> CSSStyleSheet::cssRules() | 362 PassRefPtrWillBeRawPtr<CSSRuleList> CSSStyleSheet::cssRules() |
351 { | 363 { |
352 if (!canAccessRules()) | 364 if (!canAccessRules()) |
353 return nullptr; | 365 return nullptr; |
354 if (!m_ruleListCSSOMWrapper) | 366 if (!m_ruleListCSSOMWrapper) |
355 m_ruleListCSSOMWrapper = adoptPtr(new StyleSheetCSSRuleList(this)); | 367 m_ruleListCSSOMWrapper = StyleSheetCSSRuleList::create(this); |
356 return m_ruleListCSSOMWrapper.get(); | 368 return m_ruleListCSSOMWrapper.get(); |
357 } | 369 } |
358 | 370 |
359 String CSSStyleSheet::href() const | 371 String CSSStyleSheet::href() const |
360 { | 372 { |
361 return m_contents->originalURL(); | 373 return m_contents->originalURL(); |
362 } | 374 } |
363 | 375 |
364 KURL CSSStyleSheet::baseURL() const | 376 KURL CSSStyleSheet::baseURL() const |
365 { | 377 { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 m_ownerNode->startLoadingDynamicSheet(); | 424 m_ownerNode->startLoadingDynamicSheet(); |
413 } | 425 } |
414 | 426 |
415 void CSSStyleSheet::trace(Visitor* visitor) | 427 void CSSStyleSheet::trace(Visitor* visitor) |
416 { | 428 { |
417 visitor->trace(m_contents); | 429 visitor->trace(m_contents); |
418 visitor->trace(m_mediaQueries); | 430 visitor->trace(m_mediaQueries); |
419 visitor->trace(m_ownerRule); | 431 visitor->trace(m_ownerRule); |
420 visitor->trace(m_mediaCSSOMWrapper); | 432 visitor->trace(m_mediaCSSOMWrapper); |
421 visitor->trace(m_childRuleCSSOMWrappers); | 433 visitor->trace(m_childRuleCSSOMWrappers); |
434 visitor->trace(m_ruleListCSSOMWrapper); | |
422 } | 435 } |
423 | 436 |
424 } | 437 } |
OLD | NEW |