Chromium Code Reviews| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 if (displayParameters.writingMode == CSSValueHorizontalTb) { | 182 if (displayParameters.writingMode == CSSValueHorizontalTb) { |
| 183 setInlineStyleProperty(CSSPropertyWidth, displayParameters.size, CSSPrim itiveValue::UnitType::Percentage); | 183 setInlineStyleProperty(CSSPropertyWidth, displayParameters.size, CSSPrim itiveValue::UnitType::Percentage); |
| 184 setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto); | 184 setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto); |
| 185 } else { | 185 } else { |
| 186 setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto); | 186 setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto); |
| 187 setInlineStyleProperty(CSSPropertyHeight, displayParameters.size, CSSPr imitiveValue::UnitType::Percentage); | 187 setInlineStyleProperty(CSSPropertyHeight, displayParameters.size, CSSPr imitiveValue::UnitType::Percentage); |
| 188 } | 188 } |
| 189 | 189 |
| 190 // The 'text-align' property on the (root) List of WebVTT Node Objects must | 190 // The 'text-align' property on the (root) List of WebVTT Node Objects must |
| 191 // be set to the value in the second cell of the row of the table below | 191 // be set to the value in the second cell of the row of the table below |
| 192 // whose first cell is the value of the corresponding cue's text track cue | 192 // whose first cell is the value of the corresponding cue's WebVTT cue |
| 193 // alignment: | 193 // text alignment: |
| 194 setInlineStyleProperty(CSSPropertyTextAlign, displayParameters.textAlign); | 194 setInlineStyleProperty(CSSPropertyTextAlign, displayParameters.textAlign); |
| 195 | 195 |
| 196 // TODO(philipj): The position adjustment for non-snap-to-lines cues has | 196 // TODO(philipj): The position adjustment for non-snap-to-lines cues has |
| 197 // been removed from the spec: | 197 // been removed from the spec: |
| 198 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=19178 | 198 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=19178 |
| 199 if (std::isnan(displayParameters.snapToLinesPosition)) { | 199 if (std::isnan(displayParameters.snapToLinesPosition)) { |
| 200 // 10.13.1 Set up x and y: | 200 // 10.13.1 Set up x and y: |
| 201 // Note: x and y are set through the CSS left and top above. | 201 // Note: x and y are set through the CSS left and top above. |
| 202 | 202 |
| 203 // 10.13.2 Position the boxes in boxes such that the point x% along the | 203 // 10.13.2 Position the boxes in boxes such that the point x% along the |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 { | 317 { |
| 318 if (lineIsAuto()) | 318 if (lineIsAuto()) |
| 319 result.setAutoKeyword(autoKeyword()); | 319 result.setAutoKeyword(autoKeyword()); |
| 320 else | 320 else |
| 321 result.setDouble(m_linePosition); | 321 result.setDouble(m_linePosition); |
| 322 } | 322 } |
| 323 | 323 |
| 324 void VTTCue::setLine(const DoubleOrAutoKeyword& position) | 324 void VTTCue::setLine(const DoubleOrAutoKeyword& position) |
| 325 { | 325 { |
| 326 // http://dev.w3.org/html5/webvtt/#dfn-vttcue-line | 326 // http://dev.w3.org/html5/webvtt/#dfn-vttcue-line |
| 327 // On setting, the text track cue line position must be set to the new | 327 // On setting, the WebVTT cue line must be set to the new value; if the new |
| 328 // value; if the new value is the string "auto", then it must be | 328 // value is the string "auto", then it must be interpreted as the special |
| 329 // interpreted as the special value auto. | 329 // value auto. ("auto" is translated to NaN.) |
| 330 // ("auto" is translated to NaN.) | |
| 331 float floatPosition; | 330 float floatPosition; |
| 332 if (position.isAutoKeyword()) { | 331 if (position.isAutoKeyword()) { |
| 333 if (lineIsAuto()) | 332 if (lineIsAuto()) |
| 334 return; | 333 return; |
| 335 floatPosition = std::numeric_limits<float>::quiet_NaN(); | 334 floatPosition = std::numeric_limits<float>::quiet_NaN(); |
| 336 } else { | 335 } else { |
| 337 ASSERT(position.isDouble()); | 336 ASSERT(position.isDouble()); |
| 338 floatPosition = narrowPrecisionToFloat(position.getAsDouble()); | 337 floatPosition = narrowPrecisionToFloat(position.getAsDouble()); |
| 339 if (m_linePosition == floatPosition) | 338 if (m_linePosition == floatPosition) |
| 340 return; | 339 return; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 355 if (textPositionIsAuto()) | 354 if (textPositionIsAuto()) |
| 356 result.setAutoKeyword(autoKeyword()); | 355 result.setAutoKeyword(autoKeyword()); |
| 357 else | 356 else |
| 358 result.setDouble(m_textPosition); | 357 result.setDouble(m_textPosition); |
| 359 } | 358 } |
| 360 | 359 |
| 361 void VTTCue::setPosition(const DoubleOrAutoKeyword& position, ExceptionState& ex ceptionState) | 360 void VTTCue::setPosition(const DoubleOrAutoKeyword& position, ExceptionState& ex ceptionState) |
| 362 { | 361 { |
| 363 // http://dev.w3.org/html5/webvtt/#dfn-vttcue-position | 362 // http://dev.w3.org/html5/webvtt/#dfn-vttcue-position |
| 364 // On setting, if the new value is negative or greater than 100, then an | 363 // On setting, if the new value is negative or greater than 100, then an |
| 365 // IndexSizeError exception must be thrown. Otherwise, the text track cue | 364 // IndexSizeError exception must be thrown. Otherwise, the WebVTT cue |
| 366 // text position must be set to the new value; if the new value is the | 365 // position must be set to the new value; if the new value is the string |
| 367 // string "auto", then it must be interpreted as the special value auto. | 366 // "auto", then it must be interpreted as the special value auto. |
| 368 float floatPosition; | 367 float floatPosition; |
| 369 if (position.isAutoKeyword()) { | 368 if (position.isAutoKeyword()) { |
| 370 if (textPositionIsAuto()) | 369 if (textPositionIsAuto()) |
| 371 return; | 370 return; |
| 372 floatPosition = std::numeric_limits<float>::quiet_NaN(); | 371 floatPosition = std::numeric_limits<float>::quiet_NaN(); |
| 373 } else { | 372 } else { |
| 374 ASSERT(position.isDouble()); | 373 ASSERT(position.isDouble()); |
| 375 if (isInvalidPercentage(position.getAsDouble(), exceptionState)) | 374 if (isInvalidPercentage(position.getAsDouble(), exceptionState)) |
| 376 return; | 375 return; |
| 377 floatPosition = narrowPrecisionToFloat(position.getAsDouble()); | 376 floatPosition = narrowPrecisionToFloat(position.getAsDouble()); |
| 378 if (m_textPosition == floatPosition) | 377 if (m_textPosition == floatPosition) |
| 379 return; | 378 return; |
| 380 } | 379 } |
| 381 | 380 |
| 382 cueWillChange(); | 381 cueWillChange(); |
| 383 m_textPosition = floatPosition; | 382 m_textPosition = floatPosition; |
| 384 cueDidChange(); | 383 cueDidChange(); |
| 385 } | 384 } |
| 386 | 385 |
| 387 void VTTCue::setSize(double size, ExceptionState& exceptionState) | 386 void VTTCue::setSize(double size, ExceptionState& exceptionState) |
| 388 { | 387 { |
| 389 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-ele ment.html#dom-texttrackcue-size | 388 // http://dev.w3.org/html5/webvtt/#dfn-vttcue-size |
| 390 // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError | 389 // On setting, if the new value is negative or greater than 100, then throw |
| 391 // exception. Otherwise, set the text track cue size to the new value. | 390 // an IndexSizeError exception. |
| 392 if (isInvalidPercentage(size, exceptionState)) | 391 if (isInvalidPercentage(size, exceptionState)) |
| 393 return; | 392 return; |
| 394 | 393 |
| 395 // Otherwise, set the text track cue line position to the new value. | 394 // Otherwise, set the WebVTT cue size to the new value. |
| 396 float floatSize = narrowPrecisionToFloat(size); | 395 float floatSize = narrowPrecisionToFloat(size); |
| 397 if (m_cueSize == floatSize) | 396 if (m_cueSize == floatSize) |
| 398 return; | 397 return; |
| 399 | 398 |
| 400 cueWillChange(); | 399 cueWillChange(); |
| 401 m_cueSize = floatSize; | 400 m_cueSize = floatSize; |
| 402 cueDidChange(); | 401 cueDidChange(); |
| 403 } | 402 } |
| 404 | 403 |
| 405 const String& VTTCue::align() const | 404 const String& VTTCue::align() const |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 if (m_regionId == regionId) | 490 if (m_regionId == regionId) |
| 492 return; | 491 return; |
| 493 | 492 |
| 494 cueWillChange(); | 493 cueWillChange(); |
| 495 m_regionId = regionId; | 494 m_regionId = regionId; |
| 496 cueDidChange(); | 495 cueDidChange(); |
| 497 } | 496 } |
| 498 | 497 |
| 499 float VTTCue::calculateComputedLinePosition() const | 498 float VTTCue::calculateComputedLinePosition() const |
| 500 { | 499 { |
| 501 // http://dev.w3.org/html5/webvtt/#dfn-text-track-cue-computed-line-position | 500 // http://dev.w3.org/html5/webvtt/#dfn-cue-computed-line |
| 502 // A text track cue has a text track cue computed line position whose value | 501 // A WebVTT cue has a computed line whose value is that returned by the |
| 503 // is that returned by the following algorithm, which is defined in terms | 502 // following algorithm, which is defined in terms of the other aspects of |
| 504 // of the other aspects of the cue: | 503 // the cue: |
| 505 | 504 |
| 506 // 1. If the text track cue line position is numeric, the text track cue | 505 // 1. If the line is numeric, the WebVTT cue snap-to-lines flag of the |
| 507 // snap-to-lines flag of the text track cue is not set, and the text | 506 // WebVTT cue is not set, and the line is negative or greater than 100, |
| 508 // track cue line position is negative or greater than 100, then return | 507 // then return 100 and abort these steps. |
| 509 // 100 and abort these steps. | |
| 510 if (!lineIsAuto() && !m_snapToLines && isInvalidPercentage(m_linePosition)) | 508 if (!lineIsAuto() && !m_snapToLines && isInvalidPercentage(m_linePosition)) |
| 511 return 100; | 509 return 100; |
| 512 | 510 |
| 513 // 2. If the text track cue line position is numeric, return the value of | 511 // 2. If the line is numeric, return the value of the WebVTT cue line and |
| 514 // the text track cue line position and abort these steps. (Either the | 512 // abort these steps. (Either the WebVTT cue snap-to-lines flag is set, |
| 515 // text track cue snap-to-lines flag is set, so any value, not just | 513 // so any value, not just those in the range 0..100, is valid, or the |
| 516 // those in the range 0..100, is valid, or the value is in the range | 514 // value is in the range 0..100 and is thus valid regardless of the |
| 517 // 0..100 and is thus valid regardless of the value of that flag.) | 515 // value of that flag.) |
| 518 if (!lineIsAuto()) | 516 if (!lineIsAuto()) |
| 519 return m_linePosition; | 517 return m_linePosition; |
| 520 | 518 |
| 521 // 3. If the text track cue snap-to-lines flag of the text track cue is not | 519 // 3. If the WebVTT cue snap-to-lines flag of the WebVTT cue is not set, |
| 522 // set, return the value 100 and abort these steps. (The text track cue | 520 // return the value 100 and abort these steps. (The WebVTT cue line is |
| 523 // line position is the special value auto.) | 521 // the special value auto.) |
| 524 if (!m_snapToLines) | 522 if (!m_snapToLines) |
| 525 return 100; | 523 return 100; |
| 526 | 524 |
| 527 // 4. Let cue be the text track cue. | 525 // 4. Let cue be the WebVTT cue. |
| 528 // 5. If cue is not in a list of cues of a text track, or if that text | 526 // 5. If cue is not in a list of cues of a text track, or if that text |
| 529 // track is not in the list of text tracks of a media element, return -1 | 527 // track is not in the list of text tracks of a media element, return -1 |
| 530 // and abort these steps. | 528 // and abort these steps. |
| 531 if (!track()) | 529 if (!track()) |
| 532 return -1; | 530 return -1; |
| 533 | 531 |
| 534 // 6. Let track be the text track whose list of cues the cue is in. | 532 // 6. Let track be the text track whose list of cues the cue is in. |
| 535 // 7. Let n be the number of text tracks whose text track mode is showing | 533 // 7. Let n be the number of text tracks whose text track mode is showing |
| 536 // and that are in the media element's list of text tracks before track. | 534 // and that are in the media element's list of text tracks before track. |
| 537 int n = track()->trackIndexRelativeToRenderedTracks(); | 535 int n = track()->trackIndexRelativeToRenderedTracks(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 591 } | 589 } |
| 592 } | 590 } |
| 593 | 591 |
| 594 node = NodeTraversal::next(*node); | 592 node = NodeTraversal::next(*node); |
| 595 } | 593 } |
| 596 return isLeftToRightDirection(textDirection) ? CSSValueLtr : CSSValueRtl; | 594 return isLeftToRightDirection(textDirection) ? CSSValueLtr : CSSValueRtl; |
| 597 } | 595 } |
| 598 | 596 |
| 599 float VTTCue::calculateComputedTextPosition() const | 597 float VTTCue::calculateComputedTextPosition() const |
| 600 { | 598 { |
| 601 // http://dev.w3.org/html5/webvtt/#dfn-text-track-cue-computed-text-position | 599 // http://dev.w3.org/html5/webvtt/#dfn-cue-computed-position |
| 602 | 600 |
| 603 // 1. If the text track cue text position is numeric, then return the value | 601 // 1. If the position is numeric, then return the value of the position and |
| 604 // of the text track cue text position and abort these steps. (Otherwise, | 602 // abort these steps. (Otherwise, the position is the special value auto.) |
| 605 // the text track cue text position is the special value auto.) | |
| 606 if (!textPositionIsAuto()) | 603 if (!textPositionIsAuto()) |
| 607 return m_textPosition; | 604 return m_textPosition; |
| 608 | 605 |
| 609 switch (m_cueAlignment) { | 606 switch (m_cueAlignment) { |
| 610 // 2. If the text track cue text alignment is start or left, return 0 and ab ort these steps. | 607 // 2. If the cue text alignment is start or left, return 0 and abort these s teps. |
| 611 case Start: | 608 case Start: |
| 612 case Left: | 609 case Left: |
| 613 return 0; | 610 return 0; |
| 614 // 3. If the text track cue text alignment is end or right, return 100 and a bort these steps. | 611 // 3. If the cue text alignment is end or right, return 100 and abort these steps. |
| 615 case End: | 612 case End: |
| 616 case Right: | 613 case Right: |
| 617 return 100; | 614 return 100; |
| 618 // 4. If the text track cue text alignment is middle, return 50 and abort th ese steps. | 615 // 4. If the cue text alignment is middle, return 50 and abort these steps. |
| 619 case Middle: | 616 case Middle: |
| 620 return 50; | 617 return 50; |
| 621 default: | 618 default: |
| 622 ASSERT_NOT_REACHED(); | 619 ASSERT_NOT_REACHED(); |
| 623 return 0; | 620 return 0; |
| 624 } | 621 } |
| 625 } | 622 } |
| 626 | 623 |
| 627 VTTCue::CueAlignment VTTCue::calculateComputedCueAlignment() const | 624 VTTCue::CueAlignment VTTCue::calculateComputedCueAlignment() const |
| 628 { | 625 { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 652 // Steps 1 and 2. | 649 // Steps 1 and 2. |
| 653 displayParameters.direction = determineTextDirection(m_vttNodeTree.get()); | 650 displayParameters.direction = determineTextDirection(m_vttNodeTree.get()); |
| 654 | 651 |
| 655 if (displayParameters.direction == CSSValueRtl) | 652 if (displayParameters.direction == CSSValueRtl) |
| 656 UseCounter::count(document(), UseCounter::VTTCueRenderRtl); | 653 UseCounter::count(document(), UseCounter::VTTCueRenderRtl); |
| 657 | 654 |
| 658 // Note: The 'text-align' property is also determined here so that | 655 // Note: The 'text-align' property is also determined here so that |
| 659 // VTTCueBox::applyCSSProperties need not have access to a VTTCue. | 656 // VTTCueBox::applyCSSProperties need not have access to a VTTCue. |
| 660 displayParameters.textAlign = displayAlignmentMap[cueAlignment()]; | 657 displayParameters.textAlign = displayAlignmentMap[cueAlignment()]; |
| 661 | 658 |
| 662 // 3. If the text track cue writing direction is horizontal, then let | 659 // 3. If the cue writing direction is horizontal, then let block-flow be |
| 663 // block-flow be 'tb'. Otherwise, if the text track cue writing direction is | 660 // 'tb'. Otherwise, if the cue writing direction is vertical growing left, |
| 664 // vertical growing left, then let block-flow be 'lr'. Otherwise, the text | 661 // then let block-flow be 'lr'. Otherwise, the cue writing direction is |
| 665 // track cue writing direction is vertical growing right; let block-flow be | 662 // vertical growing right; let block-flow be 'rl'. |
| 666 // 'rl'. | |
| 667 displayParameters.writingMode = displayWritingModeMap[m_writingDirection]; | 663 displayParameters.writingMode = displayWritingModeMap[m_writingDirection]; |
| 668 | 664 |
| 669 // Resolve the cue alignment to one of the values {start, end, middle}. | 665 // Resolve the cue alignment to one of the values {start, end, middle}. |
| 670 CueAlignment computedCueAlignment = calculateComputedCueAlignment(); | 666 CueAlignment computedCueAlignment = calculateComputedCueAlignment(); |
| 671 | 667 |
| 672 // 4. Determine the value of maximum size for cue as per the appropriate | 668 // 4. Determine the value of maximum size for cue as per the appropriate |
| 673 // rules from the following list: | 669 // rules from the following list: |
| 674 float computedTextPosition = calculateComputedTextPosition(); | 670 float computedTextPosition = calculateComputedTextPosition(); |
| 675 float maximumSize = computedTextPosition; | 671 float maximumSize = computedTextPosition; |
| 676 if (computedCueAlignment == Start) { | 672 if (computedCueAlignment == Start) { |
| 677 maximumSize = 100 - computedTextPosition; | 673 maximumSize = 100 - computedTextPosition; |
| 678 } else if (computedCueAlignment == End) { | 674 } else if (computedCueAlignment == End) { |
| 679 maximumSize = computedTextPosition; | 675 maximumSize = computedTextPosition; |
| 680 } else if (computedCueAlignment == Middle) { | 676 } else if (computedCueAlignment == Middle) { |
| 681 maximumSize = computedTextPosition <= 50 ? computedTextPosition : (100 - computedTextPosition); | 677 maximumSize = computedTextPosition <= 50 ? computedTextPosition : (100 - computedTextPosition); |
| 682 maximumSize = maximumSize * 2; | 678 maximumSize = maximumSize * 2; |
| 683 } else { | 679 } else { |
| 684 ASSERT_NOT_REACHED(); | 680 ASSERT_NOT_REACHED(); |
| 685 } | 681 } |
| 686 | 682 |
| 687 // 5. If the text track cue size is less than maximum size, then let size | 683 // 5. If the cue size is less than maximum size, then let size |
| 688 // be text track cue size. Otherwise, let size be maximum size. | 684 // be cue size. Otherwise, let size be maximum size. |
| 689 displayParameters.size = std::min(m_cueSize, maximumSize); | 685 displayParameters.size = std::min(m_cueSize, maximumSize); |
| 690 | 686 |
| 691 // 6. If the text track cue writing direction is horizontal, then let width | 687 // 6. If the cue writing direction is horizontal, then let width |
| 692 // be 'size vw' and height be 'auto'. Otherwise, let width be 'auto' and | 688 // be 'size vw' and height be 'auto'. Otherwise, let width be 'auto' and |
| 693 // height be 'size vh'. (These are CSS values used by the next section to | 689 // height be 'size vh'. (These are CSS values used by the next section to |
| 694 // set CSS properties for the rendering; 'vw' and 'vh' are CSS units.) | 690 // set CSS properties for the rendering; 'vw' and 'vh' are CSS units.) |
| 695 // (Emulated in VTTCueBox::applyCSSProperties.) | 691 // (Emulated in VTTCueBox::applyCSSProperties.) |
| 696 | 692 |
| 697 // 7. Determine the value of x-position or y-position for cue as per the | 693 // 7. Determine the value of x-position or y-position for cue as per the |
| 698 // appropriate rules from the following list: | 694 // appropriate rules from the following list: |
| 699 if (m_writingDirection == Horizontal) { | 695 if (m_writingDirection == Horizontal) { |
| 700 switch (computedCueAlignment) { | 696 switch (computedCueAlignment) { |
| 701 case Start: | 697 case Start: |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 720 displayParameters.position.setY(computedTextPosition - displayParame ters.size); | 716 displayParameters.position.setY(computedTextPosition - displayParame ters.size); |
| 721 break; | 717 break; |
| 722 case Middle: | 718 case Middle: |
| 723 displayParameters.position.setY(computedTextPosition - displayParame ters.size / 2); | 719 displayParameters.position.setY(computedTextPosition - displayParame ters.size / 2); |
| 724 break; | 720 break; |
| 725 default: | 721 default: |
| 726 ASSERT_NOT_REACHED(); | 722 ASSERT_NOT_REACHED(); |
| 727 } | 723 } |
| 728 } | 724 } |
| 729 | 725 |
| 730 // A text track cue has a text track cue computed line position whose value | 726 // A cue has a computed line whose value is defined in terms of |
| 731 // is defined in terms of the other aspects of the cue. | 727 // the other aspects of the cue. |
| 732 float computedLinePosition = calculateComputedLinePosition(); | 728 float computedLinePosition = calculateComputedLinePosition(); |
| 733 | 729 |
| 734 // 8. Determine the value of whichever of x-position or y-position is not | 730 // 8. Determine the value of whichever of x-position or y-position is not |
| 735 // yet calculated for cue as per the appropriate rules from the following | 731 // yet calculated for cue as per the appropriate rules from the following |
| 736 // list: | 732 // list: |
| 737 if (!m_snapToLines) { | 733 if (!m_snapToLines) { |
| 738 if (m_writingDirection == Horizontal) | 734 if (m_writingDirection == Horizontal) |
| 739 displayParameters.position.setY(computedLinePosition); | 735 displayParameters.position.setY(computedLinePosition); |
| 740 else | 736 else |
| 741 displayParameters.position.setX(computedLinePosition); | 737 displayParameters.position.setX(computedLinePosition); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 | 875 |
| 880 if (m_cueAlignment != Middle) | 876 if (m_cueAlignment != Middle) |
| 881 UseCounter::count(document(), UseCounter::VTTCueRenderAlignNotMiddle); | 877 UseCounter::count(document(), UseCounter::VTTCueRenderAlignNotMiddle); |
| 882 | 878 |
| 883 RefPtrWillBeRawPtr<VTTCueBox> displayBox = getDisplayTree(); | 879 RefPtrWillBeRawPtr<VTTCueBox> displayBox = getDisplayTree(); |
| 884 VTTRegion* region = 0; | 880 VTTRegion* region = 0; |
| 885 if (track()->regions()) | 881 if (track()->regions()) |
| 886 region = track()->regions()->getRegionById(regionId()); | 882 region = track()->regions()->getRegionById(regionId()); |
| 887 | 883 |
| 888 if (!region) { | 884 if (!region) { |
| 889 // If cue has an empty text track cue region identifier or there is no | 885 // If cue has an empty region identifier or there is no WebVTT region |
| 890 // WebVTT region whose region identifier is identical to cue's text | 886 // whose region identifier is identical to cue's region identifier, run |
| 891 // track cue region identifier, run the following substeps: | 887 // the following substeps: |
| 892 if (displayBox->hasChildren() && !container.contains(displayBox.get())) { | 888 if (displayBox->hasChildren() && !container.contains(displayBox.get())) { |
| 893 // Note: the display tree of a cue is removed when the active flag o f the cue is unset. | 889 // Note: the display tree of a cue is removed when the active flag o f the cue is unset. |
| 894 container.appendChild(displayBox); | 890 container.appendChild(displayBox); |
| 895 } | 891 } |
| 896 } else { | 892 } else { |
| 897 // Let region be the WebVTT region whose region identifier | 893 // Let region be the WebVTT region whose region identifier matches the |
| 898 // matches the text track cue region identifier of cue. | 894 // region identifier of cue. |
| 899 RefPtrWillBeRawPtr<HTMLDivElement> regionNode = region->getDisplayTree(d ocument()); | 895 RefPtrWillBeRawPtr<HTMLDivElement> regionNode = region->getDisplayTree(d ocument()); |
| 900 | 896 |
| 901 // Append the region to the viewport, if it was not already. | 897 // Append the region to the viewport, if it was not already. |
| 902 if (!container.contains(regionNode.get())) | 898 if (!container.contains(regionNode.get())) |
| 903 container.appendChild(regionNode); | 899 container.appendChild(regionNode); |
| 904 | 900 |
| 905 region->appendVTTCueBox(displayBox); | 901 region->appendVTTCueBox(displayBox); |
| 906 } | 902 } |
| 907 } | 903 } |
| 908 | 904 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 954 | 950 |
| 955 while (!input.isAtEnd()) { | 951 while (!input.isAtEnd()) { |
| 956 | 952 |
| 957 // The WebVTT cue settings part of a WebVTT cue consists of zero or more of the following components, in any order, | 953 // The WebVTT cue settings part of a WebVTT cue consists of zero or more of the following components, in any order, |
| 958 // separated from each other by one or more U+0020 SPACE characters or U +0009 CHARACTER TABULATION (tab) characters. | 954 // separated from each other by one or more U+0020 SPACE characters or U +0009 CHARACTER TABULATION (tab) characters. |
| 959 input.skipWhile<VTTParser::isValidSettingDelimiter>(); | 955 input.skipWhile<VTTParser::isValidSettingDelimiter>(); |
| 960 | 956 |
| 961 if (input.isAtEnd()) | 957 if (input.isAtEnd()) |
| 962 break; | 958 break; |
| 963 | 959 |
| 964 // When the user agent is to parse the WebVTT settings given by a string input for a text track cue cue, | 960 // When the user agent is to parse the WebVTT settings given by a string input for a text tracke cue, |
|
philipj_slow
2015/08/21 12:17:53
s/tracke/track/
| |
| 965 // the user agent must run the following steps: | 961 // the user agent must run the following steps: |
| 966 // 1. Let settings be the result of splitting input on spaces. | 962 // 1. Let settings be the result of splitting input on spaces. |
| 967 // 2. For each token setting in the list settings, run the following sub steps: | 963 // 2. For each token setting in the list settings, run the following sub steps: |
| 968 // 1. If setting does not contain a U+003A COLON character (:), or if the first U+003A COLON character (:) | 964 // 1. If setting does not contain a U+003A COLON character (:), or if the first U+003A COLON character (:) |
| 969 // in setting is either the first or last character of setting, th en jump to the step labeled next setting. | 965 // in setting is either the first or last character of setting, th en jump to the step labeled next setting. |
| 970 // 2. Let name be the leading substring of setting up to and excludin g the first U+003A COLON character (:) in that string. | 966 // 2. Let name be the leading substring of setting up to and excludin g the first U+003A COLON character (:) in that string. |
| 971 CueSetting name = settingName(input); | 967 CueSetting name = settingName(input); |
| 972 | 968 |
| 973 // 3. Let value be the trailing substring of setting starting from the c haracter immediately after the first U+003A COLON character (:) in that string. | 969 // 3. Let value be the trailing substring of setting starting from the c haracter immediately after the first U+003A COLON character (:) in that string. |
| 974 VTTScanner::Run valueRun = input.collectUntil<VTTParser::isValidSettingD elimiter>(); | 970 VTTScanner::Run valueRun = input.collectUntil<VTTParser::isValidSettingD elimiter>(); |
| 975 | 971 |
| 976 // 4. Run the appropriate substeps that apply for the value of name, as follows: | 972 // 4. Run the appropriate substeps that apply for the value of name, as follows: |
| 977 switch (name) { | 973 switch (name) { |
| 978 case Vertical: { | 974 case Vertical: { |
| 979 // If name is a case-sensitive match for "vertical" | 975 // If name is a case-sensitive match for "vertical" |
| 980 // 1. If value is a case-sensitive match for the string "rl", then | 976 // 1. If value is a case-sensitive match for the string "rl", then |
| 981 // let cue's text track cue writing direction be vertical | 977 // let cue's WebVTT cue writing direction be vertical |
| 982 // growing left. | 978 // growing left. |
| 983 if (input.scanRun(valueRun, verticalGrowingLeftKeyword())) | 979 if (input.scanRun(valueRun, verticalGrowingLeftKeyword())) |
| 984 m_writingDirection = VerticalGrowingLeft; | 980 m_writingDirection = VerticalGrowingLeft; |
| 985 | 981 |
| 986 // 2. Otherwise, if value is a case-sensitive match for the string | 982 // 2. Otherwise, if value is a case-sensitive match for the string |
| 987 // "lr", then let cue's text track cue writing direction be | 983 // "lr", then let cue's WebVTT cue writing direction be |
| 988 // vertical growing right. | 984 // vertical growing right. |
| 989 else if (input.scanRun(valueRun, verticalGrowingRightKeyword())) | 985 else if (input.scanRun(valueRun, verticalGrowingRightKeyword())) |
| 990 m_writingDirection = VerticalGrowingRight; | 986 m_writingDirection = VerticalGrowingRight; |
| 991 break; | 987 break; |
| 992 } | 988 } |
| 993 case Line: { | 989 case Line: { |
| 994 // If name is a case-sensitive match for "line" | 990 // If name is a case-sensitive match for "line" |
| 995 // Steps 1 - 2 skipped. | 991 // Steps 1 - 2 skipped. |
| 996 float number; | 992 float number; |
| 997 // 3. If linepos does not contain at least one ASCII digit, then | 993 // 3. If linepos does not contain at least one ASCII digit, then |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1014 bool isNegative = input.scan('-'); | 1010 bool isNegative = input.scan('-'); |
| 1015 int intLinePosition; | 1011 int intLinePosition; |
| 1016 if (!input.scanDigits(intLinePosition)) | 1012 if (!input.scanDigits(intLinePosition)) |
| 1017 break; | 1013 break; |
| 1018 // 3. Interpret linepos as a (potentially signed) integer, and l et | 1014 // 3. Interpret linepos as a (potentially signed) integer, and l et |
| 1019 // number be that number. | 1015 // number be that number. |
| 1020 number = isNegative ? -intLinePosition : intLinePosition; | 1016 number = isNegative ? -intLinePosition : intLinePosition; |
| 1021 } | 1017 } |
| 1022 if (!input.isAt(valueRun.end())) | 1018 if (!input.isAt(valueRun.end())) |
| 1023 break; | 1019 break; |
| 1024 // 5. Let cue's text track cue line position be number. | 1020 // 5. Let cue's WebVTT cue line be number. |
| 1025 m_linePosition = number; | 1021 m_linePosition = number; |
| 1026 // 6. If the last character in linepos is a U+0025 PERCENT SIGN | 1022 // 6. If the last character in linepos is a U+0025 PERCENT SIGN |
| 1027 // character (%), then let cue's text track cue snap-to-lines | 1023 // character (%), then let cue's WebVTT cue snap-to-lines |
| 1028 // flag be false. Otherwise, let it be true. | 1024 // flag be false. Otherwise, let it be true. |
| 1029 m_snapToLines = !isPercentage; | 1025 m_snapToLines = !isPercentage; |
| 1030 // Steps 7 - 9 skipped. | 1026 // Steps 7 - 9 skipped. |
| 1031 break; | 1027 break; |
| 1032 } | 1028 } |
| 1033 case Position: { | 1029 case Position: { |
| 1034 // If name is a case-sensitive match for "position". | 1030 // If name is a case-sensitive match for "position". |
| 1035 float number; | 1031 float number; |
| 1036 // Steps 1 - 2 skipped. | 1032 // Steps 1 - 2 skipped. |
| 1037 // 3. If parse a percentage string from colpos doesn't fail, let | 1033 // 3. If parse a percentage string from colpos doesn't fail, let |
| 1038 // number be the returned percentage, otherwise jump to the step | 1034 // number be the returned percentage, otherwise jump to the step |
| 1039 // labeled next setting (text track cue text position's value | 1035 // labeled next setting (text track cue text position's value |
| 1040 // remains the special value auto). | 1036 // remains the special value auto). |
| 1041 if (!scanPercentage(input, number)) | 1037 if (!scanPercentage(input, number)) |
| 1042 break; | 1038 break; |
| 1043 if (!input.isAt(valueRun.end())) | 1039 if (!input.isAt(valueRun.end())) |
| 1044 break; | 1040 break; |
| 1045 // 4. Let cue's text track cue text position be number. | 1041 // 4. Let cue's cue position be number. |
| 1046 m_textPosition = number; | 1042 m_textPosition = number; |
| 1047 // Steps 5 - 7 skipped. | 1043 // Steps 5 - 7 skipped. |
| 1048 break; | 1044 break; |
| 1049 } | 1045 } |
| 1050 case Size: { | 1046 case Size: { |
| 1051 // If name is a case-sensitive match for "size" | 1047 // If name is a case-sensitive match for "size" |
| 1052 float number; | 1048 float number; |
| 1053 // 1. If parse a percentage string from value doesn't fail, let | 1049 // 1. If parse a percentage string from value doesn't fail, let |
| 1054 // number be the returned percentage, otherwise jump to the step | 1050 // number be the returned percentage, otherwise jump to the step |
| 1055 // labeled next setting. | 1051 // labeled next setting. |
| 1056 if (!scanPercentage(input, number)) | 1052 if (!scanPercentage(input, number)) |
| 1057 break; | 1053 break; |
| 1058 if (!input.isAt(valueRun.end())) | 1054 if (!input.isAt(valueRun.end())) |
| 1059 break; | 1055 break; |
| 1060 // 2. Let cue's text track cue size be number. | 1056 // 2. Let cue's WebVTT cue size be number. |
| 1061 m_cueSize = number; | 1057 m_cueSize = number; |
| 1062 break; | 1058 break; |
| 1063 } | 1059 } |
| 1064 case Align: { | 1060 case Align: { |
| 1065 // If name is a case-sensitive match for "align" | 1061 // If name is a case-sensitive match for "align" |
| 1066 // 1. If value is a case-sensitive match for the string "start", | 1062 // 1. If value is a case-sensitive match for the string "start", |
| 1067 // then let cue's text track cue alignment be start alignment. | 1063 // then let cue's WebVTT cue text alignment be start alignment. |
| 1068 if (input.scanRun(valueRun, startKeyword())) | 1064 if (input.scanRun(valueRun, startKeyword())) |
| 1069 m_cueAlignment = Start; | 1065 m_cueAlignment = Start; |
| 1070 | 1066 |
| 1071 // 2. If value is a case-sensitive match for the string "middle", | 1067 // 2. If value is a case-sensitive match for the string "middle", |
| 1072 // then let cue's text track cue alignment be middle alignment. | 1068 // then let cue's WebVTT cue text alignment be middle alignment. |
| 1073 else if (input.scanRun(valueRun, middleKeyword())) | 1069 else if (input.scanRun(valueRun, middleKeyword())) |
| 1074 m_cueAlignment = Middle; | 1070 m_cueAlignment = Middle; |
| 1075 | 1071 |
| 1076 // 3. If value is a case-sensitive match for the string "end", then | 1072 // 3. If value is a case-sensitive match for the string "end", then |
| 1077 // let cue's text track cue alignment be end alignment. | 1073 // let cue's WebVTT cue text alignment be end alignment. |
| 1078 else if (input.scanRun(valueRun, endKeyword())) | 1074 else if (input.scanRun(valueRun, endKeyword())) |
| 1079 m_cueAlignment = End; | 1075 m_cueAlignment = End; |
| 1080 | 1076 |
| 1081 // 4. If value is a case-sensitive match for the string "left", | 1077 // 4. If value is a case-sensitive match for the string "left", |
| 1082 // then let cue's text track cue alignment be left alignment. | 1078 // then let cue's WebVTT cue text alignment be left alignment. |
| 1083 else if (input.scanRun(valueRun, leftKeyword())) | 1079 else if (input.scanRun(valueRun, leftKeyword())) |
| 1084 m_cueAlignment = Left; | 1080 m_cueAlignment = Left; |
| 1085 | 1081 |
| 1086 // 5. If value is a case-sensitive match for the string "right", | 1082 // 5. If value is a case-sensitive match for the string "right", |
| 1087 // then let cue's text track cue alignment be right alignment. | 1083 // then let cue's WebVTT cue text alignment be right alignment. |
| 1088 else if (input.scanRun(valueRun, rightKeyword())) | 1084 else if (input.scanRun(valueRun, rightKeyword())) |
| 1089 m_cueAlignment = Right; | 1085 m_cueAlignment = Right; |
| 1090 break; | 1086 break; |
| 1091 } | 1087 } |
| 1092 case RegionId: | 1088 case RegionId: |
| 1093 m_regionId = input.extractString(valueRun); | 1089 m_regionId = input.extractString(valueRun); |
| 1094 break; | 1090 break; |
| 1095 case None: | 1091 case None: |
| 1096 break; | 1092 break; |
| 1097 } | 1093 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1146 | 1142 |
| 1147 DEFINE_TRACE(VTTCue) | 1143 DEFINE_TRACE(VTTCue) |
| 1148 { | 1144 { |
| 1149 visitor->trace(m_vttNodeTree); | 1145 visitor->trace(m_vttNodeTree); |
| 1150 visitor->trace(m_cueBackgroundBox); | 1146 visitor->trace(m_cueBackgroundBox); |
| 1151 visitor->trace(m_displayTree); | 1147 visitor->trace(m_displayTree); |
| 1152 TextTrackCue::trace(visitor); | 1148 TextTrackCue::trace(visitor); |
| 1153 } | 1149 } |
| 1154 | 1150 |
| 1155 } // namespace blink | 1151 } // namespace blink |
| OLD | NEW |