Diff
Modified: trunk/Source/WebCore/ChangeLog (141965 => 141966)
--- trunk/Source/WebCore/ChangeLog 2013-02-06 04:30:28 UTC (rev 141965)
+++ trunk/Source/WebCore/ChangeLog 2013-02-06 05:12:54 UTC (rev 141966)
@@ -1,3 +1,38 @@
+2013-02-05 Eric Carlson <[email protected]>
+
+ More updates to Caption user preferences
+ https://bugs.webkit.org/show_bug.cgi?id=108997
+
+ Reviewed by Dean Jackson.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::captionPreferencesChanged): Give the media controls a chance
+ to update for a preferences change.
+ * html/shadow/MediaControlElements.cpp:
+ (WebCore::MediaControlTextTrackContainerElement::updateSizes): Add optional "force update"
+ param to force font size recalc even when the video size hasn't changed.
+ * html/shadow/MediaControlElements.h:
+
+ * html/shadow/MediaControls.cpp:
+ (WebCore::MediaControls::textTrackPreferencesChanged): New, force a font size recalc.
+ * html/shadow/MediaControls.h:
+
+ * html/track/TextTrackCueGeneric.cpp:
+ (WebCore::TextTrackCueGenericBoxElement::applyCSSProperties): Don't set width/size of cues
+ that use default positioning. Use "start" as the default alignment.
+
+ * page/CaptionUserPreferencesMac.mm:
+ (WebCore::CaptionUserPreferencesMac::captionsWindowCSS): Set padding when the window is visible
+ so it shows around the cue background.
+ (WebCore::CaptionUserPreferencesMac::captionsBackgroundCSS): Set padding to 0 when the background
+ is visible.
+ (WebCore::CaptionUserPreferencesMac::windowRoundedCornerRadiusCSS): Add "px" to the border radius
+ so it actually works.
+ * rendering/RenderTextTrackCue.cpp:
+ (WebCore::RenderTextTrackCue::layout): Special case generic cues with default style.
+ (WebCore::RenderTextTrackCue::repositionGenericCue):
+ * rendering/RenderTextTrackCue.h:
+
2013-02-05 Hayato Ito <[email protected]>
Split each RuleSet and feature out from StyleResolver into its own class.
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (141965 => 141966)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-02-06 04:30:28 UTC (rev 141965)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2013-02-06 05:12:54 UTC (rev 141966)
@@ -4374,6 +4374,9 @@
if (!isVideo())
return;
+ if (hasMediaControls())
+ mediaControls()->textTrackPreferencesChanged();
+
markCaptionAndSubtitleTracksAsUnconfigured();
}
Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.cpp (141965 => 141966)
--- trunk/Source/WebCore/html/shadow/MediaControlElements.cpp 2013-02-06 04:30:28 UTC (rev 141965)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.cpp 2013-02-06 05:12:54 UTC (rev 141966)
@@ -1306,7 +1306,7 @@
}
}
-void MediaControlTextTrackContainerElement::updateSizes()
+void MediaControlTextTrackContainerElement::updateSizes(bool forceUpdate)
{
HTMLMediaElement* mediaElement = toParentMediaElement(this);
if (!mediaElement)
@@ -1325,7 +1325,7 @@
videoBox = toRenderVideo(mediaElement->renderer())->videoBox();
}
- if (m_videoDisplaySize == videoBox)
+ if (!forceUpdate && m_videoDisplaySize == videoBox)
return;
m_videoDisplaySize = videoBox;
Modified: trunk/Source/WebCore/html/shadow/MediaControlElements.h (141965 => 141966)
--- trunk/Source/WebCore/html/shadow/MediaControlElements.h 2013-02-06 04:30:28 UTC (rev 141965)
+++ trunk/Source/WebCore/html/shadow/MediaControlElements.h 2013-02-06 05:12:54 UTC (rev 141966)
@@ -438,7 +438,7 @@
static PassRefPtr<MediaControlTextTrackContainerElement> create(Document*);
void updateDisplay();
- void updateSizes();
+ void updateSizes(bool forceUpdate = false);
void createSubtrees(Document*);
private:
Modified: trunk/Source/WebCore/html/shadow/MediaControls.cpp (141965 => 141966)
--- trunk/Source/WebCore/html/shadow/MediaControls.cpp 2013-02-06 04:30:28 UTC (rev 141965)
+++ trunk/Source/WebCore/html/shadow/MediaControls.cpp 2013-02-06 05:12:54 UTC (rev 141966)
@@ -407,6 +407,12 @@
m_textDisplayContainer->updateDisplay();
}
+
+void MediaControls::textTrackPreferencesChanged()
+{
+ if (m_textDisplayContainer)
+ m_textDisplayContainer->updateSizes(true);
+}
#endif
}
Modified: trunk/Source/WebCore/html/shadow/MediaControls.h (141965 => 141966)
--- trunk/Source/WebCore/html/shadow/MediaControls.h 2013-02-06 04:30:28 UTC (rev 141965)
+++ trunk/Source/WebCore/html/shadow/MediaControls.h 2013-02-06 05:12:54 UTC (rev 141966)
@@ -106,6 +106,7 @@
virtual void showTextTrackDisplay();
virtual void hideTextTrackDisplay();
virtual void updateTextTrackDisplay();
+ virtual void textTrackPreferencesChanged();
#endif
protected:
Modified: trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp (141965 => 141966)
--- trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp 2013-02-06 04:30:28 UTC (rev 141965)
+++ trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp 2013-02-06 05:12:54 UTC (rev 141966)
@@ -66,23 +66,24 @@
TextTrackCueGeneric* cue = static_cast<TextTrackCueGeneric*>(getCue());
+ float size = static_cast<float>(cue->getCSSSize());
if (cue->useDefaultPosition()) {
setInlineStyleProperty(CSSPropertyBottom, "0");
setInlineStyleProperty(CSSPropertyMarginBottom, 1.0, CSSPrimitiveValue::CSS_PERCENTAGE);
} else {
setInlineStyleProperty(CSSPropertyLeft, static_cast<float>(cue->position()), CSSPrimitiveValue::CSS_PERCENTAGE);
setInlineStyleProperty(CSSPropertyTop, static_cast<float>(cue->line()), CSSPrimitiveValue::CSS_PERCENTAGE);
+
+ if (cue->getWritingDirection() == TextTrackCue::Horizontal)
+ setInlineStyleProperty(CSSPropertyWidth, size, CSSPrimitiveValue::CSS_PERCENTAGE);
+ else
+ setInlineStyleProperty(CSSPropertyHeight, size, CSSPrimitiveValue::CSS_PERCENTAGE);
}
- float size = static_cast<float>(cue->getCSSSize());
- if (cue->getWritingDirection() == TextTrackCue::Horizontal) {
- setInlineStyleProperty(CSSPropertyDirection, CSSValueLtr);
- setInlineStyleProperty(CSSPropertyWidth, size, CSSPrimitiveValue::CSS_PERCENTAGE);
+ if (cue->getWritingDirection() == TextTrackCue::Horizontal)
setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto);
- } else {
+ else
setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);
- setInlineStyleProperty(CSSPropertyHeight, size, CSSPrimitiveValue::CSS_PERCENTAGE);
- }
if (cue->baseFontSizeRelativeToVideoHeight()) {
double fontSize = videoSize.height() * cue->baseFontSizeRelativeToVideoHeight() / 100;
@@ -91,12 +92,12 @@
setInlineStyleProperty(CSSPropertyFontSize, String::number(fontSize) + "px");
}
- if (cue->getAlignment() == TextTrackCue::Start)
- setInlineStyleProperty(CSSPropertyTextAlign, CSSValueStart);
+ if (cue->getAlignment() == TextTrackCue::Middle)
+ setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter);
else if (cue->getAlignment() == TextTrackCue::End)
setInlineStyleProperty(CSSPropertyTextAlign, CSSValueEnd);
else
- setInlineStyleProperty(CSSPropertyTextAlign, CSSValueCenter);
+ setInlineStyleProperty(CSSPropertyTextAlign, CSSValueStart);
setInlineStyleProperty(CSSPropertyWebkitWritingMode, cue->getCSSWritingMode(), false);
setInlineStyleProperty(CSSPropertyWhiteSpace, CSSValuePreWrap);
Modified: trunk/Source/WebCore/page/CaptionUserPreferencesMac.mm (141965 => 141966)
--- trunk/Source/WebCore/page/CaptionUserPreferencesMac.mm 2013-02-06 04:30:28 UTC (rev 141965)
+++ trunk/Source/WebCore/page/CaptionUserPreferencesMac.mm 2013-02-06 05:12:54 UTC (rev 141966)
@@ -140,7 +140,20 @@
windowColor = Color::transparent;
CGFloat opacity = MACaptionAppearanceGetWindowOpacity(kMACaptionAppearanceDomainUser, &behavior);
- return colorPropertyCSS(CSSPropertyBackgroundColor, Color(windowColor.red(), windowColor.green(), windowColor.blue(), static_cast<int>(opacity * 255)), behavior == kMACaptionAppearanceBehaviorUseValue);
+ String windowStyle = colorPropertyCSS(CSSPropertyBackgroundColor, Color(windowColor.red(), windowColor.green(), windowColor.blue(), static_cast<int>(opacity * 255)), behavior == kMACaptionAppearanceBehaviorUseValue);
+
+ if (!opacity)
+ return windowStyle;
+
+ StringBuilder builder;
+ builder.append(windowStyle);
+ builder.append(getPropertyNameString(CSSPropertyPadding));
+ builder.append(": .2em");
+ if (behavior == kMACaptionAppearanceBehaviorUseValue)
+ builder.append(" !important");
+ builder.append(';');
+
+ return builder.toString();
}
String CaptionUserPreferencesMac::captionsBackgroundCSS() const
@@ -157,7 +170,20 @@
backgroundColor = defaultBackgroundColor;
CGFloat opacity = MACaptionAppearanceGetBackgroundOpacity(kMACaptionAppearanceDomainUser, 0);
- return colorPropertyCSS(CSSPropertyBackgroundColor, Color(backgroundColor.red(), backgroundColor.green(), backgroundColor.blue(), static_cast<int>(opacity * 255)), behavior == kMACaptionAppearanceBehaviorUseValue);
+ String backgroundStyle = colorPropertyCSS(CSSPropertyBackgroundColor, Color(backgroundColor.red(), backgroundColor.green(), backgroundColor.blue(), static_cast<int>(opacity * 255)), behavior == kMACaptionAppearanceBehaviorUseValue);
+
+ if (!opacity)
+ return backgroundStyle;
+
+ StringBuilder builder;
+ builder.append(backgroundStyle);
+ builder.append(getPropertyNameString(CSSPropertyPadding));
+ builder.append(": 0px");
+ if (behavior == kMACaptionAppearanceBehaviorUseValue)
+ builder.append(" !important");
+ builder.append(';');
+
+ return builder.toString();
}
Color CaptionUserPreferencesMac::captionsTextColor(bool& important) const
@@ -194,8 +220,7 @@
StringBuilder builder;
builder.append(getPropertyNameString(CSSPropertyBorderRadius));
- builder.append(':');
- builder.append(String::format("%.02f", radius));
+ builder.append(String::format(":%.02fpx", radius));
if (behavior == kMACaptionAppearanceBehaviorUseValue)
builder.append(" !important");
builder.append(';');
Modified: trunk/Source/WebCore/rendering/RenderTextTrackCue.cpp (141965 => 141966)
--- trunk/Source/WebCore/rendering/RenderTextTrackCue.cpp 2013-02-06 04:30:28 UTC (rev 141965)
+++ trunk/Source/WebCore/rendering/RenderTextTrackCue.cpp 2013-02-06 05:12:54 UTC (rev 141966)
@@ -30,6 +30,7 @@
#include "RenderTextTrackCue.h"
#include "TextTrackCue.h"
+#include "TextTrackCueGeneric.h"
namespace WebCore {
@@ -45,10 +46,15 @@
RenderBlock::layout();
LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode());
- if (m_cue->snapToLines())
- repositionCueSnapToLinesSet();
- else
- repositionCueSnapToLinesNotSet();
+
+ if (m_cue->cueType()== TextTrackCue::WebVTT) {
+ if (m_cue->snapToLines())
+ repositionCueSnapToLinesSet();
+ else
+ repositionCueSnapToLinesNotSet();
+ } else
+ repositionGenericCue();
+
statePusher.pop();
}
@@ -221,6 +227,24 @@
}
}
+void RenderTextTrackCue::repositionGenericCue()
+{
+ TextTrackCueGeneric* cue = static_cast<TextTrackCueGeneric*>(m_cue);
+ if (!cue->useDefaultPosition())
+ return;
+
+ ASSERT(firstChild());
+
+ InlineFlowBox* firstLineBox = toRenderInline(firstChild())->firstLineBox();
+ if (!firstLineBox)
+ return;
+
+ LayoutUnit parentWidth = containingBlock()->logicalWidth();
+ LayoutUnit width = firstLineBox->width();
+ LayoutUnit right = (parentWidth / 2) - (width / 2);
+ setX(right);
+}
+
void RenderTextTrackCue::repositionCueSnapToLinesNotSet()
{
// FIXME: Implement overlapping detection when snap-to-lines is not set. http://wkb.ug/84296
Modified: trunk/Source/WebCore/rendering/RenderTextTrackCue.h (141965 => 141966)
--- trunk/Source/WebCore/rendering/RenderTextTrackCue.h 2013-02-06 04:30:28 UTC (rev 141965)
+++ trunk/Source/WebCore/rendering/RenderTextTrackCue.h 2013-02-06 05:12:54 UTC (rev 141966)
@@ -54,8 +54,8 @@
bool initializeLayoutParameters(InlineFlowBox*&, LayoutUnit&, LayoutUnit&);
void placeBoxInDefaultPosition(LayoutUnit, bool&);
void repositionCueSnapToLinesSet();
-
void repositionCueSnapToLinesNotSet();
+ void repositionGenericCue();
TextTrackCue* m_cue;
FloatPoint m_fallbackPosition;