| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 235 |
| 236 #ifndef NDEBUG | 236 #ifndef NDEBUG |
| 237 typedef HashSet<RawPtr<Document> > WeakDocumentSet; | 237 typedef HashSet<RawPtr<Document> > WeakDocumentSet; |
| 238 static WeakDocumentSet& liveDocumentSet() | 238 static WeakDocumentSet& liveDocumentSet() |
| 239 { | 239 { |
| 240 DEFINE_STATIC_LOCAL(OwnPtr<WeakDocumentSet>, set, (adoptPtr(new WeakDocument
Set()))); | 240 DEFINE_STATIC_LOCAL(OwnPtr<WeakDocumentSet>, set, (adoptPtr(new WeakDocument
Set()))); |
| 241 return *set; | 241 return *set; |
| 242 } | 242 } |
| 243 #endif | 243 #endif |
| 244 | 244 |
| 245 DocumentVisibilityObserver::DocumentVisibilityObserver(Document& document) | |
| 246 : m_document(nullptr) | |
| 247 { | |
| 248 registerObserver(document); | |
| 249 } | |
| 250 | |
| 251 DocumentVisibilityObserver::~DocumentVisibilityObserver() | |
| 252 { | |
| 253 #if !ENABLE(OILPAN) | |
| 254 unregisterObserver(); | |
| 255 #endif | |
| 256 } | |
| 257 | |
| 258 void DocumentVisibilityObserver::unregisterObserver() | |
| 259 { | |
| 260 if (m_document) { | |
| 261 m_document->unregisterVisibilityObserver(this); | |
| 262 m_document = nullptr; | |
| 263 } | |
| 264 } | |
| 265 | |
| 266 void DocumentVisibilityObserver::registerObserver(Document& document) | |
| 267 { | |
| 268 ASSERT(!m_document); | |
| 269 m_document = &document; | |
| 270 if (m_document) | |
| 271 m_document->registerVisibilityObserver(this); | |
| 272 } | |
| 273 | |
| 274 void DocumentVisibilityObserver::setObservedDocument(Document& document) | |
| 275 { | |
| 276 unregisterObserver(); | |
| 277 registerObserver(document); | |
| 278 } | |
| 279 | |
| 280 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
lasses) | 245 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
lasses) |
| 281 : ContainerNode(0, CreateDocument) | 246 : ContainerNode(0, CreateDocument) |
| 282 , TreeScope(*this) | 247 , TreeScope(*this) |
| 283 , m_module(nullptr) | 248 , m_module(nullptr) |
| 284 , m_hasNodesWithPlaceholderStyle(false) | 249 , m_hasNodesWithPlaceholderStyle(false) |
| 285 , m_evaluateMediaQueriesOnStyleRecalc(false) | 250 , m_evaluateMediaQueriesOnStyleRecalc(false) |
| 286 , m_pendingSheetLayout(NoLayoutWithPendingSheets) | 251 , m_pendingSheetLayout(NoLayoutWithPendingSheets) |
| 287 , m_frame(initializer.frame()) | 252 , m_frame(initializer.frame()) |
| 288 , m_domWindow(m_frame ? m_frame->domWindow() : 0) | 253 , m_domWindow(m_frame ? m_frame->domWindow() : 0) |
| 289 , m_importsController(initializer.importsController()) | 254 , m_importsController(initializer.importsController()) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 #endif | 309 #endif |
| 345 } | 310 } |
| 346 | 311 |
| 347 Document::~Document() | 312 Document::~Document() |
| 348 { | 313 { |
| 349 ASSERT(!renderView()); | 314 ASSERT(!renderView()); |
| 350 ASSERT(!parentTreeScope()); | 315 ASSERT(!parentTreeScope()); |
| 351 #if !ENABLE(OILPAN) | 316 #if !ENABLE(OILPAN) |
| 352 ASSERT(m_ranges.isEmpty()); | 317 ASSERT(m_ranges.isEmpty()); |
| 353 ASSERT(!hasGuardRefCount()); | 318 ASSERT(!hasGuardRefCount()); |
| 354 // With Oilpan, either the document outlives the visibility observers | |
| 355 // or the visibility observers and the document die in the same GC round. | |
| 356 // When they die in the same GC round, the list of visibility observers | |
| 357 // will not be empty on Document destruction. | |
| 358 ASSERT(m_visibilityObservers.isEmpty()); | |
| 359 | 319 |
| 360 if (m_templateDocument) | 320 if (m_templateDocument) |
| 361 m_templateDocument->m_templateDocumentHost = nullptr; // balanced in ens
ureTemplateDocument(). | 321 m_templateDocument->m_templateDocumentHost = nullptr; // balanced in ens
ureTemplateDocument(). |
| 362 | 322 |
| 363 // FIXME: Oilpan: Not removing event listeners here also means that we do | 323 // FIXME: Oilpan: Not removing event listeners here also means that we do |
| 364 // not notify the inspector instrumentation that the event listeners are | 324 // not notify the inspector instrumentation that the event listeners are |
| 365 // gone. The Document and all the nodes in the document are gone, so maybe | 325 // gone. The Document and all the nodes in the document are gone, so maybe |
| 366 // that is OK? | 326 // that is OK? |
| 367 removeAllEventListenersRecursively(); | 327 removeAllEventListenersRecursively(); |
| 368 | 328 |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 } | 902 } |
| 943 | 903 |
| 944 bool Document::hidden() const | 904 bool Document::hidden() const |
| 945 { | 905 { |
| 946 return pageVisibilityState() != PageVisibilityStateVisible; | 906 return pageVisibilityState() != PageVisibilityStateVisible; |
| 947 } | 907 } |
| 948 | 908 |
| 949 void Document::didChangeVisibilityState() | 909 void Document::didChangeVisibilityState() |
| 950 { | 910 { |
| 951 dispatchEvent(Event::create(EventTypeNames::visibilitychange)); | 911 dispatchEvent(Event::create(EventTypeNames::visibilitychange)); |
| 952 // Also send out the deprecated version until it can be removed. | |
| 953 dispatchEvent(Event::create(EventTypeNames::webkitvisibilitychange)); | |
| 954 | |
| 955 PageVisibilityState state = pageVisibilityState(); | |
| 956 DocumentVisibilityObserverSet::const_iterator observerEnd = m_visibilityObse
rvers.end(); | |
| 957 for (DocumentVisibilityObserverSet::const_iterator it = m_visibilityObserver
s.begin(); it != observerEnd; ++it) | |
| 958 (*it)->didChangeVisibilityState(state); | |
| 959 } | |
| 960 | |
| 961 void Document::registerVisibilityObserver(DocumentVisibilityObserver* observer) | |
| 962 { | |
| 963 ASSERT(!m_visibilityObservers.contains(observer)); | |
| 964 m_visibilityObservers.add(observer); | |
| 965 } | |
| 966 | |
| 967 void Document::unregisterVisibilityObserver(DocumentVisibilityObserver* observer
) | |
| 968 { | |
| 969 ASSERT(m_visibilityObservers.contains(observer)); | |
| 970 m_visibilityObservers.remove(observer); | |
| 971 } | 912 } |
| 972 | 913 |
| 973 String Document::nodeName() const | 914 String Document::nodeName() const |
| 974 { | 915 { |
| 975 return "#document"; | 916 return "#document"; |
| 976 } | 917 } |
| 977 | 918 |
| 978 Node::NodeType Document::nodeType() const | 919 Node::NodeType Document::nodeType() const |
| 979 { | 920 { |
| 980 return DOCUMENT_NODE; | 921 return DOCUMENT_NODE; |
| (...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2968 using namespace blink; | 2909 using namespace blink; |
| 2969 void showLiveDocumentInstances() | 2910 void showLiveDocumentInstances() |
| 2970 { | 2911 { |
| 2971 WeakDocumentSet& set = liveDocumentSet(); | 2912 WeakDocumentSet& set = liveDocumentSet(); |
| 2972 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 2913 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 2973 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { | 2914 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { |
| 2974 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); | 2915 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); |
| 2975 } | 2916 } |
| 2976 } | 2917 } |
| 2977 #endif | 2918 #endif |
| OLD | NEW |