/src/mozilla-central/dom/base/WindowNamedPropertiesHandler.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_WindowNamedPropertiesHandler_h |
8 | | #define mozilla_dom_WindowNamedPropertiesHandler_h |
9 | | |
10 | | #include "mozilla/dom/DOMJSProxyHandler.h" |
11 | | |
12 | | namespace mozilla { |
13 | | namespace dom { |
14 | | |
15 | | class WindowNamedPropertiesHandler : public BaseDOMProxyHandler |
16 | | { |
17 | | public: |
18 | | constexpr WindowNamedPropertiesHandler() |
19 | | : BaseDOMProxyHandler(nullptr, /* hasPrototype = */ true) |
20 | 0 | { |
21 | 0 | } |
22 | | virtual bool |
23 | | getOwnPropDescriptor(JSContext* aCx, JS::Handle<JSObject*> aProxy, |
24 | | JS::Handle<jsid> aId, |
25 | | bool /* unused */, |
26 | | JS::MutableHandle<JS::PropertyDescriptor> aDesc) |
27 | | const override; |
28 | | virtual bool |
29 | | defineProperty(JSContext* aCx, JS::Handle<JSObject*> aProxy, |
30 | | JS::Handle<jsid> aId, |
31 | | JS::Handle<JS::PropertyDescriptor> aDesc, |
32 | | JS::ObjectOpResult &result) const override; |
33 | | virtual bool |
34 | | ownPropNames(JSContext* aCx, JS::Handle<JSObject*> aProxy, unsigned flags, |
35 | | JS::AutoIdVector& aProps) const override; |
36 | | virtual bool |
37 | | delete_(JSContext* aCx, JS::Handle<JSObject*> aProxy, JS::Handle<jsid> aId, |
38 | | JS::ObjectOpResult &aResult) const override; |
39 | | |
40 | | // No need for getPrototypeIfOrdinary here: window named-properties objects |
41 | | // have static prototypes, so the version inherited from BaseDOMProxyHandler |
42 | | // will do the right thing. |
43 | | |
44 | | virtual bool |
45 | | preventExtensions(JSContext* aCx, JS::Handle<JSObject*> aProxy, |
46 | | JS::ObjectOpResult& aResult) const override |
47 | 0 | { |
48 | 0 | return aResult.failCantPreventExtensions(); |
49 | 0 | } |
50 | | virtual bool |
51 | | isExtensible(JSContext* aCx, JS::Handle<JSObject*> aProxy, |
52 | | bool* aIsExtensible) const override |
53 | 0 | { |
54 | 0 | *aIsExtensible = true; |
55 | 0 | return true; |
56 | 0 | } |
57 | | virtual const char* |
58 | | className(JSContext *aCx, JS::Handle<JSObject*> aProxy) const override |
59 | 0 | { |
60 | 0 | return "WindowProperties"; |
61 | 0 | } |
62 | | |
63 | | static const WindowNamedPropertiesHandler* |
64 | | getInstance() |
65 | 0 | { |
66 | 0 | static const WindowNamedPropertiesHandler instance; |
67 | 0 | return &instance; |
68 | 0 | } |
69 | | |
70 | | // For Create, aProto is the parent of the interface prototype object of the |
71 | | // Window we're associated with. |
72 | | static JSObject* |
73 | | Create(JSContext *aCx, JS::Handle<JSObject*> aProto); |
74 | | }; |
75 | | |
76 | | } // namespace dom |
77 | | } // namespace mozilla |
78 | | |
79 | | #endif /* mozilla_dom_WindowNamedPropertiesHandler_h */ |