mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
10160cd03d
- Bug 1240749 - Fixes for DPI support in Gtk widget interface: remove incorrect Get[Avail]RectDisplayPix overrides, as desktop pixels == device pixels for the Gtk widget backend, and implement nsScreenGtk::GetDefaultCSSScaleFactor, required by nsGlobalWindow since per-monitor DPI patches in bug 890156. r=karlt (9975cac985)
- Bug 1033488 - Part 2. Make PuppetBidiKeyboard correctly on content process. r=masayuki (3a91ce60a8)
- Bug 1257067 - modified XF86XK_ keysyms to GDK_ ones r=masayuki (4b922f9365)
- Bug 1251984 - allow gfx.xrender.enabled pref to work for compositing even if content backend is not Cairo. r=jrmuizel (257a163074)
- Bug 1235941 - Detect DPI change for GTK3. r=karlt (f8ca209d4b)
- Bug 1256728: Add environment variable to disable force present from bug 1232042. r=BenWa (c3b12a085b)
- Bug 1257124: Add null check for IDWriteFactory in gfxDWriteFontFileLoader::CreateCustomFontFile. r=bas (d33af4b9e1)
- Bug 1266209 - log failure reason when PathBuilderD2D::Finish fails. r=bas.schouten (360d7c2ada)
- Bug 1256552 - Disable C4577 to unblock compilation on VS2015; r=jrmuizel (7375fbf42a)
- Bug 1265960 - Remove gfxReusable* r=Bas (ed0b3aca14)
- Bug 1246290 - Refactoring to get rid of SampleContentTransformForFrame from AsyncPanZoomController. r=botond (3be6b4c1f9)
- Bug 1246290 - Add the ability for APZCs to not expose async transforms. r=botond (48942ceddf)
- Bug 1259296 - Scroll snap in the compositor in response to wheel events. r=kats (5fc694c804)
- Bug 1249040 - Allow wheel scrolls to accumulate in the presence of scroll snapping. r=kats (7514e3f6d6)
- Bug 1237343 - Replace uses of mozilla::Vector with nsTArray. r=botond (b721de19cd)
- Bug 1236046 - Don't use a stupidly small time delta to compute a velocity. r=botond (6c8f298ab6)
- Bug 1257959 - Dynamic toolbar transition seems to slow down flings r=kats (47ec4d0d54)
- Bug 1265513 - Do a fuzzy match when checking to see if a scroll will result in overscroll. r=botond (03ee304916)
- Bug 1254252 - Have Axis::ClampOriginToScrollableRect just return the original value if it falls with in the page bounds. r=kats (f88c0b4d7d)
- Bug 1261373 - Record how long it takes for content response notifications to be delivered to APZ. r=botond f=bsmedberg (b4b24d7602)
- Bug 1265515 - Update nsAutoPtr.h includes in gfx/layers/apz to RefPtr.h. r=kats (48bbc2cda8)
- Bug 1259296 - Make sure APZ smooth scroll animations end at their exact destination scroll offset. r=kats (36cace259b)
- Bug 1251837, part 1 - Use pushPrefEnv in setDeltaMultiplierSettings in window_wheel_default_action.html. r=masayuki (d673d55f02)
- Bug 1251837, part 2 - Use pushPrefEnv in doTestActionOverride in window_wheel_default_action.html. r=masayuki (f0375a3820)
- Bug 1251837, part 3 - Use pushPrefEnv in doTestWholeScroll in window_wheel_default_action.html. r=masayuki (0a7af4e103)
- Bug 1251837, part 4 - Use pushPrefEnv in doTestActionOverride in window_wheel_default_action.html. r=masayuki (51bd9cd1e2)
- Bug 1251837, part 5 - Make prepare() in doTestScroll take a callback, and use pushPrefEnv. r=masayuki (856056a947)
- Bug 1251837, part 6 - Make cleanup() in doTestScroll take a callback, and use pushPrefEnv. r=masayuki (34aa62b7f3)
- Bug 1255173 - Fix onZoomReset() in test_wheel_default_action.html to work with e10s. r=masayuki, r=jmaher (0c248c7587)
- Bug 1255178 - Part 1: Remove a leftover use of clearUserPref. r=masayuki Also, remove some trailing whitespace. (c067affdba)
- Bug 1255178 - Part 2: Remove extraneous argument to sendWheelAndWait. r=masayuki (80ce47c89b)
- Bug 1255634 - APZ should scroll by more than a page with large values of mousewheel.default.delta_multiplier_{x,y}. r=masayuki,kats (d72f77daed)
- Bug 1251638 - Don't clamp the displayport to the scrollable rect on the compositor side. r=botond (5dae2ba82e)
- Bug 1251638 - Do a bit of cleanup on the displayport margin computation in APZC; no functional changes. r=botond (575453b538)
- Bug 1266154 - Don't start a scroll snap animation if we're already at the destination. r=kats (2926d33a07)
- Bug 1258851 - Update HitTestingTreeNode::IsScrollbarNode to include the scrollbar track layers. r=rbarker (1e68081a6a)
- Bug 1265806 - Update scrollbar finding code to deal with layer trees on both OS X and Windows properly. r=rbarker (e8df49352e)
- Bug 1255224 - Add pref to force glFinish in DXGL path. (default:false) - r=dvander (8d399f8a49)
- Bug 1224199 - Destroy SharedSurfaces before ~GLContext(). - r=jrmuizel (5ad8d11f8e)
- Bug 1232480. Use 'precision' instead of 'prevision' (c7310988fa)
- Bug 1232668. Allow using kTex2DBlit_FragShaderSource on non-ES targets. (1951af5c1c)
- Bug 1235299 - Fix WebGL assertions for copyTexImage2D. r=jgilbert (226b7c14a8)
- Bug 1249189 - Use GL_RED to replace GL_ALPHA in YCbCr convert. r=jgilbert (e1d8ae2513)
- Bug 1256552 - fix int-to-float conversions in RadialGradientEffectD2D1. r=jrmuizel (36bb7f7f0f)
- Bug 1249279 - Let subdocuments' presContexts inherit the DPI setting of their parent, instead of retrieving it from their widget, to avoid using stale values from a currently-hidden widget on a screen with a different DPI. r=bz (4b8f6e0960)
- Bug 1237479 -- nsScriptSecurityManager needs to use the correct user context id in the origin attributes in a few places. r=sicking (90504a4130)
- Bug 1105556 - Call Create(originAttributes) when loadinfo->loadingPrincipal is null, instead of CreatePrincipalWithInheritedAttributes(). r=sicking (fdb341ca53)
- Bug 1253788 - Don't reload inline chrome:// style sheets in nsXBLPrototypeResources. r=bzbarsky (862464ea6c)
- Bug 1261123 - don't needlessly construct nsAutoCString temporaries in nsDefaultURIFixup; r=smaug (08f13674a8)
- Bug 1253673, r=bz (03caab3cce)
- Bug 1259511 - Overwrite loadInfo within AboutProtocolHandler and log warning to console. r=sicking (e2fc868326)
- Bug 905460 - Convert http legacy refs to smart pointers r=dragana a=kwierso (d4bdd102fa)
- Bug 1248564 - "Default authentication credentials (NTLM, Kerb) used in private mode". r=mayhemer (37c5674a0d)
- Bug 345580 - Problem decoding quoted-printable question mark in subject r=biesi (00f66a34a7)
- Bug 906986 - Rework fix for Bug 1241690 to avoid reliance on NrIceCtx inside NrIceMediaStream. r=bwc, r=drno (3d6aabeab6)
- Bug 906986 - Disable TestSrflxCandPairingFilter until bug 1226838 is fixed. r=bwc, r=drno (687281bf8b)
- Bug 906986 - Use the streams from the ice_ctx, don't hold a separate set. r=bwc, r=drno (269cd38ed2)
- Bug 906986 - Genericize some of the test setup and improve logging. r=bwc, r=drno (ad735f2459)
- Bug 906986 - Wrap NrIceCtx in NrIceCtxHandler which will allow us to handle ice restart. r=bwc, r=drno (4f2c1e5866)
- Bug 911216 - Part 12: Windows build bustage fix on a CLOSED TREE. r=efaust (f81e40df57)
- Bug 1261329 - Fix OOM handling in shell dissrc function r=efaust (d61eb121de)
- Bug 1263868 - Properly recover from OOM in ShellAutoEntryMonitor. r=jonco (3830ce7aae)
- Bug 1257722 - Prevent stdout/stderr from getting closed, r=jorendorff (48629efc06)
- Bug 1258847 - Set PTHREAD_MUTEX_ERRORCHECK for js::Mutex in debug builds. r=sfink (48cb353190)
- Bug 1252464 - Remove FrameRange cray cray in favor of using GCVectors. (r=jimb) (60ad943599)
- Bug 1257194: Tracelogger - Check for oom in drainTracelogger, r=bbouvier (7d8299958f)
- Bug 1264961 - Fix OOM case in Debugger::replaceFrameGuts. (r=jimb) (203816a8b3)
- Bug 1257588 - Don't ignore self-hosted frames when getting a saved frame's async cause. r=fitzgen (15b467a950)
- Bug 1258535 - Part 0: Add more and stronger asserts that SavedStacks-related JSAPI methods are called correctly; r=jandem (187251c401)
- Bug 1258535 - Check for the existence of a global before checking if its standard classes are resolved; r=jandem (18f7bbcc69)
- Bug 1264975 - Fix assertion in DebugScope wrapping non-syntactic scopes. (r=jimb) (753e315ddb)
- Bug 1259403 - Tracelogger: Always make sure there are 3 free slots for events, r=bbouvier (67a13b7a14)
- Bug 1231926 - add assertions on BYTEOFFSET_SLOT. r=waldo (3508ea1943)
- Bug 1260725 - Handle and report OOM in census breakdown parsing; r=jorendorff a=kwierso (de669940d1)
- Bug 1263074 - Change the JavaScript syntax error message for the old octal literal notation to suggest the new notation. r=Waldo (4e2457b27a)
- Bug 1257096, don't try to report about unusual unhandled rejected Promises, r=bz,waldo (682e4720d9)
- Bug 1262402: Use the new int64 testing features; r=luke (d213bb4f2c)
- Bug 1263882: Set a default value in DescribeScriptedCaller if the filename is null; r=luke (f66ec211f5)
726 lines
19 KiB
C++
726 lines
19 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=2 sw=2 et tw=78: */
|
|
/* 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 "nsChromeRegistry.h"
|
|
#include "nsChromeRegistryChrome.h"
|
|
#include "nsChromeRegistryContent.h"
|
|
|
|
#include "prprf.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
#include "nsError.h"
|
|
#include "nsEscape.h"
|
|
#include "nsNetUtil.h"
|
|
#include "nsString.h"
|
|
#include "nsQueryObject.h"
|
|
|
|
#include "mozilla/dom/URL.h"
|
|
#include "nsIConsoleService.h"
|
|
#include "nsIDocument.h"
|
|
#include "nsIDOMDocument.h"
|
|
#include "nsIDOMLocation.h"
|
|
#include "nsIDOMWindowCollection.h"
|
|
#include "nsIDOMWindow.h"
|
|
#include "nsIObserverService.h"
|
|
#include "nsIPresShell.h"
|
|
#include "nsIScriptError.h"
|
|
#include "nsIWindowMediator.h"
|
|
#include "nsIPrefService.h"
|
|
#include "mozilla/StyleSheetHandle.h"
|
|
#include "mozilla/StyleSheetHandleInlines.h"
|
|
|
|
nsChromeRegistry* nsChromeRegistry::gChromeRegistry;
|
|
|
|
// DO NOT use namespace mozilla; it'll break due to a naming conflict between
|
|
// mozilla::TextRange and a TextRange in OSX headers.
|
|
using mozilla::StyleSheetHandle;
|
|
using mozilla::dom::IsChromeURI;
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void
|
|
nsChromeRegistry::LogMessage(const char* aMsg, ...)
|
|
{
|
|
nsCOMPtr<nsIConsoleService> console
|
|
(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
if (!console)
|
|
return;
|
|
|
|
va_list args;
|
|
va_start(args, aMsg);
|
|
char* formatted = PR_vsmprintf(aMsg, args);
|
|
va_end(args);
|
|
if (!formatted)
|
|
return;
|
|
|
|
console->LogStringMessage(NS_ConvertUTF8toUTF16(formatted).get());
|
|
PR_smprintf_free(formatted);
|
|
}
|
|
|
|
void
|
|
nsChromeRegistry::LogMessageWithContext(nsIURI* aURL, uint32_t aLineNumber, uint32_t flags,
|
|
const char* aMsg, ...)
|
|
{
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIConsoleService> console
|
|
(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
nsCOMPtr<nsIScriptError> error
|
|
(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
|
|
if (!console || !error)
|
|
return;
|
|
|
|
va_list args;
|
|
va_start(args, aMsg);
|
|
char* formatted = PR_vsmprintf(aMsg, args);
|
|
va_end(args);
|
|
if (!formatted)
|
|
return;
|
|
|
|
nsCString spec;
|
|
if (aURL)
|
|
aURL->GetSpec(spec);
|
|
|
|
rv = error->Init(NS_ConvertUTF8toUTF16(formatted),
|
|
NS_ConvertUTF8toUTF16(spec),
|
|
EmptyString(),
|
|
aLineNumber, 0, flags, "chrome registration");
|
|
PR_smprintf_free(formatted);
|
|
|
|
if (NS_FAILED(rv))
|
|
return;
|
|
|
|
console->LogMessage(error);
|
|
}
|
|
|
|
nsChromeRegistry::~nsChromeRegistry()
|
|
{
|
|
gChromeRegistry = nullptr;
|
|
}
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsChromeRegistry)
|
|
NS_INTERFACE_MAP_ENTRY(nsIChromeRegistry)
|
|
NS_INTERFACE_MAP_ENTRY(nsIXULChromeRegistry)
|
|
NS_INTERFACE_MAP_ENTRY(nsIToolkitChromeRegistry)
|
|
#ifdef MOZ_XUL
|
|
NS_INTERFACE_MAP_ENTRY(nsIXULOverlayProvider)
|
|
#endif
|
|
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIChromeRegistry)
|
|
NS_INTERFACE_MAP_END
|
|
|
|
NS_IMPL_ADDREF(nsChromeRegistry)
|
|
NS_IMPL_RELEASE(nsChromeRegistry)
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// nsIChromeRegistry methods:
|
|
|
|
already_AddRefed<nsIChromeRegistry>
|
|
nsChromeRegistry::GetService()
|
|
{
|
|
if (!gChromeRegistry)
|
|
{
|
|
// We don't actually want this ref, we just want the service to
|
|
// initialize if it hasn't already.
|
|
nsCOMPtr<nsIChromeRegistry> reg(
|
|
do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
|
|
if (!gChromeRegistry)
|
|
return nullptr;
|
|
}
|
|
nsCOMPtr<nsIChromeRegistry> registry = gChromeRegistry;
|
|
return registry.forget();
|
|
}
|
|
|
|
nsresult
|
|
nsChromeRegistry::Init()
|
|
{
|
|
// This initialization process is fairly complicated and may cause reentrant
|
|
// getservice calls to resolve chrome URIs (especially locale files). We
|
|
// don't want that, so we inform the protocol handler about our existence
|
|
// before we are actually fully initialized.
|
|
gChromeRegistry = this;
|
|
|
|
mInitialized = true;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult
|
|
nsChromeRegistry::GetProviderAndPath(nsIURL* aChromeURL,
|
|
nsACString& aProvider, nsACString& aPath)
|
|
{
|
|
nsresult rv;
|
|
|
|
#ifdef DEBUG
|
|
bool isChrome;
|
|
aChromeURL->SchemeIs("chrome", &isChrome);
|
|
NS_ASSERTION(isChrome, "Non-chrome URI?");
|
|
#endif
|
|
|
|
nsAutoCString path;
|
|
rv = aChromeURL->GetPath(path);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (path.Length() < 3) {
|
|
LogMessage("Invalid chrome URI: %s", path.get());
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
path.SetLength(nsUnescapeCount(path.BeginWriting()));
|
|
NS_ASSERTION(path.First() == '/', "Path should always begin with a slash!");
|
|
|
|
int32_t slash = path.FindChar('/', 1);
|
|
if (slash == 1) {
|
|
LogMessage("Invalid chrome URI: %s", path.get());
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
|
|
if (slash == -1) {
|
|
aPath.Truncate();
|
|
}
|
|
else {
|
|
if (slash == (int32_t) path.Length() - 1)
|
|
aPath.Truncate();
|
|
else
|
|
aPath.Assign(path.get() + slash + 1, path.Length() - slash - 1);
|
|
|
|
--slash;
|
|
}
|
|
|
|
aProvider.Assign(path.get() + 1, slash);
|
|
return NS_OK;
|
|
}
|
|
|
|
|
|
nsresult
|
|
nsChromeRegistry::Canonify(nsIURL* aChromeURL)
|
|
{
|
|
NS_NAMED_LITERAL_CSTRING(kSlash, "/");
|
|
|
|
nsresult rv;
|
|
|
|
nsAutoCString provider, path;
|
|
rv = GetProviderAndPath(aChromeURL, provider, path);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (path.IsEmpty()) {
|
|
nsAutoCString package;
|
|
rv = aChromeURL->GetHost(package);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
// we re-use the "path" local string to build a new URL path
|
|
path.Assign(kSlash + provider + kSlash + package);
|
|
if (provider.EqualsLiteral("content")) {
|
|
path.AppendLiteral(".xul");
|
|
}
|
|
else if (provider.EqualsLiteral("locale")) {
|
|
path.AppendLiteral(".dtd");
|
|
}
|
|
else if (provider.EqualsLiteral("skin")) {
|
|
path.AppendLiteral(".css");
|
|
}
|
|
else {
|
|
return NS_ERROR_INVALID_ARG;
|
|
}
|
|
aChromeURL->SetPath(path);
|
|
}
|
|
else {
|
|
// path is already unescaped once, but uris can get unescaped twice
|
|
const char* pos = path.BeginReading();
|
|
const char* end = path.EndReading();
|
|
if (*pos == '/' || *pos == ' ') {
|
|
return NS_ERROR_DOM_BAD_URI;
|
|
}
|
|
while (pos < end) {
|
|
switch (*pos) {
|
|
case ':':
|
|
return NS_ERROR_DOM_BAD_URI;
|
|
case '.':
|
|
// prevent directory traversals ("..")
|
|
if (pos[1] == '.')
|
|
return NS_ERROR_DOM_BAD_URI;
|
|
break;
|
|
case '%':
|
|
// chrome: URIs with double-escapes are trying to trick us.
|
|
// watch for %2e, and %25 in case someone triple unescapes
|
|
if (pos[1] == '2' &&
|
|
( pos[2] == 'e' || pos[2] == 'E' ||
|
|
pos[2] == '5' ))
|
|
return NS_ERROR_DOM_BAD_URI;
|
|
break;
|
|
case '?':
|
|
case '#':
|
|
pos = end;
|
|
continue;
|
|
}
|
|
++pos;
|
|
}
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURI, nsIURI* *aResult)
|
|
{
|
|
nsresult rv;
|
|
if (NS_WARN_IF(!aChromeURI)) {
|
|
return NS_ERROR_INVALID_ARG;
|
|
}
|
|
|
|
if (mOverrideTable.Get(aChromeURI, aResult))
|
|
return NS_OK;
|
|
|
|
nsCOMPtr<nsIURL> chromeURL (do_QueryInterface(aChromeURI));
|
|
NS_ENSURE_TRUE(chromeURL, NS_NOINTERFACE);
|
|
|
|
nsAutoCString package, provider, path;
|
|
rv = chromeURL->GetHostPort(package);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = GetProviderAndPath(chromeURL, provider, path);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsIURI* baseURI = GetBaseURIFromPackage(package, provider, path);
|
|
|
|
uint32_t flags;
|
|
rv = GetFlagsFromPackage(package, &flags);
|
|
if (NS_FAILED(rv))
|
|
return rv;
|
|
|
|
if (flags & PLATFORM_PACKAGE) {
|
|
#if defined(XP_WIN)
|
|
path.Insert("win/", 0);
|
|
#elif defined(XP_MACOSX)
|
|
path.Insert("mac/", 0);
|
|
#else
|
|
path.Insert("unix/", 0);
|
|
#endif
|
|
}
|
|
|
|
if (!baseURI) {
|
|
LogMessage("No chrome package registered for chrome://%s/%s/%s",
|
|
package.get(), provider.get(), path.get());
|
|
return NS_ERROR_FILE_NOT_FOUND;
|
|
}
|
|
|
|
return NS_NewURI(aResult, path, nullptr, baseURI);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// theme stuff
|
|
|
|
|
|
static void FlushSkinBindingsForWindow(nsIDOMWindow* aWindow)
|
|
{
|
|
// Get the DOM document.
|
|
nsCOMPtr<nsIDOMDocument> domDocument;
|
|
aWindow->GetDocument(getter_AddRefs(domDocument));
|
|
if (!domDocument)
|
|
return;
|
|
|
|
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
|
|
if (!document)
|
|
return;
|
|
|
|
// Annihilate all XBL bindings.
|
|
document->FlushSkinBindings();
|
|
}
|
|
|
|
// XXXbsmedberg: move this to nsIWindowMediator
|
|
NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
|
|
{
|
|
nsCOMPtr<nsIWindowMediator> windowMediator
|
|
(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
|
|
if (!windowMediator)
|
|
return NS_OK;
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
|
windowMediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator));
|
|
bool more;
|
|
windowEnumerator->HasMoreElements(&more);
|
|
while (more) {
|
|
nsCOMPtr<nsISupports> protoWindow;
|
|
windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
|
if (protoWindow) {
|
|
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(protoWindow);
|
|
if (domWindow)
|
|
FlushSkinBindingsForWindow(domWindow);
|
|
}
|
|
windowEnumerator->HasMoreElements(&more);
|
|
}
|
|
|
|
FlushSkinCaches();
|
|
|
|
windowMediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator));
|
|
windowEnumerator->HasMoreElements(&more);
|
|
while (more) {
|
|
nsCOMPtr<nsISupports> protoWindow;
|
|
windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
|
if (protoWindow) {
|
|
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(protoWindow);
|
|
if (domWindow)
|
|
RefreshWindow(domWindow);
|
|
}
|
|
windowEnumerator->HasMoreElements(&more);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
nsChromeRegistry::FlushSkinCaches()
|
|
{
|
|
nsCOMPtr<nsIObserverService> obsSvc =
|
|
mozilla::services::GetObserverService();
|
|
NS_ASSERTION(obsSvc, "Couldn't get observer service.");
|
|
|
|
obsSvc->NotifyObservers(static_cast<nsIChromeRegistry*>(this),
|
|
NS_CHROME_FLUSH_SKINS_TOPIC, nullptr);
|
|
}
|
|
|
|
// XXXbsmedberg: move this to windowmediator
|
|
nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow)
|
|
{
|
|
// Deal with our subframes first.
|
|
nsCOMPtr<nsIDOMWindowCollection> frames;
|
|
aWindow->GetFrames(getter_AddRefs(frames));
|
|
uint32_t length;
|
|
frames->GetLength(&length);
|
|
uint32_t j;
|
|
for (j = 0; j < length; j++) {
|
|
nsCOMPtr<nsIDOMWindow> childWin;
|
|
frames->Item(j, getter_AddRefs(childWin));
|
|
RefreshWindow(childWin);
|
|
}
|
|
|
|
nsresult rv;
|
|
// Get the DOM document.
|
|
nsCOMPtr<nsIDOMDocument> domDocument;
|
|
aWindow->GetDocument(getter_AddRefs(domDocument));
|
|
if (!domDocument)
|
|
return NS_OK;
|
|
|
|
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
|
|
if (!document)
|
|
return NS_OK;
|
|
|
|
// Deal with the agent sheets first. Have to do all the style sets by hand.
|
|
nsCOMPtr<nsIPresShell> shell = document->GetShell();
|
|
if (shell) {
|
|
// Reload only the chrome URL agent style sheets.
|
|
nsTArray<StyleSheetHandle::RefPtr> agentSheets;
|
|
rv = shell->GetAgentStyleSheets(agentSheets);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
nsTArray<StyleSheetHandle::RefPtr> newAgentSheets;
|
|
for (StyleSheetHandle sheet : agentSheets) {
|
|
nsIURI* uri = sheet->GetSheetURI();
|
|
|
|
if (IsChromeURI(uri)) {
|
|
// Reload the sheet.
|
|
StyleSheetHandle::RefPtr newSheet;
|
|
rv = document->LoadChromeSheetSync(uri, true, &newSheet);
|
|
if (NS_FAILED(rv)) return rv;
|
|
if (newSheet) {
|
|
rv = newAgentSheets.AppendElement(newSheet) ? NS_OK : NS_ERROR_FAILURE;
|
|
if (NS_FAILED(rv)) return rv;
|
|
}
|
|
}
|
|
else { // Just use the same sheet.
|
|
rv = newAgentSheets.AppendElement(sheet) ? NS_OK : NS_ERROR_FAILURE;
|
|
if (NS_FAILED(rv)) return rv;
|
|
}
|
|
}
|
|
|
|
rv = shell->SetAgentStyleSheets(newAgentSheets);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
}
|
|
|
|
int32_t count = document->GetNumberOfStyleSheets();
|
|
|
|
// Build an array of style sheets we need to reload.
|
|
nsTArray<StyleSheetHandle::RefPtr> oldSheets(count);
|
|
nsTArray<StyleSheetHandle::RefPtr> newSheets(count);
|
|
|
|
// Iterate over the style sheets.
|
|
for (int32_t i = 0; i < count; i++) {
|
|
// Get the style sheet
|
|
StyleSheetHandle styleSheet = document->GetStyleSheetAt(i);
|
|
oldSheets.AppendElement(styleSheet);
|
|
}
|
|
|
|
// Iterate over our old sheets and kick off a sync load of the new
|
|
// sheet if and only if it's a non-inline sheet with a chrome URL.
|
|
for (StyleSheetHandle sheet : oldSheets) {
|
|
MOZ_ASSERT(sheet, "GetStyleSheetAt shouldn't return nullptr for "
|
|
"in-range sheet indexes");
|
|
nsIURI* uri = sheet->GetSheetURI();
|
|
|
|
if (!sheet->IsInline() && IsChromeURI(uri)) {
|
|
// Reload the sheet.
|
|
StyleSheetHandle::RefPtr newSheet;
|
|
// XXX what about chrome sheets that have a title or are disabled? This
|
|
// only works by sheer dumb luck.
|
|
document->LoadChromeSheetSync(uri, false, &newSheet);
|
|
// Even if it's null, we put in in there.
|
|
newSheets.AppendElement(newSheet);
|
|
} else {
|
|
// Just use the same sheet.
|
|
newSheets.AppendElement(sheet);
|
|
}
|
|
}
|
|
|
|
// Now notify the document that multiple sheets have been added and removed.
|
|
document->UpdateStyleSheets(oldSheets, newSheets);
|
|
return NS_OK;
|
|
}
|
|
|
|
void
|
|
nsChromeRegistry::FlushAllCaches()
|
|
{
|
|
nsCOMPtr<nsIObserverService> obsSvc =
|
|
mozilla::services::GetObserverService();
|
|
NS_ASSERTION(obsSvc, "Couldn't get observer service.");
|
|
|
|
obsSvc->NotifyObservers((nsIChromeRegistry*) this,
|
|
NS_CHROME_FLUSH_TOPIC, nullptr);
|
|
}
|
|
|
|
// xxxbsmedberg Move me to nsIWindowMediator
|
|
NS_IMETHODIMP
|
|
nsChromeRegistry::ReloadChrome()
|
|
{
|
|
UpdateSelectedLocale();
|
|
FlushAllCaches();
|
|
// Do a reload of all top level windows.
|
|
nsresult rv = NS_OK;
|
|
|
|
// Get the window mediator
|
|
nsCOMPtr<nsIWindowMediator> windowMediator
|
|
(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
|
|
if (windowMediator) {
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
|
|
|
rv = windowMediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator));
|
|
if (NS_SUCCEEDED(rv)) {
|
|
// Get each dom window
|
|
bool more;
|
|
rv = windowEnumerator->HasMoreElements(&more);
|
|
if (NS_FAILED(rv)) return rv;
|
|
while (more) {
|
|
nsCOMPtr<nsISupports> protoWindow;
|
|
rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
|
if (NS_SUCCEEDED(rv)) {
|
|
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(protoWindow);
|
|
if (domWindow) {
|
|
nsCOMPtr<nsIDOMLocation> location;
|
|
domWindow->GetLocation(getter_AddRefs(location));
|
|
if (location) {
|
|
rv = location->Reload(false);
|
|
if (NS_FAILED(rv)) return rv;
|
|
}
|
|
}
|
|
}
|
|
rv = windowEnumerator->HasMoreElements(&more);
|
|
if (NS_FAILED(rv)) return rv;
|
|
}
|
|
}
|
|
}
|
|
return rv;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsChromeRegistry::AllowScriptsForPackage(nsIURI* aChromeURI, bool *aResult)
|
|
{
|
|
nsresult rv;
|
|
*aResult = false;
|
|
|
|
#ifdef DEBUG
|
|
bool isChrome;
|
|
aChromeURI->SchemeIs("chrome", &isChrome);
|
|
NS_ASSERTION(isChrome, "Non-chrome URI passed to AllowScriptsForPackage!");
|
|
#endif
|
|
|
|
nsCOMPtr<nsIURL> url (do_QueryInterface(aChromeURI));
|
|
NS_ENSURE_TRUE(url, NS_NOINTERFACE);
|
|
|
|
nsAutoCString provider, file;
|
|
rv = GetProviderAndPath(url, provider, file);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (!provider.EqualsLiteral("skin"))
|
|
*aResult = true;
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsChromeRegistry::AllowContentToAccess(nsIURI *aURI, bool *aResult)
|
|
{
|
|
nsresult rv;
|
|
|
|
*aResult = false;
|
|
|
|
#ifdef DEBUG
|
|
bool isChrome;
|
|
aURI->SchemeIs("chrome", &isChrome);
|
|
NS_ASSERTION(isChrome, "Non-chrome URI passed to AllowContentToAccess!");
|
|
#endif
|
|
|
|
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
|
if (!url) {
|
|
NS_ERROR("Chrome URL doesn't implement nsIURL.");
|
|
return NS_ERROR_UNEXPECTED;
|
|
}
|
|
|
|
nsAutoCString package;
|
|
rv = url->GetHostPort(package);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
uint32_t flags;
|
|
rv = GetFlagsFromPackage(package, &flags);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
*aResult = !!(flags & CONTENT_ACCESSIBLE);
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsChromeRegistry::CanLoadURLRemotely(nsIURI *aURI, bool *aResult)
|
|
{
|
|
nsresult rv;
|
|
|
|
*aResult = false;
|
|
|
|
#ifdef DEBUG
|
|
bool isChrome;
|
|
aURI->SchemeIs("chrome", &isChrome);
|
|
NS_ASSERTION(isChrome, "Non-chrome URI passed to CanLoadURLRemotely!");
|
|
#endif
|
|
|
|
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
|
if (!url) {
|
|
NS_ERROR("Chrome URL doesn't implement nsIURL.");
|
|
return NS_ERROR_UNEXPECTED;
|
|
}
|
|
|
|
nsAutoCString package;
|
|
rv = url->GetHostPort(package);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
uint32_t flags;
|
|
rv = GetFlagsFromPackage(package, &flags);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
*aResult = !!(flags & REMOTE_ALLOWED);
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsChromeRegistry::MustLoadURLRemotely(nsIURI *aURI, bool *aResult)
|
|
{
|
|
nsresult rv;
|
|
|
|
*aResult = false;
|
|
|
|
#ifdef DEBUG
|
|
bool isChrome;
|
|
aURI->SchemeIs("chrome", &isChrome);
|
|
NS_ASSERTION(isChrome, "Non-chrome URI passed to MustLoadURLRemotely!");
|
|
#endif
|
|
|
|
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
|
if (!url) {
|
|
NS_ERROR("Chrome URL doesn't implement nsIURL.");
|
|
return NS_ERROR_UNEXPECTED;
|
|
}
|
|
|
|
nsAutoCString package;
|
|
rv = url->GetHostPort(package);
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
uint32_t flags;
|
|
rv = GetFlagsFromPackage(package, &flags);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
*aResult = !!(flags & REMOTE_REQUIRED);
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
bool
|
|
nsChromeRegistry::GetDirectionForLocale(const nsACString& aLocale)
|
|
{
|
|
// first check the intl.uidirection.<locale> preference, and if that is not
|
|
// set, check the same preference but with just the first two characters of
|
|
// the locale. If that isn't set, default to left-to-right.
|
|
nsAutoCString prefString = NS_LITERAL_CSTRING("intl.uidirection.") + aLocale;
|
|
nsCOMPtr<nsIPrefBranch> prefBranch (do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
if (!prefBranch) {
|
|
return false;
|
|
}
|
|
|
|
nsXPIDLCString dir;
|
|
prefBranch->GetCharPref(prefString.get(), getter_Copies(dir));
|
|
if (dir.IsEmpty()) {
|
|
int32_t hyphen = prefString.FindChar('-');
|
|
if (hyphen >= 1) {
|
|
nsAutoCString shortPref(Substring(prefString, 0, hyphen));
|
|
prefBranch->GetCharPref(shortPref.get(), getter_Copies(dir));
|
|
}
|
|
}
|
|
|
|
return dir.EqualsLiteral("rtl");
|
|
}
|
|
|
|
NS_IMETHODIMP_(bool)
|
|
nsChromeRegistry::WrappersEnabled(nsIURI *aURI)
|
|
{
|
|
nsCOMPtr<nsIURL> chromeURL (do_QueryInterface(aURI));
|
|
if (!chromeURL)
|
|
return false;
|
|
|
|
bool isChrome = false;
|
|
nsresult rv = chromeURL->SchemeIs("chrome", &isChrome);
|
|
if (NS_FAILED(rv) || !isChrome)
|
|
return false;
|
|
|
|
nsAutoCString package;
|
|
rv = chromeURL->GetHostPort(package);
|
|
if (NS_FAILED(rv))
|
|
return false;
|
|
|
|
uint32_t flags;
|
|
rv = GetFlagsFromPackage(package, &flags);
|
|
return NS_SUCCEEDED(rv) && (flags & XPCNATIVEWRAPPERS);
|
|
}
|
|
|
|
already_AddRefed<nsChromeRegistry>
|
|
nsChromeRegistry::GetSingleton()
|
|
{
|
|
if (gChromeRegistry) {
|
|
RefPtr<nsChromeRegistry> registry = gChromeRegistry;
|
|
return registry.forget();
|
|
}
|
|
|
|
RefPtr<nsChromeRegistry> cr;
|
|
if (GeckoProcessType_Content == XRE_GetProcessType())
|
|
cr = new nsChromeRegistryContent();
|
|
else
|
|
cr = new nsChromeRegistryChrome();
|
|
|
|
if (NS_FAILED(cr->Init()))
|
|
return nullptr;
|
|
|
|
return cr.forget();
|
|
}
|