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

Side by Side Diff: Source/core/html/track/vtt/VTTRegion.cpp

Issue 262753004: Replace all remaining IDL finitude type checks with [TypeChecking=Unrestricted] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/track/vtt/VTTCue.cpp ('k') | Source/core/html/track/vtt/VTTRegion.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 // The region doesn't have scrolling text, by default. 62 // The region doesn't have scrolling text, by default.
63 static const bool defaultScroll = false; 63 static const bool defaultScroll = false;
64 64
65 // Default region line-height (vh units) 65 // Default region line-height (vh units)
66 static const float lineHeight = 5.33; 66 static const float lineHeight = 5.33;
67 67
68 // Default scrolling animation time period (s). 68 // Default scrolling animation time period (s).
69 static const float scrollTime = 0.433; 69 static const float scrollTime = 0.433;
70 70
71 static bool isInfiniteOrNonNumberOrNonPercentage(double value, const char* metho d, ExceptionState& exceptionState) 71 static bool isNonPercentage(double value, const char* method, ExceptionState& ex ceptionState)
72 { 72 {
73 if (!std::isfinite(value)) {
74 exceptionState.throwTypeError(ExceptionMessages::notAFiniteNumber(value) );
75 return true;
76 }
77 if (value < 0 || value > 100) { 73 if (value < 0 || value > 100) {
78 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("value", value, 0.0, ExceptionMessages::InclusiveBound, 100.0, Exc eptionMessages::InclusiveBound)); 74 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("value", value, 0.0, ExceptionMessages::InclusiveBound, 100.0, Exc eptionMessages::InclusiveBound));
79 return true; 75 return true;
80 } 76 }
81 return false; 77 return false;
82 } 78 }
83 79
84 VTTRegion::VTTRegion() 80 VTTRegion::VTTRegion()
85 : m_id(emptyString()) 81 : m_id(emptyString())
86 , m_width(defaultWidth) 82 , m_width(defaultWidth)
(...skipping 16 matching lines...) Expand all
103 m_track = track; 99 m_track = track;
104 } 100 }
105 101
106 void VTTRegion::setId(const String& id) 102 void VTTRegion::setId(const String& id)
107 { 103 {
108 m_id = id; 104 m_id = id;
109 } 105 }
110 106
111 void VTTRegion::setWidth(double value, ExceptionState& exceptionState) 107 void VTTRegion::setWidth(double value, ExceptionState& exceptionState)
112 { 108 {
113 if (isInfiniteOrNonNumberOrNonPercentage(value, "width", exceptionState)) 109 if (isNonPercentage(value, "width", exceptionState))
114 return; 110 return;
115 111
116 m_width = value; 112 m_width = value;
117 } 113 }
118 114
119 void VTTRegion::setHeight(long value, ExceptionState& exceptionState) 115 void VTTRegion::setHeight(long value, ExceptionState& exceptionState)
120 { 116 {
121 if (value < 0) { 117 if (value < 0) {
122 exceptionState.throwDOMException(IndexSizeError, "The height provided (" + String::number(value) + ") is negative."); 118 exceptionState.throwDOMException(IndexSizeError, "The height provided (" + String::number(value) + ") is negative.");
123 return; 119 return;
124 } 120 }
125 121
126 m_heightInLines = value; 122 m_heightInLines = value;
127 } 123 }
128 124
129 void VTTRegion::setRegionAnchorX(double value, ExceptionState& exceptionState) 125 void VTTRegion::setRegionAnchorX(double value, ExceptionState& exceptionState)
130 { 126 {
131 if (isInfiniteOrNonNumberOrNonPercentage(value, "regionAnchorX", exceptionSt ate)) 127 if (isNonPercentage(value, "regionAnchorX", exceptionState))
132 return; 128 return;
133 129
134 m_regionAnchor.setX(value); 130 m_regionAnchor.setX(value);
135 } 131 }
136 132
137 void VTTRegion::setRegionAnchorY(double value, ExceptionState& exceptionState) 133 void VTTRegion::setRegionAnchorY(double value, ExceptionState& exceptionState)
138 { 134 {
139 if (isInfiniteOrNonNumberOrNonPercentage(value, "regionAnchorY", exceptionSt ate)) 135 if (isNonPercentage(value, "regionAnchorY", exceptionState))
140 return; 136 return;
141 137
142 m_regionAnchor.setY(value); 138 m_regionAnchor.setY(value);
143 } 139 }
144 140
145 void VTTRegion::setViewportAnchorX(double value, ExceptionState& exceptionState) 141 void VTTRegion::setViewportAnchorX(double value, ExceptionState& exceptionState)
146 { 142 {
147 if (isInfiniteOrNonNumberOrNonPercentage(value, "viewportAnchorX", exception State)) 143 if (isNonPercentage(value, "viewportAnchorX", exceptionState))
148 return; 144 return;
149 145
150 m_viewportAnchor.setX(value); 146 m_viewportAnchor.setX(value);
151 } 147 }
152 148
153 void VTTRegion::setViewportAnchorY(double value, ExceptionState& exceptionState) 149 void VTTRegion::setViewportAnchorY(double value, ExceptionState& exceptionState)
154 { 150 {
155 if (isInfiniteOrNonNumberOrNonPercentage(value, "viewportAnchorY", exception State)) 151 if (isNonPercentage(value, "viewportAnchorY", exceptionState))
156 return; 152 return;
157 153
158 m_viewportAnchor.setY(value); 154 m_viewportAnchor.setY(value);
159 } 155 }
160 156
161 const AtomicString VTTRegion::scroll() const 157 const AtomicString VTTRegion::scroll() const
162 { 158 {
163 DEFINE_STATIC_LOCAL(const AtomicString, upScrollValueKeyword, ("up", AtomicS tring::ConstructFromLiteral)); 159 DEFINE_STATIC_LOCAL(const AtomicString, upScrollValueKeyword, ("up", AtomicS tring::ConstructFromLiteral));
164 160
165 if (m_scroll) 161 if (m_scroll)
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 stopTimer(); 466 stopTimer();
471 displayLastVTTCueBox(); 467 displayLastVTTCueBox();
472 } 468 }
473 469
474 void VTTRegion::trace(Visitor* visitor) 470 void VTTRegion::trace(Visitor* visitor)
475 { 471 {
476 visitor->trace(m_track); 472 visitor->trace(m_track);
477 } 473 }
478 474
479 } // namespace WebCore 475 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/track/vtt/VTTCue.cpp ('k') | Source/core/html/track/vtt/VTTRegion.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698