Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: third_party/WebKit/Source/core/html/MediaDocument.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/loader/FrameLoaderClient.h" 42 #include "core/loader/FrameLoaderClient.h"
43 #include "platform/KeyboardCodes.h" 43 #include "platform/KeyboardCodes.h"
44 44
45 namespace blink { 45 namespace blink {
46 46
47 using namespace HTMLNames; 47 using namespace HTMLNames;
48 48
49 // FIXME: Share more code with PluginDocumentParser. 49 // FIXME: Share more code with PluginDocumentParser.
50 class MediaDocumentParser : public RawDataDocumentParser { 50 class MediaDocumentParser : public RawDataDocumentParser {
51 public: 51 public:
52 static PassRefPtrWillBeRawPtr<MediaDocumentParser> create(MediaDocument* doc ument) 52 static RawPtr<MediaDocumentParser> create(MediaDocument* document)
53 { 53 {
54 return adoptRefWillBeNoop(new MediaDocumentParser(document)); 54 return (new MediaDocumentParser(document));
55 } 55 }
56 56
57 private: 57 private:
58 explicit MediaDocumentParser(Document* document) 58 explicit MediaDocumentParser(Document* document)
59 : RawDataDocumentParser(document) 59 : RawDataDocumentParser(document)
60 , m_didBuildDocumentStructure(false) 60 , m_didBuildDocumentStructure(false)
61 { 61 {
62 } 62 }
63 63
64 void appendBytes(const char*, size_t) override; 64 void appendBytes(const char*, size_t) override;
65 65
66 void createDocumentStructure(); 66 void createDocumentStructure();
67 67
68 bool m_didBuildDocumentStructure; 68 bool m_didBuildDocumentStructure;
69 }; 69 };
70 70
71 void MediaDocumentParser::createDocumentStructure() 71 void MediaDocumentParser::createDocumentStructure()
72 { 72 {
73 ASSERT(document()); 73 ASSERT(document());
74 RefPtrWillBeRawPtr<HTMLHtmlElement> rootElement = HTMLHtmlElement::create(*d ocument()); 74 RawPtr<HTMLHtmlElement> rootElement = HTMLHtmlElement::create(*document());
75 rootElement->insertedByParser(); 75 rootElement->insertedByParser();
76 document()->appendChild(rootElement); 76 document()->appendChild(rootElement);
77 77
78 if (document()->frame()) 78 if (document()->frame())
79 document()->frame()->loader().dispatchDocumentElementAvailable(); 79 document()->frame()->loader().dispatchDocumentElementAvailable();
80 80
81 RefPtrWillBeRawPtr<HTMLHeadElement> head = HTMLHeadElement::create(*document ()); 81 RawPtr<HTMLHeadElement> head = HTMLHeadElement::create(*document());
82 RefPtrWillBeRawPtr<HTMLMetaElement> meta = HTMLMetaElement::create(*document ()); 82 RawPtr<HTMLMetaElement> meta = HTMLMetaElement::create(*document());
83 meta->setAttribute(nameAttr, "viewport"); 83 meta->setAttribute(nameAttr, "viewport");
84 meta->setAttribute(contentAttr, "width=device-width"); 84 meta->setAttribute(contentAttr, "width=device-width");
85 head->appendChild(meta.release()); 85 head->appendChild(meta.release());
86 86
87 RefPtrWillBeRawPtr<HTMLVideoElement> media = HTMLVideoElement::create(*docum ent()); 87 RawPtr<HTMLVideoElement> media = HTMLVideoElement::create(*document());
88 media->setAttribute(controlsAttr, ""); 88 media->setAttribute(controlsAttr, "");
89 media->setAttribute(autoplayAttr, ""); 89 media->setAttribute(autoplayAttr, "");
90 media->setAttribute(nameAttr, "media"); 90 media->setAttribute(nameAttr, "media");
91 91
92 RefPtrWillBeRawPtr<HTMLSourceElement> source = HTMLSourceElement::create(*do cument()); 92 RawPtr<HTMLSourceElement> source = HTMLSourceElement::create(*document());
93 source->setSrc(document()->url()); 93 source->setSrc(document()->url());
94 94
95 if (DocumentLoader* loader = document()->loader()) 95 if (DocumentLoader* loader = document()->loader())
96 source->setType(loader->responseMIMEType()); 96 source->setType(loader->responseMIMEType());
97 97
98 media->appendChild(source.release()); 98 media->appendChild(source.release());
99 99
100 RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document ()); 100 RawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document());
101 body->appendChild(media.release()); 101 body->appendChild(media.release());
102 102
103 rootElement->appendChild(head.release()); 103 rootElement->appendChild(head.release());
104 rootElement->appendChild(body.release()); 104 rootElement->appendChild(body.release());
105 105
106 m_didBuildDocumentStructure = true; 106 m_didBuildDocumentStructure = true;
107 } 107 }
108 108
109 void MediaDocumentParser::appendBytes(const char*, size_t) 109 void MediaDocumentParser::appendBytes(const char*, size_t)
110 { 110 {
111 if (m_didBuildDocumentStructure) 111 if (m_didBuildDocumentStructure)
112 return; 112 return;
113 113
114 LocalFrame* frame = document()->frame(); 114 LocalFrame* frame = document()->frame();
115 if (!frame->loader().client()->allowMedia(document()->url())) 115 if (!frame->loader().client()->allowMedia(document()->url()))
116 return; 116 return;
117 117
118 createDocumentStructure(); 118 createDocumentStructure();
119 finish(); 119 finish();
120 } 120 }
121 121
122 MediaDocument::MediaDocument(const DocumentInit& initializer) 122 MediaDocument::MediaDocument(const DocumentInit& initializer)
123 : HTMLDocument(initializer, MediaDocumentClass) 123 : HTMLDocument(initializer, MediaDocumentClass)
124 { 124 {
125 setCompatibilityMode(QuirksMode); 125 setCompatibilityMode(QuirksMode);
126 lockCompatibilityMode(); 126 lockCompatibilityMode();
127 } 127 }
128 128
129 PassRefPtrWillBeRawPtr<DocumentParser> MediaDocument::createParser() 129 RawPtr<DocumentParser> MediaDocument::createParser()
130 { 130 {
131 return MediaDocumentParser::create(this); 131 return MediaDocumentParser::create(this);
132 } 132 }
133 133
134 void MediaDocument::defaultEventHandler(Event* event) 134 void MediaDocument::defaultEventHandler(Event* event)
135 { 135 {
136 Node* targetNode = event->target()->toNode(); 136 Node* targetNode = event->target()->toNode();
137 if (!targetNode) 137 if (!targetNode)
138 return; 138 return;
139 139
140 if (event->type() == EventTypeNames::keydown && event->isKeyboardEvent()) { 140 if (event->type() == EventTypeNames::keydown && event->isKeyboardEvent()) {
141 HTMLVideoElement* video = Traversal<HTMLVideoElement>::firstWithin(*targ etNode); 141 HTMLVideoElement* video = Traversal<HTMLVideoElement>::firstWithin(*targ etNode);
142 if (!video) 142 if (!video)
143 return; 143 return;
144 144
145 KeyboardEvent* keyboardEvent = toKeyboardEvent(event); 145 KeyboardEvent* keyboardEvent = toKeyboardEvent(event);
146 if (keyboardEvent->keyIdentifier() == "U+0020" || keyboardEvent->keyCode () == VKEY_MEDIA_PLAY_PAUSE) { 146 if (keyboardEvent->keyIdentifier() == "U+0020" || keyboardEvent->keyCode () == VKEY_MEDIA_PLAY_PAUSE) {
147 // space or media key (play/pause) 147 // space or media key (play/pause)
148 video->togglePlayState(); 148 video->togglePlayState();
149 event->setDefaultHandled(); 149 event->setDefaultHandled();
150 } 150 }
151 } 151 }
152 } 152 }
153 153
154 } // namespace blink 154 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698