| 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 20 matching lines...) Expand all Loading... |
| 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 "bindings/core/v8/UnionTypesCore.h" |
| 36 #include "core/CSSPropertyNames.h" | 36 #include "core/CSSPropertyNames.h" |
| 37 #include "core/CSSValueKeywords.h" | 37 #include "core/CSSValueKeywords.h" |
| 38 #include "core/dom/DocumentFragment.h" | 38 #include "core/dom/DocumentFragment.h" |
| 39 #include "core/dom/NodeTraversal.h" | 39 #include "core/dom/NodeTraversal.h" |
| 40 #include "core/events/Event.h" | 40 #include "core/events/Event.h" |
| 41 #include "core/frame/Settings.h" |
| 41 #include "core/frame/UseCounter.h" | 42 #include "core/frame/UseCounter.h" |
| 42 #include "core/html/HTMLDivElement.h" | 43 #include "core/html/HTMLDivElement.h" |
| 43 #include "core/html/track/TextTrack.h" | 44 #include "core/html/track/TextTrack.h" |
| 44 #include "core/html/track/TextTrackCueList.h" | 45 #include "core/html/track/TextTrackCueList.h" |
| 45 #include "core/html/track/vtt/VTTElement.h" | 46 #include "core/html/track/vtt/VTTElement.h" |
| 46 #include "core/html/track/vtt/VTTParser.h" | 47 #include "core/html/track/vtt/VTTParser.h" |
| 47 #include "core/html/track/vtt/VTTRegionList.h" | 48 #include "core/html/track/vtt/VTTRegionList.h" |
| 48 #include "core/html/track/vtt/VTTScanner.h" | 49 #include "core/html/track/vtt/VTTScanner.h" |
| 49 #include "core/layout/LayoutVTTCue.h" | 50 #include "core/layout/LayoutVTTCue.h" |
| 50 #include "platform/FloatConversion.h" | 51 #include "platform/FloatConversion.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 130 |
| 130 static bool isInvalidPercentage(double value, ExceptionState& exceptionState) | 131 static bool isInvalidPercentage(double value, ExceptionState& exceptionState) |
| 131 { | 132 { |
| 132 if (isInvalidPercentage(value)) { | 133 if (isInvalidPercentage(value)) { |
| 133 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde
xOutsideRange<double>("value", value, 0, ExceptionMessages::InclusiveBound, 100,
ExceptionMessages::InclusiveBound)); | 134 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde
xOutsideRange<double>("value", value, 0, ExceptionMessages::InclusiveBound, 100,
ExceptionMessages::InclusiveBound)); |
| 134 return true; | 135 return true; |
| 135 } | 136 } |
| 136 return false; | 137 return false; |
| 137 } | 138 } |
| 138 | 139 |
| 140 // Sets inline CSS properties on passed in element if value is not an empty stri
ng |
| 141 static void setInlineStylePropertyIfNotEmpty(Element& element, |
| 142 CSSPropertyID propertyID, const String& value) |
| 143 { |
| 144 if (!value.isEmpty()) |
| 145 element.setInlineStyleProperty(propertyID, value); |
| 146 } |
| 147 |
| 139 VTTCueBox::VTTCueBox(Document& document, VTTCue* cue) | 148 VTTCueBox::VTTCueBox(Document& document, VTTCue* cue) |
| 140 : HTMLDivElement(document) | 149 : HTMLDivElement(document) |
| 141 , m_cue(cue) | 150 , m_cue(cue) |
| 142 { | 151 { |
| 143 setShadowPseudoId(AtomicString("-webkit-media-text-track-display", AtomicStr
ing::ConstructFromLiteral)); | 152 setShadowPseudoId(AtomicString("-webkit-media-text-track-display", AtomicStr
ing::ConstructFromLiteral)); |
| 144 } | 153 } |
| 145 | 154 |
| 146 void VTTCueBox::applyCSSProperties(const VTTDisplayParameters& displayParameters
) | 155 void VTTCueBox::applyCSSProperties(const VTTDisplayParameters& displayParameters
) |
| 147 { | 156 { |
| 148 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79
916 | 157 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79
916 |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 createVTTNodeTree(); | 802 createVTTNodeTree(); |
| 794 RefPtrWillBeRawPtr<DocumentFragment> referenceTree = DocumentFragment::creat
e(document()); | 803 RefPtrWillBeRawPtr<DocumentFragment> referenceTree = DocumentFragment::creat
e(document()); |
| 795 m_vttNodeTree->cloneChildNodes(referenceTree.get()); | 804 m_vttNodeTree->cloneChildNodes(referenceTree.get()); |
| 796 markFutureAndPastNodes(referenceTree.get(), startTime(), movieTime); | 805 markFutureAndPastNodes(referenceTree.get(), startTime(), movieTime); |
| 797 m_cueBackgroundBox->appendChild(referenceTree, ASSERT_NO_EXCEPTION); | 806 m_cueBackgroundBox->appendChild(referenceTree, ASSERT_NO_EXCEPTION); |
| 798 } | 807 } |
| 799 | 808 |
| 800 PassRefPtrWillBeRawPtr<VTTCueBox> VTTCue::getDisplayTree() | 809 PassRefPtrWillBeRawPtr<VTTCueBox> VTTCue::getDisplayTree() |
| 801 { | 810 { |
| 802 RefPtrWillBeRawPtr<VTTCueBox> displayTree(ensureDisplayTree()); | 811 RefPtrWillBeRawPtr<VTTCueBox> displayTree(ensureDisplayTree()); |
| 803 if (!m_displayTreeShouldChange || !track()->isRendered()) | 812 if (!m_displayTreeShouldChange || !track()->isRendered()) { |
| 813 // Apply updated user style overrides for already rendered text tracks. |
| 814 // This ensures that the track settings are refreshed when the video is |
| 815 // replayed or when the user slides back to an already rendered track. |
| 816 applyUserOverrideCSSProperties(); |
| 804 return displayTree.release(); | 817 return displayTree.release(); |
| 818 } |
| 805 | 819 |
| 806 createVTTNodeTree(); | 820 createVTTNodeTree(); |
| 807 | 821 |
| 808 // 10.1 - 10.10 | 822 // 10.1 - 10.10 |
| 809 VTTDisplayParameters displayParameters = calculateDisplayParameters(); | 823 VTTDisplayParameters displayParameters = calculateDisplayParameters(); |
| 810 | 824 |
| 811 // 10.11. Apply the terms of the CSS specifications to nodes within the | 825 // 10.11. Apply the terms of the CSS specifications to nodes within the |
| 812 // following constraints, thus obtaining a set of CSS boxes positioned | 826 // following constraints, thus obtaining a set of CSS boxes positioned |
| 813 // relative to an initial containing block: | 827 // relative to an initial containing block: |
| 814 displayTree->removeChildren(); | 828 displayTree->removeChildren(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 829 | 843 |
| 830 // FIXME(BUG 79916): Text runs must be wrapped according to the CSS | 844 // FIXME(BUG 79916): Text runs must be wrapped according to the CSS |
| 831 // line-wrapping rules, except that additionally, regardless of the value of | 845 // line-wrapping rules, except that additionally, regardless of the value of |
| 832 // the 'white-space' property, lines must be wrapped at the edge of their | 846 // the 'white-space' property, lines must be wrapped at the edge of their |
| 833 // containing blocks, even if doing so requires splitting a word where there | 847 // containing blocks, even if doing so requires splitting a word where there |
| 834 // is no line breaking opportunity. (Thus, normally text wraps as needed, | 848 // is no line breaking opportunity. (Thus, normally text wraps as needed, |
| 835 // but if there is a particularly long word, it does not overflow as it | 849 // but if there is a particularly long word, it does not overflow as it |
| 836 // normally would in CSS, it is instead forcibly wrapped at the box's edge.) | 850 // normally would in CSS, it is instead forcibly wrapped at the box's edge.) |
| 837 displayTree->applyCSSProperties(displayParameters); | 851 displayTree->applyCSSProperties(displayParameters); |
| 838 | 852 |
| 853 // Apply user override settings for text tracks |
| 854 applyUserOverrideCSSProperties(); |
| 855 |
| 839 m_displayTreeShouldChange = false; | 856 m_displayTreeShouldChange = false; |
| 840 | 857 |
| 841 // 10.15. Let cue's text track cue display state have the CSS boxes in | 858 // 10.15. Let cue's text track cue display state have the CSS boxes in |
| 842 // boxes. | 859 // boxes. |
| 843 return displayTree.release(); | 860 return displayTree.release(); |
| 844 } | 861 } |
| 845 | 862 |
| 846 void VTTCue::removeDisplayTree(RemovalNotification removalNotification) | 863 void VTTCue::removeDisplayTree(RemovalNotification removalNotification) |
| 847 { | 864 { |
| 848 if (removalNotification == NotifyRegion && track()->regions()) { | 865 if (removalNotification == NotifyRegion && track()->regions()) { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 } | 1138 } |
| 1122 | 1139 |
| 1123 DEFINE_TRACE(VTTCue) | 1140 DEFINE_TRACE(VTTCue) |
| 1124 { | 1141 { |
| 1125 visitor->trace(m_vttNodeTree); | 1142 visitor->trace(m_vttNodeTree); |
| 1126 visitor->trace(m_cueBackgroundBox); | 1143 visitor->trace(m_cueBackgroundBox); |
| 1127 visitor->trace(m_displayTree); | 1144 visitor->trace(m_displayTree); |
| 1128 TextTrackCue::trace(visitor); | 1145 TextTrackCue::trace(visitor); |
| 1129 } | 1146 } |
| 1130 | 1147 |
| 1148 void VTTCue::applyUserOverrideCSSProperties() |
| 1149 { |
| 1150 Settings* settings = document().settings(); |
| 1151 if (!settings) |
| 1152 return; |
| 1153 |
| 1154 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1155 CSSPropertyBackgroundColor, settings->textTrackBackgroundColor()); |
| 1156 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1157 CSSPropertyFontFamily, settings->textTrackFontFamily()); |
| 1158 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1159 CSSPropertyFontStyle, settings->textTrackFontStyle()); |
| 1160 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1161 CSSPropertyFontVariant, settings->textTrackFontVariant()); |
| 1162 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1163 CSSPropertyColor, settings->textTrackTextColor()); |
| 1164 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1165 CSSPropertyTextShadow, settings->textTrackTextShadow()); |
| 1166 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1167 CSSPropertyFontSize, settings->textTrackTextSize()); |
| 1168 } |
| 1169 |
| 1131 } // namespace blink | 1170 } // namespace blink |
| OLD | NEW |