Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the basics of TextTrack #22392

Merged
merged 2 commits into from Dec 11, 2018
Merged

Add the basics of TextTrack #22392

merged 2 commits into from Dec 11, 2018

Conversation

@dlrobertson
Copy link
Contributor

@dlrobertson dlrobertson commented Dec 9, 2018

Summary

Implement the basics of the TextTrack elements:

  • TextTrack

  • TextTrackCue

  • TextTrackCueList

  • TextTrackList

  • ./mach build -d does not report any errors

  • ./mach test-tidy does not report any errors

  • These changes is related to #22311

  • There are tests for these changes


This change is Reviewable

@highfive
Copy link

@highfive highfive commented Dec 9, 2018

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/webidls/TextTrackCueList.webidl, components/script/dom/htmlmediaelement.rs, components/script/dom/mod.rs, components/script/dom/texttrack.rs, components/script/dom/texttracklist.rs and 6 more
  • @KiChjang: components/script/dom/webidls/TextTrackCueList.webidl, components/script/dom/htmlmediaelement.rs, components/script/dom/mod.rs, components/script/dom/texttrack.rs, components/script/dom/texttracklist.rs and 6 more

Copy link
Contributor Author

@dlrobertson dlrobertson left a comment

I can remove the TextTrackCue and TextTrackCueList implementation from this PR and submit it in a follow up if it helps.

// Step 3
self.text_tracks().add(&track);
// Step 4: FIXME We need to queue a event here, but the
// addtrack atom does not exist
Copy link
Contributor Author

@dlrobertson dlrobertson Dec 9, 2018

How can I create addtrack as an Atom?

Copy link
Contributor Author

@dlrobertson dlrobertson Dec 9, 2018

Awesome! Thanks.


// https://html.spec.whatwg.org/multipage/#dom-texttrackcuelist-getcuebyid
fn GetCueById(&self, id: DOMString) -> Option<DomRoot<TextTrackCue>> {
if String::from(id.clone()).is_empty() {
Copy link
Contributor Author

@dlrobertson dlrobertson Dec 9, 2018

Is there a better way to determine that the DOMString is empty?

Copy link
Member

@jdm jdm Dec 9, 2018

id.is_empty()?

Copy link
Contributor Author

@dlrobertson dlrobertson Dec 9, 2018

😧 don't know how I missed that.

.borrow()
.iter()
.enumerate()
.filter(|(_, t)| t.id() == track.id())
Copy link
Contributor Author

@dlrobertson dlrobertson Dec 9, 2018

Again, not correct.

Copy link
Contributor Author

@dlrobertson dlrobertson Dec 9, 2018

Updated to use == which after looking at gecko I think is the right thing to do.

.borrow()
.iter()
.enumerate()
.filter(|(_, c)| c.id() == cue.id())
Copy link
Contributor Author

@dlrobertson dlrobertson Dec 9, 2018

This is not correct, and is not what gecko does.

Copy link
Contributor Author

@dlrobertson dlrobertson Dec 9, 2018

Same.

readonly attribute TextTrackCueList? cues;
// readonly attribute TextTrackCueList? activeCues;

[Throws]
Copy link
Contributor Author

@dlrobertson dlrobertson Dec 9, 2018

Note the IDL does not include Throws, but addCue can throw a "InvalidStateError" in step 2 and removeCue can throw a "NotFoundError" in step 1.

Copy link
Member

@jdm jdm Dec 9, 2018

Yeah, [Throws] is a Gecko/Servo-specific extension.

Copy link
Contributor Author

@dlrobertson dlrobertson Dec 9, 2018

👍 Thanks

@jdm
Copy link
Member

@jdm jdm commented Dec 9, 2018

r? @ferjm

@highfive highfive assigned ferjm and unassigned asajeffrey Dec 9, 2018
event_handler!(onchange, GetOnaddtrack, SetOnaddtrack);

// https://html.spec.whatwg.org/multipage/#handler-texttracklist-onremovetrack
event_handler!(onchange, GetOnremovetrack, SetOnremovetrack);
Copy link
Member

@jdm jdm Dec 9, 2018

These are using onchange, which probably explains why a few test failures remain in the event handling tests.

Copy link
Contributor Author

@dlrobertson dlrobertson Dec 10, 2018

Good catch. TrackEvent hasn't been implemented yet, so we'll likely have to implement that in order to get these to work correctly right? I haven't looked into the internals of events yet, so I'm very likely wrong 😄

@ferjm
Copy link
Member

@ferjm ferjm commented Dec 11, 2018

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Dec 11, 2018

Trying commit 4e36f33 with merge 7f400d1...

bors-servo added a commit that referenced this issue Dec 11, 2018
Add the basics of TextTrack

## Summary

Implement the basics of the TextTrack elements:
  - TextTrack
  - TextTrackCue
  - TextTrackCueList
  - TextTrackList

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes is related to #22311
- [x] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22392)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Dec 11, 2018

💔 Test failed - linux-rel-css

ferjm
ferjm approved these changes Dec 11, 2018
Copy link
Member

@ferjm ferjm left a comment

Wonderfull work!

I left some comments for minor stuff.

I believe the only thing left is to update the test expectations for tests/wpt/mozilla/tests/mozilla/interfaces.html. And getting @jdm's approval for the new exposed interfaces.

/// associated [textTracks].
///
/// [textTracks]: https://html.spec.whatwg.org/multipage/#dom-media-texttracks
pub fn text_tracks(&self) -> DomRoot<TextTrackList> {
Copy link
Member

@ferjm ferjm Dec 11, 2018

This does not need to be pubic.


// https://html.spec.whatwg.org/multipage/#dom-media-texttracks
fn TextTracks(&self) -> DomRoot<TextTrackList> {
self.text_tracks()
Copy link
Member

@ferjm ferjm Dec 11, 2018

nit: could we inline the content of the text_tracks function here and get rid of that function? We can call self.TextTracks() from AddTextTrack

// FIXME set the ready state to Loaded
let track = TextTrack::new(&window, kind, label, language, TextTrackMode::Hidden);
// Step 3 & 4
text_tracks.add(&track);
Copy link
Member

@ferjm ferjm Dec 11, 2018

nit: self.TextTracks().add(&track)

kind: kind,
label: label.into(),
language: language.into(),
id: "".to_owned(),
Copy link
Member

@ferjm ferjm Dec 11, 2018

I suspect that we need to get the id property as an argument of new and new_inherited as well, so we can assign the proper id when creating a TextTrack associated to a HTMLTrackElement.

Copy link
Contributor Author

@dlrobertson dlrobertson Dec 11, 2018

I wasn't sure what to do here. The spec states.

the track's identifier, if it has one, or the empty string otherwise

But in gecko the TextTrack class does not have an id member. For now I've added id to new and new_inherited

// https://html.spec.whatwg.org/multipage/#dom-texttrack-cues
fn GetCues(&self) -> Option<DomRoot<TextTrackCueList>> {
// FIXME if text track mode is disabled, return None
Some(self.get_cues())
Copy link
Member

@ferjm ferjm Dec 11, 2018

match self.Mode() {
   TextTrackMode::Disabled => None,
    _ => Some(self.get_cues()),
}

let window = window_from_node(self);
let text_tracks = self.text_tracks();
// Step 1 & 2
// FIXME set the ready state to Loaded
Copy link
Member

@ferjm ferjm Dec 11, 2018

Until we have a more specific issue, reference issue #22314 here, please.


// https://html.spec.whatwg.org/multipage/#dom-texttrack-addcue
fn AddCue(&self, cue: &TextTrackCue) -> ErrorResult {
// FIXME add Step 1 & 2
Copy link
Member

@ferjm ferjm Dec 11, 2018

Until we have a more specific issue, reference issue #22314 here, please.

// gecko calls RemoveCue when the given cue
// has an associated track, but doesn't return
// the error from it, so we wont either.
let _ = old_track.RemoveCue(cue);
Copy link
Member

@ferjm ferjm Dec 11, 2018

The spec says nothing about returning an error if removing the cue fails, so I think this behavior is fine. However, if removing the cue fails, that means that our implementation is buggy, so we should either add a warn! message or a debug_assert here.

@dlrobertson
Copy link
Contributor Author

@dlrobertson dlrobertson commented Dec 11, 2018

@ferjm updated

@ferjm
Copy link
Member

@ferjm ferjm commented Dec 11, 2018

Thanks! r=me

@jdm r? for the new exposed interfaces.

@jdm
Copy link
Member

@jdm jdm commented Dec 11, 2018

@bors-servo r=ferjm

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Dec 11, 2018

📌 Commit 94eec96 has been approved by ferjm

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Dec 11, 2018

Testing commit 94eec96 with merge aae005c...

bors-servo added a commit that referenced this issue Dec 11, 2018
Add the basics of TextTrack

## Summary

Implement the basics of the TextTrack elements:
  - TextTrack
  - TextTrackCue
  - TextTrackCueList
  - TextTrackList

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes is related to #22311
- [x] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22392)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Dec 11, 2018

💔 Test failed - linux-rel-wpt

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Dec 11, 2018

Testing commit 86a9bfd with merge fe15978...

bors-servo added a commit that referenced this issue Dec 11, 2018
Add the basics of TextTrack

## Summary

Implement the basics of the TextTrack elements:
  - TextTrack
  - TextTrackCue
  - TextTrackCueList
  - TextTrackList

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes is related to #22311
- [x] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22392)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Dec 11, 2018

💔 Test failed - linux-rel-css

dlrobertson added 2 commits Dec 11, 2018
Fill out the basics for the WebIDLs for the following:

  - TextTrack
  - TextTrackCue
  - TextTrackCueList
  - TextTrackList
Update the expectations of TextTrack related tests.
@dlrobertson
Copy link
Contributor Author

@dlrobertson dlrobertson commented Dec 11, 2018

The tests don't fail on my setup. Is it an intermittent? I also just rebased on the current master

@ferjm
Copy link
Member

@ferjm ferjm commented Dec 11, 2018

They indeed look like intermittents. Filed #22422 and #22423.

@bors-servo r+

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Dec 11, 2018

📌 Commit eb531f6 has been approved by ferjm

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Dec 11, 2018

Testing commit eb531f6 with merge 90fc9e2...

bors-servo added a commit that referenced this issue Dec 11, 2018
Add the basics of TextTrack

## Summary

Implement the basics of the TextTrack elements:
  - TextTrack
  - TextTrackCue
  - TextTrackCueList
  - TextTrackList

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes is related to #22311
- [x] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22392)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Dec 11, 2018

💔 Test failed - mac-rel-css1

@jdm
Copy link
Member

@jdm jdm commented Dec 11, 2018

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Dec 11, 2018

@bors-servo
Copy link
Contributor

@bors-servo bors-servo commented Dec 11, 2018

@bors-servo bors-servo merged commit eb531f6 into servo:master Dec 11, 2018
2 of 3 checks passed
@dlrobertson dlrobertson deleted the add_text_track branch Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants