Changeset 172224 in webkit
- Timestamp:
- Aug 7, 2014, 12:34:10 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r172221 r172224 1 2014-08-06 Roger Fong <roger_fong@apple.com> 2 3 Increase width of caption container if a larger font size is selected from user prefs. 4 https://bugs.webkit.org/show_bug.cgi?id=135677. 5 6 Reviewed by Brent Fulgham. 7 8 * html/shadow/MediaControlElements.cpp: 9 (WebCore::MediaControlTextTrackContainerElement::updateDisplay): 10 Upon creation of a VTTCueBox make sure to supply the font size set by the user prefs. 11 * html/track/TextTrackCueGeneric.cpp: 12 (WebCore::TextTrackCueGenericBoxElement::applyCSSProperties): 13 Increase the width of the cue box based on user prefs font size selection. 14 15 * html/track/VTTCue.h: 16 Keep track of the font size set in the user prefs for use when the cue boxes are created. 17 (WebCore::VTTCueBox::setFontSizeFromCaptionUserPrefs): 18 * html/track/VTTCue.cpp: 19 (WebCore::VTTCueBox::applyCSSProperties): 20 Increase the width of the cue box based on user prefs font size selection. 21 (WebCore::VTTCue::getDisplayTree): 22 (WebCore::VTTCue::setFontSize): 23 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. 24 1 25 2014-08-07 Alex Christensen <achristensen@webkit.org> 2 26 -
trunk/Source/WebCore/html/shadow/MediaControlElements.cpp
r172213 r172224 1180 1180 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()); 1181 1181 1182 RefPtr<VTTCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size() );1182 RefPtr<VTTCueBox> displayBox = cue->getDisplayTree(m_videoDisplaySize.size(), m_fontSize); 1183 1183 #if ENABLE(WEBVTT_REGIONS) 1184 1184 if (cue->track()->mode() == TextTrack::disabledKeyword()) -
trunk/Source/WebCore/html/track/TextTrackCueGeneric.cpp
r172213 r172224 31 31 32 32 #include "CSSPropertyNames.h" 33 #include "CSSStyleDeclaration.h" 33 34 #include "CSSValueKeywords.h" 34 35 #include "HTMLNames.h" … … 38 39 #include "RenderObject.h" 39 40 #include "ScriptExecutionContext.h" 41 #include "StyleProperties.h" 40 42 #include "TextTrackCue.h" 43 #include <wtf/MathExtras.h> 41 44 42 45 namespace WebCore { … … 76 79 setInlineStyleProperty(CSSPropertyTop, static_cast<float>(cue->line()), CSSPrimitiveValue::CSS_PERCENTAGE); 77 80 81 float authorFontSize = std::max(VTTCueBox::DEFAULTFONTSIZE, static_cast<float>(videoSize.height() * cue->baseFontSizeRelativeToVideoHeight() / 100)); 82 if (cue->fontSizeMultiplier()) 83 authorFontSize *= cue->fontSizeMultiplier() / 100; 84 85 float multiplier = std::max(1.0f, m_fontSizeFromCaptionUserPrefs / authorFontSize); 78 86 if (cue->getWritingDirection() == VTTCue::Horizontal) 79 setInlineStyleProperty(CSSPropertyWidth, size , CSSPrimitiveValue::CSS_PERCENTAGE);87 setInlineStyleProperty(CSSPropertyWidth, size * multiplier, CSSPrimitiveValue::CSS_PERCENTAGE); 80 88 else 81 setInlineStyleProperty(CSSPropertyHeight, size, CSSPrimitiveValue::CSS_PERCENTAGE); 82 } 83 84 if (cue->getWritingDirection() == VTTCue::Horizontal) 89 setInlineStyleProperty(CSSPropertyHeight, size * multiplier, CSSPrimitiveValue::CSS_PERCENTAGE); 90 } 91 92 std::pair<float, float> position = m_cue.getCSSPosition(); 93 if (cue->getWritingDirection() == VTTCue::Horizontal) { 85 94 setInlineStyleProperty(CSSPropertyMinWidth, "-webkit-min-content"); 86 else 95 double maxWidth = videoSize.width() * (100.0 - position.first) / 100.0; 96 setInlineStyleProperty(CSSPropertyMaxWidth, maxWidth, CSSPrimitiveValue::CSS_PX); 97 } else { 87 98 setInlineStyleProperty(CSSPropertyMinHeight, "-webkit-min-content"); 99 double maxHeight = videoSize.height() * (100.0 - position.second) / 100.0; 100 setInlineStyleProperty(CSSPropertyMaxHeight, maxHeight, CSSPrimitiveValue::CSS_PX); 101 } 88 102 89 103 if (cue->foregroundColor().isValid()) -
trunk/Source/WebCore/html/track/VTTCue.cpp
r171158 r172224 139 139 } 140 140 141 void VTTCueBox::applyCSSProperties(const IntSize& )141 void VTTCueBox::applyCSSProperties(const IntSize& videoSize) 142 142 { 143 143 // FIXME: Apply all the initial CSS positioning properties. http://wkb.ug/79916 … … 171 171 setInlineStyleProperty(CSSPropertyLeft, static_cast<double>(position.first), CSSPrimitiveValue::CSS_PERCENTAGE); 172 172 173 float multiplier = std::max(1.0f, m_fontSizeFromCaptionUserPrefs / VTTCueBox::DEFAULTFONTSIZE); 173 174 // the 'width' property must be set to width, and the 'height' property must be set to height 174 175 if (m_cue.vertical() == horizontalKeyword()) { 175 setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue.getCSSSize() ), CSSPrimitiveValue::CSS_PERCENTAGE);176 setInlineStyleProperty(CSSPropertyWidth, static_cast<double>(m_cue.getCSSSize() * multiplier), CSSPrimitiveValue::CSS_PERCENTAGE); 176 177 setInlineStyleProperty(CSSPropertyHeight, CSSValueAuto); 177 178 setInlineStyleProperty(CSSPropertyMinWidth, "-webkit-min-content"); 179 double maxWidth = videoSize.width() * (100.0 - position.first) / 100.0; 180 setInlineStyleProperty(CSSPropertyMaxWidth, maxWidth, CSSPrimitiveValue::CSS_PX); 178 181 } else { 179 182 setInlineStyleProperty(CSSPropertyWidth, CSSValueAuto); 180 setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue.getCSSSize() ), CSSPrimitiveValue::CSS_PERCENTAGE);183 setInlineStyleProperty(CSSPropertyHeight, static_cast<double>(m_cue.getCSSSize() * multiplier), CSSPrimitiveValue::CSS_PERCENTAGE); 181 184 setInlineStyleProperty(CSSPropertyMinHeight, "-webkit-min-content"); 185 double maxHeight = videoSize.height() * (100.0 - position.second) / 100.0; 186 setInlineStyleProperty(CSSPropertyMaxHeight, maxHeight, CSSPrimitiveValue::CSS_PX); 182 187 } 183 188 … … 187 192 // alignment: 188 193 setInlineStyleProperty(CSSPropertyTextAlign, m_cue.getCSSAlignment()); 189 194 190 195 if (!m_cue.snapToLines()) { 191 196 // 10.13.1 Set up x and y: … … 778 783 } 779 784 780 VTTCueBox* VTTCue::getDisplayTree(const IntSize& videoSize )785 VTTCueBox* VTTCue::getDisplayTree(const IntSize& videoSize, int fontSize) 781 786 { 782 787 RefPtr<VTTCueBox> displayTree = displayTreeInternal(); … … 809 814 // 'display' property has the value 'ruby-base'. 810 815 811 // FIXME(BUG 79916): Text runs must be wrapped according to the CSS 812 // line-wrapping rules, except that additionally, regardless of the value of 813 // the 'white-space' property, lines must be wrapped at the edge of their 814 // containing blocks, even if doing so requires splitting a word where there 815 // is no line breaking opportunity. (Thus, normally text wraps as needed, 816 // but if there is a particularly long word, it does not overflow as it 817 // normally would in CSS, it is instead forcibly wrapped at the box's edge.) 816 displayTree->setFontSizeFromCaptionUserPrefs(fontSize); 818 817 displayTree->applyCSSProperties(videoSize); 819 818 … … 1144 1143 LOG(Media, "TextTrackCue::setFontSize - setting cue font size to %i", fontSize); 1145 1144 1145 if (important) 1146 displayTreeInternal()->setFontSizeFromCaptionUserPrefs(0); 1147 1146 1148 displayTreeInternal()->setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX, important); 1147 1149 } -
trunk/Source/WebCore/html/track/VTTCue.h
r171004 r172224 60 60 61 61 static const AtomicString& vttCueBoxShadowPseudoId(); 62 virtual void setFontSizeFromCaptionUserPrefs(int fontSize) { m_fontSizeFromCaptionUserPrefs = fontSize; } 62 63 63 64 protected: … … 67 68 68 69 VTTCue& m_cue; 70 int m_fontSizeFromCaptionUserPrefs; 71 72 static const float DEFAULTFONTSIZE; 69 73 }; 74 75 // This default value must be the same as the one specified in mediaControlsApple.css for -webkit-media-controls-closed-captions-container 76 const float VTTCueBox::DEFAULTFONTSIZE = 10; 70 77 71 78 // ---------------------------- … … 116 123 117 124 bool hasDisplayTree() const { return m_displayTree; } 118 VTTCueBox* getDisplayTree(const IntSize& videoSize );125 VTTCueBox* getDisplayTree(const IntSize& videoSize, int fontSize); 119 126 HTMLSpanElement* element() const { return m_cueHighlightBox.get(); } 120 127
Note:
See TracChangeset
for help on using the changeset viewer.