Changeset 206404 in webkit


Ignore:
Timestamp:
Sep 26, 2016, 4:51:17 PM (8 years ago)
Author:
Antti Koivisto
Message:

Setter on style element's textContent or cssText doesn't trigger style recalc
https://bugs.webkit.org/show_bug.cgi?id=160331
<rdar://problem/27609715>

Reviewed by Ryosuke Niwa and Daniel Bates.

Source/WebCore:

We would not notify the parent when text node content changed in a shadow tree.

Test: fast/shadow-dom/shadow-style-text-mutation.html

  • dom/AuthorStyleSheets.cpp:

(WebCore::AuthorStyleSheets::updateActiveStyleSheets):

Invalidate shadow root children instead of the root itself when doing full invalidation.
The invalidity bits have no meaning for non-element, non-texts.

  • dom/CharacterData.cpp:

(WebCore::CharacterData::parserAppendData):
(WebCore::CharacterData::setDataAndUpdate):
(WebCore::CharacterData::notifyParentAfterChange):

Add a helper and call it also in shadow trees.

(WebCore::CharacterData::dispatchModifiedEvent):

  • dom/CharacterData.h:

LayoutTests:

  • fast/shadow-dom/shadow-style-text-mutation-expected.html: Added.
  • fast/shadow-dom/shadow-style-text-mutation.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r206403 r206404  
     12016-09-26  Antti Koivisto  <antti@apple.com>
     2
     3        Setter on style element's textContent or cssText doesn't trigger style recalc
     4        https://bugs.webkit.org/show_bug.cgi?id=160331
     5        <rdar://problem/27609715>
     6
     7        Reviewed by Ryosuke Niwa and Daniel Bates.
     8
     9        * fast/shadow-dom/shadow-style-text-mutation-expected.html: Added.
     10        * fast/shadow-dom/shadow-style-text-mutation.html: Added.
     11
    1122016-09-26  Antti Koivisto  <antti@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r206403 r206404  
     12016-09-26  Antti Koivisto  <antti@apple.com>
     2
     3        Setter on style element's textContent or cssText doesn't trigger style recalc
     4        https://bugs.webkit.org/show_bug.cgi?id=160331
     5        <rdar://problem/27609715>
     6
     7        Reviewed by Ryosuke Niwa and Daniel Bates.
     8
     9        We would not notify the parent when text node content changed in a shadow tree.
     10
     11        Test: fast/shadow-dom/shadow-style-text-mutation.html
     12
     13        * dom/AuthorStyleSheets.cpp:
     14        (WebCore::AuthorStyleSheets::updateActiveStyleSheets):
     15
     16            Invalidate shadow root children instead of the root itself when doing full invalidation.
     17            The invalidity bits have no meaning for non-element, non-texts.
     18
     19        * dom/CharacterData.cpp:
     20        (WebCore::CharacterData::parserAppendData):
     21        (WebCore::CharacterData::setDataAndUpdate):
     22        (WebCore::CharacterData::notifyParentAfterChange):
     23
     24            Add a helper and call it also in shadow trees.
     25
     26        (WebCore::CharacterData::dispatchModifiedEvent):
     27        * dom/CharacterData.h:
     28
    1292016-09-26  Antti Koivisto  <antti@apple.com>
    230
  • trunk/Source/WebCore/dom/AuthorStyleSheets.cpp

    r206361 r206404  
    3131#include "CSSStyleSheet.h"
    3232#include "Element.h"
     33#include "ElementChildIterator.h"
    3334#include "ExtensionStyleSheets.h"
    3435#include "HTMLIFrameElement.h"
     
    337338
    338339    if (requiresFullStyleRecalc) {
    339         if (m_shadowRoot)
    340             m_shadowRoot->setNeedsStyleRecalc();
    341         else
     340        if (m_shadowRoot) {
     341            for (auto& shadowChild : childrenOfType<Element>(*m_shadowRoot))
     342                shadowChild.setNeedsStyleRecalc();
     343        } else
    342344            m_document.scheduleForcedStyleRecalc();
    343345    }
  • trunk/Source/WebCore/dom/CharacterData.cpp

    r204316 r206404  
    104104        downcast<Text>(*this).updateRendererAfterContentChange(oldLength, 0);
    105105
    106     document().incDOMTreeVersion();
    107     // We don't call dispatchModifiedEvent here because we don't want the
    108     // parser to dispatch DOM mutation events.
    109     if (parentNode()) {
    110         ContainerNode::ChildChange change = {
    111             ContainerNode::TextChanged,
    112             ElementTraversal::previousSibling(*this),
    113             ElementTraversal::nextSibling(*this),
    114             ContainerNode::ChildChangeSourceParser
    115         };
    116         parentNode()->childrenChanged(change);
    117     }
     106    notifyParentAfterChange(ContainerNode::ChildChangeSourceParser);
    118107
    119108    return characterLengthLimit;
     
    209198        document().frame()->selection().textWasReplaced(this, offsetOfReplacedData, oldLength, newLength);
    210199
     200    notifyParentAfterChange(ContainerNode::ChildChangeSourceAPI);
     201
     202    dispatchModifiedEvent(oldData);
     203}
     204
     205void CharacterData::notifyParentAfterChange(ContainerNode::ChildChangeSource source)
     206{
    211207    document().incDOMTreeVersion();
    212     dispatchModifiedEvent(oldData);
     208
     209    if (!parentNode())
     210        return;
     211
     212    ContainerNode::ChildChange change = {
     213        ContainerNode::TextChanged,
     214        ElementTraversal::previousSibling(*this),
     215        ElementTraversal::nextSibling(*this),
     216        source
     217    };
     218    parentNode()->childrenChanged(change);
    213219}
    214220
     
    219225
    220226    if (!isInShadowTree()) {
    221         if (parentNode()) {
    222             ContainerNode::ChildChange change = {
    223                 ContainerNode::TextChanged,
    224                 ElementTraversal::previousSibling(*this),
    225                 ElementTraversal::nextSibling(*this),
    226                 ContainerNode::ChildChangeSourceAPI
    227             };
    228             parentNode()->childrenChanged(change);
    229         }
    230227        if (document().hasListenerType(Document::DOMCHARACTERDATAMODIFIED_LISTENER))
    231228            dispatchScopedEvent(MutationEvent::create(eventNames().DOMCharacterDataModifiedEvent, true, nullptr, oldData, m_data));
  • trunk/Source/WebCore/dom/CharacterData.h

    r204717 r206404  
    2323#pragma once
    2424
    25 #include "Node.h"
     25#include "ContainerNode.h"
    2626#include <wtf/text/WTFString.h>
    2727
     
    7070    void setDataAndUpdate(const String&, unsigned offsetOfReplacedData, unsigned oldLength, unsigned newLength);
    7171    void checkCharDataOperation(unsigned offset, ExceptionCode&);
     72    void notifyParentAfterChange(ContainerNode::ChildChangeSource);
    7273
    7374    String m_data;
Note: See TracChangeset for help on using the changeset viewer.