haikuwebkit/Source/WebCore/dom/PointerEventTypeNames.cpp

53 lines
1.9 KiB
C++
Raw Permalink Normal View History

WebMouseEvent.h should avoid pulling in WebCore headers that know about DOM nodes https://bugs.webkit.org/show_bug.cgi?id=222291 Reviewed by Darin Adler. Source/WebCore: Refactor `PointerEvent.h` so that the static class helper methods for getting the names of mouse, pen and touch pointer event types are instead separate functions in `PointerEventTypeNames.h`. This allows us to just import `PointerEventTypeNames.h` instead of `PointerEvent.h` in WebKit -- and, in particular, within WebKit headers that are exclusive to the UI process. No change in behavior. * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/PointerEvent.cpp: (WebCore::PointerEvent::mousePointerType): Deleted. (WebCore::PointerEvent::penPointerType): Deleted. (WebCore::PointerEvent::touchPointerType): Deleted. * dom/PointerEvent.h: Drive-by fix: also forward declare `Node` instead of including `Node.h`; `WebCore::Node` is only used in this header in the context of `RefPtr<Node>`, so the forward declaration is sufficient. * dom/PointerEventTypeNames.cpp: Added. (WebCore::mousePointerEventType): (WebCore::penPointerEventType): (WebCore::touchPointerEventType): * dom/PointerEventTypeNames.h: Added. * dom/ios/PointerEventIOS.cpp: * page/PointerCaptureController.cpp: (WebCore::PointerCaptureController::reset): (WebCore::PointerCaptureController::pointerEventForMouseEvent): (WebCore::PointerCaptureController::dispatchEvent): (WebCore::PointerCaptureController::pointerEventWillBeDispatched): (WebCore::PointerCaptureController::pointerEventWasDispatched): (WebCore::PointerCaptureController::processPendingPointerCapture): Source/WebKit: Import `PointerEventTypeNames.h` instead of `PointerEvent.h` in several UI process and shared headers. * Shared/WebMouseEvent.h: * UIProcess/API/gtk/WebKitWebViewBase.cpp: (primaryPointerForType): (webkitWebViewBaseSynthesizeMouseEvent): * UIProcess/Automation/SimulatedInputDispatcher.cpp: (WebKit::SimulatedInputDispatcher::transitionInputSourceToState): * UIProcess/Automation/WebAutomationSession.cpp: (WebKit::WebAutomationSession::performMouseInteraction): * UIProcess/gtk/PointerLockManager.cpp: (WebKit::PointerLockManager::handleMotion): Canonical link: https://commits.webkit.org/234456@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273296 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-23 03:16:32 +00:00
/*
* Copyright (C) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "PointerEventTypeNames.h"
#include <wtf/NeverDestroyed.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
const String& mousePointerEventType()
{
static NeverDestroyed<const String> mouseType(MAKE_STATIC_STRING_IMPL("mouse"));
return mouseType;
}
const String& penPointerEventType()
{
static NeverDestroyed<const String> penType(MAKE_STATIC_STRING_IMPL("pen"));
return penType;
}
const String& touchPointerEventType()
{
static NeverDestroyed<const String> touchType(MAKE_STATIC_STRING_IMPL("touch"));
return touchType;
}
} // namespace WebCore