bool HTMLPlugInImageElement::willRecalcStyle(StyleChange) { // FIXME: Why is this necessary? Manual re-attach is almost always wrong. if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType()) reattach(); return true; }
void HTMLObjectElement::renderFallbackContent() { if (useFallbackContent()) return; if (!inDocument()) return; // Before we give up and use fallback content, check to see if this is a MIME type issue. if (m_imageLoader && m_imageLoader->image() && m_imageLoader->image()->status() != CachedResource::LoadError) { m_serviceType = m_imageLoader->image()->response().mimeType(); if (!isImageType()) { // If we don't think we have an image type anymore, then clear the image from the loader. m_imageLoader->setImage(0); reattach(); return; } } m_useFallbackContent = true; // FIXME: Style gets recalculated which is suboptimal. detach(); attach(); }
void HTMLPlugInElement::detach(const AttachContext& context) { // Update the widget the next time we attach (detaching destroys the plugin). // FIXME: None of this "needsWidgetUpdate" related code looks right. if (renderer() && !useFallbackContent()) setNeedsWidgetUpdate(true); if (m_isDelayingLoadEvent) { m_isDelayingLoadEvent = false; document().decrementLoadEventDelayCount(); } // Only try to persist a plugin widget we actually own. Widget* plugin = ownedWidget(); if (plugin && plugin->pluginShouldPersist()) m_persistedPluginWidget = plugin; resetInstance(); // FIXME - is this next line necessary? setWidget(nullptr); if (m_isCapturingMouseEvents) { if (LocalFrame* frame = document().frame()) frame->eventHandler().setCapturingMouseEventsNode(nullptr); m_isCapturingMouseEvents = false; } if (m_NPObject) { _NPN_ReleaseObject(m_NPObject); m_NPObject = 0; } HTMLFrameOwnerElement::detach(context); }
RenderObject* HTMLPlugInImageElement::createRenderer(RenderArena* arena, RenderStyle* style) { // Once a PlugIn Element creates its renderer, it needs to be told when the Document goes // inactive or reactivates so it can clear the renderer before going into the page cache. if (!m_needsDocumentActivationCallbacks) { m_needsDocumentActivationCallbacks = true; document()->registerForPageCacheSuspensionCallbacks(this); } if (displayState() == DisplayingSnapshot) { RenderSnapshottedPlugIn* renderSnapshottedPlugIn = new (arena) RenderSnapshottedPlugIn(this); renderSnapshottedPlugIn->updateSnapshot(m_snapshotImage); return renderSnapshottedPlugIn; } // Fallback content breaks the DOM->Renderer class relationship of this // class and all superclasses because createObject won't necessarily // return a RenderEmbeddedObject, RenderPart or even RenderWidget. if (useFallbackContent()) return RenderObject::createObject(this, style); if (isImageType()) { RenderImage* image = new (arena) RenderImage(this); image->setImageResource(RenderImageResource::create()); return image; } return new (arena) RenderEmbeddedObject(this); }
void HTMLPlugInImageElement::recalcStyle(StyleChange ch) { // FIXME: Why is this necessary? Manual re-attach is almost always wrong. if (!useFallbackContent() && needsWidgetUpdate() && renderer() && !isImageType()) reattach(); HTMLPlugInElement::recalcStyle(ch); }
void HTMLObjectElement::renderFallbackContent() { if (useFallbackContent()) return; if (!inDocument()) return; setNeedsStyleRecalc(ReconstructRenderTree); // Before we give up and use fallback content, check to see if this is a MIME type issue. auto* loader = imageLoader(); if (loader && loader->image() && loader->image()->status() != CachedResource::LoadError) { m_serviceType = loader->image()->response().mimeType(); if (!isImageType()) { // If we don't think we have an image type anymore, then clear the image from the loader. loader->setImage(nullptr); return; } } m_useFallbackContent = true; // This was added to keep Acid 2 non-flaky. A style recalc is required to make fallback resources load. // Without forcing, this may happen after all the other resources have been loaded and the document is already // considered complete. FIXME: Would be better to address this with incrementLoadEventDelayCount instead // or disentangle loading from style entirely. document().updateStyleIfNeeded(); }
void HTMLObjectElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) { updateDocNamedItem(); if (inDocument() && !useFallbackContent()) { setNeedsWidgetUpdate(true); setNeedsStyleRecalc(); } HTMLPlugInImageElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); }
bool HTMLPlugInElement::supportsFocus() const { if (HTMLFrameOwnerElement::supportsFocus()) return true; if (useFallbackContent() || !renderer() || !renderer()->isEmbeddedObject()) return false; return !toRenderEmbeddedObject(renderer())->isPluginUnavailable(); }
void HTMLObjectElement::childrenChanged(const ChildChange& change) { updateDocNamedItem(); if (inDocument() && !useFallbackContent()) { setNeedsWidgetUpdate(true); setNeedsStyleRecalc(); } HTMLPlugInImageElement::childrenChanged(change); }
bool HTMLPlugInElement::supportsFocus() const { if (HTMLFrameOwnerElement::supportsFocus()) return true; if (useFallbackContent() || !is<RenderEmbeddedObject>(renderer())) return false; return !downcast<RenderEmbeddedObject>(*renderer()).isPluginUnavailable(); }
void HTMLPlugInImageElement::finishParsingChildren() { HTMLPlugInElement::finishParsingChildren(); if (useFallbackContent()) return; setNeedsWidgetUpdate(true); if (inDocument()) setNeedsStyleRecalc(); }
void HTMLPlugInImageElement::detach() { // FIXME: Because of the insanity that is HTMLPlugInImageElement::recalcStyle, // we can end up detaching during an attach() call, before we even have a // renderer. In that case, don't mark the widget for update. if (attached() && renderer() && !useFallbackContent()) // Update the widget the next time we attach (detaching destroys the plugin). setNeedsWidgetUpdate(true); HTMLPlugInElement::detach(); }
void HTMLPlugInElement::finishParsingChildren() { HTMLFrameOwnerElement::finishParsingChildren(); if (useFallbackContent()) return; setNeedsWidgetUpdate(true); if (inDocument()) setNeedsStyleRecalc(SubtreeStyleChange); }
void HTMLPlugInImageElement::updateWidgetIfNecessary() { document()->updateStyleIfNeeded(); if (!needsWidgetUpdate() || useFallbackContent() || isImageType()) return; if (!renderEmbeddedObject() || renderEmbeddedObject()->pluginCrashedOrWasMissing()) return; updateWidget(CreateOnlyNonNetscapePlugins); }
void HTMLPlugInImageElement::updateWidgetIfNecessary() { document()->updateStyleIfNeeded(); if (!needsWidgetUpdate() || useFallbackContent() || isImageType()) return; if (!renderEmbeddedObject() || renderEmbeddedObject()->showsUnavailablePluginIndicator()) return; updateWidget(CreateOnlyNonNetscapePlugins); }
RenderObject* HTMLPlugInImageElement::createRenderer(RenderArena* arena, RenderStyle* style) { // Fallback content breaks the DOM->Renderer class relationship of this // class and all superclasses because createObject won't necessarily // return a RenderEmbeddedObject, RenderPart or even RenderWidget. if (useFallbackContent()) return RenderObject::createObject(this, style); if (isImageType()) { RenderImage* image = new (arena) RenderImage(this); image->setImageResource(RenderImageResource::create()); return image; } return new (arena) RenderEmbeddedObject(this); }
void HTMLPlugInImageElement::attach() { bool isImage = isImageType(); if (!isImage) queuePostAttachCallback(&HTMLPlugInImageElement::updateWidgetCallback, this); HTMLPlugInElement::attach(); if (isImage && renderer() && !useFallbackContent()) { if (!m_imageLoader) m_imageLoader = adoptPtr(new HTMLImageLoader(this)); m_imageLoader->updateFromElement(); } }
void HTMLPlugInElement::attach(const AttachContext& context) { HTMLFrameOwnerElement::attach(context); if (!renderer() || useFallbackContent()) return; if (isImageType()) { if (!m_imageLoader) m_imageLoader = HTMLImageLoader::create(this); m_imageLoader->updateFromElement(); } else if (needsWidgetUpdate() && renderEmbeddedObject() && !renderEmbeddedObject()->showsUnavailablePluginIndicator() && !wouldLoadAsNetscapePlugin(m_url, m_serviceType) && !m_isDelayingLoadEvent) { m_isDelayingLoadEvent = true; document().incrementLoadEventDelayCount(); document().loadPluginsSoon(); } }