| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 ASSERT(contextEnd <= value.length()); | 70 ASSERT(contextEnd <= value.length()); |
| 71 if (contextStart != 0) | 71 if (contextStart != 0) |
| 72 builder.append(horizontalEllipsisCharacter); | 72 builder.append(horizontalEllipsisCharacter); |
| 73 escapeStringForJSON(value.string().substring(contextStart, contextEnd -
contextStart), &builder); | 73 escapeStringForJSON(value.string().substring(contextStart, contextEnd -
contextStart), &builder); |
| 74 if (contextEnd != value.length()) | 74 if (contextEnd != value.length()) |
| 75 builder.append(horizontalEllipsisCharacter); | 75 builder.append(horizontalEllipsisCharacter); |
| 76 } | 76 } |
| 77 builder.append('"'); | 77 builder.append('"'); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } | 80 } // namespace |
| 81 | 81 |
| 82 String SVGParsingError::format(const String& tagName, const QualifiedName& name,
const AtomicString& value) const | 82 String SVGParsingError::format(const String& tagName, const QualifiedName& name,
const AtomicString& value) const |
| 83 { | 83 { |
| 84 StringBuilder builder; | 84 StringBuilder builder; |
| 85 | 85 |
| 86 // TODO(fs): Remove this case once enough specific errors have been added. | 86 // TODO(fs): Remove this case once enough specific errors have been added. |
| 87 if (status() == SVGParseStatus::ParsingFailed) { | 87 if (status() == SVGParseStatus::ParsingFailed) { |
| 88 builder.appendLiteral("Invalid value for "); | 88 builder.appendLiteral("Invalid value for "); |
| 89 appendErrorContextInfo(builder, tagName, name); | 89 appendErrorContextInfo(builder, tagName, name); |
| 90 builder.append('='); | 90 builder.append('='); |
| 91 appendValue(builder, *this, value); | 91 appendValue(builder, *this, value); |
| 92 } else { | 92 } else { |
| 93 appendErrorContextInfo(builder, tagName, name); | 93 appendErrorContextInfo(builder, tagName, name); |
| 94 builder.appendLiteral(": "); | 94 builder.appendLiteral(": "); |
| 95 | 95 |
| 96 if (hasLocus() && locus() == value.length()) | 96 if (hasLocus() && locus() == value.length()) |
| 97 builder.appendLiteral("Unexpected end of attribute. "); | 97 builder.appendLiteral("Unexpected end of attribute. "); |
| 98 | 98 |
| 99 auto message = messageForStatus(status()); | 99 auto message = messageForStatus(status()); |
| 100 builder.append(message.first); | 100 builder.append(message.first); |
| 101 appendValue(builder, *this, value); | 101 appendValue(builder, *this, value); |
| 102 builder.append(message.second); | 102 builder.append(message.second); |
| 103 } | 103 } |
| 104 return builder.toString(); | 104 return builder.toString(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace blink | 107 } // namespace blink |
| OLD | NEW |