OLD | NEW |
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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 #include "platform/network/HTTPParsers.h" | 205 #include "platform/network/HTTPParsers.h" |
206 #include "platform/scroll/ScrollbarTheme.h" | 206 #include "platform/scroll/ScrollbarTheme.h" |
207 #include "platform/text/PlatformLocale.h" | 207 #include "platform/text/PlatformLocale.h" |
208 #include "platform/text/SegmentedString.h" | 208 #include "platform/text/SegmentedString.h" |
209 #include "platform/weborigin/OriginAccessEntry.h" | 209 #include "platform/weborigin/OriginAccessEntry.h" |
210 #include "platform/weborigin/SchemeRegistry.h" | 210 #include "platform/weborigin/SchemeRegistry.h" |
211 #include "platform/weborigin/SecurityOrigin.h" | 211 #include "platform/weborigin/SecurityOrigin.h" |
212 #include "public/platform/Platform.h" | 212 #include "public/platform/Platform.h" |
213 #include "wtf/CurrentTime.h" | 213 #include "wtf/CurrentTime.h" |
214 #include "wtf/DateMath.h" | 214 #include "wtf/DateMath.h" |
| 215 #include "wtf/Functional.h" |
215 #include "wtf/HashFunctions.h" | 216 #include "wtf/HashFunctions.h" |
216 #include "wtf/MainThread.h" | 217 #include "wtf/MainThread.h" |
217 #include "wtf/StdLibExtras.h" | 218 #include "wtf/StdLibExtras.h" |
218 #include "wtf/TemporaryChange.h" | 219 #include "wtf/TemporaryChange.h" |
219 #include "wtf/text/StringBuffer.h" | 220 #include "wtf/text/StringBuffer.h" |
220 #include "wtf/text/TextEncodingRegistry.h" | 221 #include "wtf/text/TextEncodingRegistry.h" |
221 | 222 |
222 using namespace WTF; | 223 using namespace WTF; |
223 using namespace Unicode; | 224 using namespace Unicode; |
224 | 225 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 void performTask(ExecutionContext* context) override | 357 void performTask(ExecutionContext* context) override |
357 { | 358 { |
358 Document* document = toDocument(context); | 359 Document* document = toDocument(context); |
359 if (RefPtrWillBeRawPtr<Element> element = document->autofocusElement())
{ | 360 if (RefPtrWillBeRawPtr<Element> element = document->autofocusElement())
{ |
360 document->setAutofocusElement(0); | 361 document->setAutofocusElement(0); |
361 element->focus(); | 362 element->focus(); |
362 } | 363 } |
363 } | 364 } |
364 }; | 365 }; |
365 | 366 |
| 367 } // namespace blink |
| 368 |
| 369 namespace WTF { |
| 370 |
| 371 #if ENABLE(OILPAN) |
| 372 // NOTE this is to prevent Document::m_executeScriptsWaitingForResourcesTask fro
m leaking. |
| 373 template<> |
| 374 struct PointerParamStorageTraits<blink::Document*, true> { |
| 375 using StorageType = blink::CrossThreadWeakPersistent<blink::Document>; |
| 376 |
| 377 static StorageType wrap(blink::Document* value) { return value; } |
| 378 static blink::Document* unwrap(const StorageType& value) { return value.get(
); } |
| 379 }; |
| 380 #endif |
| 381 |
| 382 } // namespace WTF |
| 383 |
| 384 namespace blink { |
| 385 |
366 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
lasses) | 386 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
lasses) |
367 : ContainerNode(0, CreateDocument) | 387 : ContainerNode(0, CreateDocument) |
368 , TreeScope(*this) | 388 , TreeScope(*this) |
369 , m_hasNodesWithPlaceholderStyle(false) | 389 , m_hasNodesWithPlaceholderStyle(false) |
370 , m_evaluateMediaQueriesOnStyleRecalc(false) | 390 , m_evaluateMediaQueriesOnStyleRecalc(false) |
371 , m_shouldProcessFrameLifecycle(false) | 391 , m_shouldProcessFrameLifecycle(false) |
372 , m_pendingSheetLayout(NoLayoutWithPendingSheets) | 392 , m_pendingSheetLayout(NoLayoutWithPendingSheets) |
373 , m_frame(initializer.frame()) | 393 , m_frame(initializer.frame()) |
374 , m_domWindow(m_frame ? m_frame->localDOMWindow() : 0) | 394 , m_domWindow(m_frame ? m_frame->localDOMWindow() : 0) |
375 , m_importsController(initializer.importsController()) | 395 , m_importsController(initializer.importsController()) |
376 , m_activeParserCount(0) | 396 , m_activeParserCount(0) |
377 , m_contextFeatures(ContextFeatures::defaultSwitch()) | 397 , m_contextFeatures(ContextFeatures::defaultSwitch()) |
378 , m_wellFormed(false) | 398 , m_wellFormed(false) |
379 , m_printing(false) | 399 , m_printing(false) |
380 , m_paginatedForScreen(false) | 400 , m_paginatedForScreen(false) |
381 , m_compatibilityMode(NoQuirksMode) | 401 , m_compatibilityMode(NoQuirksMode) |
382 , m_compatibilityModeLocked(false) | 402 , m_compatibilityModeLocked(false) |
383 , m_executeScriptsWaitingForResourcesTimer(this, &Document::executeScriptsWa
itingForResourcesTimerFired) | 403 , m_executeScriptsWaitingForResourcesTask(WTF::bind(&Document::executeScript
sWaitingForResources, this)) |
384 , m_hasAutofocused(false) | 404 , m_hasAutofocused(false) |
385 , m_clearFocusedElementTimer(this, &Document::clearFocusedElementTimerFired) | 405 , m_clearFocusedElementTimer(this, &Document::clearFocusedElementTimerFired) |
386 , m_domTreeVersion(++s_globalTreeVersion) | 406 , m_domTreeVersion(++s_globalTreeVersion) |
387 , m_styleVersion(0) | 407 , m_styleVersion(0) |
388 , m_listenerTypes(0) | 408 , m_listenerTypes(0) |
389 , m_mutationObserverTypes(0) | 409 , m_mutationObserverTypes(0) |
390 , m_visitedLinkState(VisitedLinkState::create(*this)) | 410 , m_visitedLinkState(VisitedLinkState::create(*this)) |
391 , m_visuallyOrdered(false) | 411 , m_visuallyOrdered(false) |
392 , m_readyState(Complete) | 412 , m_readyState(Complete) |
393 , m_parsingState(FinishedParsing) | 413 , m_parsingState(FinishedParsing) |
(...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2949 // Only imports on master documents can trigger rendering. | 2969 // Only imports on master documents can trigger rendering. |
2950 if (HTMLImportLoader* import = importLoader()) | 2970 if (HTMLImportLoader* import = importLoader()) |
2951 import->didRemoveAllPendingStylesheet(); | 2971 import->didRemoveAllPendingStylesheet(); |
2952 if (!haveImportsLoaded()) | 2972 if (!haveImportsLoaded()) |
2953 return; | 2973 return; |
2954 didLoadAllScriptBlockingResources(); | 2974 didLoadAllScriptBlockingResources(); |
2955 } | 2975 } |
2956 | 2976 |
2957 void Document::didLoadAllScriptBlockingResources() | 2977 void Document::didLoadAllScriptBlockingResources() |
2958 { | 2978 { |
2959 m_executeScriptsWaitingForResourcesTimer.startOneShot(0, FROM_HERE); | 2979 Platform::current()->currentThread()->scheduler()->postLoadingTask( |
| 2980 FROM_HERE, m_executeScriptsWaitingForResourcesTask.cancelAndCreate()); |
2960 | 2981 |
2961 if (frame()) | 2982 if (frame()) |
2962 frame()->loader().client()->didRemoveAllPendingStylesheet(); | 2983 frame()->loader().client()->didRemoveAllPendingStylesheet(); |
2963 | 2984 |
2964 if (m_gotoAnchorNeededAfterStylesheetsLoad && view()) | 2985 if (m_gotoAnchorNeededAfterStylesheetsLoad && view()) |
2965 view()->processUrlFragment(m_url); | 2986 view()->processUrlFragment(m_url); |
2966 } | 2987 } |
2967 | 2988 |
2968 void Document::executeScriptsWaitingForResourcesTimerFired(Timer<Document>*) | 2989 void Document::executeScriptsWaitingForResources() |
2969 { | 2990 { |
2970 if (!isRenderingReady()) | 2991 if (!isRenderingReady()) |
2971 return; | 2992 return; |
2972 if (ScriptableDocumentParser* parser = scriptableDocumentParser()) | 2993 if (ScriptableDocumentParser* parser = scriptableDocumentParser()) |
2973 parser->executeScriptsWaitingForResources(); | 2994 parser->executeScriptsWaitingForResources(); |
2974 } | 2995 } |
2975 | 2996 |
2976 CSSStyleSheet& Document::elementSheet() | 2997 CSSStyleSheet& Document::elementSheet() |
2977 { | 2998 { |
2978 if (!m_elemSheet) | 2999 if (!m_elemSheet) |
(...skipping 2739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5718 #ifndef NDEBUG | 5739 #ifndef NDEBUG |
5719 using namespace blink; | 5740 using namespace blink; |
5720 void showLiveDocumentInstances() | 5741 void showLiveDocumentInstances() |
5721 { | 5742 { |
5722 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5743 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
5723 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5744 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5724 for (Document* document : set) | 5745 for (Document* document : set) |
5725 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5746 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
5726 } | 5747 } |
5727 #endif | 5748 #endif |
OLD | NEW |