Skip to content

Commit

Permalink
Revert 267124@main
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260563

Unreviewed.

It caused mouse event issues, especially on Windows.

* Source/WebCore/page/LocalFrame.cpp:
(WebCore::LocalFrame::LocalFrame):
* Source/WebCore/page/LocalFrame.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::Page):
* Source/WebCore/page/Page.h:
(WebCore::Page::userInputBridge):
* Source/WebCore/replay/UserInputBridge.cpp:
(WebCore::UserInputBridge::UserInputBridge):
(WebCore::UserInputBridge::handleContextMenuEvent):
(WebCore::UserInputBridge::handleMousePressEvent):
(WebCore::UserInputBridge::handleMouseReleaseEvent):
(WebCore::UserInputBridge::handleMouseMoveEvent):
(WebCore::UserInputBridge::handleMouseMoveOnScrollbarEvent):
(WebCore::UserInputBridge::handleMouseForceEvent):
(WebCore::UserInputBridge::handleKeyEvent):
(WebCore::UserInputBridge::handleAccessKeyEvent):
(WebCore::UserInputBridge::handleWheelEvent):
(WebCore::UserInputBridge::focusSetActive):
(WebCore::UserInputBridge::focusSetFocused):
(WebCore::UserInputBridge::scrollRecursively):
(WebCore::UserInputBridge::logicalScrollRecursively):
(WebCore::UserInputBridge::loadRequest):
(WebCore::UserInputBridge::reloadFrame):
(WebCore::UserInputBridge::stopLoadingFrame):
(WebCore::UserInputBridge::tryClosePage):
* Source/WebCore/replay/UserInputBridge.h:
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::processNextQueuedMouseEvent):
(WebKit::WebPageProxy::dispatchWheelEventWithoutScrolling):
(WebKit::WebPageProxy::sendWheelEvent):
(WebKit::WebPageProxy::handleKeyboardEvent):
(WebKit::WebPageProxy::didReceiveEvent):
* Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageCopyContextMenuAtPointInWindow):
* Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::dispatchWheelEvent):
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::isContextClick): Deleted.
(WebKit::WebFrame::handleContextMenuEvent): Deleted.
(WebKit::WebFrame::handleMouseEvent): Deleted.
(WebKit::WebFrame::handleKeyEvent): Deleted.
* Source/WebKit/WebProcess/WebPage/WebFrame.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::tryClose):
(WebKit::WebPage::loadRequest):
(WebKit::WebPage::stopLoading):
(WebKit::WebPage::reload):
(WebKit::WebPage::contextMenuAtPointInWindow):
(WebKit::isContextClick):
(WebKit::handleContextMenuEvent):
(WebKit::handleMouseEvent):
(WebKit::WebPage::mouseEvent):
(WebKit::WebPage::handleWheelEvent):
(WebKit::WebPage::wheelEvent):
(WebKit::WebPage::dispatchWheelEventWithoutScrolling):
(WebKit::handleKeyEvent):
(WebKit::WebPage::keyEvent):
(WebKit::WebPage::scroll):
(WebKit::WebPage::logicalScroll):
(WebKit::WebPage::simulateMouseDown):
(WebKit::WebPage::simulateMouseUp):
(WebKit::WebPage::simulateMouseMotion):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

Canonical link: https://commits.webkit.org/267171@main
  • Loading branch information
achristensen07 committed Aug 23, 2023
1 parent 81b47f7 commit b4e7bc6
Show file tree
Hide file tree
Showing 14 changed files with 199 additions and 241 deletions.
2 changes: 0 additions & 2 deletions Source/WebCore/page/LocalFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
#include "UserContentController.h"
#include "UserContentURLPattern.h"
#include "UserGestureIndicator.h"
#include "UserInputBridge.h"
#include "UserScript.h"
#include "UserTypingGestureIndicator.h"
#include "VisibleUnits.h"
Expand Down Expand Up @@ -156,7 +155,6 @@ LocalFrame::LocalFrame(Page& page, UniqueRef<LocalFrameLoaderClient>&& frameLoad
, m_pageZoomFactor(parentPageZoomFactor(this))
, m_textZoomFactor(parentTextZoomFactor(this))
, m_eventHandler(makeUniqueRef<EventHandler>(*this))
, m_userInputBridge(makeUniqueRef<UserInputBridge>(*this))
{
ProcessWarming::initializeNames();
StaticCSSValuePool::init();
Expand Down
4 changes: 0 additions & 4 deletions Source/WebCore/page/LocalFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class RenderView;
class RenderWidget;
class ScriptController;
class SecurityOrigin;
class UserInputBridge;
class VisiblePosition;
class Widget;

Expand Down Expand Up @@ -286,8 +285,6 @@ class LocalFrame final : public Frame {

WEBCORE_EXPORT bool arePluginsEnabled();

UserInputBridge& userInputBridge() { return m_userInputBridge.get(); }

private:
friend class NavigationDisabler;

Expand Down Expand Up @@ -345,7 +342,6 @@ class LocalFrame final : public Frame {
FloatSize m_overrideScreenSize;

UniqueRef<EventHandler> m_eventHandler;
UniqueRef<UserInputBridge> m_userInputBridge;
};

inline LocalFrameView* LocalFrame::view() const
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/page/Page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
#include "TextResourceDecoder.h"
#include "UserContentProvider.h"
#include "UserContentURLPattern.h"
#include "UserInputBridge.h"
#include "UserScript.h"
#include "UserStyleSheet.h"
#include "ValidationMessageClient.h"
Expand Down Expand Up @@ -293,6 +294,7 @@ Page::Page(PageConfiguration&& pageConfiguration)
#if ENABLE(CONTEXT_MENUS)
, m_contextMenuController(makeUniqueRef<ContextMenuController>(*this, WTFMove(pageConfiguration.contextMenuClient)))
#endif
, m_userInputBridge(makeUniqueRef<UserInputBridge>(*this))
, m_inspectorController(makeUniqueRef<InspectorController>(*this, WTFMove(pageConfiguration.inspectorClient)))
, m_pointerCaptureController(makeUniqueRef<PointerCaptureController>(*this))
#if ENABLE(POINTER_LOCK)
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/page/Page.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class StorageNamespaceProvider;
class StorageProvider;
class UserContentProvider;
class UserContentURLPattern;
class UserInputBridge;
class UserScript;
class UserStyleSheet;
class ValidationMessageClient;
Expand Down Expand Up @@ -375,6 +376,7 @@ class Page : public Supplementable<Page>, public CanMakeWeakPtr<Page> {
ContextMenuController& contextMenuController() { return m_contextMenuController.get(); }
const ContextMenuController& contextMenuController() const { return m_contextMenuController.get(); }
#endif
UserInputBridge& userInputBridge() { return m_userInputBridge.get(); }
InspectorController& inspectorController() { return m_inspectorController.get(); }
PointerCaptureController& pointerCaptureController() { return m_pointerCaptureController.get(); }
#if ENABLE(POINTER_LOCK)
Expand Down Expand Up @@ -1117,6 +1119,7 @@ class Page : public Supplementable<Page>, public CanMakeWeakPtr<Page> {
#if ENABLE(CONTEXT_MENUS)
UniqueRef<ContextMenuController> m_contextMenuController;
#endif
UniqueRef<UserInputBridge> m_userInputBridge;
UniqueRef<InspectorController> m_inspectorController;
UniqueRef<PointerCaptureController> m_pointerCaptureController;
#if ENABLE(POINTER_LOCK)
Expand Down
78 changes: 42 additions & 36 deletions Source/WebCore/replay/UserInputBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,117 +41,123 @@

namespace WebCore {

UserInputBridge::UserInputBridge(LocalFrame& frame)
: m_frame(frame)
UserInputBridge::UserInputBridge(Page& page)
: m_page(page)
{
}

#if ENABLE(CONTEXT_MENU_EVENT)
bool UserInputBridge::handleContextMenuEvent(const PlatformMouseEvent& mouseEvent, InputSource)
bool UserInputBridge::handleContextMenuEvent(const PlatformMouseEvent& mouseEvent, LocalFrame& frame, InputSource)
{
return m_frame.eventHandler().sendContextMenuEvent(mouseEvent);
return frame.eventHandler().sendContextMenuEvent(mouseEvent);
}
#endif

bool UserInputBridge::handleMousePressEvent(const PlatformMouseEvent& mouseEvent, InputSource)
{
return m_frame.eventHandler().handleMousePressEvent(mouseEvent);
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return false;
return Ref(*localMainFrame)->eventHandler().handleMousePressEvent(mouseEvent);
}

bool UserInputBridge::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent, InputSource)
{
return m_frame.eventHandler().handleMouseReleaseEvent(mouseEvent);
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return false;
return Ref(*localMainFrame)->eventHandler().handleMouseReleaseEvent(mouseEvent);
}

bool UserInputBridge::handleMouseMoveEvent(const PlatformMouseEvent& mouseEvent, InputSource)
{
return m_frame.eventHandler().mouseMoved(mouseEvent);
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return false;
return Ref(*localMainFrame)->eventHandler().mouseMoved(mouseEvent);
}

bool UserInputBridge::handleMouseMoveOnScrollbarEvent(const PlatformMouseEvent& mouseEvent, InputSource)
{
return m_frame.eventHandler().passMouseMovedEventToScrollbars(mouseEvent);
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return false;
return Ref(*localMainFrame)->eventHandler().passMouseMovedEventToScrollbars(mouseEvent);
}

bool UserInputBridge::handleMouseForceEvent(const PlatformMouseEvent& mouseEvent, InputSource)
{
return m_frame.eventHandler().handleMouseForceEvent(mouseEvent);
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return false;
return Ref(*localMainFrame)->eventHandler().handleMouseForceEvent(mouseEvent);
}

bool UserInputBridge::handleKeyEvent(const PlatformKeyboardEvent& keyEvent, InputSource)
{
return m_frame.eventHandler().keyEvent(keyEvent);
return Ref(m_page.focusController().focusedOrMainFrame())->eventHandler().keyEvent(keyEvent);
}

bool UserInputBridge::handleAccessKeyEvent(const PlatformKeyboardEvent& keyEvent, InputSource)
{
return m_frame.eventHandler().handleAccessKey(keyEvent);
return Ref(m_page.focusController().focusedOrMainFrame())->eventHandler().handleAccessKey(keyEvent);
}

bool UserInputBridge::handleWheelEvent(const PlatformWheelEvent& wheelEvent, OptionSet<WheelEventProcessingSteps> processingSteps, InputSource)
{
return m_frame.eventHandler().handleWheelEvent(wheelEvent, processingSteps);
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return false;
return Ref(*localMainFrame)->eventHandler().handleWheelEvent(wheelEvent, processingSteps);
}

void UserInputBridge::focusSetActive(bool active, InputSource)
{
auto* page = m_frame.page();
if (!page)
return;
page->focusController().setActive(active);
m_page.focusController().setActive(active);
}

void UserInputBridge::focusSetFocused(bool focused, InputSource)
{
auto* page = m_frame.page();
if (!page)
return;
page->focusController().setFocused(focused);
m_page.focusController().setFocused(focused);
}

bool UserInputBridge::scrollRecursively(ScrollDirection direction, ScrollGranularity granularity, InputSource)
{
return Ref(m_frame)->eventHandler().scrollRecursively(direction, granularity, nullptr);
return Ref(m_page.focusController().focusedOrMainFrame())->eventHandler().scrollRecursively(direction, granularity, nullptr);
}

bool UserInputBridge::logicalScrollRecursively(ScrollLogicalDirection direction, ScrollGranularity granularity, InputSource)
{
return Ref(m_frame)->eventHandler().logicalScrollRecursively(direction, granularity, nullptr);
return Ref(m_page.focusController().focusedOrMainFrame())->eventHandler().logicalScrollRecursively(direction, granularity, nullptr);
}

void UserInputBridge::loadRequest(FrameLoadRequest&& request, InputSource)
{
auto* page = m_frame.page();
if (!page)
return;
#if ENABLE(WEB_AUTHN)
page->authenticatorCoordinator().resetUserGestureRequirement();
m_page.authenticatorCoordinator().resetUserGestureRequirement();
#endif
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_frame.mainFrame());
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return;
Ref(*localMainFrame)->loader().load(WTFMove(request));
}

void UserInputBridge::reloadFrame(OptionSet<ReloadOption> options, InputSource)
void UserInputBridge::reloadFrame(LocalFrame& frame, OptionSet<ReloadOption> options, InputSource)
{
#if ENABLE(WEB_AUTHN)
auto page = m_frame.page();
if (!page)
return;
page->authenticatorCoordinator().resetUserGestureRequirement();
m_page.authenticatorCoordinator().resetUserGestureRequirement();
#endif
m_frame.loader().reload(options);
frame.loader().reload(options);
}

void UserInputBridge::stopLoadingFrame(InputSource)
void UserInputBridge::stopLoadingFrame(LocalFrame& frame, InputSource)
{
m_frame.loader().stopForUserCancel();
frame.loader().stopForUserCancel();
}

bool UserInputBridge::tryClosePage(InputSource)
{
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_frame.mainFrame());
auto* localMainFrame = dynamicDowncast<LocalFrame>(m_page.mainFrame());
if (!localMainFrame)
return false;
return Ref(*localMainFrame)->loader().shouldClose();
Expand Down
11 changes: 6 additions & 5 deletions Source/WebCore/replay/UserInputBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace WebCore {

class FrameLoadRequest;
class LocalFrame;
class Page;
class PlatformKeyboardEvent;
class PlatformMouseEvent;
class PlatformWheelEvent;
Expand All @@ -54,11 +55,11 @@ class UserInputBridge {
WTF_MAKE_FAST_ALLOCATED;
WTF_MAKE_NONCOPYABLE(UserInputBridge);
public:
UserInputBridge(LocalFrame&);
UserInputBridge(Page&);

// User input APIs.
#if ENABLE(CONTEXT_MENU_EVENT)
WEBCORE_EXPORT bool handleContextMenuEvent(const PlatformMouseEvent&, InputSource = InputSource::User);
WEBCORE_EXPORT bool handleContextMenuEvent(const PlatformMouseEvent&, LocalFrame&, InputSource = InputSource::User);
#endif
WEBCORE_EXPORT bool handleMousePressEvent(const PlatformMouseEvent&, InputSource = InputSource::User);
WEBCORE_EXPORT bool handleMouseReleaseEvent(const PlatformMouseEvent&, InputSource = InputSource::User);
Expand All @@ -75,12 +76,12 @@ class UserInputBridge {

// Navigation APIs.
WEBCORE_EXPORT void loadRequest(FrameLoadRequest&&, InputSource = InputSource::User);
WEBCORE_EXPORT void reloadFrame(OptionSet<ReloadOption>, InputSource = InputSource::User);
WEBCORE_EXPORT void stopLoadingFrame(InputSource = InputSource::User);
WEBCORE_EXPORT void reloadFrame(LocalFrame&, OptionSet<ReloadOption>, InputSource = InputSource::User);
WEBCORE_EXPORT void stopLoadingFrame(LocalFrame&, InputSource = InputSource::User);
WEBCORE_EXPORT bool tryClosePage(InputSource = InputSource::User);

private:
LocalFrame& m_frame;
Page& m_page;
};

} // namespace WebCore
27 changes: 6 additions & 21 deletions Source/WebKit/UIProcess/WebPageProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3244,9 +3244,6 @@ void WebPageProxy::processNextQueuedMouseEvent()
if (!hasRunningProcess())
return;

if (!m_mainFrame)
return;

ASSERT(!internals().mouseEventQueue.isEmpty());

const NativeWebMouseEvent& event = internals().mouseEventQueue.first();
Expand All @@ -3272,7 +3269,7 @@ void WebPageProxy::processNextQueuedMouseEvent()

LOG_WITH_STREAM(MouseHandling, stream << "UIProcess: sent mouse event " << eventType << " (queue size " << internals().mouseEventQueue.size() << ")");
m_process->recordUserGestureAuthorizationToken(event.authorizationToken());
send(Messages::WebPage::MouseEvent(m_mainFrame->frameID(), event, sandboxExtensions));
send(Messages::WebPage::MouseEvent(event, sandboxExtensions));
}

void WebPageProxy::doAfterProcessingAllPendingMouseEvents(WTF::Function<void ()>&& action)
Expand Down Expand Up @@ -3301,11 +3298,7 @@ void WebPageProxy::flushPendingMouseEventCallbacks()
#if PLATFORM(IOS_FAMILY)
void WebPageProxy::dispatchWheelEventWithoutScrolling(const WebWheelEvent& event, CompletionHandler<void(bool)>&& completionHandler)
{
if (!m_mainFrame) {
completionHandler(false);
return;
}
sendWithAsyncReply(Messages::WebPage::DispatchWheelEventWithoutScrolling(m_mainFrame->frameID(), event), WTFMove(completionHandler));
sendWithAsyncReply(Messages::WebPage::DispatchWheelEventWithoutScrolling(event), WTFMove(completionHandler));
}
#endif

Expand Down Expand Up @@ -3367,14 +3360,11 @@ void WebPageProxy::sendWheelEvent(const WebWheelEvent& event, OptionSet<WheelEve
if (!connection)
return;

if (!m_mainFrame)
return;

if (drawingArea()->shouldSendWheelEventsToEventDispatcher()) {
sendWheelEventScrollingAccelerationCurveIfNecessary(event);
connection->send(Messages::EventDispatcher::WheelEvent(webPageID(), event, rubberBandableEdges), 0, { }, Thread::QOS::UserInteractive);
} else {
sendWithAsyncReply(Messages::WebPage::HandleWheelEvent(m_mainFrame->frameID(), event, processingSteps, willStartSwipe), [weakThis = WeakPtr { *this }, wheelEvent = event, wasHandledForScrolling](ScrollingNodeID nodeID, std::optional<WheelScrollGestureState> gestureState, bool handled) {
sendWithAsyncReply(Messages::WebPage::HandleWheelEvent(event, processingSteps, willStartSwipe), [weakThis = WeakPtr { *this }, wheelEvent = event, wasHandledForScrolling](ScrollingNodeID nodeID, std::optional<WheelScrollGestureState> gestureState, bool handled) {
RefPtr protectedThis = weakThis.get();
if (!protectedThis)
return;
Expand Down Expand Up @@ -3523,11 +3513,6 @@ bool WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
if (!hasRunningProcess())
return false;

if (!m_mainFrame) {
m_uiClient->didNotHandleKeyEvent(this, event);
return false;
}

LOG_WITH_STREAM(KeyHandling, stream << "WebPageProxy::handleKeyboardEvent: " << event.type());

internals().keyEventQueue.append(event);
Expand All @@ -3538,7 +3523,7 @@ bool WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
if (internals().keyEventQueue.size() == 1) {
LOG(KeyHandling, " UI process: sent keyEvent from handleKeyboardEvent");
m_process->recordUserGestureAuthorizationToken(event.authorizationToken());
send(Messages::WebPage::KeyEvent(m_mainFrame->frameID(), event));
send(Messages::WebPage::KeyEvent(event));
}

return true;
Expand Down Expand Up @@ -8555,11 +8540,11 @@ void WebPageProxy::didReceiveEvent(WebEventType eventType, bool handled)
#endif

bool canProcessMoreKeyEvents = !internals().keyEventQueue.isEmpty();
if (canProcessMoreKeyEvents && m_mainFrame) {
if (canProcessMoreKeyEvents) {
auto nextEvent = internals().keyEventQueue.first();
LOG(KeyHandling, " UI process: sent keyEvent from didReceiveEvent");
m_process->recordUserGestureAuthorizationToken(nextEvent.authorizationToken());
send(Messages::WebPage::KeyEvent(m_mainFrame->frameID(), internals().keyEventQueue.first()));
send(Messages::WebPage::KeyEvent(internals().keyEventQueue.first()));
}

// The call to doneWithKeyEvent may close this WebPage.
Expand Down
10 changes: 1 addition & 9 deletions Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,7 @@ WKArrayRef WKBundlePageCopyContextMenuItems(WKBundlePageRef pageRef)
WKArrayRef WKBundlePageCopyContextMenuAtPointInWindow(WKBundlePageRef pageRef, WKPoint point)
{
#if ENABLE(CONTEXT_MENUS)
WebCore::Page* page = WebKit::toImpl(pageRef)->corePage();
if (!page)
return nullptr;

auto* localMainFrame = dynamicDowncast<WebCore::LocalFrame>(page->mainFrame());
if (!localMainFrame)
return nullptr;

WebKit::WebContextMenu* contextMenu = WebKit::toImpl(pageRef)->contextMenuAtPointInWindow(localMainFrame->frameID(), WebKit::toIntPoint(point));
WebKit::WebContextMenu* contextMenu = WebKit::toImpl(pageRef)->contextMenuAtPointInWindow(WebKit::toIntPoint(point));
if (!contextMenu)
return nullptr;

Expand Down
4 changes: 1 addition & 3 deletions Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ void EventDispatcher::dispatchWheelEvent(PageIdentifier pageID, const WebWheelEv
if (!webPage)
return;

bool handled = false;
if (webPage->mainFrame())
handled = webPage->wheelEvent(webPage->mainFrame()->frameID(), wheelEvent, processingSteps, wheelEventOrigin);
bool handled = webPage->wheelEvent(wheelEvent, processingSteps, wheelEventOrigin);

if (processingSteps.contains(WheelEventProcessingSteps::SynchronousScrolling) && wheelEventOrigin == EventDispatcher::WheelEventOrigin::UIProcess)
sendDidReceiveEvent(pageID, wheelEvent.type(), handled);
Expand Down
Loading

0 comments on commit b4e7bc6

Please sign in to comment.