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/rendering/RenderVTTCue.h" | 50 #include "core/rendering/RenderVTTCue.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(PassRefPtrWillBeRawPtr<HTMLDivEleme nt> element, | |
142 CSSPropertyID propertyID, const String& value) | |
143 { | |
144 if (value != "") { | |
fs
2015/02/18 09:36:46
Nit: !value.isEmpty()
srivats
2015/02/18 22:39:33
Done.
| |
145 element->setInlineStyleProperty(propertyID, value, true); | |
146 } | |
fs
2015/02/18 09:36:46
Nit: Drop {} (not needed for single statements)
srivats
2015/02/18 22:39:33
Done.
| |
147 } | |
148 | |
139 VTTCueBox::VTTCueBox(Document& document, VTTCue* cue) | 149 VTTCueBox::VTTCueBox(Document& document, VTTCue* cue) |
140 : HTMLDivElement(document) | 150 : HTMLDivElement(document) |
141 , m_cue(cue) | 151 , m_cue(cue) |
142 { | 152 { |
143 setShadowPseudoId(AtomicString("-webkit-media-text-track-display", AtomicStr ing::ConstructFromLiteral)); | 153 setShadowPseudoId(AtomicString("-webkit-media-text-track-display", AtomicStr ing::ConstructFromLiteral)); |
144 } | 154 } |
145 | 155 |
146 void VTTCueBox::applyCSSProperties(const VTTDisplayParameters& displayParameters ) | 156 void VTTCueBox::applyCSSProperties(const VTTDisplayParameters& displayParameters ) |
147 { | 157 { |
148 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79 916 | 158 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79 916 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 // of the way across the height of the video's rendering area, while | 209 // of the way across the height of the video's rendering area, while |
200 // maintaining the relative positions of the boxes in boxes to each | 210 // maintaining the relative positions of the boxes in boxes to each |
201 // other. | 211 // other. |
202 setInlineStyleProperty(CSSPropertyWebkitTransform, | 212 setInlineStyleProperty(CSSPropertyWebkitTransform, |
203 String::format("translate(-%.2f%%, -%.2f%%)", position.x(), position .y())); | 213 String::format("translate(-%.2f%%, -%.2f%%)", position.x(), position .y())); |
204 | 214 |
205 setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre); | 215 setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePre); |
206 } | 216 } |
207 } | 217 } |
208 | 218 |
219 void VTTCueBox::applyUserOverrideCSSProperties() | |
220 { | |
221 Settings* settings = document().settings(); | |
222 if (settings) { | |
223 // Override background color for the cue box | |
224 setInlineStylePropertyIfNotEmpty(this, CSSPropertyBackgroundColor, setti ngs->textTrackWindowColor()); | |
225 } | |
226 } | |
227 | |
209 LayoutObject* VTTCueBox::createRenderer(const LayoutStyle&) | 228 LayoutObject* VTTCueBox::createRenderer(const LayoutStyle&) |
210 { | 229 { |
211 return new RenderVTTCue(this); | 230 return new RenderVTTCue(this); |
212 } | 231 } |
213 | 232 |
214 void VTTCueBox::trace(Visitor* visitor) | 233 void VTTCueBox::trace(Visitor* visitor) |
215 { | 234 { |
216 visitor->trace(m_cue); | 235 visitor->trace(m_cue); |
217 HTMLDivElement::trace(visitor); | 236 HTMLDivElement::trace(visitor); |
218 } | 237 } |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 | 854 |
836 // FIXME(BUG 79916): Text runs must be wrapped according to the CSS | 855 // FIXME(BUG 79916): Text runs must be wrapped according to the CSS |
837 // line-wrapping rules, except that additionally, regardless of the value of | 856 // line-wrapping rules, except that additionally, regardless of the value of |
838 // the 'white-space' property, lines must be wrapped at the edge of their | 857 // the 'white-space' property, lines must be wrapped at the edge of their |
839 // containing blocks, even if doing so requires splitting a word where there | 858 // containing blocks, even if doing so requires splitting a word where there |
840 // is no line breaking opportunity. (Thus, normally text wraps as needed, | 859 // is no line breaking opportunity. (Thus, normally text wraps as needed, |
841 // but if there is a particularly long word, it does not overflow as it | 860 // but if there is a particularly long word, it does not overflow as it |
842 // normally would in CSS, it is instead forcibly wrapped at the box's edge.) | 861 // normally would in CSS, it is instead forcibly wrapped at the box's edge.) |
843 displayTree->applyCSSProperties(displayParameters); | 862 displayTree->applyCSSProperties(displayParameters); |
844 | 863 |
864 // Apply user override settings for text tracks and the cue box | |
865 applyUserOverrideCSSProperties(); | |
866 displayTree->applyUserOverrideCSSProperties(); | |
867 | |
845 m_displayTreeShouldChange = false; | 868 m_displayTreeShouldChange = false; |
846 | 869 |
847 // 10.15. Let cue's text track cue display state have the CSS boxes in | 870 // 10.15. Let cue's text track cue display state have the CSS boxes in |
848 // boxes. | 871 // boxes. |
849 return displayTree.release(); | 872 return displayTree.release(); |
850 } | 873 } |
851 | 874 |
852 void VTTCue::removeDisplayTree() | 875 void VTTCue::removeDisplayTree() |
853 { | 876 { |
854 if (m_notifyRegion && track()->regions()) { | 877 if (m_notifyRegion && track()->regions()) { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1127 } | 1150 } |
1128 | 1151 |
1129 void VTTCue::trace(Visitor* visitor) | 1152 void VTTCue::trace(Visitor* visitor) |
1130 { | 1153 { |
1131 visitor->trace(m_vttNodeTree); | 1154 visitor->trace(m_vttNodeTree); |
1132 visitor->trace(m_cueBackgroundBox); | 1155 visitor->trace(m_cueBackgroundBox); |
1133 visitor->trace(m_displayTree); | 1156 visitor->trace(m_displayTree); |
1134 TextTrackCue::trace(visitor); | 1157 TextTrackCue::trace(visitor); |
1135 } | 1158 } |
1136 | 1159 |
1160 void VTTCue::applyUserOverrideCSSProperties() | |
1161 { | |
1162 Settings* settings = m_cueBackgroundBox->document().settings(); | |
1163 if (settings) { | |
1164 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
1165 CSSPropertyBackgroundColor, settings->textTrackBackgroundColor()); | |
1166 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
1167 CSSPropertyBackgroundColor, settings->textTrackBackgroundColor()); | |
1168 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
1169 CSSPropertyFontFamily, settings->textTrackFontFamily()); | |
1170 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
1171 CSSPropertyFontStyle, settings->textTrackFontStyle()); | |
1172 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
1173 CSSPropertyFontVariant, settings->textTrackFontVariant()); | |
1174 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
1175 CSSPropertyColor, settings->textTrackTextColor()); | |
1176 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
1177 CSSPropertyTextShadow, settings->textTrackTextShadow()); | |
1178 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
1179 CSSPropertyFontSize, settings->textTrackTextSize()); | |
1180 } | |
1181 } | |
1182 | |
1137 } // namespace blink | 1183 } // namespace blink |
OLD | NEW |