Title: [140231] trunk/Source/WebCore
Revision
140231
Author
[email protected]
Date
2013-01-18 19:59:49 -0800 (Fri, 18 Jan 2013)

Log Message

Remove a TextTrack.h include from the Element.h and move WebVTT related stuff outside the Element
https://bugs.webkit.org/show_bug.cgi?id=107080

Patch by Dima Gorbik <[email protected]> on 2013-01-18
Reviewed by Sam Weinig.

WebVTT objects are now subclasses of the Element. This allows us to remove major WebVTT chunks of code from
Element.h and NodeRareData. WebVTTElement is deriving from HTMLElement and not Element to prevent possible
problems that could happen because we reuse qTags that are being used in HTML like <b>, <i> and <u>.

No new tests. This is just a refactoring of the existing code.

* CMakeLists.txt:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::collectMatchingRules):
(WebCore::StyleResolver::canShareStyleWithElement):
* dom/Element.cpp:
* dom/Element.h:
* dom/ElementRareData.h:
(WebCore::ElementRareData::ElementRareData):
* dom/Node.h:
(WebCore::Node::isWebVTTElement):
* html/track/TextTrack.h:
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::copyWebVTTNodeToDOMTree):
(WebCore::TextTrackCue::markFutureAndPastNodes):
* html/track/WebVTTElement.cpp: Added.
(WebCore::WebVTTElement::create):
(WebCore::WebVTTElement::cloneElementWithoutAttributesAndChildren):
* html/track/WebVTTElement.h: Added.
(WebCore::WebVTTElement::setWebVTTNodeType):
(WebCore::WebVTTElement::webVTTNodeType):
(WebCore::WebVTTElement::WebVTTElement):
(WebCore::toWebVTTElement):
* html/track/WebVTTParser.cpp:
(WebCore::WebVTTParser::constructTreeFromToken):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (140230 => 140231)


--- trunk/Source/WebCore/CMakeLists.txt	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/CMakeLists.txt	2013-01-19 03:59:49 UTC (rev 140231)
@@ -1584,6 +1584,7 @@
     html/track/TextTrackList.cpp
     html/track/TrackBase.cpp
     html/track/TrackEvent.cpp
+    html/track/WebVTTElement.cpp
     html/track/WebVTTParser.cpp
     html/track/WebVTTTokenizer.cpp
 

Modified: trunk/Source/WebCore/ChangeLog (140230 => 140231)


--- trunk/Source/WebCore/ChangeLog	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/ChangeLog	2013-01-19 03:59:49 UTC (rev 140231)
@@ -1,3 +1,45 @@
+2013-01-18  Dima Gorbik  <[email protected]>
+
+        Remove a TextTrack.h include from the Element.h and move WebVTT related stuff outside the Element
+        https://bugs.webkit.org/show_bug.cgi?id=107080
+
+        Reviewed by Sam Weinig.
+
+        WebVTT objects are now subclasses of the Element. This allows us to remove major WebVTT chunks of code from
+        Element.h and NodeRareData. WebVTTElement is deriving from HTMLElement and not Element to prevent possible
+        problems that could happen because we reuse qTags that are being used in HTML like <b>, <i> and <u>.
+
+        No new tests. This is just a refactoring of the existing code.
+
+        * CMakeLists.txt:
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::checkOne):
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::collectMatchingRules):
+        (WebCore::StyleResolver::canShareStyleWithElement):
+        * dom/Element.cpp:
+        * dom/Element.h:
+        * dom/ElementRareData.h:
+        (WebCore::ElementRareData::ElementRareData):
+        * dom/Node.h:
+        (WebCore::Node::isWebVTTElement):
+        * html/track/TextTrack.h:
+        * html/track/TextTrackCue.cpp:
+        (WebCore::TextTrackCue::copyWebVTTNodeToDOMTree):
+        (WebCore::TextTrackCue::markFutureAndPastNodes):
+        * html/track/WebVTTElement.cpp: Added.
+        (WebCore::WebVTTElement::create):
+        (WebCore::WebVTTElement::cloneElementWithoutAttributesAndChildren):
+        * html/track/WebVTTElement.h: Added.
+        (WebCore::WebVTTElement::setWebVTTNodeType):
+        (WebCore::WebVTTElement::webVTTNodeType):
+        (WebCore::WebVTTElement::WebVTTElement):
+        (WebCore::toWebVTTElement):
+        * html/track/WebVTTParser.cpp:
+        (WebCore::WebVTTParser::constructTreeFromToken):
+
 2013-01-18  Beth Dakin  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=106946

Modified: trunk/Source/WebCore/WebCore.gypi (140230 => 140231)


--- trunk/Source/WebCore/WebCore.gypi	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/WebCore.gypi	2013-01-19 03:59:49 UTC (rev 140231)
@@ -3447,6 +3447,8 @@
             'html/track/TextTrackList.cpp',
             'html/track/TrackBase.cpp',
             'html/track/TrackEvent.cpp',
+            'html/track/WebVTTElement.cpp',
+            'html/track/WebVTTElement.h',
             'html/track/WebVTTParser.cpp',
             'html/track/WebVTTParser.h',
             'html/track/WebVTTToken.h',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (140230 => 140231)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2013-01-19 03:59:49 UTC (rev 140231)
@@ -65241,6 +65241,14 @@
 					>
 				</File>
 				<File
+					RelativePath="..\html\track\WebVTTElement.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\html\track\WebVTTElement.h"
+					>
+				</File>
+				<File
 					RelativePath="..\html\track\WebVTTParser.cpp"
 					>
 				</File>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (140230 => 140231)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2013-01-19 03:59:49 UTC (rev 140231)
@@ -6308,6 +6308,8 @@
 		ED501DC60B249F2900AE18D9 /* EditorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = ED501DC50B249F2900AE18D9 /* EditorMac.mm */; };
 		EDE3A5000C7A430600956A37 /* ColorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = EDE3A4FF0C7A430600956A37 /* ColorMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		EDEC98030AED7E170059137F /* WebCorePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = EDEC98020AED7E170059137F /* WebCorePrefix.h */; };
+		F12171F516A8CED2000053CA /* WebVTTElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F12171F316A8BC63000053CA /* WebVTTElement.cpp */; };
+		F12171F616A8CF0B000053CA /* WebVTTElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F12171F416A8BC63000053CA /* WebVTTElement.h */; };
 		F293B27E56C112F373FFF27E /* DNSResolveQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C60128060078BB70E367A95 /* DNSResolveQueue.cpp */; };
 		F316396B1329481A00A649CB /* InjectedScriptManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F31639691329481A00A649CB /* InjectedScriptManager.cpp */; };
 		F316396C1329481A00A649CB /* InjectedScriptManager.h in Headers */ = {isa = PBXBuildFile; fileRef = F316396A1329481A00A649CB /* InjectedScriptManager.h */; };
@@ -13898,6 +13900,8 @@
 		ED501DC50B249F2900AE18D9 /* EditorMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = EditorMac.mm; path = mac/EditorMac.mm; sourceTree = "<group>"; };
 		EDE3A4FF0C7A430600956A37 /* ColorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorMac.h; sourceTree = "<group>"; };
 		EDEC98020AED7E170059137F /* WebCorePrefix.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCorePrefix.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
+		F12171F316A8BC63000053CA /* WebVTTElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebVTTElement.cpp; sourceTree = "<group>"; };
+		F12171F416A8BC63000053CA /* WebVTTElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVTTElement.h; sourceTree = "<group>"; };
 		F31639691329481A00A649CB /* InjectedScriptManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScriptManager.cpp; sourceTree = "<group>"; };
 		F316396A1329481A00A649CB /* InjectedScriptManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScriptManager.h; sourceTree = "<group>"; };
 		F316396D1329487600A649CB /* JSInjectedScriptManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInjectedScriptManager.cpp; sourceTree = "<group>"; };
@@ -19718,6 +19722,8 @@
 		B1AD4E7713A12A7200846B27 /* track */ = {
 			isa = PBXGroup;
 			children = (
+				F12171F316A8BC63000053CA /* WebVTTElement.cpp */,
+				F12171F416A8BC63000053CA /* WebVTTElement.h */,
 				0794178F166E855F009416C2 /* InbandTextTrack.cpp */,
 				07941790166E855F009416C2 /* InbandTextTrack.h */,
 				9759E93414EF1CF80026A2DD /* LoadableTextTrack.cpp */,
@@ -26254,6 +26260,7 @@
 				977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
 				FD537353137B651800008DCE /* ZeroPole.h in Headers */,
 				FB49C39D16784947007FFB5D /* CSSHostRule.h in Headers */,
+				F12171F616A8CF0B000053CA /* WebVTTElement.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -29403,6 +29410,7 @@
 				977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */,
 				FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
 				FB49C39A16784932007FFB5D /* CSSHostRule.cpp in Sources */,
+				F12171F516A8CED2000053CA /* WebVTTElement.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (140230 => 140231)


--- trunk/Source/WebCore/css/SelectorChecker.cpp	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp	2013-01-19 03:59:49 UTC (rev 140231)
@@ -53,6 +53,10 @@
 #include "StyledElement.h"
 #include "Text.h"
 
+#if ENABLE(VIDEO_TRACK)
+#include "WebVTTElement.h"
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -941,7 +945,7 @@
             return element->isOutOfRange();
 #if ENABLE(VIDEO_TRACK)
         case CSSSelector::PseudoFutureCue:
-            return element->webVTTNodeType() == WebVTTNodeTypeFuture;
+            return (element->isWebVTTElement() && toWebVTTElement(element)->webVTTNodeType() == WebVTTNodeTypeFuture);
 #endif
 
         case CSSSelector::PseudoHorizontal:

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (140230 => 140231)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2013-01-19 03:59:49 UTC (rev 140231)
@@ -178,6 +178,10 @@
 #include "StyleCachedImageSet.h"
 #endif
 
+#if ENABLE(VIDEO_TRACK)
+#include "WebVTTElement.h"
+#endif
+
 using namespace std;
 
 namespace WTF {
@@ -656,7 +660,7 @@
     }
 
 #if ENABLE(VIDEO_TRACK)
-    if (m_element->webVTTNodeType())
+    if (m_element->isWebVTTElement() && toWebVTTElement(m_element)->webVTTNodeType())
         collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), matchRequest, firstRuleIndex, lastRuleIndex);
 #endif
     // Check whether other types of rules are applicable in the current tree scope. Criteria for this:
@@ -1243,8 +1247,12 @@
         return false;
 
 #if ENABLE(VIDEO_TRACK)
-    if (element->webVTTNodeType() != m_element->webVTTNodeType())
+    // Deny sharing styles between WebVTT and non-WebVTT nodes.
+    if (element->isWebVTTElement() != m_element->isWebVTTElement())
         return false;
+
+    if (element->isWebVTTElement() && m_element->isWebVTTElement() && toWebVTTElement(element)->webVTTNodeType() != toWebVTTElement(m_element)->webVTTNodeType())
+        return false;
 #endif
 
 #if ENABLE(FULLSCREEN_API)

Modified: trunk/Source/WebCore/dom/Element.cpp (140230 => 140231)


--- trunk/Source/WebCore/dom/Element.cpp	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/dom/Element.cpp	2013-01-19 03:59:49 UTC (rev 140231)
@@ -2345,18 +2345,6 @@
 }
 #endif
 
-#if ENABLE(VIDEO_TRACK)
-WebVTTNodeType Element::webVTTNodeType() const
-{
-    return hasRareData() ? elementRareData()->webVTTNodeType() : WebVTTNodeTypeNone;
-}
-
-void Element::setWebVTTNodeType(WebVTTNodeType type)
-{
-    ensureElementRareData()->setWebVTTNodeType(type);
-}
-#endif
-
 #if ENABLE(FULLSCREEN_API)
 void Element::webkitRequestFullscreen()
 {

Modified: trunk/Source/WebCore/dom/Element.h (140230 => 140231)


--- trunk/Source/WebCore/dom/Element.h	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/dom/Element.h	2013-01-19 03:59:49 UTC (rev 140231)
@@ -31,9 +31,6 @@
 #include "FragmentScriptingPermission.h"
 #include "HTMLNames.h"
 #include "ScrollTypes.h"
-#if ENABLE(VIDEO_TRACK)
-#include "TextTrack.h"
-#endif
 
 namespace WebCore {
 
@@ -452,11 +449,6 @@
     virtual void buildPendingResource() { };
 #endif
 
-#if ENABLE(VIDEO_TRACK)
-    WebVTTNodeType webVTTNodeType() const;
-    void setWebVTTNodeType(WebVTTNodeType);
-#endif
-
 #if ENABLE(FULLSCREEN_API)
     enum {
         ALLOW_KEYBOARD_INPUT = 1 << 0,

Modified: trunk/Source/WebCore/dom/ElementRareData.h (140230 => 140231)


--- trunk/Source/WebCore/dom/ElementRareData.h	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/dom/ElementRareData.h	2013-01-19 03:59:49 UTC (rev 140231)
@@ -60,11 +60,6 @@
     bool isInCanvasSubtree() const { return m_isInCanvasSubtree; }
     void setIsInCanvasSubtree(bool value) { m_isInCanvasSubtree = value; }
 
-#if ENABLE(VIDEO_TRACK)
-    void setWebVTTNodeType(WebVTTNodeType type) { m_webVTTNodeType = type; }
-    WebVTTNodeType webVTTNodeType() const { return static_cast<WebVTTNodeType>(m_webVTTNodeType); }
-#endif
-
 #if ENABLE(FULLSCREEN_API)
     bool containsFullScreenElement() { return m_containsFullScreenElement; }
     void setContainsFullScreenElement(bool value) { m_containsFullScreenElement = value; }
@@ -157,9 +152,6 @@
     unsigned m_childrenAffectedByDirectAdjacentRules : 1;
     unsigned m_childrenAffectedByForwardPositionalRules : 1;
     unsigned m_childrenAffectedByBackwardPositionalRules : 1;
-#if ENABLE(VIDEO_TRACK)
-    unsigned m_webVTTNodeType : 2; // WebVTTNodeType
-#endif
 
     LayoutSize m_minimumSizeForResizing;
     IntSize m_savedLayerScrollOffset;
@@ -207,9 +199,6 @@
     , m_childrenAffectedByDirectAdjacentRules(false)
     , m_childrenAffectedByForwardPositionalRules(false)
     , m_childrenAffectedByBackwardPositionalRules(false)
-#if ENABLE(VIDEO_TRACK)
-    , m_webVTTNodeType(WebVTTNodeTypeNone)
-#endif
     , m_minimumSizeForResizing(defaultMinimumSizeForResizing())
 {
 }

Modified: trunk/Source/WebCore/dom/Node.h (140230 => 140231)


--- trunk/Source/WebCore/dom/Node.h	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/dom/Node.h	2013-01-19 03:59:49 UTC (rev 140231)
@@ -236,6 +236,9 @@
 
     virtual bool isMediaControlElement() const { return false; }
     virtual bool isMediaControls() const { return false; }
+#if ENABLE(VIDEO_TRACK)
+    virtual bool isWebVTTElement() const { return false; }
+#endif
     bool isStyledElement() const { return getFlag(IsStyledElementFlag); }
     virtual bool isAttributeNode() const { return false; }
     virtual bool isCharacterDataNode() const { return false; }

Modified: trunk/Source/WebCore/html/track/TextTrack.h (140230 => 140231)


--- trunk/Source/WebCore/html/track/TextTrack.h	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/html/track/TextTrack.h	2013-01-19 03:59:49 UTC (rev 140231)
@@ -53,12 +53,6 @@
     virtual void textTrackRemoveCue(TextTrack*, PassRefPtr<TextTrackCue>) = 0;
 };
 
-enum WebVTTNodeType {
-    WebVTTNodeTypeNone = 0,
-    WebVTTNodeTypeFuture,
-    WebVTTNodeTypePast
-};
-
 class TextTrack : public TrackBase {
 public:
     static PassRefPtr<TextTrack> create(ScriptExecutionContext* context, TextTrackClient* client, const AtomicString& kind, const AtomicString& label, const AtomicString& language)

Modified: trunk/Source/WebCore/html/track/TextTrackCue.cpp (140230 => 140231)


--- trunk/Source/WebCore/html/track/TextTrackCue.cpp	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/html/track/TextTrackCue.cpp	2013-01-19 03:59:49 UTC (rev 140231)
@@ -47,6 +47,7 @@
 #include "Text.h"
 #include "TextTrack.h"
 #include "TextTrackCueList.h"
+#include "WebVTTElement.h"
 #include "WebVTTParser.h"
 #include <wtf/MathExtras.h>
 #include <wtf/text/StringBuilder.h>
@@ -695,8 +696,8 @@
                 isPastNode = false;
         }
         
-        if (child->isElementNode()) {
-            toElement(child)->setWebVTTNodeType(isPastNode ? WebVTTNodeTypePast : WebVTTNodeTypeFuture);
+        if (child->isWebVTTElement()) {
+            toWebVTTElement(child)->setWebVTTNodeType(isPastNode ? WebVTTNodeTypePast : WebVTTNodeTypeFuture);
             // Make an elemenet id match a cue id for style matching purposes.
             if (!m_id.isEmpty())
                 toElement(child)->setIdAttribute(AtomicString(m_id.characters(), m_id.length()));

Added: trunk/Source/WebCore/html/track/WebVTTElement.cpp (0 => 140231)


--- trunk/Source/WebCore/html/track/WebVTTElement.cpp	                        (rev 0)
+++ trunk/Source/WebCore/html/track/WebVTTElement.cpp	2013-01-19 03:59:49 UTC (rev 140231)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2013 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "WebVTTElement.h"
+
+#include "TextTrack.h"
+
+namespace WebCore {
+
+WebVTTElement::WebVTTElement(const QualifiedName& tagName, Document* document)
+    : HTMLElement(tagName, document)
+    , m_webVTTNodeType(WebVTTNodeTypeNone)
+{
+}
+
+PassRefPtr<WebVTTElement> WebVTTElement::create(const QualifiedName& tagName, Document* document)
+{
+    return adoptRef(new WebVTTElement(tagName, document));
+}
+
+PassRefPtr<Element> WebVTTElement::cloneElementWithoutAttributesAndChildren()
+{
+    return create(tagQName(), document());
+}
+
+} // namespace WebCore
+
+#endif

Added: trunk/Source/WebCore/html/track/WebVTTElement.h (0 => 140231)


--- trunk/Source/WebCore/html/track/WebVTTElement.h	                        (rev 0)
+++ trunk/Source/WebCore/html/track/WebVTTElement.h	2013-01-19 03:59:49 UTC (rev 140231)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if ENABLE(VIDEO_TRACK)
+
+#include "HTMLElement.h"
+
+namespace WebCore {
+
+enum WebVTTNodeType {
+    WebVTTNodeTypeNone = 0,
+    WebVTTNodeTypeFuture,
+    WebVTTNodeTypePast
+};
+
+class WebVTTElement : public HTMLElement {
+public:
+    static PassRefPtr<WebVTTElement> create(const QualifiedName&, Document*);
+    virtual PassRefPtr<Element> cloneElementWithoutAttributesAndChildren() OVERRIDE;
+
+    void setWebVTTNodeType(WebVTTNodeType type) { m_webVTTNodeType = type; }
+    WebVTTNodeType webVTTNodeType() const { return m_webVTTNodeType; }
+    virtual bool isWebVTTElement() const OVERRIDE { return true; }
+
+private:
+    WebVTTElement(const QualifiedName&, Document*);
+    WebVTTNodeType m_webVTTNodeType;
+};
+
+inline WebVTTElement* toWebVTTElement(Node* node)
+{
+    ASSERT(!node || node->isWebVTTElement());
+    return static_cast<WebVTTElement*>(node);
+}
+
+// This will catch anyone doing an unnecessary cast.
+void toWebVTTElement(const WebVTTElement*);
+
+
+} // namespace WebCore
+
+#endif

Modified: trunk/Source/WebCore/html/track/WebVTTParser.cpp (140230 => 140231)


--- trunk/Source/WebCore/html/track/WebVTTParser.cpp	2013-01-19 02:54:08 UTC (rev 140230)
+++ trunk/Source/WebCore/html/track/WebVTTParser.cpp	2013-01-19 03:59:49 UTC (rev 140231)
@@ -38,6 +38,7 @@
 #include "ProcessingInstruction.h"
 #include "SegmentedString.h"
 #include "Text.h"
+#include "WebVTTElement.h"
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -355,13 +356,13 @@
         break;
     }
     case WebVTTTokenTypes::StartTag: {
-        RefPtr<Element> child;
+        RefPtr<WebVTTElement> child;
         if (isRecognizedTag(tokenTagName))
-            child = HTMLElement::create(tagName, document);
+            child = WebVTTElement::create(tagName, document);
         else if (m_token.name().size() == 1 && m_token.name()[0] == 'c')
-            child = Element::create(TextTrackCue::classElementTagName(), document);
+            child = WebVTTElement::create(TextTrackCue::classElementTagName(), document);
         else if (m_token.name().size() == 1 && m_token.name()[0] == 'v')
-            child = Element::create(TextTrackCue::voiceElementTagName(), document);
+            child = WebVTTElement::create(TextTrackCue::voiceElementTagName(), document);
 
         if (child) {
             if (m_token.classes().size() > 0)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to