Chromium Code Reviews

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGElement.cpp

Issue 1588993005: Extended error reporting for SVG attribute parsing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TestExpectations Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org>
3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2008 Apple Inc. All rights reserved.
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 35 matching lines...)
46 #include "core/layout/svg/LayoutSVGResourceContainer.h" 46 #include "core/layout/svg/LayoutSVGResourceContainer.h"
47 #include "core/svg/SVGAnimateElement.h" 47 #include "core/svg/SVGAnimateElement.h"
48 #include "core/svg/SVGCursorElement.h" 48 #include "core/svg/SVGCursorElement.h"
49 #include "core/svg/SVGDocumentExtensions.h" 49 #include "core/svg/SVGDocumentExtensions.h"
50 #include "core/svg/SVGElementRareData.h" 50 #include "core/svg/SVGElementRareData.h"
51 #include "core/svg/SVGGraphicsElement.h" 51 #include "core/svg/SVGGraphicsElement.h"
52 #include "core/svg/SVGSVGElement.h" 52 #include "core/svg/SVGSVGElement.h"
53 #include "core/svg/SVGTitleElement.h" 53 #include "core/svg/SVGTitleElement.h"
54 #include "core/svg/SVGUseElement.h" 54 #include "core/svg/SVGUseElement.h"
55 #include "core/svg/properties/SVGProperty.h" 55 #include "core/svg/properties/SVGProperty.h"
56 #include "platform/JSONValues.h"
57 #include "wtf/TemporaryChange.h" 56 #include "wtf/TemporaryChange.h"
58 #include "wtf/Threading.h" 57 #include "wtf/Threading.h"
59 58
60 namespace blink { 59 namespace blink {
61 60
62 using namespace HTMLNames; 61 using namespace HTMLNames;
63 using namespace SVGNames; 62 using namespace SVGNames;
64 63
65 SVGElement::SVGElement(const QualifiedName& tagName, Document& document, Constru ctionType constructionType) 64 SVGElement::SVGElement(const QualifiedName& tagName, Document& document, Constru ctionType constructionType)
66 : Element(tagName, &document, constructionType) 65 : Element(tagName, &document, constructionType)
(...skipping 115 matching lines...)
182 // we're always an inner <svg> element. 181 // we're always an inner <svg> element.
183 if (inUseShadowTree() && parentOrShadowHostElement() && parentOrShadowHostEl ement()->isSVGElement()) 182 if (inUseShadowTree() && parentOrShadowHostElement() && parentOrShadowHostEl ement()->isSVGElement())
184 return false; 183 return false;
185 184
186 // This is true whenever this is the outermost SVG, even if there are HTML e lements outside it 185 // This is true whenever this is the outermost SVG, even if there are HTML e lements outside it
187 return !parentNode()->isSVGElement(); 186 return !parentNode()->isSVGElement();
188 } 187 }
189 188
190 void SVGElement::reportAttributeParsingError(SVGParsingError error, const Qualif iedName& name, const AtomicString& value) 189 void SVGElement::reportAttributeParsingError(SVGParsingError error, const Qualif iedName& name, const AtomicString& value)
191 { 190 {
192 if (error == NoError) 191 if (error == SVGStatus::NoError)
193 return; 192 return;
194 193 document().accessSVGExtensions().reportError(error.format(tagName(), name, v alue));
195 String errorString = "<" + tagName() + "> attribute " + name.toString() + "= " + JSONValue::quoteString(value);
196 SVGDocumentExtensions& extensions = document().accessSVGExtensions();
197
198 if (error == NegativeValueForbiddenError) {
199 extensions.reportError("Invalid negative value for " + errorString);
200 return;
201 }
202
203 if (error == ParsingAttributeFailedError) {
204 extensions.reportError("Invalid value for " + errorString);
205 return;
206 }
207
208 ASSERT_NOT_REACHED();
209 } 194 }
210 195
211 String SVGElement::title() const 196 String SVGElement::title() const
212 { 197 {
213 // According to spec, we should not return titles when hovering over root <s vg> elements (those 198 // According to spec, we should not return titles when hovering over root <s vg> elements (those
214 // <title> elements are the title of the document, not a tooltip) so we inst antly return. 199 // <title> elements are the title of the document, not a tooltip) so we inst antly return.
215 if (isOutermostSVGSVGElement()) 200 if (isOutermostSVGSVGElement())
216 return String(); 201 return String();
217 202
218 if (inUseShadowTree()) { 203 if (inUseShadowTree()) {
(...skipping 1022 matching lines...)
1241 Element::trace(visitor); 1226 Element::trace(visitor);
1242 } 1227 }
1243 1228
1244 const AtomicString& SVGElement::eventParameterName() 1229 const AtomicString& SVGElement::eventParameterName()
1245 { 1230 {
1246 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt", AtomicString::Con structFromLiteral)); 1231 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt", AtomicString::Con structFromLiteral));
1247 return evtString; 1232 return evtString;
1248 } 1233 }
1249 1234
1250 } // namespace blink 1235 } // namespace blink
OLDNEW

Powered by Google App Engine