Changeset 250708 in webkit


Ignore:
Timestamp:
Oct 4, 2019 12:34:32 AM (4 years ago)
Author:
rniwa@webkit.org
Message:

Radio button groups are not scoped by shadow boundaries
https://bugs.webkit.org/show_bug.cgi?id=199568

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Rebaselined a test now that it passes.

  • web-platform-tests/shadow-dom/input-type-radio-expected.txt:

Source/WebCore:

Fixed the bug that radio button groups are not scoped to each shadow tree by moving
RadioButtonGroups from FormController, which is a per-document object, to TreeScope.

Test: imported/w3c/web-platform-tests/shadow-dom/input-type-radio.html

  • dom/RadioButtonGroups.h:

(WebCore::RadioButtonGroups): Made this bmalloc'ed now that it's allocated standalone.

  • dom/TreeScope.cpp:

(WebCore::TreeScope::radioButtonGroups): Added.

  • dom/TreeScope.h:
  • html/FormController.h:

(WebCore::FormController::radioButtonGroups): Deleted.

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::~HTMLInputElement):
(WebCore::HTMLInputElement::removedFromAncestor): Update the radio button group here.
(WebCore::HTMLInputElement::didMoveToNewDocument): Removed the code to update radio
button group here since it's done in removedFromAncestor now. Note that insertion case
is alrady taken care of by HTMLInputElement::didFinishInsertingNode.
(WebCore::HTMLInputElement::radioButtonGroups const): Ditto.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r250701 r250708  
     12019-10-04  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Radio button groups are not scoped by shadow boundaries
     4        https://bugs.webkit.org/show_bug.cgi?id=199568
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Rebaselined a test now that it passes.
     9
     10        * web-platform-tests/shadow-dom/input-type-radio-expected.txt:
     11
    1122019-10-03  Antti Koivisto  <antti@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/input-type-radio-expected.txt

    r238692 r250708  
    11 
    22
    3 FAIL input type=radio elements should form a group inside shadow DOM. assert_true: expected true got false
     3PASS input type=radio elements should form a group inside shadow DOM.
    44
  • trunk/Source/WebCore/ChangeLog

    r250701 r250708  
     12019-10-04  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Radio button groups are not scoped by shadow boundaries
     4        https://bugs.webkit.org/show_bug.cgi?id=199568
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Fixed the bug that radio button groups are not scoped to each shadow tree by moving
     9        RadioButtonGroups from FormController, which is a per-document object, to TreeScope.
     10
     11        Test: imported/w3c/web-platform-tests/shadow-dom/input-type-radio.html
     12
     13        * dom/RadioButtonGroups.h:
     14        (WebCore::RadioButtonGroups): Made this bmalloc'ed now that it's allocated standalone.
     15        * dom/TreeScope.cpp:
     16        (WebCore::TreeScope::radioButtonGroups): Added.
     17        * dom/TreeScope.h:
     18        * html/FormController.h:
     19        (WebCore::FormController::radioButtonGroups): Deleted.
     20        * html/HTMLInputElement.cpp:
     21        (WebCore::HTMLInputElement::~HTMLInputElement):
     22        (WebCore::HTMLInputElement::removedFromAncestor): Update the radio button group here.
     23        (WebCore::HTMLInputElement::didMoveToNewDocument): Removed the code to update radio
     24        button group here since it's done in removedFromAncestor now. Note that insertion case
     25        is alrady taken care of by HTMLInputElement::didFinishInsertingNode.
     26        (WebCore::HTMLInputElement::radioButtonGroups const): Ditto.
     27
    1282019-10-03  Antti Koivisto  <antti@apple.com>
    229
  • trunk/Source/WebCore/dom/RadioButtonGroups.h

    r246490 r250708  
    3232
    3333class RadioButtonGroups {
     34    WTF_MAKE_FAST_ALLOCATED;
    3435public:
    3536    RadioButtonGroups();
  • trunk/Source/WebCore/dom/TreeScope.cpp

    r248846 r250708  
    4545#include "PointerLockController.h"
    4646#include "PseudoElement.h"
     47#include "RadioButtonGroups.h"
    4748#include "RenderView.h"
    4849#include "RuntimeEnabledFeatures.h"
     
    5455
    5556struct SameSizeAsTreeScope {
    56     void* pointers[9];
     57    void* pointers[10];
    5758};
    5859
     
    540541}
    541542
     543RadioButtonGroups& TreeScope::radioButtonGroups()
     544{
     545    if (!m_radioButtonGroups)
     546        m_radioButtonGroups = makeUnique<RadioButtonGroups>();
     547    return *m_radioButtonGroups;
     548}
     549
    542550} // namespace WebCore
  • trunk/Source/WebCore/dom/TreeScope.h

    r246490 r250708  
    4545class IdTargetObserverRegistry;
    4646class Node;
     47class RadioButtonGroups;
    4748class ShadowRoot;
    4849
     
    110111    IdTargetObserverRegistry& idTargetObserverRegistry() const { return *m_idTargetObserverRegistry.get(); }
    111112
     113    RadioButtonGroups& radioButtonGroups();
     114
    112115protected:
    113116    TreeScope(ShadowRoot&, Document&);
     
    136139
    137140    std::unique_ptr<IdTargetObserverRegistry> m_idTargetObserverRegistry;
     141   
     142    std::unique_ptr<RadioButtonGroups> m_radioButtonGroups;
    138143};
    139144
  • trunk/Source/WebCore/html/FormController.h

    r246490 r250708  
    2222#pragma once
    2323
    24 #include "RadioButtonGroups.h"
    2524#include <wtf/Forward.h>
     25#include <wtf/HashMap.h>
    2626#include <wtf/ListHashSet.h>
    2727#include <wtf/Vector.h>
     
    4242    FormController();
    4343    ~FormController();
    44 
    45     RadioButtonGroups& radioButtonGroups() { return m_radioButtonGroups; }
    4644
    4745    void registerFormElementWithState(HTMLFormControlElementWithState&);
     
    6866    static void formStatesFromStateVector(const Vector<String>&, SavedFormStateMap&);
    6967
    70     RadioButtonGroups m_radioButtonGroups;
    7168    FormElementListHashSet m_formElementsWithState;
    7269    SavedFormStateMap m_savedFormStateMap;
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r249194 r250708  
    174174    // That is inelegant, but harmless since we remove it here.
    175175    if (isRadioButton())
    176         document().formController().radioButtonGroups().removeButton(*this);
     176        treeScope().radioButtonGroups().removeButton(*this);
    177177
    178178#if ENABLE(TOUCH_EVENTS)
     
    15571557void HTMLInputElement::removedFromAncestor(RemovalType removalType, ContainerNode& oldParentOfRemovedTree)
    15581558{
     1559    if (removalType.treeScopeChanged && isRadioButton())
     1560        oldParentOfRemovedTree.treeScope().radioButtonGroups().removeButton(*this);
    15591561    if (removalType.disconnectedFromDocument && !form())
    15601562        removeFromRadioButtonGroup();
     
    15761578        newDocument.registerForDocumentSuspensionCallbacks(*this);
    15771579    }
    1578 
    1579     // We call this even for radio buttons in forms; it's harmless because the
    1580     // removeButton function is written to be safe for buttons not in any group.
    1581     if (isRadioButton())
    1582         oldDocument.formController().radioButtonGroups().removeButton(*this);
    15831580
    15841581#if ENABLE(TOUCH_EVENTS)
     
    19231920    if (auto* formElement = form())
    19241921        return &formElement->radioButtonGroups();
    1925     if (isConnected())
    1926         return &document().formController().radioButtonGroups();
     1922    if (isInTreeScope())
     1923        return &treeScope().radioButtonGroups();
    19271924    return nullptr;
    19281925}
Note: See TracChangeset for help on using the changeset viewer.