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 14 matching lines...) Expand all Loading... | |
| 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 27 * OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "core/html/track/vtt/VTTCue.h" | 31 #include "core/html/track/vtt/VTTCue.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ExceptionMessages.h" | 33 #include "bindings/core/v8/ExceptionMessages.h" |
| 34 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 34 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 35 #include "bindings/core/v8/UnionTypesCore.h" | |
| 35 #include "core/CSSPropertyNames.h" | 36 #include "core/CSSPropertyNames.h" |
| 36 #include "core/CSSValueKeywords.h" | 37 #include "core/CSSValueKeywords.h" |
| 37 #include "core/dom/DocumentFragment.h" | 38 #include "core/dom/DocumentFragment.h" |
| 38 #include "core/dom/NodeTraversal.h" | 39 #include "core/dom/NodeTraversal.h" |
| 39 #include "core/events/Event.h" | 40 #include "core/events/Event.h" |
| 40 #include "core/frame/UseCounter.h" | 41 #include "core/frame/UseCounter.h" |
| 41 #include "core/html/HTMLDivElement.h" | 42 #include "core/html/HTMLDivElement.h" |
| 42 #include "core/html/track/TextTrack.h" | 43 #include "core/html/track/TextTrack.h" |
| 43 #include "core/html/track/TextTrackCueList.h" | 44 #include "core/html/track/TextTrackCueList.h" |
| 44 #include "core/html/track/vtt/VTTElement.h" | 45 #include "core/html/track/vtt/VTTElement.h" |
| 45 #include "core/html/track/vtt/VTTParser.h" | 46 #include "core/html/track/vtt/VTTParser.h" |
| 46 #include "core/html/track/vtt/VTTRegionList.h" | 47 #include "core/html/track/vtt/VTTRegionList.h" |
| 47 #include "core/html/track/vtt/VTTScanner.h" | 48 #include "core/html/track/vtt/VTTScanner.h" |
| 48 #include "core/rendering/RenderVTTCue.h" | 49 #include "core/rendering/RenderVTTCue.h" |
| 50 #include "platform/FloatConversion.h" | |
| 49 #include "platform/RuntimeEnabledFeatures.h" | 51 #include "platform/RuntimeEnabledFeatures.h" |
| 50 #include "platform/text/BidiResolver.h" | 52 #include "platform/text/BidiResolver.h" |
| 51 #include "platform/text/TextRunIterator.h" | 53 #include "platform/text/TextRunIterator.h" |
| 52 #include "wtf/MathExtras.h" | 54 #include "wtf/MathExtras.h" |
| 53 #include "wtf/text/StringBuilder.h" | 55 #include "wtf/text/StringBuilder.h" |
| 54 | 56 |
| 55 namespace blink { | 57 namespace blink { |
| 56 | 58 |
| 59 static const float autoPosition = -1; | |
| 57 static const int undefinedPosition = -1; | 60 static const int undefinedPosition = -1; |
| 58 static const int undefinedSize = -1; | 61 static const int undefinedSize = -1; |
| 59 | 62 |
| 60 static const CSSValueID displayWritingModeMap[] = { | 63 static const CSSValueID displayWritingModeMap[] = { |
| 61 CSSValueHorizontalTb, CSSValueVerticalRl, CSSValueVerticalLr | 64 CSSValueHorizontalTb, CSSValueVerticalRl, CSSValueVerticalLr |
| 62 }; | 65 }; |
| 63 static_assert(WTF_ARRAY_LENGTH(displayWritingModeMap) == VTTCue::NumberOfWriting Directions, | 66 static_assert(WTF_ARRAY_LENGTH(displayWritingModeMap) == VTTCue::NumberOfWriting Directions, |
| 64 "displayWritingModeMap should have the same number of elements as VTTCue::Nu mberOfWritingDirections"); | 67 "displayWritingModeMap should have the same number of elements as VTTCue::Nu mberOfWritingDirections"); |
| 65 | 68 |
| 66 static const CSSValueID displayAlignmentMap[] = { | 69 static const CSSValueID displayAlignmentMap[] = { |
| 67 CSSValueStart, CSSValueCenter, CSSValueEnd, CSSValueLeft, CSSValueRight | 70 CSSValueStart, CSSValueCenter, CSSValueEnd, CSSValueLeft, CSSValueRight |
| 68 }; | 71 }; |
| 69 static_assert(WTF_ARRAY_LENGTH(displayAlignmentMap) == VTTCue::NumberOfAlignment s, | 72 static_assert(WTF_ARRAY_LENGTH(displayAlignmentMap) == VTTCue::NumberOfAlignment s, |
| 70 "displayAlignmentMap should have the same number of elements as VTTCue::Numb erOfAlignments"); | 73 "displayAlignmentMap should have the same number of elements as VTTCue::Numb erOfAlignments"); |
| 71 | 74 |
| 75 static const String& autoKeyword() | |
| 76 { | |
| 77 DEFINE_STATIC_LOCAL(const String, autoString, ("auto")); | |
| 78 return autoString; | |
| 79 } | |
| 80 | |
| 72 static const String& startKeyword() | 81 static const String& startKeyword() |
| 73 { | 82 { |
| 74 DEFINE_STATIC_LOCAL(const String, start, ("start")); | 83 DEFINE_STATIC_LOCAL(const String, start, ("start")); |
| 75 return start; | 84 return start; |
| 76 } | 85 } |
| 77 | 86 |
| 78 static const String& middleKeyword() | 87 static const String& middleKeyword() |
| 79 { | 88 { |
| 80 DEFINE_STATIC_LOCAL(const String, middle, ("middle")); | 89 DEFINE_STATIC_LOCAL(const String, middle, ("middle")); |
| 81 return middle; | 90 return middle; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 109 DEFINE_STATIC_LOCAL(const String, verticalrl, ("rl")); | 118 DEFINE_STATIC_LOCAL(const String, verticalrl, ("rl")); |
| 110 return verticalrl; | 119 return verticalrl; |
| 111 } | 120 } |
| 112 | 121 |
| 113 static const String& verticalGrowingRightKeyword() | 122 static const String& verticalGrowingRightKeyword() |
| 114 { | 123 { |
| 115 DEFINE_STATIC_LOCAL(const String, verticallr, ("lr")); | 124 DEFINE_STATIC_LOCAL(const String, verticallr, ("lr")); |
| 116 return verticallr; | 125 return verticallr; |
| 117 } | 126 } |
| 118 | 127 |
| 119 static bool isInvalidPercentage(int value, ExceptionState& exceptionState) | 128 template<typename NumberType> |
| 129 static bool isInvalidPercentage(NumberType value, ExceptionState& exceptionState ) | |
| 120 { | 130 { |
| 121 if (value < 0 || value > 100) { | 131 if (value < 0 || value > 100) { |
| 122 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange("value", value, 0, ExceptionMessages::InclusiveBound, 100, Excepti onMessages::InclusiveBound)); | 132 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde xOutsideRange<NumberType>("value", value, 0, ExceptionMessages::InclusiveBound, 100, ExceptionMessages::InclusiveBound)); |
| 123 return true; | 133 return true; |
| 124 } | 134 } |
| 125 return false; | 135 return false; |
| 126 } | 136 } |
| 127 | 137 |
| 128 VTTCueBox::VTTCueBox(Document& document, VTTCue* cue) | 138 VTTCueBox::VTTCueBox(Document& document, VTTCue* cue) |
| 129 : HTMLDivElement(document) | 139 : HTMLDivElement(document) |
| 130 , m_cue(cue) | 140 , m_cue(cue) |
| 131 { | 141 { |
| 132 setShadowPseudoId(AtomicString("-webkit-media-text-track-display", AtomicStr ing::ConstructFromLiteral)); | 142 setShadowPseudoId(AtomicString("-webkit-media-text-track-display", AtomicStr ing::ConstructFromLiteral)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 { | 214 { |
| 205 visitor->trace(m_cue); | 215 visitor->trace(m_cue); |
| 206 HTMLDivElement::trace(visitor); | 216 HTMLDivElement::trace(visitor); |
| 207 } | 217 } |
| 208 | 218 |
| 209 VTTCue::VTTCue(Document& document, double startTime, double endTime, const Strin g& text) | 219 VTTCue::VTTCue(Document& document, double startTime, double endTime, const Strin g& text) |
| 210 : TextTrackCue(startTime, endTime) | 220 : TextTrackCue(startTime, endTime) |
| 211 , m_text(text) | 221 , m_text(text) |
| 212 , m_linePosition(undefinedPosition) | 222 , m_linePosition(undefinedPosition) |
| 213 , m_computedLinePosition(undefinedPosition) | 223 , m_computedLinePosition(undefinedPosition) |
| 214 , m_textPosition(50) | 224 , m_textPosition(autoPosition) |
| 215 , m_cueSize(100) | 225 , m_cueSize(100) |
| 216 , m_writingDirection(Horizontal) | 226 , m_writingDirection(Horizontal) |
| 217 , m_cueAlignment(Middle) | 227 , m_cueAlignment(Middle) |
| 218 , m_vttNodeTree(nullptr) | 228 , m_vttNodeTree(nullptr) |
| 219 , m_cueBackgroundBox(HTMLDivElement::create(document)) | 229 , m_cueBackgroundBox(HTMLDivElement::create(document)) |
| 220 , m_displayDirection(CSSValueLtr) | 230 , m_displayDirection(CSSValueLtr) |
| 221 , m_displaySize(undefinedSize) | 231 , m_displaySize(undefinedSize) |
| 222 , m_snapToLines(true) | 232 , m_snapToLines(true) |
| 223 , m_displayTreeShouldChange(true) | 233 , m_displayTreeShouldChange(true) |
| 224 , m_notifyRegion(true) | 234 , m_notifyRegion(true) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 // Otherwise, set the text track cue line position to the new value. | 327 // Otherwise, set the text track cue line position to the new value. |
| 318 if (m_linePosition == position) | 328 if (m_linePosition == position) |
| 319 return; | 329 return; |
| 320 | 330 |
| 321 cueWillChange(); | 331 cueWillChange(); |
| 322 m_linePosition = position; | 332 m_linePosition = position; |
| 323 m_computedLinePosition = calculateComputedLinePosition(); | 333 m_computedLinePosition = calculateComputedLinePosition(); |
| 324 cueDidChange(); | 334 cueDidChange(); |
| 325 } | 335 } |
| 326 | 336 |
| 327 void VTTCue::setPosition(int position, ExceptionState& exceptionState) | 337 bool VTTCue::textPositionIsAuto() const |
| 328 { | 338 { |
| 329 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-ele ment.html#dom-texttrackcue-position | 339 return m_textPosition == autoPosition; |
| 330 // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception. | 340 } |
| 331 // Otherwise, set the text track cue text position to the new value. | 341 |
| 332 if (isInvalidPercentage(position, exceptionState)) | 342 void VTTCue::position(DoubleOrString& result) const |
| 333 return; | 343 { |
| 344 if (textPositionIsAuto()) | |
| 345 result.setString(autoKeyword()); | |
| 346 else | |
| 347 result.setDouble(m_textPosition); | |
| 348 } | |
| 349 | |
| 350 void VTTCue::setPosition(const DoubleOrString& position, ExceptionState& excepti onState) | |
| 351 { | |
| 352 float specifiedPosition = autoPosition; | |
| 353 if (position.isString()) { | |
| 354 // FIXME: Would be handled by bindings if the union had AutoKeyword and not DOMString. | |
| 355 if (position.getAsString() != autoKeyword()) | |
|
philipj_slow
2015/01/15 09:08:57
This should throw a TypeError, or whatever cue.ali
fs
2015/01/15 10:07:16
No, assigning an "invalid" enum value to an attrib
philipj_slow
2015/01/19 14:44:26
Acknowledged.
fs
2015/01/19 18:10:40
Actually, now I'm not so sure anymore... [1] (step
| |
| 356 return; | |
| 357 } else { | |
| 358 ASSERT(position.isDouble()); | |
| 359 double doublePosition = position.getAsDouble(); | |
| 360 | |
| 361 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video -element.html#dom-texttrackcue-position | |
|
philipj_slow
2015/01/15 09:08:57
Broken link, should be http://dev.w3.org/html5/web
| |
| 362 // On setting, if the new value is negative or greater than 100, then th row an IndexSizeError exception. | |
| 363 // Otherwise, set the text track cue text position to the new value. | |
| 364 if (isInvalidPercentage(doublePosition, exceptionState)) | |
| 365 return; | |
| 366 | |
| 367 specifiedPosition = narrowPrecisionToFloat(doublePosition); | |
| 368 } | |
| 334 | 369 |
| 335 // Otherwise, set the text track cue line position to the new value. | 370 // Otherwise, set the text track cue line position to the new value. |
| 336 if (m_textPosition == position) | 371 if (m_textPosition == specifiedPosition) |
| 337 return; | 372 return; |
| 338 | 373 |
| 339 cueWillChange(); | 374 cueWillChange(); |
| 340 m_textPosition = position; | 375 m_textPosition = specifiedPosition; |
| 341 cueDidChange(); | 376 cueDidChange(); |
| 342 } | 377 } |
| 343 | 378 |
| 344 void VTTCue::setSize(int size, ExceptionState& exceptionState) | 379 void VTTCue::setSize(int size, ExceptionState& exceptionState) |
| 345 { | 380 { |
| 346 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-ele ment.html#dom-texttrackcue-size | 381 // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-ele ment.html#dom-texttrackcue-size |
| 347 // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError | 382 // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError |
| 348 // exception. Otherwise, set the text track cue size to the new value. | 383 // exception. Otherwise, set the text track cue size to the new value. |
| 349 if (isInvalidPercentage(size, exceptionState)) | 384 if (isInvalidPercentage(size, exceptionState)) |
| 350 return; | 385 return; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 node = NodeTraversal::nextSkippingChildren(*node); | 582 node = NodeTraversal::nextSkippingChildren(*node); |
| 548 continue; | 583 continue; |
| 549 } | 584 } |
| 550 } | 585 } |
| 551 | 586 |
| 552 node = NodeTraversal::next(*node); | 587 node = NodeTraversal::next(*node); |
| 553 } | 588 } |
| 554 return isLeftToRightDirection(textDirection) ? CSSValueLtr : CSSValueRtl; | 589 return isLeftToRightDirection(textDirection) ? CSSValueLtr : CSSValueRtl; |
| 555 } | 590 } |
| 556 | 591 |
| 592 int VTTCue::calculateComputedTextPosition() const | |
| 593 { | |
| 594 // http://dev.w3.org/html5/webvtt/#dfn-text-track-cue-computed-text-position | |
| 595 | |
| 596 // 1. If the text track cue text position is numeric, then return the value | |
| 597 // of the text track cue text position and abort these steps. (Otherwise, | |
| 598 // the text track cue text position is the special value auto.) | |
| 599 if (!textPositionIsAuto()) | |
| 600 return static_cast<int>(m_textPosition); | |
|
philipj_slow
2015/01/15 09:08:57
Per spec there is no rounding of position to integ
fs
2015/01/15 10:07:16
I was trying to avoid "two steps at once" here by
philipj_slow
2015/01/19 14:44:26
As long as the whole change ends up in the same mi
fs
2015/01/19 15:09:05
Yes, that should be feasible. I'm currently lookin
| |
| 601 | |
| 602 switch (m_cueAlignment) { | |
| 603 // 2. If the text track cue text alignment is start or left, return 0 and ab ort these steps. | |
| 604 case Start: | |
| 605 case Left: | |
| 606 return 0; | |
| 607 // 3. If the text track cue text alignment is end or right, return 100 and a bort these steps. | |
| 608 case End: | |
| 609 case Right: | |
| 610 return 100; | |
| 611 // 4. If the text track cue text alignment is middle, return 50 and abort th ese steps. | |
| 612 case Middle: | |
| 613 return 50; | |
| 614 default: | |
| 615 ASSERT_NOT_REACHED(); | |
| 616 return 0; | |
| 617 } | |
| 618 } | |
| 619 | |
| 557 void VTTCue::calculateDisplayParameters() | 620 void VTTCue::calculateDisplayParameters() |
| 558 { | 621 { |
| 559 createVTTNodeTree(); | 622 createVTTNodeTree(); |
| 560 | 623 |
| 561 // Steps 10.2, 10.3 | 624 // Steps 10.2, 10.3 |
| 562 m_displayDirection = determineTextDirection(m_vttNodeTree.get()); | 625 m_displayDirection = determineTextDirection(m_vttNodeTree.get()); |
| 563 | 626 |
| 564 if (m_displayDirection == CSSValueRtl) | 627 if (m_displayDirection == CSSValueRtl) |
| 565 UseCounter::count(document(), UseCounter::VTTCueRenderRtl); | 628 UseCounter::count(document(), UseCounter::VTTCueRenderRtl); |
| 566 | 629 |
| 567 // 10.4 If the text track cue writing direction is horizontal, then let | 630 // 10.4 If the text track cue writing direction is horizontal, then let |
| 568 // block-flow be 'tb'. Otherwise, if the text track cue writing direction is | 631 // block-flow be 'tb'. Otherwise, if the text track cue writing direction is |
| 569 // vertical growing left, then let block-flow be 'lr'. Otherwise, the text | 632 // vertical growing left, then let block-flow be 'lr'. Otherwise, the text |
| 570 // track cue writing direction is vertical growing right; let block-flow be | 633 // track cue writing direction is vertical growing right; let block-flow be |
| 571 // 'rl'. | 634 // 'rl'. |
| 572 | 635 |
| 573 // The above step is done through the writing direction static map. | 636 // The above step is done through the writing direction static map. |
| 574 | 637 |
| 575 // 10.5 Determine the value of maximum size for cue as per the appropriate | 638 // 10.5 Determine the value of maximum size for cue as per the appropriate |
| 576 // rules from the following list: | 639 // rules from the following list: |
| 577 int maximumSize = m_textPosition; | 640 int computedTextPosition = calculateComputedTextPosition(); |
| 641 int maximumSize = computedTextPosition; | |
| 578 if ((m_writingDirection == Horizontal && m_cueAlignment == Start && m_displa yDirection == CSSValueLtr) | 642 if ((m_writingDirection == Horizontal && m_cueAlignment == Start && m_displa yDirection == CSSValueLtr) |
| 579 || (m_writingDirection == Horizontal && m_cueAlignment == End && m_displ ayDirection == CSSValueRtl) | 643 || (m_writingDirection == Horizontal && m_cueAlignment == End && m_displ ayDirection == CSSValueRtl) |
| 580 || (m_writingDirection == Horizontal && m_cueAlignment == Left) | 644 || (m_writingDirection == Horizontal && m_cueAlignment == Left) |
| 581 || (m_writingDirection == VerticalGrowingLeft && (m_cueAlignment == Star t || m_cueAlignment == Left)) | 645 || (m_writingDirection == VerticalGrowingLeft && (m_cueAlignment == Star t || m_cueAlignment == Left)) |
| 582 || (m_writingDirection == VerticalGrowingRight && (m_cueAlignment == Sta rt || m_cueAlignment == Left))) { | 646 || (m_writingDirection == VerticalGrowingRight && (m_cueAlignment == Sta rt || m_cueAlignment == Left))) { |
| 583 maximumSize = 100 - m_textPosition; | 647 maximumSize = 100 - computedTextPosition; |
| 584 } else if ((m_writingDirection == Horizontal && m_cueAlignment == End && m_d isplayDirection == CSSValueLtr) | 648 } else if ((m_writingDirection == Horizontal && m_cueAlignment == End && m_d isplayDirection == CSSValueLtr) |
| 585 || (m_writingDirection == Horizontal && m_cueAlignment == Start && m_dis playDirection == CSSValueRtl) | 649 || (m_writingDirection == Horizontal && m_cueAlignment == Start && m_dis playDirection == CSSValueRtl) |
| 586 || (m_writingDirection == Horizontal && m_cueAlignment == Right) | 650 || (m_writingDirection == Horizontal && m_cueAlignment == Right) |
| 587 || (m_writingDirection == VerticalGrowingLeft && (m_cueAlignment == End || m_cueAlignment == Right)) | 651 || (m_writingDirection == VerticalGrowingLeft && (m_cueAlignment == End || m_cueAlignment == Right)) |
| 588 || (m_writingDirection == VerticalGrowingRight && (m_cueAlignment == End || m_cueAlignment == Right))) { | 652 || (m_writingDirection == VerticalGrowingRight && (m_cueAlignment == End || m_cueAlignment == Right))) { |
| 589 maximumSize = m_textPosition; | 653 maximumSize = computedTextPosition; |
| 590 } else if (m_cueAlignment == Middle) { | 654 } else if (m_cueAlignment == Middle) { |
| 591 maximumSize = m_textPosition <= 50 ? m_textPosition : (100 - m_textPosit ion); | 655 maximumSize = computedTextPosition <= 50 ? computedTextPosition : (100 - computedTextPosition); |
| 592 maximumSize = maximumSize * 2; | 656 maximumSize = maximumSize * 2; |
| 593 } else { | 657 } else { |
| 594 ASSERT_NOT_REACHED(); | 658 ASSERT_NOT_REACHED(); |
| 595 } | 659 } |
| 596 | 660 |
| 597 // 10.6 If the text track cue size is less than maximum size, then let size | 661 // 10.6 If the text track cue size is less than maximum size, then let size |
| 598 // be text track cue size. Otherwise, let size be maximum size. | 662 // be text track cue size. Otherwise, let size be maximum size. |
| 599 m_displaySize = std::min(m_cueSize, maximumSize); | 663 m_displaySize = std::min(m_cueSize, maximumSize); |
| 600 | 664 |
| 601 // FIXME: Understand why step 10.7 is missing (just a copy/paste error?) | 665 // FIXME: Understand why step 10.7 is missing (just a copy/paste error?) |
| 602 // Could be done within a spec implementation check - http://crbug.com/30158 0 | 666 // Could be done within a spec implementation check - http://crbug.com/30158 0 |
| 603 | 667 |
| 604 // 10.8 Determine the value of x-position or y-position for cue as per the | 668 // 10.8 Determine the value of x-position or y-position for cue as per the |
| 605 // appropriate rules from the following list: | 669 // appropriate rules from the following list: |
| 606 if (m_writingDirection == Horizontal) { | 670 if (m_writingDirection == Horizontal) { |
| 607 switch (m_cueAlignment) { | 671 switch (m_cueAlignment) { |
| 608 case Start: | 672 case Start: |
| 609 if (m_displayDirection == CSSValueLtr) | 673 if (m_displayDirection == CSSValueLtr) |
| 610 m_displayPosition.first = m_textPosition; | 674 m_displayPosition.first = computedTextPosition; |
| 611 else | 675 else |
| 612 m_displayPosition.first = 100 - m_textPosition - m_displaySize; | 676 m_displayPosition.first = 100 - computedTextPosition - m_display Size; |
| 613 break; | 677 break; |
| 614 case End: | 678 case End: |
| 615 if (m_displayDirection == CSSValueRtl) | 679 if (m_displayDirection == CSSValueRtl) |
| 616 m_displayPosition.first = 100 - m_textPosition; | 680 m_displayPosition.first = 100 - computedTextPosition; |
| 617 else | 681 else |
| 618 m_displayPosition.first = m_textPosition - m_displaySize; | 682 m_displayPosition.first = computedTextPosition - m_displaySize; |
| 619 break; | 683 break; |
| 620 case Left: | 684 case Left: |
| 621 if (m_displayDirection == CSSValueLtr) | 685 if (m_displayDirection == CSSValueLtr) |
| 622 m_displayPosition.first = m_textPosition; | 686 m_displayPosition.first = computedTextPosition; |
| 623 else | 687 else |
| 624 m_displayPosition.first = 100 - m_textPosition; | 688 m_displayPosition.first = 100 - computedTextPosition; |
| 625 break; | 689 break; |
| 626 case Right: | 690 case Right: |
| 627 if (m_displayDirection == CSSValueLtr) | 691 if (m_displayDirection == CSSValueLtr) |
| 628 m_displayPosition.first = m_textPosition - m_displaySize; | 692 m_displayPosition.first = computedTextPosition - m_displaySize; |
| 629 else | 693 else |
| 630 m_displayPosition.first = 100 - m_textPosition - m_displaySize; | 694 m_displayPosition.first = 100 - computedTextPosition - m_display Size; |
| 631 break; | 695 break; |
| 632 case Middle: | 696 case Middle: |
| 633 if (m_displayDirection == CSSValueLtr) | 697 if (m_displayDirection == CSSValueLtr) |
| 634 m_displayPosition.first = m_textPosition - m_displaySize / 2; | 698 m_displayPosition.first = computedTextPosition - m_displaySize / 2; |
| 635 else | 699 else |
| 636 m_displayPosition.first = 100 - m_textPosition - m_displaySize / 2; | 700 m_displayPosition.first = 100 - computedTextPosition - m_display Size / 2; |
| 637 break; | 701 break; |
| 638 default: | 702 default: |
| 639 ASSERT_NOT_REACHED(); | 703 ASSERT_NOT_REACHED(); |
| 640 } | 704 } |
| 641 } else { | 705 } else { |
| 642 // Cases for m_writingDirection being VerticalGrowing{Left|Right} | 706 // Cases for m_writingDirection being VerticalGrowing{Left|Right} |
| 643 switch (m_cueAlignment) { | 707 switch (m_cueAlignment) { |
| 644 case Start: | 708 case Start: |
| 645 case Left: | 709 case Left: |
| 646 m_displayPosition.second = m_textPosition; | 710 m_displayPosition.second = computedTextPosition; |
| 647 break; | 711 break; |
| 648 case End: | 712 case End: |
| 649 case Right: | 713 case Right: |
| 650 m_displayPosition.second = m_textPosition - m_displaySize; | 714 m_displayPosition.second = computedTextPosition - m_displaySize; |
| 651 break; | 715 break; |
| 652 case Middle: | 716 case Middle: |
| 653 m_displayPosition.second = m_textPosition - m_displaySize / 2; | 717 m_displayPosition.second = computedTextPosition - m_displaySize / 2; |
| 654 break; | 718 break; |
| 655 default: | 719 default: |
| 656 ASSERT_NOT_REACHED(); | 720 ASSERT_NOT_REACHED(); |
| 657 } | 721 } |
| 658 } | 722 } |
| 659 | 723 |
| 660 // A text track cue has a text track cue computed line position whose value | 724 // A text track cue has a text track cue computed line position whose value |
| 661 // is defined in terms of the other aspects of the cue. | 725 // is defined in terms of the other aspects of the cue. |
| 662 m_computedLinePosition = calculateComputedLinePosition(); | 726 m_computedLinePosition = calculateComputedLinePosition(); |
| 663 | 727 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 786 | 850 |
| 787 if (m_writingDirection != Horizontal) | 851 if (m_writingDirection != Horizontal) |
| 788 UseCounter::count(document(), UseCounter::VTTCueRenderVertical); | 852 UseCounter::count(document(), UseCounter::VTTCueRenderVertical); |
| 789 | 853 |
| 790 if (!m_snapToLines) | 854 if (!m_snapToLines) |
| 791 UseCounter::count(document(), UseCounter::VTTCueRenderSnapToLinesFalse); | 855 UseCounter::count(document(), UseCounter::VTTCueRenderSnapToLinesFalse); |
| 792 | 856 |
| 793 if (m_linePosition != undefinedPosition) | 857 if (m_linePosition != undefinedPosition) |
| 794 UseCounter::count(document(), UseCounter::VTTCueRenderLineNotAuto); | 858 UseCounter::count(document(), UseCounter::VTTCueRenderLineNotAuto); |
| 795 | 859 |
| 796 if (m_textPosition != 50) | 860 if (textPositionIsAuto()) |
|
fs
2015/01/14 13:13:40
Changed this on the assumption that we want to che
philipj_slow
2015/01/15 09:08:57
Yeah. Too bad the name will suck, but oh well.
| |
| 797 UseCounter::count(document(), UseCounter::VTTCueRenderPositionNot50); | 861 UseCounter::count(document(), UseCounter::VTTCueRenderPositionNot50); |
| 798 | 862 |
| 799 if (m_cueSize != 100) | 863 if (m_cueSize != 100) |
| 800 UseCounter::count(document(), UseCounter::VTTCueRenderSizeNot100); | 864 UseCounter::count(document(), UseCounter::VTTCueRenderSizeNot100); |
| 801 | 865 |
| 802 if (m_cueAlignment != Middle) | 866 if (m_cueAlignment != Middle) |
| 803 UseCounter::count(document(), UseCounter::VTTCueRenderAlignNotMiddle); | 867 UseCounter::count(document(), UseCounter::VTTCueRenderAlignNotMiddle); |
| 804 | 868 |
| 805 RefPtrWillBeRawPtr<VTTCueBox> displayBox = getDisplayTree(videoSize); | 869 RefPtrWillBeRawPtr<VTTCueBox> displayBox = getDisplayTree(videoSize); |
| 806 VTTRegion* region = 0; | 870 VTTRegion* region = 0; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 825 container.appendChild(regionNode); | 889 container.appendChild(regionNode); |
| 826 | 890 |
| 827 region->appendVTTCueBox(displayBox); | 891 region->appendVTTCueBox(displayBox); |
| 828 } | 892 } |
| 829 } | 893 } |
| 830 | 894 |
| 831 std::pair<double, double> VTTCue::getPositionCoordinates() const | 895 std::pair<double, double> VTTCue::getPositionCoordinates() const |
| 832 { | 896 { |
| 833 // This method is used for setting x and y when snap to lines is not set. | 897 // This method is used for setting x and y when snap to lines is not set. |
| 834 std::pair<double, double> coordinates; | 898 std::pair<double, double> coordinates; |
| 899 int computedTextPosition = calculateComputedTextPosition(); | |
| 835 | 900 |
| 836 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) { | 901 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueLtr) { |
| 837 coordinates.first = m_textPosition; | 902 coordinates.first = computedTextPosition; |
| 838 coordinates.second = m_computedLinePosition; | 903 coordinates.second = m_computedLinePosition; |
| 839 | 904 |
| 840 return coordinates; | 905 return coordinates; |
| 841 } | 906 } |
| 842 | 907 |
| 843 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueRtl) { | 908 if (m_writingDirection == Horizontal && m_displayDirection == CSSValueRtl) { |
| 844 coordinates.first = 100 - m_textPosition; | 909 coordinates.first = 100 - computedTextPosition; |
| 845 coordinates.second = m_computedLinePosition; | 910 coordinates.second = m_computedLinePosition; |
| 846 | 911 |
| 847 return coordinates; | 912 return coordinates; |
| 848 } | 913 } |
| 849 | 914 |
| 850 if (m_writingDirection == VerticalGrowingLeft) { | 915 if (m_writingDirection == VerticalGrowingLeft) { |
| 851 coordinates.first = 100 - m_computedLinePosition; | 916 coordinates.first = 100 - m_computedLinePosition; |
| 852 coordinates.second = m_textPosition; | 917 coordinates.second = computedTextPosition; |
| 853 | 918 |
| 854 return coordinates; | 919 return coordinates; |
| 855 } | 920 } |
| 856 | 921 |
| 857 if (m_writingDirection == VerticalGrowingRight) { | 922 if (m_writingDirection == VerticalGrowingRight) { |
| 858 coordinates.first = m_computedLinePosition; | 923 coordinates.first = m_computedLinePosition; |
| 859 coordinates.second = m_textPosition; | 924 coordinates.second = computedTextPosition; |
| 860 | 925 |
| 861 return coordinates; | 926 return coordinates; |
| 862 } | 927 } |
| 863 | 928 |
| 864 ASSERT_NOT_REACHED(); | 929 ASSERT_NOT_REACHED(); |
| 865 | 930 |
| 866 return coordinates; | 931 return coordinates; |
| 867 } | 932 } |
| 868 | 933 |
| 869 VTTCue::CueSetting VTTCue::settingName(VTTScanner& input) | 934 VTTCue::CueSetting VTTCue::settingName(VTTScanner& input) |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1105 | 1170 |
| 1106 void VTTCue::trace(Visitor* visitor) | 1171 void VTTCue::trace(Visitor* visitor) |
| 1107 { | 1172 { |
| 1108 visitor->trace(m_vttNodeTree); | 1173 visitor->trace(m_vttNodeTree); |
| 1109 visitor->trace(m_cueBackgroundBox); | 1174 visitor->trace(m_cueBackgroundBox); |
| 1110 visitor->trace(m_displayTree); | 1175 visitor->trace(m_displayTree); |
| 1111 TextTrackCue::trace(visitor); | 1176 TextTrackCue::trace(visitor); |
| 1112 } | 1177 } |
| 1113 | 1178 |
| 1114 } // namespace blink | 1179 } // namespace blink |
| OLD | NEW |