OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/svg/SVGParsingError.h" | 5 #include "core/svg/SVGParsingError.h" |
6 | 6 |
7 #include "core/dom/QualifiedName.h" | 7 #include "core/dom/QualifiedName.h" |
8 #include "platform/JSONValues.h" | 8 #include "platform/JSONValues.h" |
9 #include "wtf/text/CharacterNames.h" | 9 #include "wtf/text/CharacterNames.h" |
10 #include "wtf/text/StringBuilder.h" | 10 #include "wtf/text/StringBuilder.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 return std::make_pair("Expected path command, ", "."); | 48 return std::make_pair("Expected path command, ", "."); |
49 case SVGParseStatus::ExpectedStartOfArguments: | 49 case SVGParseStatus::ExpectedStartOfArguments: |
50 return std::make_pair("Expected '(', ", "."); | 50 return std::make_pair("Expected '(', ", "."); |
51 case SVGParseStatus::ExpectedTransformFunction: | 51 case SVGParseStatus::ExpectedTransformFunction: |
52 return std::make_pair("Expected transform function, ", "."); | 52 return std::make_pair("Expected transform function, ", "."); |
53 case SVGParseStatus::NegativeValue: | 53 case SVGParseStatus::NegativeValue: |
54 return std::make_pair("A negative value is not valid. (", ")"); | 54 return std::make_pair("A negative value is not valid. (", ")"); |
55 case SVGParseStatus::ZeroValue: | 55 case SVGParseStatus::ZeroValue: |
56 return std::make_pair("A value of zero is not valid. (", ")"); | 56 return std::make_pair("A value of zero is not valid. (", ")"); |
57 case SVGParseStatus::ParsingFailed: | 57 case SVGParseStatus::ParsingFailed: |
| 58 return std::make_pair("Invalid value, ", "."); |
58 default: | 59 default: |
59 ASSERT_NOT_REACHED(); | 60 ASSERT_NOT_REACHED(); |
60 break; | 61 break; |
61 } | 62 } |
62 return std::make_pair("", ""); | 63 return std::make_pair("", ""); |
63 } | 64 } |
64 | 65 |
65 bool disableLocus(SVGParseStatus status) | 66 bool disableLocus(SVGParseStatus status) |
66 { | 67 { |
67 // Disable locus for semantic errors and generic errors (see TODO below). | 68 // Disable locus for semantic errors and generic errors (see TODO below). |
(...skipping 27 matching lines...) Expand all Loading... |
95 } | 96 } |
96 builder.append('"'); | 97 builder.append('"'); |
97 } | 98 } |
98 | 99 |
99 } // namespace | 100 } // namespace |
100 | 101 |
101 String SVGParsingError::format(const String& tagName, const QualifiedName& name,
const AtomicString& value) const | 102 String SVGParsingError::format(const String& tagName, const QualifiedName& name,
const AtomicString& value) const |
102 { | 103 { |
103 StringBuilder builder; | 104 StringBuilder builder; |
104 | 105 |
105 // TODO(fs): Remove this case once enough specific errors have been added. | 106 appendErrorContextInfo(builder, tagName, name); |
106 if (status() == SVGParseStatus::ParsingFailed) { | 107 builder.appendLiteral(": "); |
107 builder.appendLiteral("Invalid value for "); | |
108 appendErrorContextInfo(builder, tagName, name); | |
109 builder.append('='); | |
110 appendValue(builder, *this, value); | |
111 } else { | |
112 appendErrorContextInfo(builder, tagName, name); | |
113 builder.appendLiteral(": "); | |
114 | 108 |
115 if (hasLocus() && locus() == value.length()) | 109 if (hasLocus() && locus() == value.length()) |
116 builder.appendLiteral("Unexpected end of attribute. "); | 110 builder.appendLiteral("Unexpected end of attribute. "); |
117 | 111 |
118 auto message = messageForStatus(status()); | 112 auto message = messageForStatus(status()); |
119 builder.append(message.first); | 113 builder.append(message.first); |
120 appendValue(builder, *this, value); | 114 appendValue(builder, *this, value); |
121 builder.append(message.second); | 115 builder.append(message.second); |
122 } | |
123 return builder.toString(); | 116 return builder.toString(); |
124 } | 117 } |
125 | 118 |
126 } // namespace blink | 119 } // namespace blink |
OLD | NEW |