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 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(PassRefPtrWillBeRawPtr<HTMLDivEleme nt> element, | |
|
philipj_slow
2015/03/17 02:22:31
Just Element& as the argument type is OK.
srivats
2015/03/18 01:58:13
Done.
| |
| 142 CSSPropertyID propertyID, const String& value) | |
| 143 { | |
| 144 if (!value.isEmpty()) | |
| 145 element->setInlineStyleProperty(propertyID, value, true); | |
| 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 829 | 838 |
| 830 // FIXME(BUG 79916): Text runs must be wrapped according to the CSS | 839 // FIXME(BUG 79916): Text runs must be wrapped according to the CSS |
| 831 // line-wrapping rules, except that additionally, regardless of the value of | 840 // 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 | 841 // 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 | 842 // containing blocks, even if doing so requires splitting a word where there |
| 834 // is no line breaking opportunity. (Thus, normally text wraps as needed, | 843 // 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 | 844 // 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.) | 845 // normally would in CSS, it is instead forcibly wrapped at the box's edge.) |
| 837 displayTree->applyCSSProperties(displayParameters); | 846 displayTree->applyCSSProperties(displayParameters); |
| 838 | 847 |
| 848 // Apply user override settings for text tracks | |
| 849 applyUserOverrideCSSProperties(); | |
| 850 | |
| 839 m_displayTreeShouldChange = false; | 851 m_displayTreeShouldChange = false; |
| 840 | 852 |
| 841 // 10.15. Let cue's text track cue display state have the CSS boxes in | 853 // 10.15. Let cue's text track cue display state have the CSS boxes in |
| 842 // boxes. | 854 // boxes. |
| 843 return displayTree.release(); | 855 return displayTree.release(); |
| 844 } | 856 } |
| 845 | 857 |
| 846 void VTTCue::removeDisplayTree(RemovalNotification removalNotification) | 858 void VTTCue::removeDisplayTree(RemovalNotification removalNotification) |
| 847 { | 859 { |
| 848 if (removalNotification == NotifyRegion && track()->regions()) { | 860 if (removalNotification == NotifyRegion && track()->regions()) { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1121 } | 1133 } |
| 1122 | 1134 |
| 1123 DEFINE_TRACE(VTTCue) | 1135 DEFINE_TRACE(VTTCue) |
| 1124 { | 1136 { |
| 1125 visitor->trace(m_vttNodeTree); | 1137 visitor->trace(m_vttNodeTree); |
| 1126 visitor->trace(m_cueBackgroundBox); | 1138 visitor->trace(m_cueBackgroundBox); |
| 1127 visitor->trace(m_displayTree); | 1139 visitor->trace(m_displayTree); |
| 1128 TextTrackCue::trace(visitor); | 1140 TextTrackCue::trace(visitor); |
| 1129 } | 1141 } |
| 1130 | 1142 |
| 1143 void VTTCue::applyUserOverrideCSSProperties() | |
| 1144 { | |
| 1145 Settings* settings = m_cueBackgroundBox->document().settings(); | |
|
philipj_slow
2015/03/17 02:22:31
You can use just document(), see VTTCue::document(
srivats
2015/03/18 01:58:13
Done.
| |
| 1146 if (settings) { | |
|
philipj_slow
2015/03/17 02:22:31
if (!settings) return;
srivats
2015/03/18 01:58:13
Done.
| |
| 1147 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
| 1148 CSSPropertyBackgroundColor, settings->textTrackBackgroundColor()); | |
| 1149 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
| 1150 CSSPropertyBackgroundColor, settings->textTrackBackgroundColor()); | |
| 1151 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
| 1152 CSSPropertyFontFamily, settings->textTrackFontFamily()); | |
| 1153 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
| 1154 CSSPropertyFontStyle, settings->textTrackFontStyle()); | |
| 1155 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
| 1156 CSSPropertyFontVariant, settings->textTrackFontVariant()); | |
| 1157 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
| 1158 CSSPropertyColor, settings->textTrackTextColor()); | |
| 1159 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
| 1160 CSSPropertyTextShadow, settings->textTrackTextShadow()); | |
| 1161 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox, | |
| 1162 CSSPropertyFontSize, settings->textTrackTextSize()); | |
| 1163 } | |
| 1164 } | |
| 1165 | |
| 1131 } // namespace blink | 1166 } // namespace blink |
| OLD | NEW |