Changeset 217549 in webkit


Ignore:
Timestamp:
May 30, 2017 1:35:40 AM (7 years ago)
Author:
Antti Koivisto
Message:

Crash on display-contents-replaced-001.html
https://bugs.webkit.org/show_bug.cgi?id=172596

Reviewed by Andreas Kling.

Source/WebCore:

This is crashing because some code can't handle display:contents on form controls. Turns
out the draft specification tell us to disable it for them in any case.

See https://drafts.csswg.org/css-display-3/#unbox

  • css/StyleResolver.cpp:

(WebCore::hasEffectiveDisplayNoneForDisplayContents):

For certain HTML elements (replaced elements, form controls) display:contents should
behave like display:none.
Also disable it for SVG and MathML elements.

(WebCore::StyleResolver::adjustRenderStyle):

Also compute to display:none when there is no associated element (pseudos etc).

LayoutTests:

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r217548 r217549  
     12017-05-29  Antti Koivisto  <antti@apple.com>
     2
     3        Crash on display-contents-replaced-001.html
     4        https://bugs.webkit.org/show_bug.cgi?id=172596
     5
     6        Reviewed by Andreas Kling.
     7
     8        * TestExpectations: Enable the test.
     9
    1102017-05-30  Zan Dobersek  <zdobersek@igalia.com>
    211
  • trunk/LayoutTests/TestExpectations

    r217536 r217549  
    11791179webkit.org/b/157477 imported/w3c/web-platform-tests/css/css-display-3/display-contents-dynamic-list-001-none.html [ ImageOnlyFailure ]
    11801180
    1181 webkit.org/b/172596 imported/w3c/web-platform-tests/css/css-display-3/display-contents-replaced-001.html [ Skip ]
    1182 
    11831181### END OF display: contents failures
    11841182########################################
  • trunk/Source/WebCore/ChangeLog

    r217548 r217549  
     12017-05-29  Antti Koivisto  <antti@apple.com>
     2
     3        Crash on display-contents-replaced-001.html
     4        https://bugs.webkit.org/show_bug.cgi?id=172596
     5
     6        Reviewed by Andreas Kling.
     7
     8        This is crashing because some code can't handle display:contents on form controls. Turns
     9        out the draft specification tell us to disable it for them in any case.
     10
     11        See https://drafts.csswg.org/css-display-3/#unbox
     12
     13        * css/StyleResolver.cpp:
     14        (WebCore::hasEffectiveDisplayNoneForDisplayContents):
     15
     16            For certain HTML elements (replaced elements, form controls) display:contents should
     17            behave like display:none.
     18            Also disable it for SVG and MathML elements.
     19
     20        (WebCore::StyleResolver::adjustRenderStyle):
     21
     22            Also compute to display:none when there is no associated element (pseudos etc).
     23
    1242017-05-30  Zan Dobersek  <zdobersek@igalia.com>
    225
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r217536 r217549  
    8888#include "LinkHash.h"
    8989#include "LocaleToScriptMapping.h"
     90#include "MathMLElement.h"
    9091#include "MathMLNames.h"
    9192#include "MediaList.h"
     
    785786}
    786787
     788static bool hasEffectiveDisplayNoneForDisplayContents(const Element& element)
     789{
     790    // https://drafts.csswg.org/css-display-3/#unbox-html
     791    static NeverDestroyed<HashSet<AtomicString>> tagNames = [] {
     792        static const HTMLQualifiedName* const tagList[] = {
     793            &brTag,
     794            &wbrTag,
     795            &meterTag,
     796            &appletTag,
     797            &progressTag,
     798            &canvasTag,
     799            &embedTag,
     800            &objectTag,
     801            &audioTag,
     802            &iframeTag,
     803            &imgTag,
     804            &videoTag,
     805            &frameTag,
     806            &framesetTag,
     807            &inputTag,
     808            &textareaTag,
     809            &selectTag,
     810        };
     811        HashSet<AtomicString> set;
     812        for (auto& name : tagList)
     813            set.add(name->localName());
     814        return set;
     815    }();
     816
     817    // https://drafts.csswg.org/css-display-3/#unbox-svg
     818    // FIXME: <g>, <use> and <tspan> have special (?) behavior for display:contents in the current draft spec.
     819    if (is<SVGElement>(element))
     820        return true;
     821    // Not sure MathML code can handle it.
     822    if (is<MathMLElement>(element))
     823        return true;
     824    if (!is<HTMLElement>(element))
     825        return false;
     826    return tagNames.get().contains(element.localName());
     827}
     828
    787829void StyleResolver::adjustRenderStyle(RenderStyle& style, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle, const Element* element)
    788830{
     
    796838
    797839    if (style.display() == CONTENTS) {
    798         // FIXME: Enable for all elements.
    799840        bool elementSupportsDisplayContents = is<HTMLSlotElement>(element) || RuntimeEnabledFeatures::sharedFeatures().displayContentsEnabled();
    800841        if (!elementSupportsDisplayContents)
    801842            style.setDisplay(INLINE);
     843        else if (!element || hasEffectiveDisplayNoneForDisplayContents(*element))
     844            style.setDisplay(NONE);
    802845    }
    803846
Note: See TracChangeset for help on using the changeset viewer.