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

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

Issue 871383002: Merge HTMLDocument into Document (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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 #include "sky/engine/core/events/ScopedEventQueue.h" 86 #include "sky/engine/core/events/ScopedEventQueue.h"
87 #include "sky/engine/core/fetch/ResourceFetcher.h" 87 #include "sky/engine/core/fetch/ResourceFetcher.h"
88 #include "sky/engine/core/frame/FrameConsole.h" 88 #include "sky/engine/core/frame/FrameConsole.h"
89 #include "sky/engine/core/frame/FrameHost.h" 89 #include "sky/engine/core/frame/FrameHost.h"
90 #include "sky/engine/core/frame/FrameView.h" 90 #include "sky/engine/core/frame/FrameView.h"
91 #include "sky/engine/core/frame/LocalDOMWindow.h" 91 #include "sky/engine/core/frame/LocalDOMWindow.h"
92 #include "sky/engine/core/frame/LocalFrame.h" 92 #include "sky/engine/core/frame/LocalFrame.h"
93 #include "sky/engine/core/frame/Settings.h" 93 #include "sky/engine/core/frame/Settings.h"
94 #include "sky/engine/core/html/HTMLAnchorElement.h" 94 #include "sky/engine/core/html/HTMLAnchorElement.h"
95 #include "sky/engine/core/html/HTMLCanvasElement.h" 95 #include "sky/engine/core/html/HTMLCanvasElement.h"
96 #include "sky/engine/core/html/HTMLDocument.h"
97 #include "sky/engine/core/html/HTMLScriptElement.h" 96 #include "sky/engine/core/html/HTMLScriptElement.h"
98 #include "sky/engine/core/html/HTMLStyleElement.h" 97 #include "sky/engine/core/html/HTMLStyleElement.h"
99 #include "sky/engine/core/html/HTMLTemplateElement.h" 98 #include "sky/engine/core/html/HTMLTemplateElement.h"
100 #include "sky/engine/core/html/HTMLTitleElement.h" 99 #include "sky/engine/core/html/HTMLTitleElement.h"
101 #include "sky/engine/core/html/canvas/CanvasRenderingContext.h" 100 #include "sky/engine/core/html/canvas/CanvasRenderingContext.h"
102 #include "sky/engine/core/html/canvas/CanvasRenderingContext2D.h" 101 #include "sky/engine/core/html/canvas/CanvasRenderingContext2D.h"
103 #include "sky/engine/core/html/canvas/WebGLRenderingContext.h" 102 #include "sky/engine/core/html/canvas/WebGLRenderingContext.h"
104 #include "sky/engine/core/html/imports/HTMLImportChild.h" 103 #include "sky/engine/core/html/imports/HTMLImportChild.h"
105 #include "sky/engine/core/html/imports/HTMLImportLoader.h" 104 #include "sky/engine/core/html/imports/HTMLImportLoader.h"
106 #include "sky/engine/core/html/imports/HTMLImportTreeRoot.h" 105 #include "sky/engine/core/html/imports/HTMLImportTreeRoot.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 227
229 #ifndef NDEBUG 228 #ifndef NDEBUG
230 typedef HashSet<RawPtr<Document> > WeakDocumentSet; 229 typedef HashSet<RawPtr<Document> > WeakDocumentSet;
231 static WeakDocumentSet& liveDocumentSet() 230 static WeakDocumentSet& liveDocumentSet()
232 { 231 {
233 DEFINE_STATIC_LOCAL(OwnPtr<WeakDocumentSet>, set, (adoptPtr(new WeakDocument Set()))); 232 DEFINE_STATIC_LOCAL(OwnPtr<WeakDocumentSet>, set, (adoptPtr(new WeakDocument Set())));
234 return *set; 233 return *set;
235 } 234 }
236 #endif 235 #endif
237 236
238 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses) 237 Document::Document(const DocumentInit& initializer)
239 : ContainerNode(0, CreateDocument) 238 : ContainerNode(0, CreateDocument)
240 , TreeScope(*this) 239 , TreeScope(*this)
241 , m_module(nullptr) 240 , m_module(nullptr)
242 , m_evaluateMediaQueriesOnStyleRecalc(false) 241 , m_evaluateMediaQueriesOnStyleRecalc(false)
243 , m_frame(initializer.frame()) 242 , m_frame(initializer.frame())
244 , m_domWindow(m_frame ? m_frame->domWindow() : 0) 243 , m_domWindow(m_frame ? m_frame->domWindow() : 0)
245 , m_importsController(initializer.importsController()) 244 , m_importsController(initializer.importsController())
246 , m_activeParserCount(0) 245 , m_activeParserCount(0)
247 , m_resumeParserWaitingForResourcesTimer(this, &Document::resumeParserWaitin gForResourcesTimerFired) 246 , m_resumeParserWaitingForResourcesTimer(this, &Document::resumeParserWaitin gForResourcesTimerFired)
248 , m_clearFocusedElementTimer(this, &Document::clearFocusedElementTimerFired) 247 , m_clearFocusedElementTimer(this, &Document::clearFocusedElementTimerFired)
249 , m_listenerTypes(0) 248 , m_listenerTypes(0)
250 , m_mutationObserverTypes(0) 249 , m_mutationObserverTypes(0)
251 , m_readyState(Complete) 250 , m_readyState(Complete)
252 , m_isParsing(false) 251 , m_isParsing(false)
253 , m_containsValidityStyleRules(false) 252 , m_containsValidityStyleRules(false)
254 , m_markers(adoptPtr(new DocumentMarkerController)) 253 , m_markers(adoptPtr(new DocumentMarkerController))
255 , m_loadEventProgress(LoadEventNotRun) 254 , m_loadEventProgress(LoadEventNotRun)
256 , m_startTime(currentTime()) 255 , m_startTime(currentTime())
257 , m_documentClasses(documentClasses)
258 , m_renderView(0) 256 , m_renderView(0)
259 #if !ENABLE(OILPAN) 257 #if !ENABLE(OILPAN)
260 , m_weakFactory(this) 258 , m_weakFactory(this)
261 #endif 259 #endif
262 , m_contextDocument(initializer.contextDocument()) 260 , m_contextDocument(initializer.contextDocument())
263 , m_loadEventDelayCount(0) 261 , m_loadEventDelayCount(0)
264 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) 262 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired)
265 , m_didSetReferrerPolicy(false) 263 , m_didSetReferrerPolicy(false)
266 , m_referrerPolicy(ReferrerPolicyDefault) 264 , m_referrerPolicy(ReferrerPolicyDefault)
267 , m_directionSetOnDocumentElement(false) 265 , m_directionSetOnDocumentElement(false)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 345
348 setClient(0); 346 setClient(0);
349 347
350 InspectorCounters::decrementCounter(InspectorCounters::DocumentCounter); 348 InspectorCounters::decrementCounter(InspectorCounters::DocumentCounter);
351 } 349 }
352 350
353 PassRefPtr<Document> Document::create(Document& document) 351 PassRefPtr<Document> Document::create(Document& document)
354 { 352 {
355 DocumentInit init = DocumentInit::fromContext(document.contextDocument()) 353 DocumentInit init = DocumentInit::fromContext(document.contextDocument())
356 .withRegistrationContext(document.registrationContext()); 354 .withRegistrationContext(document.registrationContext());
357 return HTMLDocument::create(init); 355 return adoptRef(new Document(init));
358 } 356 }
359 357
360 #if !ENABLE(OILPAN) 358 #if !ENABLE(OILPAN)
361 void Document::dispose() 359 void Document::dispose()
362 { 360 {
363 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); 361 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun);
364 362
365 // We must make sure not to be retaining any of our children through 363 // We must make sure not to be retaining any of our children through
366 // these extra pointers or we will create a reference cycle. 364 // these extra pointers or we will create a reference cycle.
367 m_focusedElement = nullptr; 365 m_focusedElement = nullptr;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 ContainerNode::childrenChanged(change); 429 ContainerNode::childrenChanged(change);
432 m_documentElement = ElementTraversal::firstWithin(*this); 430 m_documentElement = ElementTraversal::firstWithin(*this);
433 } 431 }
434 432
435 PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionS tate& exceptionState) 433 PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionS tate& exceptionState)
436 { 434 {
437 if (!isValidName(name)) { 435 if (!isValidName(name)) {
438 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name."); 436 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name.");
439 return nullptr; 437 return nullptr;
440 } 438 }
441 if (isHTMLDocument())
442 return HTMLElementFactory::createHTMLElement(name, *this, false);
443 439
444 return Element::create(QualifiedName(name), this); 440 return HTMLElementFactory::createHTMLElement(name, *this, false);
445 } 441 }
446 442
447 ScriptValue Document::registerElement(ScriptState* scriptState, const AtomicStri ng& name, ExceptionState& exceptionState) 443 ScriptValue Document::registerElement(ScriptState* scriptState, const AtomicStri ng& name, ExceptionState& exceptionState)
448 { 444 {
449 return registerElement(scriptState, name, Dictionary(), exceptionState); 445 return registerElement(scriptState, name, Dictionary(), exceptionState);
450 } 446 }
451 447
452 ScriptValue Document::registerElement(ScriptState* scriptState, const AtomicStri ng& name, const Dictionary& options, ExceptionState& exceptionState) 448 ScriptValue Document::registerElement(ScriptState* scriptState, const AtomicStri ng& name, const Dictionary& options, ExceptionState& exceptionState)
453 { 449 {
454 CustomElementConstructorBuilder constructorBuilder(scriptState, &options); 450 CustomElementConstructorBuilder constructorBuilder(scriptState, &options);
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 } 791 }
796 792
797 void Document::setTitle(const String& title) 793 void Document::setTitle(const String& title)
798 { 794 {
799 } 795 }
800 796
801 void Document::setTitleElement(Element* titleElement) 797 void Document::setTitleElement(Element* titleElement)
802 { 798 {
803 // Only allow the first title element to change the title -- others have no effect. 799 // Only allow the first title element to change the title -- others have no effect.
804 if (m_titleElement && m_titleElement != titleElement) { 800 if (m_titleElement && m_titleElement != titleElement) {
805 if (isHTMLDocument()) 801 m_titleElement = Traversal<HTMLTitleElement>::firstWithin(*this);
806 m_titleElement = Traversal<HTMLTitleElement>::firstWithin(*this);
807 } else { 802 } else {
808 m_titleElement = titleElement; 803 m_titleElement = titleElement;
809 } 804 }
810 805
811 if (isHTMLTitleElement(m_titleElement)) 806 if (isHTMLTitleElement(m_titleElement))
812 updateTitle(toHTMLTitleElement(m_titleElement)->text()); 807 updateTitle(toHTMLTitleElement(m_titleElement)->text());
813 } 808 }
814 809
815 void Document::removeTitle(Element* titleElement) 810 void Document::removeTitle(Element* titleElement)
816 { 811 {
817 if (m_titleElement != titleElement) 812 if (m_titleElement != titleElement)
818 return; 813 return;
819 814
820 m_titleElement = nullptr; 815 m_titleElement = nullptr;
821 816
822 // Update title based on first title element in the document, if one exists. 817 // Update title based on first title element in the document, if one exists.
823 if (isHTMLDocument()) { 818 if (HTMLTitleElement* title = Traversal<HTMLTitleElement>::firstWithin(*this ))
824 if (HTMLTitleElement* title = Traversal<HTMLTitleElement>::firstWithin(* this)) 819 setTitleElement(title);
825 setTitleElement(title);
826 }
827 820
828 if (!m_titleElement) 821 if (!m_titleElement)
829 updateTitle(String()); 822 updateTitle(String());
830 } 823 }
831 824
832 const AtomicString& Document::dir() 825 const AtomicString& Document::dir()
833 { 826 {
834 return nullAtom; 827 return nullAtom;
835 } 828 }
836 829
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 checkCompleted(); 1268 checkCompleted();
1276 } 1269 }
1277 1270
1278 DocumentParser* Document::startParsing() 1271 DocumentParser* Document::startParsing()
1279 { 1272 {
1280 ASSERT(!m_parser); 1273 ASSERT(!m_parser);
1281 ASSERT(!m_isParsing); 1274 ASSERT(!m_isParsing);
1282 ASSERT(!firstChild()); 1275 ASSERT(!firstChild());
1283 ASSERT(!m_focusedElement); 1276 ASSERT(!m_focusedElement);
1284 1277
1285 m_parser = HTMLDocumentParser::create(toHTMLDocument(*this), false); 1278 m_parser = HTMLDocumentParser::create(*this, false);
1286 setParsing(true); 1279 setParsing(true);
1287 setReadyState(Loading); 1280 setReadyState(Loading);
1288 return m_parser.get(); 1281 return m_parser.get();
1289 } 1282 }
1290 1283
1291 void Document::implicitClose() 1284 void Document::implicitClose()
1292 { 1285 {
1293 ASSERT(!inStyleRecalc()); 1286 ASSERT(!inStyleRecalc());
1294 1287
1295 bool doload = !parsing() && m_parser && !processingLoadEvent(); 1288 bool doload = !parsing() && m_parser && !processingLoadEvent();
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 } 2299 }
2307 2300
2308 Document& Document::ensureTemplateDocument() 2301 Document& Document::ensureTemplateDocument()
2309 { 2302 {
2310 if (isTemplateDocument()) 2303 if (isTemplateDocument())
2311 return *this; 2304 return *this;
2312 2305
2313 if (m_templateDocument) 2306 if (m_templateDocument)
2314 return *m_templateDocument; 2307 return *m_templateDocument;
2315 2308
2316 if (isHTMLDocument()) { 2309 DocumentInit init = DocumentInit::fromContext(contextDocument(), blankURL()) ;
2317 DocumentInit init = DocumentInit::fromContext(contextDocument(), blankUR L()); 2310 m_templateDocument = Document::create(init);
2318 m_templateDocument = HTMLDocument::create(init);
2319 } else {
2320 m_templateDocument = Document::create(DocumentInit(blankURL()));
2321 }
2322 2311
2323 m_templateDocument->m_templateDocumentHost = this; // balanced in dtor. 2312 m_templateDocument->m_templateDocumentHost = this; // balanced in dtor.
2324 2313
2325 return *m_templateDocument.get(); 2314 return *m_templateDocument.get();
2326 } 2315 }
2327 2316
2328 float Document::devicePixelRatio() const 2317 float Document::devicePixelRatio() const
2329 { 2318 {
2330 return m_frame ? m_frame->devicePixelRatio() : 1.0; 2319 return m_frame ? m_frame->devicePixelRatio() : 1.0;
2331 } 2320 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 using namespace blink; 2384 using namespace blink;
2396 void showLiveDocumentInstances() 2385 void showLiveDocumentInstances()
2397 { 2386 {
2398 WeakDocumentSet& set = liveDocumentSet(); 2387 WeakDocumentSet& set = liveDocumentSet();
2399 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 2388 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
2400 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 2389 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
2401 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 2390 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
2402 } 2391 }
2403 } 2392 }
2404 #endif 2393 #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