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

Side by Side Diff: sky/engine/core/dom/Document.cpp

Issue 928393003: Remove the concept of document.documentElement (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « sky/engine/core/dom/Document.h ('k') | sky/engine/core/dom/Document.idl » ('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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 , m_startTime(currentTime()) 243 , m_startTime(currentTime())
244 , m_renderView(0) 244 , m_renderView(0)
245 #if !ENABLE(OILPAN) 245 #if !ENABLE(OILPAN)
246 , m_weakFactory(this) 246 , m_weakFactory(this)
247 #endif 247 #endif
248 , m_contextDocument(initializer.contextDocument()) 248 , m_contextDocument(initializer.contextDocument())
249 , m_loadEventDelayCount(0) 249 , m_loadEventDelayCount(0)
250 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) 250 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired)
251 , m_didSetReferrerPolicy(false) 251 , m_didSetReferrerPolicy(false)
252 , m_referrerPolicy(ReferrerPolicyDefault) 252 , m_referrerPolicy(ReferrerPolicyDefault)
253 , m_directionSetOnDocumentElement(false)
254 , m_registrationContext(initializer.registrationContext()) 253 , m_registrationContext(initializer.registrationContext())
255 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi red) 254 , m_elementDataCacheClearTimer(this, &Document::elementDataCacheClearTimerFi red)
256 , m_timeline(AnimationTimeline::create(this)) 255 , m_timeline(AnimationTimeline::create(this))
257 , m_templateDocumentHost(nullptr) 256 , m_templateDocumentHost(nullptr)
258 , m_hasViewportUnits(false) 257 , m_hasViewportUnits(false)
259 , m_styleRecalcElementCounter(0) 258 , m_styleRecalcElementCounter(0)
260 { 259 {
261 setClient(this); 260 setClient(this);
262 261
263 if (!m_registrationContext) 262 if (!m_registrationContext)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 void Document::dispose() 346 void Document::dispose()
348 { 347 {
349 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); 348 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun);
350 349
351 // We must make sure not to be retaining any of our children through 350 // We must make sure not to be retaining any of our children through
352 // these extra pointers or we will create a reference cycle. 351 // these extra pointers or we will create a reference cycle.
353 m_focusedElement = nullptr; 352 m_focusedElement = nullptr;
354 m_hoverNode = nullptr; 353 m_hoverNode = nullptr;
355 m_activeHoverElement = nullptr; 354 m_activeHoverElement = nullptr;
356 m_titleElement = nullptr; 355 m_titleElement = nullptr;
357 m_documentElement = nullptr;
358 m_userActionElements.documentDidRemoveLastRef(); 356 m_userActionElements.documentDidRemoveLastRef();
359 357
360 detachParser(); 358 detachParser();
361 359
362 m_registrationContext.clear(); 360 m_registrationContext.clear();
363 361
364 if (m_importsController) 362 if (m_importsController)
365 HTMLImportsController::removeFrom(*this); 363 HTMLImportsController::removeFrom(*this);
366 364
367 // removeDetachedChildren() doesn't always unregister IDs, 365 // removeDetachedChildren() doesn't always unregister IDs,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 401 }
404 402
405 Location* Document::location() const 403 Location* Document::location() const
406 { 404 {
407 if (!frame()) 405 if (!frame())
408 return 0; 406 return 0;
409 407
410 return &domWindow()->location(); 408 return &domWindow()->location();
411 } 409 }
412 410
413 void Document::childrenChanged(const ChildrenChange& change)
414 {
415 ContainerNode::childrenChanged(change);
416 m_documentElement = ElementTraversal::firstWithin(*this);
417 }
418
419 PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionS tate& exceptionState) 411 PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionS tate& exceptionState)
420 { 412 {
421 if (!isValidName(name)) { 413 if (!isValidName(name)) {
422 exceptionState.ThrowDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name."); 414 exceptionState.ThrowDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name.");
423 return nullptr; 415 return nullptr;
424 } 416 }
425 417
426 return HTMLElementFactory::createHTMLElement(name, *this, false); 418 return HTMLElementFactory::createHTMLElement(name, *this, false);
427 } 419 }
428 420
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 1028
1037 // Uncomment to enable printing of statistics about style sharing and the ma tched property cache. 1029 // Uncomment to enable printing of statistics about style sharing and the ma tched property cache.
1038 // Optionally pass StyleResolver::ReportSlowStats to print numbers that requ ire crawling the 1030 // Optionally pass StyleResolver::ReportSlowStats to print numbers that requ ire crawling the
1039 // entire DOM (where collecting them is very slow). 1031 // entire DOM (where collecting them is very slow).
1040 // FIXME: Expose this as a runtime flag. 1032 // FIXME: Expose this as a runtime flag.
1041 // styleResolver().enableStats(/*StyleResolver::ReportSlowStats*/); 1033 // styleResolver().enableStats(/*StyleResolver::ReportSlowStats*/);
1042 1034
1043 if (StyleResolverStats* stats = styleResolver().stats()) 1035 if (StyleResolverStats* stats = styleResolver().stats())
1044 stats->reset(); 1036 stats->reset();
1045 1037
1046 if (Element* documentElement = this->documentElement()) { 1038 for (Element* element = ElementTraversal::firstChild(*this); element; elemen t = ElementTraversal::nextSibling(*element)) {
1047 if (documentElement->shouldCallRecalcStyle(change)) 1039 if (element->shouldCallRecalcStyle(change))
1048 documentElement->recalcStyle(change); 1040 element->recalcStyle(change);
1049 } 1041 }
1050 1042
1051 styleResolver().printStats(); 1043 styleResolver().printStats();
1052 1044
1053 view()->recalcOverflowAfterStyleChange(); 1045 view()->recalcOverflowAfterStyleChange();
1054 1046
1055 clearChildNeedsStyleRecalc(); 1047 clearChildNeedsStyleRecalc();
1056 1048
1057 m_styleEngine->resolver().clearStyleSharingList(); 1049 m_styleEngine->resolver().clearStyleSharingList();
1058 1050
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 return &m_documentLoadTiming; 2153 return &m_documentLoadTiming;
2162 } 2154 }
2163 2155
2164 IntSize Document::initialViewportSize() const 2156 IntSize Document::initialViewportSize() const
2165 { 2157 {
2166 if (!view()) 2158 if (!view())
2167 return IntSize(); 2159 return IntSize();
2168 return view()->unscaledVisibleContentSize(); 2160 return view()->unscaledVisibleContentSize();
2169 } 2161 }
2170 2162
2171 Node* eventTargetNodeForDocument(Document* doc)
2172 {
2173 if (!doc)
2174 return 0;
2175 Node* node = doc->focusedElement();
2176 if (!node)
2177 node = doc->documentElement();
2178 return node;
2179 }
2180
2181 void Document::decrementActiveParserCount() 2163 void Document::decrementActiveParserCount()
2182 { 2164 {
2183 --m_activeParserCount; 2165 --m_activeParserCount;
2184 } 2166 }
2185 2167
2186 Document& Document::ensureTemplateDocument() 2168 Document& Document::ensureTemplateDocument()
2187 { 2169 {
2188 if (isTemplateDocument()) 2170 if (isTemplateDocument())
2189 return *this; 2171 return *this;
2190 2172
(...skipping 20 matching lines...) Expand all
2211 2193
2212 DocumentLifecycleNotifier& Document::lifecycleNotifier() 2194 DocumentLifecycleNotifier& Document::lifecycleNotifier()
2213 { 2195 {
2214 return static_cast<DocumentLifecycleNotifier&>(LifecycleContext<Document>::l ifecycleNotifier()); 2196 return static_cast<DocumentLifecycleNotifier&>(LifecycleContext<Document>::l ifecycleNotifier());
2215 } 2197 }
2216 2198
2217 Element* Document::activeElement() const 2199 Element* Document::activeElement() const
2218 { 2200 {
2219 if (Element* element = treeScope().adjustedFocusedElement()) 2201 if (Element* element = treeScope().adjustedFocusedElement())
2220 return element; 2202 return element;
2221 return documentElement(); 2203 return nullptr;
2222 } 2204 }
2223 2205
2224 void Document::getTransitionElementData(Vector<TransitionElementData>& elementDa ta) 2206 void Document::getTransitionElementData(Vector<TransitionElementData>& elementDa ta)
2225 { 2207 {
2226 } 2208 }
2227 2209
2228 bool Document::hasFocus() const 2210 bool Document::hasFocus() const
2229 { 2211 {
2230 Page* page = this->page(); 2212 Page* page = this->page();
2231 if (!page) 2213 if (!page)
(...skipping 10 matching lines...) Expand all
2242 using namespace blink; 2224 using namespace blink;
2243 void showLiveDocumentInstances() 2225 void showLiveDocumentInstances()
2244 { 2226 {
2245 WeakDocumentSet& set = liveDocumentSet(); 2227 WeakDocumentSet& set = liveDocumentSet();
2246 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 2228 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
2247 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 2229 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
2248 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 2230 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
2249 } 2231 }
2250 } 2232 }
2251 #endif 2233 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Document.h ('k') | sky/engine/core/dom/Document.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698