OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/html/track/WebVTTElement.h" |
27 | 28 |
28 #include "core/html/track/WebVTTElement.h" | 29 #include "HTMLElementFactory.h" |
29 | 30 |
30 namespace WebCore { | 31 namespace WebCore { |
31 | 32 |
32 static const QualifiedName& nodeTypeToTagName(WebVTTNodeType nodeType) | 33 static const QualifiedName& nodeTypeToTagName(WebVTTNodeType nodeType) |
33 { | 34 { |
34 DEFINE_STATIC_LOCAL(QualifiedName, cTag, (nullAtom, "c", nullAtom)); | 35 DEFINE_STATIC_LOCAL(QualifiedName, cTag, (nullAtom, "c", nullAtom)); |
35 DEFINE_STATIC_LOCAL(QualifiedName, vTag, (nullAtom, "v", nullAtom)); | 36 DEFINE_STATIC_LOCAL(QualifiedName, vTag, (nullAtom, "v", nullAtom)); |
36 DEFINE_STATIC_LOCAL(QualifiedName, langTag, (nullAtom, "lang", nullAtom)); | 37 DEFINE_STATIC_LOCAL(QualifiedName, langTag, (nullAtom, "lang", nullAtom)); |
37 DEFINE_STATIC_LOCAL(QualifiedName, bTag, (nullAtom, "b", nullAtom)); | 38 DEFINE_STATIC_LOCAL(QualifiedName, bTag, (nullAtom, "b", nullAtom)); |
38 DEFINE_STATIC_LOCAL(QualifiedName, uTag, (nullAtom, "u", nullAtom)); | 39 DEFINE_STATIC_LOCAL(QualifiedName, uTag, (nullAtom, "u", nullAtom)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return clone; | 83 return clone; |
83 } | 84 } |
84 | 85 |
85 PassRefPtr<HTMLElement> WebVTTElement::createEquivalentHTMLElement(Document* doc
ument) | 86 PassRefPtr<HTMLElement> WebVTTElement::createEquivalentHTMLElement(Document* doc
ument) |
86 { | 87 { |
87 RefPtr<HTMLElement> htmlElement; | 88 RefPtr<HTMLElement> htmlElement; |
88 switch (m_webVTTNodeType) { | 89 switch (m_webVTTNodeType) { |
89 case WebVTTNodeTypeClass: | 90 case WebVTTNodeTypeClass: |
90 case WebVTTNodeTypeLanguage: | 91 case WebVTTNodeTypeLanguage: |
91 case WebVTTNodeTypeVoice: | 92 case WebVTTNodeTypeVoice: |
92 htmlElement = HTMLElement::create(HTMLNames::spanTag, document); | 93 htmlElement = HTMLElementFactory::createHTMLElement(HTMLNames::spanTag,
document); |
93 htmlElement.get()->setAttribute(HTMLNames::titleAttr, getAttribute(voice
AttributeName())); | 94 htmlElement.get()->setAttribute(HTMLNames::titleAttr, getAttribute(voice
AttributeName())); |
94 htmlElement.get()->setAttribute(HTMLNames::langAttr, getAttribute(langAt
tributeName())); | 95 htmlElement.get()->setAttribute(HTMLNames::langAttr, getAttribute(langAt
tributeName())); |
95 break; | 96 break; |
96 case WebVTTNodeTypeItalic: | 97 case WebVTTNodeTypeItalic: |
97 htmlElement = HTMLElement::create(HTMLNames::iTag, document); | 98 htmlElement = HTMLElementFactory::createHTMLElement(HTMLNames::iTag, doc
ument); |
98 break; | 99 break; |
99 case WebVTTNodeTypeBold: | 100 case WebVTTNodeTypeBold: |
100 htmlElement = HTMLElement::create(HTMLNames::bTag, document); | 101 htmlElement = HTMLElementFactory::createHTMLElement(HTMLNames::bTag, doc
ument); |
101 break; | 102 break; |
102 case WebVTTNodeTypeUnderline: | 103 case WebVTTNodeTypeUnderline: |
103 htmlElement = HTMLElement::create(HTMLNames::uTag, document); | 104 htmlElement = HTMLElementFactory::createHTMLElement(HTMLNames::uTag, doc
ument); |
104 break; | 105 break; |
105 case WebVTTNodeTypeRuby: | 106 case WebVTTNodeTypeRuby: |
106 htmlElement = HTMLElement::create(HTMLNames::rubyTag, document); | 107 htmlElement = HTMLElementFactory::createHTMLElement(HTMLNames::rubyTag,
document); |
107 break; | 108 break; |
108 case WebVTTNodeTypeRubyText: | 109 case WebVTTNodeTypeRubyText: |
109 htmlElement = HTMLElement::create(HTMLNames::rtTag, document); | 110 htmlElement = HTMLElementFactory::createHTMLElement(HTMLNames::rtTag, do
cument); |
110 break; | 111 break; |
111 default: | 112 default: |
112 ASSERT_NOT_REACHED(); | 113 ASSERT_NOT_REACHED(); |
113 } | 114 } |
114 | 115 |
115 htmlElement.get()->setAttribute(HTMLNames::classAttr, getAttribute(HTMLNames
::classAttr)); | 116 htmlElement.get()->setAttribute(HTMLNames::classAttr, getAttribute(HTMLNames
::classAttr)); |
116 return htmlElement; | 117 return htmlElement; |
117 } | 118 } |
118 | 119 |
119 } // namespace WebCore | 120 } // namespace WebCore |
120 | 121 |
OLD | NEW |