Skip to content

Commit

Permalink
Make VTTCue.size() from 'int' to 'double'
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260365
rdar://problem/114089775

Reviewed by Jer Noble.

This patch aligns WebKit with Gecko / Firefox, Blink / Chromium and Web-Spec [1][2].

[1] https://w3c.github.io/webvtt/#the-vttcue-interface
[2] https://www.w3.org/Bugs/Public/show_bug.cgi?id=19836

Spec Commit: w3c/webvtt@6482591

In Web-Spec, `size` is double but in WebKit's implementation, it was using 'int',
so this PR just changes it to 'double'.

* Source/WebCore/html/track/VTTCue.h: Change 'size' to 'double' and also usage in 'setSize()' argument
* Source/WebCore/html/track/VTTCue.cpp:
(VTTCue::setSize): Update argument to 'double'
* LayoutTests/imported/w3c/web-platform-tests/webvtt/api/VTTCue/size.html: Add Test Case (manually)
* LayoutTests/imported/w3c/web-platform-tests/webvtt/api/VTTCue/size-expected.txt: Add Test Case Expectation
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/track/track-element/vtt-cue-float-precision-expected.txt: Rebaselined
* LayoutTests/media/track/track-webvtt-tc019-cue-size.html: Removed in favor of 'WPT' test
* LayoutTests/media/track/track-webvtt-tc019-cue-size-expected.txt: Ditto

Canonical link: https://commits.webkit.org/267041@main
  • Loading branch information
Ahmad-S792 authored and Ahmad Saleem committed Aug 18, 2023
1 parent 2463d7c commit b93351e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL Float precision of VTTCue attributes line, position and size, stored as floats assert_equals: expected 1.000000000000004 but got 1
PASS Float precision of VTTCue attributes line, position and size, stored as floats

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

PASS VTTCue.size, script-created cue

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!doctype html>
<title>VTTCue.size</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-size">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var cue = new VTTCue(0, 1, 'text');
assert_true('size' in cue, 'size is not supported');

for (i = 0; i <= 100; i++) {
cue.size = i;
assert_equals(cue.size, i);
}

[-1, -100, -101, 101, 200, 201].forEach(function(invalid) {
assert_throws_dom('IndexSizeError', function() {
cue.size = invalid;
});
});

cue.size = 1.5;
assert_equals(cue.size, 1.5);
}, document.title+', script-created cue');
</script>
17 changes: 0 additions & 17 deletions LayoutTests/media/track/track-webvtt-tc019-cue-size-expected.txt

This file was deleted.

67 changes: 0 additions & 67 deletions LayoutTests/media/track/track-webvtt-tc019-cue-size.html

This file was deleted.

4 changes: 2 additions & 2 deletions Source/WebCore/html/track/VTTCue.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2011, 2013 Google Inc. All rights reserved.
* Copyright (C) 2011-2019 Apple Inc. All rights reserved.
* Copyright (C) 2011-2023 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -412,7 +412,7 @@ void VTTCue::setPositionAlign(PositionAlignSetting positionAlignment)
didChange();
}

ExceptionOr<void> VTTCue::setSize(int size)
ExceptionOr<void> VTTCue::setSize(double size)
{
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
// On setting, if the new value is negative or greater than 100, then throw an IndexSizeError
Expand Down
6 changes: 3 additions & 3 deletions Source/WebCore/html/track/VTTCue.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2011, 2013 Google Inc. All rights reserved.
* Copyright (C) 2012-2014 Apple Inc. All rights reserved.
* Copyright (C) 2012-2023 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -146,8 +146,8 @@ class VTTCue : public TextTrackCue {
PositionAlignSetting positionAlign() const { return m_positionAlignment; }
void setPositionAlign(PositionAlignSetting);

int size() const { return m_cueSize; }
ExceptionOr<void> setSize(int);
double size() const { return m_cueSize; }
ExceptionOr<void> setSize(double);

AlignSetting align() const { return m_cueAlignment; }
void setAlign(AlignSetting);
Expand Down

0 comments on commit b93351e

Please sign in to comment.