⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 219950 in webkit


Ignore:
Timestamp:
Jul 26, 2017, 10:15:31 AM (9 years ago)
Author:
Chris Dumez
Message:

Pressing the Escape key should not be a valid user gesture to enter fullscreen
​https://bugs.webkit.org/show_bug.cgi?id=174864
<rdar://problem/33009088>

Reviewed by Geoffrey Garen.

Source/WebCore:

Pressing the Escape key should not be a valid user gesture to enter fullscreen since this
is the gesture to exit fullscreen already.

Test: fullscreen/requestFullscreen-escape-key.html

  • dom/Document.cpp:

(WebCore::Document::requestFullScreenForElement):

  • dom/UserGestureIndicator.cpp:

(WebCore::UserGestureIndicator::UserGestureIndicator):

  • dom/UserGestureIndicator.h:

(WebCore::UserGestureToken::create):
(WebCore::UserGestureToken::gestureType):
(WebCore::UserGestureToken::UserGestureToken):

  • page/EventHandler.cpp:

(WebCore::EventHandler::internalKeyEvent):

Tools:

Add support for eventSender.keyDown('escape') in DRT to match the behavior of
WKTR.

  • DumpRenderTree/mac/EventSendingController.mm:

(-[EventSendingController keyDown:withModifiers:withLocation:]):

LayoutTests:

Add layout test coverage.

  • fullscreen/requestFullscreen-escape-key-expected.txt: Added.
  • fullscreen/requestFullscreen-escape-key.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r219949 r219950  
     12017-07-26  Chris Dumez  <cdumez@apple.com>
     2
     3        Pressing the Escape key should not be a valid user gesture to enter fullscreen
     4        https://bugs.webkit.org/show_bug.cgi?id=174864
     5        <rdar://problem/33009088>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        Add layout test coverage.
     10
     11        * fullscreen/requestFullscreen-escape-key-expected.txt: Added.
     12        * fullscreen/requestFullscreen-escape-key.html: Added.
     13
    1142017-07-26  Nan Wang  <n_wang@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r219949 r219950  
     12017-07-26  Chris Dumez  <cdumez@apple.com>
     2
     3        Pressing the Escape key should not be a valid user gesture to enter fullscreen
     4        https://bugs.webkit.org/show_bug.cgi?id=174864
     5        <rdar://problem/33009088>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        Pressing the Escape key should not be a valid user gesture to enter fullscreen since this
     10        is the gesture to exit fullscreen already.
     11
     12        Test: fullscreen/requestFullscreen-escape-key.html
     13
     14        * dom/Document.cpp:
     15        (WebCore::Document::requestFullScreenForElement):
     16        * dom/UserGestureIndicator.cpp:
     17        (WebCore::UserGestureIndicator::UserGestureIndicator):
     18        * dom/UserGestureIndicator.h:
     19        (WebCore::UserGestureToken::create):
     20        (WebCore::UserGestureToken::gestureType):
     21        (WebCore::UserGestureToken::UserGestureToken):
     22        * page/EventHandler.cpp:
     23        (WebCore::EventHandler::internalKeyEvent):
     24
    1252017-07-26  Nan Wang  <n_wang@apple.com>
    226
  • trunk/Source/WebCore/dom/Document.cpp

    r219856 r219950  
    57865786        //   - an activation behavior is currently being processed whose click event was trusted, or
    57875787        //   - the event listener for a trusted click event is being handled.
    5788         if (!ScriptController::processingUserGesture())
     5788        if (!UserGestureIndicator::processingUserGesture())
    57895789            break;
     5790
     5791        // We do not allow pressing the Escape key as a user gesture to enter fullscreen since this is the key
     5792        // to exit fullscreen.
     5793        if (UserGestureIndicator::currentUserGesture()->gestureType() == UserGestureType::EscapeKey) {
     5794            addConsoleMessage(MessageSource::Security, MessageLevel::Error, ASCIILiteral("The Escape key may not be used as a user gesture to enter fullscreen"));
     5795            break;
     5796        }
    57905797
    57915798        // There is a previously-established user preference, security risk, or platform limitation.
  • trunk/Source/WebCore/dom/UserGestureIndicator.cpp

    r219531 r219950  
    4747}
    4848
    49 UserGestureIndicator::UserGestureIndicator(std::optional<ProcessingUserGestureState> state, Document* document)
     49UserGestureIndicator::UserGestureIndicator(std::optional<ProcessingUserGestureState> state, Document* document, UserGestureType gestureType)
    5050    : m_previousToken(currentToken())
    5151{
    … …  
    5555
    5656    if (state)
    57         currentToken() = UserGestureToken::create(state.value());
     57        currentToken() = UserGestureToken::create(state.value(), gestureType);
    5858
    5959    if (document && currentToken()->processingUserGesture()) {
  • trunk/Source/WebCore/dom/UserGestureIndicator.h

    r208985 r219950  
    4343};
    4444
     45enum class UserGestureType { EscapeKey, Other };
     46
    4547class UserGestureToken : public RefCounted<UserGestureToken> {
    4648public:
    47     static RefPtr<UserGestureToken> create(ProcessingUserGestureState state)
     49    static RefPtr<UserGestureToken> create(ProcessingUserGestureState state, UserGestureType gestureType)
    4850    {
    49         return adoptRef(new UserGestureToken(state));
     51        return adoptRef(new UserGestureToken(state, gestureType));
    5052    }
    5153
    … …  
    5557    bool processingUserGesture() const { return m_state == ProcessingUserGesture; }
    5658    bool processingUserGestureForMedia() const { return m_state == ProcessingUserGesture || m_state == ProcessingPotentialUserGesture; }
     59    UserGestureType gestureType() const { return m_gestureType; }
    5760
    5861    void addDestructionObserver(WTF::Function<void (UserGestureToken&)>&& observer)
    … …  
    6265
    6366private:
    64     UserGestureToken(ProcessingUserGestureState state)
     67    UserGestureToken(ProcessingUserGestureState state, UserGestureType gestureType)
    6568        : m_state(state)
     69        , m_gestureType(gestureType)
    6670    {
    6771    }
    … …  
    6973    ProcessingUserGestureState m_state = NotProcessingUserGesture;
    7074    Vector<WTF::Function<void (UserGestureToken&)>> m_destructionObservers;
     75    UserGestureType m_gestureType;
    7176};
    7277
    … …  
    8085
    8186    // If a document is provided, its last known user gesture timestamp is updated.
    82     WEBCORE_EXPORT explicit UserGestureIndicator(std::optional<ProcessingUserGestureState>, Document* = nullptr);
     87    WEBCORE_EXPORT explicit UserGestureIndicator(std::optional<ProcessingUserGestureState>, Document* = nullptr, UserGestureType = UserGestureType::Other);
    8388    WEBCORE_EXPORT explicit UserGestureIndicator(RefPtr<UserGestureToken>);
    8489    WEBCORE_EXPORT ~UserGestureIndicator();
  • trunk/Source/WebCore/page/EventHandler.cpp

    r219568 r219950  
    31713171        return false;
    31723172
    3173     UserGestureIndicator gestureIndicator(ProcessingUserGesture, m_frame.document());
     3173    UserGestureType gestureType = UserGestureType::Other;
     3174    if (initialKeyEvent.windowsVirtualKeyCode() == VK_ESCAPE)
     3175        gestureType = UserGestureType::EscapeKey;
     3176
     3177    UserGestureIndicator gestureIndicator(ProcessingUserGesture, m_frame.document(), gestureType);
    31743178    UserTypingGestureIndicator typingGestureIndicator(m_frame);
    31753179
  • trunk/Tools/ChangeLog

    r219941 r219950  
     12017-07-26  Chris Dumez  <cdumez@apple.com>
     2
     3        Pressing the Escape key should not be a valid user gesture to enter fullscreen
     4        https://bugs.webkit.org/show_bug.cgi?id=174864
     5        <rdar://problem/33009088>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        Add support for eventSender.keyDown('escape') in DRT to match the behavior of
     10        WKTR.
     11
     12        * DumpRenderTree/mac/EventSendingController.mm:
     13        (-[EventSendingController keyDown:withModifiers:withLocation:]):
     14
    1152017-07-26  Romain Bellessort  <romain.bellessort@crf.canon.fr>
    216
  • trunk/Tools/DumpRenderTree/mac/EventSendingController.mm

    r212663 r219950  
    935935        eventCharacter = [NSString stringWithCharacters:&ch length:1];
    936936        keyCode = 0x75;
     937    } else if ([character isEqualToString:@"escape"]) {
     938        const unichar ch = 0x1B;
     939        eventCharacter = [NSString stringWithCharacters:&ch length:1];
     940        keyCode = 0x35;
    937941    } else if ([character isEqualToString:@"printScreen"]) {
    938942        const unichar ch = NSPrintScreenFunctionKey;
Note: See TracChangeset for help on using the changeset viewer.