OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return; | 86 return; |
87 | 87 |
88 // FIXME: Why does this check settings? | 88 // FIXME: Why does this check settings? |
89 if (!frame->settings() || !frame->loader().allowPlugins(NotAboutToInstantiat
ePlugin)) | 89 if (!frame->settings() || !frame->loader().allowPlugins(NotAboutToInstantiat
ePlugin)) |
90 return; | 90 return; |
91 | 91 |
92 RefPtrWillBeRawPtr<HTMLHtmlElement> rootElement = HTMLHtmlElement::create(*d
ocument()); | 92 RefPtrWillBeRawPtr<HTMLHtmlElement> rootElement = HTMLHtmlElement::create(*d
ocument()); |
93 rootElement->insertedByParser(); | 93 rootElement->insertedByParser(); |
94 document()->appendChild(rootElement); | 94 document()->appendChild(rootElement); |
95 frame->loader().dispatchDocumentElementAvailable(); | 95 frame->loader().dispatchDocumentElementAvailable(); |
| 96 frame->loader().runScriptsAtDocumentElementAvailable(); |
| 97 if (isStopped()) |
| 98 return; // runScriptsAtDocumentElementAvailable can detach the frame. |
96 | 99 |
97 RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document
()); | 100 RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document
()); |
98 body->setAttribute(styleAttr, "background-color: rgb(38,38,38); height: 100%
; width: 100%; overflow: hidden; margin: 0"); | 101 body->setAttribute(styleAttr, "background-color: rgb(38,38,38); height: 100%
; width: 100%; overflow: hidden; margin: 0"); |
99 rootElement->appendChild(body); | 102 rootElement->appendChild(body); |
| 103 if (isStopped()) |
| 104 return; // Possibly detached by a mutation event listener installed in r
unScriptsAtDocumentElementAvailable. |
100 | 105 |
101 m_embedElement = HTMLEmbedElement::create(*document()); | 106 m_embedElement = HTMLEmbedElement::create(*document()); |
102 m_embedElement->setAttribute(widthAttr, "100%"); | 107 m_embedElement->setAttribute(widthAttr, "100%"); |
103 m_embedElement->setAttribute(heightAttr, "100%"); | 108 m_embedElement->setAttribute(heightAttr, "100%"); |
104 m_embedElement->setAttribute(nameAttr, "plugin"); | 109 m_embedElement->setAttribute(nameAttr, "plugin"); |
105 m_embedElement->setAttribute(idAttr, "plugin"); | 110 m_embedElement->setAttribute(idAttr, "plugin"); |
106 m_embedElement->setAttribute(srcAttr, AtomicString(document()->url().getStri
ng())); | 111 m_embedElement->setAttribute(srcAttr, AtomicString(document()->url().getStri
ng())); |
107 m_embedElement->setAttribute(typeAttr, document()->loader()->mimeType()); | 112 m_embedElement->setAttribute(typeAttr, document()->loader()->mimeType()); |
108 body->appendChild(m_embedElement); | 113 body->appendChild(m_embedElement); |
| 114 if (isStopped()) |
| 115 return; // Possibly detached by a mutation event listener installed in r
unScriptsAtDocumentElementAvailable. |
109 | 116 |
110 toPluginDocument(document())->setPluginNode(m_embedElement.get()); | 117 toPluginDocument(document())->setPluginNode(m_embedElement.get()); |
111 | 118 |
112 document()->updateLayout(); | 119 document()->updateLayout(); |
113 | 120 |
114 // We need the plugin to load synchronously so we can get the PluginView | 121 // We need the plugin to load synchronously so we can get the PluginView |
115 // below so flush the layout tasks now instead of waiting on the timer. | 122 // below so flush the layout tasks now instead of waiting on the timer. |
116 frame->view()->flushAnyPendingPostLayoutTasks(); | 123 frame->view()->flushAnyPendingPostLayoutTasks(); |
117 // Focus the plugin here, as the line above is where the plugin is created. | 124 // Focus the plugin here, as the line above is where the plugin is created. |
118 if (frame->isMainFrame()) | 125 if (frame->isMainFrame()) { |
119 m_embedElement->focus(); | 126 m_embedElement->focus(); |
| 127 if (isStopped()) |
| 128 return; // Possibly detached by a focus event listener installed in
runScriptsAtDocumentElementAvailable. |
| 129 } |
120 | 130 |
121 if (PluginView* view = pluginView()) | 131 if (PluginView* view = pluginView()) |
122 view->didReceiveResponse(document()->loader()->response()); | 132 view->didReceiveResponse(document()->loader()->response()); |
123 } | 133 } |
124 | 134 |
125 void PluginDocumentParser::appendBytes(const char* data, size_t length) | 135 void PluginDocumentParser::appendBytes(const char* data, size_t length) |
126 { | 136 { |
127 if (!m_embedElement) | 137 if (!m_embedElement) { |
128 createDocumentStructure(); | 138 createDocumentStructure(); |
| 139 if (isStopped()) |
| 140 return; |
| 141 } |
129 | 142 |
130 if (!length) | 143 if (!length) |
131 return; | 144 return; |
132 if (PluginView* view = pluginView()) | 145 if (PluginView* view = pluginView()) |
133 view->didReceiveData(data, length); | 146 view->didReceiveData(data, length); |
134 } | 147 } |
135 | 148 |
136 void PluginDocumentParser::finish() | 149 void PluginDocumentParser::finish() |
137 { | 150 { |
138 m_embedElement = nullptr; | 151 m_embedElement = nullptr; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 HTMLDocument::detach(context); | 194 HTMLDocument::detach(context); |
182 } | 195 } |
183 | 196 |
184 DEFINE_TRACE(PluginDocument) | 197 DEFINE_TRACE(PluginDocument) |
185 { | 198 { |
186 visitor->trace(m_pluginNode); | 199 visitor->trace(m_pluginNode); |
187 HTMLDocument::trace(visitor); | 200 HTMLDocument::trace(visitor); |
188 } | 201 } |
189 | 202 |
190 } // namespace blink | 203 } // namespace blink |
OLD | NEW |