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

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

Issue 1642283002: Deal with frame removal by content scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Schedule microtask for document_end scripts 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) 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
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 if (isStopped())
97 return;
96 98
97 RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document ()); 99 RefPtrWillBeRawPtr<HTMLBodyElement> body = HTMLBodyElement::create(*document ());
98 body->setAttribute(styleAttr, "background-color: rgb(38,38,38); height: 100% ; width: 100%; overflow: hidden; margin: 0"); 100 body->setAttribute(styleAttr, "background-color: rgb(38,38,38); height: 100% ; width: 100%; overflow: hidden; margin: 0");
99 rootElement->appendChild(body); 101 rootElement->appendChild(body);
102 if (isStopped())
103 return;
100 104
101 m_embedElement = HTMLEmbedElement::create(*document()); 105 m_embedElement = HTMLEmbedElement::create(*document());
102 m_embedElement->setAttribute(widthAttr, "100%"); 106 m_embedElement->setAttribute(widthAttr, "100%");
103 m_embedElement->setAttribute(heightAttr, "100%"); 107 m_embedElement->setAttribute(heightAttr, "100%");
104 m_embedElement->setAttribute(nameAttr, "plugin"); 108 m_embedElement->setAttribute(nameAttr, "plugin");
105 m_embedElement->setAttribute(idAttr, "plugin"); 109 m_embedElement->setAttribute(idAttr, "plugin");
106 m_embedElement->setAttribute(srcAttr, AtomicString(document()->url().string( ))); 110 m_embedElement->setAttribute(srcAttr, AtomicString(document()->url().string( )));
107 m_embedElement->setAttribute(typeAttr, document()->loader()->mimeType()); 111 m_embedElement->setAttribute(typeAttr, document()->loader()->mimeType());
108 body->appendChild(m_embedElement); 112 body->appendChild(m_embedElement);
113 if (isStopped())
114 return;
109 115
110 toPluginDocument(document())->setPluginNode(m_embedElement.get()); 116 toPluginDocument(document())->setPluginNode(m_embedElement.get());
111 117
112 document()->updateLayout(); 118 document()->updateLayout();
113 119
114 // We need the plugin to load synchronously so we can get the PluginView 120 // 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. 121 // below so flush the layout tasks now instead of waiting on the timer.
116 frame->view()->flushAnyPendingPostLayoutTasks(); 122 frame->view()->flushAnyPendingPostLayoutTasks();
117 // Focus the plugin here, as the line above is where the plugin is created. 123 // Focus the plugin here, as the line above is where the plugin is created.
118 m_embedElement->focus(); 124 m_embedElement->focus();
125 if (isStopped())
126 return;
119 127
120 if (PluginView* view = pluginView()) 128 if (PluginView* view = pluginView())
121 view->didReceiveResponse(document()->loader()->response()); 129 view->didReceiveResponse(document()->loader()->response());
122 } 130 }
123 131
124 void PluginDocumentParser::appendBytes(const char* data, size_t length) 132 void PluginDocumentParser::appendBytes(const char* data, size_t length)
125 { 133 {
126 if (!m_embedElement) 134 if (!m_embedElement) {
127 createDocumentStructure(); 135 createDocumentStructure();
136 if (isStopped())
137 return;
138 }
128 139
129 if (!length) 140 if (!length)
130 return; 141 return;
131 if (PluginView* view = pluginView()) 142 if (PluginView* view = pluginView())
132 view->didReceiveData(data, length); 143 view->didReceiveData(data, length);
133 } 144 }
134 145
135 void PluginDocumentParser::finish() 146 void PluginDocumentParser::finish()
136 { 147 {
137 m_embedElement = nullptr; 148 m_embedElement = nullptr;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 HTMLDocument::detach(context); 191 HTMLDocument::detach(context);
181 } 192 }
182 193
183 DEFINE_TRACE(PluginDocument) 194 DEFINE_TRACE(PluginDocument)
184 { 195 {
185 visitor->trace(m_pluginNode); 196 visitor->trace(m_pluginNode);
186 HTMLDocument::trace(visitor); 197 HTMLDocument::trace(visitor);
187 } 198 }
188 199
189 } // namespace blink 200 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698