mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 858524 - Move BarProp objects to Paris bindings, r=ms2ger, r=smaug
This commit is contained in:
parent
42942f5604
commit
1ead46dece
@ -4,20 +4,11 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/BarProps.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nscore.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "mozilla/dom/BarPropBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
DOMCI_DATA(BarProp, mozilla::dom::BarProp)
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIScrollable.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -26,75 +17,85 @@ namespace dom {
|
||||
// Basic (virtual) BarProp class implementation
|
||||
//
|
||||
BarProp::BarProp(nsGlobalWindow *aWindow)
|
||||
: mDOMWindow(aWindow)
|
||||
{
|
||||
mDOMWindow = aWindow;
|
||||
nsISupports *supwin = static_cast<nsIScriptGlobalObject *>(aWindow);
|
||||
mDOMWindowWeakref = do_GetWeakReference(supwin);
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
BarProp::~BarProp()
|
||||
{
|
||||
}
|
||||
|
||||
// QueryInterface implementation for BarProp
|
||||
NS_INTERFACE_MAP_BEGIN(BarProp)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMBarProp)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(BarProp)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(BarProp)
|
||||
NS_IMPL_RELEASE(BarProp)
|
||||
|
||||
NS_IMETHODIMP
|
||||
BarProp::GetVisibleByFlag(bool *aVisible, uint32_t aChromeFlag)
|
||||
nsPIDOMWindow*
|
||||
BarProp::GetParentObject() const
|
||||
{
|
||||
*aVisible = false;
|
||||
|
||||
nsCOMPtr<nsIWebBrowserChrome> browserChrome = GetBrowserChrome();
|
||||
NS_ENSURE_TRUE(browserChrome, NS_OK);
|
||||
|
||||
uint32_t chromeFlags;
|
||||
|
||||
NS_ENSURE_SUCCESS(browserChrome->GetChromeFlags(&chromeFlags),
|
||||
NS_ERROR_FAILURE);
|
||||
if (chromeFlags & aChromeFlag)
|
||||
*aVisible = true;
|
||||
|
||||
return NS_OK;
|
||||
return mDOMWindow;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BarProp::SetVisibleByFlag(bool aVisible, uint32_t aChromeFlag)
|
||||
JSObject*
|
||||
BarProp::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
return BarPropBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(BarProp, mDOMWindow)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(BarProp)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(BarProp)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BarProp)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
bool
|
||||
BarProp::GetVisibleByFlag(uint32_t aChromeFlag, ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIWebBrowserChrome> browserChrome = GetBrowserChrome();
|
||||
NS_ENSURE_TRUE(browserChrome, NS_OK);
|
||||
|
||||
if (!nsContentUtils::IsCallerChrome())
|
||||
return NS_OK;
|
||||
NS_ENSURE_TRUE(browserChrome, false);
|
||||
|
||||
uint32_t chromeFlags;
|
||||
|
||||
NS_ENSURE_SUCCESS(browserChrome->GetChromeFlags(&chromeFlags),
|
||||
NS_ERROR_FAILURE);
|
||||
if (NS_FAILED(browserChrome->GetChromeFlags(&chromeFlags))) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
return (chromeFlags & aChromeFlag);
|
||||
}
|
||||
|
||||
void
|
||||
BarProp::SetVisibleByFlag(bool aVisible, uint32_t aChromeFlag,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIWebBrowserChrome> browserChrome = GetBrowserChrome();
|
||||
NS_ENSURE_TRUE_VOID(browserChrome);
|
||||
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t chromeFlags;
|
||||
|
||||
if (NS_FAILED(browserChrome->GetChromeFlags(&chromeFlags))) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aVisible)
|
||||
chromeFlags |= aChromeFlag;
|
||||
else
|
||||
chromeFlags &= ~aChromeFlag;
|
||||
NS_ENSURE_SUCCESS(browserChrome->SetChromeFlags(chromeFlags),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
if (NS_FAILED(browserChrome->SetChromeFlags(chromeFlags))) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<nsIWebBrowserChrome>
|
||||
BarProp::GetBrowserChrome()
|
||||
{
|
||||
// Check that the window is still alive.
|
||||
nsCOMPtr<nsIDOMWindow> domwin(do_QueryReferent(mDOMWindowWeakref));
|
||||
if (!domwin)
|
||||
if (!mDOMWindow) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return mDOMWindow->GetWebBrowserChrome();
|
||||
}
|
||||
@ -112,18 +113,16 @@ MenubarProp::~MenubarProp()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MenubarProp::GetVisible(bool *aVisible)
|
||||
bool
|
||||
MenubarProp::GetVisible(ErrorResult& aRv)
|
||||
{
|
||||
return BarProp::GetVisibleByFlag(aVisible,
|
||||
nsIWebBrowserChrome::CHROME_MENUBAR);
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_MENUBAR, aRv);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MenubarProp::SetVisible(bool aVisible)
|
||||
void
|
||||
MenubarProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
||||
{
|
||||
return BarProp::SetVisibleByFlag(aVisible,
|
||||
nsIWebBrowserChrome::CHROME_MENUBAR);
|
||||
BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_MENUBAR, aRv);
|
||||
}
|
||||
|
||||
//
|
||||
@ -139,18 +138,17 @@ ToolbarProp::~ToolbarProp()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ToolbarProp::GetVisible(bool *aVisible)
|
||||
bool
|
||||
ToolbarProp::GetVisible(ErrorResult& aRv)
|
||||
{
|
||||
return BarProp::GetVisibleByFlag(aVisible,
|
||||
nsIWebBrowserChrome::CHROME_TOOLBAR);
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_TOOLBAR, aRv);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ToolbarProp::SetVisible(bool aVisible)
|
||||
void
|
||||
ToolbarProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
||||
{
|
||||
return BarProp::SetVisibleByFlag(aVisible,
|
||||
nsIWebBrowserChrome::CHROME_TOOLBAR);
|
||||
BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_TOOLBAR,
|
||||
aRv);
|
||||
}
|
||||
|
||||
//
|
||||
@ -166,20 +164,18 @@ LocationbarProp::~LocationbarProp()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LocationbarProp::GetVisible(bool *aVisible)
|
||||
bool
|
||||
LocationbarProp::GetVisible(ErrorResult& aRv)
|
||||
{
|
||||
return
|
||||
BarProp::GetVisibleByFlag(aVisible,
|
||||
nsIWebBrowserChrome::CHROME_LOCATIONBAR);
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_LOCATIONBAR,
|
||||
aRv);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LocationbarProp::SetVisible(bool aVisible)
|
||||
void
|
||||
LocationbarProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
||||
{
|
||||
return
|
||||
BarProp::SetVisibleByFlag(aVisible,
|
||||
nsIWebBrowserChrome::CHROME_LOCATIONBAR);
|
||||
BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_LOCATIONBAR,
|
||||
aRv);
|
||||
}
|
||||
|
||||
//
|
||||
@ -195,20 +191,19 @@ PersonalbarProp::~PersonalbarProp()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PersonalbarProp::GetVisible(bool *aVisible)
|
||||
bool
|
||||
PersonalbarProp::GetVisible(ErrorResult& aRv)
|
||||
{
|
||||
return
|
||||
BarProp::GetVisibleByFlag(aVisible,
|
||||
nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR);
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR,
|
||||
aRv);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PersonalbarProp::SetVisible(bool aVisible)
|
||||
void
|
||||
PersonalbarProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
||||
{
|
||||
return
|
||||
BarProp::SetVisibleByFlag(aVisible,
|
||||
nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR);
|
||||
BarProp::SetVisibleByFlag(aVisible,
|
||||
nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR,
|
||||
aRv);
|
||||
}
|
||||
|
||||
//
|
||||
@ -224,18 +219,17 @@ StatusbarProp::~StatusbarProp()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StatusbarProp::GetVisible(bool *aVisible)
|
||||
bool
|
||||
StatusbarProp::GetVisible(ErrorResult& aRv)
|
||||
{
|
||||
return BarProp::GetVisibleByFlag(aVisible,
|
||||
nsIWebBrowserChrome::CHROME_STATUSBAR);
|
||||
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_STATUSBAR, aRv);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StatusbarProp::SetVisible(bool aVisible)
|
||||
void
|
||||
StatusbarProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
||||
{
|
||||
return BarProp::SetVisibleByFlag(aVisible,
|
||||
nsIWebBrowserChrome::CHROME_STATUSBAR);
|
||||
nsIWebBrowserChrome::CHROME_STATUSBAR, aRv);
|
||||
}
|
||||
|
||||
//
|
||||
@ -251,37 +245,38 @@ ScrollbarsProp::~ScrollbarsProp()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScrollbarsProp::GetVisible(bool *aVisible)
|
||||
bool
|
||||
ScrollbarsProp::GetVisible(ErrorResult& aRv)
|
||||
{
|
||||
*aVisible = true; // one assumes
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domwin(do_QueryReferent(mDOMWindowWeakref));
|
||||
if (domwin) { // dom window not deleted
|
||||
nsCOMPtr<nsIScrollable> scroller =
|
||||
do_QueryInterface(mDOMWindow->GetDocShell());
|
||||
|
||||
if (scroller) {
|
||||
int32_t prefValue;
|
||||
scroller->GetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_Y, &prefValue);
|
||||
if (prefValue == nsIScrollable::Scrollbar_Never) // try the other way
|
||||
scroller->GetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_X, &prefValue);
|
||||
|
||||
if (prefValue == nsIScrollable::Scrollbar_Never)
|
||||
*aVisible = false;
|
||||
}
|
||||
if (!mDOMWindow) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIScrollable> scroller =
|
||||
do_QueryInterface(mDOMWindow->GetDocShell());
|
||||
|
||||
if (!scroller) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t prefValue;
|
||||
scroller->GetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_Y, &prefValue);
|
||||
if (prefValue != nsIScrollable::Scrollbar_Never) {
|
||||
return true;
|
||||
}
|
||||
|
||||
scroller->GetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_X, &prefValue);
|
||||
return prefValue != nsIScrollable::Scrollbar_Never;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScrollbarsProp::SetVisible(bool aVisible)
|
||||
void
|
||||
ScrollbarsProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
||||
{
|
||||
if (!nsContentUtils::IsCallerChrome())
|
||||
return NS_OK;
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Scrollbars, unlike the other barprops, implement visibility directly
|
||||
rather than handing off to the superclass (and from there to the
|
||||
@ -290,25 +285,22 @@ ScrollbarsProp::SetVisible(bool aVisible)
|
||||
and because embedding apps have no interface for implementing this
|
||||
themselves, and therefore the implementation must be internal. */
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domwin(do_QueryReferent(mDOMWindowWeakref));
|
||||
if (domwin) { // dom window must still exist. use away.
|
||||
nsCOMPtr<nsIScrollable> scroller =
|
||||
do_QueryInterface(mDOMWindow->GetDocShell());
|
||||
nsCOMPtr<nsIScrollable> scroller =
|
||||
do_QueryInterface(mDOMWindow->GetDocShell());
|
||||
|
||||
if (scroller) {
|
||||
int32_t prefValue;
|
||||
if (scroller) {
|
||||
int32_t prefValue;
|
||||
|
||||
if (aVisible) {
|
||||
prefValue = nsIScrollable::Scrollbar_Auto;
|
||||
} else {
|
||||
prefValue = nsIScrollable::Scrollbar_Never;
|
||||
}
|
||||
|
||||
scroller->SetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_Y, prefValue);
|
||||
scroller->SetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_X, prefValue);
|
||||
if (aVisible) {
|
||||
prefValue = nsIScrollable::Scrollbar_Auto;
|
||||
} else {
|
||||
prefValue = nsIScrollable::Scrollbar_Never;
|
||||
}
|
||||
|
||||
scroller->SetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_Y, prefValue);
|
||||
scroller->SetDefaultScrollbarPreferences(
|
||||
nsIScrollable::ScrollOrientation_X, prefValue);
|
||||
}
|
||||
|
||||
/* Notably absent is the part where we notify the chrome window using
|
||||
@ -324,8 +316,6 @@ ScrollbarsProp::SetVisible(bool aVisible)
|
||||
ask (one of) its DOM window(s) when it needs to know about scrollbar
|
||||
visibility, rather than caching its own copy of that information.
|
||||
*/
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
|
@ -12,102 +12,112 @@
|
||||
#ifndef mozilla_dom_BarProps_h
|
||||
#define mozilla_dom_BarProps_h
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMBarProp.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
class nsGlobalWindow;
|
||||
class nsIWebBrowserChrome;
|
||||
class nsPIDOMWindow;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
// Script "BarProp" object
|
||||
class BarProp : public nsIDOMBarProp
|
||||
class BarProp : public nsISupports,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
explicit BarProp(nsGlobalWindow *aWindow);
|
||||
virtual ~BarProp();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(BarProp)
|
||||
|
||||
NS_IMETHOD GetVisibleByFlag(bool *aVisible, uint32_t aChromeFlag);
|
||||
NS_IMETHOD SetVisibleByFlag(bool aVisible, uint32_t aChromeFlag);
|
||||
nsPIDOMWindow* GetParentObject() const;
|
||||
|
||||
virtual JSObject*
|
||||
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool GetVisible(ErrorResult& aRv) = 0;
|
||||
virtual void SetVisible(bool aVisible, ErrorResult& aRv) = 0;
|
||||
|
||||
protected:
|
||||
bool GetVisibleByFlag(uint32_t aChromeFlag, ErrorResult& aRv);
|
||||
void SetVisibleByFlag(bool aVisible, uint32_t aChromeFlag, ErrorResult &aRv);
|
||||
|
||||
already_AddRefed<nsIWebBrowserChrome> GetBrowserChrome();
|
||||
|
||||
nsGlobalWindow *mDOMWindow;
|
||||
nsCOMPtr<nsIWeakReference> mDOMWindowWeakref;
|
||||
/* Note the odd double reference to the owning global window.
|
||||
Since the corresponding DOM window nominally owns this object,
|
||||
but refcounted ownership of this object can be handed off to
|
||||
owners unknown, we need a weak ref back to the DOM window.
|
||||
However we also need access to properties of the DOM Window
|
||||
that aren't available through interfaces. Then it's either
|
||||
a weak ref and some skanky casting, or this funky double ref.
|
||||
Funky beats skanky, so here we are. */
|
||||
nsRefPtr<nsGlobalWindow> mDOMWindow;
|
||||
};
|
||||
|
||||
// Script "menubar" object
|
||||
class MenubarProp : public BarProp
|
||||
class MenubarProp MOZ_FINAL : public BarProp
|
||||
{
|
||||
public:
|
||||
explicit MenubarProp(nsGlobalWindow *aWindow);
|
||||
virtual ~MenubarProp();
|
||||
|
||||
NS_DECL_NSIDOMBARPROP
|
||||
virtual bool GetVisible(ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
virtual void SetVisible(bool aVisible, ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
// Script "toolbar" object
|
||||
class ToolbarProp : public BarProp
|
||||
class ToolbarProp MOZ_FINAL : public BarProp
|
||||
{
|
||||
public:
|
||||
explicit ToolbarProp(nsGlobalWindow *aWindow);
|
||||
virtual ~ToolbarProp();
|
||||
|
||||
NS_DECL_NSIDOMBARPROP
|
||||
virtual bool GetVisible(ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
virtual void SetVisible(bool aVisible, ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
// Script "locationbar" object
|
||||
class LocationbarProp : public BarProp
|
||||
class LocationbarProp MOZ_FINAL : public BarProp
|
||||
{
|
||||
public:
|
||||
explicit LocationbarProp(nsGlobalWindow *aWindow);
|
||||
virtual ~LocationbarProp();
|
||||
|
||||
NS_DECL_NSIDOMBARPROP
|
||||
virtual bool GetVisible(ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
virtual void SetVisible(bool aVisible, ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
// Script "personalbar" object
|
||||
class PersonalbarProp : public BarProp
|
||||
class PersonalbarProp MOZ_FINAL : public BarProp
|
||||
{
|
||||
public:
|
||||
explicit PersonalbarProp(nsGlobalWindow *aWindow);
|
||||
virtual ~PersonalbarProp();
|
||||
|
||||
NS_DECL_NSIDOMBARPROP
|
||||
virtual bool GetVisible(ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
virtual void SetVisible(bool aVisible, ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
// Script "statusbar" object
|
||||
class StatusbarProp : public BarProp
|
||||
class StatusbarProp MOZ_FINAL : public BarProp
|
||||
{
|
||||
public:
|
||||
explicit StatusbarProp(nsGlobalWindow *aWindow);
|
||||
virtual ~StatusbarProp();
|
||||
|
||||
NS_DECL_NSIDOMBARPROP
|
||||
virtual bool GetVisible(ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
virtual void SetVisible(bool aVisible, ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
// Script "scrollbars" object
|
||||
class ScrollbarsProp : public BarProp
|
||||
class ScrollbarsProp MOZ_FINAL : public BarProp
|
||||
{
|
||||
public:
|
||||
explicit ScrollbarsProp(nsGlobalWindow *aWindow);
|
||||
virtual ~ScrollbarsProp();
|
||||
|
||||
NS_DECL_NSIDOMBARPROP
|
||||
virtual bool GetVisible(ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
virtual void SetVisible(bool aVisible, ErrorResult& aRv) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -146,7 +146,6 @@
|
||||
|
||||
// includes needed for the prototype chain interfaces
|
||||
#include "nsIDOMNavigator.h"
|
||||
#include "nsIDOMBarProp.h"
|
||||
#include "nsIDOMDocumentXBL.h"
|
||||
#include "nsIDOMElementCSSInlineStyle.h"
|
||||
#include "nsIDOMLinkStyle.h"
|
||||
@ -485,8 +484,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(MimeTypeArray, nsMimeTypeArraySH,
|
||||
ARRAY_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(BarProp, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(History, nsHistorySH,
|
||||
ARRAY_SCRIPTABLE_FLAGS |
|
||||
nsIXPCScriptable::WANT_PRECREATE)
|
||||
@ -1522,10 +1519,6 @@ nsDOMClassInfo::Init()
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMimeTypeArray)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(BarProp, nsIDOMBarProp)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBarProp)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(History, nsIDOMHistory)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHistory)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
@ -10,7 +10,6 @@ DOMCI_CLASS(Plugin)
|
||||
DOMCI_CLASS(PluginArray)
|
||||
DOMCI_CLASS(MimeType)
|
||||
DOMCI_CLASS(MimeTypeArray)
|
||||
DOMCI_CLASS(BarProp)
|
||||
DOMCI_CLASS(History)
|
||||
DOMCI_CLASS(DOMPrototype)
|
||||
DOMCI_CLASS(DOMConstructor)
|
||||
|
@ -1678,6 +1678,13 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrameElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFocusedNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioContexts)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMenubar)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mToolbar)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocationbar)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPersonalbar)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStatusbar)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mScrollbars)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
|
||||
@ -1724,6 +1731,13 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrameElement)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFocusedNode)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAudioContexts)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMenubar)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mToolbar)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mLocationbar)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPersonalbar)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mStatusbar)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mScrollbars)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
struct TraceData
|
||||
@ -3586,7 +3600,7 @@ nsGlobalWindow::GetPrompter(nsIPrompt** aPrompt)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetMenubar(nsIDOMBarProp** aMenubar)
|
||||
nsGlobalWindow::GetMenubar(nsISupports** aMenubar)
|
||||
{
|
||||
FORWARD_TO_OUTER(GetMenubar, (aMenubar), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
@ -3605,7 +3619,7 @@ nsGlobalWindow::GetMenubar(nsIDOMBarProp** aMenubar)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetToolbar(nsIDOMBarProp** aToolbar)
|
||||
nsGlobalWindow::GetToolbar(nsISupports** aToolbar)
|
||||
{
|
||||
FORWARD_TO_OUTER(GetToolbar, (aToolbar), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
@ -3624,7 +3638,7 @@ nsGlobalWindow::GetToolbar(nsIDOMBarProp** aToolbar)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetLocationbar(nsIDOMBarProp** aLocationbar)
|
||||
nsGlobalWindow::GetLocationbar(nsISupports** aLocationbar)
|
||||
{
|
||||
FORWARD_TO_OUTER(GetLocationbar, (aLocationbar), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
@ -3643,7 +3657,7 @@ nsGlobalWindow::GetLocationbar(nsIDOMBarProp** aLocationbar)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetPersonalbar(nsIDOMBarProp** aPersonalbar)
|
||||
nsGlobalWindow::GetPersonalbar(nsISupports** aPersonalbar)
|
||||
{
|
||||
FORWARD_TO_OUTER(GetPersonalbar, (aPersonalbar), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
@ -3662,7 +3676,7 @@ nsGlobalWindow::GetPersonalbar(nsIDOMBarProp** aPersonalbar)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetStatusbar(nsIDOMBarProp** aStatusbar)
|
||||
nsGlobalWindow::GetStatusbar(nsISupports** aStatusbar)
|
||||
{
|
||||
FORWARD_TO_OUTER(GetStatusbar, (aStatusbar), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
@ -3680,22 +3694,22 @@ nsGlobalWindow::GetStatusbar(nsIDOMBarProp** aStatusbar)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mozilla::dom::BarProp*
|
||||
nsGlobalWindow::Scrollbars()
|
||||
{
|
||||
if (!mScrollbars) {
|
||||
mScrollbars = new ScrollbarsProp(this);
|
||||
}
|
||||
|
||||
return mScrollbars;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::GetScrollbars(nsIDOMBarProp** aScrollbars)
|
||||
nsGlobalWindow::GetScrollbars(nsISupports** aScrollbars)
|
||||
{
|
||||
FORWARD_TO_OUTER(GetScrollbars, (aScrollbars), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
*aScrollbars = nullptr;
|
||||
|
||||
if (!mScrollbars) {
|
||||
mScrollbars = new ScrollbarsProp(this);
|
||||
if (!mScrollbars) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ADDREF(*aScrollbars = mScrollbars);
|
||||
|
||||
NS_ADDREF(*aScrollbars = Scrollbars());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,6 @@
|
||||
#define MIN_IDLE_NOTIFICATION_TIME_S 1
|
||||
|
||||
class nsIContent;
|
||||
class nsIDOMBarProp;
|
||||
class nsIDocument;
|
||||
class nsPresContext;
|
||||
class nsIDOMCrypto;
|
||||
@ -768,6 +767,8 @@ public:
|
||||
mozilla::dom::SpeechSynthesis* GetSpeechSynthesisInternal();
|
||||
#endif
|
||||
|
||||
mozilla::dom::BarProp* Scrollbars();
|
||||
|
||||
protected:
|
||||
// Array of idle observers that are notified of idle events.
|
||||
nsTObserverArray<IdleObserverHolder> mIdleObservers;
|
||||
|
@ -137,6 +137,10 @@ DOMInterfaces = {
|
||||
'AudioStreamTrack': {
|
||||
},
|
||||
|
||||
'BarProp': {
|
||||
'headerFile': 'mozilla/dom/BarProps.h',
|
||||
},
|
||||
|
||||
'BiquadFilterNode': {
|
||||
'resultNotAddRefed': [ 'frequency', 'detune', 'q', 'gain' ],
|
||||
},
|
||||
|
@ -47,7 +47,6 @@ interface nsIDOMPlugin;
|
||||
interface nsIDOMPluginArray;
|
||||
interface nsIDOMMimeType;
|
||||
interface nsIDOMMimeTypeArray;
|
||||
interface nsIDOMBarProp;
|
||||
interface nsIDOMNavigator;
|
||||
interface nsIDOMScreen;
|
||||
interface nsIDOMHistory;
|
||||
|
@ -11,7 +11,6 @@ XPIDL_SOURCES += [
|
||||
'nsIContentPrefService.idl',
|
||||
'nsIContentPrefService2.idl',
|
||||
'nsIContentURIGrouper.idl',
|
||||
'nsIDOMBarProp.idl',
|
||||
'nsIDOMCRMFObject.idl',
|
||||
'nsIDOMChromeWindow.idl',
|
||||
'nsIDOMClientInformation.idl',
|
||||
|
@ -1,18 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMBarProp interface is the interface for controlling and
|
||||
* accessing the visibility of certain UI items (scrollbars, menubars,
|
||||
* toolbars, ...) through the DOM.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(9eb2c150-1d56-11d3-8221-0060083a0bcf)]
|
||||
interface nsIDOMBarProp : nsISupports
|
||||
{
|
||||
attribute boolean visible;
|
||||
};
|
@ -53,13 +53,16 @@ interface nsIDOMWindow : nsISupports
|
||||
|
||||
|
||||
/* [replaceable] locationbar */
|
||||
readonly attribute nsIDOMBarProp locationbar;
|
||||
/* BarProp */
|
||||
readonly attribute nsISupports locationbar;
|
||||
|
||||
/* [replaceable] menubar */
|
||||
readonly attribute nsIDOMBarProp menubar;
|
||||
/* BarProp */
|
||||
readonly attribute nsISupports menubar;
|
||||
|
||||
/* [replaceable] personalbar */
|
||||
readonly attribute nsIDOMBarProp personalbar;
|
||||
/* BarProp */
|
||||
readonly attribute nsISupports personalbar;
|
||||
|
||||
/**
|
||||
* Accessor for the object that controls whether or not scrollbars
|
||||
@ -67,13 +70,16 @@ interface nsIDOMWindow : nsISupports
|
||||
*
|
||||
* This attribute is "replaceable" in JavaScript
|
||||
*/
|
||||
readonly attribute nsIDOMBarProp scrollbars;
|
||||
/* BarProp */
|
||||
readonly attribute nsISupports scrollbars;
|
||||
|
||||
/* [replaceable] statusbar */
|
||||
readonly attribute nsIDOMBarProp statusbar;
|
||||
/* BarProp */
|
||||
readonly attribute nsISupports statusbar;
|
||||
|
||||
/* [replaceable] toolbar */
|
||||
readonly attribute nsIDOMBarProp toolbar;
|
||||
/* BarProp */
|
||||
readonly attribute nsISupports toolbar;
|
||||
|
||||
/* [replaceable] */
|
||||
attribute DOMString status;
|
||||
|
11
dom/webidl/BarProp.webidl
Normal file
11
dom/webidl/BarProp.webidl
Normal file
@ -0,0 +1,11 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
interface BarProp
|
||||
{
|
||||
[Throws]
|
||||
attribute boolean visible;
|
||||
};
|
@ -23,6 +23,7 @@ webidl_files = \
|
||||
AudioParam.webidl \
|
||||
AudioStreamTrack.webidl \
|
||||
AudioProcessingEvent.webidl \
|
||||
BarProp.webidl \
|
||||
BatteryManager.webidl \
|
||||
BeforeUnloadEvent.webidl \
|
||||
BiquadFilterNode.webidl \
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMBarProp.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
@ -54,9 +53,11 @@
|
||||
#include "nsCxPusher.h"
|
||||
#include "nsWebShellWindow.h" // get rid of this one, too...
|
||||
#include "nsDOMEvent.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
|
||||
#include "prenv.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/BarProps.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
using namespace mozilla;
|
||||
@ -1981,12 +1982,14 @@ void nsXULWindow::PlaceWindowLayersBehind(uint32_t aLowLevel,
|
||||
|
||||
void nsXULWindow::SetContentScrollbarVisibility(bool aVisible)
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> contentWin(do_GetInterface(mPrimaryContentShell));
|
||||
nsCOMPtr<nsPIDOMWindow> contentWin(do_GetInterface(mPrimaryContentShell));
|
||||
if (contentWin) {
|
||||
nsCOMPtr<nsIDOMBarProp> scrollbars;
|
||||
contentWin->GetScrollbars(getter_AddRefs(scrollbars));
|
||||
if (scrollbars)
|
||||
scrollbars->SetVisible(aVisible);
|
||||
nsRefPtr<nsGlobalWindow> window = static_cast<nsGlobalWindow*>(contentWin.get());
|
||||
nsRefPtr<mozilla::dom::BarProp> scrollbars = window->Scrollbars();
|
||||
if (scrollbars) {
|
||||
mozilla::ErrorResult rv;
|
||||
scrollbars->SetVisible(aVisible, rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user