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

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

Issue 723583002: Make the parser an implementation detail of the Document (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rename textPosition to parserPosition Created 6 years, 1 month 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/StyleElement.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) 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 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 void Document::removeAllEventListeners() 1337 void Document::removeAllEventListeners()
1338 { 1338 {
1339 ContainerNode::removeAllEventListeners(); 1339 ContainerNode::removeAllEventListeners();
1340 1340
1341 if (LocalDOMWindow* domWindow = this->domWindow()) 1341 if (LocalDOMWindow* domWindow = this->domWindow())
1342 domWindow->removeAllEventListeners(); 1342 domWindow->removeAllEventListeners();
1343 } 1343 }
1344 1344
1345 HTMLDocumentParser* Document::scriptableDocumentParser() const 1345 HTMLDocumentParser* Document::scriptableDocumentParser() const
1346 { 1346 {
1347 return parser() ? parser()->asHTMLDocumentParser() : 0; 1347 return m_parser ? m_parser->asHTMLDocumentParser() : 0;
1348 } 1348 }
1349 1349
1350 void Document::detachParser() 1350 void Document::detachParser()
1351 { 1351 {
1352 if (!m_parser) 1352 if (!m_parser)
1353 return; 1353 return;
1354 m_parser->detach(); 1354 m_parser->detach();
1355 m_parser.clear(); 1355 m_parser.clear();
1356 } 1356 }
1357 1357
1358 void Document::cancelParsing() 1358 void Document::cancelParsing()
1359 { 1359 {
1360 if (!m_parser) 1360 if (!m_parser)
1361 return; 1361 return;
1362 1362
1363 // We have to clear the parser to avoid possibly triggering 1363 // We have to clear the parser to avoid possibly triggering
1364 // the onload handler when closing as a side effect of a cancel-style 1364 // the onload handler when closing as a side effect of a cancel-style
1365 // change, such as opening a new document or closing the window while 1365 // change, such as opening a new document or closing the window while
1366 // still parsing. 1366 // still parsing.
1367 detachParser(); 1367 detachParser();
1368 1368
1369 // FIXME(sky): Unclear if anything below this makes any sense. 1369 // FIXME(sky): Unclear if anything below this makes any sense.
1370 if (!m_frame) { 1370 if (!m_frame) {
1371 m_loadEventProgress = LoadEventTried; 1371 m_loadEventProgress = LoadEventTried;
1372 return; 1372 return;
1373 } 1373 }
1374 checkCompleted(); 1374 checkCompleted();
1375 } 1375 }
1376 1376
1377 void Document::startParsing() 1377 DocumentParser* Document::startParsing()
1378 { 1378 {
1379 ASSERT(!m_parser); 1379 ASSERT(!m_parser);
1380 ASSERT(!m_isParsing); 1380 ASSERT(!m_isParsing);
1381 ASSERT(!firstChild()); 1381 ASSERT(!firstChild());
1382 ASSERT(!m_focusedElement); 1382 ASSERT(!m_focusedElement);
1383 1383
1384 m_parser = HTMLDocumentParser::create(toHTMLDocument(*this), false); 1384 m_parser = HTMLDocumentParser::create(toHTMLDocument(*this), false);
1385 setParsing(true); 1385 setParsing(true);
1386 setReadyState(Loading); 1386 setReadyState(Loading);
1387 return m_parser.get();
1387 } 1388 }
1388 1389
1389 Element* Document::viewportDefiningElement(RenderStyle* rootStyle) const 1390 Element* Document::viewportDefiningElement(RenderStyle* rootStyle) const
1390 { 1391 {
1391 // If a BODY element sets non-visible overflow, it is to be propagated to th e viewport, as long 1392 // If a BODY element sets non-visible overflow, it is to be propagated to th e viewport, as long
1392 // as the following conditions are all met: 1393 // as the following conditions are all met:
1393 // (1) The root element is HTML. 1394 // (1) The root element is HTML.
1394 // (2) It is the primary BODY element (we only assert for this, expecting ca llers to behave). 1395 // (2) It is the primary BODY element (we only assert for this, expecting ca llers to behave).
1395 // (3) The root element has visible overflow. 1396 // (3) The root element has visible overflow.
1396 // Otherwise it's the root element's properties that are to be propagated. 1397 // Otherwise it's the root element's properties that are to be propagated.
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 } 1632 }
1632 1633
1633 void Document::executeScriptsWaitingForResourcesTimerFired(Timer<Document>*) 1634 void Document::executeScriptsWaitingForResourcesTimerFired(Timer<Document>*)
1634 { 1635 {
1635 if (!isRenderingReady()) 1636 if (!isRenderingReady())
1636 return; 1637 return;
1637 if (HTMLDocumentParser* parser = scriptableDocumentParser()) 1638 if (HTMLDocumentParser* parser = scriptableDocumentParser())
1638 parser->executeScriptsWaitingForResources(); 1639 parser->executeScriptsWaitingForResources();
1639 } 1640 }
1640 1641
1642 TextPosition Document::parserPosition() const
1643 {
1644 if (HTMLDocumentParser* parser = scriptableDocumentParser())
1645 return parser->textPosition();
1646 return TextPosition::belowRangePosition();
1647 }
1648
1641 CSSStyleSheet& Document::elementSheet() 1649 CSSStyleSheet& Document::elementSheet()
1642 { 1650 {
1643 if (!m_elemSheet) 1651 if (!m_elemSheet)
1644 m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL); 1652 m_elemSheet = CSSStyleSheet::createInline(this, m_baseURL);
1645 return *m_elemSheet; 1653 return *m_elemSheet;
1646 } 1654 }
1647 1655
1648 String Document::outgoingReferrer() 1656 String Document::outgoingReferrer()
1649 { 1657 {
1650 // See http://www.whatwg.org/specs/web-apps/current-work/#fetching-resources 1658 // See http://www.whatwg.org/specs/web-apps/current-work/#fetching-resources
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after
2908 using namespace blink; 2916 using namespace blink;
2909 void showLiveDocumentInstances() 2917 void showLiveDocumentInstances()
2910 { 2918 {
2911 WeakDocumentSet& set = liveDocumentSet(); 2919 WeakDocumentSet& set = liveDocumentSet();
2912 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 2920 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
2913 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 2921 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
2914 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 2922 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
2915 } 2923 }
2916 } 2924 }
2917 #endif 2925 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Document.h ('k') | sky/engine/core/dom/StyleElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698