Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / dom / DocumentVisibilityObserver.cpp
blob012901f602ff8e4122d73925bc4fc71782434c76
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "config.h"
6 #include "core/dom/DocumentVisibilityObserver.h"
8 #include "core/dom/Document.h"
10 namespace blink {
12 DocumentVisibilityObserver::DocumentVisibilityObserver(Document& document)
13 : m_document(nullptr)
15 registerObserver(document);
18 DocumentVisibilityObserver::~DocumentVisibilityObserver()
20 #if !ENABLE(OILPAN)
21 unregisterObserver();
22 #endif
25 DEFINE_TRACE(DocumentVisibilityObserver)
27 visitor->trace(m_document);
30 void DocumentVisibilityObserver::unregisterObserver()
32 if (m_document) {
33 m_document->unregisterVisibilityObserver(this);
34 m_document = nullptr;
38 void DocumentVisibilityObserver::registerObserver(Document& document)
40 ASSERT(!m_document);
41 m_document = &document;
42 if (m_document)
43 m_document->registerVisibilityObserver(this);
46 void DocumentVisibilityObserver::setObservedDocument(Document& document)
48 unregisterObserver();
49 registerObserver(document);
52 } // namespace blink