Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGParsingError.h

Issue 1636503003: Error reporting for SVGLength and SVGLengthList (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TestExpectations Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
3 * Copyright (C) 2011 Apple, Inc. All rights reserved. 3 * Copyright (C) 2011 Apple, Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 23 matching lines...) Expand all
34 34
35 class QualifiedName; 35 class QualifiedName;
36 36
37 enum class SVGParseStatus { 37 enum class SVGParseStatus {
38 NoError, 38 NoError,
39 39
40 // Syntax errors 40 // Syntax errors
41 TrailingGarbage, 41 TrailingGarbage,
42 ExpectedBoolean, 42 ExpectedBoolean,
43 ExpectedEnumeration, 43 ExpectedEnumeration,
44 ExpectedLength,
44 ExpectedNumber, 45 ExpectedNumber,
45 46
46 // Semantic errors 47 // Semantic errors
47 NegativeValue, 48 NegativeValue,
48 49
49 // Generic error 50 // Generic error
50 ParsingFailed, 51 ParsingFailed,
51 }; 52 };
52 53
53 class SVGParsingError { 54 class SVGParsingError {
54 STACK_ALLOCATED(); 55 STACK_ALLOCATED();
55 public: 56 public:
56 SVGParsingError(SVGParseStatus status = SVGParseStatus::NoError, size_t locu s = 0) 57 SVGParsingError(SVGParseStatus status = SVGParseStatus::NoError, size_t locu s = 0)
57 : m_status(static_cast<unsigned>(status)) 58 : m_status(static_cast<unsigned>(status))
58 , m_locus(checkLocus(locus)) 59 , m_locus(checkLocus(locus))
59 { 60 {
60 ASSERT(this->status() == status); 61 ASSERT(this->status() == status);
61 } 62 }
62 63
63 SVGParseStatus status() const { return static_cast<SVGParseStatus>(m_status) ; } 64 SVGParseStatus status() const { return static_cast<SVGParseStatus>(m_status) ; }
64 65
65 bool hasLocus() const { return m_locus != kNoLocus; } 66 bool hasLocus() const { return m_locus != kNoLocus; }
66 unsigned locus() const { return m_locus; } 67 unsigned locus() const { return m_locus; }
67 68
69 // Move the locus of this error by |offset|, returning in a new error.
70 SVGParsingError offsetWith(size_t offset) const { return SVGParsingError(sta tus(), offset + locus()); }
71
68 // Generates a string describing this error for |value| in the context of 72 // Generates a string describing this error for |value| in the context of
69 // an <element, attribute>-name pair. 73 // an <element, attribute>-name pair.
70 String format(const String& tagName, const QualifiedName&, const AtomicStrin g& value) const; 74 String format(const String& tagName, const QualifiedName&, const AtomicStrin g& value) const;
71 75
72 private: 76 private:
73 static const int kLocusBits = 24; 77 static const int kLocusBits = 24;
74 static const unsigned kNoLocus = (1u << kLocusBits) - 1; 78 static const unsigned kNoLocus = (1u << kLocusBits) - 1;
75 79
76 static unsigned checkLocus(size_t locus) 80 static unsigned checkLocus(size_t locus)
77 { 81 {
(...skipping 11 matching lines...) Expand all
89 93
90 inline bool operator==(const SVGParsingError& error, SVGParseStatus status) 94 inline bool operator==(const SVGParsingError& error, SVGParseStatus status)
91 { 95 {
92 return error.status() == status; 96 return error.status() == status;
93 } 97 }
94 inline bool operator!=(const SVGParsingError& error, SVGParseStatus status) { re turn !(error == status); } 98 inline bool operator!=(const SVGParsingError& error, SVGParseStatus status) { re turn !(error == status); }
95 99
96 } // namespace blink 100 } // namespace blink
97 101
98 #endif // SVGParsingError_h 102 #endif // SVGParsingError_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGLengthList.cpp ('k') | third_party/WebKit/Source/core/svg/SVGParsingError.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698