Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd the basics of TextTrack #22392
Add the basics of TextTrack #22392
Conversation
highfive
commented
Dec 9, 2018
|
Heads up! This PR modifies the following files:
|
|
I can remove the |
| // Step 3 | ||
| self.text_tracks().add(&track); | ||
| // Step 4: FIXME We need to queue a event here, but the | ||
| // addtrack atom does not exist |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| // https://html.spec.whatwg.org/multipage/#dom-texttrackcuelist-getcuebyid | ||
| fn GetCueById(&self, id: DOMString) -> Option<DomRoot<TextTrackCue>> { | ||
| if String::from(id.clone()).is_empty() { |
This comment has been minimized.
This comment has been minimized.
dlrobertson
Dec 9, 2018
Author
Contributor
Is there a better way to determine that the DOMString is empty?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| .borrow() | ||
| .iter() | ||
| .enumerate() | ||
| .filter(|(_, t)| t.id() == track.id()) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
dlrobertson
Dec 9, 2018
Author
Contributor
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()) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| readonly attribute TextTrackCueList? cues; | ||
| // readonly attribute TextTrackCueList? activeCues; | ||
|
|
||
| [Throws] |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
r? @ferjm |
| event_handler!(onchange, GetOnaddtrack, SetOnaddtrack); | ||
|
|
||
| // https://html.spec.whatwg.org/multipage/#handler-texttracklist-onremovetrack | ||
| event_handler!(onchange, GetOnremovetrack, SetOnremovetrack); |
This comment has been minimized.
This comment has been minimized.
jdm
Dec 9, 2018
Member
These are using onchange, which probably explains why a few test failures remain in the event handling tests.
This comment has been minimized.
This comment has been minimized.
dlrobertson
Dec 10, 2018
Author
Contributor
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
|
@bors-servo try=wpt |
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 -->
|
|
| /// associated [textTracks]. | ||
| /// | ||
| /// [textTracks]: https://html.spec.whatwg.org/multipage/#dom-media-texttracks | ||
| pub fn text_tracks(&self) -> DomRoot<TextTrackList> { |
This comment has been minimized.
This comment has been minimized.
|
|
||
| // https://html.spec.whatwg.org/multipage/#dom-media-texttracks | ||
| fn TextTracks(&self) -> DomRoot<TextTrackList> { | ||
| self.text_tracks() |
This comment has been minimized.
This comment has been minimized.
ferjm
Dec 11, 2018
Member
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); |
This comment has been minimized.
This comment has been minimized.
| kind: kind, | ||
| label: label.into(), | ||
| language: language.into(), | ||
| id: "".to_owned(), |
This comment has been minimized.
This comment has been minimized.
ferjm
Dec 11, 2018
Member
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.
This comment has been minimized.
This comment has been minimized.
dlrobertson
Dec 11, 2018
Author
Contributor
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()) |
This comment has been minimized.
This comment has been minimized.
ferjm
Dec 11, 2018
Member
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 |
This comment has been minimized.
This comment has been minimized.
|
|
||
| // https://html.spec.whatwg.org/multipage/#dom-texttrack-addcue | ||
| fn AddCue(&self, cue: &TextTrackCue) -> ErrorResult { | ||
| // FIXME add Step 1 & 2 |
This comment has been minimized.
This comment has been minimized.
| // 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); |
This comment has been minimized.
This comment has been minimized.
ferjm
Dec 11, 2018
Member
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.
|
@ferjm updated |
|
Thanks! r=me @jdm r? for the new exposed interfaces. |
|
@bors-servo r=ferjm |
|
|
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 -->
|
|
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 -->
|
|
|
The tests don't fail on my setup. Is it an intermittent? I also just rebased on the current master |
|
They indeed look like intermittents. Filed #22422 and #22423. @bors-servo r+ |
|
|
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 retry |
|
|
|
|
dlrobertson commentedDec 9, 2018
•
edited by SimonSapin
Summary
Implement the basics of the TextTrack elements:
TextTrack
TextTrackCue
TextTrackCueList
TextTrackList
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThese changes is related to #22311
There are tests for these changes
This change is