OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> |
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, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 */ | 19 */ |
20 | 20 |
21 #include "core/svg/SVGScriptElement.h" | 21 #include "core/svg/SVGScriptElement.h" |
22 | 22 |
23 #include "bindings/core/v8/ScriptEventListener.h" | 23 #include "bindings/core/v8/ScriptEventListener.h" |
24 #include "core/HTMLNames.h" | 24 #include "core/HTMLNames.h" |
25 #include "core/XLinkNames.h" | 25 #include "core/XLinkNames.h" |
26 #include "core/dom/Attribute.h" | 26 #include "core/dom/Attribute.h" |
27 #include "core/dom/ScriptLoader.h" | 27 #include "core/dom/ScriptLoader.h" |
28 #include "core/dom/ScriptRunner.h" | 28 #include "core/dom/ScriptRunner.h" |
29 #include "core/events/Event.h" | 29 #include "core/events/Event.h" |
| 30 #include "core/frame/csp/ContentSecurityPolicy.h" |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 | 33 |
33 inline SVGScriptElement::SVGScriptElement(Document& document, | 34 inline SVGScriptElement::SVGScriptElement(Document& document, |
34 bool wasInsertedByParser, | 35 bool wasInsertedByParser, |
35 bool alreadyStarted) | 36 bool alreadyStarted) |
36 : SVGElement(SVGNames::scriptTag, document), | 37 : SVGElement(SVGNames::scriptTag, document), |
37 SVGURIReference(this), | 38 SVGURIReference(this), |
38 m_loader( | 39 m_loader( |
39 ScriptLoader::create(this, wasInsertedByParser, alreadyStarted)) { | 40 ScriptLoader::create(this, wasInsertedByParser, alreadyStarted)) {} |
40 if (fastHasAttribute(HTMLNames::nonceAttr)) { | |
41 m_nonce = fastGetAttribute(HTMLNames::nonceAttr); | |
42 if (RuntimeEnabledFeatures::hideNonceContentAttributeEnabled()) | |
43 removeAttribute(HTMLNames::nonceAttr); | |
44 } | |
45 } | |
46 | 41 |
47 SVGScriptElement* SVGScriptElement::create(Document& document, | 42 SVGScriptElement* SVGScriptElement::create(Document& document, |
48 bool insertedByParser) { | 43 bool insertedByParser) { |
49 return new SVGScriptElement(document, insertedByParser, false); | 44 return new SVGScriptElement(document, insertedByParser, false); |
50 } | 45 } |
51 | 46 |
52 void SVGScriptElement::parseAttribute( | 47 void SVGScriptElement::parseAttribute( |
53 const AttributeModificationParams& params) { | 48 const AttributeModificationParams& params) { |
54 if (params.name == HTMLNames::onerrorAttr) { | 49 if (params.name == HTMLNames::onerrorAttr) { |
55 setAttributeEventListener( | 50 setAttributeEventListener( |
56 EventTypeNames::error, | 51 EventTypeNames::error, |
57 createAttributeEventListener(this, params.name, params.newValue, | 52 createAttributeEventListener(this, params.name, params.newValue, |
58 eventParameterName())); | 53 eventParameterName())); |
| 54 } else if (params.name == HTMLNames::nonceAttr) { |
| 55 if (params.newValue == ContentSecurityPolicy::getNonceReplacementString()) |
| 56 return; |
| 57 setNonce(params.newValue); |
| 58 if (RuntimeEnabledFeatures::hideNonceContentAttributeEnabled()) { |
| 59 setAttribute(HTMLNames::nonceAttr, |
| 60 ContentSecurityPolicy::getNonceReplacementString()); |
| 61 } |
59 } else { | 62 } else { |
60 SVGElement::parseAttribute(params); | 63 SVGElement::parseAttribute(params); |
61 } | 64 } |
62 } | 65 } |
63 | 66 |
64 void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) { | 67 void SVGScriptElement::svgAttributeChanged(const QualifiedName& attrName) { |
65 if (SVGURIReference::isKnownAttribute(attrName)) { | 68 if (SVGURIReference::isKnownAttribute(attrName)) { |
66 SVGElement::InvalidationGuard invalidationGuard(this); | 69 SVGElement::InvalidationGuard invalidationGuard(this); |
67 m_loader->handleSourceAttribute(hrefString()); | 70 m_loader->handleSourceAttribute(hrefString()); |
68 return; | 71 return; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 163 } |
161 #endif | 164 #endif |
162 | 165 |
163 DEFINE_TRACE(SVGScriptElement) { | 166 DEFINE_TRACE(SVGScriptElement) { |
164 visitor->trace(m_loader); | 167 visitor->trace(m_loader); |
165 SVGElement::trace(visitor); | 168 SVGElement::trace(visitor); |
166 SVGURIReference::trace(visitor); | 169 SVGURIReference::trace(visitor); |
167 } | 170 } |
168 | 171 |
169 } // namespace blink | 172 } // namespace blink |
OLD | NEW |