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

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

Issue 2357463002: Consolidate read-only exception throwing for SVG*TearOffs (Closed)
Patch Set: Baseline updates Created 4 years, 3 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 20 matching lines...) Expand all
31 #include "core/svg/SVGPreserveAspectRatioTearOff.h" 31 #include "core/svg/SVGPreserveAspectRatioTearOff.h"
32 32
33 #include "bindings/core/v8/ExceptionState.h" 33 #include "bindings/core/v8/ExceptionState.h"
34 #include "core/dom/ExceptionCode.h" 34 #include "core/dom/ExceptionCode.h"
35 #include "core/svg/SVGElement.h" 35 #include "core/svg/SVGElement.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 void SVGPreserveAspectRatioTearOff::setAlign(unsigned short align, ExceptionStat e& exceptionState) 39 void SVGPreserveAspectRatioTearOff::setAlign(unsigned short align, ExceptionStat e& exceptionState)
40 { 40 {
41 if (isImmutable()) {
42 throwReadOnly(exceptionState);
43 return;
44 }
41 if (align == kSvgPreserveaspectratioUnknown || align > kSvgPreserveaspectrat ioXmaxymax) { 45 if (align == kSvgPreserveaspectratioUnknown || align > kSvgPreserveaspectrat ioXmaxymax) {
42 exceptionState.throwDOMException(NotSupportedError, "The alignment provi ded is invalid."); 46 exceptionState.throwDOMException(NotSupportedError, "The alignment provi ded is invalid.");
43 return; 47 return;
44 } 48 }
45 if (isImmutable()) {
46 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only.");
47 return;
48 }
49
50 target()->setAlign(static_cast<SVGPreserveAspectRatio::SVGPreserveAspectRati oType>(align)); 49 target()->setAlign(static_cast<SVGPreserveAspectRatio::SVGPreserveAspectRati oType>(align));
51 commitChange(); 50 commitChange();
52 } 51 }
53 52
54 void SVGPreserveAspectRatioTearOff::setMeetOrSlice(unsigned short meetOrSlice, E xceptionState& exceptionState) 53 void SVGPreserveAspectRatioTearOff::setMeetOrSlice(unsigned short meetOrSlice, E xceptionState& exceptionState)
55 { 54 {
55 if (isImmutable()) {
56 throwReadOnly(exceptionState);
57 return;
58 }
56 if (meetOrSlice == kSvgMeetorsliceUnknown || meetOrSlice > kSvgMeetorsliceSl ice) { 59 if (meetOrSlice == kSvgMeetorsliceUnknown || meetOrSlice > kSvgMeetorsliceSl ice) {
57 exceptionState.throwDOMException(NotSupportedError, "The meetOrSlice pro vided is invalid."); 60 exceptionState.throwDOMException(NotSupportedError, "The meetOrSlice pro vided is invalid.");
58 return; 61 return;
59 } 62 }
60 if (isImmutable()) {
61 exceptionState.throwDOMException(NoModificationAllowedError, "The attrib ute is read-only.");
62 return;
63 }
64
65 target()->setMeetOrSlice(static_cast<SVGPreserveAspectRatio::SVGMeetOrSliceT ype>(meetOrSlice)); 63 target()->setMeetOrSlice(static_cast<SVGPreserveAspectRatio::SVGMeetOrSliceT ype>(meetOrSlice));
66 commitChange(); 64 commitChange();
67 } 65 }
68 66
69 SVGPreserveAspectRatioTearOff::SVGPreserveAspectRatioTearOff(SVGPreserveAspectRa tio* target, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal , const QualifiedName& attributeName) 67 SVGPreserveAspectRatioTearOff::SVGPreserveAspectRatioTearOff(SVGPreserveAspectRa tio* target, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal , const QualifiedName& attributeName)
70 : SVGPropertyTearOff<SVGPreserveAspectRatio>(target, contextElement, propert yIsAnimVal, attributeName) 68 : SVGPropertyTearOff<SVGPreserveAspectRatio>(target, contextElement, propert yIsAnimVal, attributeName)
71 { 69 {
72 } 70 }
73 71
74 DEFINE_TRACE_WRAPPERS(SVGPreserveAspectRatioTearOff) 72 DEFINE_TRACE_WRAPPERS(SVGPreserveAspectRatioTearOff)
75 { 73 {
76 visitor->traceWrappers(contextElement()); 74 visitor->traceWrappers(contextElement());
77 } 75 }
78 76
79 } // namespace blink 77 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGPointTearOff.cpp ('k') | third_party/WebKit/Source/core/svg/SVGRectTearOff.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698