Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1222)

Side by Side Diff: Source/core/dom/TreeScope.h

Issue 112953007: Make TreeScope::documentScope() return a reference and ensure m_documentScope is never NULL (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added FIXMEs Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/StyleSheetCollection.h ('k') | Source/core/dom/TreeScope.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * Copyright (C) 2012 Apple Inc. All Rights Reserved. 3 * Copyright (C) 2012 Apple Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 void setParentTreeScope(TreeScope*); 57 void setParentTreeScope(TreeScope*);
58 58
59 Element* adjustedFocusedElement() const; 59 Element* adjustedFocusedElement() const;
60 Element* getElementById(const AtomicString&) const; 60 Element* getElementById(const AtomicString&) const;
61 const Vector<Element*>& getAllElementsById(const AtomicString&) const; 61 const Vector<Element*>& getAllElementsById(const AtomicString&) const;
62 bool hasElementWithId(StringImpl* id) const; 62 bool hasElementWithId(StringImpl* id) const;
63 bool containsMultipleElementsWithId(const AtomicString& id) const; 63 bool containsMultipleElementsWithId(const AtomicString& id) const;
64 void addElementById(const AtomicString& elementId, Element*); 64 void addElementById(const AtomicString& elementId, Element*);
65 void removeElementById(const AtomicString& elementId, Element*); 65 void removeElementById(const AtomicString& elementId, Element*);
66 66
67 Document* documentScope() const { return m_documentScope; } 67 Document& documentScope() const
68 {
69 ASSERT(m_documentScope);
70 return *m_documentScope;
71 }
68 72
69 Node* ancestorInThisScope(Node*) const; 73 Node* ancestorInThisScope(Node*) const;
70 74
71 void addImageMap(HTMLMapElement*); 75 void addImageMap(HTMLMapElement*);
72 void removeImageMap(HTMLMapElement*); 76 void removeImageMap(HTMLMapElement*);
73 HTMLMapElement* getImageMap(const String& url) const; 77 HTMLMapElement* getImageMap(const String& url) const;
74 78
75 Element* elementFromPoint(int x, int y) const; 79 Element* elementFromPoint(int x, int y) const;
76 80
77 // For accessibility. 81 // For accessibility.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 132
129 const KURL& baseURL() const { return m_baseURL; } 133 const KURL& baseURL() const { return m_baseURL; }
130 KURL completeURL(const String&) const; 134 KURL completeURL(const String&) const;
131 135
132 protected: 136 protected:
133 TreeScope(ContainerNode*, Document*); 137 TreeScope(ContainerNode*, Document*);
134 TreeScope(Document*); 138 TreeScope(Document*);
135 virtual ~TreeScope(); 139 virtual ~TreeScope();
136 140
137 void destroyTreeScopeData(); 141 void destroyTreeScopeData();
138 void clearDocumentScope(); 142 void setDocumentScope(Document& document) { m_documentScope = &document; }
139 void setDocumentScope(Document* document)
140 {
141 ASSERT(document);
142 m_documentScope = document;
143 }
144 143
145 bool hasGuardRefCount() const { return m_guardRefCount; } 144 bool hasGuardRefCount() const { return m_guardRefCount; }
146 145
147 void setNeedsStyleRecalcForViewportUnits(); 146 void setNeedsStyleRecalcForViewportUnits();
148 147
149 void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; } 148 void setBaseURL(const KURL& baseURL) { m_baseURL = baseURL; }
150 149
151 private: 150 private:
152 TreeScope();
153
154 virtual void dispose() { } 151 virtual void dispose() { }
155 152
156 int refCount() const; 153 int refCount() const;
157 #if SECURITY_ASSERT_ENABLED 154 #if SECURITY_ASSERT_ENABLED
158 bool deletionHasBegun(); 155 bool deletionHasBegun();
159 void beginDeletion(); 156 void beginDeletion();
160 #else 157 #else
161 bool deletionHasBegun() { return false; } 158 bool deletionHasBegun() { return false; }
162 void beginDeletion() { } 159 void beginDeletion() { }
163 #endif 160 #endif
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 inline bool operator!=(const TreeScope& a, const TreeScope& b) { return !(a == b ); } 194 inline bool operator!=(const TreeScope& a, const TreeScope& b) { return !(a == b ); }
198 inline bool operator!=(const TreeScope& a, const TreeScope* b) { return !(a == b ); } 195 inline bool operator!=(const TreeScope& a, const TreeScope* b) { return !(a == b ); }
199 inline bool operator!=(const TreeScope* a, const TreeScope& b) { return !(a == b ); } 196 inline bool operator!=(const TreeScope* a, const TreeScope& b) { return !(a == b ); }
200 197
201 RenderObject* rendererFromPoint(Document*, int x, int y, LayoutPoint* localPoint = 0); 198 RenderObject* rendererFromPoint(Document*, int x, int y, LayoutPoint* localPoint = 0);
202 TreeScope* commonTreeScope(Node*, Node*); 199 TreeScope* commonTreeScope(Node*, Node*);
203 200
204 } // namespace WebCore 201 } // namespace WebCore
205 202
206 #endif // TreeScope_h 203 #endif // TreeScope_h
OLDNEW
« no previous file with comments | « Source/core/dom/StyleSheetCollection.h ('k') | Source/core/dom/TreeScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698