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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGNumberOptionalNumber.cpp

Issue 1544673003: Refactor propagation of parsing errors for SVG attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 String SVGNumberOptionalNumber::valueAsString() const 67 String SVGNumberOptionalNumber::valueAsString() const
68 { 68 {
69 if (m_firstNumber->value() == m_secondNumber->value()) { 69 if (m_firstNumber->value() == m_secondNumber->value()) {
70 return String::number(m_firstNumber->value()); 70 return String::number(m_firstNumber->value());
71 } 71 }
72 72
73 return String::number(m_firstNumber->value()) + " " + String::number(m_secon dNumber->value()); 73 return String::number(m_firstNumber->value()) + " " + String::number(m_secon dNumber->value());
74 } 74 }
75 75
76 void SVGNumberOptionalNumber::setValueAsString(const String& value, ExceptionSta te& exceptionState) 76 SVGParsingError SVGNumberOptionalNumber::setValueAsString(const String& value)
77 { 77 {
78 float x, y; 78 float x, y;
79 SVGParsingError parseStatus = NoError;
79 if (!parseNumberOptionalNumber(value, x, y)) { 80 if (!parseNumberOptionalNumber(value, x, y)) {
80 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + value + "') is invalid."); 81 parseStatus = ParsingAttributeFailedError;
81 x = y = 0; 82 x = y = 0;
82 } 83 }
83 84
84 m_firstNumber->setValue(x); 85 m_firstNumber->setValue(x);
85 m_secondNumber->setValue(y); 86 m_secondNumber->setValue(y);
87 return parseStatus;
86 } 88 }
87 89
88 void SVGNumberOptionalNumber::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) 90 void SVGNumberOptionalNumber::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*)
89 { 91 {
90 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> otherNumberOptionalNumber = toSV GNumberOptionalNumber(other); 92 RefPtrWillBeRawPtr<SVGNumberOptionalNumber> otherNumberOptionalNumber = toSV GNumberOptionalNumber(other);
91 93
92 m_firstNumber->setValue(m_firstNumber->value() + otherNumberOptionalNumber-> m_firstNumber->value()); 94 m_firstNumber->setValue(m_firstNumber->value() + otherNumberOptionalNumber-> m_firstNumber->value());
93 m_secondNumber->setValue(m_secondNumber->value() + otherNumberOptionalNumber ->m_secondNumber->value()); 95 m_secondNumber->setValue(m_secondNumber->value() + otherNumberOptionalNumber ->m_secondNumber->value());
94 } 96 }
95 97
(...skipping 13 matching lines...) Expand all
109 m_secondNumber->setValue(y); 111 m_secondNumber->setValue(y);
110 } 112 }
111 113
112 float SVGNumberOptionalNumber::calculateDistance(PassRefPtrWillBeRawPtr<SVGPrope rtyBase> other, SVGElement*) 114 float SVGNumberOptionalNumber::calculateDistance(PassRefPtrWillBeRawPtr<SVGPrope rtyBase> other, SVGElement*)
113 { 115 {
114 // FIXME: Distance calculation is not possible for SVGNumberOptionalNumber r ight now. We need the distance for every single value. 116 // FIXME: Distance calculation is not possible for SVGNumberOptionalNumber r ight now. We need the distance for every single value.
115 return -1; 117 return -1;
116 } 118 }
117 119
118 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698