mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out 2 changesets (bug 1060529) for introducing a new intermittent bc1 orange
Backed out changeset 5ddd9eb25925 (bug 1060529) Backed out changeset d4f962fb38be (bug 1060529)
This commit is contained in:
parent
67a948adf5
commit
a15fb273c2
@ -490,5 +490,4 @@ skip-if = e10s # Bug 1100687 - test directly manipulates content (content.docume
|
||||
skip-if = e10s # bug 1100687 - test directly manipulates content (content.document.getElementById)
|
||||
[browser_mcb_redirect.js]
|
||||
skip-if = e10s # bug 1084504 - [e10s] Mixed content detection does not take redirection into account
|
||||
[browser_updatecommands.js]
|
||||
[browser_windowactivation.js]
|
||||
|
@ -1,93 +0,0 @@
|
||||
let testPage = "data:text/html,<body><input id='input1' value='value'><select size=2><option val=1>One</select></body>";
|
||||
|
||||
let browser;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gURLBar.focus();
|
||||
|
||||
var tab = gBrowser.addTab();
|
||||
browser = gBrowser.getBrowserForTab(tab);
|
||||
gBrowser.selectedTab = tab;
|
||||
|
||||
addEventListener("commandupdate", checkTest, false);
|
||||
|
||||
function runFirstTest(event) {
|
||||
browser.removeEventListener("load", runFirstTest, true);
|
||||
doTest();
|
||||
}
|
||||
|
||||
browser.addEventListener("load", runFirstTest, true);
|
||||
browser.contentWindow.location = testPage;
|
||||
}
|
||||
|
||||
let currentTest;
|
||||
|
||||
let tests = [
|
||||
// Switch focus to 'input1'. Paste and select all should be enabled.
|
||||
{ name: "focus input", test: function() { EventUtils.synthesizeKey("VK_TAB", {}) },
|
||||
commands: { "cmd_copy" : true, "cmd_paste": true, "cmd_selectAll" : true, "cmd_undo" : false, "cmd_redo": false } },
|
||||
|
||||
// Move cursor to end which will deselect the text. Copy should be disabled but paste and select all should still be enabled.
|
||||
{ name: "cursor right", test: function() { EventUtils.synthesizeKey("VK_RIGHT", {}) },
|
||||
commands: { "cmd_copy" : false, "cmd_paste": true, "cmd_selectAll" : true, "cmd_undo" : false, "cmd_redo": false } },
|
||||
|
||||
// Select all of the text. Copy should become enabled.
|
||||
{ name: "select all", test: function() { EventUtils.synthesizeKey("a", { accelKey: true }) },
|
||||
commands: { "cmd_copy" : true, "cmd_paste": true, "cmd_selectAll" : true, "cmd_undo" : false, "cmd_redo": false } },
|
||||
|
||||
// Replace the text with 'c'. Copy should now be disabled and undo enabled.
|
||||
{ name: "change value", test: function() { EventUtils.synthesizeKey("c", {}) },
|
||||
commands: { "cmd_copy" : false, "cmd_paste": true, "cmd_selectAll" : true, "cmd_undo" : true, "cmd_redo": false } },
|
||||
|
||||
// Undo. Undo should be disabled and redo enabled. The text is reselected so copy is enabled.
|
||||
{ name: "undo", test: function() { EventUtils.synthesizeKey("z", {accelKey: true }) },
|
||||
commands: { "cmd_copy" : true, "cmd_paste": true, "cmd_selectAll" : true, "cmd_undo" : false, "cmd_redo": true } },
|
||||
|
||||
// Switch focus to the select. Only select all should now be enabled.
|
||||
{ name: "focus select", test: function() { EventUtils.synthesizeKey("VK_TAB", {}) },
|
||||
commands: { "cmd_copy" : false, "cmd_paste": false, "cmd_selectAll" : true, "cmd_undo" : false, "cmd_redo": false } },
|
||||
];
|
||||
|
||||
function doTest()
|
||||
{
|
||||
if (!tests.length) {
|
||||
removeEventListener("commandupdate", checkTest, false);
|
||||
gBrowser.removeCurrentTab();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
currentTest = tests.shift();
|
||||
currentTest.test();
|
||||
}
|
||||
|
||||
function checkTest(event)
|
||||
{
|
||||
// Ignore commandupdates before the test starts
|
||||
if (document.activeElement != browser || !currentTest) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip events fired on command updaters other than the main edit menu one.
|
||||
if (event.target != document.getElementById("editMenuCommandSetAll")) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let command in currentTest.commands) {
|
||||
// Command updates can come several at a time, and, especially with multiple
|
||||
// processes, the updates can come asynchronously. Handle this by just waiting
|
||||
// until the command have the correct state. The test will timeout if the
|
||||
// correct command update never occurs.
|
||||
if ((document.getElementById(command).getAttribute("disabled") != "true") != currentTest.commands[command]) {
|
||||
return;
|
||||
}
|
||||
|
||||
is(document.getElementById(command).getAttribute("disabled") != "true", currentTest.commands[command],
|
||||
currentTest["name"] + " " + command);
|
||||
}
|
||||
|
||||
currentTest = null; // prevent the check from running again
|
||||
SimpleTest.executeSoon(doTest);
|
||||
}
|
@ -26,7 +26,6 @@
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsCaret.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsViewManager.h"
|
||||
#include "nsFrameSelection.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
@ -735,10 +734,7 @@ nsFocusManager::WindowRaised(nsIDOMWindow* aWindow)
|
||||
frameSelection->SetDragState(false);
|
||||
}
|
||||
|
||||
// If there is no nsIXULWindow, then this is an embedded or child process window.
|
||||
// Pass false for aWindowRaised so that commands get updated.
|
||||
nsCOMPtr<nsIXULWindow> xulWin(do_GetInterface(baseWindow));
|
||||
Focus(currentWindow, currentFocus, 0, true, false, xulWin != nullptr, true);
|
||||
Focus(currentWindow, currentFocus, 0, true, false, true, true);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -9270,36 +9270,6 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aURI, nsIVariant *aArgs_,
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
class ChildCommandDispatcher : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ChildCommandDispatcher(nsGlobalWindow* aWindow,
|
||||
nsITabChild* aTabChild,
|
||||
const nsAString& aAction)
|
||||
: mWindow(aWindow), mTabChild(aTabChild), mAction(aAction) {}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
nsCOMPtr<nsPIWindowRoot> root = mWindow->GetTopWindowRoot();
|
||||
if (!root) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsTArray<nsCString> enabledCommands, disabledCommands;
|
||||
root->GetEnabledDisabledCommands(enabledCommands, disabledCommands);
|
||||
if (enabledCommands.Length() || disabledCommands.Length()) {
|
||||
mTabChild->EnableDisableCommands(mAction, enabledCommands, disabledCommands);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<nsGlobalWindow> mWindow;
|
||||
nsCOMPtr<nsITabChild> mTabChild;
|
||||
nsString mAction;
|
||||
};
|
||||
|
||||
class CommandDispatcher : public nsRunnable
|
||||
{
|
||||
public:
|
||||
@ -9319,12 +9289,6 @@ public:
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::UpdateCommands(const nsAString& anAction, nsISelection* aSel, int16_t aReason)
|
||||
{
|
||||
// If this is a child process, redirect to the parent process.
|
||||
if (nsCOMPtr<nsITabChild> child = do_GetInterface(GetDocShell())) {
|
||||
nsContentUtils::AddScriptRunner(new ChildCommandDispatcher(this, child, anAction));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsPIDOMWindow *rootWindow = nsGlobalWindow::GetPrivateRoot();
|
||||
if (!rootWindow)
|
||||
return NS_OK;
|
||||
|
@ -15,8 +15,8 @@ class nsIControllers;
|
||||
class nsIController;
|
||||
|
||||
#define NS_IWINDOWROOT_IID \
|
||||
{ 0x728a2682, 0x55c0, 0x4860, \
|
||||
{ 0x82, 0x6b, 0x0c, 0x30, 0x0a, 0xac, 0xaa, 0x60 } }
|
||||
{ 0x3f71f50c, 0xa7e0, 0x43bc, \
|
||||
{ 0xac, 0x25, 0x4d, 0xbb, 0x88, 0x7b, 0x21, 0x09 } }
|
||||
|
||||
class nsPIWindowRoot : public mozilla::dom::EventTarget
|
||||
{
|
||||
@ -33,9 +33,6 @@ public:
|
||||
nsIController** aResult) = 0;
|
||||
virtual nsresult GetControllers(nsIControllers** aResult) = 0;
|
||||
|
||||
virtual void GetEnabledDisabledCommands(nsTArray<nsCString>& aEnabledCommands,
|
||||
nsTArray<nsCString>& aDisabledCommands) = 0;
|
||||
|
||||
virtual void SetParentTarget(mozilla::dom::EventTarget* aTarget) = 0;
|
||||
virtual mozilla::dom::EventTarget* GetParentTarget() = 0;
|
||||
virtual nsIDOMWindow* GetOwnerGlobal() MOZ_OVERRIDE = 0;
|
||||
|
@ -281,75 +281,6 @@ nsWindowRoot::GetControllerForCommand(const char * aCommand,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsWindowRoot::GetEnabledDisabledCommandsForControllers(nsIControllers* aControllers,
|
||||
nsTHashtable<nsCharPtrHashKey>& aCommandsHandled,
|
||||
nsTArray<nsCString>& aEnabledCommands,
|
||||
nsTArray<nsCString>& aDisabledCommands)
|
||||
{
|
||||
uint32_t controllerCount;
|
||||
aControllers->GetControllerCount(&controllerCount);
|
||||
for (uint32_t c = 0; c < controllerCount; c++) {
|
||||
nsCOMPtr<nsIController> controller;
|
||||
aControllers->GetControllerAt(c, getter_AddRefs(controller));
|
||||
|
||||
nsCOMPtr<nsICommandController> commandController(do_QueryInterface(controller));
|
||||
if (commandController) {
|
||||
uint32_t commandsCount;
|
||||
char** commands;
|
||||
if (NS_SUCCEEDED(commandController->GetSupportedCommands(&commandsCount, &commands))) {
|
||||
for (uint32_t e = 0; e < commandsCount; e++) {
|
||||
// Use a hash to determine which commands have already been handled by
|
||||
// earlier controllers, as the earlier controller's result should get
|
||||
// priority.
|
||||
if (!aCommandsHandled.Contains(commands[e])) {
|
||||
aCommandsHandled.PutEntry(commands[e]);
|
||||
|
||||
bool enabled = false;
|
||||
controller->IsCommandEnabled(commands[e], &enabled);
|
||||
|
||||
const nsDependentCSubstring commandStr(commands[e], strlen(commands[e]));
|
||||
if (enabled) {
|
||||
aEnabledCommands.AppendElement(commandStr);
|
||||
} else {
|
||||
aDisabledCommands.AppendElement(commandStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(commandsCount, commands);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsWindowRoot::GetEnabledDisabledCommands(nsTArray<nsCString>& aEnabledCommands,
|
||||
nsTArray<nsCString>& aDisabledCommands)
|
||||
{
|
||||
nsTHashtable<nsCharPtrHashKey> commandsHandled;
|
||||
|
||||
nsCOMPtr<nsIControllers> controllers;
|
||||
GetControllers(getter_AddRefs(controllers));
|
||||
if (controllers) {
|
||||
GetEnabledDisabledCommandsForControllers(controllers, commandsHandled,
|
||||
aEnabledCommands, aDisabledCommands);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> focusedWindow;
|
||||
nsFocusManager::GetFocusedDescendant(mWindow, true, getter_AddRefs(focusedWindow));
|
||||
while (focusedWindow) {
|
||||
focusedWindow->GetControllers(getter_AddRefs(controllers));
|
||||
if (controllers) {
|
||||
GetEnabledDisabledCommandsForControllers(controllers, commandsHandled,
|
||||
aEnabledCommands, aDisabledCommands);
|
||||
}
|
||||
|
||||
nsGlobalWindow* win = static_cast<nsGlobalWindow*>(focusedWindow.get());
|
||||
focusedWindow = win->GetPrivateParent();
|
||||
}
|
||||
}
|
||||
|
||||
nsIDOMNode*
|
||||
nsWindowRoot::GetPopupNode()
|
||||
{
|
||||
|
@ -23,8 +23,6 @@ class EventChainPreVisitor;
|
||||
#include "nsPIWindowRoot.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
||||
class nsWindowRoot : public nsPIWindowRoot
|
||||
{
|
||||
@ -54,9 +52,6 @@ public:
|
||||
virtual nsresult GetControllerForCommand(const char * aCommand,
|
||||
nsIController** _retval) MOZ_OVERRIDE;
|
||||
|
||||
virtual void GetEnabledDisabledCommands(nsTArray<nsCString>& aEnabledCommands,
|
||||
nsTArray<nsCString>& aDisabledCommands) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsIDOMNode* GetPopupNode() MOZ_OVERRIDE;
|
||||
virtual void SetPopupNode(nsIDOMNode* aNode) MOZ_OVERRIDE;
|
||||
|
||||
@ -77,11 +72,6 @@ public:
|
||||
protected:
|
||||
virtual ~nsWindowRoot();
|
||||
|
||||
void GetEnabledDisabledCommandsForControllers(nsIControllers* aControllers,
|
||||
nsTHashtable<nsCharPtrHashKey>& aCommandsHandled,
|
||||
nsTArray<nsCString>& aEnabledCommands,
|
||||
nsTArray<nsCString>& aDisabledCommands);
|
||||
|
||||
// Members
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
// We own the manager, which owns event listeners attached to us.
|
||||
|
@ -31,7 +31,6 @@ XPIDL_SOURCES += [
|
||||
'nsIFrameRequestCallback.idl',
|
||||
'nsIIdleObserver.idl',
|
||||
'nsIQueryContentEventResult.idl',
|
||||
'nsIRemoteBrowser.idl',
|
||||
'nsIServiceWorkerManager.idl',
|
||||
'nsIStructuredCloneContainer.idl',
|
||||
'nsITabChild.idl',
|
||||
|
@ -1,26 +0,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"
|
||||
|
||||
[scriptable, uuid(C8379366-F79F-4D25-89A6-22BEC0A93D16)]
|
||||
interface nsIRemoteBrowser : nsISupports
|
||||
{
|
||||
/*
|
||||
* Called by the child to inform the parent that a command update has occurred
|
||||
* and the supplied set of commands are now enabled and disabled.
|
||||
*
|
||||
* @param action command updater action
|
||||
* @param enabledLength length of enabledCommands array
|
||||
* @param enabledCommands commands to enable
|
||||
* @param disabledLength length of disabledCommands array
|
||||
* @param disabledCommand commands to disable
|
||||
*/
|
||||
void enableDisableCommands(in AString action,
|
||||
in unsigned long enabledLength,
|
||||
[array, size_is(enabledLength)] in string enabledCommands,
|
||||
in unsigned long disabledLength,
|
||||
[array, size_is(disabledLength)] in string disabledCommands);
|
||||
};
|
||||
|
@ -7,10 +7,7 @@
|
||||
interface nsIContentFrameMessageManager;
|
||||
interface nsIWebBrowserChrome3;
|
||||
|
||||
native CommandsArray(nsTArray<nsCString>);
|
||||
[ref] native CommandsArrayRef(nsTArray<nsCString>);
|
||||
|
||||
[scriptable, uuid(7227bac4-b6fe-4090-aeb4-bc288b790925)]
|
||||
[scriptable, uuid(2eb3bc54-78bf-40f2-b301-a5b5b70f7da0)]
|
||||
interface nsITabChild : nsISupports
|
||||
{
|
||||
readonly attribute nsIContentFrameMessageManager messageManager;
|
||||
@ -18,9 +15,5 @@ interface nsITabChild : nsISupports
|
||||
attribute nsIWebBrowserChrome3 webBrowserChrome;
|
||||
|
||||
[notxpcom] void sendRequestFocus(in boolean canFocus);
|
||||
|
||||
[noscript, notxpcom] void enableDisableCommands(in AString action,
|
||||
in CommandsArrayRef enabledCommands,
|
||||
in CommandsArrayRef disabledCommands);
|
||||
};
|
||||
|
||||
|
@ -244,14 +244,6 @@ parent:
|
||||
*/
|
||||
RequestFocus(bool canRaise);
|
||||
|
||||
/**
|
||||
* Indicate, based on the current state, that some commands are enabled and
|
||||
* some are disabled.
|
||||
*/
|
||||
EnableDisableCommands(nsString action,
|
||||
nsCString[] enabledCommands,
|
||||
nsCString[] disabledCommands);
|
||||
|
||||
prio(urgent) sync GetInputContext() returns (int32_t IMEEnabled,
|
||||
int32_t IMEOpen,
|
||||
intptr_t NativeIMEContext);
|
||||
|
@ -3226,15 +3226,6 @@ TabChild::SendRequestFocus(bool aCanFocus)
|
||||
PBrowserChild::SendRequestFocus(aCanFocus);
|
||||
}
|
||||
|
||||
void
|
||||
TabChild::EnableDisableCommands(const nsAString& aAction,
|
||||
nsTArray<nsCString>& aEnabledCommands,
|
||||
nsTArray<nsCString>& aDisabledCommands)
|
||||
{
|
||||
PBrowserChild::SendEnableDisableCommands(PromiseFlatString(aAction),
|
||||
aEnabledCommands, aDisabledCommands);
|
||||
}
|
||||
|
||||
bool
|
||||
TabChild::DoSendBlockingMessage(JSContext* aCx,
|
||||
const nsAString& aMessage,
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include "nsIWindowCreator2.h"
|
||||
#include "nsIXULBrowserWindow.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIRemoteBrowser.h"
|
||||
#include "nsViewManager.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
@ -1468,37 +1467,6 @@ TabParent::RecvRequestFocus(const bool& aCanRaise)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TabParent::RecvEnableDisableCommands(const nsString& aAction,
|
||||
const nsTArray<nsCString>& aEnabledCommands,
|
||||
const nsTArray<nsCString>& aDisabledCommands)
|
||||
{
|
||||
nsCOMPtr<nsIRemoteBrowser> remoteBrowser = do_QueryInterface(mFrameElement);
|
||||
if (remoteBrowser) {
|
||||
nsAutoArrayPtr<const char*> enabledCommands, disabledCommands;
|
||||
|
||||
if (aEnabledCommands.Length()) {
|
||||
enabledCommands = new const char* [aEnabledCommands.Length()];
|
||||
for (uint32_t c = 0; c < aEnabledCommands.Length(); c++) {
|
||||
enabledCommands[c] = aEnabledCommands[c].get();
|
||||
}
|
||||
}
|
||||
|
||||
if (aDisabledCommands.Length()) {
|
||||
disabledCommands = new const char* [aDisabledCommands.Length()];
|
||||
for (uint32_t c = 0; c < aDisabledCommands.Length(); c++) {
|
||||
disabledCommands[c] = aDisabledCommands[c].get();
|
||||
}
|
||||
}
|
||||
|
||||
remoteBrowser->EnableDisableCommands(aAction,
|
||||
aEnabledCommands.Length(), enabledCommands,
|
||||
aDisabledCommands.Length(), disabledCommands);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nsIntPoint
|
||||
TabParent::GetChildProcessOffset()
|
||||
{
|
||||
|
@ -191,9 +191,6 @@ public:
|
||||
const int32_t& aCause,
|
||||
const int32_t& aFocusChange) MOZ_OVERRIDE;
|
||||
virtual bool RecvRequestFocus(const bool& aCanRaise) MOZ_OVERRIDE;
|
||||
virtual bool RecvEnableDisableCommands(const nsString& aAction,
|
||||
const nsTArray<nsCString>& aEnabledCommands,
|
||||
const nsTArray<nsCString>& aDisabledCommands) MOZ_OVERRIDE;
|
||||
virtual bool RecvSetCursor(const uint32_t& aValue, const bool& aForce) MOZ_OVERRIDE;
|
||||
virtual bool RecvSetBackgroundColor(const nscolor& aValue) MOZ_OVERRIDE;
|
||||
virtual bool RecvSetStatus(const uint32_t& aType, const nsString& aStatus) MOZ_OVERRIDE;
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
[scriptable, uuid(D5B61B82-1DA4-11d3-BF87-00105A1B0627)]
|
||||
interface nsIController : nsISupports {
|
||||
boolean isCommandEnabled(in string command);
|
||||
boolean supportsCommand(in string command);
|
||||
boolean isCommandEnabled(in string command);
|
||||
boolean supportsCommand(in string command);
|
||||
|
||||
void doCommand(in string command);
|
||||
void doCommand(in string command);
|
||||
|
||||
void onEvent(in string eventName);
|
||||
void onEvent(in string eventName);
|
||||
};
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ interface nsIController : nsISupports {
|
||||
|
||||
interface nsICommandParams;
|
||||
|
||||
[scriptable, uuid(EEC0B435-7F53-44FE-B00A-CF3EED65C01A)]
|
||||
[scriptable, uuid(EBE55080-C8A9-11D5-A73C-DD620D6E04BC)]
|
||||
interface nsICommandController : nsISupports
|
||||
{
|
||||
|
||||
@ -33,8 +33,6 @@ interface nsICommandController : nsISupports
|
||||
|
||||
void doCommandWithParams(in string command, in nsICommandParams aCommandParams);
|
||||
|
||||
void getSupportedCommands(out unsigned long count,
|
||||
[array, size_is(count), retval] out string commands);
|
||||
};
|
||||
|
||||
|
||||
|
@ -174,10 +174,3 @@ nsBaseCommandController::OnEvent(const char * aEventName)
|
||||
NS_ENSURE_ARG_POINTER(aEventName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseCommandController::GetSupportedCommands(uint32_t* aCount, char*** aCommands)
|
||||
{
|
||||
NS_ENSURE_STATE(mCommandTable);
|
||||
return mCommandTable->GetSupportedCommands(aCount, aCommands);
|
||||
}
|
||||
|
@ -188,30 +188,6 @@ nsControllerCommandTable::GetCommandState(const char *aCommandName, nsICommandPa
|
||||
return commandHandler->GetCommandStateParams(aCommandName, aParams, aCommandRefCon);
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
AddCommand(const nsACString& aKey, nsIControllerCommand* aData, void* aArg)
|
||||
{
|
||||
// aArg is a pointer to a array of strings. It gets incremented after
|
||||
// allocating each one so that it points to the next location for AddCommand
|
||||
// to assign a string to.
|
||||
char*** commands = static_cast<char***>(aArg);
|
||||
(**commands) = ToNewCString(aKey);
|
||||
(*commands)++;
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsControllerCommandTable::GetSupportedCommands(uint32_t* aCount,
|
||||
char*** aCommands)
|
||||
{
|
||||
char** commands =
|
||||
static_cast<char **>(NS_Alloc(sizeof(char *) * mCommandsTable.Count()));
|
||||
*aCount = mCommandsTable.Count();
|
||||
*aCommands = commands;
|
||||
|
||||
mCommandsTable.EnumerateRead(AddCommand, &commands);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewControllerCommandTable(nsIControllerCommandTable** aResult)
|
||||
|
@ -18,7 +18,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
[scriptable, uuid(c847f90e-b8f3-49db-a4df-8867831f2800)]
|
||||
[scriptable, uuid(d1a47834-6ad4-11d7-bfad-000393636592)]
|
||||
interface nsIControllerCommandTable : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -82,9 +82,6 @@ interface nsIControllerCommandTable : nsISupports
|
||||
void doCommandParams(in string aCommandName, in nsICommandParams aParam, in nsISupports aCommandRefCon);
|
||||
|
||||
void getCommandState(in string aCommandName, in nsICommandParams aParam, in nsISupports aCommandRefCon);
|
||||
|
||||
void getSupportedCommands(out unsigned long count,
|
||||
[array, size_is(count), retval] out string commands);
|
||||
};
|
||||
|
||||
|
||||
|
@ -10,8 +10,7 @@
|
||||
|
||||
<binding id="remote-browser" extends="chrome://global/content/bindings/browser.xml#browser">
|
||||
|
||||
<implementation type="application/javascript"
|
||||
implements="nsIObserver, nsIDOMEventListener, nsIMessageListener, nsIRemoteBrowser">
|
||||
<implementation type="application/javascript" implements="nsIObserver, nsIDOMEventListener, nsIMessageListener">
|
||||
|
||||
<field name="_securityUI">null</field>
|
||||
|
||||
@ -373,21 +372,6 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="enableDisableCommands">
|
||||
<parameter name="aAction"/>
|
||||
<parameter name="aEnabledLength"/>
|
||||
<parameter name="aEnabledCommands"/>
|
||||
<parameter name="aDisabledLength"/>
|
||||
<parameter name="aDisabledCommands"/>
|
||||
<body>
|
||||
if (this._controller) {
|
||||
this._controller.enableDisableCommands(aAction,
|
||||
aEnabledLength, aEnabledCommands,
|
||||
aDisabledLength, aDisabledCommands);
|
||||
}
|
||||
</body>
|
||||
</method>
|
||||
|
||||
</implementation>
|
||||
|
||||
</binding>
|
||||
|
@ -14,45 +14,45 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
function RemoteController(browser)
|
||||
{
|
||||
this._browser = browser;
|
||||
|
||||
// A map of commands that have had their enabled/disabled state assigned. The
|
||||
// value of each key will be true if enabled, and false if disabled.
|
||||
this._supportedCommands = { };
|
||||
}
|
||||
|
||||
RemoteController.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIController]),
|
||||
|
||||
isCommandEnabled: function(aCommand) {
|
||||
return this._supportedCommands[aCommand] || false;
|
||||
// We can't synchronously ask content if a command is enabled,
|
||||
// so we always pretend is.
|
||||
// The right way forward would be to never use nsIController
|
||||
// to ask if something in content is enabled. Maybe even
|
||||
// by replacing the nsIController architecture by something else.
|
||||
// See bug 905768.
|
||||
return true;
|
||||
},
|
||||
|
||||
supportsCommand: function(aCommand) {
|
||||
return aCommand in this._supportedCommands;
|
||||
// Optimize the lookup a bit.
|
||||
if (!aCommand.startsWith("cmd_"))
|
||||
return false;
|
||||
|
||||
// For now only support the commands used in "browser-context.inc"
|
||||
let commands = [
|
||||
"cmd_copyLink",
|
||||
"cmd_copyImage",
|
||||
"cmd_undo",
|
||||
"cmd_cut",
|
||||
"cmd_copy",
|
||||
"cmd_paste",
|
||||
"cmd_delete",
|
||||
"cmd_selectAll",
|
||||
"cmd_switchTextDirection"
|
||||
];
|
||||
|
||||
return commands.indexOf(aCommand) >= 0;
|
||||
},
|
||||
|
||||
doCommand: function(aCommand) {
|
||||
this._browser.messageManager.sendAsyncMessage("ControllerCommands:Do", aCommand);
|
||||
},
|
||||
|
||||
onEvent: function () {},
|
||||
|
||||
// This is intended to be called from the remote-browser binding to update
|
||||
// the enabled and disabled commands.
|
||||
enableDisableCommands: function(aAction,
|
||||
aEnabledLength, aEnabledCommands,
|
||||
aDisabledLength, aDisabledCommands) {
|
||||
// Clear the list first
|
||||
this._supportedCommands = { };
|
||||
|
||||
for (let c = 0; c < aEnabledLength; c++) {
|
||||
this._supportedCommands[aEnabledCommands[c]] = true;
|
||||
}
|
||||
|
||||
for (let c = 0; c < aDisabledLength; c++) {
|
||||
this._supportedCommands[aDisabledCommands[c]] = false;
|
||||
}
|
||||
|
||||
this._browser.ownerDocument.defaultView.updateCommands(aAction);
|
||||
}
|
||||
onEvent: function () {}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user