Changeset 109179 in webkit


Ignore:
Timestamp:
Feb 28, 2012 5:43:50 PM (12 years ago)
Author:
morrita@google.com
Message:

<content> element should behave as HTMLUnknownElement outside of a shadow DOM subtree
https://bugs.webkit.org/show_bug.cgi?id=79551

Reviewed by Dimitri Glazkov.

Source/WebCore:

The problem happened because HTMLContentElement doesn't create renderer anytime.

This change allows it to create a renderer unless the HTMLContentElement is shadowed.
Since this could happen not only on <content> but also on upcoming <shadow>,
the corresponding part of the code is pulled up to InsertionPoint.

Tests: fast/dom/shadow/content-element-outside-shadow-style-expected.html

fast/dom/shadow/content-element-outside-shadow-style.html

  • dom/NodeRenderingContext.cpp:

(WebCore::NodeRenderingContext::NodeRenderingContext):

  • dom/ShadowRoot.h:

(WebCore):
(WebCore::TreeScope::isShadowRoot):

  • dom/TreeScope.h:

(TreeScope):

  • html/shadow/HTMLContentElement.h:
  • html/shadow/InsertionPoint.cpp:

(WebCore::InsertionPoint::isShadowBoundary):
(WebCore):

  • html/shadow/InsertionPoint.h:

(InsertionPoint):
(WebCore::isShadowBoundary):
(WebCore):

LayoutTests:

  • fast/dom/shadow/content-element-outside-shadow-style-expected.html: Added.
  • fast/dom/shadow/content-element-outside-shadow-style.html: Added.
  • fast/dom/shadow/content-element-outside-shadow.html:
  • platform/efl/Skipped:
  • platform/gtk/Skipped:
  • platform/mac/Skipped:
  • platform/qt/Skipped:
  • platform/win/Skipped:
  • platform/wk2/Skipped:
Location:
trunk
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r109177 r109179  
     12012-02-27  MORITA Hajime  <morrita@google.com>
     2
     3        <content> element should behave as HTMLUnknownElement outside of a shadow DOM subtree
     4        https://bugs.webkit.org/show_bug.cgi?id=79551
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        * fast/dom/shadow/content-element-outside-shadow-style-expected.html: Added.
     9        * fast/dom/shadow/content-element-outside-shadow-style.html: Added.
     10        * fast/dom/shadow/content-element-outside-shadow.html:
     11        * platform/efl/Skipped:
     12        * platform/gtk/Skipped:
     13        * platform/mac/Skipped:
     14        * platform/qt/Skipped:
     15        * platform/win/Skipped:
     16        * platform/wk2/Skipped:
     17
    1182012-02-28  Gavin Barraclough  <barraclough@apple.com>
    219
  • trunk/LayoutTests/fast/dom/shadow/content-element-outside-shadow.html

    r105917 r109179  
    1919var cases = [
    2020    ["<div><content></content></div>",
    21      "<div></div>"],
     21     "<div><unknown></unknown></div>"],
    2222    ["<div><content>Here is a text.</content></div>",
    23      "<div>Here is a text.</div>"],
     23     "<div><unknown>Here is a text.</unknown></div>"],
    2424    ["<div><content><div>Here is a </div><div>series of</div><div>blocks</div></content></div>",
    25      "<div><div>Here is a </div><div>series of</div><div>blocks</div></div>"],
     25     "<div><unknown><div>Here is a </div><div>series of</div><div>blocks</div></unknown></div>"],
    2626    ["<div><content><span>Here is a<span><span>series of</span><span>inlines.</span></content></div>",
    27      "<div><span>Here is a<span><span>series of</span><span>inlines.</span></div>"],
     27     "<div><unknown><span>Here is a<span><span>series of</span><span>inlines.</span></unknown></div>"],
    2828    ["<div><content>Here is a <content>nested content</content> inside content.</content></div>",
    29      "<div>Here is a <" + "!-- --" + ">nested content<" + "!-- --" + "> inside content.</div>"],
     29     "<div><unknown>Here is a <unknown>nested content</unknown> inside content.</unknown></div>"],
    3030    ["<div><content>Here is a <div>block and <content>nested content</content> inside the block</div>.</content></div>",
    31      "<div>Here is a <div>block and <!" + "-- --" + ">nested content<!" + "-- --" + "> inside the block</div>.</div>"]
     31     "<div><unknown>Here is a <div>block and <unknown>nested content</unknown> inside the block</div>.</unknown></div>"]
    3232];
    3333
     
    4242    comparisonContainer.innerHTML = expectedMarkup;
    4343    targetRenderTree = removeContainerLines(window.internals.elementRenderTreeAsText(targetContainer));
     44    targetRenderTree = targetRenderTree.replace(/CONTENT/g, "UNKNOWN");
    4445    comparisonRenderTree = removeContainerLines(window.internals.elementRenderTreeAsText(comparisonContainer));
    4546    debug(escapeHTML(targetMarkup));
  • trunk/LayoutTests/platform/efl/Skipped

    r109096 r109179  
    20882088fast/dom/shadow/content-element-api.html
    20892089fast/dom/shadow/content-element-outside-shadow.html
     2090fast/dom/shadow/content-element-outside-shadow-style.html
    20902091fast/dom/shadow/shadow-root-js-api.html
    20912092fast/dom/shadow/shadow-disable.html
  • trunk/LayoutTests/platform/mac/Skipped

    r109096 r109179  
    426426fast/dom/shadow/content-element-api.html
    427427fast/dom/shadow/content-element-outside-shadow.html
     428fast/dom/shadow/content-element-outside-shadow-style.html
    428429fast/dom/shadow/shadow-root-js-api.html
    429430fast/dom/shadow/shadow-disable.html
  • trunk/LayoutTests/platform/qt/Skipped

    r109167 r109179  
    162162fast/dom/shadow/content-element-api.html
    163163fast/dom/shadow/content-element-outside-shadow.html
     164fast/dom/shadow/content-element-outside-shadow-style.html
    164165fast/dom/shadow/iframe-shadow.html
    165166fast/dom/shadow/shadow-root-js-api.html
  • trunk/LayoutTests/platform/win/Skipped

    r109156 r109179  
    14521452fast/dom/shadow/content-element-api.html
    14531453fast/dom/shadow/content-element-outside-shadow.html
     1454fast/dom/shadow/content-element-outside-shadow-style.html
    14541455fast/dom/shadow/shadow-root-js-api.html
    14551456fast/dom/shadow/shadow-disable.html
  • trunk/LayoutTests/platform/wk2/Skipped

    r109096 r109179  
    10661066fast/dom/shadow/content-element-api.html
    10671067fast/dom/shadow/content-element-outside-shadow.html
     1068fast/dom/shadow/content-element-outside-shadow-style.html
    10681069fast/dom/shadow/shadow-root-js-api.html
    10691070fast/dom/shadow/shadow-disable.html
  • trunk/Source/WebCore/ChangeLog

    r109176 r109179  
     12012-02-27  MORITA Hajime  <morrita@google.com>
     2
     3        <content> element should behave as HTMLUnknownElement outside of a shadow DOM subtree
     4        https://bugs.webkit.org/show_bug.cgi?id=79551
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        The problem happened because HTMLContentElement doesn't create renderer anytime.
     9       
     10        This change allows it to create a renderer unless the HTMLContentElement is shadowed.
     11        Since this could happen not only on <content> but also on upcoming <shadow>,
     12        the corresponding part of the code is pulled up to InsertionPoint.
     13
     14        Tests: fast/dom/shadow/content-element-outside-shadow-style-expected.html
     15               fast/dom/shadow/content-element-outside-shadow-style.html
     16
     17        * dom/NodeRenderingContext.cpp:
     18        (WebCore::NodeRenderingContext::NodeRenderingContext):
     19        * dom/ShadowRoot.h:
     20        (WebCore):
     21        (WebCore::TreeScope::isShadowRoot):
     22        * dom/TreeScope.h:
     23        (TreeScope):
     24        * html/shadow/HTMLContentElement.h:
     25        * html/shadow/InsertionPoint.cpp:
     26        (WebCore::InsertionPoint::isShadowBoundary):
     27        (WebCore):
     28        * html/shadow/InsertionPoint.h:
     29        (InsertionPoint):
     30        (WebCore::isShadowBoundary):
     31        (WebCore):
     32
    1332012-02-28  Daniel Cheng  <dcheng@chromium.org>
    234
  • trunk/Source/WebCore/dom/NodeRenderingContext.cpp

    r109096 r109179  
    8888        }
    8989
    90         if (isInsertionPoint(parent)) {
     90        if (isShadowBoundary(parent)) {
    9191            if (toInsertionPoint(parent)->hasSelection())
    9292                m_phase = AttachingNotFallbacked;
  • trunk/Source/WebCore/dom/ShadowRoot.h

    r109096 r109179  
    103103}
    104104
     105// Put this TreeScope method here to inline it.
     106inline bool TreeScope::isShadowRoot() const
     107{
     108    return m_rootNode->isShadowRoot();
     109}
     110
    105111} // namespace
    106112
  • trunk/Source/WebCore/dom/TreeScope.h

    r106530 r109179  
    6161    void removeNodeListCache() { ASSERT(m_numNodeListCaches > 0); --m_numNodeListCaches; }
    6262    bool hasNodeListCaches() const { return m_numNodeListCaches; }
     63    bool isShadowRoot() const;
    6364
    6465    // Find first anchor with the given name.
  • trunk/Source/WebCore/html/shadow/HTMLContentElement.h

    r108303 r109179  
    6464private:
    6565    virtual bool isContentElement() const { return true; }
    66     virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; }
    67     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) { return 0; }
    68 
    6966    virtual void parseAttribute(Attribute*) OVERRIDE;
    7067};
  • trunk/Source/WebCore/html/shadow/InsertionPoint.cpp

    r108303 r109179  
    3232#include "InsertionPoint.h"
    3333
     34#include "ShadowRoot.h"
     35
    3436namespace WebCore {
    3537
     
    4446}
    4547
     48bool InsertionPoint::isShadowBoundary() const
     49{
     50    if (TreeScope* scope = treeScope())
     51        return scope->isShadowRoot();
     52    return false;
     53}
     54
     55bool InsertionPoint::rendererIsNeeded(const NodeRenderingContext& context)
     56{
     57    return !isShadowBoundary() && HTMLElement::rendererIsNeeded(context);
     58}
     59
    4660} // namespace WebCore
  • trunk/Source/WebCore/html/shadow/InsertionPoint.h

    r108480 r109179  
    4343    const HTMLContentSelectionList* selections() const { return &m_selections; }
    4444    bool hasSelection() const { return m_selections.first(); }
     45    bool isShadowBoundary() const;
    4546
    4647protected:
    4748    InsertionPoint(const QualifiedName&, Document*);
     49    virtual bool rendererIsNeeded(const NodeRenderingContext&) OVERRIDE;
     50
    4851    HTMLContentSelectionList m_selections;
    4952};
     
    6568}
    6669
     70inline bool isShadowBoundary(Node* node)
     71{
     72    if (!isInsertionPoint(node))
     73        return false;
     74    return toInsertionPoint(node)->isShadowBoundary();
     75}
     76
    6777} // namespace WebCore
    6878
Note: See TracChangeset for help on using the changeset viewer.