Changeset 202358 in webkit


Ignore:
Timestamp:
Jun 22, 2016 4:35:25 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

AX: Add support for CSS4 :focus-within pseudo
https://bugs.webkit.org/show_bug.cgi?id=140144

Patch by Benjamin Poulain <bpoulain@apple.com> on 2016-06-22
Reviewed by Antti Koivisto.

Source/WebCore:

Tests: fast/css/pseudo-focus-within-basics.html

fast/css/pseudo-focus-within-inside-shadow-dom.html
fast/css/pseudo-focus-within-style-sharing-1.html
fast/css/pseudo-focus-within-style-sharing-2.html
fast/selectors/focus-within-style-update.html

  • css/CSSSelector.cpp:

(WebCore::CSSSelector::selectorText):

  • css/CSSSelector.h:
  • css/SelectorChecker.cpp:

(WebCore::SelectorChecker::checkOne):

  • css/SelectorPseudoClassAndCompatibilityElementMap.in:
  • cssjit/SelectorCompiler.cpp:

(WebCore::SelectorCompiler::addPseudoClassType):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatching):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementHasFocusWithin):

  • dom/ContainerNode.cpp:

(WebCore::destroyRenderTreeIfNeeded):

  • dom/Element.cpp:

(WebCore::Element::~Element):
(WebCore::Element::setFocus):
(WebCore::Element::unregisterNamedFlowContentElement):
(WebCore::Element::setIsNamedFlowContentElement):
(WebCore::Element::clearIsNamedFlowContentElement):
(WebCore::Element::setStyleAffectedByFocusWithin):
(WebCore::Element::rareDataStyleAffectedByFocusWithin):
(WebCore::Element::rareDataIsNamedFlowContentElement):

  • dom/Element.h:

(WebCore::Element::hasFocusWithin):
(WebCore::Element::styleAffectedByFocusWithin):
(WebCore::Element::isNamedFlowContentElement):
(WebCore::Element::setHasFocusWithin):

  • dom/ElementRareData.h:

(WebCore::ElementRareData::styleAffectedByFocusWithin):
(WebCore::ElementRareData::setStyleAffectedByFocusWithin):
(WebCore::ElementRareData::isNamedFlowContentElement):
(WebCore::ElementRareData::setIsNamedFlowContentElement):
(WebCore::ElementRareData::ElementRareData):
(WebCore::ElementRareData::resetComputedStyle):

  • dom/Node.h:

(WebCore::Node::flagHasFocusWithin):
(WebCore::Node::isNamedFlowContentNode): Deleted.
(WebCore::Node::setIsNamedFlowContentNode): Deleted.
(WebCore::Node::clearIsNamedFlowContentNode): Deleted.

  • rendering/RenderNamedFlowThread.cpp:

(WebCore::RenderNamedFlowThread::clearContentElements):
(WebCore::RenderNamedFlowThread::registerNamedFlowContentElement):
(WebCore::RenderNamedFlowThread::unregisterNamedFlowContentElement):
(WebCore::nextNodeInsideContentElement):

  • style/RenderTreeUpdater.cpp:

(WebCore::RenderTreeUpdater::updateElementRenderer):

  • style/StyleRelations.cpp:

(WebCore::Style::commitRelationsToRenderStyle):
(WebCore::Style::commitRelations):

  • style/StyleRelations.h:
  • style/StyleSharingResolver.cpp:

(WebCore::Style::SharingResolver::canShareStyleWithElement):

LayoutTests:

  • fast/css/css-selector-text-expected.txt:
  • fast/css/css-selector-text.html:
  • fast/css/css-set-selector-text-expected.txt:
  • fast/css/css-set-selector-text.html:
  • fast/css/pseudo-focus-within-basics-expected.html: Added.
  • fast/css/pseudo-focus-within-basics.html: Added.
  • fast/css/pseudo-focus-within-inside-shadow-dom-expected.html: Added.
  • fast/css/pseudo-focus-within-inside-shadow-dom.html: Added.
  • fast/css/pseudo-focus-within-style-sharing-1-expected.html: Added.
  • fast/css/pseudo-focus-within-style-sharing-1.html: Added.
  • fast/css/pseudo-focus-within-style-sharing-2-expected.html: Added.
  • fast/css/pseudo-focus-within-style-sharing-2.html: Added.
  • fast/selectors/focus-within-style-update-expected.txt: Added.
  • fast/selectors/focus-within-style-update.html: Added.
Location:
trunk
Files:
12 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r202354 r202358  
     12016-06-22  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        AX: Add support for CSS4 :focus-within pseudo
     4        https://bugs.webkit.org/show_bug.cgi?id=140144
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * fast/css/css-selector-text-expected.txt:
     9        * fast/css/css-selector-text.html:
     10        * fast/css/css-set-selector-text-expected.txt:
     11        * fast/css/css-set-selector-text.html:
     12        * fast/css/pseudo-focus-within-basics-expected.html: Added.
     13        * fast/css/pseudo-focus-within-basics.html: Added.
     14        * fast/css/pseudo-focus-within-inside-shadow-dom-expected.html: Added.
     15        * fast/css/pseudo-focus-within-inside-shadow-dom.html: Added.
     16        * fast/css/pseudo-focus-within-style-sharing-1-expected.html: Added.
     17        * fast/css/pseudo-focus-within-style-sharing-1.html: Added.
     18        * fast/css/pseudo-focus-within-style-sharing-2-expected.html: Added.
     19        * fast/css/pseudo-focus-within-style-sharing-2.html: Added.
     20        * fast/selectors/focus-within-style-update-expected.txt: Added.
     21        * fast/selectors/focus-within-style-update.html: Added.
     22
    1232016-06-17  Dean Jackson  <dino@apple.com>
    224
  • trunk/LayoutTests/fast/css/css-selector-text-expected.txt

    r202066 r202358  
    216216PASS parseThenSerializeRule('a#b::-webkit-input-placeholder { }') is 'a#b::-webkit-input-placeholder { }'
    217217PASS parseThenSerializeRule('a[b].c#d::-webkit-input-placeholder { }') is 'a[b].c#d::-webkit-input-placeholder { }'
     218
     219PASS parseThenSerializeRule('a[b]:default { }') is 'a[b]:default { }'
     220PASS parseThenSerializeRule('a.b:default { }') is 'a.b:default { }'
     221PASS parseThenSerializeRule('a#b:default { }') is 'a#b:default { }'
     222PASS parseThenSerializeRule('a[b].c#d:default { }') is 'a[b].c#d:default { }'
     223
     224PASS parseThenSerializeRule('a[b]:in-range { }') is 'a[b]:in-range { }'
     225PASS parseThenSerializeRule('a.b:in-range { }') is 'a.b:in-range { }'
     226PASS parseThenSerializeRule('a#b:in-range { }') is 'a#b:in-range { }'
     227PASS parseThenSerializeRule('a[b].c#d:in-range { }') is 'a[b].c#d:in-range { }'
     228
     229PASS parseThenSerializeRule('a[b]:out-of-range { }') is 'a[b]:out-of-range { }'
     230PASS parseThenSerializeRule('a.b:out-of-range { }') is 'a.b:out-of-range { }'
     231PASS parseThenSerializeRule('a#b:out-of-range { }') is 'a#b:out-of-range { }'
     232PASS parseThenSerializeRule('a[b].c#d:out-of-range { }') is 'a[b].c#d:out-of-range { }'
     233
     234PASS parseThenSerializeRule('a[b]:focus-within { }') is 'a[b]:focus-within { }'
     235PASS parseThenSerializeRule('a.b:focus-within { }') is 'a.b:focus-within { }'
     236PASS parseThenSerializeRule('a#b:focus-within { }') is 'a#b:focus-within { }'
     237PASS parseThenSerializeRule('a[b].c#d:focus-within { }') is 'a[b].c#d:focus-within { }'
    218238
    219239PASS parseThenSerializeRule('input:not([type="file"]):focus { }') is 'input:not([type="file"]):focus { }'
  • trunk/LayoutTests/fast/css/css-selector-text.html

    r202066 r202358  
    308308debug('');
    309309
     310testSelectorRoundTrip("a[b]:default");
     311testSelectorRoundTrip("a.b:default");
     312testSelectorRoundTrip("a#b:default");
     313testSelectorRoundTrip("a[b].c#d:default");
     314
     315debug('');
     316
     317testSelectorRoundTrip("a[b]:in-range");
     318testSelectorRoundTrip("a.b:in-range");
     319testSelectorRoundTrip("a#b:in-range");
     320testSelectorRoundTrip("a[b].c#d:in-range");
     321
     322debug('');
     323
     324testSelectorRoundTrip("a[b]:out-of-range");
     325testSelectorRoundTrip("a.b:out-of-range");
     326testSelectorRoundTrip("a#b:out-of-range");
     327testSelectorRoundTrip("a[b].c#d:out-of-range");
     328
     329debug('');
     330
     331testSelectorRoundTrip("a[b]:focus-within");
     332testSelectorRoundTrip("a.b:focus-within");
     333testSelectorRoundTrip("a#b:focus-within");
     334testSelectorRoundTrip("a[b].c#d:focus-within");
     335
     336debug('');
     337
    310338testSelectorRoundTrip('input:not([type="file"]):focus');
    311339testSelectorRoundTrip(':-webkit-any([type="file"])');
  • trunk/LayoutTests/fast/css/css-set-selector-text-expected.txt

    r202066 r202358  
    219219PASS setThenReadSelectorText('a[b].c#d::-webkit-input-placeholder') is 'a[b].c#d::-webkit-input-placeholder'
    220220
     221PASS setThenReadSelectorText('a[b]:default') is 'a[b]:default'
     222PASS setThenReadSelectorText('a.b:default') is 'a.b:default'
     223PASS setThenReadSelectorText('a#b:default') is 'a#b:default'
     224PASS setThenReadSelectorText('a[b].c#d:default') is 'a[b].c#d:default'
     225
     226PASS setThenReadSelectorText('a[b]:in-range') is 'a[b]:in-range'
     227PASS setThenReadSelectorText('a.b:in-range') is 'a.b:in-range'
     228PASS setThenReadSelectorText('a#b:in-range') is 'a#b:in-range'
     229PASS setThenReadSelectorText('a[b].c#d:in-range') is 'a[b].c#d:in-range'
     230
     231PASS setThenReadSelectorText('a[b]:out-of-range') is 'a[b]:out-of-range'
     232PASS setThenReadSelectorText('a.b:out-of-range') is 'a.b:out-of-range'
     233PASS setThenReadSelectorText('a#b:out-of-range') is 'a#b:out-of-range'
     234PASS setThenReadSelectorText('a[b].c#d:out-of-range') is 'a[b].c#d:out-of-range'
     235
     236PASS setThenReadSelectorText('a[b]:focus-within') is 'a[b]:focus-within'
     237PASS setThenReadSelectorText('a.b:focus-within') is 'a.b:focus-within'
     238PASS setThenReadSelectorText('a#b:focus-within') is 'a#b:focus-within'
     239PASS setThenReadSelectorText('a[b].c#d:focus-within') is 'a[b].c#d:focus-within'
     240
    221241PASS setThenReadSelectorText('input:not([type="file"]):focus') is 'input:not([type="file"]):focus'
    222242PASS setThenReadSelectorText(':-webkit-any([type="file"])') is ':-webkit-any([type="file"])'
  • trunk/LayoutTests/fast/css/css-set-selector-text.html

    r202066 r202358  
    312312debug('');
    313313
     314testSelectorRoundTrip("a[b]:default");
     315testSelectorRoundTrip("a.b:default");
     316testSelectorRoundTrip("a#b:default");
     317testSelectorRoundTrip("a[b].c#d:default");
     318
     319debug('');
     320
     321testSelectorRoundTrip("a[b]:in-range");
     322testSelectorRoundTrip("a.b:in-range");
     323testSelectorRoundTrip("a#b:in-range");
     324testSelectorRoundTrip("a[b].c#d:in-range");
     325
     326debug('');
     327
     328testSelectorRoundTrip("a[b]:out-of-range");
     329testSelectorRoundTrip("a.b:out-of-range");
     330testSelectorRoundTrip("a#b:out-of-range");
     331testSelectorRoundTrip("a[b].c#d:out-of-range");
     332
     333debug('');
     334
     335testSelectorRoundTrip("a[b]:focus-within");
     336testSelectorRoundTrip("a.b:focus-within");
     337testSelectorRoundTrip("a#b:focus-within");
     338testSelectorRoundTrip("a[b].c#d:focus-within");
     339
     340debug('');
     341
    314342testSelectorRoundTrip('input:not([type="file"]):focus');
    315343testSelectorRoundTrip(':-webkit-any([type="file"])');
  • trunk/Source/WebCore/ChangeLog

    r202356 r202358  
     12016-06-22  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        AX: Add support for CSS4 :focus-within pseudo
     4        https://bugs.webkit.org/show_bug.cgi?id=140144
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Tests: fast/css/pseudo-focus-within-basics.html
     9               fast/css/pseudo-focus-within-inside-shadow-dom.html
     10               fast/css/pseudo-focus-within-style-sharing-1.html
     11               fast/css/pseudo-focus-within-style-sharing-2.html
     12               fast/selectors/focus-within-style-update.html
     13
     14        * css/CSSSelector.cpp:
     15        (WebCore::CSSSelector::selectorText):
     16        * css/CSSSelector.h:
     17        * css/SelectorChecker.cpp:
     18        (WebCore::SelectorChecker::checkOne):
     19        * css/SelectorPseudoClassAndCompatibilityElementMap.in:
     20        * cssjit/SelectorCompiler.cpp:
     21        (WebCore::SelectorCompiler::addPseudoClassType):
     22        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementMatching):
     23        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementHasFocusWithin):
     24        * dom/ContainerNode.cpp:
     25        (WebCore::destroyRenderTreeIfNeeded):
     26        * dom/Element.cpp:
     27        (WebCore::Element::~Element):
     28        (WebCore::Element::setFocus):
     29        (WebCore::Element::unregisterNamedFlowContentElement):
     30        (WebCore::Element::setIsNamedFlowContentElement):
     31        (WebCore::Element::clearIsNamedFlowContentElement):
     32        (WebCore::Element::setStyleAffectedByFocusWithin):
     33        (WebCore::Element::rareDataStyleAffectedByFocusWithin):
     34        (WebCore::Element::rareDataIsNamedFlowContentElement):
     35        * dom/Element.h:
     36        (WebCore::Element::hasFocusWithin):
     37        (WebCore::Element::styleAffectedByFocusWithin):
     38        (WebCore::Element::isNamedFlowContentElement):
     39        (WebCore::Element::setHasFocusWithin):
     40        * dom/ElementRareData.h:
     41        (WebCore::ElementRareData::styleAffectedByFocusWithin):
     42        (WebCore::ElementRareData::setStyleAffectedByFocusWithin):
     43        (WebCore::ElementRareData::isNamedFlowContentElement):
     44        (WebCore::ElementRareData::setIsNamedFlowContentElement):
     45        (WebCore::ElementRareData::ElementRareData):
     46        (WebCore::ElementRareData::resetComputedStyle):
     47        * dom/Node.h:
     48        (WebCore::Node::flagHasFocusWithin):
     49        (WebCore::Node::isNamedFlowContentNode): Deleted.
     50        (WebCore::Node::setIsNamedFlowContentNode): Deleted.
     51        (WebCore::Node::clearIsNamedFlowContentNode): Deleted.
     52        * rendering/RenderNamedFlowThread.cpp:
     53        (WebCore::RenderNamedFlowThread::clearContentElements):
     54        (WebCore::RenderNamedFlowThread::registerNamedFlowContentElement):
     55        (WebCore::RenderNamedFlowThread::unregisterNamedFlowContentElement):
     56        (WebCore::nextNodeInsideContentElement):
     57        * style/RenderTreeUpdater.cpp:
     58        (WebCore::RenderTreeUpdater::updateElementRenderer):
     59        * style/StyleRelations.cpp:
     60        (WebCore::Style::commitRelationsToRenderStyle):
     61        (WebCore::Style::commitRelations):
     62        * style/StyleRelations.h:
     63        * style/StyleSharingResolver.cpp:
     64        (WebCore::Style::SharingResolver::canShareStyleWithElement):
     65
    1662016-06-22  Oliver Hunt  <oliver@apple.com>
    267
  • trunk/Source/WebCore/css/CSSSelector.cpp

    r202091 r202358  
    498498                str.appendLiteral(":focus");
    499499                break;
     500            case CSSSelector::PseudoClassFocusWithin:
     501                str.appendLiteral(":focus-within");
     502                break;
    500503#if ENABLE(VIDEO_TRACK)
    501504            case CSSSelector::PseudoClassFuture:
  • trunk/Source/WebCore/css/CSSSelector.h

    r202091 r202358  
    113113            PseudoClassDrag,
    114114            PseudoClassFocus,
     115            PseudoClassFocusWithin,
    115116            PseudoClassActive,
    116117            PseudoClassChecked,
  • trunk/Source/WebCore/css/SelectorChecker.cpp

    r202245 r202358  
    945945        case CSSSelector::PseudoClassFocus:
    946946            return matchesFocusPseudoClass(element);
     947        case CSSSelector::PseudoClassFocusWithin:
     948            addStyleRelation(checkingContext, element, Style::Relation::AffectedByFocusWithin);
     949            return element.hasFocusWithin();
    947950        case CSSSelector::PseudoClassHover:
    948951            if (m_strictParsing || element.isLink() || canMatchHoverOrActiveInQuirksMode(context)) {
  • trunk/Source/WebCore/css/SelectorPseudoClassAndCompatibilityElementMap.in

    r202091 r202358  
    2626first-of-type
    2727focus
     28focus-within
    2829horizontal
    2930host
  • trunk/Source/WebCore/cssjit/SelectorCompiler.cpp

    r202245 r202358  
    324324    void generateElementIsScopeRoot(Assembler::JumpList& failureCases);
    325325    void generateElementIsTarget(Assembler::JumpList& failureCases);
     326    void generateElementHasFocusWithin(Assembler::JumpList& failureCases);
    326327
    327328    // Helpers.
     
    675676    case CSSSelector::PseudoClassOnlyChild:
    676677    case CSSSelector::PseudoClassPlaceholderShown:
     678    case CSSSelector::PseudoClassFocusWithin:
    677679        fragment.pseudoClasses.add(type);
    678680        if (selectorContext == SelectorContext::QuerySelector)
     
    25782580    if (fragment.pseudoClasses.contains(CSSSelector::PseudoClassTarget))
    25792581        generateElementIsTarget(matchingPostTagNameFailureCases);
     2582
     2583    if (fragment.pseudoClasses.contains(CSSSelector::PseudoClassFocusWithin))
     2584        generateElementHasFocusWithin(matchingPostTagNameFailureCases);
    25802585
    25812586    for (unsigned i = 0; i < fragment.unoptimizedPseudoClasses.size(); ++i)
     
    37923797}
    37933798
     3799void SelectorCodeGenerator::generateElementHasFocusWithin(Assembler::JumpList& failureCases)
     3800{
     3801    generateAddStyleRelationIfResolvingStyle(elementAddressRegister, Style::Relation::AffectedByFocusWithin);
     3802    failureCases.append(m_assembler.branchTest32(Assembler::Zero, Assembler::Address(elementAddressRegister, Node::nodeFlagsMemoryOffset()), Assembler::TrustedImm32(Node::flagHasFocusWithin())));
     3803}
     3804
    37943805void SelectorCodeGenerator::generateElementIsFirstLink(Assembler::JumpList& failureCases, Assembler::RegisterID element)
    37953806{
  • trunk/Source/WebCore/dom/ContainerNode.cpp

    r202105 r202358  
    104104    childIsHTMLSlotElement = is<HTMLSlotElement>(child);
    105105    // FIXME: Get rid of the named flow test.
    106     if (!child.renderer() && !child.isNamedFlowContentNode() && !childIsHTMLSlotElement)
     106    bool isElement = is<Element>(child);
     107    if (!child.renderer() && !childIsHTMLSlotElement
     108        && !(isElement && downcast<Element>(child).isNamedFlowContentElement()))
    107109        return;
    108     if (is<Element>(child))
     110    if (isElement)
    109111        RenderTreeUpdater::tearDownRenderers(downcast<Element>(child));
    110112    else if (is<Text>(child))
  • trunk/Source/WebCore/dom/Element.cpp

    r202292 r202358  
    183183        // When the document is not destroyed, an element that was part of a named flow
    184184        // content nodes should have been removed from the content nodes collection
    185         // and the isNamedFlowContentNode flag reset.
    186         ASSERT_WITH_SECURITY_IMPLICATION(!isNamedFlowContentNode());
     185        // and the isNamedFlowContentElement flag reset.
     186        ASSERT_WITH_SECURITY_IMPLICATION(!isNamedFlowContentElement());
    187187    }
    188188#endif
     
    602602    document().userActionElements().setFocused(this, flag);
    603603    setNeedsStyleRecalc();
     604
     605    for (Element* element = this; element; element = element->parentOrShadowHostElement())
     606        element->setHasFocusWithin(flag);
    604607}
    605608
     
    16211624void Element::unregisterNamedFlowContentElement()
    16221625{
    1623     if (isNamedFlowContentNode() && document().renderView())
     1626    if (isNamedFlowContentElement() && document().renderView())
    16241627        document().renderView()->flowThreadController().unregisterNamedFlowContentElement(*this);
    16251628}
     
    19091912}
    19101913
     1914void Element::setIsNamedFlowContentElement()
     1915{
     1916    ensureElementRareData().setIsNamedFlowContentElement(true);
     1917}
     1918
     1919void Element::clearIsNamedFlowContentElement()
     1920{
     1921    ensureElementRareData().setIsNamedFlowContentElement(false);
     1922}
     1923
    19111924void Element::removeAllEventListeners()
    19121925{
     
    25632576}
    25642577
     2578void Element::setStyleAffectedByFocusWithin()
     2579{
     2580    ensureElementRareData().setStyleAffectedByFocusWithin(true);
     2581}
     2582
    25652583void Element::setChildrenAffectedByActive()
    25662584{
     
    26062624    ASSERT(hasRareData());
    26072625    return elementRareData()->styleAffectedByEmpty();
     2626}
     2627
     2628bool Element::rareDataStyleAffectedByFocusWithin() const
     2629{
     2630    ASSERT(hasRareData());
     2631    return elementRareData()->styleAffectedByFocusWithin();
     2632}
     2633
     2634bool Element::rareDataIsNamedFlowContentElement() const
     2635{
     2636    ASSERT(hasRareData());
     2637    return elementRareData()->isNamedFlowContentElement();
    26082638}
    26092639
  • trunk/Source/WebCore/dom/Element.h

    r202292 r202358  
    274274    bool hovered() const { return isUserActionElement() && isUserActionElementHovered(); }
    275275    bool focused() const { return isUserActionElement() && isUserActionElementFocused(); }
     276    bool hasFocusWithin() const { return getFlag(HasFocusWithin); };
    276277
    277278    virtual void setActive(bool flag = true, bool pause = false);
    278279    virtual void setHovered(bool flag = true);
    279280    virtual void setFocus(bool flag);
     281    void setHasFocusWithin(bool flag);
    280282
    281283    bool tabIndexSetExplicitly() const;
     
    297299    // Methods for indicating the style is affected by dynamic updates (e.g., children changing, our position changing in our sibling list, etc.)
    298300    bool styleAffectedByEmpty() const { return hasRareData() && rareDataStyleAffectedByEmpty(); }
     301    bool styleAffectedByFocusWithin() const { return hasRareData() && rareDataStyleAffectedByFocusWithin(); }
    299302    bool childrenAffectedByHover() const { return getFlag(ChildrenAffectedByHoverRulesFlag); }
    300303    bool childrenAffectedByActive() const { return hasRareData() && rareDataChildrenAffectedByActive(); }
     
    310313
    311314    void setStyleAffectedByEmpty();
     315    void setStyleAffectedByFocusWithin();
    312316    void setChildrenAffectedByHover() { setFlag(ChildrenAffectedByHoverRulesFlag); }
    313317    void setChildrenAffectedByActive();
     
    522526    void setAttributeEventListener(const AtomicString& eventType, const QualifiedName& attributeName, const AtomicString& value);
    523527
     528    bool isNamedFlowContentElement() const { return hasRareData() && rareDataIsNamedFlowContentElement(); }
     529    void setIsNamedFlowContentElement();
     530    void clearIsNamedFlowContentElement();
     531
    524532protected:
    525533    Element(const QualifiedName&, Document&, ConstructionType);
     
    608616
    609617    bool rareDataStyleAffectedByEmpty() const;
     618    bool rareDataStyleAffectedByFocusWithin() const;
     619    bool rareDataIsNamedFlowContentElement() const;
    610620    bool rareDataChildrenAffectedByHover() const;
    611621    bool rareDataChildrenAffectedByActive() const;
     
    750760}
    751761
     762inline void Element::setHasFocusWithin(bool flag)
     763{
     764    if (hasFocusWithin() == flag)
     765        return;
     766    setFlag(flag, HasFocusWithin);
     767    if (styleAffectedByFocusWithin())
     768        setNeedsStyleRecalc();
     769}
     770
    752771} // namespace WebCore
    753772
  • trunk/Source/WebCore/dom/ElementRareData.h

    r199964 r202358  
    11/*
    2  * Copyright (C) 2008, 2009, 2010, 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008, 2009, 2010, 2014, 2016 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 David Smith <catfish.man@gmail.com>
    44 *
     
    5959    void setStyleAffectedByEmpty(bool value) { m_styleAffectedByEmpty = value; }
    6060
     61    bool styleAffectedByFocusWithin() const { return m_styleAffectedByFocusWithin; }
     62    void setStyleAffectedByFocusWithin(bool value) { m_styleAffectedByFocusWithin = value; }
     63
    6164    RegionOversetState regionOversetState() const { return m_regionOversetState; }
    6265    void setRegionOversetState(RegionOversetState state) { m_regionOversetState = state; }
     66
     67    bool isNamedFlowContentElement() const { return m_isNamedFlowContentElement; }
     68    void setIsNamedFlowContentElement(bool value) { m_isNamedFlowContentElement = value; }
    6369
    6470#if ENABLE(FULLSCREEN_API)
     
    117123    unsigned m_needsFocusAppearanceUpdateSoonAfterAttach : 1;
    118124    unsigned m_styleAffectedByEmpty : 1;
     125    unsigned m_styleAffectedByFocusWithin : 1;
    119126#if ENABLE(FULLSCREEN_API)
    120127    unsigned m_containsFullScreenElement : 1;
     
    131138    unsigned m_childrenAffectedByPropertyBasedBackwardPositionalRules : 1;
    132139    unsigned m_hasDisplayContents : 1;
     140    unsigned m_isNamedFlowContentElement : 1;
    133141
    134142    RegionOversetState m_regionOversetState;
     
    161169    , m_needsFocusAppearanceUpdateSoonAfterAttach(false)
    162170    , m_styleAffectedByEmpty(false)
     171    , m_styleAffectedByFocusWithin(false)
    163172#if ENABLE(FULLSCREEN_API)
    164173    , m_containsFullScreenElement(false)
     
    172181    , m_childrenAffectedByPropertyBasedBackwardPositionalRules(false)
    173182    , m_hasDisplayContents(false)
     183    , m_isNamedFlowContentElement(false)
    174184    , m_regionOversetState(RegionUndefined)
    175185    , m_minimumSizeForResizing(defaultMinimumSizeForResizing())
     
    201211    m_hasDisplayContents = false;
    202212    setStyleAffectedByEmpty(false);
     213    setStyleAffectedByFocusWithin(false);
    203214    setChildIndex(0);
    204215}
  • trunk/Source/WebCore/dom/Node.h

    r202091 r202358  
    248248    bool isShadowRoot() const { return isDocumentFragment() && isTreeScope(); }
    249249
    250     bool isNamedFlowContentNode() const { return getFlag(IsNamedFlowContentNodeFlag); }
    251250    bool hasCustomStyleResolveCallbacks() const { return getFlag(HasCustomStyleResolveCallbacksFlag); }
    252251
     
    337336    bool isLink() const { return getFlag(IsLinkFlag); }
    338337    void setIsLink(bool flag) { setFlag(flag, IsLinkFlag); }
    339 
    340     void setIsNamedFlowContentNode() { setFlag(IsNamedFlowContentNodeFlag); }
    341     void clearIsNamedFlowContentNode() { clearFlag(IsNamedFlowContentNodeFlag); }
    342338
    343339    bool hasEventTargetData() const { return getFlag(HasEventTargetDataFlag); }
     
    573569    static int32_t flagIsHTML() { return IsHTMLFlag; }
    574570    static int32_t flagIsLink() { return IsLinkFlag; }
     571    static int32_t flagHasFocusWithin() { return HasFocusWithin; }
    575572    static int32_t flagHasRareData() { return HasRareDataFlag; }
    576573    static int32_t flagIsParsingChildrenFinished() { return IsParsingChildrenFinishedFlag; }
     
    603600        StyleChangeMask = 1 << nodeStyleChangeShift | 1 << (nodeStyleChangeShift + 1) | 1 << (nodeStyleChangeShift + 2),
    604601        IsEditingTextOrUnresolvedCustomElementFlag = 1 << 17,
    605         IsNamedFlowContentNodeFlag = 1 << 18,
     602        HasFocusWithin = 1 << 18,
    606603        HasSyntheticAttrChildNodesFlag = 1 << 19,
    607604        HasCustomStyleResolveCallbacksFlag = 1 << 20,
  • trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp

    r200671 r202358  
    7575    for (auto& contentElement : m_contentElements) {
    7676        ASSERT(contentElement);
    77         ASSERT(contentElement->isNamedFlowContentNode());
     77        ASSERT(contentElement->isNamedFlowContentElement());
    7878        ASSERT(&contentElement->document() == &document());
    7979       
    80         contentElement->clearIsNamedFlowContentNode();
     80        contentElement->clearIsNamedFlowContentElement();
    8181    }
    8282   
     
    498498    ASSERT(&contentElement.document() == &document());
    499499
    500     contentElement.setIsNamedFlowContentNode();
     500    contentElement.setIsNamedFlowContentElement();
    501501
    502502    resetMarkForDestruction();
     
    519519{
    520520    ASSERT(m_contentElements.contains(&contentElement));
    521     ASSERT(contentElement.isNamedFlowContentNode());
     521    ASSERT(contentElement.isNamedFlowContentElement());
    522522    ASSERT(&contentElement.document() == &document());
    523523
    524     contentElement.clearIsNamedFlowContentNode();
     524    contentElement.clearIsNamedFlowContentElement();
    525525    m_contentElements.remove(&contentElement);
    526526
     
    617617static Node* nextNodeInsideContentElement(const Node& currNode, const Element* contentElement)
    618618{
    619     ASSERT(contentElement && contentElement->isNamedFlowContentNode());
     619    ASSERT(contentElement && contentElement->isNamedFlowContentElement());
    620620
    621621    if (currNode.renderer() && currNode.renderer()->isSVGRoot())
  • trunk/Source/WebCore/style/RenderTreeUpdater.cpp

    r202324 r202358  
    241241void RenderTreeUpdater::updateElementRenderer(Element& element, Style::ElementUpdate& update)
    242242{
    243     bool shouldTearDownRenderers = update.change == Style::Detach && (element.renderer() || element.isNamedFlowContentNode());
     243    bool shouldTearDownRenderers = update.change == Style::Detach && (element.renderer() || element.isNamedFlowContentElement());
    244244    if (shouldTearDownRenderers)
    245245        tearDownRenderers(element, TeardownType::KeepHoverAndActive);
  • trunk/Source/WebCore/style/StyleRelations.cpp

    r199583 r202358  
    7373            style.setUnique();
    7474            break;
     75        case Relation::AffectedByFocusWithin:
    7576        case Relation::AffectedByPreviousSibling:
    7677        case Relation::AffectsNextSibling:
     
    102103        case Relation::AffectedByEmpty:
    103104            element.setStyleAffectedByEmpty();
     105            break;
     106        case Relation::AffectedByFocusWithin:
     107            element.setStyleAffectedByFocusWithin();
    104108            break;
    105109        case Relation::AffectedByHover:
  • trunk/Source/WebCore/style/StyleRelations.h

    r199583 r202358  
    4343        AffectedByDrag,
    4444        AffectedByEmpty,
     45        AffectedByFocusWithin,
    4546        AffectedByHover,
    4647        AffectedByPreviousSibling,
  • trunk/Source/WebCore/style/StyleSharingResolver.cpp

    r202245 r202358  
    231231    if (candidateElement.affectsNextSiblingElementStyle() || candidateElement.styleIsAffectedByPreviousSibling())
    232232        return false;
     233    if (candidateElement.styleAffectedByFocusWithin() || element.styleAffectedByFocusWithin())
     234        return false;
    233235
    234236    auto& candidateElementId = candidateElement.idForStyleResolution();
Note: See TracChangeset for help on using the changeset viewer.