OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 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 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 virtual size_t appendBytes(const char*, size_t) OVERRIDE; | 66 virtual size_t appendBytes(const char*, size_t) OVERRIDE; |
67 | 67 |
68 void createDocumentStructure(); | 68 void createDocumentStructure(); |
69 | 69 |
70 bool m_didBuildDocumentStructure; | 70 bool m_didBuildDocumentStructure; |
71 }; | 71 }; |
72 | 72 |
73 void MediaDocumentParser::createDocumentStructure() | 73 void MediaDocumentParser::createDocumentStructure() |
74 { | 74 { |
75 RefPtr<HTMLHtmlElement> rootElement = HTMLHtmlElement::create(document()); | 75 ASSERT(document()); |
| 76 RefPtr<HTMLHtmlElement> rootElement = HTMLHtmlElement::create(*document()); |
76 rootElement->insertedByParser(); | 77 rootElement->insertedByParser(); |
77 document()->appendChild(rootElement); | 78 document()->appendChild(rootElement); |
78 | 79 |
79 if (document()->frame()) | 80 if (document()->frame()) |
80 document()->frame()->loader()->dispatchDocumentElementAvailable(); | 81 document()->frame()->loader()->dispatchDocumentElementAvailable(); |
81 | 82 |
82 RefPtr<HTMLHeadElement> head = HTMLHeadElement::create(document()); | 83 RefPtr<HTMLHeadElement> head = HTMLHeadElement::create(*document()); |
83 RefPtr<HTMLMetaElement> meta = HTMLMetaElement::create(document()); | 84 RefPtr<HTMLMetaElement> meta = HTMLMetaElement::create(*document()); |
84 meta->setAttribute(nameAttr, "viewport"); | 85 meta->setAttribute(nameAttr, "viewport"); |
85 meta->setAttribute(contentAttr, "width=device-width"); | 86 meta->setAttribute(contentAttr, "width=device-width"); |
86 head->appendChild(meta.release()); | 87 head->appendChild(meta.release()); |
87 | 88 |
88 RefPtr<HTMLVideoElement> media = HTMLVideoElement::create(document()); | 89 RefPtr<HTMLVideoElement> media = HTMLVideoElement::create(*document()); |
89 media->setAttribute(controlsAttr, ""); | 90 media->setAttribute(controlsAttr, ""); |
90 media->setAttribute(autoplayAttr, ""); | 91 media->setAttribute(autoplayAttr, ""); |
91 media->setAttribute(nameAttr, "media"); | 92 media->setAttribute(nameAttr, "media"); |
92 | 93 |
93 RefPtr<HTMLSourceElement> source = HTMLSourceElement::create(document()); | 94 RefPtr<HTMLSourceElement> source = HTMLSourceElement::create(*document()); |
94 source->setSrc(document()->url()); | 95 source->setSrc(document()->url()); |
95 | 96 |
96 if (DocumentLoader* loader = document()->loader()) | 97 if (DocumentLoader* loader = document()->loader()) |
97 source->setType(loader->responseMIMEType()); | 98 source->setType(loader->responseMIMEType()); |
98 | 99 |
99 media->appendChild(source.release()); | 100 media->appendChild(source.release()); |
100 | 101 |
101 RefPtr<HTMLBodyElement> body = HTMLBodyElement::create(document()); | 102 RefPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document()); |
102 body->appendChild(media.release()); | 103 body->appendChild(media.release()); |
103 | 104 |
104 rootElement->appendChild(head.release()); | 105 rootElement->appendChild(head.release()); |
105 rootElement->appendChild(body.release()); | 106 rootElement->appendChild(body.release()); |
106 | 107 |
107 m_didBuildDocumentStructure = true; | 108 m_didBuildDocumentStructure = true; |
108 } | 109 } |
109 | 110 |
110 size_t MediaDocumentParser::appendBytes(const char*, size_t) | 111 size_t MediaDocumentParser::appendBytes(const char*, size_t) |
111 { | 112 { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 if (video->canPlay()) | 160 if (video->canPlay()) |
160 video->play(); | 161 video->play(); |
161 } else | 162 } else |
162 video->pause(); | 163 video->pause(); |
163 event->setDefaultHandled(); | 164 event->setDefaultHandled(); |
164 } | 165 } |
165 } | 166 } |
166 } | 167 } |
167 | 168 |
168 } | 169 } |
OLD | NEW |