mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-02 21:37:32 +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
14
embedding/browser/build/moz.build
Normal file
14
embedding/browser/build/moz.build
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# -*- 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 += [
|
||||
'nsWebBrowserModule.cpp',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
LOCAL_INCLUDES += [
|
||||
'..',
|
||||
]
|
||||
53
embedding/browser/build/nsWebBrowserModule.cpp
Normal file
53
embedding/browser/build/nsWebBrowserModule.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 "nsIServiceManager.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsEmbedCID.h"
|
||||
|
||||
#include "nsWebBrowser.h"
|
||||
#include "nsCommandHandler.h"
|
||||
#include "nsWebBrowserContentPolicy.h"
|
||||
|
||||
// Factory Constructors
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowser)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowserContentPolicy)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCommandHandler)
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_WEBBROWSER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_COMMANDHANDLER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_WEBBROWSERCONTENTPOLICY_CID);
|
||||
|
||||
static const mozilla::Module::CIDEntry kWebBrowserCIDs[] = {
|
||||
{ &kNS_WEBBROWSER_CID, false, nullptr, nsWebBrowserConstructor },
|
||||
{ &kNS_COMMANDHANDLER_CID, false, nullptr, nsCommandHandlerConstructor },
|
||||
{ &kNS_WEBBROWSERCONTENTPOLICY_CID, false, nullptr, nsWebBrowserContentPolicyConstructor },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
static const mozilla::Module::ContractIDEntry kWebBrowserContracts[] = {
|
||||
{ NS_WEBBROWSER_CONTRACTID, &kNS_WEBBROWSER_CID },
|
||||
{ NS_COMMANDHANDLER_CONTRACTID, &kNS_COMMANDHANDLER_CID },
|
||||
{ NS_WEBBROWSERCONTENTPOLICY_CONTRACTID, &kNS_WEBBROWSERCONTENTPOLICY_CID },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
static const mozilla::Module::CategoryEntry kWebBrowserCategories[] = {
|
||||
{ "content-policy", NS_WEBBROWSERCONTENTPOLICY_CONTRACTID, NS_WEBBROWSERCONTENTPOLICY_CONTRACTID },
|
||||
{ nullptr }
|
||||
};
|
||||
|
||||
static const mozilla::Module kWebBrowserModule = {
|
||||
mozilla::Module::kVersion,
|
||||
kWebBrowserCIDs,
|
||||
kWebBrowserContracts,
|
||||
kWebBrowserCategories
|
||||
};
|
||||
|
||||
NSMODULE_DEFN(Browser_Embedding_Module) = &kWebBrowserModule;
|
||||
57
embedding/browser/moz.build
Normal file
57
embedding/browser/moz.build
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# -*- 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 += ['build']
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsCWebBrowser.idl',
|
||||
'nsICommandHandler.idl',
|
||||
'nsIContextMenuListener.idl',
|
||||
'nsIContextMenuListener2.idl',
|
||||
'nsIEmbeddingSiteWindow.idl',
|
||||
'nsITooltipListener.idl',
|
||||
'nsITooltipTextProvider.idl',
|
||||
'nsIWebBrowser.idl',
|
||||
'nsIWebBrowserChrome.idl',
|
||||
'nsIWebBrowserChrome2.idl',
|
||||
'nsIWebBrowserChrome3.idl',
|
||||
'nsIWebBrowserChromeFocus.idl',
|
||||
'nsIWebBrowserFocus.idl',
|
||||
'nsIWebBrowserSetup.idl',
|
||||
'nsIWebBrowserStream.idl',
|
||||
]
|
||||
|
||||
if CONFIG['NS_PRINTING']:
|
||||
XPIDL_SOURCES += [
|
||||
'nsIPrintingPromptService.idl',
|
||||
'nsIWebBrowserPrint.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'webBrowser_core'
|
||||
|
||||
EXPORTS += [
|
||||
'nsCTooltipTextProvider.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'nsCommandHandler.cpp',
|
||||
'nsContextMenuInfo.cpp',
|
||||
'nsDocShellTreeOwner.cpp',
|
||||
'nsEmbedStream.cpp',
|
||||
'nsWebBrowser.cpp',
|
||||
'nsWebBrowserContentPolicy.cpp',
|
||||
]
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
LOCAL_INCLUDES += [
|
||||
'/docshell/base',
|
||||
'/dom/base',
|
||||
'/dom/svg',
|
||||
'/layout/style',
|
||||
]
|
||||
|
||||
if CONFIG['GNU_CXX']:
|
||||
CXXFLAGS += ['-Wno-error=shadow']
|
||||
17
embedding/browser/nsCTooltipTextProvider.h
Normal file
17
embedding/browser/nsCTooltipTextProvider.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 NSCTOOLTIPTEXTPROVIDER_H
|
||||
#define NSCTOOLTIPTEXTPROVIDER_H
|
||||
|
||||
#include "nsITooltipTextProvider.h"
|
||||
|
||||
#define NS_TOOLTIPTEXTPROVIDER_CONTRACTID \
|
||||
"@mozilla.org/embedcomp/tooltiptextprovider;1"
|
||||
#define NS_DEFAULTTOOLTIPTEXTPROVIDER_CONTRACTID \
|
||||
"@mozilla.org/embedcomp/default-tooltiptextprovider;1"
|
||||
|
||||
#endif
|
||||
34
embedding/browser/nsCWebBrowser.idl
Normal file
34
embedding/browser/nsCWebBrowser.idl
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; 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 "nsIWebBrowser.idl"
|
||||
#include "nsIBaseWindow.idl"
|
||||
#include "nsIScrollable.idl"
|
||||
#include "nsITextScroll.idl"
|
||||
|
||||
/*
|
||||
nsCWebBrowser implements:
|
||||
-------------------------
|
||||
nsIWebBrowser
|
||||
nsIDocShellTreeItem
|
||||
nsIWebNavigation
|
||||
nsIWebProgress
|
||||
nsIBaseWindow
|
||||
nsIScrollable
|
||||
nsITextScroll
|
||||
nsIInterfaceRequestor
|
||||
|
||||
|
||||
Outwardly communicates with:
|
||||
----------------------------
|
||||
nsIWebBrowserChrome
|
||||
nsIBaseWindow
|
||||
nsIInterfaceRequestor
|
||||
*/
|
||||
|
||||
%{ C++
|
||||
#include "nsEmbedCID.h"
|
||||
%}
|
||||
139
embedding/browser/nsCommandHandler.cpp
Normal file
139
embedding/browser/nsCommandHandler.cpp
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 "nsCommandHandler.h"
|
||||
#include "nsWebBrowser.h"
|
||||
#include "nsDocShellTreeOwner.h"
|
||||
|
||||
#include "nsMemory.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
nsCommandHandler::nsCommandHandler()
|
||||
: mWindow(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
nsCommandHandler::~nsCommandHandler()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCommandHandler::GetCommandHandler(nsICommandHandler** aCommandHandler)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommandHandler);
|
||||
|
||||
*aCommandHandler = nullptr;
|
||||
if (!mWindow) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Get the document tree owner
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsTreeItem =
|
||||
do_QueryInterface(mWindow->GetDocShell());
|
||||
nsIDocShellTreeOwner* treeOwner = nullptr;
|
||||
docShellAsTreeItem->GetTreeOwner(&treeOwner);
|
||||
|
||||
// Make sure the tree owner is an an nsDocShellTreeOwner object
|
||||
// by QI'ing for a hidden interface. If it doesn't have the interface
|
||||
// then it's not safe to do the casting.
|
||||
|
||||
nsCOMPtr<nsICDocShellTreeOwner> realTreeOwner(do_QueryInterface(treeOwner));
|
||||
if (realTreeOwner) {
|
||||
nsDocShellTreeOwner* tree = static_cast<nsDocShellTreeOwner*>(treeOwner);
|
||||
if (tree->mTreeOwner) {
|
||||
nsresult rv;
|
||||
rv = tree->mTreeOwner->QueryInterface(NS_GET_IID(nsICommandHandler),
|
||||
(void**)aCommandHandler);
|
||||
NS_RELEASE(treeOwner);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_RELEASE(treeOwner);
|
||||
}
|
||||
|
||||
*aCommandHandler = nullptr;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsCommandHandler)
|
||||
NS_IMPL_RELEASE(nsCommandHandler)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsCommandHandler)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsICommandHandler)
|
||||
NS_INTERFACE_MAP_ENTRY(nsICommandHandlerInit)
|
||||
NS_INTERFACE_MAP_ENTRY(nsICommandHandler)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsICommandHandlerInit implementation
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommandHandler::GetWindow(mozIDOMWindowProxy** aWindow)
|
||||
{
|
||||
*aWindow = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommandHandler::SetWindow(mozIDOMWindowProxy* aWindow)
|
||||
{
|
||||
if (!aWindow) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mWindow = nsPIDOMWindowOuter::From(aWindow);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsICommandHandler implementation
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommandHandler::Exec(const char* aCommand, const char* aStatus,
|
||||
char** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommand);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
nsCOMPtr<nsICommandHandler> commandHandler;
|
||||
GetCommandHandler(getter_AddRefs(commandHandler));
|
||||
|
||||
// Call the client's command handler to deal with this command
|
||||
if (commandHandler) {
|
||||
*aResult = nullptr;
|
||||
return commandHandler->Exec(aCommand, aStatus, aResult);
|
||||
}
|
||||
|
||||
// Return an empty string
|
||||
const char szEmpty[] = "";
|
||||
*aResult = (char*)nsMemory::Clone(szEmpty, sizeof(szEmpty));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCommandHandler::Query(const char* aCommand, const char* aStatus,
|
||||
char** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCommand);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
nsCOMPtr<nsICommandHandler> commandHandler;
|
||||
GetCommandHandler(getter_AddRefs(commandHandler));
|
||||
|
||||
// Call the client's command handler to deal with this command
|
||||
if (commandHandler) {
|
||||
*aResult = nullptr;
|
||||
return commandHandler->Query(aCommand, aStatus, aResult);
|
||||
}
|
||||
|
||||
// Return an empty string
|
||||
const char szEmpty[] = "";
|
||||
*aResult = (char*)nsMemory::Clone(szEmpty, sizeof(szEmpty));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
35
embedding/browser/nsCommandHandler.h
Normal file
35
embedding/browser/nsCommandHandler.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 NSCOMMANDHANDLER_H
|
||||
#define NSCOMMANDHANDLER_H
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsICommandHandler.h"
|
||||
|
||||
class nsPIDOMWindowOuter;
|
||||
|
||||
class nsCommandHandler
|
||||
: public nsICommandHandlerInit
|
||||
, public nsICommandHandler
|
||||
{
|
||||
public:
|
||||
nsCommandHandler();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICOMMANDHANDLERINIT
|
||||
NS_DECL_NSICOMMANDHANDLER
|
||||
|
||||
protected:
|
||||
virtual ~nsCommandHandler();
|
||||
|
||||
private:
|
||||
nsresult GetCommandHandler(nsICommandHandler** aCommandHandler);
|
||||
|
||||
nsPIDOMWindowOuter* mWindow;
|
||||
};
|
||||
|
||||
#endif
|
||||
326
embedding/browser/nsContextMenuInfo.cpp
Normal file
326
embedding/browser/nsContextMenuInfo.cpp
Normal file
|
|
@ -0,0 +1,326 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 "nsContextMenuInfo.h"
|
||||
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "imgLoader.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIDOMHTMLHtmlElement.h"
|
||||
#include "nsIDOMHTMLAnchorElement.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsIDOMHTMLAreaElement.h"
|
||||
#include "nsIDOMHTMLLinkElement.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsICSSDeclaration.h"
|
||||
#include "nsIDOMCSSValue.h"
|
||||
#include "nsIDOMCSSPrimitiveValue.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "imgRequestProxy.h"
|
||||
|
||||
using mozilla::dom::Element;
|
||||
using mozilla::ErrorResult;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsContextMenuInfo, nsIContextMenuInfo)
|
||||
|
||||
nsContextMenuInfo::nsContextMenuInfo()
|
||||
{
|
||||
}
|
||||
|
||||
nsContextMenuInfo::~nsContextMenuInfo()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContextMenuInfo::GetMouseEvent(nsIDOMEvent** aEvent)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aEvent);
|
||||
NS_IF_ADDREF(*aEvent = mMouseEvent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContextMenuInfo::GetTargetNode(nsIDOMNode** aNode)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNode);
|
||||
NS_IF_ADDREF(*aNode = mDOMNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContextMenuInfo::GetAssociatedLink(nsAString& aHRef)
|
||||
{
|
||||
NS_ENSURE_STATE(mAssociatedLink);
|
||||
aHRef.Truncate(0);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> content(do_QueryInterface(mAssociatedLink));
|
||||
nsAutoString localName;
|
||||
if (content) {
|
||||
content->GetLocalName(localName);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMElement> linkContent;
|
||||
ToLowerCase(localName);
|
||||
if (localName.EqualsLiteral("a") ||
|
||||
localName.EqualsLiteral("area") ||
|
||||
localName.EqualsLiteral("link")) {
|
||||
bool hasAttr;
|
||||
content->HasAttribute(NS_LITERAL_STRING("href"), &hasAttr);
|
||||
if (hasAttr) {
|
||||
linkContent = content;
|
||||
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(do_QueryInterface(linkContent));
|
||||
if (anchor) {
|
||||
anchor->GetHref(aHRef);
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMHTMLAreaElement> area(do_QueryInterface(linkContent));
|
||||
if (area) {
|
||||
area->GetHref(aHRef);
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMHTMLLinkElement> link(do_QueryInterface(linkContent));
|
||||
if (link) {
|
||||
link->GetHref(aHRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsIDOMNode> curr;
|
||||
mAssociatedLink->GetParentNode(getter_AddRefs(curr));
|
||||
while (curr) {
|
||||
content = do_QueryInterface(curr);
|
||||
if (!content) {
|
||||
break;
|
||||
}
|
||||
content->GetLocalName(localName);
|
||||
ToLowerCase(localName);
|
||||
if (localName.EqualsLiteral("a")) {
|
||||
bool hasAttr;
|
||||
content->HasAttribute(NS_LITERAL_STRING("href"), &hasAttr);
|
||||
if (hasAttr) {
|
||||
linkContent = content;
|
||||
nsCOMPtr<nsIDOMHTMLAnchorElement> anchor(
|
||||
do_QueryInterface(linkContent));
|
||||
if (anchor) {
|
||||
anchor->GetHref(aHRef);
|
||||
}
|
||||
} else {
|
||||
linkContent = nullptr; // Links can't be nested.
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> temp = curr;
|
||||
temp->GetParentNode(getter_AddRefs(curr));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContextMenuInfo::GetImageContainer(imgIContainer** aImageContainer)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aImageContainer);
|
||||
NS_ENSURE_STATE(mDOMNode);
|
||||
|
||||
nsCOMPtr<imgIRequest> request;
|
||||
GetImageRequest(mDOMNode, getter_AddRefs(request));
|
||||
if (request) {
|
||||
return request->GetImage(aImageContainer);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContextMenuInfo::GetImageSrc(nsIURI** aURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
NS_ENSURE_STATE(mDOMNode);
|
||||
|
||||
nsCOMPtr<nsIImageLoadingContent> content(do_QueryInterface(mDOMNode));
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
|
||||
return content->GetCurrentURI(aURI);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContextMenuInfo::GetBackgroundImageContainer(imgIContainer** aImageContainer)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aImageContainer);
|
||||
NS_ENSURE_STATE(mDOMNode);
|
||||
|
||||
RefPtr<imgRequestProxy> request;
|
||||
GetBackgroundImageRequest(mDOMNode, getter_AddRefs(request));
|
||||
if (request) {
|
||||
return request->GetImage(aImageContainer);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContextMenuInfo::GetBackgroundImageSrc(nsIURI** aURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
NS_ENSURE_STATE(mDOMNode);
|
||||
|
||||
RefPtr<imgRequestProxy> request;
|
||||
GetBackgroundImageRequest(mDOMNode, getter_AddRefs(request));
|
||||
if (request) {
|
||||
return request->GetURI(aURI);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContextMenuInfo::GetImageRequest(nsIDOMNode* aDOMNode, imgIRequest** aRequest)
|
||||
{
|
||||
NS_ENSURE_ARG(aDOMNode);
|
||||
NS_ENSURE_ARG_POINTER(aRequest);
|
||||
|
||||
// Get content
|
||||
nsCOMPtr<nsIImageLoadingContent> content(do_QueryInterface(aDOMNode));
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
|
||||
|
||||
return content->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST, aRequest);
|
||||
}
|
||||
|
||||
bool
|
||||
nsContextMenuInfo::HasBackgroundImage(nsIDOMNode* aDOMNode)
|
||||
{
|
||||
NS_ENSURE_TRUE(aDOMNode, false);
|
||||
|
||||
RefPtr<imgRequestProxy> request;
|
||||
GetBackgroundImageRequest(aDOMNode, getter_AddRefs(request));
|
||||
|
||||
return (request != nullptr);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContextMenuInfo::GetBackgroundImageRequest(nsIDOMNode* aDOMNode,
|
||||
imgRequestProxy** aRequest)
|
||||
{
|
||||
|
||||
NS_ENSURE_ARG(aDOMNode);
|
||||
NS_ENSURE_ARG_POINTER(aRequest);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> domNode = aDOMNode;
|
||||
|
||||
// special case for the <html> element: if it has no background-image
|
||||
// we'll defer to <body>
|
||||
nsCOMPtr<nsIDOMHTMLHtmlElement> htmlElement = do_QueryInterface(domNode);
|
||||
if (htmlElement) {
|
||||
nsCOMPtr<nsIDOMHTMLElement> element = do_QueryInterface(domNode);
|
||||
nsAutoString nameSpace;
|
||||
element->GetNamespaceURI(nameSpace);
|
||||
if (nameSpace.IsEmpty()) {
|
||||
nsresult rv = GetBackgroundImageRequestInternal(domNode, aRequest);
|
||||
if (NS_SUCCEEDED(rv) && *aRequest) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// no background-image found
|
||||
nsCOMPtr<nsIDOMDocument> document;
|
||||
domNode->GetOwnerDocument(getter_AddRefs(document));
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDocument(do_QueryInterface(document));
|
||||
NS_ENSURE_TRUE(htmlDocument, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLElement> body;
|
||||
htmlDocument->GetBody(getter_AddRefs(body));
|
||||
domNode = do_QueryInterface(body);
|
||||
NS_ENSURE_TRUE(domNode, NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
return GetBackgroundImageRequestInternal(domNode, aRequest);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode* aDOMNode,
|
||||
imgRequestProxy** aRequest)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDOMNode);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> domNode = aDOMNode;
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> document;
|
||||
domNode->GetOwnerDocument(getter_AddRefs(document));
|
||||
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<mozIDOMWindowProxy> window;
|
||||
document->GetDefaultView(getter_AddRefs(window));
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
|
||||
|
||||
auto* piWindow = nsPIDOMWindowOuter::From(window);
|
||||
nsPIDOMWindowInner* innerWindow = piWindow->GetCurrentInnerWindow();
|
||||
MOZ_ASSERT(innerWindow);
|
||||
|
||||
nsCOMPtr<nsIDOMCSSPrimitiveValue> primitiveValue;
|
||||
nsAutoString bgStringValue;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(document));
|
||||
nsCOMPtr<nsIPrincipal> principal = doc ? doc->NodePrincipal() : nullptr;
|
||||
|
||||
while (true) {
|
||||
nsCOMPtr<Element> domElement(do_QueryInterface(domNode));
|
||||
// bail for the parent node of the root element or null argument
|
||||
if (!domElement) {
|
||||
break;
|
||||
}
|
||||
|
||||
ErrorResult dummy;
|
||||
nsCOMPtr<nsICSSDeclaration> computedStyle =
|
||||
innerWindow->GetComputedStyle(*domElement, EmptyString(), dummy);
|
||||
dummy.SuppressException();
|
||||
if (computedStyle) {
|
||||
nsCOMPtr<nsIDOMCSSValue> cssValue;
|
||||
computedStyle->GetPropertyCSSValue(NS_LITERAL_STRING("background-image"),
|
||||
getter_AddRefs(cssValue));
|
||||
primitiveValue = do_QueryInterface(cssValue);
|
||||
if (primitiveValue) {
|
||||
primitiveValue->GetStringValue(bgStringValue);
|
||||
if (!bgStringValue.EqualsLiteral("none")) {
|
||||
nsCOMPtr<nsIURI> bgUri;
|
||||
NS_NewURI(getter_AddRefs(bgUri), bgStringValue);
|
||||
NS_ENSURE_TRUE(bgUri, NS_ERROR_FAILURE);
|
||||
|
||||
imgLoader* il = imgLoader::NormalLoader();
|
||||
NS_ENSURE_TRUE(il, NS_ERROR_FAILURE);
|
||||
|
||||
return il->LoadImage(bgUri, nullptr, nullptr,
|
||||
doc->GetReferrerPolicy(), principal, nullptr,
|
||||
nullptr, nullptr, nullptr, nsIRequest::LOAD_NORMAL,
|
||||
nullptr, nsIContentPolicy::TYPE_INTERNAL_IMAGE,
|
||||
EmptyString(), aRequest);
|
||||
}
|
||||
}
|
||||
|
||||
// bail if we encounter non-transparent background-color
|
||||
computedStyle->GetPropertyCSSValue(NS_LITERAL_STRING("background-color"),
|
||||
getter_AddRefs(cssValue));
|
||||
primitiveValue = do_QueryInterface(cssValue);
|
||||
if (primitiveValue) {
|
||||
primitiveValue->GetStringValue(bgStringValue);
|
||||
if (!bgStringValue.EqualsLiteral("transparent")) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
domNode->GetParentNode(getter_AddRefs(parentNode));
|
||||
domNode = parentNode;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
54
embedding/browser/nsContextMenuInfo.h
Normal file
54
embedding/browser/nsContextMenuInfo.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 nsContextMenuInfo_h__
|
||||
#define nsContextMenuInfo_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContextMenuListener2.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMEvent.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "imgIRequest.h"
|
||||
|
||||
class ChromeContextMenuListener;
|
||||
class imgRequestProxy;
|
||||
|
||||
// Helper class for implementors of nsIContextMenuListener2
|
||||
class nsContextMenuInfo : public nsIContextMenuInfo
|
||||
{
|
||||
friend class ChromeContextMenuListener;
|
||||
|
||||
public:
|
||||
nsContextMenuInfo();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONTEXTMENUINFO
|
||||
|
||||
private:
|
||||
virtual ~nsContextMenuInfo();
|
||||
|
||||
void SetMouseEvent(nsIDOMEvent* aEvent) { mMouseEvent = aEvent; }
|
||||
void SetDOMNode(nsIDOMNode* aNode) { mDOMNode = aNode; }
|
||||
void SetAssociatedLink(nsIDOMNode* aLink) { mAssociatedLink = aLink; }
|
||||
|
||||
nsresult GetImageRequest(nsIDOMNode* aDOMNode, imgIRequest** aRequest);
|
||||
|
||||
bool HasBackgroundImage(nsIDOMNode* aDOMNode);
|
||||
|
||||
nsresult GetBackgroundImageRequest(nsIDOMNode* aDOMNode,
|
||||
imgRequestProxy** aRequest);
|
||||
|
||||
nsresult GetBackgroundImageRequestInternal(nsIDOMNode* aDOMNode,
|
||||
imgRequestProxy** aRequest);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDOMEvent> mMouseEvent;
|
||||
nsCOMPtr<nsIDOMNode> mDOMNode;
|
||||
nsCOMPtr<nsIDOMNode> mAssociatedLink;
|
||||
};
|
||||
|
||||
#endif // nsContextMenuInfo_h__
|
||||
1674
embedding/browser/nsDocShellTreeOwner.cpp
Normal file
1674
embedding/browser/nsDocShellTreeOwner.cpp
Normal file
File diff suppressed because it is too large
Load diff
246
embedding/browser/nsDocShellTreeOwner.h
Normal file
246
embedding/browser/nsDocShellTreeOwner.h
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 nsDocShellTreeOwner_h__
|
||||
#define nsDocShellTreeOwner_h__
|
||||
|
||||
// Helper Classes
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// Interfaces Needed
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIEmbeddingSiteWindow.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsITooltipListener.h"
|
||||
#include "nsITooltipTextProvider.h"
|
||||
#include "nsCTooltipTextProvider.h"
|
||||
#include "nsIDroppedLinkHandler.h"
|
||||
#include "nsCommandHandler.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class EventTarget;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class nsWebBrowser;
|
||||
class ChromeTooltipListener;
|
||||
class ChromeContextMenuListener;
|
||||
|
||||
// {6D10C180-6888-11d4-952B-0020183BF181}
|
||||
#define NS_ICDOCSHELLTREEOWNER_IID \
|
||||
{ 0x6d10c180, 0x6888, 0x11d4, { 0x95, 0x2b, 0x0, 0x20, 0x18, 0x3b, 0xf1, 0x81 } }
|
||||
|
||||
// This is a fake 'hidden' interface that nsDocShellTreeOwner implements.
|
||||
// Classes such as nsCommandHandler can QI for this interface to be sure that
|
||||
// they're dealing with a valid nsDocShellTreeOwner and not some other object
|
||||
// that implements nsIDocShellTreeOwner.
|
||||
class nsICDocShellTreeOwner : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICDOCSHELLTREEOWNER_IID)
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsICDocShellTreeOwner, NS_ICDOCSHELLTREEOWNER_IID)
|
||||
|
||||
class nsDocShellTreeOwner final : public nsIDocShellTreeOwner,
|
||||
public nsIBaseWindow,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIWebProgressListener,
|
||||
public nsIDOMEventListener,
|
||||
public nsICDocShellTreeOwner,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
friend class nsWebBrowser;
|
||||
friend class nsCommandHandler;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIBASEWINDOW
|
||||
NS_DECL_NSIDOCSHELLTREEOWNER
|
||||
NS_DECL_NSIDOMEVENTLISTENER
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
protected:
|
||||
nsDocShellTreeOwner();
|
||||
virtual ~nsDocShellTreeOwner();
|
||||
|
||||
void WebBrowser(nsWebBrowser* aWebBrowser);
|
||||
|
||||
nsWebBrowser* WebBrowser();
|
||||
NS_IMETHOD SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner);
|
||||
NS_IMETHOD SetWebBrowserChrome(nsIWebBrowserChrome* aWebBrowserChrome);
|
||||
|
||||
NS_IMETHOD AddChromeListeners();
|
||||
NS_IMETHOD RemoveChromeListeners();
|
||||
|
||||
nsresult FindItemWithNameAcrossWindows(
|
||||
const char16_t* aName,
|
||||
nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem* aOriginalRequestor,
|
||||
nsIDocShellTreeItem** aFoundItem);
|
||||
|
||||
void EnsurePrompter();
|
||||
void EnsureAuthPrompter();
|
||||
|
||||
void AddToWatcher();
|
||||
void RemoveFromWatcher();
|
||||
|
||||
void EnsureContentTreeOwner();
|
||||
|
||||
// These helper functions return the correct instances of the requested
|
||||
// interfaces. If the object passed to SetWebBrowserChrome() implements
|
||||
// nsISupportsWeakReference, then these functions call QueryReferent on
|
||||
// that object. Otherwise, they return an addrefed pointer. If the
|
||||
// WebBrowserChrome object doesn't exist, they return nullptr.
|
||||
already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
|
||||
already_AddRefed<nsIEmbeddingSiteWindow> GetOwnerWin();
|
||||
already_AddRefed<nsIInterfaceRequestor> GetOwnerRequestor();
|
||||
|
||||
protected:
|
||||
// Weak References
|
||||
nsWebBrowser* mWebBrowser;
|
||||
nsIDocShellTreeOwner* mTreeOwner;
|
||||
nsIDocShellTreeItem* mPrimaryContentShell;
|
||||
|
||||
nsIWebBrowserChrome* mWebBrowserChrome;
|
||||
nsIEmbeddingSiteWindow* mOwnerWin;
|
||||
nsIInterfaceRequestor* mOwnerRequestor;
|
||||
|
||||
nsWeakPtr mWebBrowserChromeWeak; // nsIWebBrowserChrome
|
||||
|
||||
// the objects that listen for chrome events like context menus and tooltips.
|
||||
// They are separate objects to avoid circular references between |this|
|
||||
// and the DOM.
|
||||
RefPtr<ChromeTooltipListener> mChromeTooltipListener;
|
||||
RefPtr<ChromeContextMenuListener> mChromeContextMenuListener;
|
||||
|
||||
RefPtr<nsDocShellTreeOwner> mContentTreeOwner;
|
||||
|
||||
nsCOMPtr<nsIPrompt> mPrompter;
|
||||
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
|
||||
nsCOMPtr<nsITabParent> mPrimaryTabParent;
|
||||
};
|
||||
|
||||
|
||||
// The class that listens to the chrome events and tells the embedding chrome to
|
||||
// show tooltips, as appropriate. Handles registering itself with the DOM with
|
||||
// AddChromeListeners() and removing itself with RemoveChromeListeners().
|
||||
class ChromeTooltipListener final : public nsIDOMEventListener
|
||||
{
|
||||
protected:
|
||||
virtual ~ChromeTooltipListener();
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
ChromeTooltipListener(nsWebBrowser* aInBrowser, nsIWebBrowserChrome* aInChrome);
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override;
|
||||
NS_IMETHOD MouseMove(nsIDOMEvent* aMouseEvent);
|
||||
|
||||
// Add/remove the relevant listeners, based on what interfaces the embedding
|
||||
// chrome implements.
|
||||
NS_IMETHOD AddChromeListeners();
|
||||
NS_IMETHOD RemoveChromeListeners();
|
||||
|
||||
private:
|
||||
// various delays for tooltips
|
||||
enum
|
||||
{
|
||||
kTooltipAutoHideTime = 5000, // ms
|
||||
kTooltipMouseMoveTolerance = 7 // pixel tolerance for mousemove event
|
||||
};
|
||||
|
||||
NS_IMETHOD AddTooltipListener();
|
||||
NS_IMETHOD RemoveTooltipListener();
|
||||
|
||||
NS_IMETHOD ShowTooltip(int32_t aInXCoords, int32_t aInYCoords,
|
||||
const nsAString& aInTipText,
|
||||
const nsAString& aDirText);
|
||||
NS_IMETHOD HideTooltip();
|
||||
|
||||
nsWebBrowser* mWebBrowser;
|
||||
nsCOMPtr<mozilla::dom::EventTarget> mEventTarget;
|
||||
nsCOMPtr<nsITooltipTextProvider> mTooltipTextProvider;
|
||||
|
||||
// This must be a strong ref in order to make sure we can hide the tooltip if
|
||||
// the window goes away while we're displaying one. If we don't hold a strong
|
||||
// ref, the chrome might have been disposed of before we get a chance to tell
|
||||
// it, and no one would ever tell us of that fact.
|
||||
nsCOMPtr<nsIWebBrowserChrome> mWebBrowserChrome;
|
||||
|
||||
bool mTooltipListenerInstalled;
|
||||
|
||||
nsCOMPtr<nsITimer> mTooltipTimer;
|
||||
static void sTooltipCallback(nsITimer* aTimer, void* aListener);
|
||||
|
||||
// Mouse coordinates for last mousemove event we saw
|
||||
int32_t mMouseClientX;
|
||||
int32_t mMouseClientY;
|
||||
|
||||
// Mouse coordinates for tooltip event
|
||||
int32_t mMouseScreenX;
|
||||
int32_t mMouseScreenY;
|
||||
|
||||
bool mShowingTooltip;
|
||||
bool mTooltipShownOnce;
|
||||
|
||||
// The node hovered over that fired the timer. This may turn into the node
|
||||
// that triggered the tooltip, but only if the timer ever gets around to
|
||||
// firing. This is a strong reference, because the tooltip content can be
|
||||
// destroyed while we're waiting for the tooltip to pup up, and we need to
|
||||
// detect that. It's set only when the tooltip timer is created and launched.
|
||||
// The timer must either fire or be cancelled (or possibly released?), and we
|
||||
// release this reference in each of those cases. So we don't leak.
|
||||
nsCOMPtr<nsIDOMNode> mPossibleTooltipNode;
|
||||
};
|
||||
|
||||
// The class that listens to the chrome events and tells the embedding chrome to
|
||||
// show context menus, as appropriate. Handles registering itself with the DOM
|
||||
// with AddChromeListeners() and removing itself with RemoveChromeListeners().
|
||||
class ChromeContextMenuListener : public nsIDOMEventListener
|
||||
{
|
||||
protected:
|
||||
virtual ~ChromeContextMenuListener();
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
ChromeContextMenuListener(nsWebBrowser* aInBrowser,
|
||||
nsIWebBrowserChrome* aInChrome);
|
||||
|
||||
// nsIDOMContextMenuListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override;
|
||||
|
||||
// Add/remove the relevant listeners, based on what interfaces
|
||||
// the embedding chrome implements.
|
||||
NS_IMETHOD AddChromeListeners();
|
||||
NS_IMETHOD RemoveChromeListeners();
|
||||
|
||||
private:
|
||||
NS_IMETHOD AddContextMenuListener();
|
||||
NS_IMETHOD RemoveContextMenuListener();
|
||||
|
||||
bool mContextMenuListenerInstalled;
|
||||
|
||||
nsWebBrowser* mWebBrowser;
|
||||
nsCOMPtr<mozilla::dom::EventTarget> mEventTarget;
|
||||
nsCOMPtr<nsIWebBrowserChrome> mWebBrowserChrome;
|
||||
};
|
||||
|
||||
#endif /* nsDocShellTreeOwner_h__ */
|
||||
101
embedding/browser/nsEmbedStream.cpp
Normal file
101
embedding/browser/nsEmbedStream.cpp
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 "nsIAsyncInputStream.h"
|
||||
#include "nsIAsyncOutputStream.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIPipe.h"
|
||||
|
||||
#include "nsEmbedStream.h"
|
||||
#include "nsError.h"
|
||||
#include "nsString.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS0(nsEmbedStream)
|
||||
|
||||
nsEmbedStream::nsEmbedStream()
|
||||
{
|
||||
mOwner = nullptr;
|
||||
}
|
||||
|
||||
nsEmbedStream::~nsEmbedStream()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
nsEmbedStream::InitOwner(nsIWebBrowser* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsEmbedStream::Init(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsEmbedStream::OpenStream(nsIURI* aBaseURI, const nsACString& aContentType)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_ARG_POINTER(aBaseURI);
|
||||
NS_ENSURE_TRUE(IsASCII(aContentType), NS_ERROR_INVALID_ARG);
|
||||
|
||||
// if we're already doing a stream, return an error
|
||||
if (mOutputStream) {
|
||||
return NS_ERROR_IN_PROGRESS;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAsyncInputStream> inputStream;
|
||||
nsCOMPtr<nsIAsyncOutputStream> outputStream;
|
||||
rv = NS_NewPipe2(getter_AddRefs(inputStream), getter_AddRefs(outputStream),
|
||||
true, false, 0, UINT32_MAX);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mOwner);
|
||||
rv = docShell->LoadStream(inputStream, aBaseURI, aContentType,
|
||||
EmptyCString(), nullptr);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
mOutputStream = outputStream;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsEmbedStream::AppendToStream(const uint8_t* aData, uint32_t aLen)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_STATE(mOutputStream);
|
||||
|
||||
uint32_t bytesWritten = 0;
|
||||
rv = mOutputStream->Write(reinterpret_cast<const char*>(aData),
|
||||
aLen, &bytesWritten);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_ASSERTION(bytesWritten == aLen,
|
||||
"underlying buffer couldn't handle the write");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsEmbedStream::CloseStream(void)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// NS_ENSURE_STATE returns NS_ERROR_UNEXPECTED if the condition isn't
|
||||
// satisfied; this is exactly what we want to return.
|
||||
NS_ENSURE_STATE(mOutputStream);
|
||||
mOutputStream->Close();
|
||||
mOutputStream = nullptr;
|
||||
|
||||
return rv;
|
||||
}
|
||||
37
embedding/browser/nsEmbedStream.h
Normal file
37
embedding/browser/nsEmbedStream.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 nsEmbedStream_h__
|
||||
#define nsEmbedStream_h__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
|
||||
class nsEmbedStream : public nsISupports
|
||||
{
|
||||
public:
|
||||
nsEmbedStream();
|
||||
|
||||
void InitOwner(nsIWebBrowser* aOwner);
|
||||
nsresult Init(void);
|
||||
|
||||
nsresult OpenStream(nsIURI* aBaseURI, const nsACString& aContentType);
|
||||
nsresult AppendToStream(const uint8_t* aData, uint32_t aLen);
|
||||
nsresult CloseStream(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
protected:
|
||||
virtual ~nsEmbedStream();
|
||||
|
||||
private:
|
||||
nsIWebBrowser* mOwner;
|
||||
nsCOMPtr<nsIOutputStream> mOutputStream;
|
||||
};
|
||||
|
||||
#endif // nsEmbedStream_h__
|
||||
40
embedding/browser/nsICommandHandler.idl
Normal file
40
embedding/browser/nsICommandHandler.idl
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/* -*- 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"
|
||||
|
||||
interface mozIDOMWindowProxy;
|
||||
|
||||
[scriptable, uuid(08aed3cc-69f7-47ba-a110-f2efa8a6d7ea)]
|
||||
interface nsICommandHandlerInit : nsISupports
|
||||
{
|
||||
attribute mozIDOMWindowProxy window;
|
||||
};
|
||||
|
||||
[scriptable, uuid(34A4FCF0-66FC-11d4-9528-0020183BF181)]
|
||||
interface nsICommandHandler : nsISupports
|
||||
{
|
||||
/*
|
||||
* Execute the specified command with the specified parameters and return
|
||||
* the result to the caller. The format of the command, parameters and
|
||||
* the result are determined by the acutal implementation.
|
||||
*/
|
||||
string exec(in string aCommand, in string aParameters);
|
||||
/*
|
||||
* Query the status of the specified command with the specified parameters
|
||||
* and return the result to the caller. The format of the command,
|
||||
* parameters and the result are determined by the implementation.
|
||||
*/
|
||||
string query(in string aCommand, in string aParameters);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
// {3A449110-66FD-11d4-9528-0020183BF181} -
|
||||
#define NS_COMMANDHANDLER_CID \
|
||||
{ 0x3a449110, 0x66fd, 0x11d4, { 0x95, 0x28, 0x0, 0x20, 0x18, 0x3b, 0xf1, 0x81 } }
|
||||
#define NS_COMMANDHANDLER_CONTRACTID \
|
||||
"@mozilla.org/embedding/browser/nsCommandHandler;1"
|
||||
%}
|
||||
|
||||
65
embedding/browser/nsIContextMenuListener.idl
Normal file
65
embedding/browser/nsIContextMenuListener.idl
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; 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 "nsISupports.idl"
|
||||
|
||||
interface nsIDOMEvent;
|
||||
interface nsIDOMNode;
|
||||
|
||||
/**
|
||||
* An optional interface for embedding clients wishing to receive
|
||||
* notifications for context menu events (e.g. generated by
|
||||
* a user right-mouse clicking on a link). The embedder implements
|
||||
* this interface on the web browser chrome object associated
|
||||
* with the window that notifications are required for. When a context
|
||||
* menu event, the browser will call this interface if present.
|
||||
*
|
||||
* @see nsIDOMNode
|
||||
* @see nsIDOMEvent
|
||||
*/
|
||||
[scriptable, uuid(3478b6b0-3875-11d4-94ef-0020183bf181)]
|
||||
interface nsIContextMenuListener : nsISupports
|
||||
{
|
||||
/** Flag. No context. */
|
||||
const unsigned long CONTEXT_NONE = 0;
|
||||
/** Flag. Context is a link element. */
|
||||
const unsigned long CONTEXT_LINK = 1;
|
||||
/** Flag. Context is an image element. */
|
||||
const unsigned long CONTEXT_IMAGE = 2;
|
||||
/** Flag. Context is the whole document. */
|
||||
const unsigned long CONTEXT_DOCUMENT = 4;
|
||||
/** Flag. Context is a text area element. */
|
||||
const unsigned long CONTEXT_TEXT = 8;
|
||||
/** Flag. Context is an input element. */
|
||||
const unsigned long CONTEXT_INPUT = 16;
|
||||
|
||||
/**
|
||||
* Called when the browser receives a context menu event (e.g. user is right-mouse
|
||||
* clicking somewhere on the document). The combination of flags, event and node
|
||||
* provided in the call indicate where and what was clicked on.
|
||||
*
|
||||
* The following table describes what context flags and node combinations are
|
||||
* possible.
|
||||
*
|
||||
* <TABLE>
|
||||
* <TR><TD><B>aContextFlag</B></TD><TD>aNode</TD></TR>
|
||||
* <TR><TD>CONTEXT_LINK</TD><TD><A></TD></TR>
|
||||
* <TR><TD>CONTEXT_IMAGE</TD><TD><IMG></TD></TR>
|
||||
* <TR><TD>CONTEXT_IMAGE | CONTEXT_LINK</TD><TD><IMG>
|
||||
* with an <A> as an ancestor</TD></TR>
|
||||
* <TR><TD>CONTEXT_INPUT</TD><TD><INPUT></TD></TR>
|
||||
* <TR><TD>CONTEXT_TEXT</TD><TD><TEXTAREA></TD></TR>
|
||||
* <TR><TD>CONTEXT_DOCUMENT</TD><TD><HTML></TD></TR>
|
||||
* </TABLE>
|
||||
*
|
||||
* @param aContextFlags Flags indicating the kind of context.
|
||||
* @param aEvent The DOM context menu event.
|
||||
* @param aNode The DOM node most relevant to the context.
|
||||
*
|
||||
* @return <CODE>NS_OK</CODE> always.
|
||||
*/
|
||||
void onShowContextMenu(in unsigned long aContextFlags, in nsIDOMEvent aEvent, in nsIDOMNode aNode);
|
||||
};
|
||||
|
||||
121
embedding/browser/nsIContextMenuListener2.idl
Normal file
121
embedding/browser/nsIContextMenuListener2.idl
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
/* -*- 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 "nsISupports.idl"
|
||||
|
||||
interface nsIDOMEvent;
|
||||
interface nsIDOMNode;
|
||||
interface imgIContainer;
|
||||
interface nsIURI;
|
||||
interface nsIContextMenuInfo;
|
||||
|
||||
/* THIS IS A PUBLIC EMBEDDING API */
|
||||
|
||||
/**
|
||||
* nsIContextMenuListener2
|
||||
*
|
||||
* This is an extended version of nsIContextMenuListener
|
||||
* It provides a helper class, nsIContextMenuInfo, to allow access to
|
||||
* background images as well as various utilities.
|
||||
*
|
||||
* @see nsIContextMenuListener
|
||||
* @see nsIContextMenuInfo
|
||||
*/
|
||||
|
||||
[scriptable, uuid(7fb719b3-d804-4964-9596-77cf924ee314)]
|
||||
interface nsIContextMenuListener2 : nsISupports
|
||||
{
|
||||
/** Flag. No context. */
|
||||
const unsigned long CONTEXT_NONE = 0;
|
||||
/** Flag. Context is a link element. */
|
||||
const unsigned long CONTEXT_LINK = 1;
|
||||
/** Flag. Context is an image element. */
|
||||
const unsigned long CONTEXT_IMAGE = 2;
|
||||
/** Flag. Context is the whole document. */
|
||||
const unsigned long CONTEXT_DOCUMENT = 4;
|
||||
/** Flag. Context is a text area element. */
|
||||
const unsigned long CONTEXT_TEXT = 8;
|
||||
/** Flag. Context is an input element. */
|
||||
const unsigned long CONTEXT_INPUT = 16;
|
||||
/** Flag. Context is a background image. */
|
||||
const unsigned long CONTEXT_BACKGROUND_IMAGE = 32;
|
||||
|
||||
/**
|
||||
* Called when the browser receives a context menu event (e.g. user is right-mouse
|
||||
* clicking somewhere on the document). The combination of flags, along with the
|
||||
* attributes of <CODE>aUtils</CODE>, indicate where and what was clicked on.
|
||||
*
|
||||
* The following table describes what context flags and node combinations are
|
||||
* possible.
|
||||
*
|
||||
* aContextFlags aUtils.targetNode
|
||||
*
|
||||
* CONTEXT_LINK <A>
|
||||
* CONTEXT_IMAGE <IMG>
|
||||
* CONTEXT_IMAGE | CONTEXT_LINK <IMG> with <A> as an ancestor
|
||||
* CONTEXT_INPUT <INPUT>
|
||||
* CONTEXT_INPUT | CONTEXT_IMAGE <INPUT> with type=image
|
||||
* CONTEXT_TEXT <TEXTAREA>
|
||||
* CONTEXT_DOCUMENT <HTML>
|
||||
* CONTEXT_BACKGROUND_IMAGE <HTML> with background image
|
||||
*
|
||||
* @param aContextFlags Flags indicating the kind of context.
|
||||
* @param aUtils Context information and helper utilities.
|
||||
*
|
||||
* @see nsIContextMenuInfo
|
||||
*/
|
||||
void onShowContextMenu(in unsigned long aContextFlags, in nsIContextMenuInfo aUtils);
|
||||
};
|
||||
|
||||
/**
|
||||
* nsIContextMenuInfo
|
||||
*
|
||||
* A helper object for implementors of nsIContextMenuListener2.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(2f977d56-5485-11d4-87e2-0010a4e75ef2)]
|
||||
interface nsIContextMenuInfo : nsISupports
|
||||
{
|
||||
/**
|
||||
* The DOM context menu event.
|
||||
*/
|
||||
readonly attribute nsIDOMEvent mouseEvent;
|
||||
|
||||
/**
|
||||
* The DOM node most relevant to the context.
|
||||
*/
|
||||
readonly attribute nsIDOMNode targetNode;
|
||||
|
||||
/**
|
||||
* Given the <CODE>CONTEXT_LINK</CODE> flag, <CODE>targetNode</CODE> may not
|
||||
* nescesarily be a link. This returns the anchor from <CODE>targetNode</CODE>
|
||||
* if it has one or that of its nearest ancestor if it does not.
|
||||
*/
|
||||
readonly attribute AString associatedLink;
|
||||
|
||||
/**
|
||||
* Given the <CODE>CONTEXT_IMAGE</CODE> flag, these methods can be
|
||||
* used in order to get the image for viewing, saving, or for the clipboard.
|
||||
*
|
||||
* @return <CODE>NS_OK</CODE> if successful, otherwise <CODE>NS_ERROR_FAILURE</CODE> if no
|
||||
* image was found, or NS_ERROR_NULL_POINTER if an internal error occurs where we think there
|
||||
* is an image, but for some reason it cannot be returned.
|
||||
*/
|
||||
|
||||
readonly attribute imgIContainer imageContainer;
|
||||
readonly attribute nsIURI imageSrc;
|
||||
|
||||
/**
|
||||
* Given the <CODE>CONTEXT_BACKGROUND_IMAGE</CODE> flag, these methods can be
|
||||
* used in order to get the image for viewing, saving, or for the clipboard.
|
||||
*
|
||||
* @return <CODE>NS_OK</CODE> if successful, otherwise <CODE>NS_ERROR_FAILURE</CODE> if no background
|
||||
* image was found, or NS_ERROR_NULL_POINTER if an internal error occurs where we think there is a
|
||||
* background image, but for some reason it cannot be returned.
|
||||
*/
|
||||
|
||||
readonly attribute imgIContainer backgroundImageContainer;
|
||||
readonly attribute nsIURI backgroundImageSrc;
|
||||
};
|
||||
157
embedding/browser/nsIEmbeddingSiteWindow.idl
Normal file
157
embedding/browser/nsIEmbeddingSiteWindow.idl
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
/* -*- 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"
|
||||
|
||||
/* THIS IS A PUBLIC EMBEDDING API */
|
||||
|
||||
/**
|
||||
* The nsIEmbeddingSiteWindow is implemented by the embedder to provide
|
||||
* Gecko with the means to call up to the host to resize the window,
|
||||
* hide or show it and set/get its title.
|
||||
*/
|
||||
[scriptable, uuid(0b976267-4aaa-4f36-a2d4-27b5ca8d73bb)]
|
||||
interface nsIEmbeddingSiteWindow : nsISupports
|
||||
{
|
||||
/**
|
||||
* Flag indicates that position of the top left corner of the outer area
|
||||
* is required/specified.
|
||||
*
|
||||
* @see setDimensions
|
||||
* @see getDimensions
|
||||
*/
|
||||
const unsigned long DIM_FLAGS_POSITION = 1;
|
||||
|
||||
/**
|
||||
* Flag indicates that the size of the inner area is required/specified.
|
||||
*
|
||||
* @note The inner and outer flags are mutually exclusive and it is
|
||||
* invalid to combine them.
|
||||
*
|
||||
* @see setDimensions
|
||||
* @see getDimensions
|
||||
* @see DIM_FLAGS_SIZE_OUTER
|
||||
*/
|
||||
const unsigned long DIM_FLAGS_SIZE_INNER = 2;
|
||||
|
||||
/**
|
||||
* Flag indicates that the size of the outer area is required/specified.
|
||||
*
|
||||
* @see setDimensions
|
||||
* @see getDimensions
|
||||
* @see DIM_FLAGS_SIZE_INNER
|
||||
*/
|
||||
const unsigned long DIM_FLAGS_SIZE_OUTER = 4;
|
||||
|
||||
/**
|
||||
* Flag indicates that the x parameter should be ignored.
|
||||
*
|
||||
* @see setDimensions
|
||||
*/
|
||||
const unsigned long DIM_FLAGS_IGNORE_X = 8;
|
||||
|
||||
/**
|
||||
* Flag indicates that the y parameter should be ignored.
|
||||
*
|
||||
* @see setDimensions
|
||||
*/
|
||||
const unsigned long DIM_FLAGS_IGNORE_Y = 16;
|
||||
|
||||
/**
|
||||
* Flag indicates that the cx parameter should be ignored.
|
||||
*
|
||||
* @see setDimensions
|
||||
*/
|
||||
const unsigned long DIM_FLAGS_IGNORE_CX = 32;
|
||||
|
||||
/**
|
||||
* Flag indicates that the cy parameter should be ignored.
|
||||
*
|
||||
* @see setDimensions
|
||||
*/
|
||||
const unsigned long DIM_FLAGS_IGNORE_CY = 64;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the dimensions for the window; the position & size. The
|
||||
* flags to indicate what the caller wants to set and whether the size
|
||||
* refers to the inner or outer area. The inner area refers to just
|
||||
* the embedded area, wheras the outer area can also include any
|
||||
* surrounding chrome, window frame, title bar, and so on.
|
||||
*
|
||||
* @param flags Combination of position, inner and outer size flags.
|
||||
* The ignore flags are telling the parent to use the
|
||||
* current values for those dimensions and ignore the
|
||||
* corresponding parameters the child sends.
|
||||
* @param x Left hand corner of the outer area.
|
||||
* @param y Top corner of the outer area.
|
||||
* @param cx Width of the inner or outer area.
|
||||
* @param cy Height of the inner or outer area.
|
||||
*
|
||||
* @return <code>NS_OK</code> if operation was performed correctly;
|
||||
* <code>NS_ERROR_UNEXPECTED</code> if window could not be
|
||||
* destroyed;
|
||||
* <code>NS_ERROR_INVALID_ARG</code> for bad flag combination
|
||||
* or illegal dimensions.
|
||||
*
|
||||
* @see getDimensions
|
||||
* @see DIM_FLAGS_POSITION
|
||||
* @see DIM_FLAGS_SIZE_OUTER
|
||||
* @see DIM_FLAGS_SIZE_INNER
|
||||
*/
|
||||
void setDimensions(in unsigned long flags, in long x, in long y, in long cx, in long cy);
|
||||
|
||||
/**
|
||||
* Gets the dimensions of the window. The caller may pass
|
||||
* <CODE>nullptr</CODE> for any value it is uninterested in receiving.
|
||||
*
|
||||
* @param flags Combination of position, inner and outer size flag .
|
||||
* @param x Left hand corner of the outer area; or <CODE>nullptr</CODE>.
|
||||
* @param y Top corner of the outer area; or <CODE>nullptr</CODE>.
|
||||
* @param cx Width of the inner or outer area; or <CODE>nullptr</CODE>.
|
||||
* @param cy Height of the inner or outer area; or <CODE>nullptr</CODE>.
|
||||
*
|
||||
* @see setDimensions
|
||||
* @see DIM_FLAGS_POSITION
|
||||
* @see DIM_FLAGS_SIZE_OUTER
|
||||
* @see DIM_FLAGS_SIZE_INNER
|
||||
*/
|
||||
void getDimensions(in unsigned long flags, out long x, out long y, out long cx, out long cy);
|
||||
|
||||
/**
|
||||
* Give the window focus.
|
||||
*/
|
||||
void setFocus();
|
||||
|
||||
/**
|
||||
* Visibility of the window.
|
||||
*/
|
||||
attribute boolean visibility;
|
||||
|
||||
/**
|
||||
* Title of the window.
|
||||
*/
|
||||
attribute wstring title;
|
||||
|
||||
/**
|
||||
* Native window for the site's window. The implementor should copy the
|
||||
* native window object into the address supplied by the caller. The
|
||||
* type of the native window that the address refers to is platform
|
||||
* and OS specific as follows:
|
||||
*
|
||||
* <ul>
|
||||
* <li>On Win32 it is an <CODE>HWND</CODE>.</li>
|
||||
* <li>On MacOS this is a <CODE>WindowPtr</CODE>.</li>
|
||||
* <li>On GTK this is a <CODE>GtkWidget*</CODE>.</li>
|
||||
* </ul>
|
||||
*/
|
||||
[noscript] readonly attribute voidPtr siteWindow;
|
||||
|
||||
/**
|
||||
* Blur the window. This should unfocus the window and send an onblur event.
|
||||
*/
|
||||
void blur();
|
||||
};
|
||||
52
embedding/browser/nsIPrintPreviewNavigation.idl
Normal file
52
embedding/browser/nsIPrintPreviewNavigation.idl
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; 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 "nsISupports.idl"
|
||||
|
||||
|
||||
/**
|
||||
* The nsIPrintPreviewNavigation
|
||||
*/
|
||||
[scriptable, uuid(8148E3F1-2E8B-11d5-A86C-00105A183419)]
|
||||
interface nsIPrintPreviewNavigation : nsISupports
|
||||
{
|
||||
|
||||
readonly attribute long pageCount;
|
||||
|
||||
|
||||
/**
|
||||
* Preview the next Page
|
||||
*
|
||||
* Return - PR_TRUE if success
|
||||
*/
|
||||
boolean nextPage();
|
||||
|
||||
/**
|
||||
* Preview the previous Page
|
||||
*
|
||||
* Return - PR_TRUE if success
|
||||
*/
|
||||
boolean previousPage();
|
||||
|
||||
/**
|
||||
* Go to a page to preview
|
||||
*
|
||||
* aPageNumber - Page to go preview
|
||||
* Return - PR_TRUE if success
|
||||
*/
|
||||
boolean goToPage(unsigned long aPageNumber);
|
||||
|
||||
|
||||
/**
|
||||
* Skip pages
|
||||
*
|
||||
* aNumPages - number of pages to skip including the current page. Neg. goes back
|
||||
* Return - true if success
|
||||
*/
|
||||
boolean skipPages(long aNumPages);
|
||||
|
||||
|
||||
};
|
||||
165
embedding/browser/nsIPrintingPromptService.idl
Normal file
165
embedding/browser/nsIPrintingPromptService.idl
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
/* -*- Mode: C++; tab-width: 2; 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/. */
|
||||
|
||||
/* Doc interface here */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIWebBrowserPrint.idl"
|
||||
#include "nsIWebProgressListener.idl"
|
||||
#include "nsIPrintProgressParams.idl"
|
||||
#include "nsIPrintSettings.idl"
|
||||
#include "nsIObserver.idl"
|
||||
|
||||
interface nsIDOMWindow;
|
||||
|
||||
[scriptable, uuid(328daa3e-09e4-455f-bb6f-0a921766042f)]
|
||||
interface nsIPrintingPromptService : nsISupports
|
||||
{
|
||||
/**
|
||||
* This service enables embedders to implement their own Print and Progress Dialogs.
|
||||
* Each platform has a "base" or "basckstop" implementation of the service. The
|
||||
* service is automatically registered at start up.
|
||||
*
|
||||
* Historically, platform toolkits with native dialogs have implemented them in the GFX layer
|
||||
* Usually they were displayed when a new DeviceContextSpec specific to that platform
|
||||
* was created.
|
||||
*
|
||||
* Windows: The GFX layer no longers supports default toolkit behavior for displaying the
|
||||
* native Print Dialog.
|
||||
* If an embedder implemented service returns any error code (other than NS_ERROR_ABORT)
|
||||
* printing will terminate.
|
||||
*
|
||||
* Returning NS_OK assumes that the PrintSettings object was correctly filled in and
|
||||
* if it does not have valid fields for printer name, etc. it may also terminate.
|
||||
*
|
||||
* Defaults for platform service:
|
||||
* showPrintDialog - displays a native dialog
|
||||
* showPageSetup - displays a XUL dialog
|
||||
* showProgress - displays a XUL dialog
|
||||
* showPrinterProperties - n/a
|
||||
*
|
||||
* Summary for Windows Embedders:
|
||||
* Stated once again: There is no "fallback" native platform support in GFX for the
|
||||
* displaying of the native print dialog. The current default implementation for Windows
|
||||
* display a native print dialog but a XUL-based progress dialog.
|
||||
* If you wish to have a native progress dialog on Windows you will have to create and
|
||||
* register your own service.
|
||||
*
|
||||
* Note: The Windows version Mozilla implements this service which is
|
||||
* automatically built and registered for you. You can use it as an example.
|
||||
* It is located at "mozilla/embedding/components/printingui/win". That service
|
||||
* is capable of displaying a native print dialog and a XUL progress dialog.
|
||||
*
|
||||
* To fly your own dialog you may:
|
||||
*
|
||||
* 1) Implement this service to display at least the Print Dialog and a Print Progress Dialog
|
||||
* or you may implement just one of the dialogs and pass back NS_ERROR_NOT_IMPLEMENTED
|
||||
* for any of the others.
|
||||
*
|
||||
* 2) For the Print Dialog:
|
||||
* You may stub out this service by having all the methods return NS_ERROR_NOT_IMPLEMENTED.
|
||||
* You can then fly you own dialog and then properly fill in the PrintSettings object
|
||||
* before calling nsIWebBrowserPrint's Print method. If you stub out this service
|
||||
* you MUST set "printSilent" to true, if you do not, Printing will terminate and an
|
||||
* error dialog will be displayed.
|
||||
*
|
||||
* Mac: The GFX layer still supports default toolkit behavior for displaying the Print Dialog.
|
||||
* If an embedder implemented service returns NS_ERROR_NOT_IMPLEMENTED for "showPrintDialog"
|
||||
* The toolkit will display the native print dialog.
|
||||
*
|
||||
* Defaults for platform service:
|
||||
* Mac OS9: showPrintDialog - displays a native dialog
|
||||
* showPageSetup - displays a native dialog
|
||||
* showProgress - displays a XUL dialog
|
||||
* showPrinterProperties - n/a
|
||||
*
|
||||
* Mac OSX: showPrintDialog - displays a native dialog
|
||||
* showPageSetup - displays a native dialog
|
||||
* showProgress - not implemented (provided by OS)
|
||||
* showPrinterProperties - n/a
|
||||
*
|
||||
* GTK: There are no native dialog for GTK.
|
||||
*
|
||||
* Defaults for platform service:
|
||||
* showPrintDialog - displays a XUL dialog
|
||||
* showPageSetup - displays a XUL dialog
|
||||
* showProgress - displays a XUL dialog
|
||||
* showPrinterProperties - displays a XUL dialog
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show the Print Dialog
|
||||
*
|
||||
* @param parent - a DOM windows the dialog will be parented to (required)
|
||||
* @param webBrowserPrint - represents the document to be printed (required)
|
||||
* @param printSettings - PrintSettings for print "job" (required)
|
||||
*
|
||||
*/
|
||||
void showPrintDialog(in mozIDOMWindowProxy parent,
|
||||
in nsIWebBrowserPrint webBrowserPrint,
|
||||
in nsIPrintSettings printSettings);
|
||||
|
||||
/**
|
||||
* Shows the print progress dialog
|
||||
*
|
||||
* @param parent - a DOM windows the dialog will be parented to
|
||||
* @param webBrowserPrint - represents the document to be printed
|
||||
* @param printSettings - PrintSettings for print "job"
|
||||
* @param openDialogObserver - an observer that will be notifed when the dialog is opened
|
||||
* @param isForPrinting - true - for printing, false for print preview
|
||||
* @param webProgressListener - additional listener can be registered for progress notifications
|
||||
* @param printProgressParams - parameter object for passing progress state
|
||||
* @param notifyOnOpen - this indicates that the observer will be notified when the progress
|
||||
* dialog has been opened. If false is returned it means the observer
|
||||
* (usually the caller) shouldn't wait
|
||||
* For Print Preview Progress there is intermediate progress
|
||||
*/
|
||||
void showProgress(in mozIDOMWindowProxy parent,
|
||||
in nsIWebBrowserPrint webBrowserPrint,
|
||||
in nsIPrintSettings printSettings,
|
||||
in nsIObserver openDialogObserver,
|
||||
in boolean isForPrinting,
|
||||
out nsIWebProgressListener webProgressListener,
|
||||
out nsIPrintProgressParams printProgressParams,
|
||||
out boolean notifyOnOpen);
|
||||
|
||||
/**
|
||||
* Shows the print progress dialog
|
||||
*
|
||||
* @param parent - a DOM windows the dialog will be parented to (required)
|
||||
* @param printSettings - PrintSettings for page setup (required)
|
||||
* @param aObs - An observer to know if the contents of the Print Settings
|
||||
* object has changed while the dialog is being shown.
|
||||
* For example, some platforms may implement an "Apply" button (not required)
|
||||
*/
|
||||
void showPageSetup(in mozIDOMWindowProxy parent,
|
||||
in nsIPrintSettings printSettings,
|
||||
in nsIObserver aObs);
|
||||
|
||||
/**
|
||||
* Sometimes platforms need to bring up a special properties dialog for showing
|
||||
* print specific properties. Although the PrintSettings has a place to set the
|
||||
* printer name, here is is an argument to be clear as to what printer is being
|
||||
* asked to have the properties set for it. The Printer name in the PS is ignored.
|
||||
*
|
||||
* @param parent - a DOM windows the dialog will be parented to (required)
|
||||
* @param printerName - name of printer (required)
|
||||
* @param printSettings - PrintSettings for page setup (required)
|
||||
*/
|
||||
void showPrinterProperties(in mozIDOMWindowProxy parent,
|
||||
in wstring printerName,
|
||||
in nsIPrintSettings printSettings);
|
||||
|
||||
};
|
||||
|
||||
%{C++
|
||||
// {260FEDC5-524D-4aa6-9A41-E829F4C78B92}
|
||||
#define NS_PRINTINGPROMPTSERVICE_IID \
|
||||
{0x260fedc5, 0x524d, 0x4aa6, { 0x9a, 0x41, 0xe8, 0x29, 0xf4, 0xc7, 0x8b, 0x92}}
|
||||
%}
|
||||
|
||||
44
embedding/browser/nsITooltipListener.idl
Normal file
44
embedding/browser/nsITooltipListener.idl
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; 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 "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* An optional interface for embedding clients wishing to receive
|
||||
* notifications for when a tooltip should be displayed or removed.
|
||||
* The embedder implements this interface on the web browser chrome
|
||||
* object associated with the window that notifications are required
|
||||
* for.
|
||||
*
|
||||
* @see nsITooltipTextProvider
|
||||
*/
|
||||
[scriptable, uuid(44b78386-1dd2-11b2-9ad2-e4eee2ca1916)]
|
||||
interface nsITooltipListener : nsISupports
|
||||
{
|
||||
/**
|
||||
* Called when a tooltip should be displayed.
|
||||
*
|
||||
* @param aXCoords The tooltip left edge X coordinate.
|
||||
* @param aYCoords The tooltip top edge Y coordinate.
|
||||
* @param aTipText The text to display in the tooltip, typically obtained
|
||||
* from the TITLE attribute of the node (or containing parent)
|
||||
* over which the pointer has been positioned.
|
||||
* @param aTipDir The direction (ltr or rtl) in which to display the text
|
||||
*
|
||||
* @note
|
||||
* Coordinates are specified in pixels, relative to the top-left
|
||||
* corner of the browser area.
|
||||
*
|
||||
* @return <code>NS_OK</code> if the tooltip was displayed.
|
||||
*/
|
||||
void onShowTooltip(in long aXCoords, in long aYCoords, in wstring aTipText,
|
||||
in wstring aTipDir);
|
||||
|
||||
/**
|
||||
* Called when the tooltip should be hidden, either because the pointer
|
||||
* has moved or the tooltip has timed out.
|
||||
*/
|
||||
void onHideTooltip();
|
||||
};
|
||||
44
embedding/browser/nsITooltipTextProvider.idl
Normal file
44
embedding/browser/nsITooltipTextProvider.idl
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* -*- Mode: C++; tab-width: 4; 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 "nsISupports.idl"
|
||||
|
||||
interface nsIDOMNode;
|
||||
|
||||
/**
|
||||
* An interface implemented by a tooltip text provider service. This
|
||||
* service is called to discover what tooltip text is associated
|
||||
* with the node that the pointer is positioned over.
|
||||
*
|
||||
* Embedders may implement and register their own tooltip text provider
|
||||
* service if they wish to provide different tooltip text.
|
||||
*
|
||||
* The default service returns the text stored in the TITLE
|
||||
* attribute of the node or a containing parent.
|
||||
*
|
||||
* @note
|
||||
* The tooltip text provider service is registered with the contract
|
||||
* defined in NS_TOOLTIPTEXTPROVIDER_CONTRACTID.
|
||||
*
|
||||
* @see nsITooltipListener
|
||||
* @see nsIComponentManager
|
||||
* @see nsIDOMNode
|
||||
*/
|
||||
[scriptable, uuid(b128a1e6-44f3-4331-8fbe-5af360ff21ee)]
|
||||
interface nsITooltipTextProvider : nsISupports
|
||||
{
|
||||
/**
|
||||
* Called to obtain the tooltip text for a node.
|
||||
*
|
||||
* @arg aNode The node to obtain the text from.
|
||||
* @arg aText The tooltip text.
|
||||
* @arg aDirection The text direction (ltr or rtl) to use
|
||||
*
|
||||
* @return <CODE>PR_TRUE</CODE> if tooltip text is associated
|
||||
* with the node and was returned in the aText argument;
|
||||
* <CODE>PR_FALSE</CODE> otherwise.
|
||||
*/
|
||||
boolean getNodeText(in nsIDOMNode aNode, out wstring aText, out wstring aDirection);
|
||||
};
|
||||
163
embedding/browser/nsIWebBrowser.idl
Normal file
163
embedding/browser/nsIWebBrowser.idl
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; 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 "nsISupports.idl"
|
||||
|
||||
interface nsIInterfaceRequestor;
|
||||
interface nsIWebBrowserChrome;
|
||||
interface nsIURIContentListener;
|
||||
interface nsIDOMWindow;
|
||||
interface mozIDOMWindowProxy;
|
||||
interface nsIWeakReference;
|
||||
|
||||
%{C++
|
||||
namespace mozilla {
|
||||
class DocShellOriginAttributes;
|
||||
}
|
||||
%}
|
||||
|
||||
[ref] native const_OriginAttributesRef(const mozilla::DocShellOriginAttributes);
|
||||
|
||||
/**
|
||||
* The nsIWebBrowser interface is implemented by web browser objects.
|
||||
* Embedders use this interface during initialisation to associate
|
||||
* the new web browser instance with the embedders chrome and
|
||||
* to register any listeners. The interface may also be used at runtime
|
||||
* to obtain the content DOM window and from that the rest of the DOM.
|
||||
*/
|
||||
[scriptable, uuid(4052b6da-4faa-4646-b3a1-7e16a01c2dc2)]
|
||||
interface nsIWebBrowser : nsISupports
|
||||
{
|
||||
/**
|
||||
* Registers a listener of the type specified by the iid to receive
|
||||
* callbacks. The browser stores a weak reference to the listener
|
||||
* to avoid any circular dependencies.
|
||||
* Typically this method will be called to register an object
|
||||
* to receive <CODE>nsIWebProgressListener</CODE> or
|
||||
* <CODE>nsISHistoryListener</CODE> notifications in which case the
|
||||
* the IID is that of the interface.
|
||||
*
|
||||
* @param aListener The listener to be added.
|
||||
* @param aIID The IID of the interface that will be called
|
||||
* on the listener as appropriate.
|
||||
* @return <CODE>NS_OK</CODE> for successful registration;
|
||||
* <CODE>NS_ERROR_INVALID_ARG</CODE> if aIID is not
|
||||
* supposed to be registered using this method;
|
||||
* <CODE>NS_ERROR_FAILURE</CODE> either aListener did not
|
||||
* expose the interface specified by the IID, or some
|
||||
* other internal error occurred.
|
||||
*
|
||||
* @see removeWebBrowserListener
|
||||
* @see nsIWeakReference
|
||||
* @see nsIWebProgressListener
|
||||
* @see nsISHistoryListener
|
||||
*
|
||||
* @return <CODE>NS_OK</CODE>, listener was successfully added;
|
||||
* <CODE>NS_ERROR_INVALID_ARG</CODE>, one of the arguments was
|
||||
* invalid or the object did not implement the interface
|
||||
* specified by the IID.
|
||||
*/
|
||||
void addWebBrowserListener(in nsIWeakReference aListener, in nsIIDRef aIID);
|
||||
|
||||
/**
|
||||
* Removes a previously registered listener.
|
||||
*
|
||||
* @param aListener The listener to be removed.
|
||||
* @param aIID The IID of the interface on the listener that will
|
||||
* no longer be called.
|
||||
*
|
||||
* @return <CODE>NS_OK</CODE>, listener was successfully removed;
|
||||
* <CODE>NS_ERROR_INVALID_ARG</CODE> arguments was invalid or
|
||||
* the object did not implement the interface specified by the IID.
|
||||
*
|
||||
* @see addWebBrowserListener
|
||||
* @see nsIWeakReference
|
||||
*/
|
||||
void removeWebBrowserListener(in nsIWeakReference aListener, in nsIIDRef aIID);
|
||||
|
||||
/**
|
||||
* The chrome object associated with the browser instance. The embedder
|
||||
* must create one chrome object for <I>each</I> browser object
|
||||
* that is instantiated. The embedder must associate the two by setting
|
||||
* this property to point to the chrome object before creating the browser
|
||||
* window via the browser's <CODE>nsIBaseWindow</CODE> interface.
|
||||
*
|
||||
* The chrome object must also implement <CODE>nsIEmbeddingSiteWindow</CODE>.
|
||||
*
|
||||
* The chrome may optionally implement <CODE>nsIInterfaceRequestor</CODE>,
|
||||
* <CODE>nsIWebBrowserChromeFocus</CODE>,
|
||||
* <CODE>nsIContextMenuListener</CODE> and
|
||||
* <CODE>nsITooltipListener</CODE> to receive additional notifications
|
||||
* from the browser object.
|
||||
*
|
||||
* The chrome object may optionally implement <CODE>nsIWebProgressListener</CODE>
|
||||
* instead of explicitly calling <CODE>addWebBrowserListener</CODE> and
|
||||
* <CODE>removeWebBrowserListener</CODE> to register a progress listener
|
||||
* object. If the implementation does this, it must also implement
|
||||
* <CODE>nsIWeakReference</CODE>.
|
||||
*
|
||||
* @note The implementation should not refcount the supplied chrome
|
||||
* object; it should assume that a non <CODE>nullptr</CODE> value is
|
||||
* always valid. The embedder must explicitly set this value back
|
||||
* to nullptr if the chrome object is destroyed before the browser
|
||||
* object.
|
||||
*
|
||||
* @see nsIBaseWindow
|
||||
* @see nsIWebBrowserChrome
|
||||
* @see nsIEmbeddingSiteWindow
|
||||
* @see nsIInterfaceRequestor
|
||||
* @see nsIWebBrowserChromeFocus
|
||||
* @see nsIContextMenuListener
|
||||
* @see nsITooltipListener
|
||||
* @see nsIWeakReference
|
||||
* @see nsIWebProgressListener
|
||||
*/
|
||||
attribute nsIWebBrowserChrome containerWindow;
|
||||
|
||||
/**
|
||||
* URI content listener parent. The embedder may set this property to
|
||||
* their own implementation if they intend to override or prevent
|
||||
* how certain kinds of content are loaded.
|
||||
*
|
||||
* @note If this attribute is set to an object that implements
|
||||
* nsISupportsWeakReference, the implementation should get the
|
||||
* nsIWeakReference and hold that. Otherwise, the implementation
|
||||
* should not refcount this interface; it should assume that a non
|
||||
* null value is always valid. In that case, the embedder should
|
||||
* explicitly set this value back to null if the parent content
|
||||
* listener is destroyed before the browser object.
|
||||
*
|
||||
* @see nsIURIContentListener
|
||||
*/
|
||||
attribute nsIURIContentListener parentURIContentListener;
|
||||
|
||||
/**
|
||||
* The top-level DOM window. The embedder may walk the entire
|
||||
* DOM starting from this value.
|
||||
*
|
||||
* @see nsIDOMWindow
|
||||
*/
|
||||
readonly attribute mozIDOMWindowProxy contentDOMWindow;
|
||||
|
||||
/**
|
||||
* Whether this web browser is active. Active means that it's visible
|
||||
* enough that we want to avoid certain optimizations like discarding
|
||||
* decoded image data and throttling the refresh driver. In Firefox,
|
||||
* this corresponds to the visible tab.
|
||||
*
|
||||
* Defaults to true. For optimal performance, set it to false when
|
||||
* appropriate.
|
||||
*/
|
||||
attribute boolean isActive;
|
||||
|
||||
/**
|
||||
* Set Origin Attributes on the nsIWebBrowser.
|
||||
* The Origin Attributes will be passed to the docshell once it has been
|
||||
* created
|
||||
*/
|
||||
[noscript, notxpcom, nostdcall, binaryname(SetOriginAttributes)]
|
||||
void binarySetOriginAttributes(in const_OriginAttributesRef aOriginAttrs);
|
||||
};
|
||||
147
embedding/browser/nsIWebBrowserChrome.idl
Normal file
147
embedding/browser/nsIWebBrowserChrome.idl
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; 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 "nsISupports.idl"
|
||||
|
||||
interface nsIWebBrowser;
|
||||
interface nsIDocShellTreeItem;
|
||||
|
||||
/**
|
||||
* nsIWebBrowserChrome corresponds to the top-level, outermost window
|
||||
* containing an embedded Gecko web browser.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(E8C414C4-DC38-4BA3-AB4E-EC4CBBE22907)]
|
||||
interface nsIWebBrowserChrome : nsISupports
|
||||
{
|
||||
const unsigned long STATUS_SCRIPT = 0x00000001;
|
||||
const unsigned long STATUS_LINK = 0x00000003;
|
||||
|
||||
/**
|
||||
* Called when the status text in the chrome needs to be updated.
|
||||
* @param statusType indicates what is setting the text
|
||||
* @param status status string. null is an acceptable value meaning
|
||||
* no status.
|
||||
*/
|
||||
void setStatus(in unsigned long statusType, in wstring status);
|
||||
|
||||
/**
|
||||
* The currently loaded WebBrowser. The browser chrome may be
|
||||
* told to set the WebBrowser object to a new object by setting this
|
||||
* attribute. In this case the implementer is responsible for taking the
|
||||
* new WebBrowser object and doing any necessary initialization or setup
|
||||
* as if it had created the WebBrowser itself. This includes positioning
|
||||
* setting up listeners etc.
|
||||
*/
|
||||
attribute nsIWebBrowser webBrowser;
|
||||
|
||||
/**
|
||||
* Definitions for the chrome flags
|
||||
*/
|
||||
const unsigned long CHROME_DEFAULT = 0x00000001;
|
||||
const unsigned long CHROME_WINDOW_BORDERS = 0x00000002;
|
||||
const unsigned long CHROME_WINDOW_CLOSE = 0x00000004;
|
||||
const unsigned long CHROME_WINDOW_RESIZE = 0x00000008;
|
||||
const unsigned long CHROME_MENUBAR = 0x00000010;
|
||||
const unsigned long CHROME_TOOLBAR = 0x00000020;
|
||||
const unsigned long CHROME_LOCATIONBAR = 0x00000040;
|
||||
const unsigned long CHROME_STATUSBAR = 0x00000080;
|
||||
const unsigned long CHROME_PERSONAL_TOOLBAR = 0x00000100;
|
||||
const unsigned long CHROME_SCROLLBARS = 0x00000200;
|
||||
const unsigned long CHROME_TITLEBAR = 0x00000400;
|
||||
const unsigned long CHROME_EXTRA = 0x00000800;
|
||||
|
||||
// createBrowserWindow specific flags
|
||||
const unsigned long CHROME_WITH_SIZE = 0x00001000;
|
||||
const unsigned long CHROME_WITH_POSITION = 0x00002000;
|
||||
|
||||
// special cases
|
||||
const unsigned long CHROME_WINDOW_MIN = 0x00004000;
|
||||
const unsigned long CHROME_WINDOW_POPUP = 0x00008000;
|
||||
|
||||
// whether to open a new private window. CHROME_NON_PRIVATE_WINDOW
|
||||
// forces the opened window to be non-private, and overrides
|
||||
// CHROME_PRIVATE_WINDOW if it's set. CHROME_PRIVATE_WINDOW
|
||||
// forces the opened window to be private. If neither of these
|
||||
// flags are specified, the opened window will inherit the privacy
|
||||
// status of its opener. If there is no opener window, the new
|
||||
// window will be non-private.
|
||||
//
|
||||
// CHROME_PRIVATE_LIFETIME causes the docshell to affect private-browsing
|
||||
// session lifetime. This flag is currently respected only for remote
|
||||
// docshells.
|
||||
const unsigned long CHROME_PRIVATE_WINDOW = 0x00010000;
|
||||
const unsigned long CHROME_NON_PRIVATE_WINDOW = 0x00020000;
|
||||
const unsigned long CHROME_PRIVATE_LIFETIME = 0x00040000;
|
||||
|
||||
// Whether this was opened by nsGlobalWindow::ShowModalDialog.
|
||||
const unsigned long CHROME_MODAL_CONTENT_WINDOW = 0x00080000;
|
||||
|
||||
// Whether this window should use remote (out-of-process) tabs.
|
||||
const unsigned long CHROME_REMOTE_WINDOW = 0x00100000;
|
||||
|
||||
// Prevents new window animations on Mac OS X Lion. Ignored on other
|
||||
// platforms.
|
||||
const unsigned long CHROME_MAC_SUPPRESS_ANIMATION = 0x01000000;
|
||||
|
||||
const unsigned long CHROME_WINDOW_RAISED = 0x02000000;
|
||||
const unsigned long CHROME_WINDOW_LOWERED = 0x04000000;
|
||||
const unsigned long CHROME_CENTER_SCREEN = 0x08000000;
|
||||
|
||||
// Make the new window dependent on the parent. This flag is only
|
||||
// meaningful if CHROME_OPENAS_CHROME is set; content windows should not be
|
||||
// dependent.
|
||||
const unsigned long CHROME_DEPENDENT = 0x10000000;
|
||||
|
||||
// Note: The modal style bit just affects the way the window looks and does
|
||||
// mean it's actually modal.
|
||||
const unsigned long CHROME_MODAL = 0x20000000;
|
||||
const unsigned long CHROME_OPENAS_DIALOG = 0x40000000;
|
||||
const unsigned long CHROME_OPENAS_CHROME = 0x80000000;
|
||||
|
||||
const unsigned long CHROME_ALL = 0x00000ffe;
|
||||
|
||||
/**
|
||||
* The chrome flags for this browser chrome. The implementation should
|
||||
* reflect the value of this attribute by hiding or showing its chrome
|
||||
* appropriately.
|
||||
*/
|
||||
attribute unsigned long chromeFlags;
|
||||
|
||||
/**
|
||||
* Asks the implementer to destroy the window associated with this
|
||||
* WebBrowser object.
|
||||
*/
|
||||
void destroyBrowserWindow();
|
||||
|
||||
/**
|
||||
* Tells the chrome to size itself such that the browser will be the
|
||||
* specified size.
|
||||
* @param aCX new width of the browser
|
||||
* @param aCY new height of the browser
|
||||
*/
|
||||
void sizeBrowserTo(in long aCX, in long aCY);
|
||||
|
||||
/**
|
||||
* Shows the window as a modal window.
|
||||
* @return (the function error code) the status value specified by
|
||||
* in exitModalEventLoop.
|
||||
*/
|
||||
void showAsModal();
|
||||
|
||||
/**
|
||||
* Is the window modal (that is, currently executing a modal loop)?
|
||||
* @return true if it's a modal window
|
||||
*/
|
||||
boolean isWindowModal();
|
||||
|
||||
/**
|
||||
* Exit a modal event loop if we're in one. The implementation
|
||||
* should also exit out of the loop if the window is destroyed.
|
||||
* @param aStatus - the result code to return from showAsModal
|
||||
*/
|
||||
void exitModalEventLoop(in nsresult aStatus);
|
||||
};
|
||||
33
embedding/browser/nsIWebBrowserChrome2.idl
Normal file
33
embedding/browser/nsIWebBrowserChrome2.idl
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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 "nsIWebBrowserChrome.idl"
|
||||
|
||||
/**
|
||||
* nsIWebBrowserChrome2 is an extension to nsIWebBrowserChrome.
|
||||
*/
|
||||
[scriptable, uuid(2585a7b1-7b47-43c4-bf17-c6bf84e09b7b)]
|
||||
interface nsIWebBrowserChrome2 : nsIWebBrowserChrome
|
||||
{
|
||||
/**
|
||||
* Called when the status text in the chrome needs to be updated. This
|
||||
* method may be called instead of nsIWebBrowserChrome::SetStatus. An
|
||||
* implementor of this method, should still implement SetStatus.
|
||||
*
|
||||
* @param statusType
|
||||
* Indicates what is setting the text.
|
||||
* @param status
|
||||
* Status string. Null is an acceptable value meaning no status.
|
||||
* @param contextNode
|
||||
* An object that provides context pertaining to the status type.
|
||||
* If statusType is STATUS_LINK, then statusContext may be a DOM
|
||||
* node corresponding to the source of the link. This value can
|
||||
* be null if there is no context.
|
||||
*/
|
||||
void setStatusWithContext(in unsigned long statusType,
|
||||
in AString statusText,
|
||||
in nsISupports statusContext);
|
||||
};
|
||||
61
embedding/browser/nsIWebBrowserChrome3.idl
Normal file
61
embedding/browser/nsIWebBrowserChrome3.idl
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* 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 "nsIWebBrowserChrome2.idl"
|
||||
#include "nsIURI.idl"
|
||||
#include "nsIDOMNode.idl"
|
||||
|
||||
interface nsIDocShell;
|
||||
interface nsIInputStream;
|
||||
|
||||
/**
|
||||
* nsIWebBrowserChrome3 is an extension to nsIWebBrowserChrome2.
|
||||
*/
|
||||
[scriptable, uuid(542b6625-35a9-426a-8257-c12a345383b0)]
|
||||
interface nsIWebBrowserChrome3 : nsIWebBrowserChrome2
|
||||
{
|
||||
/**
|
||||
* Determines the appropriate target for a link.
|
||||
*
|
||||
* @param originalTarget
|
||||
* The original link target.
|
||||
* @param linkURI
|
||||
* Link destination URI.
|
||||
* @param aDOMNode
|
||||
* Link DOM node.
|
||||
* @param isAppTab
|
||||
* Whether or not the link is in an app tab.
|
||||
* @returns A new link target, if appropriate.
|
||||
* Otherwise returns originalTarget.
|
||||
*/
|
||||
AString onBeforeLinkTraversal(in AString originalTarget,
|
||||
in nsIURI linkURI,
|
||||
in nsIDOMNode linkNode,
|
||||
in boolean isAppTab);
|
||||
|
||||
/**
|
||||
* Determines whether a load should continue.
|
||||
*
|
||||
* @param aDocShell
|
||||
* The docshell performing the load.
|
||||
* @param aURI
|
||||
* The URI being loaded.
|
||||
* @param aReferrer
|
||||
* The referrer of the load.
|
||||
*/
|
||||
bool shouldLoadURI(in nsIDocShell aDocShell,
|
||||
in nsIURI aURI,
|
||||
in nsIURI aReferrer);
|
||||
|
||||
/**
|
||||
* Attempts to load the currently loaded page into a fresh process to increase
|
||||
* available memory.
|
||||
*
|
||||
* @param aDocShell
|
||||
* The docshell performing the load.
|
||||
*/
|
||||
bool reloadInFreshProcess(in nsIDocShell aDocShell,
|
||||
in nsIURI aURI,
|
||||
in nsIURI aReferrer);
|
||||
};
|
||||
32
embedding/browser/nsIWebBrowserChromeFocus.idl
Normal file
32
embedding/browser/nsIWebBrowserChromeFocus.idl
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 0 -*-
|
||||
*
|
||||
* 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"
|
||||
|
||||
/**
|
||||
* The nsIWebBrowserChromeFocus is implemented by the same object as the
|
||||
* nsIEmbeddingSiteWindow. It represents the focus up-calls from mozilla
|
||||
* to the embedding chrome. See mozilla bug #70224 for gratuitous info.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(947B2EE6-51ED-4C2B-9F45-426C27CA84C6)]
|
||||
interface nsIWebBrowserChromeFocus : nsISupports
|
||||
{
|
||||
/**
|
||||
* Set the focus at the next focusable element in the chrome. If
|
||||
* aForDocumentNavigation is true, this was a document navigation, so
|
||||
* focus the parent window.
|
||||
*/
|
||||
|
||||
void focusNextElement(in bool aForDocumentNavigation);
|
||||
|
||||
/**
|
||||
* Set the focus at the previous focusable element in the chrome.
|
||||
*/
|
||||
|
||||
void focusPrevElement(in bool aForDocumentNavigation);
|
||||
|
||||
};
|
||||
76
embedding/browser/nsIWebBrowserFocus.idl
Normal file
76
embedding/browser/nsIWebBrowserFocus.idl
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; 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 mozIDOMWindowProxy;
|
||||
interface nsIDOMElement;
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* nsIWebBrowserFocus
|
||||
* Interface that embedders use for controlling and interacting
|
||||
* with the browser focus management. The embedded browser can be focused by
|
||||
* clicking in it or tabbing into it. If the browser is currently focused and
|
||||
* the embedding application's top level window is disabled, deactivate() must
|
||||
* be called, and activate() called again when the top level window is
|
||||
* reactivated for the browser's focus memory to work correctly.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(7f8c754e-5b36-44be-bc96-191b49f08ea6)]
|
||||
interface nsIWebBrowserFocus : nsISupports
|
||||
{
|
||||
/**
|
||||
* MANDATORY
|
||||
* activate() is a mandatory call that must be made to the browser
|
||||
* when the embedding application's window is activated *and* the
|
||||
* browser area was the last thing in focus. This method can also be called
|
||||
* if the embedding application wishes to give the browser area focus,
|
||||
* without affecting the currently focused element within the browser.
|
||||
*
|
||||
* @note
|
||||
* If you fail to make this call, mozilla focus memory will not work
|
||||
* correctly.
|
||||
*/
|
||||
void activate();
|
||||
|
||||
/**
|
||||
* MANDATORY
|
||||
* deactivate() is a mandatory call that must be made to the browser
|
||||
* when the embedding application's window is deactivated *and* the
|
||||
* browser area was the last thing in focus. On non-windows platforms,
|
||||
* deactivate() should also be called when focus moves from the browser
|
||||
* to the embedding chrome.
|
||||
*
|
||||
* @note
|
||||
* If you fail to make this call, mozilla focus memory will not work
|
||||
* correctly.
|
||||
*/
|
||||
void deactivate();
|
||||
|
||||
/**
|
||||
* Give the first element focus within mozilla
|
||||
* (i.e. TAB was pressed and focus should enter mozilla)
|
||||
*/
|
||||
void setFocusAtFirstElement();
|
||||
|
||||
/**
|
||||
* Give the last element focus within mozilla
|
||||
* (i.e. SHIFT-TAB was pressed and focus should enter mozilla)
|
||||
*/
|
||||
void setFocusAtLastElement();
|
||||
|
||||
/**
|
||||
* The currently focused nsDOMWindow when the browser is active,
|
||||
* or the last focused nsDOMWindow when the browser is inactive.
|
||||
*/
|
||||
attribute mozIDOMWindowProxy focusedWindow;
|
||||
|
||||
/**
|
||||
* The currently focused nsDOMElement when the browser is active,
|
||||
* or the last focused nsDOMElement when the browser is inactive.
|
||||
*/
|
||||
attribute nsIDOMElement focusedElement;
|
||||
};
|
||||
152
embedding/browser/nsIWebBrowserPrint.idl
Normal file
152
embedding/browser/nsIWebBrowserPrint.idl
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; 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 "nsISupports.idl"
|
||||
|
||||
interface mozIDOMWindowProxy;
|
||||
interface nsIPrintSettings;
|
||||
interface nsIWebProgressListener;
|
||||
|
||||
/**
|
||||
* nsIWebBrowserPrint corresponds to the main interface
|
||||
* for printing an embedded Gecko web browser window/document
|
||||
*/
|
||||
[scriptable, uuid(c9a934ed-fff1-4971-bfba-6c25ad70e1e6)]
|
||||
interface nsIWebBrowserPrint : nsISupports
|
||||
{
|
||||
/**
|
||||
* PrintPreview Navigation Constants
|
||||
*/
|
||||
const short PRINTPREVIEW_GOTO_PAGENUM = 0;
|
||||
const short PRINTPREVIEW_PREV_PAGE = 1;
|
||||
const short PRINTPREVIEW_NEXT_PAGE = 2;
|
||||
const short PRINTPREVIEW_HOME = 3;
|
||||
const short PRINTPREVIEW_END = 4;
|
||||
|
||||
/**
|
||||
* Returns a "global" PrintSettings object
|
||||
* Creates a new the first time, if one doesn't exist.
|
||||
*
|
||||
* Then returns the same object each time after that.
|
||||
*
|
||||
* Initializes the globalPrintSettings from the default printer
|
||||
*/
|
||||
readonly attribute nsIPrintSettings globalPrintSettings;
|
||||
|
||||
/**
|
||||
* Returns a pointer to the PrintSettings object that
|
||||
* that was passed into either "print" or "print preview"
|
||||
*
|
||||
* This enables any consumers of the interface to have access
|
||||
* to the "current" PrintSetting at later points in the execution
|
||||
*/
|
||||
readonly attribute nsIPrintSettings currentPrintSettings;
|
||||
|
||||
/**
|
||||
* Returns a pointer to the current child DOMWindow
|
||||
* that is being print previewed. (FrameSet Frames)
|
||||
*
|
||||
* Returns null if parent document is not a frameset or the entire FrameSet
|
||||
* document is being print previewed
|
||||
*
|
||||
* This enables any consumers of the interface to have access
|
||||
* to the "current" child DOMWindow at later points in the execution
|
||||
*/
|
||||
readonly attribute mozIDOMWindowProxy currentChildDOMWindow;
|
||||
|
||||
/**
|
||||
* Returns whether it is in Print mode
|
||||
*/
|
||||
readonly attribute boolean doingPrint;
|
||||
|
||||
/**
|
||||
* Returns whether it is in Print Preview mode
|
||||
*/
|
||||
readonly attribute boolean doingPrintPreview;
|
||||
|
||||
/**
|
||||
* This returns whether the current document is a frameset document
|
||||
*/
|
||||
readonly attribute boolean isFramesetDocument;
|
||||
|
||||
/**
|
||||
* This returns whether the current document is a frameset document
|
||||
*/
|
||||
readonly attribute boolean isFramesetFrameSelected;
|
||||
|
||||
/**
|
||||
* This returns whether there is an IFrame selected
|
||||
*/
|
||||
readonly attribute boolean isIFrameSelected;
|
||||
|
||||
/**
|
||||
* This returns whether there is a "range" selection
|
||||
*/
|
||||
readonly attribute boolean isRangeSelection;
|
||||
|
||||
/**
|
||||
* This returns the total number of pages for the Print Preview
|
||||
*/
|
||||
readonly attribute long printPreviewNumPages;
|
||||
|
||||
/**
|
||||
* Print the specified DOM window
|
||||
*
|
||||
* @param aThePrintSettings - Printer Settings for the print job, if aThePrintSettings is null
|
||||
* then the global PS will be used.
|
||||
* @param aWPListener - is updated during the print
|
||||
* @return void
|
||||
*/
|
||||
void print(in nsIPrintSettings aThePrintSettings,
|
||||
in nsIWebProgressListener aWPListener);
|
||||
|
||||
/**
|
||||
* Print Preview the specified DOM window
|
||||
*
|
||||
* @param aThePrintSettings - Printer Settings for the print preview, if aThePrintSettings is null
|
||||
* then the global PS will be used.
|
||||
* @param aChildDOMWin - DOM Window to be print previewed.
|
||||
* @param aWPListener - is updated during the printpreview
|
||||
* @return void
|
||||
*/
|
||||
void printPreview(in nsIPrintSettings aThePrintSettings,
|
||||
in mozIDOMWindowProxy aChildDOMWin,
|
||||
in nsIWebProgressListener aWPListener);
|
||||
|
||||
/**
|
||||
* Print Preview - Navigates within the window
|
||||
*
|
||||
* @param aNavType - navigation enum
|
||||
* @param aPageNum - page num to navigate to when aNavType = ePrintPreviewGoToPageNum
|
||||
* @return void
|
||||
*/
|
||||
void printPreviewNavigate(in short aNavType, in long aPageNum);
|
||||
|
||||
/**
|
||||
* Cancels the current print
|
||||
* @return void
|
||||
*/
|
||||
void cancel();
|
||||
|
||||
/**
|
||||
* Returns an array of the names of all documents names (Title or URL)
|
||||
* and sub-documents. This will return a single item if the attr "isFramesetDocument" is false
|
||||
* and may return any number of items is "isFramesetDocument" is true
|
||||
*
|
||||
* @param aCount - returns number of printers returned
|
||||
* @param aResult - returns array of names
|
||||
* @return void
|
||||
*/
|
||||
void enumerateDocumentNames(out uint32_t aCount,[retval, array, size_is(aCount)] out wstring aResult);
|
||||
|
||||
/**
|
||||
* This exists PrintPreview mode and returns browser window to galley mode
|
||||
* @return void
|
||||
*/
|
||||
void exitPrintPreview();
|
||||
|
||||
};
|
||||
|
||||
109
embedding/browser/nsIWebBrowserSetup.idl
Normal file
109
embedding/browser/nsIWebBrowserSetup.idl
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/* -*- Mode: IDL; 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"
|
||||
|
||||
/**
|
||||
* The nsIWebBrowserSetup interface lets you set properties on a browser
|
||||
* object; you can do so at any time during the life cycle of the browser.
|
||||
*
|
||||
* @note Unless stated otherwise, settings are presumed to be enabled by
|
||||
* default.
|
||||
*/
|
||||
[scriptable, uuid(F15398A0-8018-11d3-AF70-00A024FFC08C)]
|
||||
interface nsIWebBrowserSetup : nsISupports
|
||||
{
|
||||
/**
|
||||
* Boolean. Enables/disables plugin support for this browser.
|
||||
*
|
||||
* @see setProperty
|
||||
*/
|
||||
const unsigned long SETUP_ALLOW_PLUGINS = 1;
|
||||
|
||||
/**
|
||||
* Boolean. Enables/disables Javascript support for this browser.
|
||||
*
|
||||
* @see setProperty
|
||||
*/
|
||||
const unsigned long SETUP_ALLOW_JAVASCRIPT = 2;
|
||||
|
||||
/**
|
||||
* Boolean. Enables/disables meta redirect support for this browser.
|
||||
* Meta redirect timers will be ignored if this option is disabled.
|
||||
*
|
||||
* @see setProperty
|
||||
*/
|
||||
const unsigned long SETUP_ALLOW_META_REDIRECTS = 3;
|
||||
|
||||
/**
|
||||
* Boolean. Enables/disables subframes within the browser
|
||||
*
|
||||
* @see setProperty
|
||||
*/
|
||||
const unsigned long SETUP_ALLOW_SUBFRAMES = 4;
|
||||
|
||||
/**
|
||||
* Boolean. Enables/disables image loading for this browser
|
||||
* window. If you disable the images, load a page, then enable the images,
|
||||
* the page will *not* automatically load the images for the previously
|
||||
* loaded page. This flag controls the state of a webBrowser at load time
|
||||
* and does not automatically re-load a page when the state is toggled.
|
||||
* Reloading must be done by hand, or by walking through the DOM tree and
|
||||
* re-setting the src attributes.
|
||||
*
|
||||
* @see setProperty
|
||||
*/
|
||||
const unsigned long SETUP_ALLOW_IMAGES = 5;
|
||||
|
||||
/**
|
||||
* Boolean. Enables/disables whether the document as a whole gets focus before
|
||||
* traversing the document's content, or after traversing its content.
|
||||
*
|
||||
* NOTE: this property is obsolete and now has no effect
|
||||
*
|
||||
* @see setProperty
|
||||
*/
|
||||
const unsigned long SETUP_FOCUS_DOC_BEFORE_CONTENT = 6;
|
||||
|
||||
/**
|
||||
* Boolean. Enables/disables the use of global history in the browser. Visited
|
||||
* URLs will not be recorded in the global history when it is disabled.
|
||||
*
|
||||
* @see setProperty
|
||||
*/
|
||||
const unsigned long SETUP_USE_GLOBAL_HISTORY = 256;
|
||||
|
||||
/**
|
||||
* Boolean. A value of PR_TRUE makes the browser a chrome wrapper.
|
||||
* Default is PR_FALSE.
|
||||
*
|
||||
* @since mozilla1.0
|
||||
*
|
||||
* @see setProperty
|
||||
*/
|
||||
const unsigned long SETUP_IS_CHROME_WRAPPER = 7;
|
||||
|
||||
|
||||
/**
|
||||
* Boolean. Enables/disables DNS prefetch for HTML anchors in this browser.
|
||||
* This takes effect starting with the next pageload after the property is
|
||||
* set. The default is to not allow DNS prefetch, for backwards
|
||||
* compatibility.
|
||||
*
|
||||
* @see setProperty
|
||||
*/
|
||||
const unsigned long SETUP_ALLOW_DNS_PREFETCH = 8;
|
||||
|
||||
/**
|
||||
* Sets an integer or boolean property on the new web browser object.
|
||||
* Only PR_TRUE and PR_FALSE are legal boolean values.
|
||||
*
|
||||
* @param aId The identifier of the property to be set.
|
||||
* @param aValue The value of the property.
|
||||
*/
|
||||
void setProperty(in unsigned long aId, in unsigned long aValue);
|
||||
};
|
||||
|
||||
56
embedding/browser/nsIWebBrowserStream.idl
Normal file
56
embedding/browser/nsIWebBrowserStream.idl
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: C; tab-width: 2; 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"
|
||||
|
||||
interface nsIURI;
|
||||
|
||||
/**
|
||||
* This interface provides a way to stream data to the web browser. This allows
|
||||
* loading of data from sources which can not be accessed using URIs and
|
||||
* nsIWebNavigation.
|
||||
*/
|
||||
[scriptable, uuid(86d02f0e-219b-4cfc-9c88-bd98d2cce0b8)]
|
||||
interface nsIWebBrowserStream : nsISupports
|
||||
{
|
||||
/**
|
||||
* Prepare to load a stream of data. When this function returns successfully,
|
||||
* it must be paired by a call to closeStream.
|
||||
*
|
||||
* @param aBaseURI
|
||||
* The base URI of the data. Must not be null. Relative
|
||||
* URIs will be resolved relative to this URI.
|
||||
* @param aContentType
|
||||
* ASCII string giving the content type of the data. If rendering
|
||||
* content of this type is not supported, this method fails.
|
||||
* This string may include a charset declaration, for example:
|
||||
* text/html;charset=ISO-8859-1
|
||||
*
|
||||
* @throw NS_ERROR_NOT_AVAILABLE
|
||||
* The requested content type is not supported.
|
||||
* @throw NS_ERROR_IN_PROGRESS
|
||||
* openStream was called twice without an intermediate closeStream.
|
||||
*/
|
||||
void openStream(in nsIURI aBaseURI, in ACString aContentType);
|
||||
|
||||
/**
|
||||
* Append data to this stream.
|
||||
* @param aData The data to append
|
||||
* @param aLen Length of the data to append.
|
||||
*
|
||||
* @note To append more than 4 GB of data, call this method multiple times.
|
||||
*/
|
||||
void appendToStream([const, array, size_is(aLen)] in octet aData,
|
||||
in unsigned long aLen);
|
||||
|
||||
/**
|
||||
* Notifies the browser that all the data has been appended. This may notify
|
||||
* the user that the browser is "done loading" in some form.
|
||||
*
|
||||
* @throw NS_ERROR_UNEXPECTED
|
||||
* This method was called without a preceding openStream.
|
||||
*/
|
||||
void closeStream();
|
||||
};
|
||||
1952
embedding/browser/nsWebBrowser.cpp
Normal file
1952
embedding/browser/nsWebBrowser.cpp
Normal file
File diff suppressed because it is too large
Load diff
185
embedding/browser/nsWebBrowser.h
Normal file
185
embedding/browser/nsWebBrowser.h
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 nsWebBrowser_h__
|
||||
#define nsWebBrowser_h__
|
||||
|
||||
// Local Includes
|
||||
#include "nsDocShellTreeOwner.h"
|
||||
|
||||
// Core Includes
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
// Interfaces needed
|
||||
#include "nsCWebBrowser.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIScrollable.h"
|
||||
#include "nsISHistory.h"
|
||||
#include "nsITextScroll.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsISecureBrowserUI.h"
|
||||
#include "nsIWebBrowser.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWebBrowserSetup.h"
|
||||
#include "nsIWebBrowserPersist.h"
|
||||
#include "nsIWebBrowserFocus.h"
|
||||
#include "nsIWebBrowserStream.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIPrintSettings.h"
|
||||
#include "nsEmbedStream.h"
|
||||
#include "nsIWidgetListener.h"
|
||||
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsWeakPtr.h"
|
||||
|
||||
class nsWebBrowserInitInfo
|
||||
{
|
||||
public:
|
||||
// nsIBaseWindow Stuff
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t cx;
|
||||
int32_t cy;
|
||||
bool visible;
|
||||
nsCOMPtr<nsISHistory> sessionHistory;
|
||||
nsString name;
|
||||
};
|
||||
|
||||
class nsWebBrowserListenerState
|
||||
{
|
||||
public:
|
||||
bool Equals(nsIWeakReference* aListener, const nsIID& aID)
|
||||
{
|
||||
return mWeakPtr.get() == aListener && mID.Equals(aID);
|
||||
}
|
||||
|
||||
nsWeakPtr mWeakPtr;
|
||||
nsIID mID;
|
||||
};
|
||||
|
||||
// {cda5863a-aa9c-411e-be49-ea0d525ab4b5} -
|
||||
#define NS_WEBBROWSER_CID \
|
||||
{ 0xcda5863a, 0xaa9c, 0x411e, { 0xbe, 0x49, 0xea, 0x0d, 0x52, 0x5a, 0xb4, 0xb5 } }
|
||||
|
||||
|
||||
class nsWebBrowser final : public nsIWebBrowser,
|
||||
public nsIWebNavigation,
|
||||
public nsIWebBrowserSetup,
|
||||
public nsIDocShellTreeItem,
|
||||
public nsIBaseWindow,
|
||||
public nsIScrollable,
|
||||
public nsITextScroll,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIWebBrowserPersist,
|
||||
public nsIWebBrowserFocus,
|
||||
public nsIWebProgressListener,
|
||||
public nsIWebBrowserStream,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
friend class nsDocShellTreeOwner;
|
||||
|
||||
public:
|
||||
|
||||
// The implementation of non-refcounted nsIWidgetListener, which would hold a
|
||||
// strong reference on stack before calling nsWebBrowser.
|
||||
class WidgetListenerDelegate : public nsIWidgetListener
|
||||
{
|
||||
public:
|
||||
explicit WidgetListenerDelegate(nsWebBrowser* aWebBrowser)
|
||||
: mWebBrowser(aWebBrowser) {}
|
||||
virtual bool PaintWindow(
|
||||
nsIWidget* aWidget, mozilla::LayoutDeviceIntRegion aRegion) override;
|
||||
|
||||
private:
|
||||
// The lifetime of WidgetListenerDelegate is bound to nsWebBrowser so we
|
||||
// just use raw pointer here.
|
||||
nsWebBrowser* mWebBrowser;
|
||||
};
|
||||
|
||||
nsWebBrowser();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSIBASEWINDOW
|
||||
NS_DECL_NSIDOCSHELLTREEITEM
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
NS_DECL_NSISCROLLABLE
|
||||
NS_DECL_NSITEXTSCROLL
|
||||
NS_DECL_NSIWEBBROWSER
|
||||
NS_DECL_NSIWEBNAVIGATION
|
||||
NS_DECL_NSIWEBBROWSERSETUP
|
||||
NS_DECL_NSIWEBBROWSERPERSIST
|
||||
NS_DECL_NSICANCELABLE
|
||||
NS_DECL_NSIWEBBROWSERFOCUS
|
||||
NS_DECL_NSIWEBBROWSERSTREAM
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
protected:
|
||||
virtual ~nsWebBrowser();
|
||||
NS_IMETHOD InternalDestroy();
|
||||
|
||||
// XXXbz why are these NS_IMETHOD? They're not interface methods!
|
||||
NS_IMETHOD SetDocShell(nsIDocShell* aDocShell);
|
||||
NS_IMETHOD EnsureDocShellTreeOwner();
|
||||
NS_IMETHOD BindListener(nsISupports* aListener, const nsIID& aIID);
|
||||
NS_IMETHOD UnBindListener(nsISupports* aListener, const nsIID& aIID);
|
||||
NS_IMETHOD EnableGlobalHistory(bool aEnable);
|
||||
|
||||
// nsIWidgetListener
|
||||
virtual void WindowRaised(nsIWidget* aWidget);
|
||||
virtual void WindowLowered(nsIWidget* aWidget);
|
||||
bool PaintWindow(nsIWidget* aWidget, mozilla::LayoutDeviceIntRegion aRegion);
|
||||
|
||||
protected:
|
||||
RefPtr<nsDocShellTreeOwner> mDocShellTreeOwner;
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
nsCOMPtr<nsIInterfaceRequestor> mDocShellAsReq;
|
||||
nsCOMPtr<nsIBaseWindow> mDocShellAsWin;
|
||||
nsCOMPtr<nsIWebNavigation> mDocShellAsNav;
|
||||
nsCOMPtr<nsIScrollable> mDocShellAsScrollable;
|
||||
nsCOMPtr<nsITextScroll> mDocShellAsTextScroll;
|
||||
mozilla::DocShellOriginAttributes mOriginAttributes;
|
||||
|
||||
nsCOMPtr<nsIWidget> mInternalWidget;
|
||||
nsCOMPtr<nsIWindowWatcher> mWWatch;
|
||||
nsAutoPtr<nsWebBrowserInitInfo> mInitInfo;
|
||||
uint32_t mContentType;
|
||||
bool mActivating;
|
||||
bool mShouldEnableHistory;
|
||||
bool mIsActive;
|
||||
nativeWindow mParentNativeWindow;
|
||||
nsIWebProgressListener* mProgressListener;
|
||||
nsCOMPtr<nsIWebProgress> mWebProgress;
|
||||
|
||||
nsCOMPtr<nsIPrintSettings> mPrintSettings;
|
||||
|
||||
WidgetListenerDelegate mWidgetListenerDelegate;
|
||||
|
||||
// cached background color
|
||||
nscolor mBackgroundColor;
|
||||
|
||||
// persistence object
|
||||
nsCOMPtr<nsIWebBrowserPersist> mPersist;
|
||||
uint32_t mPersistCurrentState;
|
||||
nsresult mPersistResult;
|
||||
uint32_t mPersistFlags;
|
||||
|
||||
// stream
|
||||
RefPtr<nsEmbedStream> mStream;
|
||||
|
||||
// Weak Reference interfaces...
|
||||
nsIWidget* mParentWidget;
|
||||
nsAutoPtr<nsTArray<nsWebBrowserListenerState> > mListenerArray;
|
||||
};
|
||||
|
||||
#endif /* nsWebBrowser_h__ */
|
||||
108
embedding/browser/nsWebBrowserContentPolicy.cpp
Normal file
108
embedding/browser/nsWebBrowserContentPolicy.cpp
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 "nsWebBrowserContentPolicy.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsIContentViewer.h"
|
||||
|
||||
nsWebBrowserContentPolicy::nsWebBrowserContentPolicy()
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsWebBrowserContentPolicy);
|
||||
}
|
||||
|
||||
nsWebBrowserContentPolicy::~nsWebBrowserContentPolicy()
|
||||
{
|
||||
MOZ_COUNT_DTOR(nsWebBrowserContentPolicy);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsWebBrowserContentPolicy, nsIContentPolicy)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowserContentPolicy::ShouldLoad(uint32_t aContentType,
|
||||
nsIURI* aContentLocation,
|
||||
nsIURI* aRequestingLocation,
|
||||
nsISupports* aRequestingContext,
|
||||
const nsACString& aMimeGuess,
|
||||
nsISupports* aExtra,
|
||||
nsIPrincipal* aRequestPrincipal,
|
||||
int16_t* aShouldLoad)
|
||||
{
|
||||
NS_PRECONDITION(aShouldLoad, "Null out param");
|
||||
|
||||
MOZ_ASSERT(aContentType == nsContentUtils::InternalContentPolicyTypeToExternal(aContentType),
|
||||
"We should only see external content policy types here.");
|
||||
|
||||
*aShouldLoad = nsIContentPolicy::ACCEPT;
|
||||
|
||||
nsIDocShell* shell = NS_CP_GetDocShellFromContext(aRequestingContext);
|
||||
/* We're going to dereference shell, so make sure it isn't null */
|
||||
if (!shell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
bool allowed = true;
|
||||
|
||||
switch (aContentType) {
|
||||
case nsIContentPolicy::TYPE_SCRIPT:
|
||||
rv = shell->GetAllowJavascript(&allowed);
|
||||
break;
|
||||
case nsIContentPolicy::TYPE_SUBDOCUMENT:
|
||||
rv = shell->GetAllowSubframes(&allowed);
|
||||
break;
|
||||
#if 0
|
||||
/* XXXtw: commented out in old code; add during conpol phase 2 */
|
||||
case nsIContentPolicy::TYPE_REFRESH:
|
||||
rv = shell->GetAllowMetaRedirects(&allowed); /* meta _refresh_ */
|
||||
break;
|
||||
#endif
|
||||
case nsIContentPolicy::TYPE_IMAGE:
|
||||
case nsIContentPolicy::TYPE_IMAGESET:
|
||||
rv = shell->GetAllowImages(&allowed);
|
||||
break;
|
||||
default:
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !allowed) {
|
||||
*aShouldLoad = nsIContentPolicy::REJECT_TYPE;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowserContentPolicy::ShouldProcess(uint32_t aContentType,
|
||||
nsIURI* aContentLocation,
|
||||
nsIURI* aRequestingLocation,
|
||||
nsISupports* aRequestingContext,
|
||||
const nsACString& aMimeGuess,
|
||||
nsISupports* aExtra,
|
||||
nsIPrincipal* aRequestPrincipal,
|
||||
int16_t* aShouldProcess)
|
||||
{
|
||||
NS_PRECONDITION(aShouldProcess, "Null out param");
|
||||
|
||||
MOZ_ASSERT(aContentType == nsContentUtils::InternalContentPolicyTypeToExternal(aContentType),
|
||||
"We should only see external content policy types here.");
|
||||
|
||||
*aShouldProcess = nsIContentPolicy::ACCEPT;
|
||||
|
||||
// Object tags will always open channels with TYPE_OBJECT, but may end up
|
||||
// loading with TYPE_IMAGE or TYPE_DOCUMENT as their final type, so we block
|
||||
// actual-plugins at the process stage
|
||||
if (aContentType != nsIContentPolicy::TYPE_OBJECT) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDocShell* shell = NS_CP_GetDocShellFromContext(aRequestingContext);
|
||||
if (shell && (!shell->PluginsAllowedInCurrentDoc())) {
|
||||
*aShouldProcess = nsIContentPolicy::REJECT_TYPE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
26
embedding/browser/nsWebBrowserContentPolicy.h
Normal file
26
embedding/browser/nsWebBrowserContentPolicy.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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 "nsIContentPolicy.h"
|
||||
|
||||
/* f66bc334-1dd1-11b2-bab2-90e04fe15c19 */
|
||||
#define NS_WEBBROWSERCONTENTPOLICY_CID \
|
||||
{ 0xf66bc334, 0x1dd1, 0x11b2, { 0xba, 0xb2, 0x90, 0xe0, 0x4f, 0xe1, 0x5c, 0x19 } }
|
||||
|
||||
#define NS_WEBBROWSERCONTENTPOLICY_CONTRACTID \
|
||||
"@mozilla.org/embedding/browser/content-policy;1"
|
||||
|
||||
class nsWebBrowserContentPolicy : public nsIContentPolicy
|
||||
{
|
||||
protected:
|
||||
virtual ~nsWebBrowserContentPolicy();
|
||||
|
||||
public:
|
||||
nsWebBrowserContentPolicy();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONTENTPOLICY
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue