Skip to content
Permalink
Browse files
Remove a first bit of unused plug-in code
https://bugs.webkit.org/show_bug.cgi?id=240309

Reviewed by Chris Dumez.

* Source/WebKit/Sources.txt: Removed Plugin.cpp.
Removed unneeded @no-unify for PluginView.cpp and WebPluginInfoProvider.cpp.

* Source/WebKit/UIProcess/WebProcessProxy.cpp: Removed unneeded include
of PDFPlugin.h.

* Source/WebKit/WebKit.xcodeproj/project.pbxproj: Removed Plugin.cpp,
Plugin.h, and PluginController.h, and turned off non-unified building
for PluginView.cpp and WebPluginInfoProvider.cpp.

* Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleFrame.cpp:
(WKBundleFrameHandlesPageScaleGesture): Deprecate, and always return false.

* Source/WebKit/WebProcess/InjectedBundle/API/c/mac/WKBundlePageMac.mm:
(WKBundlePageGetPDFDocumentInFrame): Moved code inside #if ENABLE(PDFKIT_PLUGIN)
and also removed some unneeded local variables and includes.

* Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h: Updated includes,
removing uneeeded ones, and adding others that previously were inherited
from Plugin.h. Similarly, added and removed forward declarations.
Changed the class to inherit from ThreadSafeRefCounted directly, eliminating
the Plugin base class. Removed the unneeded WebFrame argument from the create
function. Moved functions here from Plugin. Made handlesPageScalFactor,
convertFromPDFViewToRootView frameForHUD, and ensureDataBufferLength private.
Made isFullFramePlugin public. Added deviceScaleFactor. Made the virtual
function overrides just normal functions. Also tweaked arguments and return
values on some of them so they are the minimum needed to do the job.
Replaced the old weak pointer to the plug-in controller with a weak ponter
to the plug-in view; the two are the same object. Removed the isPDFPlugin
function and the type traits for downcast, since this is no longer derived
from a Plugin base class.

* Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm: Tweaked includes.
Removed the "requestID" since now loading the main resource of the plug-in
is done without using general purpose "stream-loading" machinery.
(WebKit::PDFPlugin::create): Take fewer arguments.
(WebKit::PDFPlugin::PDFPlugin): Use WebFrame::fromCoreFrame to find the
frame so we don't have to pass it in. No need for null checks, though, because
PluginView does all those. Refactor and tweak a bit.
(WebKit::PDFPlugin::getResourceBytesAtPosition): Get URL from m_view.
(WebKit::PDFPlugin::updateScrollbars): Use m_view.
(WebKit::PDFPlugin::pluginView): Deleted.
(WebKit::PDFPlugin::pluginView const): Deleted.
(WebKit::PDFPlugin::createScrollbar): Use m_view.
(WebKit::PDFPlugin::convertFromScrollbarToContainingView const): Ditto.
(WebKit::PDFPlugin::convertFromContainingViewToScrollbar const): Ditto.
(WebKit::PDFPlugin::handleScroll): Deleted.
(WebKit::PDFPlugin::scrollCornerRect const): Use m_view.
(WebKit::PDFPlugin::scrollableAreaBoundingBox const): Ditto.
(WebKit::PDFPlugin::addArchiveResource): Ditto. Also get URL from m_vie
since we no longer have m_sourceURL.
(WebKit::PDFPlugin::streamDidFinishLoading): Merged with
documentDataDidFinishLoading and manualStreamDidFinishLoading, and removed
the streamID argument since we only use one stream, to load PDF document data.
(WebKit::PDFPlugin::installPDFDocument): Use m_view.
(WebKit::PDFPlugin::streamDidReceiveResponse): Merged with setSuggestedFilename
and manualStreamDidReceiveResponse, and removed the streamID argument.
(WebKit::PDFPlugin::streamDidReceiveData): Merged with manualStreamDidReceiveData,
and removed the streamID argument.
(WebKit::PDFPlugin::streamDidFail): Merged with manualStreamDidFail, and removed
the streamID argument.
(WebKit::PDFPlugin::deviceScaleFactor const): Added. Gets the device scale factor
from the WebCore Page, which is something we have to do twice. The old code used
to go through the controller to do this.
(WebKit::PDFPlugin::updatePageAndDeviceScaleFactors): Use m_view. This change
looks confusing because what the controller called contentsScaleFactor was the
device scale factor from the WebCore::Page. Better to call that deviceScaleFactor.
(WebKit::PDFPlugin::initialize): Deleted. Moved all this code into
PluginView::initializePlugin.
(WebKit::PDFPlugin::setView): Added. Used to initialize.
(WebKit::PDFPlugin::destroy): Merged with destroyPlugin and with Plugin::destroy.
(WebKit::PDFPlugin::snapshot): Use deviceScaleFactor. See note above.
(WebKit::PDFPlugin::pluginLayer): Use CALayer for the return type.
(WebKit::PDFPlugin::geometryDidChange): Use m_view.
(WebKit::PDFPlugin::frameDidFinishLoading): Deleted.
(WebKit::PDFPlugin::frameDidFail): Deleted.
(WebKit::PDFPlugin::didEvaluateJavaScript): Deleted.
(WebKit::PDFPlugin::handleEditingCommand): Removed unused argument, use StringView.
(WebKit::PDFPlugin::isEditingCommandEnabled): Use StringView.
(WebKit::PDFPlugin::isFullFramePlugin const): Use m_view.
(WebKit::PDFPlugin::notifyContentScaleFactorChanged): Ditto.
(WebKit::PDFPlugin::pluginHandlesContentOffsetForAccessibilityHitTest const): Deleted.
(WebKit::PDFPlugin::openWithNativeApplication): Use isNull.
(WebKit::PDFPlugin::nextMatchForString): Use bool.

* Source/WebKit/WebProcess/Plugins/Plugin.cpp: Removed.
* Source/WebKit/WebProcess/Plugins/Plugin.h: Removed.
* Source/WebKit/WebProcess/Plugins/PluginController.h: Removed.

* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::URLRequest): Deleted.
(WebKit::PluginView::Stream::create): Remove streamID.
(WebKit::PluginView::Stream::streamID const): Deleted.
(WebKit::PluginView::Stream::Stream): Remove streamID.
(WebKit::PluginView::Stream::start): Use PluginView::frame.
(WebKit::PluginView::Stream::continueLoad): Removed unneeded assertion.
(WebKit::buildHTTPHeaders): Deleted.
(WebKit::lastModifiedDateMS): Deleted.
(WebKit::PluginView::Stream::willSendRequest): Removed call to
streamWillSendRequest.
(WebKit::PluginView::Stream::didReceiveResponse): Removed most of the
arguments to streamDidReceiveResponse.
(WebKit::PluginView::Stream::didReceiveData): Removed the streamID
argument to streamDidReceiveData.
(WebKit::PluginView::Stream::didFail): Removed the arguments to
streamDidFail, and the call to removeStream, since we can do that here.
(WebKit::PluginView::Stream::didFinishLoading): Removed the
streamID argument to stringDidFinishLoading, and the call to removeStream,
since we can do that here.
(WebKit::webPage): Deleted.
(WebKit::PluginView::create): Moved the code to map from element to WebPage
in here, changed the arguments to take all the parameters instead of
a Parameters struct, and moved the call to shouldUsePDFPlugin here
from WebPage::createPlugin.
(WebKit::PluginView::PluginView): Take individual parameters instead of
a Parameters struct. Also update for name changes.
(WebKit::PluginView::~PluginView): Removed most of the code, leaving
only call to cancel the stream and destroy the plug-in.
(WebKit::PluginView::destroyPluginAndReset): Deleted.
(WebKit::PluginView::setLayerHostingMode): Deleted.
(WebKit::PluginView::manualLoadDidReceiveResponse): Removed null check
of m_plugin, and most of the arguments to manualStreamDidReceiveResponse,
calling streamDidReceiveResponse instead.
(WebKit::PluginView::manualLoadDidReceiveData): Removed null check
of m_plugin, and call streamDidReceiveData instead of a separate
manualStreamDidReceiveData.
(WebKit::PluginView::manualLoadDidFinishLoading): Removed null check
of m_plugin, and call streamDidFinishLoading instead of a separate
manualStreamDidFinishLoading.
(WebKit::PluginView::manualLoadDidFail): Removed null check
of m_plugin, handling of specific stream errors, and call streamDidFail
without a specific error instead of a separate manualStreamDidFail.
(WebKit::PluginView::setPageScaleFactor): Removed unused IntPoint argument.
(WebKit::PluginView::handlesPageScaleFactor const): Deleted.
(WebKit::PluginView::requiresUnifiedScaleFactor const): Deleted.
(WebKit::PluginView::activityStateDidChange): Deleted.
(WebKit::PluginView::setDeviceScaleFactor): Removed null check of m_plugin.
(WebKit::PluginView::accessibilityAssociatedPluginParentForElement const):
(WebKit::PluginView::windowAndViewFramesChanged): Deleted.
(WebKit::PluginView::accessibilityAssociatedPluginParentForElement const):
Removed null check of m_plugin.
(WebKit::PluginView::accessibilityObject const): Ditto.
(WebKit::PluginView::initializePlugin): Merged with didInitializePlugin
removed null check of m_plugin, code to call addMediaCanStartListener,
code to call addAudioProducer, call Plugin::setView instead of calling
Plugin::initialize, call loadMainResource if needed, which was previously
done by Plugin::initialize. Removed the calls to windowAndViewFramesChanged
Plugin::setFocus. windowVisibilityChanged, windowFocusChanged, and
wantsWheelEvents. Fixed a bug in handling of non-full-frame plug-ins
in the main frame by only sending
MainFramePluginHandlesPageScaleGestureDidChange when it is full frame.
(WebKit::PluginView::platformLayer const): Removed null check of m_plugin.
(WebKit::PluginView::storageBlockingStateChanged): Deleted.
(WebKit::PluginView::scroll): Ditto.
(WebKit::PluginView::horizontalScrollbar): Ditto.
(WebKit::PluginView::verticalScrollbar): Ditto.
(WebKit::PluginView::wantsWheelEvents): Return true.
(WebKit::PluginView::paint): Removed null check of m_plugin and the
call to Plugin::paint.
(WebKit::PluginView::countFindMatches): Removed null check of m_plugin.
(WebKit::PluginView::findString): Ditto.
(WebKit::PluginView::getSelectionString const): Ditto.
(WebKit::PluginView::createWebEvent const): Deleted. Calling this
eventually resulted in calling Plugin::convertToRootView and would then
hit ASSSERT_NOT_REACHED.
(WebKit::PluginView::handleEvent): Removed the call to  createWebEvent.
Updated since m_pluginElement is a Ref instead of RefPtr. Removed the
call to wantsWheelEvents, which is now always true.
(WebKit::PluginView::handleEditingCommand): Removed null check of
m_plugin and stop passing the argument to Plugin::handleEditingCommand.
(WebKit::PluginView::isEditingCommandEnabled): Removed null check of
m_plugin.
(WebKit::PluginView::shouldAllowScripting): Deleted.
(WebKit::PluginView::shouldAllowNavigationFromDrags const): Return true.
(WebKit::PluginView::willDetachRenderer): Removed null check of m_plugin.
(WebKit::PluginView::liveResourceData const): Ditto.
(WebKit::PluginView::performDictionaryLookupAtLocation): Ditto.
(WebKit::PluginView::existingSelectionContainsPoint const): Ditto.
(WebKit::PluginView::viewGeometryDidChange): Ditto.
(WebKit::PluginView::viewVisibilityDidChange): Removed code to calculate
the clip rect and don't pass a clip rect to Plugin::geometryDidChange.
(WebKit::PluginView::clipRectInWindowCoordinates const): Update since
m_pluginElement is a Ref.
(WebKit::PluginView::focusPluginElement): Ditto.
(WebKit::PluginView::pendingResourceRequestTimerFired): Renamed from
pendingURLRequestsTimerFired. Simplified code since we can only have
one pending resource request and we don't want to support JavaScript URLs.
(WebKit::PluginView::performURLRequest): Deleted.
(WebKit::PluginView::performFrameLoadURLRequest): Deleted.
(WebKit::PluginView::performJavaScriptURLRequest): Deleted.
(WebKit::PluginView::addStream): Deleted.
(WebKit::PluginView::removeStream): Deleted.
(WebKit::PluginView::cancelAllStreams): Deleted.
(WebKit::PluginView::redeliverManualStream): Removed error argument
for manualLoadDidFail function.
(WebKit::PluginView::invalidateRect): Removed null check of m_plugin.
(WebKit::PluginView::setFocus): Deleted.
(WebKit::PluginView::mediaCanStart): Deleted.
(WebKit::PluginView::pageMutedStateDidChange): Deleted.
(WebKit::PluginView::loadMainResource): Renamed from loadURL.
Removed all the arguments, since it always loads the same URL in the
same way. Removed most of the code since most arguments are defaults.
(WebKit::PluginView::contentsScaleFactor): Deleted.
(WebKit::PluginView::didFinishLoad): Deleted.
(WebKit::PluginView::didFailLoad): Deleted.
(WebKit::PluginView::shouldCreateTransientPaintingSnapshot const):
Removed null check of m_plugin.
(WebKit::PluginView::isBeingDestroyed const): Moved out of
PluginView.h so it does not have to include PDFPlugin.h.
(WebKit::PluginView::pdfDocumentForPrinting const): Ditto.
(WebKit::PluginView::pdfDocumentSizeForPrinting const): Added.
(WebKit::PluginView::accessibilityHitTest const): Moved out of
PluginView.h so it does not have to include PDFPlugin.h.
(WebKit::PluginView::rectForSelectionInRootView const): Added.
(WebKit::PluginView::contentScaleFactor const): Added.

* Source/WebKit/WebProcess/Plugins/PluginView.h: Wrapped the
entire file in #if ENABLE(PDFKIT_PLUGIN) since this is no longer
a general purpose plug-in view. Removed many includes and an
obsolete comment about moving this whole class to WebCore.
Changed PluginView to no longer derive from PluginController,
MediaCanStartListener, LoadListener, or MediaProducer.
Removed most arguments to PluginView::create and the constructor,
added in the logic about whether to create a PDF view or not, so
it can now return nullptr. Moved isBeingDestroyed out of the header.
Removed the argument to manualLoadDidFail. Removed activityStateDidChange,
setLayerHostingMode, windowAndViewFramesChanged, initialParameters,
handlesPageScaleFactor, requiresUnifiedScaleFactor, shouldAllowScripting,
performURLRequest, performFrameLoadURLRequest, performJavaScriptURLRequest,
addStream, removeStream, cancelAllStreams, mediaCanStart, mediaState,
pageMutedStateDidChange, contentsScaleFactor, didInitializePlugin,
destroyPluginAndReset, didFinishLoad, didFailLoad, createWebEvent,
m_parameters, m_isWaitingUntilMediaCanStart, m_mainResourceURL,
m_mainResourceContentType, m_shouldUseManualLoader, m_pendingFrameLoads,
m_streams, m_manualStreamError, and m_pluginIsPlayingAudio.
Added pdfDocumentSizeForPrinting, mainResourceURL, lookupTextAtLocation,
rectForSelectionInRootView, contentScaleFactor, and m_stream.
Removed unused origin argument to setPageScaleFactor. Renamed
pendingURLRequestsTimerFired to pendingResourceRequestTimerFired,
m_pendingURLRequests to m_pendingResourceRequest,
m_pendingURLRequestsTimer to m_pendingResourceRequestTimer, and
loadURL to loadMainResource. Changed m_pluginElement and m_plugin
from RefPtr to Ref since neither can be null.

* Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.cpp:
Removed most includes.
(WebKit::WebPluginInfoProvider::WebPluginInfoProvider): Deleted.
(WebKit::WebPluginInfoProvider::~WebPluginInfoProvider): Deleted.
(WebKit::pluginInfoVector): Added. Factors out common code.
(WebKit::WebPluginInfoProvider::pluginInfo): Removed everything
except the call to pluginInfoVector.
(WebKit::WebPluginInfoProvider::webVisiblePluginInfo): Ditto.

* Source/WebKit/WebProcess/Plugins/WebPluginInfoProvider.h:
Removed unnneded include and tweaked coding style a bit.

* Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp:
Added a missing FrameDestructionObserverInlines.h include.

* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::print): Call pdfDocumentSizeForPrinting
on the view, not the plug-in. Fixed the #if that was incorrectly
doing PLATFORM(COCOA) when it means ENABLE(PDFKIT_PLUGIN).

* Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::hasPlugInView const): Added.
(WebKit::WebFrameLoaderClient::setMainDocumentError): Moved
plug-in-specific code inside ENABLE(PDFKIT_PLUGIN).
(WebKit::WebFrameLoaderClient::committedLoad): Call hasPlugInView
and moved plug-in-specific code inside ENABLE(PDFKIT_PLUGIN).
(WebKit::WebFrameLoaderClient::finishedLoading): Ditto.
(WebKit::WebFrameLoaderClient::createPlugin): Ditto. Also pass in
the arguments individually instead of a Parameters struct.
(WebKit::WebFrameLoaderClient::redirectDataToPlugin): Ditto.
(WebKit::WebFrameLoaderClient::allowScript): Always return false
for frames with plug-in views.

* Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
Added hasPlugInView. Moved m_pluginView and m_hasSentResponseToPluginView
inside ENABLE(PDFKIT_PLUGIN).

* Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::performDictionaryLookupAtLocation): Put the plug-in
code inside ENABLE(PDFKIT_PLUGIN) and use mainFramePlugIn.
(WebKit::WebPage::getPDFFirstPageSize): Ditto. Also call the
pdfDocumentSizeForPrinting function on the plug-in view rather than
the plug-in. Also removed unneeded null check of WebCore frame before
calling pluginViewForFrame.

* Source/WebKit/WebProcess/WebPage/FindController.cpp: Added include
needed now that other headers don't pull in as many.
(WebKit::FindController::mainFramePlugIn): Added.
(WebKit::FindController::countStringMatches): Put code inside
(WebKit::FindController::updateFindUIAfterPageScroll): Ditto.
(WebKit::FindController::findString): Ditto.
(WebKit::FindController::hideFindUI): Ditto.

* Source/WebKit/WebProcess/WebPage/FindController.h: Added mainFramePlugIn.

* Source/WebKit/WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
(WebKit::ViewGestureGeometryCollector::collectGeometryForSmartMagnificationGesture):
Update since handlesPageScaleGesture is now a WebPage function rather than a
WebFrame function.
(WebKit::ViewGestureGeometryCollector::collectGeometryForMagnificationGesture): Ditto.

* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::handlesPageScaleGesture const): Deleted.
(WebKit::WebFrame::requiresUnifiedScaleFactor const): Deleted.
* Source/WebKit/WebProcess/WebPage/WebFrame.h: Updated for the above.

* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::~WebPage): Put plug-in code inside #if ENABLE(PDFKIT_PLUGIN).
(WebKit::WebPage::editorState const): Ditto.
(WebKit::WebPage::createPlugin): Deleted.
(WebKit::WebPage::pluginViewForFrame): Use dynamicDowncast.
(WebKit::WebPage::mainFramePlugIn): Added.
(WebKit::WebPage::executeEditingCommand): Put plug-in code inside
 #if ENABLE(PDFKIT_PLUGIN).
(WebKit::WebPage::isEditingCommandEnabled): Ditto.
(WebKit::WebPage::textZoomFactor const): Updated since all plug-ins
use "unified scale factor" and all main-frame plug-ins "handle page scale factor".
(WebKit::WebPage::setTextZoomFactor): Ditto.
(WebKit::WebPage::pageZoomFactor const): Ditto.
(WebKit::WebPage::setPageZoomFactor): Ditto.
(WebKit::WebPage::setPageAndTextZoomFactors): Ditto.
(WebKit::WebPage::scalePage): Removed original argument to setPageScaleFactor
and put plug-in code inside #if ENABLE(PDFKIT_PLUGIN).
(WebKit::WebPage::totalScaleFactor const): Updated since all main-frame
plug-ins "handle page scale factor" and put code in #if ENABLE.
(WebKit::WebPage::validateCommand): Put code in #if ENABLE.
(WebKit::WebPage::setTopContentInset): Ditto.
(WebKit::WebPage::getMainResourceDataOfFrame): Ditto.
(WebKit::WebPage::mainFrameView const): Ditto.
(WebKit::WebPage::setActivityState): Removed call to PluginView::activityStateDidChange.
(WebKit::WebPage::setLayerHostingMode): Removed call to PluginView::setLayerHostingMode.
(WebKit::WebPage::addPluginView): Removed code to set m_hasSeenPlugin.
(WebKit::WebPage::windowAndViewFramesChanged): Removed call to
PluginView::windowAndViewFramesChanged.
(WebKit::WebPage::handlesPageScaleGesture const): Added. Returns true if
we have a main-frame plug-in.

* Source/WebKit/WebProcess/WebPage/WebPage.h: Removed include of Plugin.h,
createPlugin, and m_hasSeenPlugin. Changed argument to the
dictionaryPopupInfoForSelectionInPDFPlugin from PDFPlugin to PluginView.
Put all members that involve PluginView inside #if statements.
Added handlesPageScaleGesture and mainFramePlugIn functions.

(WebKit::WebPage::accessibilityObjectForMainFramePlugin): Just return nil
since we don't have any plug-ins in iOS at this time.

* Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
(-[WKAccessibilityWebPageObject accessibilityHitTest:]): Removed call to
pluginHandlesContentOffsetForAccessibilityHitTest, and use mainFramePlugIn.

* Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::accessibilityObjectForMainFramePlugin): Use mainFramePlugIn.
(WebKit::WebPage::dictionaryPopupInfoForSelectionInPDFPlugin): Update since
the plug-in view function is named contentScaleFactor, not just scaleFactor
as the PDF plug-in functino was named.
(WebKit::WebPage::performImmediateActionHitTestAtLocation): Call
lookupTextAtLocation on the plug-in view, not the plug-in.

* Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper associatedPluginParent]): Use dynamicDowncast,
and remove some other casts that are not needed any more.

* Source/WebCore/bindings/js/JSPluginElementFunctions.cpp:
(WebCore::pluginScriptObject): Use dynamicDowncast and removed the plug-in
element argument to DOMTimer::scriptDidInteractWithPlugin.

* Source/WebCore/bindings/js/ScriptController.cpp: Removed include of
PluginViewBase.h.
(WebCore::ScriptController::createScriptInstanceForWidget): Always return
nullptr; this function is only used on platforms that do not support scripting
with widgets at all.

* Source/WebCore/html/HTMLObjectElement.cpp: Removed include of PluginViewBase.h.

* Source/WebCore/html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::pluginWidget const): Return PluginViewBase* instead
of Widget*.
(WebCore::HTMLPlugInElement::isKeyboardFocusable const): Return false.
(WebCore::HTMLPlugInElement::isUserObservable const): Deleted.
(WebCore::HTMLPlugInElement::isBelowSizeThreshold const): Deleted.
* Source/WebCore/html/HTMLPlugInElement.h: Updated for the above.

* Source/WebCore/html/HTMLPlugInImageElement.cpp:
(WebCore::HTMLPlugInImageElement::willDetachRenderers): Removed unneeded
type castss now that pluginWidget returns a PluginViewBase.

* Source/WebCore/html/PluginDocument.cpp:
(WebCore::PluginDocument::pluginWidget): Return PluginViewBase* instead
of Widget*.
* Source/WebCore/html/PluginDocument.h: Updated for the above.

* Source/WebCore/inspector/PageDebugger.cpp:
(WebCore::PageDebugger::setJavaScriptPaused): Removed calls to plug-in views.

* Source/WebCore/loader/FrameLoaderClient.h: Removed forward
declaration of PluginViewBase.

* Source/WebCore/page/DOMTimer.cpp:
(WebCore::DOMTimer::scriptDidInteractWithPlugin): Removed the plug-in
element argument, because all were always returning true for isUserObservable.
* Source/WebCore/page/DOMTimer.h: Updated for the above.

* Source/WebCore/page/DragController.cpp:
(WebCore::DragController::operationForLoad): Removed unneeded dynamicDowncast.

* Source/WebCore/page/Page.cpp:
(WebCore::Page::pluginViews): Deleted.
(WebCore::Page::storageBlockingStateChanged): Removed calls to plug-in views.
* Source/WebCore/page/Page.h: Updated for the above.

* Source/WebCore/platform/ScrollableArea.h:
(WebCore::ScrollableArea::isPDFPlugin const): Deleted.

* Source/WebCore/platform/Widget.h:
(WebCore::Widget::isPluginView const): Deleted.

* Source/WebCore/plugins/PluginViewBase.h: Removed storageBlockingStateChanged,
supportsKeyboardFocus, audioHardwareActivity, setJavaScriptPaused,
and bindingInstance. Made isPluginViewBase private and final.

* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::pluginIsBelowSizeThreshold): Deleted.
* Source/WebCore/testing/Internals.cpp: Updated for the above.
* Source/WebCore/testing/Internals.idl: Ditto. No test was using this.

Canonical link: https://commits.webkit.org/250781@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294526 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
darinadler committed May 20, 2022
1 parent 3e88e12 commit 834b53df582e1113ca713ca2332fa26f34e6298c
Showing 51 changed files with 656 additions and 1,940 deletions.
@@ -1677,15 +1677,13 @@ - (id)associatedPluginParent
auto* backingObject = protectedSelf.get().axBackingObject;
if (!backingObject || !backingObject->hasApplePDFAnnotationAttribute())
return nil;

if (!backingObject->document()->isPluginDocument())
auto* document = dynamicDowncast<PluginDocument>(backingObject->document());
if (!document)
return nil;

Widget* pluginWidget = static_cast<PluginDocument*>(backingObject->document())->pluginWidget();
if (!pluginWidget || !pluginWidget->isPluginViewBase())
auto* widget = document->pluginWidget();
if (!widget)
return nil;

return static_cast<PluginViewBase*>(pluginWidget)->accessibilityAssociatedPluginParentForElement(backingObject->element());
return widget->accessibilityAssociatedPluginParentForElement(backingObject->element());
});
}

@@ -24,8 +24,6 @@
#include "HTMLNames.h"
#include "HTMLPlugInElement.h"
#include "JSHTMLElement.h"
#include "PluginViewBase.h"


namespace WebCore {
using namespace JSC;
@@ -51,23 +49,21 @@ Instance* pluginInstance(HTMLElement& element)

JSObject* pluginScriptObject(JSGlobalObject* lexicalGlobalObject, JSHTMLElement* jsHTMLElement)
{
HTMLElement& element = jsHTMLElement->wrapped();
if (!is<HTMLPlugInElement>(element))
auto* element = dynamicDowncast<HTMLPlugInElement>(jsHTMLElement->wrapped());
if (!element)
return nullptr;

auto& pluginElement = downcast<HTMLPlugInElement>(element);

// Choke point for script/plugin interaction; notify DOMTimer of the event.
DOMTimer::scriptDidInteractWithPlugin(pluginElement);
DOMTimer::scriptDidInteractWithPlugin();

// The plugin element holds an owning reference, so we don't have to.
auto* instance = pluginElement.bindingsInstance();
auto* instance = element->bindingsInstance();
if (!instance || !instance->rootObject())
return nullptr;

return instance->createRuntimeObject(lexicalGlobalObject);
}

JSC_DEFINE_CUSTOM_GETTER(pluginElementPropertyGetter, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName propertyName))
{
VM& vm = lexicalGlobalObject->vm();
@@ -47,7 +47,6 @@
#include "PageConsoleClient.h"
#include "PageGroup.h"
#include "PaymentCoordinator.h"
#include "PluginViewBase.h"
#include "RunJavaScriptParameters.h"
#include "RuntimeApplicationChecks.h"
#include "RuntimeEnabledFeatures.h"
@@ -493,12 +492,9 @@ void ScriptController::collectIsolatedContexts(Vector<std::pair<JSC::JSGlobalObj
}

#if !PLATFORM(COCOA)
RefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWidget(Widget* widget)
RefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWidget(Widget*)
{
if (!is<PluginViewBase>(*widget))
return nullptr;

return downcast<PluginViewBase>(*widget).bindingInstance();
return nullptr;
}
#endif

@@ -41,7 +41,6 @@
#include "MIMETypeRegistry.h"
#include "NodeList.h"
#include "Page.h"
#include "PluginViewBase.h"
#include "RenderEmbeddedObject.h"
#include "RenderImage.h"
#include "RenderWidget.h"
@@ -112,13 +112,13 @@ JSC::Bindings::Instance* HTMLPlugInElement::bindingsInstance()
return m_instance.get();
}

Widget* HTMLPlugInElement::pluginWidget(PluginLoadingPolicy loadPolicy) const
PluginViewBase* HTMLPlugInElement::pluginWidget(PluginLoadingPolicy loadPolicy) const
{
RenderWidget* renderWidget = loadPolicy == PluginLoadingPolicy::Load ? renderWidgetLoadingPlugin() : this->renderWidget();
if (!renderWidget)
return nullptr;

return renderWidget->widget();
return dynamicDowncast<PluginViewBase>(renderWidget->widget());
}

RenderWidget* HTMLPlugInElement::renderWidgetLoadingPlugin() const
@@ -187,39 +187,14 @@ void HTMLPlugInElement::defaultEventHandler(Event& event)

bool HTMLPlugInElement::isKeyboardFocusable(KeyboardEvent*) const
{
// FIXME: Why is this check needed?
if (!document().page())
return false;

RefPtr<Widget> widget = pluginWidget();
if (!is<PluginViewBase>(widget))
return false;

return downcast<PluginViewBase>(*widget).supportsKeyboardFocus();
return false;
}

bool HTMLPlugInElement::isPluginElement() const
{
return true;
}

bool HTMLPlugInElement::isUserObservable() const
{
// No widget - can't be anything to see or hear here.
RefPtr<Widget> widget = pluginWidget(PluginLoadingPolicy::DoNotLoad);
if (!is<PluginViewBase>(widget))
return false;

PluginViewBase& pluginView = downcast<PluginViewBase>(*widget);

// If audio is playing (or might be) then the plugin is detectable.
if (pluginView.audioHardwareActivity() != AudioHardwareActivityType::IsInactive)
return true;

// If the plugin is visible and not vanishingly small in either dimension it is detectable.
return pluginView.isVisible() && pluginView.width() > 2 && pluginView.height() > 2;
}

bool HTMLPlugInElement::supportsFocus() const
{
if (HTMLFrameOwnerElement::supportsFocus())
@@ -362,15 +337,6 @@ bool HTMLPlugInElement::requestObject(const String& relativeURL, const String& m
return true;
}

bool HTMLPlugInElement::isBelowSizeThreshold() const
{
auto* renderObject = renderer();
if (!is<RenderEmbeddedObject>(renderObject))
return true;
auto& renderEmbeddedObject = downcast<RenderEmbeddedObject>(*renderObject);
return renderEmbeddedObject.isPluginUnavailable() && renderEmbeddedObject.pluginUnavailabilityReason() == RenderEmbeddedObject::PluginTooSmall;
}

bool HTMLPlugInElement::setReplacement(RenderEmbeddedObject::PluginUnavailabilityReason reason, const String& unavailabilityDescription)
{
if (!is<RenderEmbeddedObject>(renderer()))
@@ -36,8 +36,8 @@ class Instance;
namespace WebCore {

class PluginReplacement;
class PluginViewBase;
class RenderWidget;
class Widget;

class HTMLPlugInElement : public HTMLFrameOwnerElement {
WTF_MAKE_ISO_ALLOCATED(HTMLPlugInElement);
@@ -49,7 +49,7 @@ class HTMLPlugInElement : public HTMLFrameOwnerElement {
JSC::Bindings::Instance* bindingsInstance();

enum class PluginLoadingPolicy { DoNotLoad, Load };
WEBCORE_EXPORT Widget* pluginWidget(PluginLoadingPolicy = PluginLoadingPolicy::Load) const;
WEBCORE_EXPORT PluginViewBase* pluginWidget(PluginLoadingPolicy = PluginLoadingPolicy::Load) const;

enum DisplayState {
Playing,
@@ -69,10 +69,6 @@ class HTMLPlugInElement : public HTMLFrameOwnerElement {

virtual bool isPlugInImageElement() const = 0;

bool isUserObservable() const;

WEBCORE_EXPORT bool isBelowSizeThreshold() const;

// Return whether or not the replacement content for blocked plugins is accessible to the user.
WEBCORE_EXPORT bool setReplacement(RenderEmbeddedObject::PluginUnavailabilityReason, const String& unavailabilityDescription);

@@ -180,9 +180,8 @@ void HTMLPlugInImageElement::didAttachRenderers()

void HTMLPlugInImageElement::willDetachRenderers()
{
RefPtr widget = pluginWidget(PluginLoadingPolicy::DoNotLoad);
if (is<PluginViewBase>(widget))
downcast<PluginViewBase>(*widget).willDetachRenderer();
if (RefPtr widget = pluginWidget(PluginLoadingPolicy::DoNotLoad))
widget->willDetachRenderer();

HTMLPlugInElement::willDetachRenderers();
}
@@ -34,6 +34,7 @@
#include "HTMLEmbedElement.h"
#include "HTMLHtmlElement.h"
#include "HTMLNames.h"
#include "PluginViewBase.h"
#include "RawDataDocumentParser.h"
#include "RenderEmbeddedObject.h"
#include <wtf/IsoMallocInlines.h>
@@ -155,14 +156,14 @@ Ref<DocumentParser> PluginDocument::createParser()
return PluginDocumentParser::create(*this);
}

Widget* PluginDocument::pluginWidget()
PluginViewBase* PluginDocument::pluginWidget()
{
if (!m_pluginElement)
return nullptr;
auto* renderer = m_pluginElement->renderer();
auto* renderer = dynamicDowncast<RenderEmbeddedObject>(m_pluginElement->renderer());
if (!renderer)
return nullptr;
return downcast<RenderEmbeddedObject>(*m_pluginElement->renderer()).widget();
return dynamicDowncast<PluginViewBase>(renderer->widget());
}

void PluginDocument::setPluginElement(HTMLPlugInElement& element)
@@ -29,7 +29,7 @@
namespace WebCore {

class HTMLPlugInElement;
class Widget;
class PluginViewBase;

class PluginDocument final : public HTMLDocument {
WTF_MAKE_ISO_ALLOCATED(PluginDocument);
@@ -39,7 +39,7 @@ class PluginDocument final : public HTMLDocument {
return adoptRef(*new PluginDocument(frame, url));
}

WEBCORE_EXPORT Widget* pluginWidget();
WEBCORE_EXPORT PluginViewBase* pluginWidget();
HTMLPlugInElement* pluginElement() { return m_pluginElement.get(); }

void setPluginElement(HTMLPlugInElement&);
@@ -37,7 +37,6 @@
#include "JSDOMWindowCustom.h"
#include "Page.h"
#include "PageGroup.h"
#include "PluginViewBase.h"
#include "ScriptController.h"
#include "Timer.h"
#include <JavaScriptCore/JSLock.h>
@@ -176,14 +175,6 @@ void PageDebugger::setJavaScriptPaused(Frame& frame, bool paused)
document.resumeActiveDOMObjects(ReasonForSuspension::JavaScriptDebuggerPaused);
document.resumeScriptedAnimationControllerCallbacks();
}

if (auto* view = frame.view()) {
for (auto& child : view->children()) {
if (!is<PluginViewBase>(child))
continue;
downcast<PluginViewBase>(child.get()).setJavaScriptPaused(paused);
}
}
}

#if !PLATFORM(MAC)
@@ -89,7 +89,6 @@ class LegacyPreviewLoaderClient;
class MessageEvent;
class NavigationAction;
class Page;
class PluginViewBase;
class ProtectionSpace;
class RegistrableDomain;
class RTCPeerConnectionHandler;
@@ -31,7 +31,6 @@
#include "InspectorInstrumentation.h"
#include "Logging.h"
#include "Page.h"
#include "PluginViewBase.h"
#include "ScheduledAction.h"
#include "ScriptExecutionContext.h"
#include "Settings.h"
@@ -275,15 +274,12 @@ void DOMTimer::updateThrottlingStateIfNecessary(const DOMTimerFireState& fireSta
}
}

void DOMTimer::scriptDidInteractWithPlugin(HTMLPlugInElement& pluginElement)
void DOMTimer::scriptDidInteractWithPlugin()
{
if (!DOMTimerFireState::current)
return;

if (pluginElement.isUserObservable())
DOMTimerFireState::current->setScriptMadeUserObservableChanges();
else
DOMTimerFireState::current->setScriptMadeNonUserObservableChanges();
DOMTimerFireState::current->setScriptMadeUserObservableChanges();
}

void DOMTimer::fired()
@@ -37,7 +37,6 @@ namespace WebCore {

class DOMTimerFireState;
class Document;
class HTMLPlugInElement;
class ScheduledAction;

class DOMTimer final : public RefCounted<DOMTimer>, public SuspendableTimerBase {
@@ -62,7 +61,7 @@ class DOMTimer final : public RefCounted<DOMTimer>, public SuspendableTimerBase
// setting for the context has changed).
void updateTimerIntervalIfNecessary();

static void scriptDidInteractWithPlugin(HTMLPlugInElement&);
static void scriptDidInteractWithPlugin();

private:
DOMTimer(ScriptExecutionContext&, Function<void(ScriptExecutionContext&)>&&, Seconds interval, bool singleShot);
@@ -503,7 +503,7 @@ std::optional<DragOperation> DragController::operationForLoad(const DragData& dr

bool pluginDocumentAcceptsDrags = false;
if (auto* pluginDocument = dynamicDowncast<PluginDocument>(document)) {
if (auto* pluginView = dynamicDowncast<PluginViewBase>(pluginDocument->pluginWidget()))
if (auto* pluginView = pluginDocument->pluginWidget())
pluginDocumentAcceptsDrags = pluginView->shouldAllowNavigationFromDrags();
}

@@ -2279,31 +2279,11 @@ void Page::dnsPrefetchingStateChanged()
});
}

Vector<Ref<PluginViewBase>> Page::pluginViews()
{
Vector<Ref<PluginViewBase>> views;
for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
auto* view = frame->view();
if (!view)
break;
for (auto& widget : view->children()) {
if (is<PluginViewBase>(widget))
views.append(downcast<PluginViewBase>(widget.get()));
}
}
return views;
}

void Page::storageBlockingStateChanged()
{
forEachDocument([] (Document& document) {
document.storageBlockingStateDidChange();
});

// Collect the PluginViews in to a vector to ensure that action the plug-in takes
// from below storageBlockingStateChanged does not affect their lifetime.
for (auto& view : pluginViews())
view->storageBlockingStateChanged();
}

void Page::updateIsPlayingMedia()
@@ -145,7 +145,6 @@ class PerformanceMonitor;
class PermissionController;
class PluginData;
class PluginInfoProvider;
class PluginViewBase;
class PointerCaptureController;
class PointerLockController;
class ProgressTracker;
@@ -991,8 +990,6 @@ class Page : public Supplementable<Page>, public CanMakeWeakPtr<Page> {
void playbackControlsManagerUpdateTimerFired();
#endif

Vector<Ref<PluginViewBase>> pluginViews();

void handleLowModePowerChange(bool);

enum class TimerThrottlingState { Disabled, Enabled, EnabledIncreasing };
@@ -66,7 +66,6 @@ class ScrollableArea : public CanMakeWeakPtr<ScrollableArea> {
virtual bool isScrollView() const { return false; }
virtual bool isRenderLayer() const { return false; }
virtual bool isListBox() const { return false; }
virtual bool isPDFPlugin() const { return false; }

WEBCORE_EXPORT bool scroll(ScrollDirection, ScrollGranularity, unsigned stepCount = 1);
WEBCORE_EXPORT void scrollToPositionWithAnimation(const FloatPoint&, ScrollClamping = ScrollClamping::Clamped);
@@ -129,8 +129,6 @@ class Widget : public RefCounted<Widget>, public CanMakeWeakPtr<Widget> {
void setIsSelected(bool);

virtual bool isFrameView() const { return false; }
virtual bool isPluginView() const { return false; }
// FIXME: The Mac plug-in code should inherit from PluginView. When this happens PluginViewBase and PluginView can become one class.
virtual bool isPluginViewBase() const { return false; }
virtual bool isScrollbar() const { return false; }
virtual bool isScrollView() const { return false; }

0 comments on commit 834b53d

Please sign in to comment.