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

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: Addressed comments from fs and added a new test 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
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..099d6ed55f0e0a1db75ec25e6319e5e4a515126a 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,15 @@ 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 != "") {
fs 2015/02/18 09:36:46 Nit: !value.isEmpty()
srivats 2015/02/18 22:39:33 Done.
+ element->setInlineStyleProperty(propertyID, value, true);
+ }
fs 2015/02/18 09:36:46 Nit: Drop {} (not needed for single statements)
srivats 2015/02/18 22:39:33 Done.
+}
+
VTTCueBox::VTTCueBox(Document& document, VTTCue* cue)
: HTMLDivElement(document)
, m_cue(cue)
@@ -206,6 +216,15 @@ void VTTCueBox::applyCSSProperties(const VTTDisplayParameters& displayParameters
}
}
+void VTTCueBox::applyUserOverrideCSSProperties()
+{
+ Settings* settings = document().settings();
+ if (settings) {
+ // Override background color for the cue box
+ setInlineStylePropertyIfNotEmpty(this, CSSPropertyBackgroundColor, settings->textTrackWindowColor());
+ }
+}
+
LayoutObject* VTTCueBox::createRenderer(const LayoutStyle&)
{
return new RenderVTTCue(this);
@@ -842,6 +861,10 @@ 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 and the cue box
+ applyUserOverrideCSSProperties();
+ displayTree->applyUserOverrideCSSProperties();
+
m_displayTreeShouldChange = false;
// 10.15. Let cue's text track cue display state have the CSS boxes in
@@ -1134,4 +1157,27 @@ void VTTCue::trace(Visitor* visitor)
TextTrackCue::trace(visitor);
}
+void VTTCue::applyUserOverrideCSSProperties()
+{
+ Settings* settings = m_cueBackgroundBox->document().settings();
+ if (settings) {
+ 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

Powered by Google App Engine
This is Rietveld 408576698