Changeset 171004 in webkit


Ignore:
Timestamp:
Jul 11, 2014 10:32:17 AM (10 years ago)
Author:
Brent Fulgham
Message:

Use a separate backdrop element to allow cues to have highlight and background color
https://bugs.webkit.org/show_bug.cgi?id=134821
<rdar://problem/15999721>

Reviewed by Eric Carlson.

Source/WebCore:
Add a new <div> element wrapping the existing cue <span>. This allows
us to have a highlight on the cue (in the <span> background), as well
as an overall background color.

  • Modules/mediacontrols/mediaControlsApple.css:

(video::-webkit-media-text-track-display-backdrop): New markup for
the backdrop element of the caption.

  • html/track/VTTCue.cpp:

(WebCore::VTTCue::cueBackdropShadowPseudoId): Added to
allow user customization of the cue backdrop.
(WebCore::VTTCue::initialize): Rename the old "m_cueBackgroundBox" to
"m_cueHighlightBox" and add a new "m_cueBackdropBox" member.
(WebCore::VTTCue::updateDisplayTree): Update for m_cueHighlightBox.
(WebCore::VTTCue::getDisplayTree): Make m_cueHighlightBox a child
of the new m_cueBackdropBox element, and add m_cueBackdropBox to
the display tree.

  • html/track/VTTCue.h:

(WebCore::VTTCue::element):

  • page/CaptionUserPreferencesMediaAF.cpp:

(WebCore::CaptionUserPreferencesMediaAF::setInterestedInCaptionPreferenceChanges):
Fix for missing caption style updates. Even if we are already
listening for caption changes, we still want to update the new
instance's style sheet to match.
(WebCore::CaptionUserPreferencesMediaAF::captionsStyleSheetOverride):

  • rendering/RenderVTTCue.cpp:

(WebCore::RenderVTTCue::initializeLayoutParameters): Take the new
<div> into consideration when looking for the Cue text element.

LayoutTests:
Updated tests for new formatting logic.

  • platform/mac/media/track/track-cue-rendering-horizontal-expected.png:
  • platform/mac/media/track/track-cue-rendering-horizontal-expected.txt:
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r171001 r171004  
     12014-07-11  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Use a separate backdrop element to allow cues to have highlight and background color
     4        https://bugs.webkit.org/show_bug.cgi?id=134821
     5        <rdar://problem/15999721>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Updated tests for new formatting logic.
     10
     11        * platform/mac/media/track/track-cue-rendering-horizontal-expected.png:
     12        * platform/mac/media/track/track-cue-rendering-horizontal-expected.txt:
     13
    1142014-07-11  Zalan Bujtas  <zalan@apple.com>
    215
  • trunk/LayoutTests/platform/mac/media/track/track-cue-rendering-horizontal-expected.png

    • Property svn:mime-type set to image/png
  • trunk/LayoutTests/platform/mac/media/track/track-cue-rendering-horizontal-expected.txt

    r150260 r171004  
    2727layer at (8,8) size 320x14
    2828  RenderBlock (positioned) {DIV} at (0,0) size 320x14
    29     RenderInline {SPAN} at (0,0) size 276x14 [bgcolor=#000000CC]
    30       RenderText {#text} at (22,0) size 276x14
    31         text run at (22,0) width 276: "Cue 1: should be positioned at the top of the video."
     29    RenderBlock {DIV} at (22,0) size 276x14
     30      RenderInline {SPAN} at (0,0) size 275x14 [bgcolor=#000000CC]
     31        RenderText {#text} at (0,0) size 275x14
     32          text run at (0,0) width 275: "Cue 1: should be positioned at the top of the video."
    3233layer at (8,22) size 320x14
    3334  RenderBlock (positioned) {DIV} at (0,14) size 320x14
    34     RenderInline {SPAN} at (0,0) size 304x14 [bgcolor=#000000CC]
    35       RenderText {#text} at (8,0) size 304x14
    36         text run at (8,0) width 304: "Cue 2: should be the second cue and not overlap cue 1."
     35    RenderBlock {DIV} at (8,0) size 304x14
     36      RenderInline {SPAN} at (0,0) size 303x14 [bgcolor=#000000CC]
     37        RenderText {#text} at (0,0) size 303x14
     38          text run at (0,0) width 303: "Cue 2: should be the second cue and not overlap cue 1."
    3739layer at (8,36) size 320x14
    3840  RenderBlock (positioned) {DIV} at (0,28) size 320x14
    39     RenderInline {SPAN} at (0,0) size 296x14 [bgcolor=#000000CC]
    40       RenderText {#text} at (12,0) size 296x14
    41         text run at (12,0) width 296: "Cue 3: should become the third line from top to bottom."
     41    RenderBlock {DIV} at (12,0) size 296x14
     42      RenderInline {SPAN} at (0,0) size 296x14 [bgcolor=#000000CC]
     43        RenderText {#text} at (0,0) size 296x14
     44          text run at (0,0) width 296: "Cue 3: should become the third line from top to bottom."
    4245layer at (8,78) size 320x14
    4346  RenderBlock (positioned) {DIV} at (0,70) size 320x14
    44     RenderInline {SPAN} at (0,0) size 288x14 [bgcolor=#000000CC]
    45       RenderText {#text} at (16,0) size 288x14
    46         text run at (16,0) width 288: "Cue 4: should be fixed positioned around the middle."
     47    RenderBlock {DIV} at (16,0) size 288x14
     48      RenderInline {SPAN} at (0,0) size 287x14 [bgcolor=#000000CC]
     49        RenderText {#text} at (0,0) size 287x14
     50          text run at (0,0) width 287: "Cue 4: should be fixed positioned around the middle."
    4751layer at (8,234) size 320x14
    4852  RenderBlock (positioned) {DIV} at (0,226) size 320x14
    49     RenderInline {SPAN} at (0,0) size 292x14 [bgcolor=#000000CC]
    50       RenderText {#text} at (14,0) size 292x14
    51         text run at (14,0) width 292: "Cue 5: should be displayed at the bottom of the video."
     53    RenderBlock {DIV} at (14,0) size 292x14
     54      RenderInline {SPAN} at (0,0) size 291x14 [bgcolor=#000000CC]
     55        RenderText {#text} at (0,0) size 291x14
     56          text run at (0,0) width 291: "Cue 5: should be displayed at the bottom of the video."
    5257layer at (8,220) size 320x14
    5358  RenderBlock (positioned) {DIV} at (0,212) size 320x14
    54     RenderInline {SPAN} at (0,0) size 280x14 [bgcolor=#000000CC]
    55       RenderText {#text} at (20,0) size 280x14
    56         text run at (20,0) width 280: "Cue 6: should be on top of bottom positioned cue 5."
     59    RenderBlock {DIV} at (20,0) size 280x14
     60      RenderInline {SPAN} at (0,0) size 279x14 [bgcolor=#000000CC]
     61        RenderText {#text} at (0,0) size 279x14
     62          text run at (0,0) width 279: "Cue 6: should be on top of bottom positioned cue 5."
  • trunk/Source/WebCore/ChangeLog

    r171001 r171004  
     12014-07-10  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Use a separate backdrop element to allow cues to have highlight and background color
     4        https://bugs.webkit.org/show_bug.cgi?id=134821
     5        <rdar://problem/15999721>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Add a new <div> element wrapping the existing cue <span>. This allows
     10        us to have a highlight on the cue (in the <span> background), as well
     11        as an overall background color.
     12
     13        * Modules/mediacontrols/mediaControlsApple.css:
     14        (video::-webkit-media-text-track-display-backdrop): New markup for
     15        the backdrop element of the caption.
     16        * html/track/VTTCue.cpp:
     17        (WebCore::VTTCue::cueBackdropShadowPseudoId): Added to
     18        allow user customization of the cue backdrop.
     19        (WebCore::VTTCue::initialize): Rename the old "m_cueBackgroundBox" to
     20        "m_cueHighlightBox" and add a new "m_cueBackdropBox" member.
     21        (WebCore::VTTCue::updateDisplayTree): Update for m_cueHighlightBox.
     22        (WebCore::VTTCue::getDisplayTree): Make m_cueHighlightBox a child
     23        of the new m_cueBackdropBox element, and add m_cueBackdropBox to
     24        the display tree.
     25        * html/track/VTTCue.h:
     26        (WebCore::VTTCue::element):
     27        * page/CaptionUserPreferencesMediaAF.cpp:
     28        (WebCore::CaptionUserPreferencesMediaAF::setInterestedInCaptionPreferenceChanges):
     29        Fix for missing caption style updates. Even if we are already
     30        listening for caption changes, we still want to update the new
     31        instance's style sheet to match.
     32        (WebCore::CaptionUserPreferencesMediaAF::captionsStyleSheetOverride):
     33        * rendering/RenderVTTCue.cpp:
     34        (WebCore::RenderVTTCue::initializeLayoutParameters): Take the new
     35        <div> into consideration when looking for the Cue text element.
     36
    1372014-07-11  Zalan Bujtas  <zalan@apple.com>
    238
  • trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.css

    r169019 r171004  
    729729}
    730730
     731video::-webkit-media-text-track-display-backdrop {
     732    display: inline-block;
     733}
     734
    731735video::cue(:future) {
    732736    color: gray;
  • trunk/Source/WebCore/Modules/mediacontrols/mediaControlsiOS.css

    r169636 r171004  
    381381}
    382382
     383video::-webkit-media-text-track-display-backdrop {
     384    display: inline-block;
     385}
     386
    383387video::cue(:future) {
    384388    color: gray;
  • trunk/Source/WebCore/html/track/VTTCue.cpp

    r170774 r171004  
    217217// ----------------------------
    218218
     219const AtomicString& VTTCue::cueBackdropShadowPseudoId()
     220{
     221    DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, cueBackdropShadowPseudoId, ("-webkit-media-text-track-display-backdrop", AtomicString::ConstructFromLiteral));
     222    return cueBackdropShadowPseudoId;
     223}
     224
    219225PassRefPtr<VTTCue> VTTCue::create(ScriptExecutionContext& context, double start, double end, const String& content)
    220226{
     
    263269    m_cueAlignment = Middle;
    264270    m_webVTTNodeTree = nullptr;
    265     m_cueBackgroundBox = HTMLSpanElement::create(spanTag, toDocument(context));
     271    m_cueBackdropBox = HTMLDivElement::create(toDocument(context));
     272    m_cueHighlightBox = HTMLSpanElement::create(spanTag, toDocument(context));
    266273    m_displayDirection = CSSValueLtr;
    267274    m_displaySize = 0;
     
    758765
    759766    // Clear the contents of the set.
    760     m_cueBackgroundBox->removeChildren();
     767    m_cueHighlightBox->removeChildren();
    761768
    762769    // Update the two sets containing past and future WebVTT objects.
     
    766773
    767774    markFutureAndPastNodes(referenceTree.get(), startTime(), movieTime);
    768     m_cueBackgroundBox->appendChild(referenceTree);
     775    m_cueHighlightBox->appendChild(referenceTree);
    769776}
    770777
     
    789796    // background box.
    790797
    791     // Note: This is contained by default in m_cueBackgroundBox.
    792     m_cueBackgroundBox->setPseudo(cueShadowPseudoId());
    793     displayTree->appendChild(m_cueBackgroundBox, ASSERT_NO_EXCEPTION);
     798    // Note: This is contained by default in m_cueHighlightBox.
     799    m_cueHighlightBox->setPseudo(cueShadowPseudoId());
     800
     801    m_cueBackdropBox->setPseudo(cueBackdropShadowPseudoId());
     802    m_cueBackdropBox->appendChild(m_cueHighlightBox, ASSERT_NO_EXCEPTION);
     803    displayTree->appendChild(m_cueBackdropBox, ASSERT_NO_EXCEPTION);
    794804
    795805    // FIXME(BUG 79916): Runs of children of WebVTT Ruby Objects that are not
  • trunk/Source/WebCore/html/track/VTTCue.h

    r170694 r171004  
    4343
    4444class DocumentFragment;
     45class HTMLDivElement;
    4546class HTMLSpanElement;
    4647class ScriptExecutionContext;
     
    7576    static PassRefPtr<VTTCue> create(ScriptExecutionContext&, const WebVTTCueData&);
    7677
     78    static const AtomicString& cueBackdropShadowPseudoId();
     79
    7780    virtual ~VTTCue();
    7881
     
    114117    bool hasDisplayTree() const { return m_displayTree; }
    115118    VTTCueBox* getDisplayTree(const IntSize& videoSize);
    116     HTMLSpanElement* element() const { return m_cueBackgroundBox.get(); }
     119    HTMLSpanElement* element() const { return m_cueHighlightBox.get(); }
    117120
    118121    void updateDisplayTree(double);
     
    203206
    204207    RefPtr<DocumentFragment> m_webVTTNodeTree;
    205     RefPtr<HTMLSpanElement> m_cueBackgroundBox;
     208    RefPtr<HTMLSpanElement> m_cueHighlightBox;
     209    RefPtr<HTMLDivElement> m_cueBackdropBox;
    206210    RefPtr<VTTCueBox> m_displayTree;
    207211
  • trunk/Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp

    r169725 r171004  
    235235        m_listeningForPreferenceChanges = true;
    236236        CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), this, userCaptionPreferencesChangedNotificationCallback, kMAXCaptionAppearanceSettingsChangedNotification, 0, CFNotificationSuspensionBehaviorCoalesce);
    237         updateCaptionStyleSheetOveride();
    238     }
     237    }
     238
     239    updateCaptionStyleSheetOveride();
    239240}
    240241
     
    541542    if (!windowColor.isEmpty() || !windowCornerRadius.isEmpty()) {
    542543        captionsOverrideStyleSheet.append(" video::");
    543         captionsOverrideStyleSheet.append(VTTCueBox::vttCueBoxShadowPseudoId());
     544        captionsOverrideStyleSheet.append(VTTCue::cueBackdropShadowPseudoId());
    544545        captionsOverrideStyleSheet.append('{');
    545546       
    546547        if (!windowColor.isEmpty())
    547548            captionsOverrideStyleSheet.append(windowColor);
    548         if (!windowCornerRadius.isEmpty())
     549        if (!windowCornerRadius.isEmpty()) {
    549550            captionsOverrideStyleSheet.append(windowCornerRadius);
     551        }
    550552       
    551553        captionsOverrideStyleSheet.append('}');
  • trunk/Source/WebCore/rendering/RenderVTTCue.cpp

    r170774 r171004  
    7575
    7676    RenderBlock* parentBlock = containingBlock();
    77     firstLineBox = toRenderInline(firstChild())->firstLineBox();
     77
     78    // firstChild() returns the wrapping (backdrop) <div>. The cue object is
     79    // the <div>'s first child.
     80    RenderObject* firstChild = this->firstChild();
     81    RenderElement* backdropElement = toRenderElement(firstChild);
     82   
     83    firstLineBox = toRenderInline(backdropElement->firstChild())->firstLineBox();
    7884    if (!firstLineBox)
    7985        firstLineBox = this->firstRootBox();
     
    335341{
    336342    ASSERT(firstChild());
    337     InlineFlowBox* firstLineBox = toRenderInline(firstChild())->firstLineBox();
     343
     344    // firstChild() returns the wrapping (backdrop) <div>. The cue object is
     345    // the <div>'s first child.
     346    RenderObject* firstChild = this->firstChild();
     347    RenderElement* backdropElement = toRenderElement(firstChild);
     348   
     349    InlineFlowBox* firstLineBox = toRenderInline(backdropElement->firstChild())->firstLineBox();
    338350    if (static_cast<TextTrackCueGeneric*>(m_cue)->useDefaultPosition() && firstLineBox) {
    339351        LayoutUnit parentWidth = containingBlock()->logicalWidth();
  • trunk/WebKit.xcworkspace/xcshareddata/xcschemes/All Source.xcscheme

    r168541 r171004  
    131131      <Testables>
    132132      </Testables>
     133      <MacroExpansion>
     134         <BuildableReference
     135            BuildableIdentifier = "primary"
     136            BlueprintIdentifier = "8D1107260486CEB800E47090"
     137            BuildableName = "MiniBrowser.app"
     138            BlueprintName = "MiniBrowser"
     139            ReferencedContainer = "container:Tools/MiniBrowser/MiniBrowser.xcodeproj">
     140         </BuildableReference>
     141      </MacroExpansion>
    133142   </TestAction>
    134143   <LaunchAction
     
    141150      debugDocumentVersioning = "YES"
    142151      allowLocationSimulation = "YES">
    143       <PathRunnable
    144          FilePath = "/Applications/Safari.app/Contents/MacOS/SafariForWebKitDevelopment">
    145       </PathRunnable>
     152      <BuildableProductRunnable>
     153         <BuildableReference
     154            BuildableIdentifier = "primary"
     155            BlueprintIdentifier = "8D1107260486CEB800E47090"
     156            BuildableName = "MiniBrowser.app"
     157            BlueprintName = "MiniBrowser"
     158            ReferencedContainer = "container:Tools/MiniBrowser/MiniBrowser.xcodeproj">
     159         </BuildableReference>
     160      </BuildableProductRunnable>
    146161      <AdditionalOptions>
    147162      </AdditionalOptions>
Note: See TracChangeset for help on using the changeset viewer.