2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
1999-06-09 22:59:04 +04:00
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
#include "mozilla/dom/BarProps.h"
|
2013-06-01 12:53:00 +04:00
|
|
|
#include "mozilla/dom/BarPropBinding.h"
|
|
|
|
#include "nsContentUtils.h"
|
2002-02-16 04:15:52 +03:00
|
|
|
#include "nsGlobalWindow.h"
|
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIScrollable.h"
|
2013-08-15 22:17:48 +04:00
|
|
|
#include "nsIWebBrowserChrome.h"
|
2013-05-31 14:30:00 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
1999-06-09 22:59:04 +04:00
|
|
|
//
|
|
|
|
// Basic (virtual) BarProp class implementation
|
|
|
|
//
|
2013-10-25 15:12:01 +04:00
|
|
|
BarProp::BarProp(nsGlobalWindow* aWindow)
|
2013-06-01 12:53:00 +04:00
|
|
|
: mDOMWindow(aWindow)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2013-10-25 15:12:01 +04:00
|
|
|
MOZ_ASSERT(aWindow->IsInnerWindow());
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
BarProp::~BarProp()
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner*
|
2013-06-01 12:53:00 +04:00
|
|
|
BarProp::GetParentObject() const
|
|
|
|
{
|
2016-01-30 20:05:36 +03:00
|
|
|
return mDOMWindow->AsInner();
|
2013-06-01 12:53:00 +04:00
|
|
|
}
|
2000-02-08 16:40:10 +03:00
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
BarProp::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-06-01 12:53:00 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return BarPropBinding::Wrap(aCx, this, aGivenProto);
|
2013-06-01 12:53:00 +04:00
|
|
|
}
|
2000-02-08 16:40:10 +03:00
|
|
|
|
2014-04-29 12:57:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(BarProp, mDOMWindow)
|
2013-06-01 12:53:00 +04:00
|
|
|
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
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
bool
|
|
|
|
BarProp::GetVisibleByFlag(uint32_t aChromeFlag, ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2011-04-28 00:54:07 +04:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome = GetBrowserChrome();
|
2013-06-01 12:53:00 +04:00
|
|
|
NS_ENSURE_TRUE(browserChrome, false);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t chromeFlags;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
if (NS_FAILED(browserChrome->GetChromeFlags(&chromeFlags))) {
|
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return false;
|
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
return (chromeFlags & aChromeFlag);
|
1999-06-10 05:27:47 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
void
|
|
|
|
BarProp::SetVisibleByFlag(bool aVisible, uint32_t aChromeFlag,
|
|
|
|
ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2011-04-28 00:54:07 +04:00
|
|
|
nsCOMPtr<nsIWebBrowserChrome> browserChrome = GetBrowserChrome();
|
2013-06-01 12:53:00 +04:00
|
|
|
NS_ENSURE_TRUE_VOID(browserChrome);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
if (!nsContentUtils::IsCallerChrome()) {
|
|
|
|
return;
|
|
|
|
}
|
2004-03-09 03:45:41 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t chromeFlags;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
if (NS_FAILED(browserChrome->GetChromeFlags(&chromeFlags))) {
|
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-28 00:54:07 +04:00
|
|
|
if (aVisible)
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
chromeFlags |= aChromeFlag;
|
|
|
|
else
|
|
|
|
chromeFlags &= ~aChromeFlag;
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
if (NS_FAILED(browserChrome->SetChromeFlags(chromeFlags))) {
|
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
}
|
1999-06-10 05:27:47 +04:00
|
|
|
}
|
|
|
|
|
2011-04-28 00:54:07 +04:00
|
|
|
already_AddRefed<nsIWebBrowserChrome>
|
2013-05-31 14:30:00 +04:00
|
|
|
BarProp::GetBrowserChrome()
|
2011-04-28 00:54:07 +04:00
|
|
|
{
|
2013-06-01 12:53:00 +04:00
|
|
|
if (!mDOMWindow) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2013-06-01 12:53:00 +04:00
|
|
|
}
|
2011-04-28 00:54:07 +04:00
|
|
|
|
2013-04-26 10:51:04 +04:00
|
|
|
return mDOMWindow->GetWebBrowserChrome();
|
2011-04-28 00:54:07 +04:00
|
|
|
}
|
|
|
|
|
1999-06-09 22:59:04 +04:00
|
|
|
//
|
|
|
|
// MenubarProp class implementation
|
|
|
|
//
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
MenubarProp::MenubarProp(nsGlobalWindow *aWindow)
|
|
|
|
: BarProp(aWindow)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
MenubarProp::~MenubarProp()
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
bool
|
|
|
|
MenubarProp::GetVisible(ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2013-06-01 12:53:00 +04:00
|
|
|
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_MENUBAR, aRv);
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
void
|
|
|
|
MenubarProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2013-06-01 12:53:00 +04:00
|
|
|
BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_MENUBAR, aRv);
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// ToolbarProp class implementation
|
|
|
|
//
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
ToolbarProp::ToolbarProp(nsGlobalWindow *aWindow)
|
|
|
|
: BarProp(aWindow)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
ToolbarProp::~ToolbarProp()
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
bool
|
|
|
|
ToolbarProp::GetVisible(ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2013-06-01 12:53:00 +04:00
|
|
|
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_TOOLBAR, aRv);
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
void
|
|
|
|
ToolbarProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2013-06-01 12:53:00 +04:00
|
|
|
BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_TOOLBAR,
|
|
|
|
aRv);
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// LocationbarProp class implementation
|
|
|
|
//
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
LocationbarProp::LocationbarProp(nsGlobalWindow *aWindow)
|
|
|
|
: BarProp(aWindow)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
LocationbarProp::~LocationbarProp()
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
bool
|
|
|
|
LocationbarProp::GetVisible(ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2013-06-01 12:53:00 +04:00
|
|
|
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_LOCATIONBAR,
|
|
|
|
aRv);
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
void
|
|
|
|
LocationbarProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2013-06-01 12:53:00 +04:00
|
|
|
BarProp::SetVisibleByFlag(aVisible, nsIWebBrowserChrome::CHROME_LOCATIONBAR,
|
|
|
|
aRv);
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// PersonalbarProp class implementation
|
|
|
|
//
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
PersonalbarProp::PersonalbarProp(nsGlobalWindow *aWindow)
|
|
|
|
: BarProp(aWindow)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
PersonalbarProp::~PersonalbarProp()
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
bool
|
|
|
|
PersonalbarProp::GetVisible(ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2013-06-01 12:53:00 +04:00
|
|
|
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR,
|
|
|
|
aRv);
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
void
|
|
|
|
PersonalbarProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2013-06-01 12:53:00 +04:00
|
|
|
BarProp::SetVisibleByFlag(aVisible,
|
|
|
|
nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR,
|
|
|
|
aRv);
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// StatusbarProp class implementation
|
|
|
|
//
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
StatusbarProp::StatusbarProp(nsGlobalWindow *aWindow)
|
|
|
|
: BarProp(aWindow)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
StatusbarProp::~StatusbarProp()
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
bool
|
|
|
|
StatusbarProp::GetVisible(ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2013-06-01 12:53:00 +04:00
|
|
|
return BarProp::GetVisibleByFlag(nsIWebBrowserChrome::CHROME_STATUSBAR, aRv);
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
void
|
|
|
|
StatusbarProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2013-05-31 14:30:00 +04:00
|
|
|
return BarProp::SetVisibleByFlag(aVisible,
|
2013-06-01 12:53:00 +04:00
|
|
|
nsIWebBrowserChrome::CHROME_STATUSBAR, aRv);
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// ScrollbarsProp class implementation
|
|
|
|
//
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
ScrollbarsProp::ScrollbarsProp(nsGlobalWindow *aWindow)
|
|
|
|
: BarProp(aWindow)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
ScrollbarsProp::~ScrollbarsProp()
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
bool
|
|
|
|
ScrollbarsProp::GetVisible(ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2013-06-01 12:53:00 +04:00
|
|
|
if (!mDOMWindow) {
|
|
|
|
return true;
|
2002-02-16 04:15:52 +03:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
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;
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
|
|
|
|
2013-06-01 12:53:00 +04:00
|
|
|
void
|
|
|
|
ScrollbarsProp::SetVisible(bool aVisible, ErrorResult& aRv)
|
2000-02-08 16:40:10 +03:00
|
|
|
{
|
2014-09-25 13:04:45 +04:00
|
|
|
if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode()) {
|
2013-06-01 12:53:00 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-12-30 19:57:46 +03:00
|
|
|
|
2002-02-16 04:15:52 +03:00
|
|
|
/* Scrollbars, unlike the other barprops, implement visibility directly
|
|
|
|
rather than handing off to the superclass (and from there to the
|
|
|
|
chrome window) because scrollbar visibility uniquely applies only
|
|
|
|
to the window making the change (arguably. it does now, anyway.)
|
|
|
|
and because embedding apps have no interface for implementing this
|
|
|
|
themselves, and therefore the implementation must be internal. */
|
|
|
|
|
2016-03-15 01:03:37 +03:00
|
|
|
nsCOMPtr<nsIScrollable> scroller =
|
|
|
|
do_QueryInterface(mDOMWindow->GetDocShell());
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2002-02-16 04:15:52 +03:00
|
|
|
|
|
|
|
/* Notably absent is the part where we notify the chrome window using
|
2011-04-28 00:54:07 +04:00
|
|
|
GetBrowserChrome()->SetChromeFlags(). Given the possibility of multiple
|
2002-02-16 04:15:52 +03:00
|
|
|
DOM windows (multiple top-level windows, even) within a single
|
|
|
|
chrome window, the historical concept of a single "has scrollbars"
|
|
|
|
flag in the chrome is inapplicable, and we can't tell at this level
|
|
|
|
whether we represent the particular DOM window that makes this decision
|
|
|
|
for the chrome.
|
|
|
|
|
|
|
|
So only this object (and its corresponding DOM window) knows whether
|
|
|
|
scrollbars are visible. The corresponding chrome window will need to
|
|
|
|
ask (one of) its DOM window(s) when it needs to know about scrollbar
|
|
|
|
visibility, rather than caching its own copy of that information.
|
|
|
|
*/
|
1999-06-09 22:59:04 +04:00
|
|
|
}
|
2002-02-16 04:15:52 +03:00
|
|
|
|
2013-05-31 14:30:00 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|