OLD | NEW |
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 } | 116 } |
117 | 117 |
118 static const String& verticalGrowingRightKeyword() | 118 static const String& verticalGrowingRightKeyword() |
119 { | 119 { |
120 DEFINE_STATIC_LOCAL(const String, verticallr, ("lr")); | 120 DEFINE_STATIC_LOCAL(const String, verticallr, ("lr")); |
121 return verticallr; | 121 return verticallr; |
122 } | 122 } |
123 | 123 |
124 static bool isInvalidPercentage(double value) | 124 static bool isInvalidPercentage(double value) |
125 { | 125 { |
126 ASSERT(std::isfinite(value)); | 126 DCHECK(std::isfinite(value)); |
127 return value < 0 || value > 100; | 127 return value < 0 || value > 100; |
128 } | 128 } |
129 | 129 |
130 static bool isInvalidPercentage(double value, ExceptionState& exceptionState) | 130 static bool isInvalidPercentage(double value, ExceptionState& exceptionState) |
131 { | 131 { |
132 if (isInvalidPercentage(value)) { | 132 if (isInvalidPercentage(value)) { |
133 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde
xOutsideRange<double>("value", value, 0, ExceptionMessages::InclusiveBound, 100,
ExceptionMessages::InclusiveBound)); | 133 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde
xOutsideRange<double>("value", value, 0, ExceptionMessages::InclusiveBound, 100,
ExceptionMessages::InclusiveBound)); |
134 return true; | 134 return true; |
135 } | 135 } |
136 return false; | 136 return false; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 const String& VTTCue::vertical() const | 265 const String& VTTCue::vertical() const |
266 { | 266 { |
267 switch (m_writingDirection) { | 267 switch (m_writingDirection) { |
268 case Horizontal: | 268 case Horizontal: |
269 return horizontalKeyword(); | 269 return horizontalKeyword(); |
270 case VerticalGrowingLeft: | 270 case VerticalGrowingLeft: |
271 return verticalGrowingLeftKeyword(); | 271 return verticalGrowingLeftKeyword(); |
272 case VerticalGrowingRight: | 272 case VerticalGrowingRight: |
273 return verticalGrowingRightKeyword(); | 273 return verticalGrowingRightKeyword(); |
274 default: | 274 default: |
275 ASSERT_NOT_REACHED(); | 275 NOTREACHED(); |
276 return emptyString(); | 276 return emptyString(); |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 void VTTCue::setVertical(const String& value) | 280 void VTTCue::setVertical(const String& value) |
281 { | 281 { |
282 WritingDirection direction = m_writingDirection; | 282 WritingDirection direction = m_writingDirection; |
283 if (value == horizontalKeyword()) | 283 if (value == horizontalKeyword()) |
284 direction = Horizontal; | 284 direction = Horizontal; |
285 else if (value == verticalGrowingLeftKeyword()) | 285 else if (value == verticalGrowingLeftKeyword()) |
286 direction = VerticalGrowingLeft; | 286 direction = VerticalGrowingLeft; |
287 else if (value == verticalGrowingRightKeyword()) | 287 else if (value == verticalGrowingRightKeyword()) |
288 direction = VerticalGrowingRight; | 288 direction = VerticalGrowingRight; |
289 else | 289 else |
290 ASSERT_NOT_REACHED(); | 290 NOTREACHED(); |
291 | 291 |
292 if (direction == m_writingDirection) | 292 if (direction == m_writingDirection) |
293 return; | 293 return; |
294 | 294 |
295 cueWillChange(); | 295 cueWillChange(); |
296 m_writingDirection = direction; | 296 m_writingDirection = direction; |
297 cueDidChange(); | 297 cueDidChange(); |
298 } | 298 } |
299 | 299 |
300 void VTTCue::setSnapToLines(bool value) | 300 void VTTCue::setSnapToLines(bool value) |
(...skipping 24 matching lines...) Expand all Loading... |
325 // http://dev.w3.org/html5/webvtt/#dfn-vttcue-line | 325 // http://dev.w3.org/html5/webvtt/#dfn-vttcue-line |
326 // On setting, the WebVTT cue line must be set to the new value; if the new | 326 // 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 | 327 // value is the string "auto", then it must be interpreted as the special |
328 // value auto. ("auto" is translated to NaN.) | 328 // value auto. ("auto" is translated to NaN.) |
329 float floatPosition; | 329 float floatPosition; |
330 if (position.isAutoKeyword()) { | 330 if (position.isAutoKeyword()) { |
331 if (lineIsAuto()) | 331 if (lineIsAuto()) |
332 return; | 332 return; |
333 floatPosition = std::numeric_limits<float>::quiet_NaN(); | 333 floatPosition = std::numeric_limits<float>::quiet_NaN(); |
334 } else { | 334 } else { |
335 ASSERT(position.isDouble()); | 335 DCHECK(position.isDouble()); |
336 floatPosition = narrowPrecisionToFloat(position.getAsDouble()); | 336 floatPosition = narrowPrecisionToFloat(position.getAsDouble()); |
337 if (m_linePosition == floatPosition) | 337 if (m_linePosition == floatPosition) |
338 return; | 338 return; |
339 } | 339 } |
340 | 340 |
341 cueWillChange(); | 341 cueWillChange(); |
342 m_linePosition = floatPosition; | 342 m_linePosition = floatPosition; |
343 cueDidChange(); | 343 cueDidChange(); |
344 } | 344 } |
345 | 345 |
(...skipping 16 matching lines...) Expand all Loading... |
362 // On setting, if the new value is negative or greater than 100, then an | 362 // On setting, if the new value is negative or greater than 100, then an |
363 // IndexSizeError exception must be thrown. Otherwise, the WebVTT cue | 363 // IndexSizeError exception must be thrown. Otherwise, the WebVTT cue |
364 // position must be set to the new value; if the new value is the string | 364 // position must be set to the new value; if the new value is the string |
365 // "auto", then it must be interpreted as the special value auto. | 365 // "auto", then it must be interpreted as the special value auto. |
366 float floatPosition; | 366 float floatPosition; |
367 if (position.isAutoKeyword()) { | 367 if (position.isAutoKeyword()) { |
368 if (textPositionIsAuto()) | 368 if (textPositionIsAuto()) |
369 return; | 369 return; |
370 floatPosition = std::numeric_limits<float>::quiet_NaN(); | 370 floatPosition = std::numeric_limits<float>::quiet_NaN(); |
371 } else { | 371 } else { |
372 ASSERT(position.isDouble()); | 372 DCHECK(position.isDouble()); |
373 if (isInvalidPercentage(position.getAsDouble(), exceptionState)) | 373 if (isInvalidPercentage(position.getAsDouble(), exceptionState)) |
374 return; | 374 return; |
375 floatPosition = narrowPrecisionToFloat(position.getAsDouble()); | 375 floatPosition = narrowPrecisionToFloat(position.getAsDouble()); |
376 if (m_textPosition == floatPosition) | 376 if (m_textPosition == floatPosition) |
377 return; | 377 return; |
378 } | 378 } |
379 | 379 |
380 cueWillChange(); | 380 cueWillChange(); |
381 m_textPosition = floatPosition; | 381 m_textPosition = floatPosition; |
382 cueDidChange(); | 382 cueDidChange(); |
(...skipping 24 matching lines...) Expand all Loading... |
407 return startKeyword(); | 407 return startKeyword(); |
408 case Middle: | 408 case Middle: |
409 return middleKeyword(); | 409 return middleKeyword(); |
410 case End: | 410 case End: |
411 return endKeyword(); | 411 return endKeyword(); |
412 case Left: | 412 case Left: |
413 return leftKeyword(); | 413 return leftKeyword(); |
414 case Right: | 414 case Right: |
415 return rightKeyword(); | 415 return rightKeyword(); |
416 default: | 416 default: |
417 ASSERT_NOT_REACHED(); | 417 NOTREACHED(); |
418 return emptyString(); | 418 return emptyString(); |
419 } | 419 } |
420 } | 420 } |
421 | 421 |
422 void VTTCue::setAlign(const String& value) | 422 void VTTCue::setAlign(const String& value) |
423 { | 423 { |
424 CueAlignment alignment = m_cueAlignment; | 424 CueAlignment alignment = m_cueAlignment; |
425 if (value == startKeyword()) | 425 if (value == startKeyword()) |
426 alignment = Start; | 426 alignment = Start; |
427 else if (value == middleKeyword()) | 427 else if (value == middleKeyword()) |
428 alignment = Middle; | 428 alignment = Middle; |
429 else if (value == endKeyword()) | 429 else if (value == endKeyword()) |
430 alignment = End; | 430 alignment = End; |
431 else if (value == leftKeyword()) | 431 else if (value == leftKeyword()) |
432 alignment = Left; | 432 alignment = Left; |
433 else if (value == rightKeyword()) | 433 else if (value == rightKeyword()) |
434 alignment = Right; | 434 alignment = Right; |
435 else | 435 else |
436 ASSERT_NOT_REACHED(); | 436 NOTREACHED(); |
437 | 437 |
438 if (alignment == m_cueAlignment) | 438 if (alignment == m_cueAlignment) |
439 return; | 439 return; |
440 | 440 |
441 cueWillChange(); | 441 cueWillChange(); |
442 m_cueAlignment = alignment; | 442 m_cueAlignment = alignment; |
443 cueDidChange(); | 443 cueDidChange(); |
444 } | 444 } |
445 | 445 |
446 void VTTCue::setText(const String& text) | 446 void VTTCue::setText(const String& text) |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 { | 558 { |
559 TextRun run(value); | 559 TextRun run(value); |
560 BidiResolver<VTTTextRunIterator, BidiCharacterRun> bidiResolver; | 560 BidiResolver<VTTTextRunIterator, BidiCharacterRun> bidiResolver; |
561 bidiResolver.setStatus(BidiStatus(LTR, false)); | 561 bidiResolver.setStatus(BidiStatus(LTR, false)); |
562 bidiResolver.setPositionIgnoringNestedIsolates(VTTTextRunIterator(&run, 0)); | 562 bidiResolver.setPositionIgnoringNestedIsolates(VTTTextRunIterator(&run, 0)); |
563 return bidiResolver.determineDirectionality(&hasStrongDirectionality); | 563 return bidiResolver.determineDirectionality(&hasStrongDirectionality); |
564 } | 564 } |
565 | 565 |
566 static CSSValueID determineTextDirection(DocumentFragment* vttRoot) | 566 static CSSValueID determineTextDirection(DocumentFragment* vttRoot) |
567 { | 567 { |
568 ASSERT(vttRoot); | 568 DCHECK(vttRoot); |
569 | 569 |
570 // Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the | 570 // Apply the Unicode Bidirectional Algorithm's Paragraph Level steps to the |
571 // concatenation of the values of each WebVTT Text Object in nodes, in a | 571 // concatenation of the values of each WebVTT Text Object in nodes, in a |
572 // pre-order, depth-first traversal, excluding WebVTT Ruby Text Objects and | 572 // pre-order, depth-first traversal, excluding WebVTT Ruby Text Objects and |
573 // their descendants. | 573 // their descendants. |
574 TextDirection textDirection = LTR; | 574 TextDirection textDirection = LTR; |
575 Node* node = NodeTraversal::next(*vttRoot); | 575 Node* node = NodeTraversal::next(*vttRoot); |
576 while (node) { | 576 while (node) { |
577 ASSERT(node->isDescendantOf(vttRoot)); | 577 DCHECK(node->isDescendantOf(vttRoot)); |
578 | 578 |
579 if (node->isTextNode()) { | 579 if (node->isTextNode()) { |
580 bool hasStrongDirectionality; | 580 bool hasStrongDirectionality; |
581 textDirection = determineDirectionality(node->nodeValue(), hasStrong
Directionality); | 581 textDirection = determineDirectionality(node->nodeValue(), hasStrong
Directionality); |
582 if (hasStrongDirectionality) | 582 if (hasStrongDirectionality) |
583 break; | 583 break; |
584 } else if (node->isVTTElement()) { | 584 } else if (node->isVTTElement()) { |
585 if (toVTTElement(node)->webVTTNodeType() == VTTNodeTypeRubyText) { | 585 if (toVTTElement(node)->webVTTNodeType() == VTTNodeTypeRubyText) { |
586 node = NodeTraversal::nextSkippingChildren(*node); | 586 node = NodeTraversal::nextSkippingChildren(*node); |
587 continue; | 587 continue; |
(...skipping 20 matching lines...) Expand all Loading... |
608 case Left: | 608 case Left: |
609 return 0; | 609 return 0; |
610 // 3. If the cue text alignment is end or right, return 100 and abort these
steps. | 610 // 3. If the cue text alignment is end or right, return 100 and abort these
steps. |
611 case End: | 611 case End: |
612 case Right: | 612 case Right: |
613 return 100; | 613 return 100; |
614 // 4. If the cue text alignment is middle, return 50 and abort these steps. | 614 // 4. If the cue text alignment is middle, return 50 and abort these steps. |
615 case Middle: | 615 case Middle: |
616 return 50; | 616 return 50; |
617 default: | 617 default: |
618 ASSERT_NOT_REACHED(); | 618 NOTREACHED(); |
619 return 0; | 619 return 0; |
620 } | 620 } |
621 } | 621 } |
622 | 622 |
623 VTTCue::CueAlignment VTTCue::calculateComputedCueAlignment() const | 623 VTTCue::CueAlignment VTTCue::calculateComputedCueAlignment() const |
624 { | 624 { |
625 switch (m_cueAlignment) { | 625 switch (m_cueAlignment) { |
626 case VTTCue::Left: | 626 case VTTCue::Left: |
627 return VTTCue::Start; | 627 return VTTCue::Start; |
628 case VTTCue::Right: | 628 case VTTCue::Right: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 float computedTextPosition = calculateComputedTextPosition(); | 669 float computedTextPosition = calculateComputedTextPosition(); |
670 float maximumSize = computedTextPosition; | 670 float maximumSize = computedTextPosition; |
671 if (computedCueAlignment == Start) { | 671 if (computedCueAlignment == Start) { |
672 maximumSize = 100 - computedTextPosition; | 672 maximumSize = 100 - computedTextPosition; |
673 } else if (computedCueAlignment == End) { | 673 } else if (computedCueAlignment == End) { |
674 maximumSize = computedTextPosition; | 674 maximumSize = computedTextPosition; |
675 } else if (computedCueAlignment == Middle) { | 675 } else if (computedCueAlignment == Middle) { |
676 maximumSize = computedTextPosition <= 50 ? computedTextPosition : (100 -
computedTextPosition); | 676 maximumSize = computedTextPosition <= 50 ? computedTextPosition : (100 -
computedTextPosition); |
677 maximumSize = maximumSize * 2; | 677 maximumSize = maximumSize * 2; |
678 } else { | 678 } else { |
679 ASSERT_NOT_REACHED(); | 679 NOTREACHED(); |
680 } | 680 } |
681 | 681 |
682 // 5. If the cue size is less than maximum size, then let size | 682 // 5. If the cue size is less than maximum size, then let size |
683 // be cue size. Otherwise, let size be maximum size. | 683 // be cue size. Otherwise, let size be maximum size. |
684 displayParameters.size = std::min(m_cueSize, maximumSize); | 684 displayParameters.size = std::min(m_cueSize, maximumSize); |
685 | 685 |
686 // 6. If the cue writing direction is horizontal, then let width | 686 // 6. If the cue writing direction is horizontal, then let width |
687 // be 'size vw' and height be 'auto'. Otherwise, let width be 'auto' and | 687 // be 'size vw' and height be 'auto'. Otherwise, let width be 'auto' and |
688 // height be 'size vh'. (These are CSS values used by the next section to | 688 // height be 'size vh'. (These are CSS values used by the next section to |
689 // set CSS properties for the rendering; 'vw' and 'vh' are CSS units.) | 689 // set CSS properties for the rendering; 'vw' and 'vh' are CSS units.) |
690 // (Emulated in VTTCueBox::applyCSSProperties.) | 690 // (Emulated in VTTCueBox::applyCSSProperties.) |
691 | 691 |
692 // 7. Determine the value of x-position or y-position for cue as per the | 692 // 7. Determine the value of x-position or y-position for cue as per the |
693 // appropriate rules from the following list: | 693 // appropriate rules from the following list: |
694 if (m_writingDirection == Horizontal) { | 694 if (m_writingDirection == Horizontal) { |
695 switch (computedCueAlignment) { | 695 switch (computedCueAlignment) { |
696 case Start: | 696 case Start: |
697 displayParameters.position.setX(computedTextPosition); | 697 displayParameters.position.setX(computedTextPosition); |
698 break; | 698 break; |
699 case End: | 699 case End: |
700 displayParameters.position.setX(computedTextPosition - displayParame
ters.size); | 700 displayParameters.position.setX(computedTextPosition - displayParame
ters.size); |
701 break; | 701 break; |
702 case Middle: | 702 case Middle: |
703 displayParameters.position.setX(computedTextPosition - displayParame
ters.size / 2); | 703 displayParameters.position.setX(computedTextPosition - displayParame
ters.size / 2); |
704 break; | 704 break; |
705 default: | 705 default: |
706 ASSERT_NOT_REACHED(); | 706 NOTREACHED(); |
707 } | 707 } |
708 } else { | 708 } else { |
709 // Cases for m_writingDirection being VerticalGrowing{Left|Right} | 709 // Cases for m_writingDirection being VerticalGrowing{Left|Right} |
710 switch (computedCueAlignment) { | 710 switch (computedCueAlignment) { |
711 case Start: | 711 case Start: |
712 displayParameters.position.setY(computedTextPosition); | 712 displayParameters.position.setY(computedTextPosition); |
713 break; | 713 break; |
714 case End: | 714 case End: |
715 displayParameters.position.setY(computedTextPosition - displayParame
ters.size); | 715 displayParameters.position.setY(computedTextPosition - displayParame
ters.size); |
716 break; | 716 break; |
717 case Middle: | 717 case Middle: |
718 displayParameters.position.setY(computedTextPosition - displayParame
ters.size / 2); | 718 displayParameters.position.setY(computedTextPosition - displayParame
ters.size / 2); |
719 break; | 719 break; |
720 default: | 720 default: |
721 ASSERT_NOT_REACHED(); | 721 NOTREACHED(); |
722 } | 722 } |
723 } | 723 } |
724 | 724 |
725 // A cue has a computed line whose value is defined in terms of | 725 // A cue has a computed line whose value is defined in terms of |
726 // the other aspects of the cue. | 726 // the other aspects of the cue. |
727 float computedLinePosition = calculateComputedLinePosition(); | 727 float computedLinePosition = calculateComputedLinePosition(); |
728 | 728 |
729 // 8. Determine the value of whichever of x-position or y-position is not | 729 // 8. Determine the value of whichever of x-position or y-position is not |
730 // yet calculated for cue as per the appropriate rules from the following | 730 // yet calculated for cue as per the appropriate rules from the following |
731 // list: | 731 // list: |
732 if (!m_snapToLines) { | 732 if (!m_snapToLines) { |
733 if (m_writingDirection == Horizontal) | 733 if (m_writingDirection == Horizontal) |
734 displayParameters.position.setY(computedLinePosition); | 734 displayParameters.position.setY(computedLinePosition); |
735 else | 735 else |
736 displayParameters.position.setX(computedLinePosition); | 736 displayParameters.position.setX(computedLinePosition); |
737 } else { | 737 } else { |
738 if (m_writingDirection == Horizontal) | 738 if (m_writingDirection == Horizontal) |
739 displayParameters.position.setY(0); | 739 displayParameters.position.setY(0); |
740 else | 740 else |
741 displayParameters.position.setX(0); | 741 displayParameters.position.setX(0); |
742 } | 742 } |
743 | 743 |
744 // Step 9 not implemented (margin == 0). | 744 // Step 9 not implemented (margin == 0). |
745 | 745 |
746 // The snap-to-lines position is propagated to LayoutVTTCue. | 746 // The snap-to-lines position is propagated to LayoutVTTCue. |
747 displayParameters.snapToLinesPosition = m_snapToLines | 747 displayParameters.snapToLinesPosition = m_snapToLines |
748 ? computedLinePosition | 748 ? computedLinePosition |
749 : std::numeric_limits<float>::quiet_NaN(); | 749 : std::numeric_limits<float>::quiet_NaN(); |
750 | 750 |
751 ASSERT(std::isfinite(displayParameters.size)); | 751 DCHECK(std::isfinite(displayParameters.size)); |
752 ASSERT(displayParameters.direction != CSSValueNone); | 752 DCHECK_NE(displayParameters.direction, CSSValueNone); |
753 ASSERT(displayParameters.writingMode != CSSValueNone); | 753 DCHECK_NE(displayParameters.writingMode, CSSValueNone); |
754 return displayParameters; | 754 return displayParameters; |
755 } | 755 } |
756 | 756 |
757 void VTTCue::updatePastAndFutureNodes(double movieTime) | 757 void VTTCue::updatePastAndFutureNodes(double movieTime) |
758 { | 758 { |
759 DEFINE_STATIC_LOCAL(const String, timestampTag, ("timestamp")); | 759 DEFINE_STATIC_LOCAL(const String, timestampTag, ("timestamp")); |
760 | 760 |
761 ASSERT(isActive()); | 761 DCHECK(isActive()); |
762 | 762 |
763 // An active cue may still not have a display tree, e.g. if its track is | 763 // An active cue may still not have a display tree, e.g. if its track is |
764 // hidden or if the track belongs to an audio element. | 764 // hidden or if the track belongs to an audio element. |
765 if (!m_displayTree) | 765 if (!m_displayTree) |
766 return; | 766 return; |
767 | 767 |
768 // FIXME: Per spec it's possible for neither :past nor :future to match, but | 768 // FIXME: Per spec it's possible for neither :past nor :future to match, but |
769 // as implemented here and in SelectorChecker they are simply each others | 769 // as implemented here and in SelectorChecker they are simply each others |
770 // negations. For a cue with no internal timestamps, :past will match but | 770 // negations. For a cue with no internal timestamps, :past will match but |
771 // should not per spec. :future is correct, however. See the spec bug to | 771 // should not per spec. :future is correct, however. See the spec bug to |
772 // determine what the correct behavior should be: | 772 // determine what the correct behavior should be: |
773 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28237 | 773 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=28237 |
774 | 774 |
775 bool isPastNode = true; | 775 bool isPastNode = true; |
776 double currentTimestamp = startTime(); | 776 double currentTimestamp = startTime(); |
777 if (currentTimestamp > movieTime) | 777 if (currentTimestamp > movieTime) |
778 isPastNode = false; | 778 isPastNode = false; |
779 | 779 |
780 for (Node& child : NodeTraversal::descendantsOf(*m_displayTree)) { | 780 for (Node& child : NodeTraversal::descendantsOf(*m_displayTree)) { |
781 if (child.nodeName() == timestampTag) { | 781 if (child.nodeName() == timestampTag) { |
782 double currentTimestamp; | 782 double currentTimestamp; |
783 bool check = VTTParser::collectTimeStamp(child.nodeValue(), currentT
imestamp); | 783 DCHECK(VTTParser::collectTimeStamp(child.nodeValue(), currentTimesta
mp)); |
784 ASSERT_UNUSED(check, check); | |
785 | 784 |
786 if (currentTimestamp > movieTime) | 785 if (currentTimestamp > movieTime) |
787 isPastNode = false; | 786 isPastNode = false; |
788 } | 787 } |
789 | 788 |
790 if (child.isVTTElement()) { | 789 if (child.isVTTElement()) { |
791 toVTTElement(child).setIsPastNode(isPastNode); | 790 toVTTElement(child).setIsPastNode(isPastNode); |
792 // Make an elemenet id match a cue id for style matching purposes. | 791 // Make an elemenet id match a cue id for style matching purposes. |
793 if (!id().isEmpty()) | 792 if (!id().isEmpty()) |
794 toElement(child).setIdAttribute(id()); | 793 toElement(child).setIdAttribute(id()); |
795 } | 794 } |
796 } | 795 } |
797 } | 796 } |
798 | 797 |
799 VTTCueBox* VTTCue::getDisplayTree() | 798 VTTCueBox* VTTCue::getDisplayTree() |
800 { | 799 { |
801 ASSERT(track() && track()->isRendered() && isActive()); | 800 DCHECK(track() && track()->isRendered() && isActive()); |
802 | 801 |
803 if (!m_displayTree) { | 802 if (!m_displayTree) { |
804 m_displayTree = VTTCueBox::create(document()); | 803 m_displayTree = VTTCueBox::create(document()); |
805 m_displayTree->appendChild(m_cueBackgroundBox); | 804 m_displayTree->appendChild(m_cueBackgroundBox); |
806 } | 805 } |
807 | 806 |
808 ASSERT(m_displayTree->firstChild() == m_cueBackgroundBox); | 807 DCHECK_EQ(m_displayTree->firstChild(), m_cueBackgroundBox); |
809 | 808 |
810 if (!m_displayTreeShouldChange) { | 809 if (!m_displayTreeShouldChange) { |
811 // Apply updated user style overrides for text tracks when display tree
doesn't change. | 810 // Apply updated user style overrides for text tracks when display tree
doesn't change. |
812 // This ensures that the track settings are refreshed when the video is | 811 // This ensures that the track settings are refreshed when the video is |
813 // replayed or when the user slides back to an already rendered track. | 812 // replayed or when the user slides back to an already rendered track. |
814 applyUserOverrideCSSProperties(); | 813 applyUserOverrideCSSProperties(); |
815 return m_displayTree; | 814 return m_displayTree; |
816 } | 815 } |
817 | 816 |
818 createVTTNodeTree(); | 817 createVTTNodeTree(); |
(...skipping 27 matching lines...) Expand all Loading... |
846 if (region) | 845 if (region) |
847 region->willRemoveVTTCueBox(m_displayTree.get()); | 846 region->willRemoveVTTCueBox(m_displayTree.get()); |
848 } | 847 } |
849 | 848 |
850 if (m_displayTree) | 849 if (m_displayTree) |
851 m_displayTree->remove(ASSERT_NO_EXCEPTION); | 850 m_displayTree->remove(ASSERT_NO_EXCEPTION); |
852 } | 851 } |
853 | 852 |
854 void VTTCue::updateDisplay(HTMLDivElement& container) | 853 void VTTCue::updateDisplay(HTMLDivElement& container) |
855 { | 854 { |
856 ASSERT(track() && track()->isRendered() && isActive()); | 855 DCHECK(track() && track()->isRendered() && isActive()); |
857 | 856 |
858 UseCounter::count(document(), UseCounter::VTTCueRender); | 857 UseCounter::count(document(), UseCounter::VTTCueRender); |
859 | 858 |
860 if (m_writingDirection != Horizontal) | 859 if (m_writingDirection != Horizontal) |
861 UseCounter::count(document(), UseCounter::VTTCueRenderVertical); | 860 UseCounter::count(document(), UseCounter::VTTCueRenderVertical); |
862 | 861 |
863 if (!m_snapToLines) | 862 if (!m_snapToLines) |
864 UseCounter::count(document(), UseCounter::VTTCueRenderSnapToLinesFalse); | 863 UseCounter::count(document(), UseCounter::VTTCueRenderSnapToLinesFalse); |
865 | 864 |
866 if (!lineIsAuto()) | 865 if (!lineIsAuto()) |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, | 1121 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
1123 CSSPropertyColor, settings->textTrackTextColor()); | 1122 CSSPropertyColor, settings->textTrackTextColor()); |
1124 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, | 1123 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
1125 CSSPropertyTextShadow, settings->textTrackTextShadow()); | 1124 CSSPropertyTextShadow, settings->textTrackTextShadow()); |
1126 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, | 1125 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
1127 CSSPropertyFontSize, settings->textTrackTextSize()); | 1126 CSSPropertyFontSize, settings->textTrackTextSize()); |
1128 } | 1127 } |
1129 | 1128 |
1130 ExecutionContext* VTTCue::getExecutionContext() const | 1129 ExecutionContext* VTTCue::getExecutionContext() const |
1131 { | 1130 { |
1132 ASSERT(m_cueBackgroundBox); | 1131 DCHECK(m_cueBackgroundBox); |
1133 return m_cueBackgroundBox->getExecutionContext(); | 1132 return m_cueBackgroundBox->getExecutionContext(); |
1134 } | 1133 } |
1135 | 1134 |
1136 Document& VTTCue::document() const | 1135 Document& VTTCue::document() const |
1137 { | 1136 { |
1138 ASSERT(m_cueBackgroundBox); | 1137 DCHECK(m_cueBackgroundBox); |
1139 return m_cueBackgroundBox->document(); | 1138 return m_cueBackgroundBox->document(); |
1140 } | 1139 } |
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 |
OLD | NEW |