mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-01 12:57:31 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
9
xpfe/components/autocomplete/jar.mn
Normal file
9
xpfe/components/autocomplete/jar.mn
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# 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/.
|
||||
|
||||
toolkit.jar:
|
||||
content/global/autocomplete.xml (resources/content/autocomplete.xml)
|
||||
|
||||
comm.jar:
|
||||
content/communicator/autocomplete.css (resources/content/autocomplete.css)
|
||||
7
xpfe/components/autocomplete/moz.build
Normal file
7
xpfe/components/autocomplete/moz.build
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/* 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/. */
|
||||
|
||||
|
||||
.autocomplete-result-popupset {
|
||||
width: 0 !important;
|
||||
}
|
||||
|
||||
.autocomplete-result-popup {
|
||||
display: -moz-popup !important;
|
||||
}
|
||||
|
||||
/* the C++ implementation of widgets is too eager to make popups visible.
|
||||
this causes problems (bug 120155 and others), thus this workaround: */
|
||||
.autocomplete-result-popup[hidden="true"] {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.autocomplete-tree {
|
||||
-moz-user-focus: ignore;
|
||||
}
|
||||
|
||||
.autocomplete-history-dropmarker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.autocomplete-history-dropmarker[enablehistory="true"] {
|
||||
display: -moz-box;
|
||||
}
|
||||
|
||||
/* The following rule is here to fix bug 96899 (and now 117952).
|
||||
Somehow trees create a situation
|
||||
in which a popupset flows itself as if its popup child is directly within it
|
||||
instead of the placeholder child that should actually be inside the popupset.
|
||||
This is a stopgap measure, and it does not address the real bug. */
|
||||
popupset {
|
||||
max-width: 0px;
|
||||
width: 0px;
|
||||
min-width: 0%;
|
||||
min-height: 0%;
|
||||
}
|
||||
|
||||
treecolpicker {
|
||||
display: none;
|
||||
}
|
||||
1646
xpfe/components/autocomplete/resources/content/autocomplete.xml
Normal file
1646
xpfe/components/autocomplete/resources/content/autocomplete.xml
Normal file
File diff suppressed because it is too large
Load diff
15
xpfe/components/build/moz.build
Normal file
15
xpfe/components/build/moz.build
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
SOURCES += [
|
||||
'nsModule.cpp',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'../directory',
|
||||
]
|
||||
44
xpfe/components/build/nsModule.cpp
Normal file
44
xpfe/components/build/nsModule.cpp
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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 "mozilla/ModuleUtils.h"
|
||||
#include "nsDirectoryViewer.h"
|
||||
#include "rdf.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsCURILoader.h"
|
||||
|
||||
// Factory constructors
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHTTPIndex, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDirectoryViewerFactory)
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_DIRECTORYVIEWERFACTORY_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_HTTPINDEX_SERVICE_CID);
|
||||
|
||||
static const mozilla::Module::CIDEntry kXPFECIDs[] = {
|
||||
{ &kNS_DIRECTORYVIEWERFACTORY_CID, false, nullptr, nsDirectoryViewerFactoryConstructor },
|
||||
{ &kNS_HTTPINDEX_SERVICE_CID, false, nullptr, nsHTTPIndexConstructor },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
static const mozilla::Module::ContractIDEntry kXPFEContracts[] = {
|
||||
{ "@mozilla.org/xpfe/http-index-format-factory-constructor", &kNS_DIRECTORYVIEWERFACTORY_CID },
|
||||
{ NS_HTTPINDEX_SERVICE_CONTRACTID, &kNS_HTTPINDEX_SERVICE_CID },
|
||||
{ NS_HTTPINDEX_DATASOURCE_CONTRACTID, &kNS_HTTPINDEX_SERVICE_CID },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
static const mozilla::Module::CategoryEntry kXPFECategories[] = {
|
||||
{ "Gecko-Content-Viewers", "application/http-index-format", "@mozilla.org/xpfe/http-index-format-factory-constructor" },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
static const mozilla::Module kXPFEModule = {
|
||||
mozilla::Module::kVersion,
|
||||
kXPFECIDs,
|
||||
kXPFEContracts,
|
||||
kXPFECategories
|
||||
};
|
||||
|
||||
NSMODULE_DEFN(application) = &kXPFEModule;
|
||||
20
xpfe/components/directory/moz.build
Normal file
20
xpfe/components/directory/moz.build
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIHTTPIndex.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'directory'
|
||||
|
||||
SOURCES += [
|
||||
'nsDirectoryViewer.cpp',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
if CONFIG['GNU_CXX']:
|
||||
CXXFLAGS += ['-Wno-error=shadow']
|
||||
1393
xpfe/components/directory/nsDirectoryViewer.cpp
Normal file
1393
xpfe/components/directory/nsDirectoryViewer.cpp
Normal file
File diff suppressed because it is too large
Load diff
126
xpfe/components/directory/nsDirectoryViewer.h
Normal file
126
xpfe/components/directory/nsDirectoryViewer.h
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef nsdirectoryviewer__h____
|
||||
#define nsdirectoryviewer__h____
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIHTTPIndex.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFLiteral.h"
|
||||
#include "nsIDocumentLoaderFactory.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIDirIndexListener.h"
|
||||
#include "nsIFTPChannel.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
class nsIMutableArray;
|
||||
|
||||
class nsDirectoryViewerFactory : public nsIDocumentLoaderFactory
|
||||
{
|
||||
public:
|
||||
nsDirectoryViewerFactory();
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOCUMENTLOADERFACTORY
|
||||
|
||||
protected:
|
||||
virtual ~nsDirectoryViewerFactory();
|
||||
};
|
||||
|
||||
class nsHTTPIndex final : public nsIHTTPIndex,
|
||||
public nsIRDFDataSource,
|
||||
public nsIStreamListener,
|
||||
public nsIDirIndexListener,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIFTPEventSink
|
||||
{
|
||||
private:
|
||||
|
||||
// note: these are NOT statics due to the native of nsHTTPIndex
|
||||
// where it may or may not be treated as a singleton
|
||||
|
||||
nsCOMPtr<nsIRDFResource> kNC_Child;
|
||||
nsCOMPtr<nsIRDFResource> kNC_Comment;
|
||||
nsCOMPtr<nsIRDFResource> kNC_Loading;
|
||||
nsCOMPtr<nsIRDFResource> kNC_URL;
|
||||
nsCOMPtr<nsIRDFResource> kNC_Description;
|
||||
nsCOMPtr<nsIRDFResource> kNC_ContentLength;
|
||||
nsCOMPtr<nsIRDFResource> kNC_LastModified;
|
||||
nsCOMPtr<nsIRDFResource> kNC_ContentType;
|
||||
nsCOMPtr<nsIRDFResource> kNC_FileType;
|
||||
nsCOMPtr<nsIRDFResource> kNC_IsContainer;
|
||||
nsCOMPtr<nsIRDFLiteral> kTrueLiteral;
|
||||
nsCOMPtr<nsIRDFLiteral> kFalseLiteral;
|
||||
|
||||
nsCOMPtr<nsIRDFService> mDirRDF;
|
||||
|
||||
protected:
|
||||
// We grab a reference to the content viewer container (which
|
||||
// indirectly owns us) so that we can insert ourselves as a global
|
||||
// in the script context _after_ the XUL doc has been embedded into
|
||||
// content viewer. We'll know that this has happened once we receive
|
||||
// an OnStartRequest() notification
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> mInner;
|
||||
nsCOMPtr<nsIMutableArray> mConnectionList;
|
||||
nsCOMPtr<nsIMutableArray> mNodeList;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
nsCOMPtr<nsIDirIndexParser> mParser;
|
||||
nsCString mBaseURL;
|
||||
nsCString mEncoding;
|
||||
bool mBindToGlobalObject;
|
||||
nsIInterfaceRequestor* mRequestor; // WEAK
|
||||
nsCOMPtr<nsIRDFResource> mDirectory;
|
||||
|
||||
explicit nsHTTPIndex(nsIInterfaceRequestor* aRequestor);
|
||||
nsresult CommonInit(void);
|
||||
nsresult Init(nsIURI* aBaseURL);
|
||||
void GetDestination(nsIRDFResource* r, nsXPIDLCString& dest);
|
||||
bool isWellknownContainerURI(nsIRDFResource *r);
|
||||
nsresult AddElement(nsIRDFResource *parent, nsIRDFResource *prop,
|
||||
nsIRDFNode *child);
|
||||
|
||||
static void FireTimer(nsITimer* aTimer, void* aClosure);
|
||||
|
||||
virtual ~nsHTTPIndex();
|
||||
|
||||
public:
|
||||
nsHTTPIndex();
|
||||
nsresult Init(void);
|
||||
|
||||
static nsresult Create(nsIURI* aBaseURI, nsIInterfaceRequestor* aContainer,
|
||||
nsIHTTPIndex** aResult);
|
||||
|
||||
// nsIHTTPIndex interface
|
||||
NS_DECL_NSIHTTPINDEX
|
||||
|
||||
// NSIRDFDataSource interface
|
||||
NS_DECL_NSIRDFDATASOURCE
|
||||
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
||||
NS_DECL_NSIDIRINDEXLISTENER
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSIFTPEVENTSINK
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHTTPIndex, nsIHTTPIndex)
|
||||
};
|
||||
|
||||
// {82776710-5690-11d3-BE36-00104BDE6048}
|
||||
#define NS_DIRECTORYVIEWERFACTORY_CID \
|
||||
{ 0x82776710, 0x5690, 0x11d3, { 0xbe, 0x36, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
#endif // nsdirectoryviewer__h____
|
||||
50
xpfe/components/directory/nsIHTTPIndex.idl
Normal file
50
xpfe/components/directory/nsIHTTPIndex.idl
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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/. */
|
||||
|
||||
/*
|
||||
|
||||
The interface to an HTTP index
|
||||
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIStreamListener;
|
||||
interface nsIRDFDataSource;
|
||||
interface nsIRDFNode;
|
||||
interface nsIRDFResource;
|
||||
|
||||
[scriptable, uuid(6F2BDBD0-58C3-11d3-BE36-00104BDE6048)]
|
||||
interface nsIHTTPIndex : nsISupports
|
||||
{
|
||||
/**
|
||||
* The base URL of the HTTP index
|
||||
*/
|
||||
readonly attribute string BaseURL;
|
||||
|
||||
/**
|
||||
* The RDF datasource that contains the HTTP index information.
|
||||
*/
|
||||
readonly attribute nsIRDFDataSource DataSource;
|
||||
|
||||
/**
|
||||
* The charset to use for decoding FTP filenames
|
||||
*/
|
||||
attribute string encoding;
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
||||
// {{2587e382-1324-11d4-a652-eadbb2be3484}
|
||||
#define NS_HTTPINDEX_SERVICE_CID \
|
||||
{ 0x2587e382, 0x1324, 0x11d4, { 0xa6, 0x52, 0xea, 0xdb, 0xb2, 0xbe, 0x34, 0x84 } }
|
||||
|
||||
#define NS_HTTPINDEX_SERVICE_CONTRACTID \
|
||||
"@mozilla.org/browser/httpindex-service;1"
|
||||
|
||||
#define NS_HTTPINDEX_DATASOURCE_CONTRACTID \
|
||||
"@mozilla.org/rdf/datasource;1?name=httpindex"
|
||||
|
||||
%}
|
||||
12
xpfe/components/moz.build
Normal file
12
xpfe/components/moz.build
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
DIRS += [
|
||||
'windowds',
|
||||
'directory',
|
||||
'build',
|
||||
]
|
||||
|
||||
17
xpfe/components/windowds/moz.build
Normal file
17
xpfe/components/windowds/moz.build
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIWindowDataSource.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'windowds'
|
||||
|
||||
SOURCES += [
|
||||
'nsWindowDataSource.cpp',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
17
xpfe/components/windowds/nsIWindowDataSource.idl
Normal file
17
xpfe/components/windowds/nsIWindowDataSource.idl
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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 "nsISupports.idl"
|
||||
#include "nsIDOMWindow.idl"
|
||||
|
||||
// interface for accessing RDF-specific data from the window datasource
|
||||
[scriptable, uuid(3722A5B9-5323-4ed0-BB1A-8299F27A4E89)]
|
||||
interface nsIWindowDataSource : nsISupports
|
||||
{
|
||||
/**
|
||||
* for the given resource name, return the window
|
||||
*/
|
||||
nsIDOMWindow getWindowForResource(in string inResource);
|
||||
};
|
||||
519
xpfe/components/windowds/nsWindowDataSource.cpp
Normal file
519
xpfe/components/windowds/nsWindowDataSource.cpp
Normal file
|
|
@ -0,0 +1,519 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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 "nsWindowDataSource.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "rdf.h"
|
||||
#include "nsIRDFContainerUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsXPCOMCID.h"
|
||||
#include "mozilla/ModuleUtils.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// just to do the reverse-lookup! sheesh.
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
||||
uint32_t nsWindowDataSource::windowCount = 0;
|
||||
|
||||
nsIRDFResource* nsWindowDataSource::kNC_Name = nullptr;
|
||||
nsIRDFResource* nsWindowDataSource::kNC_WindowRoot = nullptr;
|
||||
nsIRDFResource* nsWindowDataSource::kNC_KeyIndex = nullptr;
|
||||
|
||||
nsIRDFService* nsWindowDataSource::gRDFService = nullptr;
|
||||
|
||||
uint32_t nsWindowDataSource::gRefCnt = 0;
|
||||
|
||||
#define URINC_WINDOWROOT "NC:WindowMediatorRoot"
|
||||
#define URINC_NAME NC_NAMESPACE_URI "Name"
|
||||
#define URINC_KEYINDEX NC_NAMESPACE_URI "KeyIndex"
|
||||
|
||||
nsresult
|
||||
nsWindowDataSource::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (gRefCnt++ == 0) {
|
||||
rv = CallGetService("@mozilla.org/rdf/rdf-service;1", &gRDFService);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
gRDFService->GetResource(NS_LITERAL_CSTRING(URINC_WINDOWROOT), &kNC_WindowRoot);
|
||||
gRDFService->GetResource(NS_LITERAL_CSTRING(URINC_NAME), &kNC_Name);
|
||||
gRDFService->GetResource(NS_LITERAL_CSTRING(URINC_KEYINDEX), &kNC_KeyIndex);
|
||||
}
|
||||
|
||||
mInner = do_CreateInstance("@mozilla.org/rdf/datasource;1?name=in-memory-datasource", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFContainerUtils> rdfc =
|
||||
do_GetService("@mozilla.org/rdf/container-utils;1", &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = rdfc->MakeSeq(this, kNC_WindowRoot, getter_AddRefs(mContainer));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIWindowMediator> windowMediator =
|
||||
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = windowMediator->AddListener(this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
|
||||
false);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsWindowDataSource::~nsWindowDataSource()
|
||||
{
|
||||
if (--gRefCnt == 0) {
|
||||
NS_IF_RELEASE(kNC_Name);
|
||||
NS_IF_RELEASE(kNC_KeyIndex);
|
||||
NS_IF_RELEASE(kNC_WindowRoot);
|
||||
NS_IF_RELEASE(gRDFService);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowDataSource::Observe(nsISupports *aSubject, const char* aTopic, const char16_t *aData)
|
||||
{
|
||||
if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
|
||||
// release these objects so that they release their reference
|
||||
// to us
|
||||
mContainer = nullptr;
|
||||
mInner = nullptr;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(nsWindowDataSource)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_0(nsWindowDataSource)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsWindowDataSource)
|
||||
// XXX mContainer?
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInner)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsWindowDataSource)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsWindowDataSource)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsWindowDataSource)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWindowMediatorListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWindowDataSource)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
// nsIWindowMediatorListener implementation
|
||||
// handle notifications from the window mediator and reflect them into
|
||||
// RDF
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowDataSource::OnWindowTitleChange(nsIXULWindow *window,
|
||||
const char16_t *newTitle)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> windowResource;
|
||||
mWindowResources.Get(window, getter_AddRefs(windowResource));
|
||||
|
||||
// oops, make sure this window is in the hashtable!
|
||||
if (!windowResource) {
|
||||
OnOpenWindow(window);
|
||||
mWindowResources.Get(window, getter_AddRefs(windowResource));
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(windowResource, NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIRDFLiteral> newTitleLiteral;
|
||||
rv = gRDFService->GetLiteral(newTitle, getter_AddRefs(newTitleLiteral));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// get the old title
|
||||
nsCOMPtr<nsIRDFNode> oldTitleNode;
|
||||
rv = GetTarget(windowResource, kNC_Name, true,
|
||||
getter_AddRefs(oldTitleNode));
|
||||
|
||||
// assert the change
|
||||
if (NS_SUCCEEDED(rv) && oldTitleNode)
|
||||
// has an existing window title, update it
|
||||
rv = Change(windowResource, kNC_Name, oldTitleNode, newTitleLiteral);
|
||||
else
|
||||
// removed from the tasklist
|
||||
rv = Assert(windowResource, kNC_Name, newTitleLiteral, true);
|
||||
|
||||
if (rv != NS_RDF_ASSERTION_ACCEPTED)
|
||||
{
|
||||
NS_ERROR("unable to set window name");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowDataSource::OnOpenWindow(nsIXULWindow *window)
|
||||
{
|
||||
nsAutoCString windowId(NS_LITERAL_CSTRING("window-"));
|
||||
windowId.AppendInt(windowCount++, 10);
|
||||
|
||||
nsCOMPtr<nsIRDFResource> windowResource;
|
||||
gRDFService->GetResource(windowId, getter_AddRefs(windowResource));
|
||||
|
||||
mWindowResources.Put(window, windowResource);
|
||||
|
||||
// assert the new window
|
||||
if (mContainer)
|
||||
mContainer->AppendElement(windowResource);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowDataSource::OnCloseWindow(nsIXULWindow *window)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
mWindowResources.Get(window, getter_AddRefs(resource));
|
||||
if (!resource) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
mWindowResources.Remove(window);
|
||||
|
||||
// make sure we're not shutting down
|
||||
if (!mContainer) return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIRDFNode> oldKeyNode;
|
||||
nsCOMPtr<nsIRDFInt> oldKeyInt;
|
||||
|
||||
// get the old keyIndex, if any
|
||||
rv = GetTarget(resource, kNC_KeyIndex, true,
|
||||
getter_AddRefs(oldKeyNode));
|
||||
if (NS_SUCCEEDED(rv) && (rv != NS_RDF_NO_VALUE))
|
||||
oldKeyInt = do_QueryInterface(oldKeyNode);
|
||||
|
||||
|
||||
// update RDF and keyindex - from this point forward we'll ignore
|
||||
// errors, because they just indicate some kind of RDF inconsistency
|
||||
int32_t winIndex = -1;
|
||||
rv = mContainer->IndexOf(resource, &winIndex);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
// unassert the old window, ignore any error
|
||||
mContainer->RemoveElement(resource, true);
|
||||
|
||||
nsCOMPtr<nsISimpleEnumerator> children;
|
||||
rv = mContainer->GetElements(getter_AddRefs(children));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
bool more = false;
|
||||
|
||||
while (NS_SUCCEEDED(rv = children->HasMoreElements(&more)) && more) {
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
rv = children->GetNext(getter_AddRefs(sup));
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsIRDFResource> windowResource = do_QueryInterface(sup, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
int32_t currentIndex = -1;
|
||||
mContainer->IndexOf(windowResource, ¤tIndex);
|
||||
|
||||
// can skip updating windows with lower indexes
|
||||
// than the window that was removed
|
||||
if (currentIndex < winIndex)
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIRDFNode> newKeyNode;
|
||||
nsCOMPtr<nsIRDFInt> newKeyInt;
|
||||
|
||||
rv = GetTarget(windowResource, kNC_KeyIndex, true,
|
||||
getter_AddRefs(newKeyNode));
|
||||
if (NS_SUCCEEDED(rv) && (rv != NS_RDF_NO_VALUE))
|
||||
newKeyInt = do_QueryInterface(newKeyNode);
|
||||
|
||||
// changing from one key index to another
|
||||
if (oldKeyInt && newKeyInt)
|
||||
Change(windowResource, kNC_KeyIndex, oldKeyInt, newKeyInt);
|
||||
// creating a new keyindex - probably window going
|
||||
// from (none) to "9"
|
||||
else if (newKeyInt)
|
||||
Assert(windowResource, kNC_KeyIndex, newKeyInt, true);
|
||||
|
||||
// somehow inserting a window above this one,
|
||||
// "9" to (none)
|
||||
else if (oldKeyInt)
|
||||
Unassert(windowResource, kNC_KeyIndex, oldKeyInt);
|
||||
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIWindowDataSource implementation
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowDataSource::GetWindowForResource(const char *aResourceString,
|
||||
nsIDOMWindow** aResult)
|
||||
{
|
||||
if (NS_WARN_IF(!aResourceString)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRDFResource> windowResource;
|
||||
gRDFService->GetResource(nsDependentCString(aResourceString),
|
||||
getter_AddRefs(windowResource));
|
||||
|
||||
// now reverse-lookup in the hashtable
|
||||
for (auto iter = mWindowResources.Iter(); !iter.Done(); iter.Next()) {
|
||||
nsIXULWindow* window = iter.Key();
|
||||
nsIRDFResource* resource = iter.UserData();
|
||||
|
||||
if (resource == windowResource) {
|
||||
// This sucks, we have to jump through docshell to go from
|
||||
// nsIXULWindow -> nsIDOMWindow.
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
window->GetDocShell(getter_AddRefs(docShell));
|
||||
|
||||
if (docShell) {
|
||||
nsCOMPtr<nsIDOMWindow> result = do_GetInterface(docShell);
|
||||
|
||||
*aResult = result;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// nsIRDFDataSource implementation
|
||||
// mostly, we just forward to mInner, except:
|
||||
// GetURI() - need to return "rdf:window-mediator"
|
||||
// GetTarget() - need to handle kNC_KeyIndex
|
||||
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::GetURI(char * *aURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
|
||||
*aURI = ToNewCString(NS_LITERAL_CSTRING("rdf:window-mediator"));
|
||||
|
||||
if (!*aURI)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::GetTarget(nsIRDFResource *aSource, nsIRDFResource *aProperty, bool aTruthValue, nsIRDFNode **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
// add extra nullptr checking for top-crash bug # 146466
|
||||
if (!gRDFService) return NS_RDF_NO_VALUE;
|
||||
if (!mInner) return NS_RDF_NO_VALUE;
|
||||
if (!mContainer) return NS_RDF_NO_VALUE;
|
||||
// special case kNC_KeyIndex before we forward to mInner
|
||||
if (aProperty == kNC_KeyIndex) {
|
||||
|
||||
int32_t theIndex = 0;
|
||||
nsresult rv = mContainer->IndexOf(aSource, &theIndex);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// only allow the range of 1 to 9 for single key access
|
||||
if (theIndex < 1 || theIndex > 9) return(NS_RDF_NO_VALUE);
|
||||
|
||||
nsCOMPtr<nsIRDFInt> indexInt;
|
||||
rv = gRDFService->GetIntLiteral(theIndex, getter_AddRefs(indexInt));
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
if (!indexInt) return(NS_ERROR_FAILURE);
|
||||
|
||||
indexInt.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return mInner->GetTarget(aSource, aProperty, aTruthValue, _retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::GetSource(nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue, nsIRDFResource **_retval)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->GetSource(aProperty, aTarget, aTruthValue, _retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::GetSources(nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->GetSources(aProperty, aTarget, aTruthValue, _retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, bool aTruthValue, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->GetTargets(aSource, aProperty, aTruthValue, _retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::Assert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->Assert(aSource, aProperty, aTarget, aTruthValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::Unassert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->Unassert(aSource, aProperty, aTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::Change(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aOldTarget, nsIRDFNode *aNewTarget)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->Change(aSource, aProperty, aOldTarget, aNewTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::Move(nsIRDFResource *aOldSource, nsIRDFResource *aNewSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->Move(aOldSource, aNewSource, aProperty, aTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue, bool *_retval)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->HasAssertion(aSource, aProperty, aTarget, aTruthValue, _retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::AddObserver(nsIRDFObserver *aObserver)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->AddObserver(aObserver);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::RemoveObserver(nsIRDFObserver *aObserver)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->RemoveObserver(aObserver);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->ArcLabelsIn(aNode, _retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::ArcLabelsOut(nsIRDFResource *aSource, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->ArcLabelsOut(aSource, _retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::GetAllResources(nsISimpleEnumerator **_retval)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->GetAllResources(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::IsCommandEnabled(nsISupports *aSources, nsIRDFResource *aCommand, nsISupports *aArguments, bool *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::DoCommand(nsISupports *aSources, nsIRDFResource *aCommand, nsISupports *aArguments)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::GetAllCmds(nsIRDFResource *aSource, nsISimpleEnumerator **_retval)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->GetAllCmds(aSource, _retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, bool *_retval)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->HasArcIn(aNode, aArc, _retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, bool *_retval)
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->HasArcOut(aSource, aArc, _retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::BeginUpdateBatch()
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->BeginUpdateBatch();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowDataSource::EndUpdateBatch()
|
||||
{
|
||||
if (mInner)
|
||||
return mInner->EndUpdateBatch();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// The module goop
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWindowDataSource, Init)
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_WINDOWDATASOURCE_CID);
|
||||
|
||||
static const mozilla::Module::CIDEntry kWindowDSCIDs[] = {
|
||||
{ &kNS_WINDOWDATASOURCE_CID, false, nullptr, nsWindowDataSourceConstructor },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
static const mozilla::Module::ContractIDEntry kWindowDSContracts[] = {
|
||||
{ NS_RDF_DATASOURCE_CONTRACTID_PREFIX "window-mediator", &kNS_WINDOWDATASOURCE_CID },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
static const mozilla::Module::CategoryEntry kWindowDSCategories[] = {
|
||||
{ "app-startup", "Window Data Source", "service," NS_RDF_DATASOURCE_CONTRACTID_PREFIX "window-mediator" },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
static const mozilla::Module kWindowDSModule = {
|
||||
mozilla::Module::kVersion,
|
||||
kWindowDSCIDs,
|
||||
kWindowDSContracts,
|
||||
kWindowDSCategories
|
||||
};
|
||||
|
||||
NSMODULE_DEFN(nsWindowDataSourceModule) = &kWindowDSModule;
|
||||
59
xpfe/components/windowds/nsWindowDataSource.h
Normal file
59
xpfe/components/windowds/nsWindowDataSource.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* 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 "nsIRDFDataSource.h"
|
||||
#include "nsIWindowMediatorListener.h"
|
||||
#include "nsIWindowDataSource.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFContainer.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
// {C744CA3D-840B-460a-8D70-7CE63C51C958}
|
||||
#define NS_WINDOWDATASOURCE_CID \
|
||||
{ 0xc744ca3d, 0x840b, 0x460a, \
|
||||
{ 0x8d, 0x70, 0x7c, 0xe6, 0x3c, 0x51, 0xc9, 0x58 } }
|
||||
|
||||
|
||||
class nsWindowDataSource final : public nsIRDFDataSource,
|
||||
public nsIObserver,
|
||||
public nsIWindowMediatorListener,
|
||||
public nsIWindowDataSource
|
||||
{
|
||||
public:
|
||||
nsWindowDataSource() { }
|
||||
|
||||
nsresult Init();
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsWindowDataSource,
|
||||
nsIRDFDataSource)
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIWINDOWMEDIATORLISTENER
|
||||
NS_DECL_NSIWINDOWDATASOURCE
|
||||
NS_DECL_NSIRDFDATASOURCE
|
||||
|
||||
protected:
|
||||
virtual ~nsWindowDataSource();
|
||||
|
||||
private:
|
||||
|
||||
// mapping of window -> RDF resource
|
||||
nsInterfaceHashtable<nsPtrHashKey<nsIXULWindow>, nsIRDFResource> mWindowResources;
|
||||
|
||||
static uint32_t windowCount;
|
||||
static uint32_t gRefCnt;
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> mInner;
|
||||
nsCOMPtr<nsIRDFContainer> mContainer;
|
||||
|
||||
static nsIRDFResource* kNC_Name;
|
||||
static nsIRDFResource* kNC_KeyIndex;
|
||||
static nsIRDFResource* kNC_WindowRoot;
|
||||
static nsIRDFService* gRDFService;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue