Diff
Modified: branches/safari-600.1-branch/Source/WebCore/ChangeLog (172285 => 172286)
--- branches/safari-600.1-branch/Source/WebCore/ChangeLog 2014-08-07 22:14:44 UTC (rev 172285)
+++ branches/safari-600.1-branch/Source/WebCore/ChangeLog 2014-08-07 22:16:30 UTC (rev 172286)
@@ -1,5 +1,33 @@
2014-08-07 Dana Burkart <[email protected]>
+ Merge r172224
+
+ 2014-08-06 Roger Fong <[email protected]>
+
+ Increase width of caption container if a larger font size is selected from user prefs.
+ https://bugs.webkit.org/show_bug.cgi?id=135677.
+
+ Reviewed by Brent Fulgham.
+
+ * html/shadow/MediaControlElements.cpp:
+ (WebCore::MediaControlTextTrackContainerElement::updateDisplay):
+ Upon creation of a VTTCueBox make sure to supply the font size set by the user prefs.
+ * html/track/TextTrackCueGeneric.cpp:
+ (WebCore::TextTrackCueGenericBoxElement::applyCSSProperties):
+ Increase the width of the cue box based on user prefs font size selection.
+
+ * html/track/VTTCue.h:
+ Keep track of the font size set in the user prefs for use when the cue boxes are created.
+ (WebCore::VTTCueBox::setFontSizeFromCaptionUserPrefs):
+ * html/track/VTTCue.cpp:
+ (WebCore::VTTCueBox::applyCSSProperties):
+ Increase the width of the cue box based on user prefs font size selection.
+ (WebCore::VTTCue::getDisplayTree):
+ (WebCore::VTTCue::setFontSize):
+ If the font size set is important then we don't want to use the font size set by user prefs, set it to 0.
+
+2014-08-07 Dana Burkart <[email protected]>
+
Merge r172257
2014-08-07 Eric Carlson <[email protected]>
Modified: branches/safari-600.1-branch/Source/WebCore/html/shadow/MediaControlElements.cpp (172285 => 172286)
--- branches/safari-600.1-branch/Source/WebCore/html/shadow/MediaControlElements.cpp 2014-08-07 22:14:44 UTC (rev 172285)
+++ branches/safari-600.1-branch/Source/WebCore/html/shadow/MediaControlElements.cpp 2014-08-07 22:16:30 UTC (rev 172286)
@@ -1340,7 +1340,7 @@
LOG(Media, "MediaControlTextTrackContainerElement::updateDisplay(%p) - adding and positioning cue #%zu: \"%s\", start=%.2f, end=%.2f, line=%.2f", this, i, cue->text().utf8().data(), cue->startTime(), cue->endTime(), cue->line());
- RefPtr<VTTCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size());
+ RefPtr<VTTCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size(), m_fontSize);
#if ENABLE(WEBVTT_REGIONS)
if (cue->track()->mode() == TextTrack::disabledKeyword())
continue;
Modified: branches/safari-600.1-branch/Source/WebCore/html/track/TextTrackCueGeneric.cpp (172285 => 172286)
--- branches/safari-600.1-branch/Source/WebCore/html/track/TextTrackCueGeneric.cpp 2014-08-07 22:14:44 UTC (rev 172285)
+++ branches/safari-600.1-branch/Source/WebCore/html/track/TextTrackCueGeneric.cpp 2014-08-07 22:16:30 UTC (rev 172286)
@@ -30,6 +30,7 @@
#include "TextTrackCueGeneric.h"
#include "CSSPropertyNames.h"
+#include "CSSStyleDeclaration.h"
#include "CSSValueKeywords.h"
#include "HTMLNames.h"
#include "HTMLSpanElement.h"
@@ -37,7 +38,9 @@
#include "Logging.h"
#include "RenderObject.h"
#include "ScriptExecutionContext.h"
+#include "StyleProperties.h"
#include "TextTrackCue.h"
+#include <wtf/MathExtras.h>
namespace WebCore {
@@ -75,16 +78,27 @@
setInlineStyleProperty(CSSPropertyLeft, static_cast<float>(cue->position()), CSSPrimitiveValue::CSS_PERCENTAGE);
setInlineStyleProperty(CSSPropertyTop, static_cast<float>(cue->line()), CSSPrimitiveValue::CSS_PERCENTAGE);
+ float authorFontSize = std::max(VTTCueBox::DEFAULTFONTSIZE, static_cast<float>(videoSize.height() * cue->baseFontSizeRelativeToVideoHeight() / 100));
+ if (cue->fontSizeMultiplier())
+ authorFontSize *= cue->fontSizeMultiplier() / 100;
+
+ float multiplier = std::max(1.0f, m_fontSizeFromCaptionUserPrefs / authorFontSize);
if (cue->getWritingDirection() == VTTCue::Horizontal)
- setInlineStyleProperty(CSSPropertyWidth, size, CSSPrimitiveValue::CSS_PERCENTAGE);
+ setInlineStyleProperty(CSSPropertyWidth, size * multiplier, CSSPrimitiveValue::CSS_PERCENTAGE);
else
- setInlineStyleProperty(CSSPropertyHeight, size, CSSPrimitiveValue::CSS_PERCENTAGE);
+ setInlineStyleProperty(CSSPropertyHeight, size * multiplier, CSSPrimitiveValue::CSS_PERCENTAGE);
}
- if (cue->getWritingDirection() == VTTCue::Horizontal)
+ std::pair<float, float> position = m_cue.getCSSPosition();
+ if (cue->getWritingDirection() == VTTCue::Horizontal) {
setInlineStyleProperty(CSSPropertyMinWidth, "-webkit-min-content");
- else
+ double maxWidth = videoSize.width() * (100.0 - position.first) / 100.0;
+ setInlineStyleProperty(CSSPropertyMaxWidth, maxWidth, CSSPrimitiveValue::CSS_PX);
+ } else {
setInlineStyleProperty(CSSPropertyMinHeight, "-webkit-min-content");
+ double maxHeight = videoSize.height() * (100.0 - position.second) / 100.0;
+ setInlineStyleProperty(CSSPropertyMaxHeight, maxHeight, CSSPrimitiveValue::CSS_PX);
+ }
if (cue->foregroundColor().isValid())
cueElement->setInlineStyleProperty(CSSPropertyColor, cue->foregroundColor().serialized());
Modified: branches/safari-600.1-branch/Source/WebCore/html/track/VTTCue.cpp (172285 => 172286)
--- branches/safari-600.1-branch/Source/WebCore/html/track/VTTCue.cpp 2014-08-07 22:14:44 UTC (rev 172285)
+++ branches/safari-600.1-branch/Source/WebCore/html/track/VTTCue.cpp 2014-08-07 22:16:30 UTC (rev 172286)
@@ -138,7 +138,7 @@
return &m_cue;
}
-void VTTCueBox::applyCSSProperties(const IntSize&)
+void VTTCueBox::applyCSSProperties(const IntSize& videoSize)
{
// FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79916
#if ENABLE(WEBVTT_REGIONS)
@@ -170,15 +170,20 @@
// the 'left' property must be set to left
setInlineStyleProperty(CSSPropertyLeft, static_cast<double>(position.first), CSSPrimitiveValue::CSS_PERCENTAGE);
+ float multiplier = std::max(1.0f, m_fontSizeFromCaptionUserPrefs / VTTCueBox::DEFAULTFONTSIZE);
// the 'width' property must be set to width, and the 'height' property must be set to height
if (m_cue.vertical() == horizontalKeyword()) {
- setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue.getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
+ setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue.getCSSSize() * multiplier), CSSPrimitiveValue::CSS_PERCENTAGE);
setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto);
setInlineStyleProperty(CSSPropertyMinWidth, "-webkit-min-content");
+ double maxWidth = videoSize.width() * (100.0 - position.first) / 100.0;
+ setInlineStyleProperty(CSSPropertyMaxWidth, maxWidth, CSSPrimitiveValue::CSS_PX);
} else {
setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto);
- setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue.getCSSSize()), CSSPrimitiveValue::CSS_PERCENTAGE);
+ setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue.getCSSSize() * multiplier), CSSPrimitiveValue::CSS_PERCENTAGE);
setInlineStyleProperty(CSSPropertyMinHeight, "-webkit-min-content");
+ double maxHeight = videoSize.height() * (100.0 - position.second) / 100.0;
+ setInlineStyleProperty(CSSPropertyMaxHeight, maxHeight, CSSPrimitiveValue::CSS_PX);
}
// The 'text-align' property on the (root) List of WebVTT Node Objects must
@@ -186,7 +191,7 @@
// whose first cell is the value of the corresponding cue's text track cue
// alignment:
setInlineStyleProperty(CSSPropertyTextAlign, m_cue.getCSSAlignment());
-
+
if (!m_cue.snapToLines()) {
// 10.13.1 Set up x and y:
// Note: x and y are set through the CSS left and top above.
@@ -777,7 +782,7 @@
m_cueHighlightBox->appendChild(referenceTree);
}
-VTTCueBox* VTTCue::getDisplayTree(const IntSize& videoSize)
+VTTCueBox* VTTCue::getDisplayTree(const IntSize& videoSize, int fontSize)
{
RefPtr<VTTCueBox> displayTree = displayTreeInternal();
if (!m_displayTreeShouldChange || !track()->isRendered())
@@ -808,13 +813,7 @@
// WebVTT Ruby Text Objects must be wrapped in anonymous boxes whose
// 'display' property has the value 'ruby-base'.
- // FIXME(BUG 79916): Text runs must be wrapped according to the CSS
- // line-wrapping rules, except that additionally, regardless of the value of
- // the 'white-space' property, lines must be wrapped at the edge of their
- // containing blocks, even if doing so requires splitting a word where there
- // is no line breaking opportunity. (Thus, normally text wraps as needed,
- // but if there is a particularly long word, it does not overflow as it
- // normally would in CSS, it is instead forcibly wrapped at the box's edge.)
+ displayTree->setFontSizeFromCaptionUserPrefs(fontSize);
displayTree->applyCSSProperties(videoSize);
m_displayTreeShouldChange = false;
@@ -1143,6 +1142,9 @@
LOG(Media, "TextTrackCue::setFontSize - setting cue font size to %i", fontSize);
+ if (important)
+ displayTreeInternal()->setFontSizeFromCaptionUserPrefs(0);
+
displayTreeInternal()->setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX, important);
}
Modified: branches/safari-600.1-branch/Source/WebCore/html/track/VTTCue.h (172285 => 172286)
--- branches/safari-600.1-branch/Source/WebCore/html/track/VTTCue.h 2014-08-07 22:14:44 UTC (rev 172285)
+++ branches/safari-600.1-branch/Source/WebCore/html/track/VTTCue.h 2014-08-07 22:16:30 UTC (rev 172286)
@@ -59,6 +59,7 @@
virtual void applyCSSProperties(const IntSize& videoSize);
static const AtomicString& vttCueBoxShadowPseudoId();
+ virtual void setFontSizeFromCaptionUserPrefs(int fontSize) { m_fontSizeFromCaptionUserPrefs = fontSize; }
protected:
VTTCueBox(Document&, VTTCue&);
@@ -66,8 +67,14 @@
virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override;
VTTCue& m_cue;
+ int m_fontSizeFromCaptionUserPrefs;
+
+ static const float DEFAULTFONTSIZE;
};
+// This default value must be the same as the one specified in mediaControlsApple.css for -webkit-media-controls-closed-captions-container
+const float VTTCueBox::DEFAULTFONTSIZE = 10;
+
// ----------------------------
class VTTCue : public TextTrackCue {
@@ -115,7 +122,7 @@
virtual void setIsActive(bool);
bool hasDisplayTree() const { return m_displayTree; }
- VTTCueBox* getDisplayTree(const IntSize& videoSize);
+ VTTCueBox* getDisplayTree(const IntSize& videoSize, int fontSize);
HTMLSpanElement* element() const { return m_cueHighlightBox.get(); }
void updateDisplayTree(double);