| 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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 { | 799 { |
| 791 ASSERT(track() && track()->isRendered() && isActive()); | 800 ASSERT(track() && track()->isRendered() && isActive()); |
| 792 | 801 |
| 793 if (!m_displayTree) { | 802 if (!m_displayTree) { |
| 794 m_displayTree = VTTCueBox::create(document(), this); | 803 m_displayTree = VTTCueBox::create(document(), this); |
| 795 m_displayTree->appendChild(m_cueBackgroundBox); | 804 m_displayTree->appendChild(m_cueBackgroundBox); |
| 796 } | 805 } |
| 797 | 806 |
| 798 ASSERT(m_displayTree->firstChild() == m_cueBackgroundBox); | 807 ASSERT(m_displayTree->firstChild() == m_cueBackgroundBox); |
| 799 | 808 |
| 800 if (!m_displayTreeShouldChange) | 809 if (!m_displayTreeShouldChange) { |
| 810 // Apply updated user style overrides for text tracks when display tree
doesn't change. |
| 811 // This ensures that the track settings are refreshed when the video is |
| 812 // replayed or when the user slides back to an already rendered track. |
| 813 applyUserOverrideCSSProperties(); |
| 801 return m_displayTree; | 814 return m_displayTree; |
| 815 } |
| 802 | 816 |
| 803 createVTTNodeTree(); | 817 createVTTNodeTree(); |
| 804 | 818 |
| 805 m_cueBackgroundBox->removeChildren(); | 819 m_cueBackgroundBox->removeChildren(); |
| 806 m_vttNodeTree->cloneChildNodes(m_cueBackgroundBox.get()); | 820 m_vttNodeTree->cloneChildNodes(m_cueBackgroundBox.get()); |
| 807 | 821 |
| 808 VTTDisplayParameters displayParameters = calculateDisplayParameters(); | 822 VTTDisplayParameters displayParameters = calculateDisplayParameters(); |
| 809 m_displayTree->applyCSSProperties(displayParameters); | 823 m_displayTree->applyCSSProperties(displayParameters); |
| 810 | 824 |
| 825 // Apply user override settings for text tracks |
| 826 applyUserOverrideCSSProperties(); |
| 827 |
| 811 m_displayTreeShouldChange = false; | 828 m_displayTreeShouldChange = false; |
| 812 | 829 |
| 813 return m_displayTree; | 830 return m_displayTree; |
| 814 } | 831 } |
| 815 | 832 |
| 816 void VTTCue::removeDisplayTree(RemovalNotification removalNotification) | 833 void VTTCue::removeDisplayTree(RemovalNotification removalNotification) |
| 817 { | 834 { |
| 818 if (removalNotification == NotifyRegion && track()->regions()) { | 835 if (removalNotification == NotifyRegion && track()->regions()) { |
| 819 // The region needs to be informed about the cue removal. | 836 // The region needs to be informed about the cue removal. |
| 820 VTTRegion* region = track()->regions()->getRegionById(m_regionId); | 837 VTTRegion* region = track()->regions()->getRegionById(m_regionId); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 } | 1110 } |
| 1094 | 1111 |
| 1095 DEFINE_TRACE(VTTCue) | 1112 DEFINE_TRACE(VTTCue) |
| 1096 { | 1113 { |
| 1097 visitor->trace(m_vttNodeTree); | 1114 visitor->trace(m_vttNodeTree); |
| 1098 visitor->trace(m_cueBackgroundBox); | 1115 visitor->trace(m_cueBackgroundBox); |
| 1099 visitor->trace(m_displayTree); | 1116 visitor->trace(m_displayTree); |
| 1100 TextTrackCue::trace(visitor); | 1117 TextTrackCue::trace(visitor); |
| 1101 } | 1118 } |
| 1102 | 1119 |
| 1120 void VTTCue::applyUserOverrideCSSProperties() |
| 1121 { |
| 1122 Settings* settings = document().settings(); |
| 1123 if (!settings) |
| 1124 return; |
| 1125 |
| 1126 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1127 CSSPropertyBackgroundColor, settings->textTrackBackgroundColor()); |
| 1128 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1129 CSSPropertyFontFamily, settings->textTrackFontFamily()); |
| 1130 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1131 CSSPropertyFontStyle, settings->textTrackFontStyle()); |
| 1132 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1133 CSSPropertyFontVariant, settings->textTrackFontVariant()); |
| 1134 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1135 CSSPropertyColor, settings->textTrackTextColor()); |
| 1136 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1137 CSSPropertyTextShadow, settings->textTrackTextShadow()); |
| 1138 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1139 CSSPropertyFontSize, settings->textTrackTextSize()); |
| 1140 } |
| 1141 |
| 1103 } // namespace blink | 1142 } // namespace blink |
| OLD | NEW |