Changeset 208176 in webkit


Ignore:
Timestamp:
Oct 31, 2016 2:47:30 PM (7 years ago)
Author:
rniwa@webkit.org
Message:

CSSStyleDeclaration should be annotated with CEReactions
https://bugs.webkit.org/show_bug.cgi?id=163968

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Rebaselined the test now that all test cases pass.

  • web-platform-tests/custom-elements/attribute-changed-callback-expected.txt:

Source/WebCore:

Added CEReactions to CSSStyleDeclaration.idl.

Test: fast/custom-elements/reactions/CSSStyleDeclaration.html

  • bindings/js/JSCSSStyleDeclarationCustom.cpp:

(WebCore::JSCSSStyleDeclaration::putDelegate):

  • css/CSSStyleDeclaration.idl:
  • css/PropertySetCSSStyleDeclaration.cpp:

(WebCore::StyleAttributeMutationScope::StyleAttributeMutationScope): Remember the old value when this is
an inline style declaration for a custom element. Also store m_oldValue and m_customElement instead of
a mutation record so that we don't create a superfluous mutation record for custom elements.
(WebCore::StyleAttributeMutationScope::~StyleAttributeMutationScope): Enqueue attributeChangedCallback
when m_customElement is not null.

  • dom/CustomElementReactionQueue.cpp:

(WebCore::CustomElementReactionQueue::observesStyleAttribute):

  • dom/CustomElementReactionQueue.h:

LayoutTests:

Added a W3C style testharness.js test.

  • fast/custom-elements/reactions/CSSStyleDeclaration-expected.txt: Added.
  • fast/custom-elements/reactions/CSSStyleDeclaration.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r208170 r208176  
     12016-10-31  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        CSSStyleDeclaration should be annotated with CEReactions
     4        https://bugs.webkit.org/show_bug.cgi?id=163968
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Added a W3C style testharness.js test.
     9
     10        * fast/custom-elements/reactions/CSSStyleDeclaration-expected.txt: Added.
     11        * fast/custom-elements/reactions/CSSStyleDeclaration.html: Added.
     12
    1132016-10-31  Zalan Bujtas  <zalan@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r208096 r208176  
     12016-10-31  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        CSSStyleDeclaration should be annotated with CEReactions
     4        https://bugs.webkit.org/show_bug.cgi?id=163968
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Rebaselined the test now that all test cases pass.
     9
     10        * web-platform-tests/custom-elements/attribute-changed-callback-expected.txt:
     11
    1122016-10-28  Darin Adler  <darin@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/attribute-changed-callback-expected.txt

    r207571 r208176  
    88PASS Mutating observedAttributes after calling customElements.define must not affect the set of attributes for which attributedChangedCallback is invoked
    99PASS attributedChangedCallback must be enqueued for attributes specified in a non-Array iterable observedAttributes
    10 FAIL attributedChangedCallback must be enqueued for style attribute change by mutating inline style declaration assert_equals: expected 1 but got 0
     10PASS attributedChangedCallback must be enqueued for style attribute change by mutating inline style declaration
    1111PASS attributedChangedCallback must not be enqueued when mutating inline style declaration if the style attribute is not observed
    1212
  • trunk/Source/WebCore/ChangeLog

    r208175 r208176  
     12016-10-31  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        CSSStyleDeclaration should be annotated with CEReactions
     4        https://bugs.webkit.org/show_bug.cgi?id=163968
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Added CEReactions to CSSStyleDeclaration.idl.
     9
     10        Test: fast/custom-elements/reactions/CSSStyleDeclaration.html
     11
     12        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
     13        (WebCore::JSCSSStyleDeclaration::putDelegate):
     14        * css/CSSStyleDeclaration.idl:
     15        * css/PropertySetCSSStyleDeclaration.cpp:
     16        (WebCore::StyleAttributeMutationScope::StyleAttributeMutationScope): Remember the old value when this is
     17        an inline style declaration for a custom element. Also store m_oldValue and m_customElement instead of
     18        a mutation record so that we don't create a superfluous mutation record for custom elements.
     19        (WebCore::StyleAttributeMutationScope::~StyleAttributeMutationScope): Enqueue attributeChangedCallback
     20        when m_customElement is not null.
     21        * dom/CustomElementReactionQueue.cpp:
     22        (WebCore::CustomElementReactionQueue::observesStyleAttribute):
     23        * dom/CustomElementReactionQueue.h:
     24
    1252016-10-31  Jer Noble  <jer.noble@apple.com>
    226
  • trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp

    r208135 r208176  
    3434#include "CSSStyleSheet.h"
    3535#include "CSSValue.h"
     36#include "CustomElementReactionQueue.h"
    3637#include "HashTools.h"
    3738#include "JSCSSStyleDeclaration.h"
     
    323324bool JSCSSStyleDeclaration::putDelegate(ExecState* state, PropertyName propertyName, JSValue value, PutPropertySlot&, bool& putResult)
    324325{
     326#if ENABLE(CUSTOM_ELEMENTS)
     327    CustomElementReactionStack customElementReactionStack;
     328#endif
    325329    auto propertyInfo = parseJavaScriptCSSPropertyName(propertyName);
    326330    if (!propertyInfo.propertyID)
  • trunk/Source/WebCore/css/CSSStyleDeclaration.idl

    r207396 r208176  
    2929    SkipVTableValidation,
    3030] interface CSSStyleDeclaration {
    31     [SetterMayThrowException] attribute DOMString cssText;
     31    [CEReactions, SetterMayThrowException] attribute DOMString cssText;
    3232
    3333    DOMString getPropertyValue(DOMString propertyName);
    3434    [Custom] CSSValue? getPropertyCSSValue(DOMString propertyName);
    3535
    36     [MayThrowException] DOMString removeProperty(DOMString propertyName);
     36    [CEReactions, MayThrowException] DOMString removeProperty(DOMString propertyName);
    3737    DOMString? getPropertyPriority(DOMString propertyName);
    3838
    39     [MayThrowException] void setProperty(DOMString propertyName, [TreatNullAs=EmptyString] DOMString value, [TreatNullAs=EmptyString] optional DOMString priority = "");
     39    [CEReactions, MayThrowException] void setProperty(DOMString propertyName, [TreatNullAs=EmptyString] DOMString value, [TreatNullAs=EmptyString] optional DOMString priority = "");
    4040
    4141    readonly attribute unsigned long length;
  • trunk/Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp

    r207396 r208176  
    2727#include "CSSRule.h"
    2828#include "CSSStyleSheet.h"
     29#include "CustomElementReactionQueue.h"
    2930#include "HTMLNames.h"
    3031#include "InspectorInstrumentation.h"
     
    5455        s_currentDecl = decl;
    5556
    56         if (!s_currentDecl->parentElement())
     57        auto* element = s_currentDecl->parentElement();
     58        if (!element)
    5759            return;
    5860
     
    6365            shouldReadOldValue = true;
    6466
    65         AtomicString oldValue;
     67#if ENABLE(CUSTOM_ELEMENTS)
     68        if (UNLIKELY(element->isDefinedCustomElement())) {
     69            auto* reactionQueue = element->reactionQueue();
     70            if (reactionQueue && reactionQueue->observesStyleAttribute()) {
     71                m_customElement = element;
     72                shouldReadOldValue = true;
     73            }
     74        }
     75#endif
     76
    6677        if (shouldReadOldValue)
    67             oldValue = s_currentDecl->parentElement()->getAttribute(HTMLNames::styleAttr);
    68 
    69         if (m_mutationRecipients) {
    70             AtomicString requestedOldValue = m_mutationRecipients->isOldValueRequested() ? oldValue : nullAtom;
    71             m_mutation = MutationRecord::createAttributes(*s_currentDecl->parentElement(), HTMLNames::styleAttr, requestedOldValue);
    72         }
     78            m_oldValue = s_currentDecl->parentElement()->getAttribute(HTMLNames::styleAttr);
    7379    }
    7480
     
    7985            return;
    8086
    81         if (m_mutation && s_shouldDeliver)
    82             m_mutationRecipients->enqueueMutationRecord(m_mutation.releaseNonNull());
     87        if (s_shouldDeliver) {
     88            if (m_mutationRecipients) {
     89                auto mutation = MutationRecord::createAttributes(*s_currentDecl->parentElement(), HTMLNames::styleAttr, m_oldValue);
     90                m_mutationRecipients->enqueueMutationRecord(WTFMove(mutation));
     91            }
     92            if (m_customElement) {
     93                AtomicString newValue = m_customElement->getAttribute(HTMLNames::styleAttr);
     94                CustomElementReactionQueue::enqueueAttributeChangedCallbackIfNeeded(*m_customElement, HTMLNames::styleAttr, m_oldValue, newValue);
     95            }
     96        }
    8397
    8498        s_shouldDeliver = false;
     
    112126
    113127    std::unique_ptr<MutationObserverInterestGroup> m_mutationRecipients;
    114     RefPtr<MutationRecord> m_mutation;
     128    AtomicString m_oldValue;
     129    RefPtr<Element> m_customElement;
    115130};
    116131
  • trunk/Source/WebCore/dom/CustomElementReactionQueue.cpp

    r207810 r208176  
    3333#include "Document.h"
    3434#include "Element.h"
     35#include "HTMLNames.h"
    3536#include "JSCustomElementInterface.h"
    3637#include "JSDOMBinding.h"
     
    191192}
    192193
     194bool CustomElementReactionQueue::observesStyleAttribute() const
     195{
     196    return m_interface->observesAttribute(HTMLNames::styleAttr.localName());
     197}
     198
    193199void CustomElementReactionQueue::invokeAll(Element& element)
    194200{
  • trunk/Source/WebCore/dom/CustomElementReactionQueue.h

    r207810 r208176  
    5454    static void enqueuePostUpgradeReactions(Element&);
    5555
     56    bool observesStyleAttribute() const;
    5657    void invokeAll(Element&);
    5758    void clear();
Note: See TracChangeset for help on using the changeset viewer.