| 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 26 matching lines...) Expand all Loading... |
| 37 case SVGParseStatus::ExpectedLength: | 37 case SVGParseStatus::ExpectedLength: |
| 38 return std::make_pair("Expected length, ", "."); | 38 return std::make_pair("Expected length, ", "."); |
| 39 case SVGParseStatus::ExpectedMoveToCommand: | 39 case SVGParseStatus::ExpectedMoveToCommand: |
| 40 return std::make_pair("Expected moveto path command ('M' or 'm'), ", "."
); | 40 return std::make_pair("Expected moveto path command ('M' or 'm'), ", "."
); |
| 41 case SVGParseStatus::ExpectedNumber: | 41 case SVGParseStatus::ExpectedNumber: |
| 42 return std::make_pair("Expected number, ", "."); | 42 return std::make_pair("Expected number, ", "."); |
| 43 case SVGParseStatus::ExpectedPathCommand: | 43 case SVGParseStatus::ExpectedPathCommand: |
| 44 return std::make_pair("Expected path command, ", "."); | 44 return std::make_pair("Expected path command, ", "."); |
| 45 case SVGParseStatus::NegativeValue: | 45 case SVGParseStatus::NegativeValue: |
| 46 return std::make_pair("A negative value is not valid. (", ")"); | 46 return std::make_pair("A negative value is not valid. (", ")"); |
| 47 case SVGParseStatus::ZeroValue: |
| 48 return std::make_pair("A value of zero is not valid. (", ")"); |
| 47 case SVGParseStatus::ParsingFailed: | 49 case SVGParseStatus::ParsingFailed: |
| 48 default: | 50 default: |
| 49 ASSERT_NOT_REACHED(); | 51 ASSERT_NOT_REACHED(); |
| 50 break; | 52 break; |
| 51 } | 53 } |
| 52 return std::make_pair("", ""); | 54 return std::make_pair("", ""); |
| 53 } | 55 } |
| 54 | 56 |
| 55 bool disableLocus(SVGParseStatus status) | 57 bool disableLocus(SVGParseStatus status) |
| 56 { | 58 { |
| 57 // Disable locus for semantic errors and generic errors (see TODO below). | 59 // Disable locus for semantic errors and generic errors (see TODO below). |
| 58 return status == SVGParseStatus::NegativeValue | 60 return status == SVGParseStatus::NegativeValue |
| 61 || status == SVGParseStatus::ZeroValue |
| 59 || status == SVGParseStatus::ParsingFailed; | 62 || status == SVGParseStatus::ParsingFailed; |
| 60 } | 63 } |
| 61 | 64 |
| 62 void appendValue(StringBuilder& builder, SVGParsingError error, const AtomicStri
ng& value) | 65 void appendValue(StringBuilder& builder, SVGParsingError error, const AtomicStri
ng& value) |
| 63 { | 66 { |
| 64 builder.append('"'); | 67 builder.append('"'); |
| 65 if (!error.hasLocus() || disableLocus(error.status())) { | 68 if (!error.hasLocus() || disableLocus(error.status())) { |
| 66 escapeStringForJSON(value.string(), &builder); | 69 escapeStringForJSON(value.string(), &builder); |
| 67 } else { | 70 } else { |
| 68 // Emit a string on the form: '"[...]<before><after>[...]"' | 71 // Emit a string on the form: '"[...]<before><after>[...]"' |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 109 |
| 107 auto message = messageForStatus(status()); | 110 auto message = messageForStatus(status()); |
| 108 builder.append(message.first); | 111 builder.append(message.first); |
| 109 appendValue(builder, *this, value); | 112 appendValue(builder, *this, value); |
| 110 builder.append(message.second); | 113 builder.append(message.second); |
| 111 } | 114 } |
| 112 return builder.toString(); | 115 return builder.toString(); |
| 113 } | 116 } |
| 114 | 117 |
| 115 } // namespace blink | 118 } // namespace blink |
| OLD | NEW |