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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/track/vtt/VTTCue.cpp
diff --git a/Source/core/html/track/vtt/VTTCue.cpp b/Source/core/html/track/vtt/VTTCue.cpp
index 1b4970969dedd71198f12e5ddf8183ec75952f04..9fa4a26786b6175aa8c72f51d87df02bf86285b6 100644
--- a/Source/core/html/track/vtt/VTTCue.cpp
+++ b/Source/core/html/track/vtt/VTTCue.cpp
@@ -38,6 +38,7 @@
#include "core/dom/DocumentFragment.h"
#include "core/dom/NodeTraversal.h"
#include "core/events/Event.h"
+#include "core/frame/Settings.h"
#include "core/frame/UseCounter.h"
#include "core/html/HTMLDivElement.h"
#include "core/html/track/TextTrack.h"
@@ -136,6 +137,14 @@ static bool isInvalidPercentage(double value, ExceptionState& exceptionState)
return false;
}
+// Sets inline CSS properties on passed in element if value is not an empty string
+static void setInlineStylePropertyIfNotEmpty(PassRefPtrWillBeRawPtr<HTMLDivElement> element,
+ CSSPropertyID propertyID, const String& value)
+{
+ if (!value.isEmpty())
+ element->setInlineStyleProperty(propertyID, value, true);
+}
+
VTTCueBox::VTTCueBox(Document& document, VTTCue* cue)
: HTMLDivElement(document)
, m_cue(cue)
@@ -842,6 +851,9 @@ PassRefPtrWillBeRawPtr<VTTCueBox> VTTCue::getDisplayTree()
// normally would in CSS, it is instead forcibly wrapped at the box's edge.)
displayTree->applyCSSProperties(displayParameters);
+ // Apply user override settings for text tracks
+ applyUserOverrideCSSProperties();
+
m_displayTreeShouldChange = false;
// 10.15. Let cue's text track cue display state have the CSS boxes in
@@ -1134,4 +1146,27 @@ void VTTCue::trace(Visitor* visitor)
TextTrackCue::trace(visitor);
}
+void VTTCue::applyUserOverrideCSSProperties()
+{
+ Settings* settings = m_cueBackgroundBox->document().settings();
+ if (settings) {
philipj_slow 2015/03/18 06:31:09 "if (!settings) return" to reduce the indentation
+ setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
+ CSSPropertyBackgroundColor, settings->textTrackBackgroundColor());
+ setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
+ CSSPropertyBackgroundColor, settings->textTrackBackgroundColor());
+ setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
+ CSSPropertyFontFamily, settings->textTrackFontFamily());
+ setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
+ CSSPropertyFontStyle, settings->textTrackFontStyle());
+ setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
+ CSSPropertyFontVariant, settings->textTrackFontVariant());
+ setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
+ CSSPropertyColor, settings->textTrackTextColor());
+ setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
+ CSSPropertyTextShadow, settings->textTrackTextShadow());
+ setInlineStylePropertyIfNotEmpty(m_cueBackgroundBox,
+ CSSPropertyFontSize, settings->textTrackTextSize());
+ }
+}
+
} // namespace blink
« 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