1 | /* |
2 | * Copyright (C) 2015, 2016 Canon Inc. All rights reserved. |
3 | * Copyright (C) 2016 Apple Inc. All rights reserved. |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Lesser General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Lesser General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public |
16 | * License along with this library; if not, write to the Free Software |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
18 | */ |
19 | |
20 | #pragma once |
21 | |
22 | #include "Document.h" |
23 | #include "JSDOMConstructorBase.h" |
24 | |
25 | namespace WebCore { |
26 | |
27 | // Constructors using this base class depend on being in a Document and |
28 | // can never be used from a WorkerGlobalScope. |
29 | class JSDOMConstructorWithDocument : public JSDOMConstructorBase { |
30 | public: |
31 | using Base = JSDOMConstructorBase; |
32 | |
33 | Document* document() const |
34 | { |
35 | return downcast<Document>(scriptExecutionContext()); |
36 | } |
37 | |
38 | protected: |
39 | JSDOMConstructorWithDocument(JSC::Structure* structure, JSDOMGlobalObject& globalObject) |
40 | : JSDOMConstructorBase(structure, globalObject) |
41 | { |
42 | } |
43 | |
44 | void finishCreation(JSDOMGlobalObject& globalObject) |
45 | { |
46 | Base::finishCreation(globalObject.vm()); |
47 | ASSERT(globalObject.scriptExecutionContext()->isDocument()); |
48 | } |
49 | }; |
50 | |
51 | } // namespace WebCore |
52 | |