haikuwebkit/Source/WebCore/page/PopupOpeningObserver.h

39 lines
1.5 KiB
C
Raw Permalink Normal View History

A Spin button should release mouse event capturing when a modal dialog opens https://bugs.webkit.org/show_bug.cgi?id=98007 Reviewed by Hajime Morita. Description of bug: If the mouse left button is pressed on a spin button in input[type=number] and a 'change' event handler opens a modal dialog such as alert(), a repeating timer doesn't stop and mouse event capturing isn't released even though the mouse pointer isn't on the spin button. A user will see repeating alert dialogs for a document like <input type=number value=1 onchange="if (this.value==1) {alert(...); this.value=1;}"> by clicking the up button. How to solve: We should notify modal dialog or popup open to a spin button. This patch introduce PopupOpeningObserver. Chrome notifies it when any dialogs / popups is opening. SpinButtonElement implements PopupOpeningObserver and registers/unregisters itself to/from Chrome. No new tests. This is a behavior change, but it's very hard to make an automated test for timer-related behavior. * page/PopupOpeningObserver.h: Added. * GNUmakefile.list.am: Add PopupOpeningObserver.h * Target.pri: Ditto. * WebCore.gypi: Ditto. * WebCore.vcproj/WebCore.vcproj: Ditto. * WebCore.xcodeproj/project.pbxproj: Ditto. * page/Chrome.cpp: (WebCore::Chrome::runJavaScriptAlert): Calls notifyPopupOpeningObservers. (WebCore::Chrome::runJavaScriptConfirm): Ditto. (WebCore::Chrome::runJavaScriptPrompt): Ditto. (WebCore::Chrome::createColorChooser): Ditto. (WebCore::Chrome::openDateTimeChooser): Added. Calls notifyPopupOpeningObservers before calling ChromeClient::openDateTimeChooser. (WebCore::Chrome::runOpenPanel): Calls notifyPopupOpeningObservers. (WebCore::Chrome::createPopupMenu): Ditto. (WebCore::Chrome::createSearchPopupMenu): Ditto. (WebCore::Chrome::registerPopupOpeningObserver): Added. (WebCore::Chrome::unregisterPopupOpeningObserver): Added. (WebCore::Chrome::notifyPopupOpeningObservers): Added. * page/Chrome.h: Added new members and required class/struct declarations. * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::handleDOMActivateEvent): Use Chrome::openDateTimeChooser instead of ChromeClient::openDateTimeChooser. * html/shadow/PickerIndicatorElement.cpp: (WebCore::PickerIndicatorElement::openPopup): Ditto. * html/shadow/SpinButtonElement.h: (SpinButtonElement): Declare willOpenPopup. * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::defaultEventHandler): Change the order of timer start and changing the value so that we can cancel the timer correctly. Calls Chrome::registerPopupOpeningObserver on starting mouse capturing. (WebCore::SpinButtonElement::willOpenPopup): Release mouse event capturing before opening a modal dialog. (WebCore::SpinButtonElement::releaseCapture): Calls Chrome::unregisterPopupOpeningObserver. Canonical link: https://commits.webkit.org/120581@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134886 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-11-16 04:30:07 +00:00
/*
* Copyright (C) 2012 Google 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.
*/
#pragma once
A Spin button should release mouse event capturing when a modal dialog opens https://bugs.webkit.org/show_bug.cgi?id=98007 Reviewed by Hajime Morita. Description of bug: If the mouse left button is pressed on a spin button in input[type=number] and a 'change' event handler opens a modal dialog such as alert(), a repeating timer doesn't stop and mouse event capturing isn't released even though the mouse pointer isn't on the spin button. A user will see repeating alert dialogs for a document like <input type=number value=1 onchange="if (this.value==1) {alert(...); this.value=1;}"> by clicking the up button. How to solve: We should notify modal dialog or popup open to a spin button. This patch introduce PopupOpeningObserver. Chrome notifies it when any dialogs / popups is opening. SpinButtonElement implements PopupOpeningObserver and registers/unregisters itself to/from Chrome. No new tests. This is a behavior change, but it's very hard to make an automated test for timer-related behavior. * page/PopupOpeningObserver.h: Added. * GNUmakefile.list.am: Add PopupOpeningObserver.h * Target.pri: Ditto. * WebCore.gypi: Ditto. * WebCore.vcproj/WebCore.vcproj: Ditto. * WebCore.xcodeproj/project.pbxproj: Ditto. * page/Chrome.cpp: (WebCore::Chrome::runJavaScriptAlert): Calls notifyPopupOpeningObservers. (WebCore::Chrome::runJavaScriptConfirm): Ditto. (WebCore::Chrome::runJavaScriptPrompt): Ditto. (WebCore::Chrome::createColorChooser): Ditto. (WebCore::Chrome::openDateTimeChooser): Added. Calls notifyPopupOpeningObservers before calling ChromeClient::openDateTimeChooser. (WebCore::Chrome::runOpenPanel): Calls notifyPopupOpeningObservers. (WebCore::Chrome::createPopupMenu): Ditto. (WebCore::Chrome::createSearchPopupMenu): Ditto. (WebCore::Chrome::registerPopupOpeningObserver): Added. (WebCore::Chrome::unregisterPopupOpeningObserver): Added. (WebCore::Chrome::notifyPopupOpeningObservers): Added. * page/Chrome.h: Added new members and required class/struct declarations. * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::handleDOMActivateEvent): Use Chrome::openDateTimeChooser instead of ChromeClient::openDateTimeChooser. * html/shadow/PickerIndicatorElement.cpp: (WebCore::PickerIndicatorElement::openPopup): Ditto. * html/shadow/SpinButtonElement.h: (SpinButtonElement): Declare willOpenPopup. * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::defaultEventHandler): Change the order of timer start and changing the value so that we can cancel the timer correctly. Calls Chrome::registerPopupOpeningObserver on starting mouse capturing. (WebCore::SpinButtonElement::willOpenPopup): Release mouse event capturing before opening a modal dialog. (WebCore::SpinButtonElement::releaseCapture): Calls Chrome::unregisterPopupOpeningObserver. Canonical link: https://commits.webkit.org/120581@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134886 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-11-16 04:30:07 +00:00
namespace WebCore {
class PopupOpeningObserver {
public:
virtual void willOpenPopup() = 0;
protected:
Use "= default" to denote default constructor or destructor https://bugs.webkit.org/show_bug.cgi?id=178528 Rubber-stamped by Andy Estes. Source/WebCore: * Modules/airplay/WebKitPlaybackTargetAvailabilityEvent.h: * Modules/applepay/ApplePayError.cpp: * Modules/applepay/ApplePayPaymentAuthorizedEvent.cpp: * Modules/applepay/ApplePayPaymentMethodSelectedEvent.cpp: * Modules/applepay/ApplePaySession.cpp: * Modules/applepay/ApplePaySessionPaymentRequest.cpp: * Modules/applepay/ApplePayShippingContactSelectedEvent.cpp: * Modules/applepay/ApplePayShippingMethodSelectedEvent.cpp: * Modules/applepay/ApplePayValidateMerchantEvent.cpp: * Modules/applepay/Payment.h: * Modules/applepay/PaymentCoordinatorClient.h: * Modules/credentials/BasicCredential.cpp: * Modules/credentials/FederatedCredential.cpp: * Modules/credentials/NavigatorCredentials.cpp: * Modules/credentials/PasswordCredential.cpp: * Modules/encryptedmedia/CDMClient.h: * Modules/encryptedmedia/legacy/LegacyCDM.cpp: * Modules/encryptedmedia/legacy/LegacyCDM.h: * Modules/encryptedmedia/legacy/LegacyCDMPrivate.h: * Modules/encryptedmedia/legacy/LegacyCDMPrivateClearKey.h: * Modules/encryptedmedia/legacy/LegacyCDMPrivateMediaPlayer.h: * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp: * Modules/encryptedmedia/legacy/WebKitMediaKeyMessageEvent.cpp: * Modules/encryptedmedia/legacy/WebKitMediaKeyNeededEvent.cpp: * Modules/entriesapi/DOMFileSystem.cpp: * Modules/entriesapi/FileSystemDirectoryReader.cpp: * Modules/entriesapi/FileSystemEntry.cpp: * Modules/fetch/FetchLoaderClient.h: * Modules/gamepad/Gamepad.cpp: * Modules/gamepad/GamepadEvent.h: * Modules/gamepad/deprecated/Gamepad.cpp: [ truncated ] Source/WebCore/PAL: * pal/Logger.h: (PAL::Logger::Observer::~Observer): Deleted. * pal/crypto/gcrypt/CryptoDigestGCrypt.cpp: * pal/system/SleepDisabler.cpp: * pal/system/SystemSleepListener.h: Canonical link: https://commits.webkit.org/194740@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-19 23:48:45 +00:00
virtual ~PopupOpeningObserver() = default;
A Spin button should release mouse event capturing when a modal dialog opens https://bugs.webkit.org/show_bug.cgi?id=98007 Reviewed by Hajime Morita. Description of bug: If the mouse left button is pressed on a spin button in input[type=number] and a 'change' event handler opens a modal dialog such as alert(), a repeating timer doesn't stop and mouse event capturing isn't released even though the mouse pointer isn't on the spin button. A user will see repeating alert dialogs for a document like <input type=number value=1 onchange="if (this.value==1) {alert(...); this.value=1;}"> by clicking the up button. How to solve: We should notify modal dialog or popup open to a spin button. This patch introduce PopupOpeningObserver. Chrome notifies it when any dialogs / popups is opening. SpinButtonElement implements PopupOpeningObserver and registers/unregisters itself to/from Chrome. No new tests. This is a behavior change, but it's very hard to make an automated test for timer-related behavior. * page/PopupOpeningObserver.h: Added. * GNUmakefile.list.am: Add PopupOpeningObserver.h * Target.pri: Ditto. * WebCore.gypi: Ditto. * WebCore.vcproj/WebCore.vcproj: Ditto. * WebCore.xcodeproj/project.pbxproj: Ditto. * page/Chrome.cpp: (WebCore::Chrome::runJavaScriptAlert): Calls notifyPopupOpeningObservers. (WebCore::Chrome::runJavaScriptConfirm): Ditto. (WebCore::Chrome::runJavaScriptPrompt): Ditto. (WebCore::Chrome::createColorChooser): Ditto. (WebCore::Chrome::openDateTimeChooser): Added. Calls notifyPopupOpeningObservers before calling ChromeClient::openDateTimeChooser. (WebCore::Chrome::runOpenPanel): Calls notifyPopupOpeningObservers. (WebCore::Chrome::createPopupMenu): Ditto. (WebCore::Chrome::createSearchPopupMenu): Ditto. (WebCore::Chrome::registerPopupOpeningObserver): Added. (WebCore::Chrome::unregisterPopupOpeningObserver): Added. (WebCore::Chrome::notifyPopupOpeningObservers): Added. * page/Chrome.h: Added new members and required class/struct declarations. * html/BaseChooserOnlyDateAndTimeInputType.cpp: (WebCore::BaseChooserOnlyDateAndTimeInputType::handleDOMActivateEvent): Use Chrome::openDateTimeChooser instead of ChromeClient::openDateTimeChooser. * html/shadow/PickerIndicatorElement.cpp: (WebCore::PickerIndicatorElement::openPopup): Ditto. * html/shadow/SpinButtonElement.h: (SpinButtonElement): Declare willOpenPopup. * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::defaultEventHandler): Change the order of timer start and changing the value so that we can cancel the timer correctly. Calls Chrome::registerPopupOpeningObserver on starting mouse capturing. (WebCore::SpinButtonElement::willOpenPopup): Release mouse event capturing before opening a modal dialog. (WebCore::SpinButtonElement::releaseCapture): Calls Chrome::unregisterPopupOpeningObserver. Canonical link: https://commits.webkit.org/120581@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134886 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-11-16 04:30:07 +00:00
};
} // namespace WebCore