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

Compute positioning of single cues #99

Merged
merged 1 commit into from Sep 6, 2013
Merged

Conversation

RickEyre
Copy link
Contributor

@RickEyre RickEyre commented Sep 3, 2013

This implements the part of the processing algorithm that positions single cues. I'd like to get some feedback on this before I proceed further.

What's left to do after this is to implement the part of the algorithm that adjusts the positions of cues in relation to the other cues that are being displayed and to implement the part that handles regions as well.

We also have to figure out the bidirectional paragraph problem and add more tests to make sure that we are hitting every path in the processing model algorithm. I think some students might be able to help us with that.

Partial fix for #89 and #86.

@RickEyre
Copy link
Contributor Author

RickEyre commented Sep 3, 2013

I've changed it up a bit now. The WebVTTParser now has a new method, processTextTrackList(window, textTrackList). This implements the first halve of the processing model. It grabs all the active VTTCues that a MediaElement has on its list of TextTracks and converts them to DOM trees and applies initial CSS positioning and styling to them.

One of my questions here is how should we best integrate this into the test suite? We'd have to create a fake text track list class and probably have separate JSON tests for these as it deals with multiple cues at a time.

return -1;
// TODO: Have to figure out a way to determine what the position of the
// Track is in the Media element's list of TextTracks and return that + 1,
// negated. For now return 0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"For now return 0" and then you return 100. Typo in code or comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the comment. I originally had it as 0, but switched it to 100 as that is the default value in the spec.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, please fix this so the comment matches the code.

@RickEyre
Copy link
Contributor Author

RickEyre commented Sep 4, 2013

I've changed it a bit since my last comment. processTextTrackList is now processCues. This way we can only rebuild the DOM tree, etc, for cues that have changed since the last time we built them.

return 100;
if (typeof cue.line === "number")
return cue.line;
if (!cue.snapToLines)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this case is necessary, if you're going to return 100 in the default case below anyway.

@RickEyre
Copy link
Contributor Author

RickEyre commented Sep 4, 2013

I've updated as per your requests Dave and converted all the current JSON tests to test the processing model as well. Adding enough tests to get good coverage for this is going to be a big job, but not too hard, so I was thinking it would be a good candidate for a student to do. If you agree then we can land this and open an issue for the student to work on?


return {
direction: position.direction,
writingMode: writingMode,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get rid of the block of code from 414-418, the writingMode variable, and use a tertiary operation here too, like you do in lines 423, 424, etc.

@humphd
Copy link
Contributor

humphd commented Sep 4, 2013

I think having students work on these tests is reasonable, yes.

return { top: yPos, left: xPos, size: size };
}

var direction = calcParagraphDirection(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand the need for these variables at all. Why not just move these functions down to 409++ and store the return value directly on the return object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm struggling to see a different way of doing this. What your suggesting would work for direction, but xPos, yPos, and size all change after they are calculated initially. When the margin is applied they all change based on the relationship with each other. So we calculate size, then xPos and yPos based on size, and then we apply a margin to the values and at that time either xPos and size will change or yPos and size will change.

return "ltr";
}();

var boxLen = function(direction){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should just be function boxLen(direction){ (i.e., no need for var here)....

OK, reading this again, you're running this function right away. Use this pattern:

var boxLen = (function(direction){
...
}(this.direction));

@humphd
Copy link
Contributor

humphd commented Sep 6, 2013

One last nit, and I think this is good. r=me with that fixed.

This patch implements support for processing multiple VTTCues
from multiple TextTracks at once as well as applying the initial
CSS positioning and styles to the VTTCues once they are converted
to a DOM tree.
@RickEyre RickEyre merged commit c5f362a into mozilla:master Sep 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants