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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGNumber.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. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return false; 63 return false;
64 } 64 }
65 65
66 return true; 66 return true;
67 } 67 }
68 68
69 SVGParsingError SVGNumber::setValueAsString(const String& string) 69 SVGParsingError SVGNumber::setValueAsString(const String& string)
70 { 70 {
71 if (string.isEmpty()) { 71 if (string.isEmpty()) {
72 m_value = 0; 72 m_value = 0;
73 return NoError; 73 return SVGStatus::NoError;
74 } 74 }
75 75
76 bool valid = false; 76 bool valid = false;
77 if (string.is8Bit()) { 77 if (string.is8Bit()) {
78 const LChar* ptr = string.characters8(); 78 const LChar* ptr = string.characters8();
79 const LChar* end = ptr + string.length(); 79 const LChar* end = ptr + string.length();
80 valid = parse(ptr, end); 80 valid = parse(ptr, end);
81 } else { 81 } else {
82 const UChar* ptr = string.characters16(); 82 const UChar* ptr = string.characters16();
83 const UChar* end = ptr + string.length(); 83 const UChar* end = ptr + string.length();
84 valid = parse(ptr, end); 84 valid = parse(ptr, end);
85 } 85 }
86 86
87 if (!valid) { 87 if (!valid) {
88 m_value = 0; 88 m_value = 0;
89 return ParsingAttributeFailedError; 89 return SVGStatus::ParsingFailed;
90 } 90 }
91 return NoError; 91 return SVGStatus::NoError;
92 } 92 }
93 93
94 void SVGNumber::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) 94 void SVGNumber::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*)
95 { 95 {
96 setValue(m_value + toSVGNumber(other)->value()); 96 setValue(m_value + toSVGNumber(other)->value());
97 } 97 }
98 98
99 void SVGNumber::calculateAnimatedValue(SVGAnimationElement* animationElement, fl oat percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> fr om, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGProper tyBase> toAtEndOfDuration, SVGElement*) 99 void SVGNumber::calculateAnimatedValue(SVGAnimationElement* animationElement, fl oat percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> fr om, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBeRawPtr<SVGProper tyBase> toAtEndOfDuration, SVGElement*)
100 { 100 {
101 ASSERT(animationElement); 101 ASSERT(animationElement);
(...skipping 11 matching lines...) Expand all
113 } 113 }
114 114
115 PassRefPtrWillBeRawPtr<SVGNumber> SVGNumberAcceptPercentage::clone() const 115 PassRefPtrWillBeRawPtr<SVGNumber> SVGNumberAcceptPercentage::clone() const
116 { 116 {
117 return create(m_value); 117 return create(m_value);
118 } 118 }
119 119
120 SVGParsingError SVGNumberAcceptPercentage::setValueAsString(const String& string ) 120 SVGParsingError SVGNumberAcceptPercentage::setValueAsString(const String& string )
121 { 121 {
122 if (parseNumberOrPercentage(string, m_value)) 122 if (parseNumberOrPercentage(string, m_value))
123 return NoError; 123 return SVGStatus::NoError;
124 124
125 m_value = 0; 125 m_value = 0;
126 return ParsingAttributeFailedError; 126 return SVGStatus::ParsingFailed;
127 } 127 }
128 128
129 SVGNumberAcceptPercentage::SVGNumberAcceptPercentage(float value) 129 SVGNumberAcceptPercentage::SVGNumberAcceptPercentage(float value)
130 : SVGNumber(value) 130 : SVGNumber(value)
131 { 131 {
132 } 132 }
133 133
134 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698