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

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

Issue 2723993002: Rename platform/Widget to platform/FrameViewBase in core. (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 28 matching lines...) Expand all
39 #include "core/html/PluginDocument.h" 39 #include "core/html/PluginDocument.h"
40 #include "core/input/EventHandler.h" 40 #include "core/input/EventHandler.h"
41 #include "core/inspector/ConsoleMessage.h" 41 #include "core/inspector/ConsoleMessage.h"
42 #include "core/layout/LayoutImage.h" 42 #include "core/layout/LayoutImage.h"
43 #include "core/layout/LayoutPart.h" 43 #include "core/layout/LayoutPart.h"
44 #include "core/layout/api/LayoutEmbeddedItem.h" 44 #include "core/layout/api/LayoutEmbeddedItem.h"
45 #include "core/loader/MixedContentChecker.h" 45 #include "core/loader/MixedContentChecker.h"
46 #include "core/page/Page.h" 46 #include "core/page/Page.h"
47 #include "core/page/scrolling/ScrollingCoordinator.h" 47 #include "core/page/scrolling/ScrollingCoordinator.h"
48 #include "core/plugins/PluginView.h" 48 #include "core/plugins/PluginView.h"
49 #include "platform/FrameViewBase.h"
49 #include "platform/Histogram.h" 50 #include "platform/Histogram.h"
50 #include "platform/Widget.h"
51 #include "platform/network/ResourceRequest.h" 51 #include "platform/network/ResourceRequest.h"
52 #include "platform/network/mime/MIMETypeFromURL.h" 52 #include "platform/network/mime/MIMETypeFromURL.h"
53 #include "platform/network/mime/MIMETypeRegistry.h" 53 #include "platform/network/mime/MIMETypeRegistry.h"
54 #include "platform/plugins/PluginData.h" 54 #include "platform/plugins/PluginData.h"
55 #include "public/platform/WebURLRequest.h" 55 #include "public/platform/WebURLRequest.h"
56 56
57 namespace blink { 57 namespace blink {
58 58
59 using namespace HTMLNames; 59 using namespace HTMLNames;
60 60
(...skipping 10 matching lines...) Expand all
71 } // anonymous namespace 71 } // anonymous namespace
72 72
73 HTMLPlugInElement::HTMLPlugInElement( 73 HTMLPlugInElement::HTMLPlugInElement(
74 const QualifiedName& tagName, 74 const QualifiedName& tagName,
75 Document& doc, 75 Document& doc,
76 bool createdByParser, 76 bool createdByParser,
77 PreferPlugInsForImagesOption preferPlugInsForImagesOption) 77 PreferPlugInsForImagesOption preferPlugInsForImagesOption)
78 : HTMLFrameOwnerElement(tagName, doc), 78 : HTMLFrameOwnerElement(tagName, doc),
79 m_isDelayingLoadEvent(false), 79 m_isDelayingLoadEvent(false),
80 // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay 80 // m_needsWidgetUpdate(!createdByParser) allows HTMLObjectElement to delay
81 // widget updates until after all children are parsed. For 81 // FrameViewBase updates until after all children are parsed. For
82 // HTMLEmbedElement this delay is unnecessary, but it is simpler to make 82 // HTMLEmbedElement this delay is unnecessary, but it is simpler to make
83 // both classes share the same codepath in this class. 83 // both classes share the same codepath in this class.
84 m_needsWidgetUpdate(!createdByParser), 84 m_needsWidgetUpdate(!createdByParser),
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_persistedPluginWidget);
96 HTMLFrameOwnerElement::trace(visitor); 96 HTMLFrameOwnerElement::trace(visitor);
97 } 97 }
98 98
99 void HTMLPlugInElement::setPersistedPluginWidget(Widget* widget) { 99 void HTMLPlugInElement::setPersistedPluginWidget(FrameViewBase* frameViewBase) {
100 if (m_persistedPluginWidget == widget) 100 if (m_persistedPluginWidget == frameViewBase)
101 return; 101 return;
102 if (m_persistedPluginWidget) { 102 if (m_persistedPluginWidget) {
103 if (m_persistedPluginWidget->isPluginView()) { 103 if (m_persistedPluginWidget->isPluginView()) {
104 m_persistedPluginWidget->hide(); 104 m_persistedPluginWidget->hide();
105 disposeWidgetSoon(m_persistedPluginWidget.release()); 105 disposeWidgetSoon(m_persistedPluginWidget.release());
106 } else { 106 } else {
107 DCHECK(m_persistedPluginWidget->isFrameView() || 107 DCHECK(m_persistedPluginWidget->isFrameView() ||
108 m_persistedPluginWidget->isRemoteFrameView()); 108 m_persistedPluginWidget->isRemoteFrameView());
109 } 109 }
110 } 110 }
111 m_persistedPluginWidget = widget; 111 m_persistedPluginWidget = frameViewBase;
112 } 112 }
113 113
114 bool HTMLPlugInElement::requestObjectInternal( 114 bool HTMLPlugInElement::requestObjectInternal(
115 const String& url, 115 const String& url,
116 const String& mimeType, 116 const String& mimeType,
117 const Vector<String>& paramNames, 117 const Vector<String>& paramNames,
118 const Vector<String>& paramValues) { 118 const Vector<String>& paramValues) {
119 if (url.isEmpty() && mimeType.isEmpty()) 119 if (url.isEmpty() && mimeType.isEmpty())
120 return false; 120 return false;
121 121
122 if (protocolIsJavaScript(url)) 122 if (protocolIsJavaScript(url))
123 return false; 123 return false;
124 124
125 KURL completedURL = url.isEmpty() ? KURL() : document().completeURL(url); 125 KURL completedURL = url.isEmpty() ? KURL() : document().completeURL(url);
126 if (!allowedToLoadObject(completedURL, mimeType)) 126 if (!allowedToLoadObject(completedURL, mimeType))
127 return false; 127 return false;
128 128
129 bool useFallback; 129 bool useFallback;
130 if (!shouldUsePlugin(completedURL, mimeType, hasFallbackContent(), 130 if (!shouldUsePlugin(completedURL, mimeType, hasFallbackContent(),
131 useFallback)) { 131 useFallback)) {
132 // If the plugin element already contains a subframe, 132 // If the plugin element already contains a subframe,
133 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a 133 // loadOrRedirectSubframe will re-use it. Otherwise, it will create a
134 // new frame and set it as the LayoutPart's widget, causing what was 134 // new frame and set it as the LayoutPart's FrameViewBase, causing what was
135 // previously in the widget to be torn down. 135 // previously in the FrameViewBase to be torn down.
136 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true); 136 return loadOrRedirectSubframe(completedURL, getNameAttribute(), true);
137 } 137 }
138 138
139 return loadPlugin(completedURL, mimeType, paramNames, paramValues, 139 return loadPlugin(completedURL, mimeType, paramNames, paramValues,
140 useFallback, true); 140 useFallback, true);
141 } 141 }
142 142
143 bool HTMLPlugInElement::canProcessDrag() const { 143 bool HTMLPlugInElement::canProcessDrag() const {
144 return pluginWidget() && pluginWidget()->isPluginView() && 144 return pluginWidget() && pluginWidget()->isPluginView() &&
145 toPluginView(pluginWidget())->canProcessDrag(); 145 toPluginView(pluginWidget())->canProcessDrag();
146 } 146 }
147 147
148 bool HTMLPlugInElement::canStartSelection() const { 148 bool HTMLPlugInElement::canStartSelection() const {
149 return useFallbackContent() && Node::canStartSelection(); 149 return useFallbackContent() && Node::canStartSelection();
150 } 150 }
151 151
152 bool HTMLPlugInElement::willRespondToMouseClickEvents() { 152 bool HTMLPlugInElement::willRespondToMouseClickEvents() {
153 if (isDisabledFormControl()) 153 if (isDisabledFormControl())
154 return false; 154 return false;
155 LayoutObject* r = layoutObject(); 155 LayoutObject* r = layoutObject();
156 return r && (r->isEmbeddedObject() || r->isLayoutPart()); 156 return r && (r->isEmbeddedObject() || r->isLayoutPart());
157 } 157 }
158 158
159 void HTMLPlugInElement::removeAllEventListeners() { 159 void HTMLPlugInElement::removeAllEventListeners() {
160 HTMLFrameOwnerElement::removeAllEventListeners(); 160 HTMLFrameOwnerElement::removeAllEventListeners();
161 if (LayoutPart* layoutObject = existingLayoutPart()) { 161 if (LayoutPart* layoutObject = existingLayoutPart()) {
162 if (Widget* widget = layoutObject->widget()) 162 if (FrameViewBase* frameViewBase = layoutObject->widget())
163 widget->eventListenersRemoved(); 163 frameViewBase->eventListenersRemoved();
164 } 164 }
165 } 165 }
166 166
167 void HTMLPlugInElement::didMoveToNewDocument(Document& oldDocument) { 167 void HTMLPlugInElement::didMoveToNewDocument(Document& oldDocument) {
168 if (m_imageLoader) 168 if (m_imageLoader)
169 m_imageLoader->elementDidMoveToNewDocument(); 169 m_imageLoader->elementDidMoveToNewDocument();
170 HTMLFrameOwnerElement::didMoveToNewDocument(oldDocument); 170 HTMLFrameOwnerElement::didMoveToNewDocument(oldDocument);
171 } 171 }
172 172
173 void HTMLPlugInElement::attachLayoutTree(const AttachContext& context) { 173 void HTMLPlugInElement::attachLayoutTree(const AttachContext& context) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 Vector<String> paramValues; 245 Vector<String> paramValues;
246 246
247 paramNames.push_back("type"); 247 paramNames.push_back("type");
248 paramValues.push_back(m_serviceType); 248 paramValues.push_back(m_serviceType);
249 249
250 bool useFallback = false; 250 bool useFallback = false;
251 loadPlugin(url, m_serviceType, paramNames, paramValues, useFallback, false); 251 loadPlugin(url, m_serviceType, paramNames, paramValues, useFallback, false);
252 } 252 }
253 253
254 bool HTMLPlugInElement::shouldAccelerate() const { 254 bool HTMLPlugInElement::shouldAccelerate() const {
255 if (Widget* widget = ownedWidget()) 255 if (FrameViewBase* frameViewBase = ownedWidget()) {
256 return widget->isPluginView() && toPluginView(widget)->platformLayer(); 256 return frameViewBase->isPluginView() &&
257 toPluginView(frameViewBase)->platformLayer();
258 }
257 return false; 259 return false;
258 } 260 }
259 261
260 void HTMLPlugInElement::detachLayoutTree(const AttachContext& context) { 262 void HTMLPlugInElement::detachLayoutTree(const AttachContext& context) {
261 // Update the widget the next time we attach (detaching destroys the plugin). 263 // Update the FrameViewBase the next time we attach (detaching destroys the
264 // plugin).
262 // FIXME: None of this "needsWidgetUpdate" related code looks right. 265 // FIXME: None of this "needsWidgetUpdate" related code looks right.
263 if (layoutObject() && !useFallbackContent()) 266 if (layoutObject() && !useFallbackContent())
264 setNeedsWidgetUpdate(true); 267 setNeedsWidgetUpdate(true);
265 if (m_isDelayingLoadEvent) { 268 if (m_isDelayingLoadEvent) {
266 m_isDelayingLoadEvent = false; 269 m_isDelayingLoadEvent = false;
267 document().decrementLoadEventDelayCount(); 270 document().decrementLoadEventDelayCount();
268 } 271 }
269 272
270 // Only try to persist a plugin widget we actually own. 273 // Only try to persist a plugin FrameViewBase we actually own.
271 Widget* plugin = ownedWidget(); 274 FrameViewBase* plugin = ownedWidget();
272 if (plugin && context.performingReattach) { 275 if (plugin && context.performingReattach) {
273 setPersistedPluginWidget(releaseWidget()); 276 setPersistedPluginWidget(releaseWidget());
274 } else { 277 } else {
275 // Clear the widget; will trigger disposal of it with Oilpan. 278 // Clear the FrameViewBase; will trigger disposal of it with Oilpan.
276 setWidget(nullptr); 279 setWidget(nullptr);
277 } 280 }
278 281
279 resetInstance(); 282 resetInstance();
280 283
281 HTMLFrameOwnerElement::detachLayoutTree(context); 284 HTMLFrameOwnerElement::detachLayoutTree(context);
282 } 285 }
283 286
284 LayoutObject* HTMLPlugInElement::createLayoutObject( 287 LayoutObject* HTMLPlugInElement::createLayoutObject(
285 const ComputedStyle& style) { 288 const ComputedStyle& style) {
(...skipping 29 matching lines...) Expand all
315 318
316 SharedPersistent<v8::Object>* HTMLPlugInElement::pluginWrapper() { 319 SharedPersistent<v8::Object>* HTMLPlugInElement::pluginWrapper() {
317 LocalFrame* frame = document().frame(); 320 LocalFrame* frame = document().frame();
318 if (!frame) 321 if (!frame)
319 return nullptr; 322 return nullptr;
320 323
321 // If the host dynamically turns off JavaScript (or Java) we will still 324 // If the host dynamically turns off JavaScript (or Java) we will still
322 // return the cached allocated Bindings::Instance. Not supporting this 325 // return the cached allocated Bindings::Instance. Not supporting this
323 // edge-case is OK. 326 // edge-case is OK.
324 if (!m_pluginWrapper) { 327 if (!m_pluginWrapper) {
325 Widget* plugin; 328 FrameViewBase* plugin;
326 329
327 if (m_persistedPluginWidget) 330 if (m_persistedPluginWidget)
328 plugin = m_persistedPluginWidget.get(); 331 plugin = m_persistedPluginWidget.get();
329 else 332 else
330 plugin = pluginWidget(); 333 plugin = pluginWidget();
331 334
332 if (plugin) 335 if (plugin)
333 m_pluginWrapper = frame->script().createPluginWrapper(plugin); 336 m_pluginWrapper = frame->script().createPluginWrapper(plugin);
334 } 337 }
335 return m_pluginWrapper.get(); 338 return m_pluginWrapper.get();
336 } 339 }
337 340
338 Widget* HTMLPlugInElement::pluginWidget() const { 341 FrameViewBase* HTMLPlugInElement::pluginWidget() const {
339 if (LayoutPart* layoutPart = layoutPartForJSBindings()) 342 if (LayoutPart* layoutPart = layoutPartForJSBindings())
340 return layoutPart->widget(); 343 return layoutPart->widget();
341 return nullptr; 344 return nullptr;
342 } 345 }
343 346
344 bool HTMLPlugInElement::isPresentationAttribute( 347 bool HTMLPlugInElement::isPresentationAttribute(
345 const QualifiedName& name) const { 348 const QualifiedName& name) const {
346 if (name == widthAttr || name == heightAttr || name == vspaceAttr || 349 if (name == widthAttr || name == heightAttr || name == vspaceAttr ||
347 name == hspaceAttr || name == alignAttr) 350 name == hspaceAttr || name == alignAttr)
348 return true; 351 return true;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // code in EventHandler; these code paths should be united. 386 // code in EventHandler; these code paths should be united.
384 387
385 LayoutObject* r = layoutObject(); 388 LayoutObject* r = layoutObject();
386 if (!r || !r->isLayoutPart()) 389 if (!r || !r->isLayoutPart())
387 return; 390 return;
388 if (r->isEmbeddedObject()) { 391 if (r->isEmbeddedObject()) {
389 if (LayoutEmbeddedItem(toLayoutEmbeddedObject(r)) 392 if (LayoutEmbeddedItem(toLayoutEmbeddedObject(r))
390 .showsUnavailablePluginIndicator()) 393 .showsUnavailablePluginIndicator())
391 return; 394 return;
392 } 395 }
393 Widget* widget = toLayoutPart(r)->widget(); 396 FrameViewBase* frameViewBase = toLayoutPart(r)->widget();
394 if (!widget) 397 if (!frameViewBase)
395 return; 398 return;
396 widget->handleEvent(event); 399 frameViewBase->handleEvent(event);
397 if (event->defaultHandled()) 400 if (event->defaultHandled())
398 return; 401 return;
399 HTMLFrameOwnerElement::defaultEventHandler(event); 402 HTMLFrameOwnerElement::defaultEventHandler(event);
400 } 403 }
401 404
402 LayoutPart* HTMLPlugInElement::layoutPartForJSBindings() const { 405 LayoutPart* HTMLPlugInElement::layoutPartForJSBindings() const {
403 // Needs to load the plugin immediatedly because this function is called 406 // Needs to load the plugin immediatedly because this function is called
404 // when JavaScript code accesses the plugin. 407 // when JavaScript code accesses the plugin.
405 // FIXME: Check if dispatching events here is safe. 408 // FIXME: Check if dispatching events here is safe.
406 document().updateStyleAndLayoutIgnorePendingStylesheets( 409 document().updateStyleAndLayoutIgnorePendingStylesheets(
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 m_loadedUrl = url; 524 m_loadedUrl = url;
522 525
523 if (m_persistedPluginWidget) { 526 if (m_persistedPluginWidget) {
524 setWidget(m_persistedPluginWidget.release()); 527 setWidget(m_persistedPluginWidget.release());
525 } else { 528 } else {
526 bool loadManually = 529 bool loadManually =
527 document().isPluginDocument() && !document().containsPlugins(); 530 document().isPluginDocument() && !document().containsPlugins();
528 LocalFrameClient::DetachedPluginPolicy policy = 531 LocalFrameClient::DetachedPluginPolicy policy =
529 requireLayoutObject ? LocalFrameClient::FailOnDetachedPlugin 532 requireLayoutObject ? LocalFrameClient::FailOnDetachedPlugin
530 : LocalFrameClient::AllowDetachedPlugin; 533 : LocalFrameClient::AllowDetachedPlugin;
531 Widget* widget = frame->loader().client()->createPlugin( 534 FrameViewBase* frameViewBase = frame->loader().client()->createPlugin(
532 this, url, paramNames, paramValues, mimeType, loadManually, policy); 535 this, url, paramNames, paramValues, mimeType, loadManually, policy);
533 if (!widget) { 536 if (!frameViewBase) {
534 if (!layoutItem.isNull() && 537 if (!layoutItem.isNull() &&
535 !layoutItem.showsUnavailablePluginIndicator()) { 538 !layoutItem.showsUnavailablePluginIndicator()) {
536 m_pluginIsAvailable = false; 539 m_pluginIsAvailable = false;
537 layoutItem.setPluginAvailability(LayoutEmbeddedObject::PluginMissing); 540 layoutItem.setPluginAvailability(LayoutEmbeddedObject::PluginMissing);
538 } 541 }
539 return false; 542 return false;
540 } 543 }
541 544
542 if (!layoutItem.isNull()) 545 if (!layoutItem.isNull())
543 setWidget(widget); 546 setWidget(frameViewBase);
544 else 547 else
545 setPersistedPluginWidget(widget); 548 setPersistedPluginWidget(frameViewBase);
546 } 549 }
547 550
548 document().setContainsPlugins(); 551 document().setContainsPlugins();
549 // TODO(esprehn): WebPluginContainerImpl::setWebLayer also schedules a 552 // TODO(esprehn): WebPluginContainerImpl::setWebLayer also schedules a
550 // compositing update, do we need both? 553 // compositing update, do we need both?
551 setNeedsCompositingUpdate(); 554 setNeedsCompositingUpdate();
552 // Make sure any input event handlers introduced by the plugin are taken into 555 // Make sure any input event handlers introduced by the plugin are taken into
553 // account. 556 // account.
554 if (Page* page = document().frame()->page()) { 557 if (Page* page = document().frame()->page()) {
555 if (ScrollingCoordinator* scrollingCoordinator = 558 if (ScrollingCoordinator* scrollingCoordinator =
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 649
647 void HTMLPlugInElement::lazyReattachIfNeeded() { 650 void HTMLPlugInElement::lazyReattachIfNeeded() {
648 if (!useFallbackContent() && needsWidgetUpdate() && layoutObject() && 651 if (!useFallbackContent() && needsWidgetUpdate() && layoutObject() &&
649 !isImageType()) { 652 !isImageType()) {
650 lazyReattachIfAttached(); 653 lazyReattachIfAttached();
651 setPersistedPluginWidget(nullptr); 654 setPersistedPluginWidget(nullptr);
652 } 655 }
653 } 656 }
654 657
655 } // namespace blink 658 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLObjectElement.cpp ('k') | third_party/WebKit/Source/core/html/PluginDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698