Changeset 137535 in webkit


Ignore:
Timestamp:
Dec 12, 2012 4:32:18 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r137524.
http://trac.webkit.org/changeset/137524
https://bugs.webkit.org/show_bug.cgi?id=104859

Causes m_deletionHasBegun assertion failures in
MutationObserver tests (Requested by aklein on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-12-12

  • dom/Document.cpp:

(WebCore::Document::Document):
(WebCore::Document::~Document):
(WebCore::Document::suggestedMIMEType):

  • dom/Document.h:

(WebCore::Node::isDocumentNode):
(WebCore):
(WebCore::Node::treeScope):
(WebCore::Node::Node):

  • dom/Element.cpp:

(WebCore::Element::createRareData):

  • dom/ElementRareData.h:

(ElementRareData):
(WebCore::ElementRareData::ElementRareData):

  • dom/Node.cpp:

(WebCore::Node::~Node):
(WebCore::Node::setDocument):
(WebCore):
(WebCore::Node::setTreeScope):
(WebCore::Node::createRareData):
(WebCore::Node::attach):
(WebCore::Node::reportMemoryUsage):

  • dom/Node.h:

(WebCore):
(WebCore::NodeRareDataBase::treeScope):
(WebCore::NodeRareDataBase::setTreeScope):
(NodeRareDataBase):
(WebCore::NodeRareDataBase::NodeRareDataBase):
(Node):
(WebCore::Node::inDocument):
(WebCore::Node::documentInternal):

  • dom/NodeRareData.cpp:

(SameSizeAsNodeRareData):
(WebCore::NodeRareData::reportMemoryUsage):

  • dom/NodeRareData.h:

(WebCore::NodeRareData::NodeRareData):

  • dom/ShadowRoot.cpp:

(WebCore::ShadowRoot::ShadowRoot):

  • dom/TreeScope.cpp:

(SameSizeAsTreeScope):
(WebCore::TreeScope::TreeScope):
(WebCore::TreeScope::setParentTreeScope):

  • dom/TreeScope.h:

(WebCore):
(TreeScope):

  • dom/TreeScopeAdopter.cpp:

(WebCore::TreeScopeAdopter::moveTreeToNewScope):
(WebCore::TreeScopeAdopter::moveNodeToNewDocument):

Location:
trunk/Source/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r137534 r137535  
     12012-12-12  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r137524.
     4        http://trac.webkit.org/changeset/137524
     5        https://bugs.webkit.org/show_bug.cgi?id=104859
     6
     7        Causes m_deletionHasBegun assertion failures in
     8        MutationObserver tests (Requested by aklein on #webkit).
     9
     10        * dom/Document.cpp:
     11        (WebCore::Document::Document):
     12        (WebCore::Document::~Document):
     13        (WebCore::Document::suggestedMIMEType):
     14        * dom/Document.h:
     15        (WebCore::Node::isDocumentNode):
     16        (WebCore):
     17        (WebCore::Node::treeScope):
     18        (WebCore::Node::Node):
     19        * dom/Element.cpp:
     20        (WebCore::Element::createRareData):
     21        * dom/ElementRareData.h:
     22        (ElementRareData):
     23        (WebCore::ElementRareData::ElementRareData):
     24        * dom/Node.cpp:
     25        (WebCore::Node::~Node):
     26        (WebCore::Node::setDocument):
     27        (WebCore):
     28        (WebCore::Node::setTreeScope):
     29        (WebCore::Node::createRareData):
     30        (WebCore::Node::attach):
     31        (WebCore::Node::reportMemoryUsage):
     32        * dom/Node.h:
     33        (WebCore):
     34        (WebCore::NodeRareDataBase::treeScope):
     35        (WebCore::NodeRareDataBase::setTreeScope):
     36        (NodeRareDataBase):
     37        (WebCore::NodeRareDataBase::NodeRareDataBase):
     38        (Node):
     39        (WebCore::Node::inDocument):
     40        (WebCore::Node::documentInternal):
     41        * dom/NodeRareData.cpp:
     42        (SameSizeAsNodeRareData):
     43        (WebCore::NodeRareData::reportMemoryUsage):
     44        * dom/NodeRareData.h:
     45        (WebCore::NodeRareData::NodeRareData):
     46        * dom/ShadowRoot.cpp:
     47        (WebCore::ShadowRoot::ShadowRoot):
     48        * dom/TreeScope.cpp:
     49        (SameSizeAsTreeScope):
     50        (WebCore::TreeScope::TreeScope):
     51        (WebCore::TreeScope::setParentTreeScope):
     52        * dom/TreeScope.h:
     53        (WebCore):
     54        (TreeScope):
     55        * dom/TreeScopeAdopter.cpp:
     56        (WebCore::TreeScopeAdopter::moveTreeToNewScope):
     57        (WebCore::TreeScopeAdopter::moveNodeToNewDocument):
     58
    1592012-12-12  Seokju Kwon  <seokju.kwon@gmail.com>
    260
  • trunk/Source/WebCore/dom/Document.cpp

    r137524 r137535  
    437437
    438438Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
    439     : ContainerNode(this, CreateDocument)
     439    : ContainerNode(0, CreateDocument)
    440440    , TreeScope(this)
    441441    , m_guardRefCount(0)
     
    511511#endif
    512512{
     513    m_document = this;
     514
    513515    m_printing = false;
    514516    m_paginatedForScreen = false;
     
    667669    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); i++)
    668670        ASSERT(!m_nodeListCounts[i]);
     671
     672    m_document = 0;
    669673
    670674    InspectorCounters::decrementCounter(InspectorCounters::DocumentCounter);
     
    13421346String Document::suggestedMIMEType() const
    13431347{
    1344     if (isXHTMLDocument())
     1348    if (m_document->isXHTMLDocument())
    13451349        return "application/xhtml+xml";
    1346     if (isSVGDocument())
     1350    if (m_document->isSVGDocument())
    13471351        return "image/svg+xml";
    1348     if (xmlStandalone())
     1352    if (m_document->xmlStandalone())
    13491353        return "text/xml";
    1350     if (isHTMLDocument())
     1354    if (m_document->isHTMLDocument())
    13511355        return "text/html";
    13521356
  • trunk/Source/WebCore/dom/Document.h

    r137524 r137535  
    15601560inline bool Node::isDocumentNode() const
    15611561{
    1562     return this == documentInternal();
     1562    return this == m_document;
     1563}
     1564
     1565inline TreeScope* Node::treeScope() const
     1566{
     1567    return hasRareData() ? m_data.m_rareData->treeScope() : documentInternal();
    15631568}
    15641569
    15651570inline Node::Node(Document* document, ConstructionType type)
    15661571    : m_nodeFlags(type)
    1567     , m_treeScope(document)
     1572    , m_document(document)
    15681573    , m_previous(0)
    15691574    , m_next(0)
     
    15711576    if (document)
    15721577        document->guardRef();
    1573     else
    1574         m_treeScope = TreeScope::noDocumentInstance();
    1575 
    15761578#if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS)
    15771579    trackForDebugging();
  • trunk/Source/WebCore/dom/Element.cpp

    r137524 r137535  
    218218PassOwnPtr<NodeRareData> Element::createRareData()
    219219{
    220     return adoptPtr(new ElementRareData());
     220    return adoptPtr(new ElementRareData(documentInternal()));
    221221}
    222222
  • trunk/Source/WebCore/dom/ElementRareData.h

    r137524 r137535  
    3636class ElementRareData : public NodeRareData {
    3737public:
    38     ElementRareData();
     38    ElementRareData(Document*);
    3939    virtual ~ElementRareData();
    4040
     
    131131}
    132132
    133 inline ElementRareData::ElementRareData()
    134     : m_minimumSizeForResizing(defaultMinimumSizeForResizing())
     133inline ElementRareData::ElementRareData(Document* document)
     134    : NodeRareData(document)
     135    , m_minimumSizeForResizing(defaultMinimumSizeForResizing())
    135136    , m_generatedBefore(0)
    136137    , m_generatedAfter(0)
  • trunk/Source/WebCore/dom/Node.cpp

    r137524 r137535  
    419419        detach();
    420420
    421     Document* doc = documentInternal();
     421    Document* doc = m_document;
    422422    if (AXObjectCache::accessibilityEnabled() && doc && doc->axObjectCacheExists() && !isContainerNode())
    423423        doc->axObjectCache()->remove(this);
     
    432432
    433433    InspectorCounters::decrementCounter(InspectorCounters::NodeCounter);
     434}
     435
     436void Node::setDocument(Document* document)
     437{
     438    ASSERT(!inDocument() || m_document == document);
     439    if (inDocument() || m_document == document)
     440        return;
     441
     442    m_document = document;
     443}
     444
     445void Node::setTreeScope(TreeScope* scope)
     446{
     447    if (!hasRareData() && scope->rootNode()->isDocumentNode())
     448        return;
     449
     450    ensureRareData()->setTreeScope(scope);
    434451}
    435452
     
    455472PassOwnPtr<NodeRareData> Node::createRareData()
    456473{
    457     return adoptPtr(new NodeRareData());
     474    return adoptPtr(new NodeRareData(documentInternal()));
    458475}
    459476
     
    10661083    clearNeedsStyleRecalc();
    10671084
    1068     Document* doc = documentInternal();
     1085    Document* doc = m_document;
    10691086    if (AXObjectCache::accessibilityEnabled() && doc && doc->axObjectCacheExists())
    10701087        doc->axObjectCache()->updateCacheAfterNodeIsAttached(this);
     
    25832600    TreeShared<Node, ContainerNode>::reportMemoryUsage(memoryObjectInfo);
    25842601    ScriptWrappable::reportMemoryUsage(memoryObjectInfo);
    2585     info.addMember(m_treeScope);
     2602    info.addMember(m_document);
    25862603    info.addMember(m_next);
    25872604    info.addMember(m_previous);
  • trunk/Source/WebCore/dom/Node.h

    r137524 r137535  
    3434#include "ScriptWrappable.h"
    3535#include "SimulatedClickOptions.h"
    36 #include "TreeScope.h"
    3736#include "TreeShared.h"
    3837#include <wtf/Forward.h>
     
    8786class ShadowRoot;
    8887class TagNodeList;
     88class TreeScope;
    8989
    9090#if ENABLE(GESTURE_EVENTS)
     
    116116    void setRenderer(RenderObject* renderer) { m_renderer = renderer; }
    117117
     118    TreeScope* treeScope() const { return m_treeScope; }
     119    void setTreeScope(TreeScope* scope) { m_treeScope = scope; }
     120
    118121    virtual ~NodeRareDataBase() { }
    119122protected:
    120     NodeRareDataBase() { }
     123    NodeRareDataBase(TreeScope* scope)
     124        : m_treeScope(scope)
     125    {
     126    }
    121127private:
    122128    RenderObject* m_renderer;
     129    TreeScope* m_treeScope;
    123130};
    124131
     
    453460    }
    454461
    455     TreeScope* treeScope() const { return m_treeScope; }
     462    TreeScope* treeScope() const;
    456463
    457464    // Returns true if this node is associated with a document and is in its associated document's
     
    459466    bool inDocument() const
    460467    {
    461         ASSERT(documentInternal() || !getFlag(InDocumentFlag));
     468        ASSERT(m_document || !getFlag(InDocumentFlag));
    462469        return getFlag(InDocumentFlag);
    463470    }
     
    750757    void setHasCustomCallbacks() { setFlag(true, HasCustomCallbacksFlag); }
    751758
    752     Document* documentInternal() const { return treeScope()->documentScope(); }
    753     void setTreeScope(TreeScope* scope) { m_treeScope = scope; }
     759    Document* documentInternal() const { return m_document; }
    754760
    755761private:
     
    757763
    758764    void removedLastRef();
     765
     766    // These API should be only used for a tree scope migration.
     767    void setTreeScope(TreeScope*);
     768    void setDocument(Document*);
    759769
    760770    enum EditableLevel { Editable, RichlyEditable };
     
    800810
    801811    mutable uint32_t m_nodeFlags;
    802     TreeScope* m_treeScope;
     812    Document* m_document;
    803813    Node* m_previous;
    804814    Node* m_next;
  • trunk/Source/WebCore/dom/NodeRareData.cpp

    r137524 r137535  
    4040
    4141struct SameSizeAsNodeRareData {
    42     void* m_pointer[3];
     42    void* m_pointer[4];
    4343    unsigned m_indicesAndBitfields[2];
    4444
     
    6565{
    6666    MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM);
     67    info.addMember(treeScope());
    6768    info.addMember(m_nodeLists);
    6869
  • trunk/Source/WebCore/dom/NodeRareData.h

    r137524 r137535  
    247247
    248248public:   
    249     NodeRareData()
    250         : m_tabIndex(0)
     249    NodeRareData(Document* document)
     250        : NodeRareDataBase(document)
     251        , m_tabIndex(0)
    251252        , m_childIndex(0)
    252253        , m_tabIndexWasSetExplicitly(false)
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r137524 r137535  
    6666ShadowRoot::ShadowRoot(Document* document)
    6767    : DocumentFragment(document, CreateShadowRoot)
    68     , TreeScope(this, document)
     68    , TreeScope(this)
    6969    , m_prev(0)
    7070    , m_next(0)
     
    7676{
    7777    ASSERT(document);
    78     setTreeScope(this);
     78   
     79    // Assume document as parent scope.
     80    setParentTreeScope(document);
     81    // Shadow tree scopes have the scope pointer point to themselves.
     82    // This way, direct children will receive the correct scope pointer.
     83    ensureRareData()->setTreeScope(this);
    7984}
    8085
  • trunk/Source/WebCore/dom/TreeScope.cpp

    r137524 r137535  
    5656struct SameSizeAsTreeScope {
    5757    virtual ~SameSizeAsTreeScope();
    58     void* pointers[8];
     58    void* pointers[7];
    5959};
    6060
     
    6363using namespace HTMLNames;
    6464
    65 TreeScope::TreeScope(ContainerNode* rootNode, Document* document)
     65TreeScope::TreeScope(ContainerNode* rootNode)
    6666    : m_rootNode(rootNode)
    67     , m_documentScope(document)
    68     , m_parentTreeScope(document)
    69     , m_idTargetObserverRegistry(IdTargetObserverRegistry::create())
    70 {
    71     ASSERT(rootNode);
    72     ASSERT(document);
    73     ASSERT(rootNode != document);
    74 }
    75 
    76 TreeScope::TreeScope(Document* document)
    77     : m_rootNode(document)
    78     , m_documentScope(document)
    7967    , m_parentTreeScope(0)
    8068    , m_idTargetObserverRegistry(IdTargetObserverRegistry::create())
    8169{
    82     ASSERT(document);
    83 }
    84 
    85 TreeScope::TreeScope()
    86     : m_rootNode(0)
    87     , m_documentScope(0)
    88     , m_parentTreeScope(0)
    89 {
     70    ASSERT(rootNode);
    9071}
    9172
     
    11394
    11495    m_parentTreeScope = newParentScope;
    115     setDocumentScope(newParentScope->documentScope());
    11696}
    11797
  • trunk/Source/WebCore/dom/TreeScope.h

    r137524 r137535  
    3636class ContainerNode;
    3737class DOMSelection;
    38 class Document;
    3938class Element;
    4039class HTMLLabelElement;
     
    4847class TreeScope {
    4948    friend class Document;
    50     friend class TreeScopeAdopter;
    5149
    5250public:
     
    6058    void addElementById(const AtomicString& elementId, Element*);
    6159    void removeElementById(const AtomicString& elementId, Element*);
    62 
    63     Document* documentScope() const { return m_documentScope; }
    6460
    6561    Node* ancestorInThisScope(Node*) const;
     
    9692    virtual void reportMemoryUsage(MemoryObjectInfo*) const;
    9793
    98     static TreeScope* noDocumentInstance()
    99     {
    100         DEFINE_STATIC_LOCAL(TreeScope, instance, ());
    101         return &instance;
    102     }
    103 
    10494protected:
    105     TreeScope(ContainerNode*, Document*);
    106     TreeScope(Document*);
     95    explicit TreeScope(ContainerNode*);
    10796    virtual ~TreeScope();
    10897
    10998    void destroyTreeScopeData();
    110     void setDocumentScope(Document* document)
    111     {
    112         ASSERT(document);
    113         ASSERT(this != noDocumentInstance());
    114         m_documentScope = document;
    115     }
    11699
    117100private:
    118     TreeScope();
    119 
    120101    ContainerNode* m_rootNode;
    121     Document* m_documentScope;
    122102    TreeScope* m_parentTreeScope;
    123103
  • trunk/Source/WebCore/dom/TreeScopeAdopter.cpp

    r137524 r137535  
    4444    // of the document it was moved to. By increasing the DOMTreeVersion of the donating document here
    4545    // we ensure that the collection cache will be invalidated as needed when the element is moved back.
    46     Document* oldDocument = m_oldScope->documentScope();
    47     Document* newDocument = m_newScope->documentScope();
     46    Document* oldDocument = m_oldScope ? m_oldScope->rootNode()->document() : 0;
     47    Document* newDocument = m_newScope->rootNode()->document();
    4848    bool willMoveToNewDocument = oldDocument != newDocument;
    4949    if (oldDocument && willMoveToNewDocument)
     
    5252    for (Node* node = root; node; node = NodeTraversal::next(node, root)) {
    5353        node->setTreeScope(m_newScope);
    54 
    5554        if (node->hasRareData()) {
    5655            NodeRareData* rareData = node->rareData();
     
    9998        oldDocument->moveNodeIteratorsToNewDocument(node, newDocument);
    10099
    101     if (node->isShadowRoot())
    102         toShadowRoot(node)->setDocumentScope(newDocument);
     100    node->setDocument(newDocument);
    103101
    104102#ifndef NDEBUG
Note: See TracChangeset for help on using the changeset viewer.