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

Side by Side Diff: third_party/WebKit/Source/core/html/track/vtt/VTTCue.cpp

Issue 2342913003: Replace narrowPrecisionToFloat with clampTo<float> (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/LayoutTheme.cpp » ('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, Opera Software ASA. All rights reserved. 2 * Copyright (c) 2013, Opera Software ASA. 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 29 matching lines...) Expand all
40 #include "core/frame/Settings.h" 40 #include "core/frame/Settings.h"
41 #include "core/frame/UseCounter.h" 41 #include "core/frame/UseCounter.h"
42 #include "core/html/HTMLDivElement.h" 42 #include "core/html/HTMLDivElement.h"
43 #include "core/html/track/TextTrack.h" 43 #include "core/html/track/TextTrack.h"
44 #include "core/html/track/TextTrackCueList.h" 44 #include "core/html/track/TextTrackCueList.h"
45 #include "core/html/track/vtt/VTTElement.h" 45 #include "core/html/track/vtt/VTTElement.h"
46 #include "core/html/track/vtt/VTTParser.h" 46 #include "core/html/track/vtt/VTTParser.h"
47 #include "core/html/track/vtt/VTTRegionList.h" 47 #include "core/html/track/vtt/VTTRegionList.h"
48 #include "core/html/track/vtt/VTTScanner.h" 48 #include "core/html/track/vtt/VTTScanner.h"
49 #include "core/layout/LayoutVTTCue.h" 49 #include "core/layout/LayoutVTTCue.h"
50 #include "platform/FloatConversion.h"
51 #include "platform/RuntimeEnabledFeatures.h" 50 #include "platform/RuntimeEnabledFeatures.h"
52 #include "platform/text/BidiResolver.h" 51 #include "platform/text/BidiResolver.h"
53 #include "platform/text/TextRunIterator.h" 52 #include "platform/text/TextRunIterator.h"
54 #include "wtf/MathExtras.h" 53 #include "wtf/MathExtras.h"
55 #include "wtf/text/StringBuilder.h" 54 #include "wtf/text/StringBuilder.h"
56 55
57 namespace blink { 56 namespace blink {
58 57
59 static const CSSValueID displayWritingModeMap[] = { 58 static const CSSValueID displayWritingModeMap[] = {
60 CSSValueHorizontalTb, CSSValueVerticalRl, CSSValueVerticalLr 59 CSSValueHorizontalTb, CSSValueVerticalRl, CSSValueVerticalLr
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // On setting, the WebVTT cue line must be set to the new value; if the new 325 // On setting, the WebVTT cue line must be set to the new value; if the new
327 // value is the string "auto", then it must be interpreted as the special 326 // value is the string "auto", then it must be interpreted as the special
328 // value auto. ("auto" is translated to NaN.) 327 // value auto. ("auto" is translated to NaN.)
329 float floatPosition; 328 float floatPosition;
330 if (position.isAutoKeyword()) { 329 if (position.isAutoKeyword()) {
331 if (lineIsAuto()) 330 if (lineIsAuto())
332 return; 331 return;
333 floatPosition = std::numeric_limits<float>::quiet_NaN(); 332 floatPosition = std::numeric_limits<float>::quiet_NaN();
334 } else { 333 } else {
335 DCHECK(position.isDouble()); 334 DCHECK(position.isDouble());
336 floatPosition = narrowPrecisionToFloat(position.getAsDouble()); 335 floatPosition = clampTo<float>(position.getAsDouble());
337 if (m_linePosition == floatPosition) 336 if (m_linePosition == floatPosition)
338 return; 337 return;
339 } 338 }
340 339
341 cueWillChange(); 340 cueWillChange();
342 m_linePosition = floatPosition; 341 m_linePosition = floatPosition;
343 cueDidChange(); 342 cueDidChange();
344 } 343 }
345 344
346 bool VTTCue::textPositionIsAuto() const 345 bool VTTCue::textPositionIsAuto() const
(...skipping 18 matching lines...) Expand all
365 // "auto", then it must be interpreted as the special value auto. 364 // "auto", then it must be interpreted as the special value auto.
366 float floatPosition; 365 float floatPosition;
367 if (position.isAutoKeyword()) { 366 if (position.isAutoKeyword()) {
368 if (textPositionIsAuto()) 367 if (textPositionIsAuto())
369 return; 368 return;
370 floatPosition = std::numeric_limits<float>::quiet_NaN(); 369 floatPosition = std::numeric_limits<float>::quiet_NaN();
371 } else { 370 } else {
372 DCHECK(position.isDouble()); 371 DCHECK(position.isDouble());
373 if (isInvalidPercentage(position.getAsDouble(), exceptionState)) 372 if (isInvalidPercentage(position.getAsDouble(), exceptionState))
374 return; 373 return;
375 floatPosition = narrowPrecisionToFloat(position.getAsDouble()); 374 floatPosition = clampTo<float>(position.getAsDouble());
376 if (m_textPosition == floatPosition) 375 if (m_textPosition == floatPosition)
377 return; 376 return;
378 } 377 }
379 378
380 cueWillChange(); 379 cueWillChange();
381 m_textPosition = floatPosition; 380 m_textPosition = floatPosition;
382 cueDidChange(); 381 cueDidChange();
383 } 382 }
384 383
385 void VTTCue::setSize(double size, ExceptionState& exceptionState) 384 void VTTCue::setSize(double size, ExceptionState& exceptionState)
386 { 385 {
387 // http://dev.w3.org/html5/webvtt/#dfn-vttcue-size 386 // http://dev.w3.org/html5/webvtt/#dfn-vttcue-size
388 // On setting, if the new value is negative or greater than 100, then throw 387 // On setting, if the new value is negative or greater than 100, then throw
389 // an IndexSizeError exception. 388 // an IndexSizeError exception.
390 if (isInvalidPercentage(size, exceptionState)) 389 if (isInvalidPercentage(size, exceptionState))
391 return; 390 return;
392 391
393 // Otherwise, set the WebVTT cue size to the new value. 392 // Otherwise, set the WebVTT cue size to the new value.
394 float floatSize = narrowPrecisionToFloat(size); 393 float floatSize = clampTo<float>(size);
395 if (m_cueSize == floatSize) 394 if (m_cueSize == floatSize)
396 return; 395 return;
397 396
398 cueWillChange(); 397 cueWillChange();
399 m_cueSize = floatSize; 398 m_cueSize = floatSize;
400 cueDidChange(); 399 cueDidChange();
401 } 400 }
402 401
403 const String& VTTCue::align() const 402 const String& VTTCue::align() const
404 { 403 {
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 1140
1142 DEFINE_TRACE(VTTCue) 1141 DEFINE_TRACE(VTTCue)
1143 { 1142 {
1144 visitor->trace(m_vttNodeTree); 1143 visitor->trace(m_vttNodeTree);
1145 visitor->trace(m_cueBackgroundBox); 1144 visitor->trace(m_cueBackgroundBox);
1146 visitor->trace(m_displayTree); 1145 visitor->trace(m_displayTree);
1147 TextTrackCue::trace(visitor); 1146 TextTrackCue::trace(visitor);
1148 } 1147 }
1149 1148
1150 } // namespace blink 1149 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/LayoutTheme.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698