2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Corporation. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 * THE POSSIBILITY OF SUCH DAMAGE.
28 #include "WebPageProxy.h"
31 #include "APIFindClient.h"
32 #include "APIFormClient.h"
33 #include "APILoaderClient.h"
34 #include "APIPolicyClient.h"
35 #include "APIUIClient.h"
36 #include "APIURLRequest.h"
37 #include "AuthenticationChallengeProxy.h"
38 #include "AuthenticationDecisionListener.h"
39 #include "DataReference.h"
40 #include "DownloadProxy.h"
41 #include "DrawingAreaProxy.h"
42 #include "DrawingAreaProxyMessages.h"
43 #include "EventDispatcherMessages.h"
44 #include "FindIndicator.h"
46 #include "NativeWebKeyboardEvent.h"
47 #include "NativeWebMouseEvent.h"
48 #include "NativeWebWheelEvent.h"
49 #include "NavigationActionData.h"
50 #include "NotificationPermissionRequest.h"
51 #include "NotificationPermissionRequestManager.h"
52 #include "PageClient.h"
53 #include "PluginInformation.h"
54 #include "PluginProcessManager.h"
55 #include "PrintInfo.h"
56 #include "TextChecker.h"
57 #include "TextCheckerState.h"
58 #include "WKContextPrivate.h"
59 #include "WebBackForwardList.h"
60 #include "WebBackForwardListItem.h"
61 #include "WebCertificateInfo.h"
62 #include "WebContext.h"
63 #include "WebContextMenuProxy.h"
64 #include "WebContextUserMessageCoders.h"
65 #include "WebCoreArgumentCoders.h"
66 #include "WebEditCommandProxy.h"
68 #include "WebEventConversion.h"
69 #include "WebFormSubmissionListenerProxy.h"
70 #include "WebFramePolicyListenerProxy.h"
71 #include "WebFullScreenManagerProxy.h"
72 #include "WebFullScreenManagerProxyMessages.h"
73 #include "WebInspectorProxy.h"
74 #include "WebInspectorProxyMessages.h"
75 #include "WebNotificationManagerProxy.h"
76 #include "WebOpenPanelParameters.h"
77 #include "WebOpenPanelResultListenerProxy.h"
78 #include "WebPageCreationParameters.h"
79 #include "WebPageGroup.h"
80 #include "WebPageGroupData.h"
81 #include "WebPageMessages.h"
82 #include "WebPageProxyMessages.h"
83 #include "WebPopupItem.h"
84 #include "WebPopupMenuProxy.h"
85 #include "WebPreferences.h"
86 #include "WebProcessMessages.h"
87 #include "WebProcessProxy.h"
88 #include "WebProtectionSpace.h"
89 #include "WebSecurityOrigin.h"
90 #include "WebUserContentControllerProxy.h"
91 #include <WebCore/DragController.h>
92 #include <WebCore/DragData.h>
93 #include <WebCore/FloatRect.h>
94 #include <WebCore/FocusDirection.h>
95 #include <WebCore/MIMETypeRegistry.h>
96 #include <WebCore/RenderEmbeddedObject.h>
97 #include <WebCore/SerializedCryptoKeyWrap.h>
98 #include <WebCore/TextCheckerClient.h>
99 #include <WebCore/WindowFeatures.h>
101 #include <wtf/NeverDestroyed.h>
102 #include <wtf/text/StringView.h>
104 #if ENABLE(ASYNC_SCROLLING)
105 #include "RemoteScrollingCoordinatorProxy.h"
108 #if USE(COORDINATED_GRAPHICS)
109 #include "CoordinatedLayerTreeHostProxyMessages.h"
113 #include "ArgumentCodersGtk.h"
116 #if USE(SOUP) && !ENABLE(CUSTOM_PROTOCOLS)
117 #include "WebSoupRequestManagerProxy.h"
120 #if ENABLE(VIBRATION)
121 #include "WebVibrationProxy.h"
125 #include <wtf/RefCountedLeakCounter.h>
128 #if ENABLE(NETWORK_PROCESS)
129 #include "NetworkProcessMessages.h"
133 #include "ViewSnapshotStore.h"
134 #include <WebCore/RunLoopObserver.h>
138 #include "WebVideoFullscreenManagerProxy.h"
139 #include "WebVideoFullscreenManagerProxyMessages.h"
143 #include <WebCore/CairoUtilities.h>
146 // This controls what strategy we use for mouse wheel coalescing.
147 #define MERGE_WHEEL_EVENTS 1
149 #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_process->connection())
150 #define MESSAGE_CHECK_URL(url) MESSAGE_CHECK_BASE(m_process->checkURLReceivedFromWebProcess(url), m_process->connection())
152 using namespace WebCore;
154 // Represents the number of wheel events we can hold in the queue before we start pushing them preemptively.
155 static const unsigned wheelEventQueueSizeThreshold = 10;
159 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, webPageProxyCounter, ("WebPageProxy"));
161 class ExceededDatabaseQuotaRecords {
162 WTF_MAKE_NONCOPYABLE(ExceededDatabaseQuotaRecords); WTF_MAKE_FAST_ALLOCATED;
163 friend class NeverDestroyed<ExceededDatabaseQuotaRecords>;
167 String originIdentifier;
170 uint64_t currentQuota;
171 uint64_t currentOriginUsage;
172 uint64_t currentDatabaseUsage;
173 uint64_t expectedUsage;
174 RefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply> reply;
177 static ExceededDatabaseQuotaRecords& shared();
179 std::unique_ptr<Record> createRecord(uint64_t frameID, String originIdentifier,
180 String databaseName, String displayName, uint64_t currentQuota,
181 uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage,
182 PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply>);
184 void add(std::unique_ptr<Record>);
185 bool areBeingProcessed() const { return !!m_currentRecord; }
189 ExceededDatabaseQuotaRecords() { }
190 ~ExceededDatabaseQuotaRecords() { }
192 Deque<std::unique_ptr<Record>> m_records;
193 std::unique_ptr<Record> m_currentRecord;
196 ExceededDatabaseQuotaRecords& ExceededDatabaseQuotaRecords::shared()
198 static NeverDestroyed<ExceededDatabaseQuotaRecords> records;
202 std::unique_ptr<ExceededDatabaseQuotaRecords::Record> ExceededDatabaseQuotaRecords::createRecord(
203 uint64_t frameID, String originIdentifier, String databaseName, String displayName,
204 uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage,
205 uint64_t expectedUsage, PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply> reply)
207 auto record = std::make_unique<Record>();
208 record->frameID = frameID;
209 record->originIdentifier = originIdentifier;
210 record->databaseName = databaseName;
211 record->displayName = displayName;
212 record->currentQuota = currentQuota;
213 record->currentOriginUsage = currentOriginUsage;
214 record->currentDatabaseUsage = currentDatabaseUsage;
215 record->expectedUsage = expectedUsage;
216 record->reply = reply;
217 return WTF::move(record);
220 void ExceededDatabaseQuotaRecords::add(std::unique_ptr<ExceededDatabaseQuotaRecords::Record> record)
222 m_records.append(WTF::move(record));
225 ExceededDatabaseQuotaRecords::Record* ExceededDatabaseQuotaRecords::next()
227 m_currentRecord = nullptr;
228 if (!m_records.isEmpty())
229 m_currentRecord = m_records.takeFirst();
230 return m_currentRecord.get();
234 static const char* webKeyboardEventTypeString(WebEvent::Type type)
237 case WebEvent::KeyDown:
240 case WebEvent::KeyUp:
243 case WebEvent::RawKeyDown:
250 ASSERT_NOT_REACHED();
254 #endif // !LOG_DISABLED
256 PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient& pageClient, WebProcessProxy& process, uint64_t pageID, const WebPageConfiguration& configuration)
258 return adoptRef(new WebPageProxy(pageClient, process, pageID, configuration));
261 WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uint64_t pageID, const WebPageConfiguration& configuration)
262 : m_pageClient(pageClient)
263 , m_loaderClient(std::make_unique<API::LoaderClient>())
264 , m_policyClient(std::make_unique<API::PolicyClient>())
265 , m_formClient(std::make_unique<API::FormClient>())
266 , m_uiClient(std::make_unique<API::UIClient>())
267 , m_findClient(std::make_unique<API::FindClient>())
269 , m_pageGroup(*configuration.pageGroup)
270 , m_preferences(*configuration.preferences)
271 , m_userContentController(configuration.userContentController)
272 , m_visitedLinkProvider(*configuration.visitedLinkProvider)
273 , m_mainFrame(nullptr)
274 , m_userAgent(standardUserAgent())
276 , m_deviceOrientation(0)
277 , m_dynamicViewportSizeUpdateWaitingForTarget(false)
278 , m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit(false)
279 , m_dynamicViewportSizeUpdateLayerTreeTransactionID(0)
281 , m_geolocationPermissionRequestManager(*this)
282 , m_notificationPermissionRequestManager(*this)
283 , m_viewState(ViewState::NoFlags)
284 , m_viewWasEverInWindow(false)
285 , m_backForwardList(WebBackForwardList::create(*this))
286 , m_loadStateAtProcessExit(FrameLoadState::State::Finished)
287 #if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
288 , m_temporarilyClosedComposition(false)
290 , m_textZoomFactor(1)
291 , m_pageZoomFactor(1)
292 , m_pageScaleFactor(1)
293 , m_intrinsicDeviceScaleFactor(1)
294 , m_customDeviceScaleFactor(0)
295 , m_topContentInset(0)
296 , m_layerHostingMode(LayerHostingMode::InProcess)
297 , m_drawsBackground(true)
298 , m_drawsTransparentBackground(false)
299 , m_useFixedLayout(false)
300 , m_suppressScrollbarAnimations(false)
301 , m_paginationMode(Pagination::Unpaginated)
302 , m_paginationBehavesLikeColumns(false)
304 , m_gapBetweenPages(0)
307 , m_canRunModal(false)
308 , m_isInPrintingMode(false)
309 , m_isPerformingDOMPrintOperation(false)
310 , m_inDecidePolicyForResponseSync(false)
311 , m_decidePolicyForResponseRequest(0)
312 , m_syncMimeTypePolicyActionIsValid(false)
313 , m_syncMimeTypePolicyAction(PolicyUse)
314 , m_syncMimeTypePolicyDownloadID(0)
315 , m_inDecidePolicyForNavigationAction(false)
316 , m_syncNavigationActionPolicyActionIsValid(false)
317 , m_syncNavigationActionPolicyAction(PolicyUse)
318 , m_syncNavigationActionPolicyDownloadID(0)
319 , m_processingMouseMoveEvent(false)
320 #if ENABLE(TOUCH_EVENTS)
321 , m_isTrackingTouchEvents(false)
324 , m_session(*configuration.session)
325 , m_isPageSuspended(false)
326 , m_addsVisitedLinks(true)
327 #if ENABLE(REMOTE_INSPECTOR)
328 , m_allowsRemoteInspection(true)
331 , m_isSmartInsertDeleteEnabled(TextChecker::isSmartInsertDeleteEnabled())
333 , m_spellDocumentTag(0)
334 , m_hasSpellDocumentTag(false)
335 , m_pendingLearnOrIgnoreWordMessageCount(0)
336 , m_mainFrameHasCustomContentProvider(false)
337 #if ENABLE(DRAG_SUPPORT)
338 , m_currentDragOperation(DragOperationNone)
339 , m_currentDragIsOverFileInput(false)
340 , m_currentDragNumberOfFilesToBeAccepted(0)
342 , m_pageLoadState(*this)
343 , m_delegatesScrolling(false)
344 , m_mainFrameHasHorizontalScrollbar(false)
345 , m_mainFrameHasVerticalScrollbar(false)
346 , m_canShortCircuitHorizontalWheelEvents(true)
347 , m_mainFrameIsPinnedToLeftSide(true)
348 , m_mainFrameIsPinnedToRightSide(true)
349 , m_mainFrameIsPinnedToTopSide(true)
350 , m_mainFrameIsPinnedToBottomSide(true)
351 , m_shouldUseImplicitRubberBandControl(false)
352 , m_rubberBandsAtLeft(true)
353 , m_rubberBandsAtRight(true)
354 , m_rubberBandsAtTop(true)
355 , m_rubberBandsAtBottom(true)
356 , m_enableVerticalRubberBanding(true)
357 , m_enableHorizontalRubberBanding(true)
358 , m_backgroundExtendsBeyondPage(false)
359 , m_shouldRecordNavigationSnapshots(false)
360 , m_isShowingNavigationGestureSnapshot(false)
362 , m_renderTreeSize(0)
363 , m_shouldSendEventsSynchronously(false)
364 , m_suppressVisibilityUpdates(false)
365 , m_autoSizingShouldExpandToViewHeight(false)
367 , m_mayStartMediaWhenInWindow(true)
368 , m_scrollPinningBehavior(DoNotPin)
370 , m_configurationPreferenceValues(configuration.preferenceValues)
371 , m_potentiallyChangedViewStateFlags(ViewState::NoFlags)
372 , m_viewStateChangeWantsReply(false)
374 if (m_process->state() == WebProcessProxy::State::Running) {
375 if (m_userContentController)
376 m_userContentController->addProcess(m_process.get());
377 m_visitedLinkProvider->addProcess(m_process.get());
381 updateActivityToken();
383 #if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
384 m_layerHostingMode = m_viewState & ViewState::IsInWindow ? m_pageClient.viewLayerHostingMode() : LayerHostingMode::OutOfProcess;
387 platformInitialize();
390 webPageProxyCounter.increment();
393 WebContext::statistics().wkPageCount++;
395 m_preferences->addPage(*this);
396 m_pageGroup->addPage(this);
398 #if ENABLE(INSPECTOR)
399 m_inspector = WebInspectorProxy::create(this);
401 #if ENABLE(FULLSCREEN_API)
402 m_fullScreenManager = WebFullScreenManagerProxy::create(*this, m_pageClient.fullScreenManagerProxyClient());
405 m_videoFullscreenManager = WebVideoFullscreenManagerProxy::create(*this);
407 #if ENABLE(VIBRATION)
408 m_vibration = WebVibrationProxy::create(this);
411 m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
413 // FIXME: If we ever expose the session storage size as a preference, we need to pass it here.
414 IPC::Connection* connection = m_process->state() == WebProcessProxy::State::Running ? m_process->connection() : nullptr;
415 m_process->context().storageManager().createSessionStorageNamespace(m_pageID, connection, std::numeric_limits<unsigned>::max());
416 setSession(*configuration.session);
419 const CFIndex viewStateChangeRunLoopOrder = (CFIndex)RunLoopObserver::WellKnownRunLoopOrders::CoreAnimationCommit - 1;
420 m_viewStateChangeDispatcher = RunLoopObserver::create(viewStateChangeRunLoopOrder, [this]() {
421 this->dispatchViewStateChange();
426 WebPageProxy::~WebPageProxy()
431 WebContext::statistics().wkPageCount--;
433 if (m_hasSpellDocumentTag)
434 TextChecker::closeSpellDocumentWithTag(m_spellDocumentTag);
436 m_preferences->removePage(*this);
437 m_pageGroup->removePage(this);
440 webPageProxyCounter.decrement();
444 PlatformProcessIdentifier WebPageProxy::processIdentifier() const
449 return m_process->processIdentifier();
452 bool WebPageProxy::isValid() const
454 // A page that has been explicitly closed is never valid.
461 void WebPageProxy::setPreferences(WebPreferences& preferences)
463 if (&preferences == &m_preferences.get())
466 m_preferences->removePage(*this);
467 m_preferences = preferences;
468 m_preferences->addPage(*this);
470 preferencesDidChange();
473 void WebPageProxy::setLoaderClient(std::unique_ptr<API::LoaderClient> loaderClient)
476 m_loaderClient = std::make_unique<API::LoaderClient>();
480 m_loaderClient = WTF::move(loaderClient);
483 void WebPageProxy::setPolicyClient(std::unique_ptr<API::PolicyClient> policyClient)
486 m_policyClient = std::make_unique<API::PolicyClient>();
490 m_policyClient = WTF::move(policyClient);
493 void WebPageProxy::setFormClient(std::unique_ptr<API::FormClient> formClient)
496 m_formClient = std::make_unique<API::FormClient>();
500 m_formClient = WTF::move(formClient);
503 void WebPageProxy::setUIClient(std::unique_ptr<API::UIClient> uiClient)
506 m_uiClient = std::make_unique<API::UIClient>();
510 m_uiClient = WTF::move(uiClient);
515 m_process->send(Messages::WebPage::SetCanRunBeforeUnloadConfirmPanel(m_uiClient->canRunBeforeUnloadConfirmPanel()), m_pageID);
516 setCanRunModal(m_uiClient->canRunModal());
519 void WebPageProxy::setFindClient(std::unique_ptr<API::FindClient> findClient)
522 m_findClient = std::make_unique<API::FindClient>();
526 m_findClient = WTF::move(findClient);
529 void WebPageProxy::initializeFindMatchesClient(const WKPageFindMatchesClientBase* client)
531 m_findMatchesClient.initialize(client);
534 #if ENABLE(CONTEXT_MENUS)
535 void WebPageProxy::initializeContextMenuClient(const WKPageContextMenuClientBase* client)
537 m_contextMenuClient.initialize(client);
541 void WebPageProxy::reattachToWebProcess()
545 ASSERT(m_process->state() == WebProcessProxy::State::Terminated);
549 if (m_process->context().processModel() == ProcessModelSharedSecondaryProcess)
550 m_process = m_process->context().ensureSharedWebProcess();
552 m_process = m_process->context().createNewWebProcessRespectingProcessCountLimit();
553 m_process->addExistingWebPage(this, m_pageID);
554 m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
557 updateActivityToken();
559 #if ENABLE(INSPECTOR)
560 m_inspector = WebInspectorProxy::create(this);
562 #if ENABLE(FULLSCREEN_API)
563 m_fullScreenManager = WebFullScreenManagerProxy::create(*this, m_pageClient.fullScreenManagerProxyClient());
566 m_videoFullscreenManager = WebVideoFullscreenManagerProxy::create(*this);
571 m_pageClient.didRelaunchProcess();
572 m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
575 uint64_t WebPageProxy::reattachToWebProcessWithItem(WebBackForwardListItem* item)
580 if (item && item != m_backForwardList->currentItem())
581 m_backForwardList->goToItem(item);
583 reattachToWebProcess();
588 uint64_t navigationID = generateNavigationID();
590 m_process->send(Messages::WebPage::GoToBackForwardItem(navigationID, item->itemID()), m_pageID);
591 m_process->responsivenessTimer()->start();
596 void WebPageProxy::setSession(API::Session& session)
599 m_process->send(Messages::WebPage::SetSessionID(session.getID()), m_pageID);
601 #if ENABLE(NETWORK_PROCESS)
602 if (session.isEphemeral())
603 m_process->context().sendToNetworkingProcess(Messages::NetworkProcess::EnsurePrivateBrowsingSession(session.getID()));
607 void WebPageProxy::initializeWebPage()
611 BackForwardListItemVector items = m_backForwardList->entries();
612 for (size_t i = 0; i < items.size(); ++i)
613 m_process->registerNewWebBackForwardListItem(items[i].get());
615 m_drawingArea = m_pageClient.createDrawingAreaProxy();
616 ASSERT(m_drawingArea);
618 #if ENABLE(ASYNC_SCROLLING)
619 if (m_drawingArea->type() == DrawingAreaTypeRemoteLayerTree) {
620 m_scrollingCoordinatorProxy = std::make_unique<RemoteScrollingCoordinatorProxy>(*this);
622 // On iOS, main frame scrolls are sent in terms of visible rect updates.
623 m_scrollingCoordinatorProxy->setPropagatesMainFrameScrolls(false);
628 #if ENABLE(INSPECTOR_SERVER)
629 if (pageGroup().preferences().developerExtrasEnabled())
630 inspector()->enableRemoteInspection();
633 process().send(Messages::WebProcess::CreateWebPage(m_pageID, creationParameters()), 0);
636 send(Messages::WebPage::SetSmartInsertDeleteEnabled(m_isSmartInsertDeleteEnabled));
640 bool WebPageProxy::isProcessSuppressible() const
642 return (m_viewState & ViewState::IsVisuallyIdle) && m_preferences->pageVisibilityBasedProcessSuppressionEnabled();
645 void WebPageProxy::close()
652 if (m_process->state() == WebProcessProxy::State::Running) {
653 if (m_userContentController)
654 m_userContentController->removeProcess(m_process.get());
655 m_visitedLinkProvider->removeProcess(m_process.get());
658 m_backForwardList->pageClosed();
659 m_pageClient.pageClosed();
661 m_process->disconnectFramesFromPage(this);
663 resetState(ResetStateReason::PageInvalidated);
665 m_loaderClient = std::make_unique<API::LoaderClient>();
666 m_policyClient = std::make_unique<API::PolicyClient>();
667 m_formClient = std::make_unique<API::FormClient>();
668 m_uiClient = std::make_unique<API::UIClient>();
670 m_uiPopupMenuClient.initialize(0);
672 m_findClient = std::make_unique<API::FindClient>();
673 m_findMatchesClient.initialize(0);
674 #if ENABLE(CONTEXT_MENUS)
675 m_contextMenuClient.initialize(0);
678 m_process->send(Messages::WebPage::Close(), m_pageID);
679 m_process->removeWebPage(m_pageID);
680 m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID);
681 m_process->context().storageManager().destroySessionStorageNamespace(m_pageID);
682 m_process->context().supplement<WebNotificationManagerProxy>()->clearNotifications(this);
685 bool WebPageProxy::tryClose()
690 m_process->send(Messages::WebPage::TryClose(), m_pageID);
691 m_process->responsivenessTimer()->start();
695 bool WebPageProxy::maybeInitializeSandboxExtensionHandle(const URL& url, SandboxExtension::Handle& sandboxExtensionHandle)
697 if (!url.isLocalFile())
700 if (m_process->hasAssumedReadAccessToURL(url))
703 #if ENABLE(INSPECTOR)
704 // Inspector resources are in a directory with assumed access.
705 ASSERT_WITH_SECURITY_IMPLICATION(!WebInspectorProxy::isInspectorPage(*this));
708 SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, sandboxExtensionHandle);
712 uint64_t WebPageProxy::loadRequest(const ResourceRequest& request, API::Object* userData)
717 uint64_t navigationID = generateNavigationID();
719 auto transaction = m_pageLoadState.transaction();
721 m_pageLoadState.setPendingAPIRequestURL(transaction, request.url());
724 reattachToWebProcess();
726 SandboxExtension::Handle sandboxExtensionHandle;
727 bool createdExtension = maybeInitializeSandboxExtensionHandle(request.url(), sandboxExtensionHandle);
728 if (createdExtension)
729 m_process->willAcquireUniversalFileReadSandboxExtension();
730 m_process->send(Messages::WebPage::LoadRequest(navigationID, request, sandboxExtensionHandle, WebContextUserMessageEncoder(userData, process())), m_pageID);
731 m_process->responsivenessTimer()->start();
736 void WebPageProxy::loadFile(const String& fileURLString, const String& resourceDirectoryURLString, API::Object* userData)
742 reattachToWebProcess();
744 URL fileURL = URL(URL(), fileURLString);
745 if (!fileURL.isLocalFile())
748 URL resourceDirectoryURL;
749 if (resourceDirectoryURLString.isNull())
750 resourceDirectoryURL = URL(ParsedURLString, ASCIILiteral("file:///"));
752 resourceDirectoryURL = URL(URL(), resourceDirectoryURLString);
753 if (!resourceDirectoryURL.isLocalFile())
757 String resourceDirectoryPath = resourceDirectoryURL.fileSystemPath();
759 SandboxExtension::Handle sandboxExtensionHandle;
760 SandboxExtension::createHandle(resourceDirectoryPath, SandboxExtension::ReadOnly, sandboxExtensionHandle);
761 m_process->assumeReadAccessToBaseURL(resourceDirectoryURL);
762 m_process->send(Messages::WebPage::LoadRequest(generateNavigationID(), fileURL, sandboxExtensionHandle, WebContextUserMessageEncoder(userData, process())), m_pageID);
763 m_process->responsivenessTimer()->start();
766 void WebPageProxy::loadData(API::Data* data, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData)
772 reattachToWebProcess();
774 m_process->assumeReadAccessToBaseURL(baseURL);
775 m_process->send(Messages::WebPage::LoadData(data->dataReference(), MIMEType, encoding, baseURL, WebContextUserMessageEncoder(userData, process())), m_pageID);
776 m_process->responsivenessTimer()->start();
779 uint64_t WebPageProxy::loadHTMLString(const String& htmlString, const String& baseURL, API::Object* userData)
784 uint64_t navigationID = generateNavigationID();
786 auto transaction = m_pageLoadState.transaction();
788 String pendingAPIRequestURL = baseURL.isEmpty() ? baseURL : ASCIILiteral("about:blank");
789 m_pageLoadState.setPendingAPIRequestURL(transaction, pendingAPIRequestURL);
792 reattachToWebProcess();
794 m_process->assumeReadAccessToBaseURL(baseURL);
795 m_process->send(Messages::WebPage::LoadHTMLString(navigationID, htmlString, baseURL, WebContextUserMessageEncoder(userData, process())), m_pageID);
796 m_process->responsivenessTimer()->start();
801 void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, API::Object* userData)
807 reattachToWebProcess();
809 auto transaction = m_pageLoadState.transaction();
811 m_pageLoadState.setUnreachableURL(transaction, unreachableURL);
814 m_mainFrame->setUnreachableURL(unreachableURL);
816 m_process->assumeReadAccessToBaseURL(baseURL);
817 m_process->send(Messages::WebPage::LoadAlternateHTMLString(htmlString, baseURL, unreachableURL, WebContextUserMessageEncoder(userData, process())), m_pageID);
818 m_process->responsivenessTimer()->start();
821 void WebPageProxy::loadPlainTextString(const String& string, API::Object* userData)
827 reattachToWebProcess();
829 m_process->send(Messages::WebPage::LoadPlainTextString(string, WebContextUserMessageEncoder(userData, process())), m_pageID);
830 m_process->responsivenessTimer()->start();
833 void WebPageProxy::loadWebArchiveData(API::Data* webArchiveData, API::Object* userData)
839 reattachToWebProcess();
841 m_process->send(Messages::WebPage::LoadWebArchiveData(webArchiveData->dataReference(), WebContextUserMessageEncoder(userData, process())), m_pageID);
842 m_process->responsivenessTimer()->start();
845 void WebPageProxy::stopLoading()
850 m_process->send(Messages::WebPage::StopLoading(), m_pageID);
851 m_process->responsivenessTimer()->start();
854 uint64_t WebPageProxy::reload(bool reloadFromOrigin)
856 SandboxExtension::Handle sandboxExtensionHandle;
858 if (m_backForwardList->currentItem()) {
859 String url = m_backForwardList->currentItem()->url();
860 auto transaction = m_pageLoadState.transaction();
861 m_pageLoadState.setPendingAPIRequestURL(transaction, url);
863 // We may not have an extension yet if back/forward list was reinstated after a WebProcess crash or a browser relaunch
864 bool createdExtension = maybeInitializeSandboxExtensionHandle(URL(URL(), url), sandboxExtensionHandle);
865 if (createdExtension)
866 m_process->willAcquireUniversalFileReadSandboxExtension();
870 return reattachToWebProcessWithItem(m_backForwardList->currentItem());
872 uint64_t navigationID = generateNavigationID();
874 m_process->send(Messages::WebPage::Reload(navigationID, reloadFromOrigin, sandboxExtensionHandle), m_pageID);
875 m_process->responsivenessTimer()->start();
880 void WebPageProxy::recordNavigationSnapshot()
882 if (!m_shouldRecordNavigationSnapshots)
886 ViewSnapshotStore::shared().recordSnapshot(*this);
890 uint64_t WebPageProxy::goForward()
892 WebBackForwardListItem* forwardItem = m_backForwardList->forwardItem();
896 auto transaction = m_pageLoadState.transaction();
898 m_pageLoadState.setPendingAPIRequestURL(transaction, forwardItem->url());
901 return reattachToWebProcessWithItem(forwardItem);
903 uint64_t navigationID = m_backForwardList->currentItem()->itemIsInSameDocument(*forwardItem) ? 0 : generateNavigationID();
905 m_process->send(Messages::WebPage::GoForward(navigationID, forwardItem->itemID()), m_pageID);
906 m_process->responsivenessTimer()->start();
911 uint64_t WebPageProxy::goBack()
913 WebBackForwardListItem* backItem = m_backForwardList->backItem();
917 auto transaction = m_pageLoadState.transaction();
919 m_pageLoadState.setPendingAPIRequestURL(transaction, backItem->url());
922 return reattachToWebProcessWithItem(backItem);
924 uint64_t navigationID = m_backForwardList->currentItem()->itemIsInSameDocument(*backItem) ? 0 : generateNavigationID();
926 m_process->send(Messages::WebPage::GoBack(navigationID, backItem->itemID()), m_pageID);
927 m_process->responsivenessTimer()->start();
932 uint64_t WebPageProxy::goToBackForwardItem(WebBackForwardListItem* item)
935 return reattachToWebProcessWithItem(item);
937 auto transaction = m_pageLoadState.transaction();
939 m_pageLoadState.setPendingAPIRequestURL(transaction, item->url());
941 uint64_t navigationID = m_backForwardList->currentItem()->itemIsInSameDocument(*item) ? 0 : generateNavigationID();
943 m_process->send(Messages::WebPage::GoToBackForwardItem(navigationID, item->itemID()), m_pageID);
944 m_process->responsivenessTimer()->start();
949 void WebPageProxy::tryRestoreScrollPosition()
954 m_process->send(Messages::WebPage::TryRestoreScrollPosition(), m_pageID);
957 void WebPageProxy::didChangeBackForwardList(WebBackForwardListItem* added, Vector<RefPtr<WebBackForwardListItem>> removed)
959 m_loaderClient->didChangeBackForwardList(this, added, WTF::move(removed));
961 auto transaction = m_pageLoadState.transaction();
963 m_pageLoadState.setCanGoBack(transaction, m_backForwardList->backItem());
964 m_pageLoadState.setCanGoForward(transaction, m_backForwardList->forwardItem());
967 void WebPageProxy::willGoToBackForwardListItem(uint64_t itemID, IPC::MessageDecoder& decoder)
969 RefPtr<API::Object> userData;
970 WebContextUserMessageDecoder messageDecoder(userData, process());
971 if (!decoder.decode(messageDecoder))
974 if (WebBackForwardListItem* item = m_process->webBackForwardItem(itemID))
975 m_loaderClient->willGoToBackForwardListItem(this, item, userData.get());
978 bool WebPageProxy::shouldKeepCurrentBackForwardListItemInList(WebBackForwardListItem* item)
980 return m_loaderClient->shouldKeepCurrentBackForwardListItemInList(this, item);
983 bool WebPageProxy::canShowMIMEType(const String& mimeType)
985 if (MIMETypeRegistry::canShowMIMEType(mimeType))
988 #if ENABLE(NETSCAPE_PLUGIN_API)
989 String newMimeType = mimeType;
990 PluginModuleInfo plugin = m_process->context().pluginInfoStore().findPlugin(newMimeType, URL());
991 if (!plugin.path.isNull() && m_preferences->pluginsEnabled())
993 #endif // ENABLE(NETSCAPE_PLUGIN_API)
996 // On Mac, we can show PDFs.
997 if (MIMETypeRegistry::isPDFOrPostScriptMIMEType(mimeType) && !WebContext::omitPDFSupport())
999 #endif // PLATFORM(COCOA)
1004 #if ENABLE(REMOTE_INSPECTOR)
1005 void WebPageProxy::setAllowsRemoteInspection(bool allow)
1007 if (m_allowsRemoteInspection == allow)
1010 m_allowsRemoteInspection = allow;
1013 m_process->send(Messages::WebPage::SetAllowsRemoteInspection(allow), m_pageID);
1017 void WebPageProxy::setDrawsBackground(bool drawsBackground)
1019 if (m_drawsBackground == drawsBackground)
1022 m_drawsBackground = drawsBackground;
1025 m_process->send(Messages::WebPage::SetDrawsBackground(drawsBackground), m_pageID);
1028 void WebPageProxy::setDrawsTransparentBackground(bool drawsTransparentBackground)
1030 if (m_drawsTransparentBackground == drawsTransparentBackground)
1033 m_drawsTransparentBackground = drawsTransparentBackground;
1036 m_process->send(Messages::WebPage::SetDrawsTransparentBackground(drawsTransparentBackground), m_pageID);
1039 void WebPageProxy::setTopContentInset(float contentInset)
1041 if (m_topContentInset == contentInset)
1044 m_topContentInset = contentInset;
1047 m_process->send(Messages::WebPage::SetTopContentInset(contentInset), m_pageID);
1050 void WebPageProxy::setUnderlayColor(const Color& color)
1052 if (m_underlayColor == color)
1055 m_underlayColor = color;
1058 m_process->send(Messages::WebPage::SetUnderlayColor(color), m_pageID);
1061 void WebPageProxy::viewWillStartLiveResize()
1065 #if ENABLE(INPUT_TYPE_COLOR_POPOVER)
1069 m_process->send(Messages::WebPage::ViewWillStartLiveResize(), m_pageID);
1072 void WebPageProxy::viewWillEndLiveResize()
1076 m_process->send(Messages::WebPage::ViewWillEndLiveResize(), m_pageID);
1079 void WebPageProxy::setViewNeedsDisplay(const IntRect& rect)
1081 m_pageClient.setViewNeedsDisplay(rect);
1084 void WebPageProxy::displayView()
1086 m_pageClient.displayView();
1089 bool WebPageProxy::canScrollView()
1091 return m_pageClient.canScrollView();
1094 void WebPageProxy::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
1096 m_pageClient.scrollView(scrollRect, scrollOffset);
1099 void WebPageProxy::requestScroll(const FloatPoint& scrollPosition, bool isProgrammaticScroll)
1101 m_pageClient.requestScroll(scrollPosition, isProgrammaticScroll);
1104 void WebPageProxy::updateViewState(ViewState::Flags flagsToUpdate)
1106 m_viewState &= ~flagsToUpdate;
1107 if (flagsToUpdate & ViewState::IsFocused && m_pageClient.isViewFocused())
1108 m_viewState |= ViewState::IsFocused;
1109 if (flagsToUpdate & ViewState::WindowIsActive && m_pageClient.isViewWindowActive())
1110 m_viewState |= ViewState::WindowIsActive;
1111 if (flagsToUpdate & ViewState::IsVisible && m_pageClient.isViewVisible())
1112 m_viewState |= ViewState::IsVisible;
1113 if (flagsToUpdate & ViewState::IsVisibleOrOccluded && m_pageClient.isViewVisibleOrOccluded())
1114 m_viewState |= ViewState::IsVisibleOrOccluded;
1115 if (flagsToUpdate & ViewState::IsInWindow && m_pageClient.isViewInWindow()) {
1116 m_viewState |= ViewState::IsInWindow;
1117 m_viewWasEverInWindow = true;
1119 if (flagsToUpdate & ViewState::IsVisuallyIdle && m_pageClient.isVisuallyIdle())
1120 m_viewState |= ViewState::IsVisuallyIdle;
1123 void WebPageProxy::viewStateDidChange(ViewState::Flags mayHaveChanged, bool wantsReply, ViewStateChangeDispatchMode dispatchMode)
1125 m_potentiallyChangedViewStateFlags |= mayHaveChanged;
1126 m_viewStateChangeWantsReply = m_viewStateChangeWantsReply || wantsReply;
1129 bool isNewlyInWindow = !isInWindow() && (mayHaveChanged & ViewState::IsInWindow) && m_pageClient.isViewInWindow();
1130 if (dispatchMode == ViewStateChangeDispatchMode::Immediate || isNewlyInWindow) {
1131 dispatchViewStateChange();
1134 m_viewStateChangeDispatcher->schedule();
1136 UNUSED_PARAM(dispatchMode);
1137 dispatchViewStateChange();
1141 void WebPageProxy::viewDidLeaveWindow()
1143 #if ENABLE(INPUT_TYPE_COLOR_POPOVER)
1144 // When leaving the current page, close the popover color well.
1149 // When leaving the current page, close the video fullscreen.
1150 if (m_videoFullscreenManager)
1151 m_videoFullscreenManager->requestHideAndExitFullscreen();
1155 void WebPageProxy::viewDidEnterWindow()
1157 LayerHostingMode layerHostingMode = m_pageClient.viewLayerHostingMode();
1158 if (m_layerHostingMode != layerHostingMode) {
1159 m_layerHostingMode = layerHostingMode;
1160 m_process->send(Messages::WebPage::SetLayerHostingMode(static_cast<unsigned>(layerHostingMode)), m_pageID);
1164 void WebPageProxy::dispatchViewStateChange()
1167 m_viewStateChangeDispatcher->invalidate();
1173 // If the visibility state may have changed, then so may the visually idle & occluded agnostic state.
1174 if (m_potentiallyChangedViewStateFlags & ViewState::IsVisible)
1175 m_potentiallyChangedViewStateFlags |= ViewState::IsVisibleOrOccluded | ViewState::IsVisuallyIdle;
1177 // Record the prior view state, update the flags that may have changed,
1178 // and check which flags have actually changed.
1179 ViewState::Flags previousViewState = m_viewState;
1180 updateViewState(m_potentiallyChangedViewStateFlags);
1181 ViewState::Flags changed = m_viewState ^ previousViewState;
1183 // We always want to wait for the Web process to reply if we've been in-window before and are coming back in-window.
1184 if (m_viewWasEverInWindow && (changed & ViewState::IsInWindow) && isInWindow())
1185 m_viewStateChangeWantsReply = true;
1187 if (changed || m_viewStateChangeWantsReply)
1188 m_process->send(Messages::WebPage::SetViewState(m_viewState, m_viewStateChangeWantsReply), m_pageID);
1190 // This must happen after the SetViewState message is sent, to ensure the page visibility event can fire.
1191 updateActivityToken();
1193 if (changed & ViewState::IsVisuallyIdle)
1194 m_process->pageSuppressibilityChanged(this);
1196 // If we've started the responsiveness timer as part of telling the web process to update the backing store
1197 // state, it might not send back a reply (since it won't paint anything if the web page is hidden) so we
1198 // stop the unresponsiveness timer here.
1199 if ((changed & ViewState::IsVisible) && !isViewVisible())
1200 m_process->responsivenessTimer()->stop();
1202 if (changed & ViewState::IsInWindow) {
1204 viewDidEnterWindow();
1206 viewDidLeaveWindow();
1209 updateBackingStoreDiscardableState();
1211 if (m_viewStateChangeWantsReply)
1212 waitForDidUpdateViewState();
1214 m_potentiallyChangedViewStateFlags = ViewState::NoFlags;
1215 m_viewStateChangeWantsReply = false;
1218 void WebPageProxy::updateActivityToken()
1221 if (!isViewVisible())
1222 m_activityToken = nullptr;
1223 else if (!m_activityToken)
1224 m_activityToken = std::make_unique<ProcessThrottler::ForegroundActivityToken>(m_process->throttler());
1228 void WebPageProxy::layerHostingModeDidChange()
1233 LayerHostingMode layerHostingMode = m_pageClient.viewLayerHostingMode();
1234 if (m_layerHostingMode == layerHostingMode)
1237 m_layerHostingMode = layerHostingMode;
1238 m_process->send(Messages::WebPage::SetLayerHostingMode(static_cast<unsigned>(layerHostingMode)), m_pageID);
1241 void WebPageProxy::waitForDidUpdateViewState()
1246 if (m_process->state() != WebProcessProxy::State::Running)
1249 // If we have previously timed out with no response from the WebProcess, don't block the UIProcess again until it starts responding.
1250 if (m_waitingForDidUpdateViewState)
1253 m_waitingForDidUpdateViewState = true;
1255 m_drawingArea->waitForDidUpdateViewState();
1258 IntSize WebPageProxy::viewSize() const
1260 return m_pageClient.viewSize();
1263 void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent)
1267 m_process->send(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent), m_pageID);
1270 void WebPageProxy::setWindowResizerSize(const IntSize& windowResizerSize)
1274 m_process->send(Messages::WebPage::SetWindowResizerSize(windowResizerSize), m_pageID);
1277 void WebPageProxy::clearSelection()
1281 m_process->send(Messages::WebPage::ClearSelection(), m_pageID);
1284 void WebPageProxy::validateCommand(const String& commandName, std::function<void (const String&, bool, int32_t, CallbackBase::Error)> callbackFunction)
1287 callbackFunction(String(), false, 0, CallbackBase::Error::Unknown);
1291 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
1292 m_process->send(Messages::WebPage::ValidateCommand(commandName, callbackID), m_pageID);
1295 void WebPageProxy::setMaintainsInactiveSelection(bool newValue)
1297 m_maintainsInactiveSelection = newValue;
1300 void WebPageProxy::executeEditCommand(const String& commandName)
1302 static NeverDestroyed<String> ignoreSpellingCommandName(ASCIILiteral("ignoreSpelling"));
1307 if (commandName == ignoreSpellingCommandName)
1308 ++m_pendingLearnOrIgnoreWordMessageCount;
1310 m_process->send(Messages::WebPage::ExecuteEditCommand(commandName), m_pageID);
1314 void WebPageProxy::didCommitLayerTree(const RemoteLayerTreeTransaction&)
1319 #if USE(TILED_BACKING_STORE)
1320 void WebPageProxy::commitPageTransitionViewport()
1325 process().send(Messages::WebPage::CommitPageTransitionViewport(), m_pageID);
1329 #if ENABLE(DRAG_SUPPORT)
1330 void WebPageProxy::dragEntered(DragData& dragData, const String& dragStorageName)
1332 SandboxExtension::Handle sandboxExtensionHandle;
1333 SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
1334 performDragControllerAction(DragControllerActionEntered, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
1337 void WebPageProxy::dragUpdated(DragData& dragData, const String& dragStorageName)
1339 SandboxExtension::Handle sandboxExtensionHandle;
1340 SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
1341 performDragControllerAction(DragControllerActionUpdated, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
1344 void WebPageProxy::dragExited(DragData& dragData, const String& dragStorageName)
1346 SandboxExtension::Handle sandboxExtensionHandle;
1347 SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
1348 performDragControllerAction(DragControllerActionExited, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
1351 void WebPageProxy::performDragOperation(DragData& dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
1353 performDragControllerAction(DragControllerActionPerformDragOperation, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionsForUpload);
1356 void WebPageProxy::performDragControllerAction(DragControllerAction action, DragData& dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
1361 UNUSED_PARAM(dragStorageName);
1362 UNUSED_PARAM(sandboxExtensionHandle);
1363 UNUSED_PARAM(sandboxExtensionsForUpload);
1364 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData), m_pageID);
1366 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData.clientPosition(), dragData.globalPosition(), dragData.draggingSourceOperationMask(), dragStorageName, dragData.flags(), sandboxExtensionHandle, sandboxExtensionsForUpload), m_pageID);
1370 void WebPageProxy::didPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted)
1372 MESSAGE_CHECK(dragOperation <= DragOperationDelete);
1374 m_currentDragOperation = static_cast<DragOperation>(dragOperation);
1375 m_currentDragIsOverFileInput = mouseIsOverFileInput;
1376 m_currentDragNumberOfFilesToBeAccepted = numberOfItemsToBeAccepted;
1380 void WebPageProxy::startDrag(const DragData& dragData, const ShareableBitmap::Handle& dragImageHandle)
1382 RefPtr<ShareableBitmap> dragImage = 0;
1383 if (!dragImageHandle.isNull()) {
1384 dragImage = ShareableBitmap::create(dragImageHandle);
1389 m_pageClient.startDrag(dragData, dragImage.release());
1393 void WebPageProxy::dragEnded(const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t operation)
1397 m_process->send(Messages::WebPage::DragEnded(clientPosition, globalPosition, operation), m_pageID);
1399 #endif // ENABLE(DRAG_SUPPORT)
1401 void WebPageProxy::handleMouseEvent(const NativeWebMouseEvent& event)
1406 // NOTE: This does not start the responsiveness timer because mouse move should not indicate interaction.
1407 if (event.type() != WebEvent::MouseMove)
1408 m_process->responsivenessTimer()->start();
1410 if (m_processingMouseMoveEvent) {
1411 m_nextMouseMoveEvent = std::make_unique<NativeWebMouseEvent>(event);
1415 m_processingMouseMoveEvent = true;
1418 // <https://bugs.webkit.org/show_bug.cgi?id=57904> We need to keep track of the mouse down event in the case where we
1419 // display a popup menu for select elements. When the user changes the selected item,
1420 // we fake a mouse up event by using this stored down event. This event gets cleared
1421 // when the mouse up message is received from WebProcess.
1422 if (event.type() == WebEvent::MouseDown)
1423 m_currentlyProcessedMouseDownEvent = std::make_unique<NativeWebMouseEvent>(event);
1425 if (m_shouldSendEventsSynchronously) {
1426 bool handled = false;
1427 m_process->sendSync(Messages::WebPage::MouseEventSyncForTesting(event), Messages::WebPage::MouseEventSyncForTesting::Reply(handled), m_pageID);
1428 didReceiveEvent(event.type(), handled);
1430 m_process->send(Messages::WebPage::MouseEvent(event), m_pageID);
1433 #if MERGE_WHEEL_EVENTS
1434 static bool canCoalesce(const WebWheelEvent& a, const WebWheelEvent& b)
1436 if (a.position() != b.position())
1438 if (a.globalPosition() != b.globalPosition())
1440 if (a.modifiers() != b.modifiers())
1442 if (a.granularity() != b.granularity())
1445 if (a.phase() != b.phase())
1447 if (a.momentumPhase() != b.momentumPhase())
1449 if (a.hasPreciseScrollingDeltas() != b.hasPreciseScrollingDeltas())
1456 static WebWheelEvent coalesce(const WebWheelEvent& a, const WebWheelEvent& b)
1458 ASSERT(canCoalesce(a, b));
1460 FloatSize mergedDelta = a.delta() + b.delta();
1461 FloatSize mergedWheelTicks = a.wheelTicks() + b.wheelTicks();
1464 FloatSize mergedUnacceleratedScrollingDelta = a.unacceleratedScrollingDelta() + b.unacceleratedScrollingDelta();
1466 return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.directionInvertedFromDevice(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.scrollCount(), mergedUnacceleratedScrollingDelta, b.modifiers(), b.timestamp());
1468 return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.modifiers(), b.timestamp());
1471 #endif // MERGE_WHEEL_EVENTS
1473 static WebWheelEvent coalescedWheelEvent(Deque<NativeWebWheelEvent>& queue, Vector<NativeWebWheelEvent>& coalescedEvents)
1475 ASSERT(!queue.isEmpty());
1476 ASSERT(coalescedEvents.isEmpty());
1478 #if MERGE_WHEEL_EVENTS
1479 NativeWebWheelEvent firstEvent = queue.takeFirst();
1480 coalescedEvents.append(firstEvent);
1482 WebWheelEvent event = firstEvent;
1483 while (!queue.isEmpty() && canCoalesce(event, queue.first())) {
1484 NativeWebWheelEvent firstEvent = queue.takeFirst();
1485 coalescedEvents.append(firstEvent);
1486 event = coalesce(event, firstEvent);
1491 while (!queue.isEmpty())
1492 coalescedEvents.append(queue.takeFirst());
1493 return coalescedEvents.last();
1497 void WebPageProxy::handleWheelEvent(const NativeWebWheelEvent& event)
1499 #if ENABLE(ASYNC_SCROLLING)
1500 if (m_scrollingCoordinatorProxy && m_scrollingCoordinatorProxy->handleWheelEvent(platform(event)))
1507 if (!m_currentlyProcessedWheelEvents.isEmpty()) {
1508 m_wheelEventQueue.append(event);
1509 if (m_wheelEventQueue.size() < wheelEventQueueSizeThreshold)
1511 // The queue has too many wheel events, so push a new event.
1514 if (!m_wheelEventQueue.isEmpty()) {
1515 processNextQueuedWheelEvent();
1519 auto coalescedWheelEvent = std::make_unique<Vector<NativeWebWheelEvent>>();
1520 coalescedWheelEvent->append(event);
1521 m_currentlyProcessedWheelEvents.append(WTF::move(coalescedWheelEvent));
1522 sendWheelEvent(event);
1525 void WebPageProxy::processNextQueuedWheelEvent()
1527 auto nextCoalescedEvent = std::make_unique<Vector<NativeWebWheelEvent>>();
1528 WebWheelEvent nextWheelEvent = coalescedWheelEvent(m_wheelEventQueue, *nextCoalescedEvent.get());
1529 m_currentlyProcessedWheelEvents.append(WTF::move(nextCoalescedEvent));
1530 sendWheelEvent(nextWheelEvent);
1533 void WebPageProxy::sendWheelEvent(const WebWheelEvent& event)
1535 m_process->responsivenessTimer()->start();
1537 if (m_shouldSendEventsSynchronously) {
1538 bool handled = false;
1539 m_process->sendSync(Messages::WebPage::WheelEventSyncForTesting(event), Messages::WebPage::WheelEventSyncForTesting::Reply(handled), m_pageID);
1540 didReceiveEvent(event.type(), handled);
1545 Messages::EventDispatcher::WheelEvent(
1548 shouldUseImplicitRubberBandControl() ? !m_backForwardList->backItem() : rubberBandsAtLeft(),
1549 shouldUseImplicitRubberBandControl() ? !m_backForwardList->forwardItem() : rubberBandsAtRight(),
1551 rubberBandsAtBottom()
1555 void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
1560 LOG(KeyHandling, "WebPageProxy::handleKeyboardEvent: %s", webKeyboardEventTypeString(event.type()));
1562 m_keyEventQueue.append(event);
1564 m_process->responsivenessTimer()->start();
1565 if (m_shouldSendEventsSynchronously) {
1566 bool handled = false;
1567 m_process->sendSync(Messages::WebPage::KeyEventSyncForTesting(event), Messages::WebPage::KeyEventSyncForTesting::Reply(handled), m_pageID);
1568 didReceiveEvent(event.type(), handled);
1569 } else if (m_keyEventQueue.size() == 1) // Otherwise, sent from DidReceiveEvent message handler.
1570 m_process->send(Messages::WebPage::KeyEvent(event), m_pageID);
1573 uint64_t WebPageProxy::generateNavigationID()
1575 return ++m_navigationID;
1578 WebPreferencesStore WebPageProxy::preferencesStore() const
1580 if (m_configurationPreferenceValues.isEmpty())
1581 return m_preferences->store();
1583 WebPreferencesStore store = m_preferences->store();
1584 for (const auto& preference : m_configurationPreferenceValues)
1585 store.m_values.set(preference.key, preference.value);
1590 #if ENABLE(NETSCAPE_PLUGIN_API)
1591 void WebPageProxy::findPlugin(const String& mimeType, uint32_t processType, const String& urlString, const String& frameURLString, const String& pageURLString, bool allowOnlyApplicationPlugins, uint64_t& pluginProcessToken, String& newMimeType, uint32_t& pluginLoadPolicy, String& unavailabilityDescription)
1593 MESSAGE_CHECK_URL(urlString);
1595 newMimeType = mimeType.lower();
1596 pluginLoadPolicy = PluginModuleLoadNormally;
1598 PluginData::AllowedPluginTypes allowedPluginTypes = allowOnlyApplicationPlugins ? PluginData::OnlyApplicationPlugins : PluginData::AllPlugins;
1599 PluginModuleInfo plugin = m_process->context().pluginInfoStore().findPlugin(newMimeType, URL(URL(), urlString), allowedPluginTypes);
1601 pluginProcessToken = 0;
1605 pluginLoadPolicy = PluginInfoStore::defaultLoadPolicyForPlugin(plugin);
1608 RefPtr<ImmutableDictionary> pluginInformation = createPluginInformationDictionary(plugin, frameURLString, String(), pageURLString, String(), String());
1609 pluginLoadPolicy = m_loaderClient->pluginLoadPolicy(this, static_cast<PluginModuleLoadPolicy>(pluginLoadPolicy), pluginInformation.get(), unavailabilityDescription);
1611 UNUSED_PARAM(frameURLString);
1612 UNUSED_PARAM(pageURLString);
1613 UNUSED_PARAM(unavailabilityDescription);
1616 PluginProcessSandboxPolicy pluginProcessSandboxPolicy = PluginProcessSandboxPolicyNormal;
1617 switch (pluginLoadPolicy) {
1618 case PluginModuleLoadNormally:
1619 pluginProcessSandboxPolicy = PluginProcessSandboxPolicyNormal;
1621 case PluginModuleLoadUnsandboxed:
1622 pluginProcessSandboxPolicy = PluginProcessSandboxPolicyUnsandboxed;
1625 case PluginModuleBlocked:
1626 pluginProcessToken = 0;
1630 pluginProcessToken = PluginProcessManager::shared().pluginProcessToken(plugin, static_cast<PluginProcessType>(processType), pluginProcessSandboxPolicy);
1633 #endif // ENABLE(NETSCAPE_PLUGIN_API)
1635 #if ENABLE(TOUCH_EVENTS)
1637 bool WebPageProxy::shouldStartTrackingTouchEvents(const WebTouchEvent& touchStartEvent) const
1639 #if ENABLE(ASYNC_SCROLLING)
1640 for (auto& touchPoint : touchStartEvent.touchPoints()) {
1641 if (m_scrollingCoordinatorProxy->isPointInNonFastScrollableRegion(touchPoint.location()))
1647 UNUSED_PARAM(touchStartEvent);
1648 #endif // ENABLE(ASYNC_SCROLLING)
1654 #if ENABLE(IOS_TOUCH_EVENTS)
1655 void WebPageProxy::handleTouchEventSynchronously(const NativeWebTouchEvent& event)
1660 if (event.type() == WebEvent::TouchStart)
1661 m_isTrackingTouchEvents = shouldStartTrackingTouchEvents(event);
1663 if (!m_isTrackingTouchEvents)
1666 m_process->responsivenessTimer()->start();
1667 bool handled = false;
1668 m_process->sendSync(Messages::WebPage::TouchEventSync(event), Messages::WebPage::TouchEventSync::Reply(handled), m_pageID);
1669 didReceiveEvent(event.type(), handled);
1670 m_pageClient.doneWithTouchEvent(event, handled);
1671 m_process->responsivenessTimer()->stop();
1673 if (event.allTouchPointsAreReleased())
1674 m_isTrackingTouchEvents = false;
1677 void WebPageProxy::handleTouchEventAsynchronously(const NativeWebTouchEvent& event)
1682 if (!m_isTrackingTouchEvents)
1685 m_process->send(Messages::EventDispatcher::TouchEvent(m_pageID, event), 0);
1687 if (event.allTouchPointsAreReleased())
1688 m_isTrackingTouchEvents = false;
1691 #elif ENABLE(TOUCH_EVENTS)
1692 void WebPageProxy::handleTouchEvent(const NativeWebTouchEvent& event)
1697 if (event.type() == WebEvent::TouchStart)
1698 m_isTrackingTouchEvents = shouldStartTrackingTouchEvents(event);
1700 if (!m_isTrackingTouchEvents)
1703 // If the page is suspended, which should be the case during panning, pinching
1704 // and animation on the page itself (kinetic scrolling, tap to zoom) etc, then
1705 // we do not send any of the events to the page even if is has listeners.
1706 if (!m_isPageSuspended) {
1707 m_touchEventQueue.append(event);
1708 m_process->responsivenessTimer()->start();
1709 if (m_shouldSendEventsSynchronously) {
1710 bool handled = false;
1711 m_process->sendSync(Messages::WebPage::TouchEventSyncForTesting(event), Messages::WebPage::TouchEventSyncForTesting::Reply(handled), m_pageID);
1712 didReceiveEvent(event.type(), handled);
1714 m_process->send(Messages::WebPage::TouchEvent(event), m_pageID);
1716 if (m_touchEventQueue.isEmpty()) {
1717 bool isEventHandled = false;
1718 m_pageClient.doneWithTouchEvent(event, isEventHandled);
1720 // We attach the incoming events to the newest queued event so that all
1721 // the events are delivered in the correct order when the event is dequed.
1722 QueuedTouchEvents& lastEvent = m_touchEventQueue.last();
1723 lastEvent.deferredTouchEvents.append(event);
1727 if (event.allTouchPointsAreReleased())
1728 m_isTrackingTouchEvents = false;
1730 #endif // ENABLE(TOUCH_EVENTS)
1732 void WebPageProxy::scrollBy(ScrollDirection direction, ScrollGranularity granularity)
1737 m_process->send(Messages::WebPage::ScrollBy(direction, granularity), m_pageID);
1740 void WebPageProxy::centerSelectionInVisibleArea()
1745 m_process->send(Messages::WebPage::CenterSelectionInVisibleArea(), m_pageID);
1748 void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* frame, uint64_t listenerID, uint64_t navigationID)
1753 auto transaction = m_pageLoadState.transaction();
1755 if (action == PolicyIgnore)
1756 m_pageLoadState.clearPendingAPIRequestURL(transaction);
1758 uint64_t downloadID = 0;
1759 if (action == PolicyDownload) {
1760 // Create a download proxy.
1761 DownloadProxy* download = m_process->context().createDownloadProxy();
1762 downloadID = download->downloadID();
1763 handleDownloadRequest(download);
1766 // If we received a policy decision while in decidePolicyForResponse the decision will
1767 // be sent back to the web process by decidePolicyForResponse.
1768 if (m_inDecidePolicyForResponseSync) {
1769 m_syncMimeTypePolicyActionIsValid = true;
1770 m_syncMimeTypePolicyAction = action;
1771 m_syncMimeTypePolicyDownloadID = downloadID;
1775 // If we received a policy decision while in decidePolicyForNavigationAction the decision will
1776 // be sent back to the web process by decidePolicyForNavigationAction.
1777 if (m_inDecidePolicyForNavigationAction) {
1778 m_syncNavigationActionPolicyActionIsValid = true;
1779 m_syncNavigationActionPolicyAction = action;
1780 m_syncNavigationActionPolicyDownloadID = downloadID;
1784 m_process->send(Messages::WebPage::DidReceivePolicyDecision(frame->frameID(), listenerID, action, navigationID, downloadID), m_pageID);
1787 void WebPageProxy::setUserAgent(const String& userAgent)
1789 if (m_userAgent == userAgent)
1791 m_userAgent = userAgent;
1795 m_process->send(Messages::WebPage::SetUserAgent(m_userAgent), m_pageID);
1798 void WebPageProxy::setApplicationNameForUserAgent(const String& applicationName)
1800 if (m_applicationNameForUserAgent == applicationName)
1803 m_applicationNameForUserAgent = applicationName;
1804 if (!m_customUserAgent.isEmpty())
1807 setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
1810 void WebPageProxy::setCustomUserAgent(const String& customUserAgent)
1812 if (m_customUserAgent == customUserAgent)
1815 m_customUserAgent = customUserAgent;
1817 if (m_customUserAgent.isEmpty()) {
1818 setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
1822 setUserAgent(m_customUserAgent);
1825 void WebPageProxy::resumeActiveDOMObjectsAndAnimations()
1827 if (!isValid() || !m_isPageSuspended)
1830 m_isPageSuspended = false;
1832 m_process->send(Messages::WebPage::ResumeActiveDOMObjectsAndAnimations(), m_pageID);
1835 void WebPageProxy::suspendActiveDOMObjectsAndAnimations()
1837 if (!isValid() || m_isPageSuspended)
1840 m_isPageSuspended = true;
1842 m_process->send(Messages::WebPage::SuspendActiveDOMObjectsAndAnimations(), m_pageID);
1845 bool WebPageProxy::supportsTextEncoding() const
1847 // FIXME (118840): We should probably only support this for text documents, not all non-image documents.
1848 return m_mainFrame && !m_mainFrame->isDisplayingStandaloneImageDocument();
1851 void WebPageProxy::setCustomTextEncodingName(const String& encodingName)
1853 if (m_customTextEncodingName == encodingName)
1855 m_customTextEncodingName = encodingName;
1859 m_process->send(Messages::WebPage::SetCustomTextEncodingName(encodingName), m_pageID);
1862 void WebPageProxy::terminateProcess()
1864 // NOTE: This uses a check of m_isValid rather than calling isValid() since
1865 // we want this to run even for pages being closed or that already closed.
1869 m_process->requestTermination();
1870 resetStateAfterProcessExited();
1873 SessionState WebPageProxy::sessionState(const std::function<bool (WebBackForwardListItem&)>& filter) const
1875 SessionState sessionState;
1877 sessionState.backForwardListState = m_backForwardList->backForwardListState(filter);
1879 String provisionalURLString = m_pageLoadState.pendingAPIRequestURL();
1880 if (provisionalURLString.isEmpty())
1881 provisionalURLString = m_pageLoadState.provisionalURL();
1883 if (!provisionalURLString.isEmpty())
1884 sessionState.provisionalURL = URL(URL(), provisionalURLString);
1886 return sessionState;
1889 uint64_t WebPageProxy::restoreFromSessionState(SessionState sessionState, bool navigate)
1891 bool hasBackForwardList = !!sessionState.backForwardListState.currentIndex;
1893 if (hasBackForwardList) {
1894 m_backForwardList->restoreFromState(WTF::move(sessionState.backForwardListState));
1896 for (const auto& entry : m_backForwardList->entries())
1897 process().registerNewWebBackForwardListItem(entry.get());
1899 process().send(Messages::WebPage::RestoreSession(m_backForwardList->itemStates()), m_pageID);
1903 // FIXME: Navigating should be separate from state restoration.
1905 if (!sessionState.provisionalURL.isNull())
1906 return loadRequest(sessionState.provisionalURL);
1908 if (hasBackForwardList) {
1909 // FIXME: Do we have to null check the back forward list item here?
1910 if (WebBackForwardListItem* item = m_backForwardList->currentItem())
1911 return goToBackForwardItem(item);
1918 bool WebPageProxy::supportsTextZoom() const
1920 // FIXME (118840): This should also return false for standalone media and plug-in documents.
1921 if (!m_mainFrame || m_mainFrame->isDisplayingStandaloneImageDocument())
1927 void WebPageProxy::setTextZoomFactor(double zoomFactor)
1932 if (m_textZoomFactor == zoomFactor)
1935 m_textZoomFactor = zoomFactor;
1936 m_process->send(Messages::WebPage::SetTextZoomFactor(m_textZoomFactor), m_pageID);
1939 void WebPageProxy::setPageZoomFactor(double zoomFactor)
1944 if (m_pageZoomFactor == zoomFactor)
1947 m_pageZoomFactor = zoomFactor;
1948 m_process->send(Messages::WebPage::SetPageZoomFactor(m_pageZoomFactor), m_pageID);
1951 void WebPageProxy::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
1956 if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor)
1959 m_pageZoomFactor = pageZoomFactor;
1960 m_textZoomFactor = textZoomFactor;
1961 m_process->send(Messages::WebPage::SetPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor), m_pageID);
1964 void WebPageProxy::scalePage(double scale, const IntPoint& origin)
1969 m_pageScaleFactor = scale;
1970 m_process->send(Messages::WebPage::ScalePage(scale, origin), m_pageID);
1973 void WebPageProxy::scalePageInViewCoordinates(double scale, const IntPoint& centerInViewCoordinates)
1978 m_pageScaleFactor = scale;
1979 m_process->send(Messages::WebPage::ScalePageInViewCoordinates(scale, centerInViewCoordinates), m_pageID);
1982 void WebPageProxy::setIntrinsicDeviceScaleFactor(float scaleFactor)
1984 if (m_intrinsicDeviceScaleFactor == scaleFactor)
1987 m_intrinsicDeviceScaleFactor = scaleFactor;
1990 m_drawingArea->deviceScaleFactorDidChange();
1993 void WebPageProxy::windowScreenDidChange(PlatformDisplayID displayID)
1998 m_process->send(Messages::WebPage::WindowScreenDidChange(displayID), m_pageID);
2001 float WebPageProxy::deviceScaleFactor() const
2003 if (m_customDeviceScaleFactor)
2004 return m_customDeviceScaleFactor;
2005 return m_intrinsicDeviceScaleFactor;
2008 void WebPageProxy::setCustomDeviceScaleFactor(float customScaleFactor)
2013 // FIXME: Remove this once we bump cairo requirements to support HiDPI.
2014 // https://bugs.webkit.org/show_bug.cgi?id=133378
2015 #if USE(CAIRO) && !HAVE(CAIRO_SURFACE_SET_DEVICE_SCALE)
2019 if (m_customDeviceScaleFactor == customScaleFactor)
2022 float oldScaleFactor = deviceScaleFactor();
2024 m_customDeviceScaleFactor = customScaleFactor;
2026 if (deviceScaleFactor() != oldScaleFactor)
2027 m_drawingArea->deviceScaleFactorDidChange();
2030 void WebPageProxy::setUseFixedLayout(bool fixed)
2035 // This check is fine as the value is initialized in the web
2036 // process as part of the creation parameters.
2037 if (fixed == m_useFixedLayout)
2040 m_useFixedLayout = fixed;
2042 m_fixedLayoutSize = IntSize();
2043 m_process->send(Messages::WebPage::SetUseFixedLayout(fixed), m_pageID);
2046 void WebPageProxy::setFixedLayoutSize(const IntSize& size)
2051 if (size == m_fixedLayoutSize)
2054 m_fixedLayoutSize = size;
2055 m_process->send(Messages::WebPage::SetFixedLayoutSize(size), m_pageID);
2058 void WebPageProxy::listenForLayoutMilestones(WebCore::LayoutMilestones milestones)
2063 m_process->send(Messages::WebPage::ListenForLayoutMilestones(milestones), m_pageID);
2066 void WebPageProxy::setSuppressScrollbarAnimations(bool suppressAnimations)
2071 if (suppressAnimations == m_suppressScrollbarAnimations)
2074 m_suppressScrollbarAnimations = suppressAnimations;
2075 m_process->send(Messages::WebPage::SetSuppressScrollbarAnimations(suppressAnimations), m_pageID);
2078 bool WebPageProxy::rubberBandsAtLeft() const
2080 return m_rubberBandsAtLeft;
2083 void WebPageProxy::setRubberBandsAtLeft(bool rubberBandsAtLeft)
2085 m_rubberBandsAtLeft = rubberBandsAtLeft;
2088 bool WebPageProxy::rubberBandsAtRight() const
2090 return m_rubberBandsAtRight;
2093 void WebPageProxy::setRubberBandsAtRight(bool rubberBandsAtRight)
2095 m_rubberBandsAtRight = rubberBandsAtRight;
2098 bool WebPageProxy::rubberBandsAtTop() const
2100 return m_rubberBandsAtTop;
2103 void WebPageProxy::setRubberBandsAtTop(bool rubberBandsAtTop)
2105 m_rubberBandsAtTop = rubberBandsAtTop;
2108 bool WebPageProxy::rubberBandsAtBottom() const
2110 return m_rubberBandsAtBottom;
2113 void WebPageProxy::setRubberBandsAtBottom(bool rubberBandsAtBottom)
2115 m_rubberBandsAtBottom = rubberBandsAtBottom;
2118 void WebPageProxy::setEnableVerticalRubberBanding(bool enableVerticalRubberBanding)
2120 if (enableVerticalRubberBanding == m_enableVerticalRubberBanding)
2123 m_enableVerticalRubberBanding = enableVerticalRubberBanding;
2127 m_process->send(Messages::WebPage::SetEnableVerticalRubberBanding(enableVerticalRubberBanding), m_pageID);
2130 bool WebPageProxy::verticalRubberBandingIsEnabled() const
2132 return m_enableVerticalRubberBanding;
2135 void WebPageProxy::setEnableHorizontalRubberBanding(bool enableHorizontalRubberBanding)
2137 if (enableHorizontalRubberBanding == m_enableHorizontalRubberBanding)
2140 m_enableHorizontalRubberBanding = enableHorizontalRubberBanding;
2144 m_process->send(Messages::WebPage::SetEnableHorizontalRubberBanding(enableHorizontalRubberBanding), m_pageID);
2147 bool WebPageProxy::horizontalRubberBandingIsEnabled() const
2149 return m_enableHorizontalRubberBanding;
2152 void WebPageProxy::setBackgroundExtendsBeyondPage(bool backgroundExtendsBeyondPage)
2154 if (backgroundExtendsBeyondPage == m_backgroundExtendsBeyondPage)
2157 m_backgroundExtendsBeyondPage = backgroundExtendsBeyondPage;
2161 m_process->send(Messages::WebPage::SetBackgroundExtendsBeyondPage(backgroundExtendsBeyondPage), m_pageID);
2164 bool WebPageProxy::backgroundExtendsBeyondPage() const
2166 return m_backgroundExtendsBeyondPage;
2169 void WebPageProxy::setPaginationMode(WebCore::Pagination::Mode mode)
2171 if (mode == m_paginationMode)
2174 m_paginationMode = mode;
2178 m_process->send(Messages::WebPage::SetPaginationMode(mode), m_pageID);
2181 void WebPageProxy::setPaginationBehavesLikeColumns(bool behavesLikeColumns)
2183 if (behavesLikeColumns == m_paginationBehavesLikeColumns)
2186 m_paginationBehavesLikeColumns = behavesLikeColumns;
2190 m_process->send(Messages::WebPage::SetPaginationBehavesLikeColumns(behavesLikeColumns), m_pageID);
2193 void WebPageProxy::setPageLength(double pageLength)
2195 if (pageLength == m_pageLength)
2198 m_pageLength = pageLength;
2202 m_process->send(Messages::WebPage::SetPageLength(pageLength), m_pageID);
2205 void WebPageProxy::setGapBetweenPages(double gap)
2207 if (gap == m_gapBetweenPages)
2210 m_gapBetweenPages = gap;
2214 m_process->send(Messages::WebPage::SetGapBetweenPages(gap), m_pageID);
2217 void WebPageProxy::pageScaleFactorDidChange(double scaleFactor)
2219 m_pageScaleFactor = scaleFactor;
2222 void WebPageProxy::pageZoomFactorDidChange(double zoomFactor)
2224 m_pageZoomFactor = zoomFactor;
2227 void WebPageProxy::findStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
2229 if (string.isEmpty()) {
2230 didFindStringMatches(string, Vector<Vector<WebCore::IntRect>> (), 0);
2234 m_process->send(Messages::WebPage::FindStringMatches(string, options, maxMatchCount), m_pageID);
2237 void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount)
2239 m_process->send(Messages::WebPage::FindString(string, options, maxMatchCount), m_pageID);
2242 void WebPageProxy::getImageForFindMatch(int32_t matchIndex)
2244 m_process->send(Messages::WebPage::GetImageForFindMatch(matchIndex), m_pageID);
2247 void WebPageProxy::selectFindMatch(int32_t matchIndex)
2249 m_process->send(Messages::WebPage::SelectFindMatch(matchIndex), m_pageID);
2252 void WebPageProxy::hideFindUI()
2254 m_process->send(Messages::WebPage::HideFindUI(), m_pageID);
2257 void WebPageProxy::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
2262 m_process->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID);
2265 void WebPageProxy::runJavaScriptInMainFrame(const String& script, std::function<void (WebSerializedScriptValue*, CallbackBase::Error)> callbackFunction)
2268 callbackFunction(nullptr, CallbackBase::Error::Unknown);
2272 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
2273 m_process->send(Messages::WebPage::RunJavaScriptInMainFrame(script, callbackID), m_pageID);
2276 void WebPageProxy::getRenderTreeExternalRepresentation(std::function<void (const String&, CallbackBase::Error)> callbackFunction)
2279 callbackFunction(String(), CallbackBase::Error::Unknown);
2283 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
2284 m_process->send(Messages::WebPage::GetRenderTreeExternalRepresentation(callbackID), m_pageID);
2287 void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, std::function<void (const String&, CallbackBase::Error)> callbackFunction)
2290 callbackFunction(String(), CallbackBase::Error::Unknown);
2294 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
2295 m_loadDependentStringCallbackIDs.add(callbackID);
2296 m_process->send(Messages::WebPage::GetSourceForFrame(frame->frameID(), callbackID), m_pageID);
2299 void WebPageProxy::getContentsAsString(std::function<void (const String&, CallbackBase::Error)> callbackFunction)
2302 callbackFunction(String(), CallbackBase::Error::Unknown);
2306 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
2307 m_loadDependentStringCallbackIDs.add(callbackID);
2308 m_process->send(Messages::WebPage::GetContentsAsString(callbackID), m_pageID);
2311 void WebPageProxy::getBytecodeProfile(std::function<void (const String&, CallbackBase::Error)> callbackFunction)
2314 callbackFunction(String(), CallbackBase::Error::Unknown);
2318 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
2319 m_loadDependentStringCallbackIDs.add(callbackID);
2320 m_process->send(Messages::WebPage::GetBytecodeProfile(callbackID), m_pageID);
2324 void WebPageProxy::getContentsAsMHTMLData(std::function<void (API::Data*, CallbackBase::Error)> callbackFunction, bool useBinaryEncoding)
2327 callbackFunction(nullptr, CallbackBase::Error::Unknown);
2331 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
2332 m_process->send(Messages::WebPage::GetContentsAsMHTMLData(callbackID, useBinaryEncoding), m_pageID);
2336 void WebPageProxy::getSelectionOrContentsAsString(std::function<void (const String&, CallbackBase::Error)> callbackFunction)
2339 callbackFunction(String(), CallbackBase::Error::Unknown);
2343 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
2344 m_process->send(Messages::WebPage::GetSelectionOrContentsAsString(callbackID), m_pageID);
2347 void WebPageProxy::getSelectionAsWebArchiveData(std::function<void (API::Data*, CallbackBase::Error)> callbackFunction)
2350 callbackFunction(nullptr, CallbackBase::Error::Unknown);
2354 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
2355 m_process->send(Messages::WebPage::GetSelectionAsWebArchiveData(callbackID), m_pageID);
2358 void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, std::function<void (API::Data*, CallbackBase::Error)> callbackFunction)
2360 if (!isValid() || !frame) {
2361 callbackFunction(nullptr, CallbackBase::Error::Unknown);
2365 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
2366 m_process->send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID), m_pageID);
2369 void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, API::URL* resourceURL, std::function<void (API::Data*, CallbackBase::Error)> callbackFunction)
2372 callbackFunction(nullptr, CallbackBase::Error::Unknown);
2376 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
2377 m_process->send(Messages::WebPage::GetResourceDataFromFrame(frame->frameID(), resourceURL->string(), callbackID), m_pageID);
2380 void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, std::function<void (API::Data*, CallbackBase::Error)> callbackFunction)
2383 callbackFunction(nullptr, CallbackBase::Error::Unknown);
2387 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
2388 m_process->send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID), m_pageID);
2391 void WebPageProxy::forceRepaint(PassRefPtr<VoidCallback> prpCallback)
2393 RefPtr<VoidCallback> callback = prpCallback;
2395 // FIXME: If the page is invalid we should not call the callback. It'd be better to just return false from forceRepaint.
2396 callback->invalidate(CallbackBase::Error::OwnerWasInvalidated);
2400 uint64_t callbackID = callback->callbackID();
2401 m_callbacks.put(callback);
2402 m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
2403 m_process->send(Messages::WebPage::ForceRepaint(callbackID), m_pageID);
2406 void WebPageProxy::preferencesDidChange()
2411 #if ENABLE(INSPECTOR_SERVER)
2412 if (m_preferences->developerExtrasEnabled())
2413 inspector()->enableRemoteInspection();
2416 m_process->pagePreferencesChanged(this);
2418 m_pageClient.preferencesDidChange();
2420 // FIXME: It probably makes more sense to send individual preference changes.
2421 // However, WebKitTestRunner depends on getting a preference change notification
2422 // even if nothing changed in UI process, so that overrides get removed.
2424 // Preferences need to be updated during synchronous printing to make "print backgrounds" preference work when toggled from a print dialog checkbox.
2425 m_process->send(Messages::WebPage::PreferencesDidChange(preferencesStore()), m_pageID, m_isPerformingDOMPrintOperation ? IPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
2428 void WebPageProxy::didCreateMainFrame(uint64_t frameID)
2430 MESSAGE_CHECK(!m_mainFrame);
2431 MESSAGE_CHECK(m_process->canCreateFrame(frameID));
2433 m_mainFrame = WebFrameProxy::create(this, frameID);
2435 // Add the frame to the process wide map.
2436 m_process->frameCreated(frameID, m_mainFrame.get());
2439 void WebPageProxy::didCreateSubframe(uint64_t frameID)
2441 MESSAGE_CHECK(m_mainFrame);
2442 MESSAGE_CHECK(m_process->canCreateFrame(frameID));
2444 RefPtr<WebFrameProxy> subFrame = WebFrameProxy::create(this, frameID);
2446 // Add the frame to the process wide map.
2447 m_process->frameCreated(frameID, subFrame.get());
2450 double WebPageProxy::estimatedProgress() const
2452 return m_pageLoadState.estimatedProgress();
2455 void WebPageProxy::didStartProgress()
2457 auto transaction = m_pageLoadState.transaction();
2458 m_pageLoadState.didStartProgress(transaction);
2460 m_pageLoadState.commitChanges();
2461 m_loaderClient->didStartProgress(this);
2464 void WebPageProxy::didChangeProgress(double value)
2466 auto transaction = m_pageLoadState.transaction();
2467 m_pageLoadState.didChangeProgress(transaction, value);
2469 m_pageLoadState.commitChanges();
2470 m_loaderClient->didChangeProgress(this);
2473 void WebPageProxy::didFinishProgress()
2475 auto transaction = m_pageLoadState.transaction();
2476 m_pageLoadState.didFinishProgress(transaction);
2478 m_pageLoadState.commitChanges();
2479 m_loaderClient->didFinishProgress(this);
2482 void WebPageProxy::setNetworkRequestsInProgress(bool networkRequestsInProgress)
2484 auto transaction = m_pageLoadState.transaction();
2485 m_pageLoadState.setNetworkRequestsInProgress(transaction, networkRequestsInProgress);
2488 void WebPageProxy::didDestroyNavigation(uint64_t navigationID)
2490 m_loaderClient->didDestroyNavigation(this, navigationID);
2493 void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& url, const String& unreachableURL, IPC::MessageDecoder& decoder)
2495 auto transaction = m_pageLoadState.transaction();
2497 m_pageLoadState.clearPendingAPIRequestURL(transaction);
2499 RefPtr<API::Object> userData;
2500 WebContextUserMessageDecoder messageDecoder(userData, process());
2501 if (!decoder.decode(messageDecoder))
2504 WebFrameProxy* frame = m_process->webFrame(frameID);
2505 MESSAGE_CHECK(frame);
2506 MESSAGE_CHECK_URL(url);
2508 if (frame->isMainFrame())
2509 m_pageLoadState.didStartProvisionalLoad(transaction, url, unreachableURL);
2511 frame->setUnreachableURL(unreachableURL);
2512 frame->didStartProvisionalLoad(url);
2514 m_pageLoadState.commitChanges();
2515 m_loaderClient->didStartProvisionalLoadForFrame(this, frame, navigationID, userData.get());
2518 void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& url, IPC::MessageDecoder& decoder)
2520 RefPtr<API::Object> userData;
2521 WebContextUserMessageDecoder messageDecoder(userData, process());
2522 if (!decoder.decode(messageDecoder))
2525 WebFrameProxy* frame = m_process->webFrame(frameID);
2526 MESSAGE_CHECK(frame);
2527 MESSAGE_CHECK_URL(url);
2529 auto transaction = m_pageLoadState.transaction();
2531 if (frame->isMainFrame())
2532 m_pageLoadState.didReceiveServerRedirectForProvisionalLoad(transaction, url);
2534 frame->didReceiveServerRedirectForProvisionalLoad(url);
2536 m_pageLoadState.commitChanges();
2537 m_loaderClient->didReceiveServerRedirectForProvisionalLoadForFrame(this, frame, navigationID, userData.get());
2540 void WebPageProxy::didFailProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const ResourceError& error, IPC::MessageDecoder& decoder)
2542 RefPtr<API::Object> userData;
2543 WebContextUserMessageDecoder messageDecoder(userData, process());
2544 if (!decoder.decode(messageDecoder))
2547 WebFrameProxy* frame = m_process->webFrame(frameID);
2548 MESSAGE_CHECK(frame);
2550 auto transaction = m_pageLoadState.transaction();
2552 if (frame->isMainFrame())
2553 m_pageLoadState.didFailProvisionalLoad(transaction);
2555 frame->didFailProvisionalLoad();
2557 m_pageLoadState.commitChanges();
2558 m_loaderClient->didFailProvisionalLoadWithErrorForFrame(this, frame, navigationID, error, userData.get());
2561 void WebPageProxy::clearLoadDependentCallbacks()
2563 Vector<uint64_t> callbackIDsCopy;
2564 copyToVector(m_loadDependentStringCallbackIDs, callbackIDsCopy);
2565 m_loadDependentStringCallbackIDs.clear();
2567 for (size_t i = 0; i < callbackIDsCopy.size(); ++i) {
2568 auto callback = m_callbacks.take<StringCallback>(callbackIDsCopy[i]);
2570 callback->invalidate();
2574 void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t opaqueFrameLoadType, const WebCore::CertificateInfo& certificateInfo, IPC::MessageDecoder& decoder)
2576 RefPtr<API::Object> userData;
2577 WebContextUserMessageDecoder messageDecoder(userData, process());
2578 if (!decoder.decode(messageDecoder))
2581 WebFrameProxy* frame = m_process->webFrame(frameID);
2582 MESSAGE_CHECK(frame);
2584 auto transaction = m_pageLoadState.transaction();
2586 if (frame->isMainFrame())
2587 m_pageLoadState.didCommitLoad(transaction);
2590 // FIXME (bug 59111): didCommitLoadForFrame comes too late when restoring a page from b/f cache, making us disable secure event mode in password fields.
2591 // FIXME: A load going on in one frame shouldn't affect text editing in other frames on the page.
2592 m_pageClient.resetSecureInputState();
2593 dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
2594 m_pageClient.dismissDictionaryLookupPanel();
2597 clearLoadDependentCallbacks();
2599 frame->didCommitLoad(mimeType, certificateInfo);
2601 if (frame->isMainFrame()) {
2602 m_mainFrameHasCustomContentProvider = frameHasCustomContentProvider;
2604 if (m_mainFrameHasCustomContentProvider) {
2605 // Always assume that the main frame is pinned here, since the custom representation view will handle
2606 // any wheel events and dispatch them to the WKView when necessary.
2607 m_mainFrameIsPinnedToLeftSide = true;
2608 m_mainFrameIsPinnedToRightSide = true;
2609 m_mainFrameIsPinnedToTopSide = true;
2610 m_mainFrameIsPinnedToBottomSide = true;
2612 m_uiClient->pinnedStateDidChange(*this);
2614 m_pageClient.didCommitLoadForMainFrame(mimeType, frameHasCustomContentProvider);
2617 // Even if WebPage has the default pageScaleFactor (and therefore doesn't reset it),
2618 // WebPageProxy's cache of the value can get out of sync (e.g. in the case where a
2619 // plugin is handling page scaling itself) so we should reset it to the default
2620 // for standard main frame loads.
2621 if (frame->isMainFrame() && static_cast<FrameLoadType>(opaqueFrameLoadType) == FrameLoadType::Standard)
2622 m_pageScaleFactor = 1;
2624 m_pageLoadState.commitChanges();
2625 m_loaderClient->didCommitLoadForFrame(this, frame, navigationID, userData.get());
2628 void WebPageProxy::didFinishDocumentLoadForFrame(uint64_t frameID, uint64_t navigationID, IPC::MessageDecoder& decoder)
2630 RefPtr<API::Object> userData;
2631 WebContextUserMessageDecoder messageDecoder(userData, process());
2632 if (!decoder.decode(messageDecoder))
2635 WebFrameProxy* frame = m_process->webFrame(frameID);
2636 MESSAGE_CHECK(frame);
2638 m_loaderClient->didFinishDocumentLoadForFrame(this, frame, navigationID, userData.get());
2641 void WebPageProxy::didFinishLoadForFrame(uint64_t frameID, uint64_t navigationID, IPC::MessageDecoder& decoder)
2643 RefPtr<API::Object> userData;
2644 WebContextUserMessageDecoder messageDecoder(userData, process());
2645 if (!decoder.decode(messageDecoder))
2648 WebFrameProxy* frame = m_process->webFrame(frameID);
2649 MESSAGE_CHECK(frame);
2651 auto transaction = m_pageLoadState.transaction();
2653 if (frame->isMainFrame())
2654 m_pageLoadState.didFinishLoad(transaction);
2656 frame->didFinishLoad();
2658 m_pageLoadState.commitChanges();
2659 m_loaderClient->didFinishLoadForFrame(this, frame, navigationID, userData.get());
2662 void WebPageProxy::didFailLoadForFrame(uint64_t frameID, uint64_t navigationID, const ResourceError& error, IPC::MessageDecoder& decoder)
2664 RefPtr<API::Object> userData;
2665 WebContextUserMessageDecoder messageDecoder(userData, process());
2666 if (!decoder.decode(messageDecoder))
2669 WebFrameProxy* frame = m_process->webFrame(frameID);
2670 MESSAGE_CHECK(frame);
2672 clearLoadDependentCallbacks();
2674 auto transaction = m_pageLoadState.transaction();
2676 if (frame->isMainFrame())
2677 m_pageLoadState.didFailLoad(transaction);
2679 frame->didFailLoad();
2681 m_pageLoadState.commitChanges();
2682 m_loaderClient->didFailLoadWithErrorForFrame(this, frame, navigationID, error, userData.get());
2685 void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint64_t navigationID, uint32_t opaqueSameDocumentNavigationType, const String& url, IPC::MessageDecoder& decoder)
2687 RefPtr<API::Object> userData;
2688 WebContextUserMessageDecoder messageDecoder(userData, process());
2689 if (!decoder.decode(messageDecoder))
2692 WebFrameProxy* frame = m_process->webFrame(frameID);
2693 MESSAGE_CHECK(frame);
2694 MESSAGE_CHECK_URL(url);
2696 auto transaction = m_pageLoadState.transaction();
2698 if (frame->isMainFrame())
2699 m_pageLoadState.didSameDocumentNavigation(transaction, url);
2701 m_pageLoadState.clearPendingAPIRequestURL(transaction);
2702 frame->didSameDocumentNavigation(url);
2704 m_pageLoadState.commitChanges();
2705 m_loaderClient->didSameDocumentNavigationForFrame(this, frame, navigationID, static_cast<SameDocumentNavigationType>(opaqueSameDocumentNavigationType), userData.get());
2708 void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String& title, IPC::MessageDecoder& decoder)
2710 RefPtr<API::Object> userData;
2711 WebContextUserMessageDecoder messageDecoder(userData, process());
2712 if (!decoder.decode(messageDecoder))
2715 WebFrameProxy* frame = m_process->webFrame(frameID);
2716 MESSAGE_CHECK(frame);
2718 auto transaction = m_pageLoadState.transaction();
2720 if (frame->isMainFrame())
2721 m_pageLoadState.setTitle(transaction, title);
2723 frame->didChangeTitle(title);
2725 m_pageLoadState.commitChanges();
2726 m_loaderClient->didReceiveTitleForFrame(this, title, frame, userData.get());
2729 void WebPageProxy::didFirstLayoutForFrame(uint64_t frameID, IPC::MessageDecoder& decoder)
2731 RefPtr<API::Object> userData;
2732 WebContextUserMessageDecoder messageDecoder(userData, process());
2733 if (!decoder.decode(messageDecoder))
2736 WebFrameProxy* frame = m_process->webFrame(frameID);
2737 MESSAGE_CHECK(frame);
2739 m_loaderClient->didFirstLayoutForFrame(this, frame, userData.get());
2742 void WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, IPC::MessageDecoder& decoder)
2744 RefPtr<API::Object> userData;
2745 WebContextUserMessageDecoder messageDecoder(userData, process());
2746 if (!decoder.decode(messageDecoder))
2749 WebFrameProxy* frame = m_process->webFrame(frameID);
2750 MESSAGE_CHECK(frame);
2752 m_loaderClient->didFirstVisuallyNonEmptyLayoutForFrame(this, frame, userData.get());
2755 void WebPageProxy::didLayout(uint32_t layoutMilestones, IPC::MessageDecoder& decoder)
2757 RefPtr<API::Object> userData;
2758 WebContextUserMessageDecoder messageDecoder(userData, process());
2759 if (!decoder.decode(messageDecoder))
2762 m_loaderClient->didLayout(this, static_cast<LayoutMilestones>(layoutMilestones), userData.get());
2765 void WebPageProxy::didRemoveFrameFromHierarchy(uint64_t frameID, IPC::MessageDecoder& decoder)
2767 RefPtr<API::Object> userData;
2768 WebContextUserMessageDecoder messageDecoder(userData, process());
2769 if (!decoder.decode(messageDecoder))
2772 WebFrameProxy* frame = m_process->webFrame(frameID);
2773 MESSAGE_CHECK(frame);
2775 m_loaderClient->didRemoveFrameFromHierarchy(this, frame, userData.get());
2778 void WebPageProxy::didDisplayInsecureContentForFrame(uint64_t frameID, IPC::MessageDecoder& decoder)
2780 RefPtr<API::Object> userData;
2781 WebContextUserMessageDecoder messageDecoder(userData, process());
2782 if (!decoder.decode(messageDecoder))
2785 WebFrameProxy* frame = m_process->webFrame(frameID);
2786 MESSAGE_CHECK(frame);
2788 auto transaction = m_pageLoadState.transaction();
2789 m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
2791 m_pageLoadState.commitChanges();
2792 m_loaderClient->didDisplayInsecureContentForFrame(this, frame, userData.get());
2795 void WebPageProxy::didRunInsecureContentForFrame(uint64_t frameID, IPC::MessageDecoder& decoder)
2797 RefPtr<API::Object> userData;
2798 WebContextUserMessageDecoder messageDecoder(userData, process());
2799 if (!decoder.decode(messageDecoder))
2802 WebFrameProxy* frame = m_process->webFrame(frameID);
2803 MESSAGE_CHECK(frame);
2805 auto transaction = m_pageLoadState.transaction();
2806 m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
2808 m_pageLoadState.commitChanges();
2809 m_loaderClient->didRunInsecureContentForFrame(this, frame, userData.get());
2812 void WebPageProxy::didDetectXSSForFrame(uint64_t frameID, IPC::MessageDecoder& decoder)
2814 RefPtr<API::Object> userData;
2815 WebContextUserMessageDecoder messageDecoder(userData, process());
2816 if (!decoder.decode(messageDecoder))
2819 WebFrameProxy* frame = m_process->webFrame(frameID);
2820 MESSAGE_CHECK(frame);
2822 m_loaderClient->didDetectXSSForFrame(this, frame, userData.get());
2825 void WebPageProxy::frameDidBecomeFrameSet(uint64_t frameID, bool value)
2827 WebFrameProxy* frame = m_process->webFrame(frameID);
2828 MESSAGE_CHECK(frame);
2830 frame->setIsFrameSet(value);
2831 if (frame->isMainFrame())
2832 m_frameSetLargestFrame = value ? m_mainFrame : 0;
2835 void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, uint64_t navigationID, const NavigationActionData& navigationActionData, uint64_t originatingFrameID, const WebCore::ResourceRequest& originalRequest, const ResourceRequest& request, uint64_t listenerID, IPC::MessageDecoder& decoder, bool& receivedPolicyAction, uint64_t& newNavigationID, uint64_t& policyAction, uint64_t& downloadID)
2837 RefPtr<API::Object> userData;
2838 WebContextUserMessageDecoder messageDecoder(userData, process());
2839 if (!decoder.decode(messageDecoder))
2842 auto transaction = m_pageLoadState.transaction();
2844 if (request.url() != m_pageLoadState.pendingAPIRequestURL())
2845 m_pageLoadState.clearPendingAPIRequestURL(transaction);
2847 WebFrameProxy* frame = m_process->webFrame(frameID);
2848 MESSAGE_CHECK(frame);
2849 MESSAGE_CHECK_URL(request.url());
2850 MESSAGE_CHECK_URL(originalRequest.url());
2852 WebFrameProxy* originatingFrame = m_process->webFrame(originatingFrameID);
2854 RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2855 if (!navigationID && frame->isMainFrame()) {
2856 newNavigationID = generateNavigationID();
2857 listener->setNavigationID(newNavigationID);
2860 #if ENABLE(CONTENT_FILTERING)
2861 if (frame->contentFilterDidHandleNavigationAction(request)) {
2862 receivedPolicyAction = true;
2863 policyAction = PolicyIgnore;
2868 ASSERT(!m_inDecidePolicyForNavigationAction);
2870 m_inDecidePolicyForNavigationAction = true;
2871 m_syncNavigationActionPolicyActionIsValid = false;
2873 m_policyClient->decidePolicyForNavigationAction(this, frame, navigationActionData, originatingFrame, originalRequest, request, WTF::move(listener), userData.get());
2875 m_inDecidePolicyForNavigationAction = false;
2877 // Check if we received a policy decision already. If we did, we can just pass it back.
2878 receivedPolicyAction = m_syncNavigationActionPolicyActionIsValid;
2879 if (m_syncNavigationActionPolicyActionIsValid) {
2880 policyAction = m_syncNavigationActionPolicyAction;
2881 downloadID = m_syncNavigationActionPolicyDownloadID;
2885 void WebPageProxy::decidePolicyForNewWindowAction(uint64_t frameID, const NavigationActionData& navigationActionData, const ResourceRequest& request, const String& frameName, uint64_t listenerID, IPC::MessageDecoder& decoder)
2887 RefPtr<API::Object> userData;
2888 WebContextUserMessageDecoder messageDecoder(userData, process());
2889 if (!decoder.decode(messageDecoder))
2892 WebFrameProxy* frame = m_process->webFrame(frameID);
2893 MESSAGE_CHECK(frame);
2894 MESSAGE_CHECK_URL(request.url());
2896 RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2898 m_policyClient->decidePolicyForNewWindowAction(this, frame, navigationActionData, request, frameName, WTF::move(listener), userData.get());
2901 void WebPageProxy::decidePolicyForResponse(uint64_t frameID, const ResourceResponse& response, const ResourceRequest& request, bool canShowMIMEType, uint64_t listenerID, IPC::MessageDecoder& decoder)
2903 RefPtr<API::Object> userData;
2904 WebContextUserMessageDecoder messageDecoder(userData, process());
2905 if (!decoder.decode(messageDecoder))
2908 WebFrameProxy* frame = m_process->webFrame(frameID);
2909 MESSAGE_CHECK(frame);
2910 MESSAGE_CHECK_URL(request.url());
2911 MESSAGE_CHECK_URL(response.url());
2913 RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2915 m_policyClient->decidePolicyForResponse(this, frame, response, request, canShowMIMEType, WTF::move(listener), userData.get());
2918 void WebPageProxy::decidePolicyForResponseSync(uint64_t frameID, const ResourceResponse& response, const ResourceRequest& request, bool canShowMIMEType, uint64_t listenerID, IPC::MessageDecoder& decoder, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
2920 ASSERT(!m_inDecidePolicyForResponseSync);
2922 m_inDecidePolicyForResponseSync = true;
2923 m_decidePolicyForResponseRequest = &request;
2924 m_syncMimeTypePolicyActionIsValid = false;
2926 decidePolicyForResponse(frameID, response, request, canShowMIMEType, listenerID, decoder);
2928 m_inDecidePolicyForResponseSync = false;
2929 m_decidePolicyForResponseRequest = 0;
2931 // Check if we received a policy decision already. If we did, we can just pass it back.
2932 receivedPolicyAction = m_syncMimeTypePolicyActionIsValid;
2933 if (m_syncMimeTypePolicyActionIsValid) {
2934 policyAction = m_syncMimeTypePolicyAction;
2935 downloadID = m_syncMimeTypePolicyDownloadID;
2939 void WebPageProxy::unableToImplementPolicy(uint64_t frameID, const ResourceError& error, IPC::MessageDecoder& decoder)
2941 RefPtr<API::Object> userData;
2942 WebContextUserMessageDecoder messageDecoder(userData, process());
2943 if (!decoder.decode(messageDecoder))
2946 WebFrameProxy* frame = m_process->webFrame(frameID);
2947 MESSAGE_CHECK(frame);
2949 m_policyClient->unableToImplementPolicy(this, frame, error, userData.get());
2954 void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const Vector<std::pair<String, String>>& textFieldValues, uint64_t listenerID, IPC::MessageDecoder& decoder)
2956 RefPtr<API::Object> userData;
2957 WebContextUserMessageDecoder messageDecoder(userData, process());
2958 if (!decoder.decode(messageDecoder))
2961 WebFrameProxy* frame = m_process->webFrame(frameID);
2962 MESSAGE_CHECK(frame);
2964 WebFrameProxy* sourceFrame = m_process->webFrame(sourceFrameID);
2965 MESSAGE_CHECK(sourceFrame);
2967 RefPtr<WebFormSubmissionListenerProxy> listener = frame->setUpFormSubmissionListenerProxy(listenerID);
2968 if (!m_formClient->willSubmitForm(this, frame, sourceFrame, textFieldValues, userData.get(), listener.get()))
2969 listener->continueSubmission();
2974 void WebPageProxy::createNewPage(uint64_t frameID, const ResourceRequest& request, const WindowFeatures& windowFeatures, const NavigationActionData& navigationActionData, uint64_t& newPageID, WebPageCreationParameters& newPageParameters)
2976 WebFrameProxy* frame = m_process->webFrame(frameID);
2977 MESSAGE_CHECK(frame);
2979 RefPtr<WebPageProxy> newPage = m_uiClient->createNewPage(this, frame, request, windowFeatures, navigationActionData);
2985 newPageID = newPage->pageID();
2986 newPageParameters = newPage->creationParameters();
2987 process().context().storageManager().cloneSessionStorageNamespace(m_pageID, newPage->pageID());
2990 void WebPageProxy::showPage()
2992 m_uiClient->showPage(this);
2995 void WebPageProxy::closePage(bool stopResponsivenessTimer)
2997 if (stopResponsivenessTimer)
2998 m_process->responsivenessTimer()->stop();
3000 m_pageClient.clearAllEditCommands();
3001 m_uiClient->close(this);
3004 void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message, RefPtr<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply> reply)
3006 WebFrameProxy* frame = m_process->webFrame(frameID);
3007 MESSAGE_CHECK(frame);
3009 // Since runJavaScriptAlert() can spin a nested run loop we need to turn off the responsiveness timer.
3010 m_process->responsivenessTimer()->stop();
3012 m_uiClient->runJavaScriptAlert(this, message, frame, [reply]{ reply->send(); });
3015 void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, RefPtr<Messages::WebPageProxy::RunJavaScriptConfirm::DelayedReply> reply)
3017 WebFrameProxy* frame = m_process->webFrame(frameID);
3018 MESSAGE_CHECK(frame);
3020 // Since runJavaScriptConfirm() can spin a nested run loop we need to turn off the responsiveness timer.
3021 m_process->responsivenessTimer()->stop();
3023 m_uiClient->runJavaScriptConfirm(this, message, frame, [reply](bool result) { reply->send(result); });
3026 void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, RefPtr<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply> reply)
3028 WebFrameProxy* frame = m_process->webFrame(frameID);
3029 MESSAGE_CHECK(frame);
3031 // Since runJavaScriptPrompt() can spin a nested run loop we need to turn off the responsiveness timer.
3032 m_process->responsivenessTimer()->stop();
3034 m_uiClient->runJavaScriptPrompt(this, message, defaultValue, frame, [reply](const String& result) { reply->send(result); });
3037 void WebPageProxy::shouldInterruptJavaScript(bool& result)
3039 // Since shouldInterruptJavaScript() can spin a nested run loop we need to turn off the responsiveness timer.
3040 m_process->responsivenessTimer()->stop();
3042 result = m_uiClient->shouldInterruptJavaScript(this);
3045 void WebPageProxy::setStatusText(const String& text)
3047 m_uiClient->setStatusText(this, text);
3050 void WebPageProxy::mouseDidMoveOverElement(const WebHitTestResult::Data& hitTestResultData, uint32_t opaqueModifiers, IPC::MessageDecoder& decoder)
3052 RefPtr<API::Object> userData;
3053 WebContextUserMessageDecoder messageDecoder(userData, process());
3054 if (!decoder.decode(messageDecoder))
3057 WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
3059 m_uiClient->mouseDidMoveOverElement(this, hitTestResultData, modifiers, userData.get());
3062 void WebPageProxy::connectionWillOpen(IPC::Connection* connection)
3064 ASSERT(connection == m_process->connection());
3066 m_process->context().storageManager().setAllowedSessionStorageNamespaceConnection(m_pageID, connection);
3069 void WebPageProxy::connectionWillClose(IPC::Connection* connection)
3071 ASSERT_UNUSED(connection, connection == m_process->connection());
3073 m_process->context().storageManager().setAllowedSessionStorageNamespaceConnection(m_pageID, 0);
3076 void WebPageProxy::processDidFinishLaunching()
3078 if (m_userContentController)
3079 m_userContentController->addProcess(m_process.get());
3080 m_visitedLinkProvider->addProcess(m_process.get());
3083 #if ENABLE(NETSCAPE_PLUGIN_API)
3084 void WebPageProxy::unavailablePluginButtonClicked(uint32_t opaquePluginUnavailabilityReason, const String& mimeType, const String& pluginURLString, const String& pluginspageAttributeURLString, const String& frameURLString, const String& pageURLString)
3086 MESSAGE_CHECK_URL(pluginURLString);
3087 MESSAGE_CHECK_URL(pluginspageAttributeURLString);
3088 MESSAGE_CHECK_URL(frameURLString);
3089 MESSAGE_CHECK_URL(pageURLString);
3091 RefPtr<ImmutableDictionary> pluginInformation;
3092 String newMimeType = mimeType;
3093 PluginModuleInfo plugin = m_process->context().pluginInfoStore().findPlugin(newMimeType, URL(URL(), pluginURLString));
3094 pluginInformation = createPluginInformationDictionary(plugin, frameURLString, mimeType, pageURLString, pluginspageAttributeURLString, pluginURLString);
3096 WKPluginUnavailabilityReason pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginMissing;
3097 switch (static_cast<RenderEmbeddedObject::PluginUnavailabilityReason>(opaquePluginUnavailabilityReason)) {
3098 case RenderEmbeddedObject::PluginMissing:
3099 pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginMissing;
3101 case RenderEmbeddedObject::InsecurePluginVersion:
3102 pluginUnavailabilityReason = kWKPluginUnavailabilityReasonInsecurePluginVersion;
3104 case RenderEmbeddedObject::PluginCrashed:
3105 pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginCrashed;
3107 case RenderEmbeddedObject::PluginBlockedByContentSecurityPolicy:
3108 ASSERT_NOT_REACHED();
3111 m_uiClient->unavailablePluginButtonClicked(this, pluginUnavailabilityReason, pluginInformation.get());
3113 #endif // ENABLE(NETSCAPE_PLUGIN_API)
3116 void WebPageProxy::webGLPolicyForURL(const String& url, uint32_t& loadPolicy)
3118 loadPolicy = static_cast<uint32_t>(m_loaderClient->webGLLoadPolicy(this, url));
3121 void WebPageProxy::resolveWebGLPolicyForURL(const String& url, uint32_t& loadPolicy)
3123 loadPolicy = static_cast<uint32_t>(m_loaderClient->resolveWebGLLoadPolicy(this, url));
3125 #endif // ENABLE(WEBGL)
3127 void WebPageProxy::setToolbarsAreVisible(bool toolbarsAreVisible)
3129 m_uiClient->setToolbarsAreVisible(this, toolbarsAreVisible);
3132 void WebPageProxy::getToolbarsAreVisible(bool& toolbarsAreVisible)
3134 toolbarsAreVisible = m_uiClient->toolbarsAreVisible(this);
3137 void WebPageProxy::setMenuBarIsVisible(bool menuBarIsVisible)
3139 m_uiClient->setMenuBarIsVisible(this, menuBarIsVisible);
3142 void WebPageProxy::getMenuBarIsVisible(bool& menuBarIsVisible)
3144 menuBarIsVisible = m_uiClient->menuBarIsVisible(this);
3147 void WebPageProxy::setStatusBarIsVisible(bool statusBarIsVisible)
3149 m_uiClient->setStatusBarIsVisible(this, statusBarIsVisible);
3152 void WebPageProxy::getStatusBarIsVisible(bool& statusBarIsVisible)
3154 statusBarIsVisible = m_uiClient->statusBarIsVisible(this);
3157 void WebPageProxy::setIsResizable(bool isResizable)
3159 m_uiClient->setIsResizable(this, isResizable);
3162 void WebPageProxy::getIsResizable(bool& isResizable)
3164 isResizable = m_uiClient->isResizable(this);
3167 void WebPageProxy::setWindowFrame(const FloatRect& newWindowFrame)
3169 m_uiClient->setWindowFrame(this, m_pageClient.convertToDeviceSpace(newWindowFrame));
3172 void WebPageProxy::getWindowFrame(FloatRect& newWindowFrame)
3174 newWindowFrame = m_pageClient.convertToUserSpace(m_uiClient->windowFrame(this));
3177 void WebPageProxy::screenToRootView(const IntPoint& screenPoint, IntPoint& windowPoint)
3179 windowPoint = m_pageClient.screenToRootView(screenPoint);
3182 void WebPageProxy::rootViewToScreen(const IntRect& viewRect, IntRect& result)
3184 result = m_pageClient.rootViewToScreen(viewRect);
3188 void WebPageProxy::accessibilityScreenToRootView(const IntPoint& screenPoint, IntPoint& windowPoint)
3190 windowPoint = m_pageClient.accessibilityScreenToRootView(screenPoint);
3193 void WebPageProxy::rootViewToAccessibilityScreen(const IntRect& viewRect, IntRect& result)
3195 result = m_pageClient.rootViewToAccessibilityScreen(viewRect);
3199 void WebPageProxy::runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose)
3201 WebFrameProxy* frame = m_process->webFrame(frameID);
3202 MESSAGE_CHECK(frame);
3204 // Since runBeforeUnloadConfirmPanel() can spin a nested run loop we need to turn off the responsiveness timer.
3205 m_process->responsivenessTimer()->stop();
3207 shouldClose = m_uiClient->runBeforeUnloadConfirmPanel(this, message, frame);
3210 #if USE(TILED_BACKING_STORE)
3211 void WebPageProxy::pageDidRequestScroll(const IntPoint& point)
3213 m_pageClient.pageDidRequestScroll(point);
3216 void WebPageProxy::pageTransitionViewportReady()
3218 m_pageClient.pageTransitionViewportReady();
3221 void WebPageProxy::didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect)
3223 m_pageClient.didRenderFrame(contentsSize, coveredRect);
3228 void WebPageProxy::didChangeViewportProperties(const ViewportAttributes& attr)
3230 m_pageClient.didChangeViewportProperties(attr);
3233 void WebPageProxy::pageDidScroll()
3235 m_uiClient->pageDidScroll(this);
3237 dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
3241 void WebPageProxy::runOpenPanel(uint64_t frameID, const FileChooserSettings& settings)
3243 if (m_openPanelResultListener) {
3244 m_openPanelResultListener->invalidate();
3245 m_openPanelResultListener = 0;
3248 WebFrameProxy* frame = m_process->webFrame(frameID);
3249 MESSAGE_CHECK(frame);
3251 RefPtr<WebOpenPanelParameters> parameters = WebOpenPanelParameters::create(settings);
3252 m_openPanelResultListener = WebOpenPanelResultListenerProxy::create(this);
3254 // Since runOpenPanel() can spin a nested run loop we need to turn off the responsiveness timer.
3255 m_process->responsivenessTimer()->stop();
3257 if (!m_uiClient->runOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get())) {
3258 if (!m_pageClient.handleRunOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get()))
3259 didCancelForOpenPanel();
3263 void WebPageProxy::printFrame(uint64_t frameID)
3265 ASSERT(!m_isPerformingDOMPrintOperation);
3266 m_isPerformingDOMPrintOperation = true;
3268 WebFrameProxy* frame = m_process->webFrame(frameID);
3269 MESSAGE_CHECK(frame);
3271 m_uiClient->printFrame(this, frame);
3273 endPrinting(); // Send a message synchronously while m_isPerformingDOMPrintOperation is still true.
3274 m_isPerformingDOMPrintOperation = false;
3277 void WebPageProxy::printMainFrame()
3279 printFrame(m_mainFrame->frameID());
3282 void WebPageProxy::setMediaVolume(float volume)
3284 if (volume == m_mediaVolume)
3287 m_mediaVolume = volume;
3292 m_process->send(Messages::WebPage::SetMediaVolume(volume), m_pageID);
3295 void WebPageProxy::setMayStartMediaWhenInWindow(bool mayStartMedia)
3297 if (mayStartMedia == m_mayStartMediaWhenInWindow)
3300 m_mayStartMediaWhenInWindow = mayStartMedia;
3305 process().send(Messages::WebPage::SetMayStartMediaWhenInWindow(mayStartMedia), m_pageID);
3308 void WebPageProxy::handleDownloadRequest(DownloadProxy* download)
3310 m_pageClient.handleDownloadRequest(download);
3314 void WebPageProxy::didChangeContentSize(const IntSize& size)
3316 m_pageClient.didChangeContentSize(size);
3320 #if ENABLE(INPUT_TYPE_COLOR)
3321 void WebPageProxy::showColorPicker(const WebCore::Color& initialColor, const IntRect& elementRect)
3323 #if ENABLE(INPUT_TYPE_COLOR_POPOVER)
3324 // A new popover color well needs to be created (and the previous one destroyed) for
3325 // each activation of a color element.
3329 m_colorPicker = m_pageClient.createColorPicker(this, initialColor, elementRect);
3330 m_colorPicker->showColorPicker(initialColor);
3333 void WebPageProxy::setColorPickerColor(const WebCore::Color& color)
3335 ASSERT(m_colorPicker);
3337 m_colorPicker->setSelectedColor(color);
3340 void WebPageProxy::endColorPicker()
3342 ASSERT(m_colorPicker);
3344 m_colorPicker->endPicker();
3347 void WebPageProxy::didChooseColor(const WebCore::Color& color)
3352 m_process->send(Messages::WebPage::DidChooseColor(color), m_pageID);
3355 void WebPageProxy::didEndColorPicker()
3360 if (m_colorPicker) {
3361 m_colorPicker->invalidate();
3362 m_colorPicker = nullptr;
3365 m_process->send(Messages::WebPage::DidEndColorPicker(), m_pageID);
3369 void WebPageProxy::didDraw()
3371 m_uiClient->didDraw(this);
3376 #if ENABLE(INSPECTOR)
3378 WebInspectorProxy* WebPageProxy::inspector()
3380 if (isClosed() || !isValid())
3382 return m_inspector.get();
3387 #if ENABLE(FULLSCREEN_API)
3388 WebFullScreenManagerProxy* WebPageProxy::fullScreenManager()
3390 return m_fullScreenManager.get();
3395 RefPtr<WebVideoFullscreenManagerProxy> WebPageProxy::videoFullscreenManager()
3397 return m_videoFullscreenManager;
3403 void WebPageProxy::backForwardAddItem(uint64_t itemID)
3405 m_backForwardList->addItem(m_process->webBackForwardItem(itemID));
3408 void WebPageProxy::backForwardGoToItem(uint64_t itemID, SandboxExtension::Handle& sandboxExtensionHandle)
3410 WebBackForwardListItem* item = m_process->webBackForwardItem(itemID);
3414 bool createdExtension = maybeInitializeSandboxExtensionHandle(URL(URL(), item->url()), sandboxExtensionHandle);
3415 if (createdExtension)
3416 m_process->willAcquireUniversalFileReadSandboxExtension();
3417 m_backForwardList->goToItem(item);
3420 void WebPageProxy::backForwardItemAtIndex(int32_t index, uint64_t& itemID)
3422 WebBackForwardListItem* item = m_backForwardList->itemAtIndex(index);
3423 itemID = item ? item->itemID() : 0;
3426 void WebPageProxy::backForwardBackListCount(int32_t& count)
3428 count = m_backForwardList->backListCount();
3431 void WebPageProxy::backForwardForwardListCount(int32_t& count)
3433 count = m_backForwardList->forwardListCount();
3436 void WebPageProxy::editorStateChanged(const EditorState& editorState)
3439 bool couldChangeSecureInputState = m_editorState.isInPasswordField != editorState.isInPasswordField || m_editorState.selectionIsNone;
3441 #if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
3442 bool closedComposition = !editorState.shouldIgnoreCompositionSelectionChange && !editorState.hasComposition && (m_editorState.hasComposition || m_temporarilyClosedComposition);
3443 m_temporarilyClosedComposition = editorState.shouldIgnoreCompositionSelectionChange && (m_temporarilyClosedComposition || m_editorState.hasComposition) && !editorState.hasComposition;
3446 m_editorState = editorState;
3449 // Selection being none is a temporary state when editing. Flipping secure input state too quickly was causing trouble (not fully understood).
3450 if (couldChangeSecureInputState && !editorState.selectionIsNone)
3451 m_pageClient.updateSecureInputState();
3454 if (editorState.shouldIgnoreCompositionSelectionChange)
3457 #if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
3458 if (closedComposition)
3459 m_pageClient.notifyInputContextAboutDiscardedComposition();
3460 if (editorState.hasComposition) {
3461 // Abandon the current inline input session if selection changed for any other reason but an input method changing the composition.
3462 // FIXME: This logic should be in WebCore, no need to round-trip to UI process to cancel the composition.
3463 cancelComposition();
3464 m_pageClient.notifyInputContextAboutDiscardedComposition();
3467 // We always need to notify the client on iOS to make sure the selection is redrawn,
3468 // even during composition to support phrase boundary gesture.
3469 notifyRevealedSelection();
3470 #elif PLATFORM(EFL) || PLATFORM(GTK)
3471 m_pageClient.updateTextInputState();
3475 void WebPageProxy::compositionWasCanceled(const EditorState& editorState)
3478 m_pageClient.notifyInputContextAboutDiscardedComposition();
3480 editorStateChanged(editorState);
3485 void WebPageProxy::registerEditCommandForUndo(uint64_t commandID, uint32_t editAction)
3487 registerEditCommand(WebEditCommandProxy::create(commandID, static_cast<EditAction>(editAction), this), Undo);
3490 void WebPageProxy::registerInsertionUndoGrouping()
3492 #if USE(INSERTION_UNDO_GROUPING)
3493 m_pageClient.registerInsertionUndoGrouping();
3497 void WebPageProxy::canUndoRedo(uint32_t action, bool& result)
3499 result = m_pageClient.canUndoRedo(static_cast<UndoOrRedo>(action));
3502 void WebPageProxy::executeUndoRedo(uint32_t action, bool& result)
3504 m_pageClient.executeUndoRedo(static_cast<UndoOrRedo>(action));
3508 void WebPageProxy::clearAllEditCommands()
3510 m_pageClient.clearAllEditCommands();
3513 void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCount)
3515 m_findClient->didCountStringMatches(this, string, matchCount);
3518 void WebPageProxy::didGetImageForFindMatch(const ShareableBitmap::Handle& contentImageHandle, uint32_t matchIndex)
3520 m_findMatchesClient.didGetImageForMatchResult(this, WebImage::create(ShareableBitmap::create(contentImageHandle)).get(), matchIndex);
3523 void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut, bool animate)
3525 RefPtr<FindIndicator> findIndicator = FindIndicator::create(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageScaleFactor, contentImageHandle);
3526 m_pageClient.setFindIndicator(findIndicator.release(), fadeOut, animate);
3529 void WebPageProxy::didFindString(const String& string, uint32_t matchCount, int32_t matchIndex)
3531 m_findClient->didFindString(this, string, matchCount, matchIndex);
3534 void WebPageProxy::didFindStringMatches(const String& string, const Vector<Vector<WebCore::IntRect>>& matchRects, int32_t firstIndexAfterSelection)
3536 Vector<RefPtr<API::Object>> matches;
3537 matches.reserveInitialCapacity(matchRects.size());
3539 for (const auto& rects : matchRects) {
3540 Vector<RefPtr<API::Object>> apiRects;
3541 apiRects.reserveInitialCapacity(rects.size());
3543 for (const auto& rect : rects)
3544 apiRects.uncheckedAppend(API::Rect::create(toAPI(rect)));
3546 matches.uncheckedAppend(API::Array::create(WTF::move(apiRects)));
3549 m_findMatchesClient.didFindStringMatches(this, string, API::Array::create(WTF::move(matches)).get(), firstIndexAfterSelection);
3552 void WebPageProxy::didFailToFindString(const String& string)
3554 m_findClient->didFailToFindString(this, string);
3557 bool WebPageProxy::sendMessage(std::unique_ptr<IPC::MessageEncoder> encoder, unsigned messageSendFlags)
3559 return m_process->sendMessage(WTF::move(encoder), messageSendFlags);
3562 IPC::Connection* WebPageProxy::messageSenderConnection()
3564 return m_process->connection();
3567 uint64_t WebPageProxy::messageSenderDestinationID()
3572 void WebPageProxy::valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex)
3574 m_process->send(Messages::WebPage::DidChangeSelectedIndexForActivePopupMenu(newSelectedIndex), m_pageID);
3577 void WebPageProxy::setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index)
3579 m_process->send(Messages::WebPage::SetTextForActivePopupMenu(index), m_pageID);
3582 NativeWebMouseEvent* WebPageProxy::currentlyProcessedMouseDownEvent()
3584 return m_currentlyProcessedMouseDownEvent.get();
3587 void WebPageProxy::postMessageToInjectedBundle(const String& messageName, API::Object* messageBody)
3589 process().send(Messages::WebPage::PostInjectedBundleMessage(messageName, WebContextUserMessageEncoder(messageBody, process())), m_pageID);
3593 void WebPageProxy::failedToShowPopupMenu()
3595 m_process->send(Messages::WebPage::FailedToShowPopupMenu(), m_pageID);
3599 void WebPageProxy::showPopupMenu(const IntRect& rect, uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData& data)
3601 if (m_activePopupMenu) {
3603 m_uiPopupMenuClient.hidePopupMenu(this);
3605 m_activePopupMenu->hidePopupMenu();
3607 m_activePopupMenu->invalidate();
3608 m_activePopupMenu = 0;
3611 m_activePopupMenu = m_pageClient.createPopupMenuProxy(this);
3613 if (!m_activePopupMenu)
3616 // Since showPopupMenu() can spin a nested run loop we need to turn off the responsiveness timer.
3617 m_process->responsivenessTimer()->stop();
3621 m_uiPopupMenuClient.showPopupMenu(this, m_activePopupMenu.get(), rect, static_cast<TextDirection>(textDirection), m_pageScaleFactor, items, selectedIndex);
3623 RefPtr<WebPopupMenuProxy> protectedActivePopupMenu = m_activePopupMenu;
3625 protectedActivePopupMenu->showPopupMenu(rect, static_cast<TextDirection>(textDirection), m_pageScaleFactor, items, data, selectedIndex);
3627 // Since Efl doesn't use a nested mainloop to show the popup and get the answer, we need to keep the client pointer valid.
3628 // FIXME: The above comment doesn't make any sense since this code is compiled out for EFL.
3629 protectedActivePopupMenu->invalidate();
3630 protectedActivePopupMenu = 0;
3634 void WebPageProxy::hidePopupMenu()
3636 if (!m_activePopupMenu)
3640 m_uiPopupMenuClient.hidePopupMenu(this);
3642 m_activePopupMenu->hidePopupMenu();
3644 m_activePopupMenu->invalidate();