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

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

Issue 2759063002: Remove most of Widget (FrameViewBase) class from HTMLPlugInElement. (Closed)
Patch Set: Created 3 years, 9 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de)
5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption == 85 m_shouldPreferPlugInsForImages(preferPlugInsForImagesOption ==
86 ShouldPreferPlugInsForImages) {} 86 ShouldPreferPlugInsForImages) {}
87 87
88 HTMLPlugInElement::~HTMLPlugInElement() { 88 HTMLPlugInElement::~HTMLPlugInElement() {
89 DCHECK(!m_pluginWrapper); // cleared in detachLayoutTree() 89 DCHECK(!m_pluginWrapper); // cleared in detachLayoutTree()
90 DCHECK(!m_isDelayingLoadEvent); 90 DCHECK(!m_isDelayingLoadEvent);
91 } 91 }
92 92
93 DEFINE_TRACE(HTMLPlugInElement) { 93 DEFINE_TRACE(HTMLPlugInElement) {
94 visitor->trace(m_imageLoader); 94 visitor->trace(m_imageLoader);
95 visitor->trace(m_persistedPluginWidget); 95 visitor->trace(m_persistedPlugin);
96 HTMLFrameOwnerElement::trace(visitor); 96 HTMLFrameOwnerElement::trace(visitor);
97 } 97 }
98 98
99 void HTMLPlugInElement::setPersistedPluginWidget(FrameViewBase* frameViewBase) { 99 void HTMLPlugInElement::setPersistedPlugin(PluginView* plugin) {
100 if (m_persistedPluginWidget == frameViewBase) 100 if (m_persistedPlugin == plugin)
101 return; 101 return;
102 if (m_persistedPluginWidget) { 102 if (m_persistedPlugin) {
103 if (m_persistedPluginWidget->isPluginView()) { 103 m_persistedPlugin->hide();
104 m_persistedPluginWidget->hide(); 104 disposeWidgetSoon(m_persistedPlugin.release());
105 disposeWidgetSoon(m_persistedPluginWidget.release());
106 } else {
107 DCHECK(m_persistedPluginWidget->isFrameView() ||
108 m_persistedPluginWidget->isRemoteFrameView());
haraken 2017/03/20 03:06:35 Just to confirm: Was this code path not reachable?
joelhockey 2017/03/20 03:54:29 Yes, the code path has never been reachable, and b
109 }
110 } 105 }
111 m_persistedPluginWidget = frameViewBase; 106 m_persistedPlugin = plugin;
112 } 107 }
113 108
114 bool HTMLPlugInElement::requestObjectInternal( 109 bool HTMLPlugInElement::requestObjectInternal(
115 const String& url, 110 const String& url,
116 const String& mimeType, 111 const String& mimeType,
117 const Vector<String>& paramNames, 112 const Vector<String>& paramNames,
118 const Vector<String>& paramValues) { 113 const Vector<String>& paramValues) {
119 if (url.isEmpty() && mimeType.isEmpty()) 114 if (url.isEmpty() && mimeType.isEmpty())
120 return false; 115 return false;
121 116
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 m_imageLoader->elementDidMoveToNewDocument(); 164 m_imageLoader->elementDidMoveToNewDocument();
170 HTMLFrameOwnerElement::didMoveToNewDocument(oldDocument); 165 HTMLFrameOwnerElement::didMoveToNewDocument(oldDocument);
171 } 166 }
172 167
173 void HTMLPlugInElement::attachLayoutTree(const AttachContext& context) { 168 void HTMLPlugInElement::attachLayoutTree(const AttachContext& context) {
174 HTMLFrameOwnerElement::attachLayoutTree(context); 169 HTMLFrameOwnerElement::attachLayoutTree(context);
175 170
176 if (!layoutObject() || useFallbackContent()) { 171 if (!layoutObject() || useFallbackContent()) {
177 // If we don't have a layoutObject we have to dispose of any plugins 172 // If we don't have a layoutObject we have to dispose of any plugins
178 // which we persisted over a reattach. 173 // which we persisted over a reattach.
179 if (m_persistedPluginWidget) { 174 if (m_persistedPlugin) {
180 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 175 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
181 setPersistedPluginWidget(nullptr); 176 setPersistedPlugin(nullptr);
182 } 177 }
183 return; 178 return;
184 } 179 }
185 180
186 if (isImageType()) { 181 if (isImageType()) {
187 if (!m_imageLoader) 182 if (!m_imageLoader)
188 m_imageLoader = HTMLImageLoader::create(this); 183 m_imageLoader = HTMLImageLoader::create(this);
189 m_imageLoader->updateFromElement(); 184 m_imageLoader->updateFromElement();
190 } else if (needsPluginUpdate() && !layoutEmbeddedItem().isNull() && 185 } else if (needsPluginUpdate() && !layoutEmbeddedItem().isNull() &&
191 !layoutEmbeddedItem().showsUnavailablePluginIndicator() && 186 !layoutEmbeddedItem().showsUnavailablePluginIndicator() &&
192 !wouldLoadAsNetscapePlugin(m_url, m_serviceType) && 187 !wouldLoadAsNetscapePlugin(m_url, m_serviceType) &&
193 !m_isDelayingLoadEvent) { 188 !m_isDelayingLoadEvent) {
194 m_isDelayingLoadEvent = true; 189 m_isDelayingLoadEvent = true;
195 document().incrementLoadEventDelayCount(); 190 document().incrementLoadEventDelayCount();
196 document().loadPluginsSoon(); 191 document().loadPluginsSoon();
197 } 192 }
198 } 193 }
199 194
200 void HTMLPlugInElement::updatePlugin() { 195 void HTMLPlugInElement::updatePlugin() {
201 updatePluginInternal(); 196 updatePluginInternal();
202 if (m_isDelayingLoadEvent) { 197 if (m_isDelayingLoadEvent) {
203 m_isDelayingLoadEvent = false; 198 m_isDelayingLoadEvent = false;
204 document().decrementLoadEventDelayCount(); 199 document().decrementLoadEventDelayCount();
205 } 200 }
206 } 201 }
207 202
208 void HTMLPlugInElement::removedFrom(ContainerNode* insertionPoint) { 203 void HTMLPlugInElement::removedFrom(ContainerNode* insertionPoint) {
209 // If we've persisted the plugin and we're removed from the tree then 204 // If we've persisted the plugin and we're removed from the tree then
210 // make sure we cleanup the persistance pointer. 205 // make sure we cleanup the persistance pointer.
211 if (m_persistedPluginWidget) { 206 if (m_persistedPlugin) {
212 // TODO(dcheng): This UpdateSuspendScope doesn't seem to provide much; 207 // TODO(dcheng): This UpdateSuspendScope doesn't seem to provide much;
213 // investigate removing it. 208 // investigate removing it.
214 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 209 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
215 setPersistedPluginWidget(nullptr); 210 setPersistedPlugin(nullptr);
216 } 211 }
217 HTMLFrameOwnerElement::removedFrom(insertionPoint); 212 HTMLFrameOwnerElement::removedFrom(insertionPoint);
218 } 213 }
219 214
220 void HTMLPlugInElement::requestPluginCreationWithoutLayoutObjectIfPossible() { 215 void HTMLPlugInElement::requestPluginCreationWithoutLayoutObjectIfPossible() {
221 if (m_serviceType.isEmpty()) 216 if (m_serviceType.isEmpty())
222 return; 217 return;
223 218
224 if (!document().frame() || 219 if (!document().frame() ||
225 !document().frame()->loader().client()->canCreatePluginWithoutRenderer( 220 !document().frame()->loader().client()->canCreatePluginWithoutRenderer(
(...skipping 19 matching lines...) Expand all
245 Vector<String> paramValues; 240 Vector<String> paramValues;
246 241
247 paramNames.push_back("type"); 242 paramNames.push_back("type");
248 paramValues.push_back(m_serviceType); 243 paramValues.push_back(m_serviceType);
249 244
250 bool useFallback = false; 245 bool useFallback = false;
251 loadPlugin(url, m_serviceType, paramNames, paramValues, useFallback, false); 246 loadPlugin(url, m_serviceType, paramNames, paramValues, useFallback, false);
252 } 247 }
253 248
254 bool HTMLPlugInElement::shouldAccelerate() const { 249 bool HTMLPlugInElement::shouldAccelerate() const {
255 if (FrameViewBase* frameViewBase = ownedWidget()) { 250 return ownedPlugin()->platformLayer();
256 return frameViewBase->isPluginView() &&
257 toPluginView(frameViewBase)->platformLayer();
258 }
259 return false;
260 } 251 }
261 252
262 void HTMLPlugInElement::detachLayoutTree(const AttachContext& context) { 253 void HTMLPlugInElement::detachLayoutTree(const AttachContext& context) {
263 // Update the FrameViewBase the next time we attach (detaching destroys the 254 // Update the FrameViewBase the next time we attach (detaching destroys the
264 // plugin). 255 // plugin).
265 // FIXME: None of this "needsPluginUpdate" related code looks right. 256 // FIXME: None of this "needsPluginUpdate" related code looks right.
266 if (layoutObject() && !useFallbackContent()) 257 if (layoutObject() && !useFallbackContent())
267 setNeedsPluginUpdate(true); 258 setNeedsPluginUpdate(true);
268 259
269 if (m_isDelayingLoadEvent) { 260 if (m_isDelayingLoadEvent) {
270 m_isDelayingLoadEvent = false; 261 m_isDelayingLoadEvent = false;
271 document().decrementLoadEventDelayCount(); 262 document().decrementLoadEventDelayCount();
272 } 263 }
273 264
274 // Only try to persist a plugin FrameViewBase we actually own. 265 // Only try to persist a plugin we actually own.
275 FrameViewBase* plugin = ownedWidget(); 266 PluginView* plugin = ownedPlugin();
276 if (plugin && context.performingReattach) { 267 if (plugin && context.performingReattach) {
277 setPersistedPluginWidget(releaseWidget()); 268 setPersistedPlugin(releasePlugin());
278 } else { 269 } else {
279 // Clear the FrameViewBase; will trigger disposal of it with Oilpan. 270 // Clear the plugin; will trigger disposal of it with Oilpan.
280 setWidget(nullptr); 271 setPlugin(nullptr);
281 } 272 }
282 273
283 resetInstance(); 274 resetInstance();
284 275
285 HTMLFrameOwnerElement::detachLayoutTree(context); 276 HTMLFrameOwnerElement::detachLayoutTree(context);
286 } 277 }
287 278
288 LayoutObject* HTMLPlugInElement::createLayoutObject( 279 LayoutObject* HTMLPlugInElement::createLayoutObject(
289 const ComputedStyle& style) { 280 const ComputedStyle& style) {
290 // Fallback content breaks the DOM->layoutObject class relationship of this 281 // Fallback content breaks the DOM->layoutObject class relationship of this
(...skipping 30 matching lines...) Expand all
321 LocalFrame* frame = document().frame(); 312 LocalFrame* frame = document().frame();
322 if (!frame) 313 if (!frame)
323 return nullptr; 314 return nullptr;
324 315
325 // If the host dynamically turns off JavaScript (or Java) we will still 316 // If the host dynamically turns off JavaScript (or Java) we will still
326 // return the cached allocated Bindings::Instance. Not supporting this 317 // return the cached allocated Bindings::Instance. Not supporting this
327 // edge-case is OK. 318 // edge-case is OK.
328 if (!m_pluginWrapper) { 319 if (!m_pluginWrapper) {
329 FrameViewBase* plugin; 320 FrameViewBase* plugin;
330 321
331 if (m_persistedPluginWidget) 322 if (m_persistedPlugin)
332 plugin = m_persistedPluginWidget.get(); 323 plugin = m_persistedPlugin.get();
333 else 324 else
334 plugin = pluginWidget(); 325 plugin = pluginWidget();
335 326
336 if (plugin) 327 if (plugin)
337 m_pluginWrapper = frame->script().createPluginWrapper(plugin); 328 m_pluginWrapper = frame->script().createPluginWrapper(plugin);
338 } 329 }
339 return m_pluginWrapper.get(); 330 return m_pluginWrapper.get();
340 } 331 }
341 332
342 FrameViewBase* HTMLPlugInElement::pluginWidget() const { 333 FrameViewBase* HTMLPlugInElement::pluginWidget() const {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 bool HTMLPlugInElement::hasCustomFocusLogic() const { 414 bool HTMLPlugInElement::hasCustomFocusLogic() const {
424 return !useFallbackContent(); 415 return !useFallbackContent();
425 } 416 }
426 417
427 bool HTMLPlugInElement::isPluginElement() const { 418 bool HTMLPlugInElement::isPluginElement() const {
428 return true; 419 return true;
429 } 420 }
430 421
431 void HTMLPlugInElement::disconnectContentFrame() { 422 void HTMLPlugInElement::disconnectContentFrame() {
432 HTMLFrameOwnerElement::disconnectContentFrame(); 423 HTMLFrameOwnerElement::disconnectContentFrame();
433 setPersistedPluginWidget(nullptr); 424 setPersistedPlugin(nullptr);
434 } 425 }
435 426
436 bool HTMLPlugInElement::layoutObjectIsFocusable() const { 427 bool HTMLPlugInElement::layoutObjectIsFocusable() const {
437 if (HTMLFrameOwnerElement::supportsFocus() && 428 if (HTMLFrameOwnerElement::supportsFocus() &&
438 HTMLFrameOwnerElement::layoutObjectIsFocusable()) 429 HTMLFrameOwnerElement::layoutObjectIsFocusable())
439 return true; 430 return true;
440 431
441 if (useFallbackContent() || !HTMLFrameOwnerElement::layoutObjectIsFocusable()) 432 if (useFallbackContent() || !HTMLFrameOwnerElement::layoutObjectIsFocusable())
442 return false; 433 return false;
443 return m_pluginIsAvailable; 434 return m_pluginIsAvailable;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 508
518 LayoutEmbeddedItem layoutItem = layoutEmbeddedItem(); 509 LayoutEmbeddedItem layoutItem = layoutEmbeddedItem();
519 // FIXME: This code should not depend on layoutObject! 510 // FIXME: This code should not depend on layoutObject!
520 if ((layoutItem.isNull() && requireLayoutObject) || useFallback) 511 if ((layoutItem.isNull() && requireLayoutObject) || useFallback)
521 return false; 512 return false;
522 513
523 VLOG(1) << this << " Plugin URL: " << m_url; 514 VLOG(1) << this << " Plugin URL: " << m_url;
524 VLOG(1) << "Loaded URL: " << url.getString(); 515 VLOG(1) << "Loaded URL: " << url.getString();
525 m_loadedUrl = url; 516 m_loadedUrl = url;
526 517
527 if (m_persistedPluginWidget) { 518 if (m_persistedPlugin) {
528 setWidget(m_persistedPluginWidget.release()); 519 setPlugin(m_persistedPlugin.release());
529 } else { 520 } else {
530 bool loadManually = 521 bool loadManually =
531 document().isPluginDocument() && !document().containsPlugins(); 522 document().isPluginDocument() && !document().containsPlugins();
532 LocalFrameClient::DetachedPluginPolicy policy = 523 LocalFrameClient::DetachedPluginPolicy policy =
533 requireLayoutObject ? LocalFrameClient::FailOnDetachedPlugin 524 requireLayoutObject ? LocalFrameClient::FailOnDetachedPlugin
534 : LocalFrameClient::AllowDetachedPlugin; 525 : LocalFrameClient::AllowDetachedPlugin;
535 FrameViewBase* frameViewBase = frame->loader().client()->createPlugin( 526 PluginView* plugin = frame->loader().client()->createPlugin(
536 this, url, paramNames, paramValues, mimeType, loadManually, policy); 527 this, url, paramNames, paramValues, mimeType, loadManually, policy);
537 if (!frameViewBase) { 528 if (!plugin) {
538 if (!layoutItem.isNull() && 529 if (!layoutItem.isNull() &&
539 !layoutItem.showsUnavailablePluginIndicator()) { 530 !layoutItem.showsUnavailablePluginIndicator()) {
540 m_pluginIsAvailable = false; 531 m_pluginIsAvailable = false;
541 layoutItem.setPluginAvailability(LayoutEmbeddedObject::PluginMissing); 532 layoutItem.setPluginAvailability(LayoutEmbeddedObject::PluginMissing);
542 } 533 }
543 return false; 534 return false;
544 } 535 }
545 536
546 if (!layoutItem.isNull()) 537 if (!layoutItem.isNull())
547 setWidget(frameViewBase); 538 setPlugin(plugin);
548 else 539 else
549 setPersistedPluginWidget(frameViewBase); 540 setPersistedPlugin(plugin);
550 } 541 }
551 542
552 document().setContainsPlugins(); 543 document().setContainsPlugins();
553 // TODO(esprehn): WebPluginContainerImpl::setWebLayer also schedules a 544 // TODO(esprehn): WebPluginContainerImpl::setWebLayer also schedules a
554 // compositing update, do we need both? 545 // compositing update, do we need both?
555 setNeedsCompositingUpdate(); 546 setNeedsCompositingUpdate();
556 // Make sure any input event handlers introduced by the plugin are taken into 547 // Make sure any input event handlers introduced by the plugin are taken into
557 // account. 548 // account.
558 if (Page* page = document().frame()->page()) { 549 if (Page* page = document().frame()->page()) {
559 if (ScrollingCoordinator* scrollingCoordinator = 550 if (ScrollingCoordinator* scrollingCoordinator =
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 } 636 }
646 637
647 bool HTMLPlugInElement::useFallbackContent() const { 638 bool HTMLPlugInElement::useFallbackContent() const {
648 return false; 639 return false;
649 } 640 }
650 641
651 void HTMLPlugInElement::lazyReattachIfNeeded() { 642 void HTMLPlugInElement::lazyReattachIfNeeded() {
652 if (!useFallbackContent() && needsPluginUpdate() && layoutObject() && 643 if (!useFallbackContent() && needsPluginUpdate() && layoutObject() &&
653 !isImageType()) { 644 !isImageType()) {
654 lazyReattachIfAttached(); 645 lazyReattachIfAttached();
655 setPersistedPluginWidget(nullptr); 646 setPersistedPlugin(nullptr);
656 } 647 }
657 } 648 }
658 649
659 } // namespace blink 650 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698