Title: [137955] trunk
Revision
137955
Author
[email protected]
Date
2012-12-17 16:01:39 -0800 (Mon, 17 Dec 2012)

Log Message

Implement matching cue by the class name with ::cue pseudo element
https://bugs.webkit.org/show_bug.cgi?id=104191

Patch by Dima Gorbik <[email protected]> on 2012-12-17
Reviewed by Antti Koivisto.

Source/WebCore:

Implemented the ::cue() pseudo-element with an argument that may hold a simple selector list.
This enables matching cue objects by the class name.

Test: media/track/track-css-matching.html

* css/CSSGrammar.y.in: support parsing the ::cue() with an argument.
* css/CSSParser.cpp:
(WebCore::CSSParser::detectFunctionTypeToken): tokenize the 'cue'.
(WebCore::CSSParser::updateSpecifiersWithElementName): do not set the tag for the cue pseudo-element because
the ::cue may match elements with different tags.
(WebCore::CSSParser::updateSpecifiers): the behavior for the PseudoCue selector should be same as for
unknown pseudo elements - the pseudo-element should stay on top of the selector chain.
* css/CSSSelector.cpp: added the type detection for the new selector.
(WebCore::CSSSelector::pseudoId):
(WebCore::nameToPseudoTypeMap):
(WebCore::CSSSelector::extractPseudoType):
* css/CSSSelector.h:
* css/RuleSet.cpp: add a new list to hold all the rulesets for the new pseudo element.
(WebCore::RuleSet::reportMemoryUsage):
(WebCore::RuleSet::addRule):
(WebCore::RuleSet::shrinkToFit):
* css/RuleSet.h:
(RuleSet):
(WebCore::RuleSet::cuePseudoRules):
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOneSelector):
* css/SelectorChecker.h:
(WebCore::SelectorChecker::SelectorCheckingContext::SelectorCheckingContext):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::collectMatchingRules):
* dom/Element.cpp: an addition to the rare data to be able to find out if the node is a webvtt node.
(WebCore):
(WebCore::Element::isWebVTTNode):
(WebCore::Element::setIsWebVTTNode):
(WebCore::Element::cloneDataFromElement):
* dom/Element.h:
(Element):
* dom/ElementRareData.h:
(ElementRareData):
* dom/NodeRareData.h:
(WebCore::NodeRareData::NodeRareData):
(NodeRareData):
(WebCore::NodeRareData::isWebVTTNode):
(WebCore::NodeRareData::setIsWebVTTNode):
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::markNodesAsWebVTTNodes): mark the cloned nodes as WebVTT nodes.
(WebCore):
(WebCore::TextTrackCue::getCueAsHTML):
* html/track/TextTrackCue.h:
(TextTrackCue):
* html/track/WebVTTParser.cpp:
(WebCore::WebVTTParser::constructTreeFromToken):
* rendering/style/RenderStyleConstants.h:

LayoutTests:

Verify that ::cue pseudo-element accepts a simple-selector list that matches cue objects by the a class.

* media/track/captions-webvtt/styling.vtt:
* media/track/track-css-matching-expected.txt: Added.
* media/track/track-css-matching.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (137954 => 137955)


--- trunk/LayoutTests/ChangeLog	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/LayoutTests/ChangeLog	2012-12-18 00:01:39 UTC (rev 137955)
@@ -1,3 +1,16 @@
+2012-12-17  Dima Gorbik  <[email protected]>
+
+        Implement matching cue by the class name with ::cue pseudo element
+        https://bugs.webkit.org/show_bug.cgi?id=104191
+
+        Reviewed by Antti Koivisto.
+
+        Verify that ::cue pseudo-element accepts a simple-selector list that matches cue objects by the a class.
+
+        * media/track/captions-webvtt/styling.vtt:
+        * media/track/track-css-matching-expected.txt: Added.
+        * media/track/track-css-matching.html: Added.
+
 2012-12-14  Ryosuke Niwa  <[email protected]>
 
         Layout Test editing/selection/move-by-character-crash-test-textarea.html is flaky

Modified: trunk/LayoutTests/media/track/captions-webvtt/styling.vtt (137954 => 137955)


--- trunk/LayoutTests/media/track/captions-webvtt/styling.vtt	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/LayoutTests/media/track/captions-webvtt/styling.vtt	2012-12-18 00:01:39 UTC (rev 137955)
@@ -1,4 +1,9 @@
 WEBVTT
 
-00:00.000 --> 00:04.000
-Lorum ipsum
\ No newline at end of file
+1
+00:00.000 --> 00:01.000
+Lorum ipsum
+
+2
+00:01.000 --> 00:02.000
+<c.red>dolor sit </c><c.green>amet, consectetur </c><c.red2>adipiscing elit</c>

Added: trunk/LayoutTests/media/track/track-css-matching-expected.txt (0 => 137955)


--- trunk/LayoutTests/media/track/track-css-matching-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/track/track-css-matching-expected.txt	2012-12-18 00:01:39 UTC (rev 137955)
@@ -0,0 +1,8 @@
+Test that cues are being matched properly by the class name
+EVENT(canplaythrough)
+EVENT(seeked)
+EXPECTED (getComputedStyle(cueNode).color == 'rgb(255, 0, 0)') OK
+EXPECTED (getComputedStyle(cueNode).color == 'rgb(0, 128, 0)') OK
+EXPECTED (getComputedStyle(cueNode).color == 'rgb(255, 0, 0)') OK
+END OF TEST
+

Added: trunk/LayoutTests/media/track/track-css-matching.html (0 => 137955)


--- trunk/LayoutTests/media/track/track-css-matching.html	                        (rev 0)
+++ trunk/LayoutTests/media/track/track-css-matching.html	2012-12-18 00:01:39 UTC (rev 137955)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+        <script src=""
+        <script src=""
+        <script src=""
+
+        <style>
+
+        video::cue(.red, .red2) { color:red }
+        #testvideo::cue(.green) { color:green }
+
+        </style>
+
+        <script>
+
+        var cueNode;
+
+        function seeked()
+        {
+            cueNode = textTrackDisplayElement(video, 'past-nodes').firstChild;
+            testExpected("getComputedStyle(cueNode).color", "rgb(255, 0, 0)");
+            cueNode = cueNode.nextSibling;
+            testExpected("getComputedStyle(cueNode).color", "rgb(0, 128, 0)");
+            cueNode = cueNode.nextSibling;
+            testExpected("getComputedStyle(cueNode).color", "rgb(255, 0, 0)");
+            endTest();
+        }
+
+        function loaded()
+        {
+            consoleWrite("Test that cues are being matched properly by the class name");
+            findMediaElement();
+            video.src = "" '../content/test');
+            video.id = "testvideo";
+            waitForEvent('seeked', seeked);
+            waitForEvent('canplaythrough', function() { video.currentTime = 1.5; });
+        }
+
+        </script>
+    </head>
+    <body _onload_="loaded()">
+        <video controls >
+            <track src="" kind="captions" default>
+        </video>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (137954 => 137955)


--- trunk/Source/WebCore/ChangeLog	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/ChangeLog	2012-12-18 00:01:39 UTC (rev 137955)
@@ -1,3 +1,64 @@
+2012-12-17  Dima Gorbik  <[email protected]>
+
+        Implement matching cue by the class name with ::cue pseudo element
+        https://bugs.webkit.org/show_bug.cgi?id=104191
+
+        Reviewed by Antti Koivisto.
+
+        Implemented the ::cue() pseudo-element with an argument that may hold a simple selector list.
+        This enables matching cue objects by the class name.
+
+        Test: media/track/track-css-matching.html
+
+        * css/CSSGrammar.y.in: support parsing the ::cue() with an argument.
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::detectFunctionTypeToken): tokenize the 'cue'.
+        (WebCore::CSSParser::updateSpecifiersWithElementName): do not set the tag for the cue pseudo-element because
+        the ::cue may match elements with different tags.
+        (WebCore::CSSParser::updateSpecifiers): the behavior for the PseudoCue selector should be same as for
+        unknown pseudo elements - the pseudo-element should stay on top of the selector chain.
+        * css/CSSSelector.cpp: added the type detection for the new selector.
+        (WebCore::CSSSelector::pseudoId):
+        (WebCore::nameToPseudoTypeMap):
+        (WebCore::CSSSelector::extractPseudoType):
+        * css/CSSSelector.h:
+        * css/RuleSet.cpp: add a new list to hold all the rulesets for the new pseudo element.
+        (WebCore::RuleSet::reportMemoryUsage):
+        (WebCore::RuleSet::addRule):
+        (WebCore::RuleSet::shrinkToFit):
+        * css/RuleSet.h:
+        (RuleSet):
+        (WebCore::RuleSet::cuePseudoRules):
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::checkOneSelector):
+        * css/SelectorChecker.h:
+        (WebCore::SelectorChecker::SelectorCheckingContext::SelectorCheckingContext):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::collectMatchingRules):
+        * dom/Element.cpp: an addition to the rare data to be able to find out if the node is a webvtt node.
+        (WebCore):
+        (WebCore::Element::isWebVTTNode):
+        (WebCore::Element::setIsWebVTTNode):
+        (WebCore::Element::cloneDataFromElement):
+        * dom/Element.h:
+        (Element):
+        * dom/ElementRareData.h:
+        (ElementRareData):
+        * dom/NodeRareData.h:
+        (WebCore::NodeRareData::NodeRareData):
+        (NodeRareData):
+        (WebCore::NodeRareData::isWebVTTNode):
+        (WebCore::NodeRareData::setIsWebVTTNode):
+        * html/track/TextTrackCue.cpp:
+        (WebCore::TextTrackCue::markNodesAsWebVTTNodes): mark the cloned nodes as WebVTT nodes.
+        (WebCore):
+        (WebCore::TextTrackCue::getCueAsHTML):
+        * html/track/TextTrackCue.h:
+        (TextTrackCue):
+        * html/track/WebVTTParser.cpp:
+        (WebCore::WebVTTParser::constructTreeFromToken):
+        * rendering/style/RenderStyleConstants.h:
+
 2012-12-17  Michael Pruett  <[email protected]>
 
         IndexedDB: Don't use strings to represent serialized values

Modified: trunk/Source/WebCore/css/CSSGrammar.y.in (137954 => 137955)


--- trunk/Source/WebCore/css/CSSGrammar.y.in	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/css/CSSGrammar.y.in	2012-12-18 00:01:39 UTC (rev 137955)
@@ -173,6 +173,9 @@
 %token <string> URI
 %token <string> FUNCTION
 %token <string> ANYFUNCTION
+#if ENABLE_VIDEO_TRACK
+%token <string> CUEFUNCTION
+#endif
 %token <string> NOTFUNCTION
 %token <string> CALCFUNCTION
 %token <string> MINFUNCTION
@@ -1323,6 +1326,21 @@
         if (type == CSSSelector::PseudoUnknown)
             $$ = 0;
     }
+#if ENABLE_VIDEO_TRACK
+    // used by ::cue(:past/:future)
+    | ':' ':' CUEFUNCTION maybe_space simple_selector_list maybe_space ')' {
+        if ($5) {
+            $$ = parser->createFloatingSelector();
+            $$->setMatch(CSSSelector::PseudoClass);
+            $$->adoptSelectorVector(*parser->sinkFloatingSelectorVector($5));
+            $$->setValue($3);
+            CSSSelector::PseudoType type = $$->pseudoType();
+            if (type != CSSSelector::PseudoCue)
+                $$ = 0;
+        } else
+            $$ = 0;
+    }
+#endif
     // use by :-webkit-any.
     // FIXME: should we support generic selectors here or just simple_selectors?
     // Use simple_selector_list for now to match -moz-any.

Modified: trunk/Source/WebCore/css/CSSParser.cpp (137954 => 137955)


--- trunk/Source/WebCore/css/CSSParser.cpp	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2012-12-18 00:01:39 UTC (rev 137955)
@@ -9485,6 +9485,10 @@
             m_token = NOTFUNCTION;
         else if (isASCIIAlphaCaselessEqual(name[0], 'u') && isASCIIAlphaCaselessEqual(name[1], 'r') && isASCIIAlphaCaselessEqual(name[2], 'l'))
             m_token = URI;
+#if ENABLE(VIDEO_TRACK)
+        else if (isASCIIAlphaCaselessEqual(name[0], 'c') && isASCIIAlphaCaselessEqual(name[1], 'u') && isASCIIAlphaCaselessEqual(name[2], 'e'))
+            m_token = CUEFUNCTION;
+#endif
         return;
 
     case 9:
@@ -10602,7 +10606,10 @@
     AtomicString determinedNamespace = namespacePrefix != nullAtom && m_styleSheet ? m_styleSheet->determineNamespace(namespacePrefix) : m_defaultNamespace;
     QualifiedName tag = QualifiedName(namespacePrefix, elementName, determinedNamespace);
     if (!specifiers->isCustomPseudoElement()) {
-        specifiers->setTag(tag);
+#if ENABLE(VIDEO_TRACK)
+        if (!(specifiers->pseudoType() == CSSSelector::PseudoCue))
+#endif
+            specifiers->setTag(tag);
         return;
     }
 
@@ -10629,7 +10636,11 @@
 
 CSSParserSelector* CSSParser::updateSpecifiers(CSSParserSelector* specifiers, CSSParserSelector* newSpecifier)
 {
+#if ENABLE(VIDEO_TRACK)
+    if (newSpecifier->isCustomPseudoElement() || newSpecifier->pseudoType() == CSSSelector::PseudoCue) {
+#else
     if (newSpecifier->isCustomPseudoElement()) {
+#endif
         // Unknown pseudo element always goes at the top of selector chain.
         newSpecifier->appendTagHistory(CSSSelector::ShadowDescendant, sinkFloatingSelector(specifiers));
         return newSpecifier;

Modified: trunk/Source/WebCore/css/CSSSelector.cpp (137954 => 137955)


--- trunk/Source/WebCore/css/CSSSelector.cpp	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/css/CSSSelector.cpp	2012-12-18 00:01:39 UTC (rev 137955)
@@ -220,6 +220,9 @@
     case PseudoOutOfRange:
     case PseudoUserAgentCustomElement:
     case PseudoWebKitCustomElement:
+#if ENABLE(VIDEO_TRACK)
+    case PseudoCue:
+#endif
         return NOPSEUDO;
     case PseudoNotParsed:
         ASSERT_NOT_REACHED();
@@ -302,6 +305,9 @@
     DEFINE_STATIC_LOCAL(AtomicString, fullScreenAncestor, ("-webkit-full-screen-ancestor", AtomicString::ConstructFromLiteral));
     DEFINE_STATIC_LOCAL(AtomicString, animatingFullScreenTransition, ("-webkit-animating-full-screen-transition", AtomicString::ConstructFromLiteral));
 #endif
+#if ENABLE(VIDEO_TRACK)
+    DEFINE_STATIC_LOCAL(AtomicString, cue, ("cue(", AtomicString::ConstructFromLiteral));
+#endif
     DEFINE_STATIC_LOCAL(AtomicString, inRange, ("in-range", AtomicString::ConstructFromLiteral));
     DEFINE_STATIC_LOCAL(AtomicString, outOfRange, ("out-of-range", AtomicString::ConstructFromLiteral));
 
@@ -377,6 +383,9 @@
         nameToPseudoType->set(fullScreenAncestor.impl(), CSSSelector::PseudoFullScreenAncestor);
         nameToPseudoType->set(animatingFullScreenTransition.impl(), CSSSelector::PseudoAnimatingFullScreenTransition);
 #endif
+#if ENABLE(VIDEO_TRACK)
+        nameToPseudoType->set(cue.impl(), CSSSelector::PseudoCue);
+#endif
         nameToPseudoType->set(inRange.impl(), CSSSelector::PseudoInRange);
         nameToPseudoType->set(outOfRange.impl(), CSSSelector::PseudoOutOfRange);
     }
@@ -421,6 +430,9 @@
     switch (m_pseudoType) {
     case PseudoAfter:
     case PseudoBefore:
+#if ENABLE(VIDEO_TRACK)
+    case PseudoCue:
+#endif
     case PseudoFirstLetter:
     case PseudoFirstLine:
         compat = true;

Modified: trunk/Source/WebCore/css/CSSSelector.h (137954 => 137955)


--- trunk/Source/WebCore/css/CSSSelector.h	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/css/CSSSelector.h	2012-12-18 00:01:39 UTC (rev 137955)
@@ -156,6 +156,9 @@
             PseudoOutOfRange,
             PseudoUserAgentCustomElement,
             PseudoWebKitCustomElement,
+#if ENABLE(VIDEO_TRACK)
+            PseudoCue,
+#endif
         };
 
         enum MarginBoxType {

Modified: trunk/Source/WebCore/css/RuleSet.cpp (137954 => 137955)


--- trunk/Source/WebCore/css/RuleSet.cpp	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/css/RuleSet.cpp	2012-12-18 00:01:39 UTC (rev 137955)
@@ -145,6 +145,9 @@
     reportAtomRuleMap(&info, m_tagRules);
     reportAtomRuleMap(&info, m_shadowPseudoElementRules);
     info.addMember(m_linkPseudoClassRules);
+#if ENABLE(VIDEO_TRACK)
+    info.addMember(m_cuePseudoRules);
+#endif
     info.addMember(m_focusPseudoClassRules);
     info.addMember(m_universalRules);
     info.addMember(m_pageRules);
@@ -208,6 +211,12 @@
         addToRuleSet(selector->value().impl(), m_shadowPseudoElementRules, ruleData);
         return;
     }
+#if ENABLE(VIDEO_TRACK)
+    if (selector->pseudoType() == CSSSelector::PseudoCue) {
+        m_cuePseudoRules.append(ruleData);
+        return;
+    }
+#endif
     if (SelectorChecker::isCommonPseudoClassSelector(selector)) {
         switch (selector->pseudoType()) {
         case CSSSelector::PseudoLink:
@@ -377,6 +386,9 @@
     shrinkMapVectorsToFit(m_tagRules);
     shrinkMapVectorsToFit(m_shadowPseudoElementRules);
     m_linkPseudoClassRules.shrinkToFit();
+#if ENABLE(VIDEO_TRACK)
+    m_cuePseudoRules.shrinkToFit();
+#endif
     m_focusPseudoClassRules.shrinkToFit();
     m_universalRules.shrinkToFit();
     m_pageRules.shrinkToFit();

Modified: trunk/Source/WebCore/css/RuleSet.h (137954 => 137955)


--- trunk/Source/WebCore/css/RuleSet.h	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/css/RuleSet.h	2012-12-18 00:01:39 UTC (rev 137955)
@@ -120,6 +120,9 @@
     const Vector<RuleData>* tagRules(AtomicStringImpl* key) const { return m_tagRules.get(key); }
     const Vector<RuleData>* shadowPseudoElementRules(AtomicStringImpl* key) const { return m_shadowPseudoElementRules.get(key); }
     const Vector<RuleData>* linkPseudoClassRules() const { return &m_linkPseudoClassRules; }
+#if ENABLE(VIDEO_TRACK)
+    const Vector<RuleData>* cuePseudoRules() const { return &m_cuePseudoRules; }
+#endif
     const Vector<RuleData>* focusPseudoClassRules() const { return &m_focusPseudoClassRules; }
     const Vector<RuleData>* universalRules() const { return &m_universalRules; }
     const Vector<StyleRulePage*>& pageRules() const { return m_pageRules; }
@@ -134,6 +137,9 @@
     AtomRuleMap m_tagRules;
     AtomRuleMap m_shadowPseudoElementRules;
     Vector<RuleData> m_linkPseudoClassRules;
+#if ENABLE(VIDEO_TRACK)
+    Vector<RuleData> m_cuePseudoRules;
+#endif
     Vector<RuleData> m_focusPseudoClassRules;
     Vector<RuleData> m_universalRules;
     Vector<StyleRulePage*> m_pageRules;

Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (137954 => 137955)


--- trunk/Source/WebCore/css/SelectorChecker.cpp	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp	2012-12-18 00:01:39 UTC (rev 137955)
@@ -1132,6 +1132,20 @@
         }
         return false;
     }
+#if ENABLE(VIDEO_TRACK)
+    else if (selector->m_match == CSSSelector::PseudoElement && selector->pseudoType() == CSSSelector::PseudoCue) {
+        SelectorCheckingContext subContext(context);
+        subContext.isSubSelector = true;
+
+        PseudoId ignoreDynamicPseudo = NOPSEUDO;
+        CSSSelector* const & selector = context.selector;
+        for (subContext.selector = selector->selectorList()->first(); subContext.selector; subContext.selector = CSSSelectorList::next(subContext.selector)) {
+            if (checkSelector(subContext, ignoreDynamicPseudo) == SelectorMatches)
+                return true;
+        }
+        return false;
+    }
+#endif
     // ### add the rest of the checks...
     return true;
 }

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (137954 => 137955)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2012-12-18 00:01:39 UTC (rev 137955)
@@ -649,6 +649,10 @@
         collectMatchingRulesForList(rules->shadowPseudoElementRules(pseudoId.impl()), firstRuleIndex, lastRuleIndex, options);
     }
 
+#if ENABLE(VIDEO_TRACK)
+    if (m_element->isWebVTTNode())
+        collectMatchingRulesForList(rules->cuePseudoRules(), firstRuleIndex, lastRuleIndex, options);
+#endif
     // Check whether other types of rules are applicable in the current tree scope. Criteria for this:
     // a) it's a UA rule
     // b) the tree scope allows author rules

Modified: trunk/Source/WebCore/dom/Element.cpp (137954 => 137955)


--- trunk/Source/WebCore/dom/Element.cpp	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/dom/Element.cpp	2012-12-18 00:01:39 UTC (rev 137955)
@@ -2278,7 +2278,19 @@
     return ContainerNode::childShouldCreateRenderer(childContext);
 }
 #endif
-    
+
+#if ENABLE(VIDEO_TRACK)
+bool Element::isWebVTTNode() const
+{
+    return hasRareData() && elementRareData()->isWebVTTNode();
+}
+
+void Element::setIsWebVTTNode(bool flag)
+{
+    ensureElementRareData()->setIsWebVTTNode(flag);
+}
+#endif
+
 #if ENABLE(FULLSCREEN_API)
 void Element::webkitRequestFullscreen()
 {

Modified: trunk/Source/WebCore/dom/Element.h (137954 => 137955)


--- trunk/Source/WebCore/dom/Element.h	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/dom/Element.h	2012-12-18 00:01:39 UTC (rev 137955)
@@ -431,6 +431,11 @@
 #if ENABLE(SVG)
     virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const;
 #endif
+
+#if ENABLE(VIDEO_TRACK)
+    bool isWebVTTNode() const;
+    void setIsWebVTTNode(bool flag);
+#endif
     
 #if ENABLE(FULLSCREEN_API)
     enum {

Modified: trunk/Source/WebCore/dom/ElementRareData.h (137954 => 137955)


--- trunk/Source/WebCore/dom/ElementRareData.h	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/dom/ElementRareData.h	2012-12-18 00:01:39 UTC (rev 137955)
@@ -54,6 +54,10 @@
     bool isInCanvasSubtree() const { return m_isInCanvasSubtree; }
     void setIsInCanvasSubtree(bool value) { m_isInCanvasSubtree = value; }
 
+#if ENABLE(VIDEO_TRACK)
+    using NodeRareData::isWebVTTNode;
+    using NodeRareData::setIsWebVTTNode;
+#endif
 #if ENABLE(FULLSCREEN_API)
     bool containsFullScreenElement() { return m_containsFullScreenElement; }
     void setContainsFullScreenElement(bool value) { m_containsFullScreenElement = value; }

Modified: trunk/Source/WebCore/dom/NodeRareData.h (137954 => 137955)


--- trunk/Source/WebCore/dom/NodeRareData.h	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/dom/NodeRareData.h	2012-12-18 00:01:39 UTC (rev 137955)
@@ -254,6 +254,9 @@
         , m_needsFocusAppearanceUpdateSoonAfterAttach(false)
         , m_styleAffectedByEmpty(false)
         , m_isInCanvasSubtree(false)
+#if ENABLE(VIDEO_TRACK)
+        , m_isWebVTTNode(false)
+#endif
 #if ENABLE(FULLSCREEN_API)
         , m_containsFullScreenElement(false)
 #endif
@@ -367,12 +370,19 @@
     virtual void reportMemoryUsage(MemoryObjectInfo*) const;
 
 protected:
+#if ENABLE(VIDEO_TRACK)
+    bool isWebVTTNode() { return m_isWebVTTNode; }
+    void setIsWebVTTNode(bool value) { m_isWebVTTNode = value; }
+#endif
     short m_tabIndex;
     unsigned short m_childIndex;
     bool m_tabIndexWasSetExplicitly : 1;
     bool m_needsFocusAppearanceUpdateSoonAfterAttach : 1;
     bool m_styleAffectedByEmpty : 1;
     bool m_isInCanvasSubtree : 1;
+#if ENABLE(VIDEO_TRACK)
+    bool m_isWebVTTNode : 1;
+#endif
 #if ENABLE(FULLSCREEN_API)
     bool m_containsFullScreenElement : 1;
 #endif

Modified: trunk/Source/WebCore/html/track/TextTrackCue.cpp (137954 => 137955)


--- trunk/Source/WebCore/html/track/TextTrackCue.cpp	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/html/track/TextTrackCue.cpp	2012-12-18 00:01:39 UTC (rev 137955)
@@ -41,6 +41,7 @@
 #include "Event.h"
 #include "HTMLDivElement.h"
 #include "HTMLMediaElement.h"
+#include "NodeTraversal.h"
 #include "RenderTextTrackCue.h"
 #include "Text.h"
 #include "TextTrack.h"
@@ -487,6 +488,12 @@
     m_cueIndex = invalidCueIndex;
 }
 
+void TextTrackCue::markNodesAsWebVTTNodes(Node* root)
+{
+    for (Element* child = ElementTraversal::firstWithin(root); child; child = ElementTraversal::next(child, root))
+        child->setIsWebVTTNode(true);
+}
+
 PassRefPtr<DocumentFragment> TextTrackCue::getCueAsHTML()
 {
     RefPtr<DocumentFragment> clonedFragment;
@@ -509,6 +516,7 @@
 
     clonedFragment = DocumentFragment::create(document);
     m_documentFragment->cloneChildNodes(clonedFragment.get());
+    markNodesAsWebVTTNodes(clonedFragment.get());
 
     return clonedFragment.release();
 }

Modified: trunk/Source/WebCore/html/track/TextTrackCue.h (137954 => 137955)


--- trunk/Source/WebCore/html/track/TextTrackCue.h	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/html/track/TextTrackCue.h	2012-12-18 00:01:39 UTC (rev 137955)
@@ -125,6 +125,7 @@
     void invalidateCueIndex();
 
     PassRefPtr<DocumentFragment> getCueAsHTML();
+    void markNodesAsWebVTTNodes(Node*);
 
     virtual bool dispatchEvent(PassRefPtr<Event>);
     bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&);

Modified: trunk/Source/WebCore/html/track/WebVTTParser.cpp (137954 => 137955)


--- trunk/Source/WebCore/html/track/WebVTTParser.cpp	2012-12-17 23:59:47 UTC (rev 137954)
+++ trunk/Source/WebCore/html/track/WebVTTParser.cpp	2012-12-18 00:01:39 UTC (rev 137955)
@@ -364,6 +364,7 @@
             child = HTMLElement::create(qTag, document);
 
         if (child) {
+            child->setIsWebVTTNode(true);
             if (m_token.classes().size() > 0)
                 child->setAttribute(classAttr, AtomicString(m_token.classes().data(), m_token.classes().size()));
             if (child->hasTagName(qTag))
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to