| 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 17 matching lines...) Expand all Loading... |
| 28 #include "core/css/CSSCharsetRule.h" | 28 #include "core/css/CSSCharsetRule.h" |
| 29 #include "core/css/CSSImportRule.h" | 29 #include "core/css/CSSImportRule.h" |
| 30 #include "core/css/parser/BisonCSSParser.h" | 30 #include "core/css/parser/BisonCSSParser.h" |
| 31 #include "core/css/CSSRuleList.h" | 31 #include "core/css/CSSRuleList.h" |
| 32 #include "core/css/MediaList.h" | 32 #include "core/css/MediaList.h" |
| 33 #include "core/css/StyleRule.h" | 33 #include "core/css/StyleRule.h" |
| 34 #include "core/css/StyleSheetContents.h" | 34 #include "core/css/StyleSheetContents.h" |
| 35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 36 #include "core/dom/ExceptionCode.h" | 36 #include "core/dom/ExceptionCode.h" |
| 37 #include "core/dom/Node.h" | 37 #include "core/dom/Node.h" |
| 38 #include "core/frame/ContentSecurityPolicy.h" | |
| 39 #include "core/frame/UseCounter.h" | 38 #include "core/frame/UseCounter.h" |
| 40 #include "core/inspector/InspectorInstrumentation.h" | 39 #include "core/inspector/InspectorInstrumentation.h" |
| 41 #include "platform/weborigin/SecurityOrigin.h" | 40 #include "platform/weborigin/SecurityOrigin.h" |
| 42 #include "wtf/text/StringBuilder.h" | 41 #include "wtf/text/StringBuilder.h" |
| 43 | 42 |
| 44 namespace WebCore { | 43 namespace WebCore { |
| 45 | 44 |
| 46 class StyleSheetCSSRuleList FINAL : public CSSRuleList { | 45 class StyleSheetCSSRuleList FINAL : public CSSRuleList { |
| 47 public: | 46 public: |
| 48 StyleSheetCSSRuleList(CSSStyleSheet* sheet) : m_styleSheet(sheet) { } | 47 StyleSheetCSSRuleList(CSSStyleSheet* sheet) : m_styleSheet(sheet) { } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 continue; | 263 continue; |
| 265 nonCharsetRules->rules().append(rule); | 264 nonCharsetRules->rules().append(rule); |
| 266 } | 265 } |
| 267 return nonCharsetRules.release(); | 266 return nonCharsetRules.release(); |
| 268 } | 267 } |
| 269 | 268 |
| 270 unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
eptionState& exceptionState) | 269 unsigned CSSStyleSheet::insertRule(const String& ruleString, unsigned index, Exc
eptionState& exceptionState) |
| 271 { | 270 { |
| 272 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); | 271 ASSERT(m_childRuleCSSOMWrappers.isEmpty() || m_childRuleCSSOMWrappers.size()
== m_contents->ruleCount()); |
| 273 | 272 |
| 274 if (Document* document = ownerDocument()) { | |
| 275 if (!document->contentSecurityPolicy()->allowStyleEval()) { | |
| 276 exceptionState.throwSecurityError(document->contentSecurityPolicy()-
>styleEvalDisabledErrorMessage()); | |
| 277 return 0; | |
| 278 } | |
| 279 } | |
| 280 | |
| 281 if (index > length()) { | 273 if (index > length()) { |
| 282 exceptionState.throwDOMException(IndexSizeError, "The index provided ("
+ String::number(index) + ") is larger than the maximum index (" + String::numbe
r(length()) + ")."); | 274 exceptionState.throwDOMException(IndexSizeError, "The index provided ("
+ String::number(index) + ") is larger than the maximum index (" + String::numbe
r(length()) + ")."); |
| 283 return 0; | 275 return 0; |
| 284 } | 276 } |
| 285 CSSParserContext context(m_contents->parserContext(), UseCounter::getFrom(th
is)); | 277 CSSParserContext context(m_contents->parserContext(), UseCounter::getFrom(th
is)); |
| 286 BisonCSSParser p(context); | 278 BisonCSSParser p(context); |
| 287 RefPtr<StyleRuleBase> rule = p.parseRule(m_contents.get(), ruleString); | 279 RefPtr<StyleRuleBase> rule = p.parseRule(m_contents.get(), ruleString); |
| 288 | 280 |
| 289 if (!rule) { | 281 if (!rule) { |
| 290 exceptionState.throwDOMException(SyntaxError, "Failed to parse the rule
'" + ruleString + "'."); | 282 exceptionState.throwDOMException(SyntaxError, "Failed to parse the rule
'" + ruleString + "'."); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 return m_loadCompleted; | 399 return m_loadCompleted; |
| 408 } | 400 } |
| 409 | 401 |
| 410 void CSSStyleSheet::startLoadingDynamicSheet() | 402 void CSSStyleSheet::startLoadingDynamicSheet() |
| 411 { | 403 { |
| 412 m_loadCompleted = false; | 404 m_loadCompleted = false; |
| 413 m_ownerNode->startLoadingDynamicSheet(); | 405 m_ownerNode->startLoadingDynamicSheet(); |
| 414 } | 406 } |
| 415 | 407 |
| 416 } | 408 } |
| OLD | NEW |