Changeset 191113 in webkit


Ignore:
Timestamp:
Oct 15, 2015 9:08:24 AM (9 years ago)
Author:
dbates@webkit.org
Message:

[iOS] DOM click event may not be dispatched when page has :active style and <input type="search">
https://bugs.webkit.org/show_bug.cgi?id=144451
<rdar://problem/23099482>

Reviewed by Simon Fraser.

Source/WebCore:

Fixes an issue where a DOM click event is not dispatched to an element in a subframe on a page
that has a <input type="search"> and defines a CSS :active pseudo-class for the HTML body element.

On iOS we only dispatch a DOM click event if the content does not change as part
of dispatching a DOM mousemove event at the tapped element. In particular, we do not
dispatch a DOM click event if there is a visibility change to some element on the page
as part of dispatching a mousemove event at the tapped element. For a web page
that specifies CSS :active pseudo-class and contains a search field, applying/unapplying
this pseudo-class as part of dispatching a DOM mousemove event may cause the
visibility of the search field cancel button to change; => a DOM click event will not
be dispatched to the tapped element.

Tests: fast/events/can-click-element-on-page-with-active-pseudo-class-and-search-field.html

fast/forms/search/search-cancel-button-visible-when-input-becomes-disabled.html
fast/forms/search/search-cancel-button-visible-when-input-becomes-readonly.html
fast/forms/search/search-cancel-in-formerly-invisible-element.html
fast/forms/search/search-cancel-toggle-visibility-initially-hidden.html
fast/forms/search/search-cancel-toggle-visibility-initially-visible.html

  • rendering/RenderSearchField.cpp:

(WebCore::RenderSearchField::updateCancelButtonVisibility): Write logic for determining
whether the visibility of the cancel button changed in terms of m_isCancelButtonVisible
instead of querying for the current style data as the latter is overwritten on a full
style recalculation.
(WebCore::RenderSearchField::RenderSearchField): Deleted.
(WebCore::RenderSearchField::visibilityForCancelButton): Deleted.

  • rendering/RenderSearchField.h: Define instance variable m_isCancelButtonVisible to

store the visibility state of the cancel button.

LayoutTests:

Add a test to ensure that a DOM click event is dispatched to an element in a subframe on a page
with a search field and that specifies a CSS :active pseudo-class that changes the tap highlight
color.

Additionally, add tests to ensure we update the cancel button visibility whenever the visibility
of the search field changes.

  • fast/events/can-click-element-on-page-with-active-pseudo-class-and-search-field-expected.txt: Added.
  • fast/events/can-click-element-on-page-with-active-pseudo-class-and-search-field.html: Added.
  • fast/forms/search/search-cancel-button-visible-when-input-becomes-disabled-expected.html: Added.
  • fast/forms/search/search-cancel-button-visible-when-input-becomes-disabled.html: Added.
  • fast/forms/search/search-cancel-button-visible-when-input-becomes-readonly-expected.html: Added.
  • fast/forms/search/search-cancel-button-visible-when-input-becomes-readonly.html: Added.
  • fast/forms/search/search-cancel-in-formerly-invisible-element-expected.html: Added.
  • fast/forms/search/search-cancel-in-formerly-invisible-element.html: Added.
  • fast/forms/search/search-cancel-toggle-visibility-initially-hidden-expected.html: Added.
  • fast/forms/search/search-cancel-toggle-visibility-initially-hidden.html: Added.
  • fast/forms/search/search-cancel-toggle-visibility-initially-visible-expected.html: Added.
  • fast/forms/search/search-cancel-toggle-visibility-initially-visible.html: Added.
Location:
trunk
Files:
12 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r191101 r191113  
     12015-10-15  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] DOM click event may not be dispatched when page has :active style and <input type="search">
     4        https://bugs.webkit.org/show_bug.cgi?id=144451
     5        <rdar://problem/23099482>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Add a test to ensure that a DOM click event is dispatched to an element in a subframe on a page
     10        with a search field and that specifies a CSS :active pseudo-class that changes the tap highlight
     11        color.
     12
     13        Additionally, add tests to ensure we update the cancel button visibility whenever the visibility
     14        of the search field changes.
     15
     16        * fast/events/can-click-element-on-page-with-active-pseudo-class-and-search-field-expected.txt: Added.
     17        * fast/events/can-click-element-on-page-with-active-pseudo-class-and-search-field.html: Added.
     18        * fast/forms/search/search-cancel-button-visible-when-input-becomes-disabled-expected.html: Added.
     19        * fast/forms/search/search-cancel-button-visible-when-input-becomes-disabled.html: Added.
     20        * fast/forms/search/search-cancel-button-visible-when-input-becomes-readonly-expected.html: Added.
     21        * fast/forms/search/search-cancel-button-visible-when-input-becomes-readonly.html: Added.
     22        * fast/forms/search/search-cancel-in-formerly-invisible-element-expected.html: Added.
     23        * fast/forms/search/search-cancel-in-formerly-invisible-element.html: Added.
     24        * fast/forms/search/search-cancel-toggle-visibility-initially-hidden-expected.html: Added.
     25        * fast/forms/search/search-cancel-toggle-visibility-initially-hidden.html: Added.
     26        * fast/forms/search/search-cancel-toggle-visibility-initially-visible-expected.html: Added.
     27        * fast/forms/search/search-cancel-toggle-visibility-initially-visible.html: Added.
     28
    1292015-10-15  Carlos Garcia Campos  <cgarcia@igalia.com>
    230
  • trunk/Source/WebCore/ChangeLog

    r191112 r191113  
     12015-10-15  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] DOM click event may not be dispatched when page has :active style and <input type="search">
     4        https://bugs.webkit.org/show_bug.cgi?id=144451
     5        <rdar://problem/23099482>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Fixes an issue where a DOM click event is not dispatched to an element in a subframe on a page
     10        that has a <input type="search"> and defines a CSS :active pseudo-class for the HTML body element.
     11
     12        On iOS we only dispatch a DOM click event if the content does not change as part
     13        of dispatching a DOM mousemove event at the tapped element. In particular, we do not
     14        dispatch a DOM click event if there is a visibility change to some element on the page
     15        as part of dispatching a mousemove event at the tapped element. For a web page
     16        that specifies CSS :active pseudo-class and contains a search field, applying/unapplying
     17        this pseudo-class as part of dispatching a DOM mousemove event may cause the
     18        visibility of the search field cancel button to change; => a DOM click event will not
     19        be dispatched to the tapped element.
     20
     21        Tests: fast/events/can-click-element-on-page-with-active-pseudo-class-and-search-field.html
     22               fast/forms/search/search-cancel-button-visible-when-input-becomes-disabled.html
     23               fast/forms/search/search-cancel-button-visible-when-input-becomes-readonly.html
     24               fast/forms/search/search-cancel-in-formerly-invisible-element.html
     25               fast/forms/search/search-cancel-toggle-visibility-initially-hidden.html
     26               fast/forms/search/search-cancel-toggle-visibility-initially-visible.html
     27
     28        * rendering/RenderSearchField.cpp:
     29        (WebCore::RenderSearchField::updateCancelButtonVisibility): Write logic for determining
     30        whether the visibility of the cancel button changed in terms of m_isCancelButtonVisible
     31        instead of querying for the current style data as the latter is overwritten on a full
     32        style recalculation.
     33        (WebCore::RenderSearchField::RenderSearchField): Deleted.
     34        (WebCore::RenderSearchField::visibilityForCancelButton): Deleted.
     35        * rendering/RenderSearchField.h: Define instance variable m_isCancelButtonVisible to
     36        store the visibility state of the cancel button.
     37
    1382015-10-15  Antti Koivisto  <antti@apple.com>
    239
  • trunk/Source/WebCore/rendering/RenderSearchField.cpp

    r191084 r191113  
    5353RenderSearchField::RenderSearchField(HTMLInputElement& element, Ref<RenderStyle>&& style)
    5454    : RenderTextControlSingleLine(element, WTF::move(style))
    55     , m_searchPopupIsVisible(false)
    56     , m_searchPopup(0)
    5755{
    5856    ASSERT(element.isSearchField());
     
    168166}
    169167
    170 void RenderSearchField::updateCancelButtonVisibility() const
     168void RenderSearchField::updateCancelButtonVisibility()
    171169{
    172170    RenderElement* cancelButtonRenderer = cancelButtonElement()->renderer();
     
    174172        return;
    175173
    176     const RenderStyle& curStyle = cancelButtonRenderer->style();
    177     EVisibility buttonVisibility = visibilityForCancelButton();
    178     if (curStyle.visibility() == buttonVisibility)
    179         return;
    180 
    181     auto cancelButtonStyle = RenderStyle::clone(&curStyle);
    182     cancelButtonStyle.get().setVisibility(buttonVisibility);
     174    bool wasCancelButtonVisible = m_isCancelButtonVisible;
     175    m_isCancelButtonVisible = style().visibility() == VISIBLE && !inputElement().value().isEmpty();
     176    if (wasCancelButtonVisible == m_isCancelButtonVisible)
     177        return;
     178
     179    auto cancelButtonStyle = RenderStyle::clone(&cancelButtonRenderer->style());
     180    cancelButtonStyle.get().setVisibility(m_isCancelButtonVisible ? VISIBLE : HIDDEN);
    183181    cancelButtonRenderer->setStyle(WTF::move(cancelButtonStyle));
    184 }
    185 
    186 EVisibility RenderSearchField::visibilityForCancelButton() const
    187 {
    188     return (style().visibility() == HIDDEN || inputElement().value().isEmpty()) ? HIDDEN : VISIBLE;
    189182}
    190183
  • trunk/Source/WebCore/rendering/RenderSearchField.h

    r191084 r191113  
    3737    virtual ~RenderSearchField();
    3838
    39     void updateCancelButtonVisibility() const;
     39    void updateCancelButtonVisibility();
    4040
    4141    void addSearchResult();
     
    5151    virtual LayoutUnit computeLogicalHeightLimit() const override;
    5252    virtual void updateFromElement() override;
    53     EVisibility visibilityForCancelButton() const;
    5453    const AtomicString& autosaveName() const;
    5554
     
    8685    HTMLElement* cancelButtonElement() const;
    8786
    88     bool m_searchPopupIsVisible;
     87    bool m_searchPopupIsVisible { false };
     88    bool m_isCancelButtonVisible { false };
    8989    RefPtr<SearchPopupMenu> m_searchPopup;
    9090    Vector<RecentSearch> m_recentSearches;
Note: See TracChangeset for help on using the changeset viewer.