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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 // If cue's line position is not auto or cue's size is not 100 or cue's | 1090 // If cue's line position is not auto or cue's size is not 100 or cue's |
1074 // writing direction is not horizontal, but cue's region identifier is not | 1091 // writing direction is not horizontal, but cue's region identifier is not |
1075 // the empty string, let cue's region identifier be the empty string. | 1092 // the empty string, let cue's region identifier be the empty string. |
1076 if (m_regionId.isEmpty()) | 1093 if (m_regionId.isEmpty()) |
1077 return; | 1094 return; |
1078 | 1095 |
1079 if (!lineIsAuto() || m_cueSize != 100 || m_writingDirection != Horizontal) | 1096 if (!lineIsAuto() || m_cueSize != 100 || m_writingDirection != Horizontal) |
1080 m_regionId = emptyString(); | 1097 m_regionId = emptyString(); |
1081 } | 1098 } |
1082 | 1099 |
| 1100 void VTTCue::applyUserOverrideCSSProperties() |
| 1101 { |
| 1102 Settings* settings = document().settings(); |
| 1103 if (!settings) |
| 1104 return; |
| 1105 |
| 1106 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1107 CSSPropertyBackgroundColor, settings->textTrackBackgroundColor()); |
| 1108 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1109 CSSPropertyFontFamily, settings->textTrackFontFamily()); |
| 1110 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1111 CSSPropertyFontStyle, settings->textTrackFontStyle()); |
| 1112 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1113 CSSPropertyFontVariant, settings->textTrackFontVariant()); |
| 1114 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1115 CSSPropertyColor, settings->textTrackTextColor()); |
| 1116 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1117 CSSPropertyTextShadow, settings->textTrackTextShadow()); |
| 1118 setInlineStylePropertyIfNotEmpty(*m_cueBackgroundBox, |
| 1119 CSSPropertyFontSize, settings->textTrackTextSize()); |
| 1120 } |
| 1121 |
1083 ExecutionContext* VTTCue::executionContext() const | 1122 ExecutionContext* VTTCue::executionContext() const |
1084 { | 1123 { |
1085 ASSERT(m_cueBackgroundBox); | 1124 ASSERT(m_cueBackgroundBox); |
1086 return m_cueBackgroundBox->executionContext(); | 1125 return m_cueBackgroundBox->executionContext(); |
1087 } | 1126 } |
1088 | 1127 |
1089 Document& VTTCue::document() const | 1128 Document& VTTCue::document() const |
1090 { | 1129 { |
1091 ASSERT(m_cueBackgroundBox); | 1130 ASSERT(m_cueBackgroundBox); |
1092 return m_cueBackgroundBox->document(); | 1131 return m_cueBackgroundBox->document(); |
1093 } | 1132 } |
1094 | 1133 |
1095 DEFINE_TRACE(VTTCue) | 1134 DEFINE_TRACE(VTTCue) |
1096 { | 1135 { |
1097 visitor->trace(m_vttNodeTree); | 1136 visitor->trace(m_vttNodeTree); |
1098 visitor->trace(m_cueBackgroundBox); | 1137 visitor->trace(m_cueBackgroundBox); |
1099 visitor->trace(m_displayTree); | 1138 visitor->trace(m_displayTree); |
1100 TextTrackCue::trace(visitor); | 1139 TextTrackCue::trace(visitor); |
1101 } | 1140 } |
1102 | 1141 |
1103 } // namespace blink | 1142 } // namespace blink |
OLD | NEW |