Changeset 119949 in webkit


Ignore:
Timestamp:
Jun 10, 2012 8:58:56 PM (12 years ago)
Author:
hayato@chromium.org
Message:

An inheritance of '-webkit-user-modify' does not stop at shadow boundary.
https://bugs.webkit.org/show_bug.cgi?id=88514

Reviewed by Ryosuke Niwa.

Source/WebCore:

In StyleResolver::styleForElement(), we reset '-webkit-user-modify'
CSS property after inheriting a parent style, but that is not
enough. We also have to reset '-webkit-user-modify' when we use a
cached result in applying matched properties.

Test: fast/dom/shadow/user-modify-inheritance.html

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::applyMatchedProperties):
(WebCore::StyleResolver::styleForElement):

  • css/StyleResolver.h:

(StyleResolver):

  • rendering/style/RenderStyle.cpp:

(WebCore::RenderStyle::inheritFrom):

  • rendering/style/RenderStyle.h:

LayoutTests:

  • fast/dom/shadow/user-modify-inheritance-expected.txt: Added.
  • fast/dom/shadow/user-modify-inheritance.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r119948 r119949  
     12012-06-10  Hayato Ito  <hayato@chromium.org>
     2
     3        An inheritance of '-webkit-user-modify' does not stop at shadow boundary.
     4        https://bugs.webkit.org/show_bug.cgi?id=88514
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * fast/dom/shadow/user-modify-inheritance-expected.txt: Added.
     9        * fast/dom/shadow/user-modify-inheritance.html: Added.
     10
    1112012-06-10  Yoshifumi Inoue  <yosin@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r119948 r119949  
     12012-06-10  Hayato Ito  <hayato@chromium.org>
     2
     3        An inheritance of '-webkit-user-modify' does not stop at shadow boundary.
     4        https://bugs.webkit.org/show_bug.cgi?id=88514
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        In StyleResolver::styleForElement(), we reset '-webkit-user-modify'
     9        CSS property after inheriting a parent style, but that is not
     10        enough.  We also have to reset '-webkit-user-modify' when we use a
     11        cached result in applying matched properties.
     12
     13        Test: fast/dom/shadow/user-modify-inheritance.html
     14
     15        * css/StyleResolver.cpp:
     16        (WebCore::StyleResolver::applyMatchedProperties):
     17        (WebCore::StyleResolver::styleForElement):
     18        * css/StyleResolver.h:
     19        (StyleResolver):
     20        * rendering/style/RenderStyle.cpp:
     21        (WebCore::RenderStyle::inheritFrom):
     22        * rendering/style/RenderStyle.h:
     23
    1242012-06-10  Yoshifumi Inoue  <yosin@chromium.org>
    225
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r119799 r119949  
    16201620}
    16211621
    1622 static inline bool isAtShadowBoundary(Element* element)
     1622static inline bool isAtShadowBoundary(const Element* element)
    16231623{
    16241624    if (!element)
     
    16551655
    16561656    if (m_parentStyle)
    1657         m_style->inheritFrom(m_parentStyle);
     1657        m_style->inheritFrom(m_parentStyle, isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
    16581658    else {
    16591659        m_parentStyle = style();
     
    16661666    }
    16671667
    1668     // Even if surrounding content is user-editable, shadow DOM should act as a single unit, and not necessarily be editable
    1669     if (isAtShadowBoundary(element))
    1670         m_style->setUserModify(RenderStyle::initialUserModify());
    1671 
    16721668    if (element->isLink()) {
    16731669        m_style->setIsLink(true);
     
    16831679        matchAllRules(matchResult, matchingBehavior != MatchAllRulesExcludingSMIL);
    16841680
    1685     applyMatchedProperties(matchResult);
     1681    applyMatchedProperties(matchResult, element);
    16861682
    16871683    // Clean up our style object's display and text decorations (among other fixups).
     
    18441840    m_style->setStyleType(pseudo);
    18451841
    1846     applyMatchedProperties(matchResult);
     1842    applyMatchedProperties(matchResult, e);
    18471843
    18481844    // Clean up our style object's display and text decorations (among other fixups).
     
    28242820}
    28252821
    2826 void StyleResolver::applyMatchedProperties(const MatchResult& matchResult)
    2827 {
     2822void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const Element* element)
     2823{
     2824    ASSERT(element);
    28282825    unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash(matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0;
    28292826    bool applyInheritedOnly = false;
     
    28382835            // If the cache item parent style has identical inherited properties to the current parent style then the
    28392836            // resulting style will be identical too. We copy the inherited properties over from the cache and are done.
    2840             m_style->inheritFrom(cacheItem->renderStyle.get());
     2837            m_style->inheritFrom(cacheItem->renderStyle.get(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
    28412838            // Unfortunately the link status is treated like an inherited property. We need to explicitly restore it.
    28422839            m_style->setInsideLink(linkStatus);
  • trunk/Source/WebCore/css/StyleResolver.h

    r119799 r119949  
    354354    bool checkSelector(const RuleData&, const ContainerNode* scope = 0);
    355355    bool checkRegionSelector(CSSSelector* regionSelector, Element* regionElement);
    356     void applyMatchedProperties(const MatchResult&);
     356    void applyMatchedProperties(const MatchResult&, const Element*);
    357357    enum StyleApplicationPass {
    358358        HighPriorityProperties,
  • trunk/Source/WebCore/rendering/style/RenderStyle.cpp

    r119564 r119949  
    163163}
    164164
    165 void RenderStyle::inheritFrom(const RenderStyle* inheritParent)
    166 {
    167     rareInheritedData = inheritParent->rareInheritedData;
     165void RenderStyle::inheritFrom(const RenderStyle* inheritParent, IsAtShadowBoundary isAtShadowBoundary)
     166{
     167    if (isAtShadowBoundary == AtShadowBoundary) {
     168        // Even if surrounding content is user-editable, shadow DOM should act as a single unit, and not necessarily be editable
     169        EUserModify currentUserModify = userModify();
     170        rareInheritedData = inheritParent->rareInheritedData;
     171        setUserModify(currentUserModify);
     172    } else
     173        rareInheritedData = inheritParent->rareInheritedData;
    168174    inherited = inheritParent->inherited;
    169175    inherited_flags = inheritParent->inherited_flags;
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r119455 r119949  
    391391    static PassRefPtr<RenderStyle> clone(const RenderStyle*);
    392392
    393     void inheritFrom(const RenderStyle* inheritParent);
     393    enum IsAtShadowBoundary {
     394        AtShadowBoundary,
     395        NotAtShadowBoundary,
     396    };
     397
     398    void inheritFrom(const RenderStyle* inheritParent, IsAtShadowBoundary = NotAtShadowBoundary);
    394399    void copyNonInheritedFrom(const RenderStyle*);
    395400
Note: See TracChangeset for help on using the changeset viewer.