Changeset 82882 in webkit


Ignore:
Timestamp:
Apr 4, 2011 3:25:18 PM (13 years ago)
Author:
rolandsteiner@chromium.org
Message:

2011-04-04 Roland Steiner <rolandsteiner@chromium.org>

Reviewed by NOBODY (OOPS!).

Bug 57689 - Extract scoping functionality from Document
https://bugs.webkit.org/show_bug.cgi?id=57689

Moved selfOnlyRef (renamed to guardRef), element ID, image map
and accesss key functionalities from Document to a new base
class TreeScope.

TreeShared: made removedLastRef protected

No new tests. (refactoring)

  • Android.mk:
  • CMakeLists.txt:
  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/Document.cpp: (WebCore::Document::Document): (WebCore::Document::destroyScope): (WebCore::Document::getElementById): (WebCore::Document::childrenChanged): (WebCore::Document::scheduleStyleRecalc): (WebCore::Document::attach): (WebCore::Document::detach):
  • dom/Document.h: (WebCore::Node::Node):
  • dom/DocumentOrderedMap.cpp: (WebCore::DocumentOrderedMap::get): (WebCore::DocumentOrderedMap::getElementById): (WebCore::DocumentOrderedMap::getElementByMapName): (WebCore::DocumentOrderedMap::getElementByLowercasedMapName):
  • dom/DocumentOrderedMap.h:
  • dom/DOMAllInOne.cpp:
  • dom/Node.cpp: (WebCore::Node::~Node): (WebCore::Node::setDocument):
  • dom/Node.h:
  • dom/TreeScope.cpp: Added.
  • dom/TreeScope.h: Added.
  • platform/TreeShared.h: (WebCore::TreeShared::removedLastRef): made protected
Location:
trunk/Source/WebCore
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/Android.mk

    r82880 r82882  
    189189        dom/TouchList.cpp \
    190190        dom/Traversal.cpp \
     191        dom/TreeScope.cpp \
    191192        dom/TreeWalker.cpp \
    192193        dom/UIEvent.cpp \
  • trunk/Source/WebCore/CMakeLists.txt

    r82880 r82882  
    615615    dom/TransformSourceLibxslt.cpp
    616616    dom/Traversal.cpp
     617    dom/TreeScope.cpp
    617618    dom/TreeWalker.cpp
    618619    dom/UIEvent.cpp
  • trunk/Source/WebCore/ChangeLog

    r82880 r82882  
     12011-04-04  Roland Steiner  <rolandsteiner@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Bug 57689 - Extract scoping functionality from Document
     6        https://bugs.webkit.org/show_bug.cgi?id=57689
     7
     8        Moved selfOnlyRef (renamed to guardRef), element ID, image map
     9        and accesss key functionalities from Document to a new base
     10        class TreeScope.
     11
     12        TreeShared: made removedLastRef protected
     13
     14        No new tests. (refactoring)
     15
     16        * Android.mk:
     17        * CMakeLists.txt:
     18        * GNUmakefile.am:
     19        * WebCore.gypi:
     20        * WebCore.pro:
     21        * WebCore.vcproj/WebCore.vcproj:
     22        * WebCore.xcodeproj/project.pbxproj:
     23        * dom/Document.cpp:
     24        (WebCore::Document::Document):
     25        (WebCore::Document::destroyScope):
     26        (WebCore::Document::getElementById):
     27        (WebCore::Document::childrenChanged):
     28        (WebCore::Document::scheduleStyleRecalc):
     29        (WebCore::Document::attach):
     30        (WebCore::Document::detach):
     31        * dom/Document.h:
     32        (WebCore::Node::Node):
     33        * dom/DocumentOrderedMap.cpp:
     34        (WebCore::DocumentOrderedMap::get):
     35        (WebCore::DocumentOrderedMap::getElementById):
     36        (WebCore::DocumentOrderedMap::getElementByMapName):
     37        (WebCore::DocumentOrderedMap::getElementByLowercasedMapName):
     38        * dom/DocumentOrderedMap.h:
     39        * dom/DOMAllInOne.cpp:
     40        * dom/Node.cpp:
     41        (WebCore::Node::~Node):
     42        (WebCore::Node::setDocument):
     43        * dom/Node.h:
     44        * dom/TreeScope.cpp: Added.
     45        * dom/TreeScope.h: Added.
     46        * platform/TreeShared.h:
     47        (WebCore::TreeShared::removedLastRef): made protected
     48
    1492011-04-04  MORITA Hajime  <morrita@google.com>
    250
  • trunk/Source/WebCore/GNUmakefile.am

    r82880 r82882  
    13531353        Source/WebCore/dom/Traversal.h \
    13541354        Source/WebCore/dom/TreeDepthLimit.h \
     1355        Source/WebCore/dom/TreeScope.cpp \
     1356        Source/WebCore/dom/TreeScope.h \
    13551357        Source/WebCore/dom/TreeWalker.cpp \
    13561358        Source/WebCore/dom/TreeWalker.h \
  • trunk/Source/WebCore/WebCore.gypi

    r82880 r82882  
    25462546            'dom/Traversal.h',
    25472547            'dom/TreeDepthLimit.h',
     2548            'dom/TreeScope.cpp',
     2549            'dom/TreeScope.h',
    25482550            'dom/TreeWalker.cpp',
    25492551            'dom/TreeWalker.h',
  • trunk/Source/WebCore/WebCore.pro

    r82880 r82882  
    545545    dom/TouchList.cpp \
    546546    dom/Traversal.cpp \
     547    dom/TreeScope.cpp \
    547548    dom/TreeWalker.cpp \
    548549    dom/UIEvent.cpp \
     
    15081509    dom/Traversal.h \
    15091510    dom/TreeDepthLimit.h \
     1511    dom/TreeScope.h \
    15101512    dom/TreeWalker.h \
    15111513    dom/UIEvent.h \
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r82880 r82882  
    4707947079                        </File>
    4708047080                        <File
     47081                                RelativePath="..\dom\TreeScope.cpp"
     47082                                >
     47083                                <FileConfiguration
     47084                                        Name="Debug|Win32"
     47085                                        ExcludedFromBuild="true"
     47086                                        >
     47087                                        <Tool
     47088                                                Name="VCCLCompilerTool"
     47089                                        />
     47090                                </FileConfiguration>
     47091                                <FileConfiguration
     47092                                        Name="Release|Win32"
     47093                                        ExcludedFromBuild="true"
     47094                                        >
     47095                                        <Tool
     47096                                                Name="VCCLCompilerTool"
     47097                                        />
     47098                                </FileConfiguration>
     47099                                <FileConfiguration
     47100                                        Name="Debug_Cairo_CFLite|Win32"
     47101                                        ExcludedFromBuild="true"
     47102                                        >
     47103                                        <Tool
     47104                                                Name="VCCLCompilerTool"
     47105                                        />
     47106                                </FileConfiguration>
     47107                                <FileConfiguration
     47108                                        Name="Release_Cairo_CFLite|Win32"
     47109                                        ExcludedFromBuild="true"
     47110                                        >
     47111                                        <Tool
     47112                                                Name="VCCLCompilerTool"
     47113                                        />
     47114                                </FileConfiguration>
     47115                                <FileConfiguration
     47116                                        Name="Debug_All|Win32"
     47117                                        ExcludedFromBuild="true"
     47118                                        >
     47119                                        <Tool
     47120                                                Name="VCCLCompilerTool"
     47121                                        />
     47122                                </FileConfiguration>
     47123                                <FileConfiguration
     47124                                        Name="Production|Win32"
     47125                                        ExcludedFromBuild="true"
     47126                                        >
     47127                                        <Tool
     47128                                                Name="VCCLCompilerTool"
     47129                                        />
     47130                                </FileConfiguration>
     47131                        </File>
     47132                        <File
     47133                                RelativePath="..\dom\TreeScope.h"
     47134                                >
     47135                        </File>
     47136                        <File
    4708147137                                RelativePath="..\dom\TreeWalker.h"
    4708247138                                >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r82880 r82882  
    317317                14CF7B3309F6ECD700EB3665 /* JSCSSRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14CF7B3109F6ECD700EB3665 /* JSCSSRule.cpp */; };
    318318                14CF7B3409F6ECD700EB3665 /* JSCSSRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 14CF7B3209F6ECD700EB3665 /* JSCSSRule.h */; };
     319                14D64B5C134A5B6B00E58FDA /* TreeScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14D64B5A134A5B6B00E58FDA /* TreeScope.cpp */; };
     320                14D64B5D134A5B6B00E58FDA /* TreeScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D64B5B134A5B6B00E58FDA /* TreeScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
    319321                14D823520AF92A790004F057 /* Chrome.h in Headers */ = {isa = PBXBuildFile; fileRef = 14D823500AF92A790004F057 /* Chrome.h */; settings = {ATTRIBUTES = (Private, ); }; };
    320322                14D8238B0AF92DF60004F057 /* Chrome.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14D8238A0AF92DF60004F057 /* Chrome.cpp */; };
     
    66966698                14CF7B3209F6ECD700EB3665 /* JSCSSRule.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCSSRule.h; sourceTree = "<group>"; };
    66976699                14CF7C2009F7110600EB3665 /* KeyboardEvent.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = KeyboardEvent.idl; sourceTree = "<group>"; };
     6700                14D64B5A134A5B6B00E58FDA /* TreeScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TreeScope.cpp; sourceTree = "<group>"; };
     6701                14D64B5B134A5B6B00E58FDA /* TreeScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeScope.h; sourceTree = "<group>"; };
    66986702                14D823500AF92A790004F057 /* Chrome.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Chrome.h; sourceTree = "<group>"; };
    66996703                14D8238A0AF92DF60004F057 /* Chrome.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Chrome.cpp; sourceTree = "<group>"; };
     
    1943819442                                854FE72D0A2297BE0058D7AD /* Traversal.h */,
    1943919443                                37FD4297118368460093C029 /* TreeDepthLimit.h */,
     19444                                14D64B5A134A5B6B00E58FDA /* TreeScope.cpp */,
     19445                                14D64B5B134A5B6B00E58FDA /* TreeScope.h */,
    1944019446                                854FE72E0A2297BE0058D7AD /* TreeWalker.cpp */,
    1944119447                                854FE72F0A2297BE0058D7AD /* TreeWalker.h */,
     
    2120921215                                4F707A9A11EF679400ACDA69 /* InspectorBackendDispatcher.h in Headers */,
    2121021216                                F3D4C47912E07663003DA150 /* InspectorBrowserDebuggerAgent.h in Headers */,
    21211                                 227777601345DEA9008EA455 /* InspectorFrontendChannel.h in Headers */,
    2121221217                                1C81B95C0E97330800266E07 /* InspectorClient.h in Headers */,
    2121321218                                F3335BF912E07DC300D33011 /* InspectorConsoleAgent.h in Headers */,
     
    2122221227                                7A74ECBB101839A600BF939E /* InspectorDOMStorageAgent.h in Headers */,
    2122321228                                41F061740F5F00AC00A07EAC /* InspectorDOMStorageResource.h in Headers */,
     21229                                227777601345DEA9008EA455 /* InspectorFrontendChannel.h in Headers */,
    2122421230                                F344C7141125B82C00F26EEE /* InspectorFrontendClient.h in Headers */,
    2122521231                                F344C75311294D9D00F26EEE /* InspectorFrontendClientLocal.h in Headers */,
     
    2259722603                                854FE7370A2297BE0058D7AD /* Traversal.h in Headers */,
    2259822604                                37FD4298118368460093C029 /* TreeDepthLimit.h in Headers */,
     22605                                14D64B5D134A5B6B00E58FDA /* TreeScope.h in Headers */,
    2259922606                                1419D2C50CEA6F6100FF507A /* TreeShared.h in Headers */,
    2260022607                                854FE7390A2297BE0058D7AD /* TreeWalker.h in Headers */,
     
    2530525312                                49E911D10EF86D47009D0CAF /* TranslateTransformOperation.cpp in Sources */,
    2530625313                                854FE7360A2297BE0058D7AD /* Traversal.cpp in Sources */,
     25314                                14D64B5C134A5B6B00E58FDA /* TreeScope.cpp in Sources */,
    2530725315                                854FE7380A2297BE0058D7AD /* TreeWalker.cpp in Sources */,
    2530825316                                93309E19099E64920056E581 /* TypingCommand.cpp in Sources */,
  • trunk/Source/WebCore/dom/DOMAllInOne.cpp

    r82127 r82882  
    122122#include "TransformSourceLibxslt.cpp"
    123123#include "Traversal.cpp"
     124#include "TreeScope.cpp"
    124125#include "TreeWalker.cpp"
    125126#include "UIEvent.cpp"
  • trunk/Source/WebCore/dom/Document.cpp

    r82580 r82882  
    378378
    379379Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
    380     : ContainerNode(0)
     380    : TreeScope(0)
    381381    , m_compatibilityMode(NoQuirksMode)
    382382    , m_compatibilityModeLocked(false)
     
    400400    , m_savedRenderer(0)
    401401    , m_designMode(inherit)
    402     , m_selfOnlyRefCount(0)
    403402#if ENABLE(SVG)
    404403    , m_svgExtensions(0)
     
    408407    , m_dashboardRegionsDirty(false)
    409408#endif
    410     , m_accessKeyMapValid(false)
    411409    , m_createRenderers(true)
    412410    , m_inPageCache(false)
     
    416414    , m_usesViewSourceStyles(false)
    417415    , m_sawElementsInKnownNamespaces(false)
    418     , m_numNodeListCaches(0)
    419416#if USE(JSC)
    420417    , m_normalWorldWrapperCache(0)
     
    512509}
    513510
    514 void Document::removedLastRef()
     511void Document::destroyScope()
    515512{
    516513    ASSERT(!m_deletionHasBegun);
    517     if (m_selfOnlyRefCount) {
    518         // If removing a child removes the last self-only ref, we don't
    519         // want the document to be destructed until after
    520         // removeAllChildren returns, so we guard ourselves with an
    521         // extra self-only ref.
    522         selfOnlyRef();
    523 
    524         // We must make sure not to be retaining any of our children through
    525         // these extra pointers or we will create a reference cycle.
    526         m_docType = 0;
    527         m_focusedNode = 0;
    528         m_hoverNode = 0;
    529         m_activeNode = 0;
    530         m_titleElement = 0;
    531         m_documentElement = 0;
     514
     515    // We must make sure not to be retaining any of our children through
     516    // these extra pointers or we will create a reference cycle.
     517    m_docType = 0;
     518    m_focusedNode = 0;
     519    m_hoverNode = 0;
     520    m_activeNode = 0;
     521    m_titleElement = 0;
     522    m_documentElement = 0;
    532523#if ENABLE(FULLSCREEN_API)
    533         m_fullScreenElement = 0;
    534 #endif
    535 
    536         // removeAllChildren() doesn't always unregister IDs, do it upfront to avoid having stale references in the map.
    537         m_elementsById.clear();
    538 
    539         removeAllChildren();
    540 
    541         m_markers->detach();
    542 
    543         detachParser();
    544 
    545         m_cssCanvasElements.clear();
     524    m_fullScreenElement = 0;
     525#endif
     526
     527    TreeScope::destroyScope();
     528
     529    m_markers->detach();
     530
     531    detachParser();
     532
     533    m_cssCanvasElements.clear();
    546534
    547535#if ENABLE(REQUEST_ANIMATION_FRAME)
    548         // FIXME: consider using ActiveDOMObject.
    549         m_scriptedAnimationController = 0;
     536    // FIXME: consider using ActiveDOMObject.
     537    m_scriptedAnimationController = 0;
    550538#endif
    551539
    552540#ifndef NDEBUG
    553         m_inRemovedLastRefFunction = false;
    554 #endif
    555 
    556         selfOnlyDeref();
    557     } else {
    558 #ifndef NDEBUG
    559         m_deletionHasBegun = true;
    560 #endif
    561         delete this;
    562     }
     541    m_inRemovedLastRefFunction = false;
     542#endif
    563543}
    564544
     
    622602}
    623603
     604Element* Document::getElementById(const AtomicString& id) const
     605{
     606    return TreeScope::getElementById(id);
     607}
     608
    624609MediaQueryMatcher* Document::mediaQueryMatcher()
    625610{
     
    710695void Document::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
    711696{
    712     ContainerNode::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
     697    TreeScope::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
    713698   
    714699    // Invalidate the document element we have cached in case it was replaced.
     
    1003988}
    1004989
    1005 Element* Document::getElementById(const AtomicString& elementId) const
    1006 {
    1007     if (elementId.isEmpty())
    1008         return 0;
    1009     return m_elementsById.getElementById(elementId.impl(), this);
    1010 }
    1011 
    1012990String Document::readyState() const
    1013991{
     
    12361214}
    12371215
    1238 void Document::addElementById(const AtomicString& elementId, Element* element)
    1239 {
    1240     m_elementsById.add(elementId.impl(), element);
    1241 }
    1242 
    1243 void Document::removeElementById(const AtomicString& elementId, Element* element)
    1244 {
    1245     m_elementsById.remove(elementId.impl(), element);
    1246 }
    1247 
    1248 Element* Document::getElementByAccessKey(const String& key) const
    1249 {
    1250     if (key.isEmpty())
    1251         return 0;
    1252     if (!m_accessKeyMapValid) {
    1253         for (Node* n = firstChild(); n; n = n->traverseNextNode()) {
    1254             if (!n->isElementNode())
    1255                 continue;
    1256             Element* element = static_cast<Element*>(n);
    1257             const AtomicString& accessKey = element->getAttribute(accesskeyAttr);
    1258             if (!accessKey.isEmpty())
    1259                 m_elementsByAccessKey.set(accessKey.impl(), element);
    1260         }
    1261         m_accessKeyMapValid = true;
    1262     }
    1263     return m_elementsByAccessKey.get(key.impl());
    1264 }
    1265 
    12661216/*
    12671217 * Performs three operations:
     
    14611411   
    14621412    // FIXME: Why on earth is this here? This is clearly misplaced.
    1463     if (m_accessKeyMapValid) {
    1464         m_accessKeyMapValid = false;
    1465         m_elementsByAccessKey.clear();
    1466     }
     1413    invalidateAccessKeyMap();
    14671414   
    14681415    m_styleRecalcTimer.startOneShot(0);
     
    17561703    setRenderer(0);
    17571704
    1758     ContainerNode::attach();
     1705    TreeScope::attach();
    17591706
    17601707    setRenderer(render);
     
    18131760    m_activeNode = 0;
    18141761
    1815     ContainerNode::detach();
     1762    TreeScope::detach();
    18161763
    18171764    unscheduleStyleRecalc();
     
    38963843}
    38973844
    3898 void Document::addImageMap(HTMLMapElement* imageMap)
    3899 {
    3900     AtomicStringImpl* name = imageMap->getName().impl();
    3901     if (!name)
    3902         return;
    3903     m_imageMapsByName.add(name, imageMap);
    3904 }
    3905 
    3906 void Document::removeImageMap(HTMLMapElement* imageMap)
    3907 {
    3908     AtomicStringImpl* name = imageMap->getName().impl();
    3909     if (!name)
    3910         return;
    3911     m_imageMapsByName.remove(name, imageMap);
    3912 }
    3913 
    3914 HTMLMapElement* Document::getImageMap(const String& url) const
    3915 {
    3916     if (url.isNull())
    3917         return 0;
    3918     size_t hashPos = url.find('#');
    3919     String name = (hashPos == notFound ? url : url.substring(hashPos + 1)).impl();
    3920     if (isHTMLDocument())
    3921         return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this));
    3922     return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByMapName(AtomicString(name).impl(), this));
    3923 }
    3924 
    39253845void Document::setDecoder(PassRefPtr<TextResourceDecoder> decoder)
    39263846{
     
    47714691}
    47724692
    4773 Element* Document::findAnchor(const String& name)
    4774 {
    4775     if (name.isEmpty())
    4776         return 0;
    4777     if (Element* element = getElementById(name))
    4778         return element;
    4779     for (Node* node = this; node; node = node->traverseNextNode()) {
    4780         if (node->hasTagName(aTag)) {
    4781             HTMLAnchorElement* anchor = static_cast<HTMLAnchorElement*>(node);
    4782             if (inQuirksMode()) {
    4783                 // Quirks mode, case insensitive comparison of names.
    4784                 if (equalIgnoringCase(anchor->name(), name))
    4785                     return anchor;
    4786             } else {
    4787                 // Strict mode, names need to match exactly.
    4788                 if (anchor->name() == name)
    4789                     return anchor;
    4790             }
    4791         }
    4792     }
    4793     return 0;
    4794 }
    4795 
    47964693String Document::displayStringModifiedByEncoding(const String& str) const
    47974694{
  • trunk/Source/WebCore/dom/Document.h

    r82580 r82882  
    3232#include "CollectionType.h"
    3333#include "Color.h"
    34 #include "ContainerNode.h"
    3534#include "DOMTimeStamp.h"
    36 #include "DocumentOrderedMap.h"
    3735#include "DocumentTiming.h"
    3836#include "QualifiedName.h"
     
    4038#include "StringWithDirection.h"
    4139#include "Timer.h"
     40#include "TreeScope.h"
    4241#include "ViewportArguments.h"
    4342#include <wtf/FixedArray.h>
     
    207206enum StyleSelectorUpdateFlag { RecalcStyleImmediately, DeferRecalcStyle };
    208207
    209 class Document : public ContainerNode, public ScriptExecutionContext {
     208class Document : public TreeScope, public ScriptExecutionContext {
    210209public:
    211210    static PassRefPtr<Document> create(Frame* frame, const KURL& url)
     
    221220    MediaQueryMatcher* mediaQueryMatcher();
    222221
    223     using ContainerNode::ref;
    224     using ContainerNode::deref;
    225 
    226     // Nodes belonging to this document hold "self-only" references -
    227     // these are enough to keep the document from being destroyed, but
    228     // not enough to keep it from removing its children. This allows a
    229     // node that outlives its document to still have a valid document
    230     // pointer without introducing reference cycles
    231 
    232     void selfOnlyRef()
    233     {
    234         ASSERT(!m_deletionHasBegun);
    235         ++m_selfOnlyRefCount;
    236     }
    237     void selfOnlyDeref()
    238     {
    239         ASSERT(!m_deletionHasBegun);
    240         --m_selfOnlyRefCount;
    241         if (!m_selfOnlyRefCount && !refCount()) {
    242 #ifndef NDEBUG
    243             m_deletionHasBegun = true;
    244 #endif
    245             delete this;
    246         }
    247     }
     222    using TreeScope::ref;
     223    using TreeScope::deref;
     224
     225    Element* getElementById(const AtomicString& id) const;
    248226
    249227    // DOM methods & attributes for Document
     
    330308    virtual PassRefPtr<Element> createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionCode&);
    331309    PassRefPtr<Element> createElement(const QualifiedName&, bool createdByParser);
    332     Element* getElementById(const AtomicString&) const;
    333     bool hasElementWithId(AtomicStringImpl* id) const;
    334     bool containsMultipleElementsWithId(const AtomicString& id) const;
    335310
    336311    /**
     
    396371    PassRefPtr<HTMLAllCollection> all();
    397372
    398     // Find first anchor with the given name.
    399     // First searches for an element with the given ID, but if that fails, then looks
    400     // for an anchor with the given name. ID matching is always case sensitive, but
    401     // Anchor name matching is case sensitive in strict mode and not case sensitive in
    402     // quirks mode for historical compatibility reasons.
    403     Element* findAnchor(const String& name);
    404 
    405373    CollectionCache* collectionInfo(CollectionType type)
    406374    {
     
    453421    }
    454422
    455     Element* getElementByAccessKey(const String& key) const;
    456    
    457423    /**
    458424     * Updates the pending sheet count and then calls updateStyleSelector.
     
    868834    static bool hasPrefixNamespaceMismatch(const QualifiedName&);
    869835   
    870     void addElementById(const AtomicString& elementId, Element *element);
    871     void removeElementById(const AtomicString& elementId, Element *element);
    872 
    873     void addImageMap(HTMLMapElement*);
    874     void removeImageMap(HTMLMapElement*);
    875     HTMLMapElement* getImageMap(const String& url) const;
    876 
    877836    HTMLElement* body() const;
    878837    void setBody(PassRefPtr<HTMLElement>, ExceptionCode&);
     
    947906    bool useSecureKeyboardEntryWhenActive() const;
    948907
    949     void addNodeListCache() { ++m_numNodeListCaches; }
    950     void removeNodeListCache() { ASSERT(m_numNodeListCaches > 0); --m_numNodeListCaches; }
    951     bool hasNodeListCaches() const { return m_numNodeListCaches; }
    952 
    953908    void updateFocusAppearanceSoon(bool restorePreviousSelection);
    954909    void cancelFocusAppearanceUpdate();
     
    11311086    Document(Frame*, const KURL&, bool isXHTML, bool isHTML);
    11321087
     1088    virtual void destroyScope();
     1089
    11331090    void clearXMLVersion() { m_xmlVersion = String(); }
    11341091
     
    11421099
    11431100    virtual bool isDocument() const { return true; }
    1144     virtual void removedLastRef();
    11451101
    11461102    virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
     
    13291285#endif
    13301286
    1331     DocumentOrderedMap m_imageMapsByName;
    1332 
    13331287    int m_docID; // A unique document identifier used for things like document-specific mapped attributes.
    13341288
     
    13471301    RefPtr<TextResourceDecoder> m_decoder;
    13481302
    1349     DocumentOrderedMap m_elementsById;
    1350    
    1351     mutable HashMap<StringImpl*, Element*, CaseFoldingHash> m_elementsByAccessKey;
    1352    
    13531303    InheritedBool m_designMode;
    13541304   
    1355     int m_selfOnlyRefCount;
    1356 
    13571305    CheckedRadioButtons m_checkedRadioButtons;
    13581306
     
    13771325    HashMap<String, RefPtr<HTMLCanvasElement> > m_cssCanvasElements;
    13781326
    1379     mutable bool m_accessKeyMapValid;
    13801327    bool m_createRenderers;
    13811328    bool m_inPageCache;
     
    13931340    bool m_usesViewSourceStyles;
    13941341    bool m_sawElementsInKnownNamespaces;
    1395 
    1396     unsigned m_numNodeListCaches;
    13971342
    13981343#if USE(JSC)
     
    14431388};
    14441389
    1445 inline bool Document::hasElementWithId(AtomicStringImpl* id) const
    1446 {
    1447     ASSERT(id);
    1448     return m_elementsById.contains(id);
    1449 }
    1450 
    1451 inline bool Document::containsMultipleElementsWithId(const AtomicString& id) const
    1452 {
    1453     return m_elementsById.containsMultiple(id.impl());
    1454 }
    1455    
    14561390inline bool Node::isDocumentNode() const
    14571391{
     
    14681402{
    14691403    if (m_document)
    1470         m_document->selfOnlyRef();
     1404        m_document->guardRef();
    14711405#if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS)
    14721406    trackForDebugging();
  • trunk/Source/WebCore/dom/DocumentOrderedMap.cpp

    r77239 r82882  
    3535#include "HTMLMapElement.h"
    3636#include "HTMLNames.h"
     37#include "TreeScope.h"
    3738
    3839namespace WebCore {
     
    105106
    106107template<bool keyMatches(AtomicStringImpl*, Element*)>
    107 inline Element* DocumentOrderedMap::get(AtomicStringImpl* key, const Document* document) const
     108inline Element* DocumentOrderedMap::get(AtomicStringImpl* key, const TreeScope* scope) const
    108109{
    109110    ASSERT(key);
     
    117118    if (m_duplicateCounts.contains(key)) {
    118119        // We know there's at least one node that matches; iterate to find the first one.
    119         for (Node* node = document->firstChild(); node; node = node->traverseNextNode()) {
     120        for (Node* node = scope->firstChild(); node; node = node->traverseNextNode()) {
    120121            if (!node->isElementNode())
    121122                continue;
     
    133134}
    134135
    135 Element* DocumentOrderedMap::getElementById(AtomicStringImpl* key, const Document* document) const
     136Element* DocumentOrderedMap::getElementById(AtomicStringImpl* key, const TreeScope* scope) const
    136137{
    137     return get<keyMatchesId>(key, document);
     138    return get<keyMatchesId>(key, scope);
    138139}
    139140
    140 Element* DocumentOrderedMap::getElementByMapName(AtomicStringImpl* key, const Document* document) const
     141Element* DocumentOrderedMap::getElementByMapName(AtomicStringImpl* key, const TreeScope* scope) const
    141142{
    142     return get<keyMatchesMapName>(key, document);
     143    return get<keyMatchesMapName>(key, scope);
    143144}
    144145
    145 Element* DocumentOrderedMap::getElementByLowercasedMapName(AtomicStringImpl* key, const Document* document) const
     146Element* DocumentOrderedMap::getElementByLowercasedMapName(AtomicStringImpl* key, const TreeScope* scope) const
    146147{
    147     return get<keyMatchesLowercasedMapName>(key, document);
     148    return get<keyMatchesLowercasedMapName>(key, scope);
    148149}
    149150
  • trunk/Source/WebCore/dom/DocumentOrderedMap.h

    r77239 r82882  
    3838namespace WebCore {
    3939
    40 class Document;
    4140class Element;
     41class TreeScope;
    4242
    4343class DocumentOrderedMap {
     
    5050    bool containsMultiple(AtomicStringImpl*) const;
    5151    // concrete instantiations of the get<>() method template
    52     Element* getElementById(AtomicStringImpl*, const Document*) const;
    53     Element* getElementByMapName(AtomicStringImpl*, const Document*) const;
    54     Element* getElementByLowercasedMapName(AtomicStringImpl*, const Document*) const;
     52    Element* getElementById(AtomicStringImpl*, const TreeScope*) const;
     53    Element* getElementByMapName(AtomicStringImpl*, const TreeScope*) const;
     54    Element* getElementByLowercasedMapName(AtomicStringImpl*, const TreeScope*) const;
    5555
    5656    void checkConsistency() const;
    5757
    5858private:
    59     template<bool keyMatches(AtomicStringImpl*, Element*)> Element* get(AtomicStringImpl*, const Document*) const;
     59    template<bool keyMatches(AtomicStringImpl*, Element*)> Element* get(AtomicStringImpl*, const TreeScope*) const;
    6060
    6161    typedef HashMap<AtomicStringImpl*, Element*> Map;
  • trunk/Source/WebCore/dom/Node.cpp

    r82264 r82882  
    407407
    408408    if (m_document)
    409         m_document->selfOnlyDeref();
     409        m_document->guardDeref();
    410410}
    411411
     
    443443        return;
    444444
    445     document->selfOnlyRef();
     445    document->guardRef();
    446446
    447447    setWillMoveToNewOwnerDocumentWasCalled(false);
     
    461461    if (m_document) {
    462462        m_document->moveNodeIteratorsToNewDocument(this, document);
    463         m_document->selfOnlyDeref();
     463        m_document->guardDeref();
    464464    }
    465465
     
    795795}
    796796
    797 void Node::setDocumentRecursively(Document* document)
    798 {
    799     if (this->document() == document)
     797void Node::setDocumentRecursively(Document* newDocument)
     798{
     799    if (document() == newDocument)
    800800        return;
    801801
     
    804804    // of the document it was moved to. By increasing the DOMTreeVersion of the donating document here
    805805    // we ensure that the collection cache will be invalidated as needed when the element is moved back.
    806     if (this->document())
    807         this->document()->incDOMTreeVersion();
     806    if (document())
     807        document()->incDOMTreeVersion();
    808808
    809809    for (Node* node = this; node; node = node->traverseNextNode(this)) {
    810         node->setDocument(document);
     810        node->setDocument(newDocument);
    811811        if (!node->isElementNode())
    812812            continue;
    813813        if (Node* shadow = toElement(node)->shadowRoot())
    814             shadow->setDocumentRecursively(document);
     814            shadow->setDocumentRecursively(newDocument);
    815815    }
    816816}
  • trunk/Source/WebCore/platform/TreeShared.h

    r76248 r82882  
    110110#endif
    111111
    112 private:
    113 #ifndef NDEBUG
    114     friend void adopted<>(TreeShared<T>*);
    115 #endif
    116 
     112protected:
    117113    virtual void removedLastRef()
    118114    {
     
    122118        delete this;
    123119    }
     120
     121private:
     122#ifndef NDEBUG
     123    friend void adopted<>(TreeShared<T>*);
     124#endif
    124125
    125126    int m_refCount;
Note: See TracChangeset for help on using the changeset viewer.