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