Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: Source/core/html/track/vtt/VTTCue.cpp

Issue 921833003: Expose APIs for text track settings (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed window color API as per Philip's suggestion Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/track/vtt/VTTCue.h ('k') | Source/web/WebSettingsImpl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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.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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 844
836 // FIXME(BUG 79916): Text runs must be wrapped according to the CSS 845 // FIXME(BUG 79916): Text runs must be wrapped according to the CSS
837 // line-wrapping rules, except that additionally, regardless of the value of 846 // 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 847 // 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 848 // containing blocks, even if doing so requires splitting a word where there
840 // is no line breaking opportunity. (Thus, normally text wraps as needed, 849 // 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 850 // 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.) 851 // normally would in CSS, it is instead forcibly wrapped at the box's edge.)
843 displayTree->applyCSSProperties(displayParameters); 852 displayTree->applyCSSProperties(displayParameters);
844 853
854 // Apply user override settings for text tracks
855 applyUserOverrideCSSProperties();
856
845 m_displayTreeShouldChange = false; 857 m_displayTreeShouldChange = false;
846 858
847 // 10.15. Let cue's text track cue display state have the CSS boxes in 859 // 10.15. Let cue's text track cue display state have the CSS boxes in
848 // boxes. 860 // boxes.
849 return displayTree.release(); 861 return displayTree.release();
850 } 862 }
851 863
852 void VTTCue::removeDisplayTree() 864 void VTTCue::removeDisplayTree()
853 { 865 {
854 if (m_notifyRegion && track()->regions()) { 866 if (m_notifyRegion && track()->regions()) {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 } 1139 }
1128 1140
1129 void VTTCue::trace(Visitor* visitor) 1141 void VTTCue::trace(Visitor* visitor)
1130 { 1142 {
1131 visitor->trace(m_vttNodeTree); 1143 visitor->trace(m_vttNodeTree);
1132 visitor->trace(m_cueBackgroundBox); 1144 visitor->trace(m_cueBackgroundBox);
1133 visitor->trace(m_displayTree); 1145 visitor->trace(m_displayTree);
1134 TextTrackCue::trace(visitor); 1146 TextTrackCue::trace(visitor);
1135 } 1147 }
1136 1148
1149 void VTTCue::applyUserOverrideCSSProperties()
1150 {
1151 Settings* settings = m_cueBackgroundBox->document().settings();
1152 if (settings) {
philipj_slow 2015/03/18 06:31:09 "if (!settings) return" to reduce the indentation
1153 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
1154 CSSPropertyBackgroundColor, settings->textTrackBackgroundColor());
1155 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
1156 CSSPropertyBackgroundColor, settings->textTrackBackgroundColor());
1157 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
1158 CSSPropertyFontFamily, settings->textTrackFontFamily());
1159 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
1160 CSSPropertyFontStyle, settings->textTrackFontStyle());
1161 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
1162 CSSPropertyFontVariant, settings->textTrackFontVariant());
1163 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
1164 CSSPropertyColor, settings->textTrackTextColor());
1165 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
1166 CSSPropertyTextShadow, settings->textTrackTextShadow());
1167 setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
1168 CSSPropertyFontSize, settings->textTrackTextSize());
1169 }
1170 }
1171
1137 } // namespace blink 1172 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/track/vtt/VTTCue.h ('k') | Source/web/WebSettingsImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698