Merge m-c to inbound.

This commit is contained in:
Ryan VanderMeulen 2012-08-20 20:21:35 -04:00
commit f1e04816ea
27 changed files with 367 additions and 280 deletions

View File

@ -1128,6 +1128,12 @@ pref("browser.newtab.preload", false);
// Toggles the content of 'about:newtab'. Shows the grid when enabled.
pref("browser.newtabpage.enabled", true);
// number of rows of newtab grid
pref("browser.newtabpage.rows", 3);
// number of columns of newtab grid
pref("browser.newtabpage.columns", 3);
// Enable the DOM fullscreen API.
pref("full-screen-api.enabled", true);

View File

@ -22,17 +22,8 @@ let gGrid = {
/**
* All cells contained in the grid.
*/
get cells() {
let cells = [];
let children = this.node.querySelectorAll(".newtab-cell");
for (let i = 0; i < children.length; i++)
cells.push(new Cell(this, children[i]));
// Replace the getter with our cached value.
Object.defineProperty(this, "cells", {value: cells, enumerable: true});
return cells;
},
_cells: null,
get cells() this._cells,
/**
* All sites contained in the grid's cells. Sites may be empty.
@ -46,7 +37,7 @@ let gGrid = {
init: function Grid_init() {
this._node = document.getElementById("newtab-grid");
this._createSiteFragment();
this._draw();
this._render();
},
/**
@ -74,8 +65,8 @@ let gGrid = {
node.removeChild(child);
}, this);
// Draw the grid again.
this._draw();
// Render the grid again.
this._render();
},
/**
@ -92,6 +83,32 @@ let gGrid = {
this.node.removeAttribute("locked");
},
/**
* Creates the newtab grid.
*/
_renderGrid: function Grid_renderGrid() {
let row = document.createElementNS(HTML_NAMESPACE, "div");
let cell = document.createElementNS(HTML_NAMESPACE, "div");
row.classList.add("newtab-row");
cell.classList.add("newtab-cell");
// Clear the grid
this._node.innerHTML = "";
// Creates the structure of one row
for (let i = 0; i < gGridPrefs.gridColumns; i++) {
row.appendChild(cell.cloneNode(true));
}
// Creates the grid
for (let j = 0; j < gGridPrefs.gridRows; j++) {
this._node.appendChild(row.cloneNode(true));
}
// (Re-)initialize all cells.
let cellElements = this.node.querySelectorAll(".newtab-cell");
this._cells = [new Cell(this, cell) for (cell of cellElements)];
},
/**
* Creates the DOM fragment that is re-used when creating sites.
*/
@ -116,11 +133,10 @@ let gGrid = {
},
/**
* Draws the grid, creates all sites and puts them into their cells.
* Renders the sites, creates all sites and puts them into their cells.
*/
_draw: function Grid_draw() {
_renderSites: function Grid_renderSites() {
let cells = this.cells;
// Put sites into the cells.
let links = gLinks.getLinks();
let length = Math.min(links.length, cells.length);
@ -129,5 +145,24 @@ let gGrid = {
if (links[i])
this.createSite(links[i], cells[i]);
}
},
/**
* Renders the grid.
*/
_render: function Grid_render() {
if (this._shouldRenderGrid()) {
this._renderGrid();
}
this._renderSites();
},
_shouldRenderGrid : function Grid_shouldRenderGrid() {
let rowsLength = this._node.querySelectorAll(".newtab-row").length;
let cellsLength = this._node.querySelectorAll(".newtab-cell").length;
return (rowsLength != gGridPrefs.gridRows ||
cellsLength != (gGridPrefs.gridRows * gGridPrefs.gridColumns));
}
};

View File

@ -20,7 +20,8 @@ let {
allPages: gAllPages,
linkChecker: gLinkChecker,
pinnedLinks: gPinnedLinks,
blockedLinks: gBlockedLinks
blockedLinks: gBlockedLinks,
gridPrefs: gGridPrefs
} = NewTabUtils;
XPCOMUtils.defineLazyGetter(this, "gStringBundle", function() {

View File

@ -26,21 +26,6 @@
<div class="newtab-side-margin"/>
<div id="newtab-grid">
<div class="newtab-row">
<div class="newtab-cell"/>
<div class="newtab-cell"/>
<div class="newtab-cell"/>
</div>
<div class="newtab-row">
<div class="newtab-cell"/>
<div class="newtab-cell"/>
<div class="newtab-cell"/>
</div>
<div class="newtab-row">
<div class="newtab-cell"/>
<div class="newtab-cell"/>
<div class="newtab-cell"/>
</div>
</div>
<div class="newtab-side-margin"/>

View File

@ -28,6 +28,7 @@ _BROWSER_FILES = \
browser_newtab_bug725996.js \
browser_newtab_bug734043.js \
browser_newtab_bug735987.js \
browser_newtab_bug752841.js \
browser_newtab_bug765628.js \
head.js \
$(NULL)

View File

@ -0,0 +1,53 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const PREF_NEWTAB_ROWS = "browser.newtabpage.rows";
const PREF_NEWTAB_COLUMNS = "browser.newtabpage.columns";
function runTests() {
let testValues = [
{row: 0, column: 0},
{row: -1, column: -1},
{row: -1, column: 0},
{row: 0, column: -1},
{row: 2, column: 4},
{row: 2, column: 5},
];
// Expected length of grid
let expectedValues = [1, 1, 1, 1, 8, 10];
// Values before setting new pref values (9 is the default value -> 3 x 3)
let previousValues = [9, 1, 1, 1, 1, 8];
let existingTab, existingTabGridLength, newTab, newTabGridLength;
yield addNewTabPageTab();
existingTab = gBrowser.selectedTab;
for (let i = 0; i < expectedValues.length; i++) {
gBrowser.selectedTab = existingTab;
existingTabGridLength = getGrid().cells.length;
is(existingTabGridLength, previousValues[i],
"Grid length of existing page before update is correctly.");
Services.prefs.setIntPref(PREF_NEWTAB_ROWS, testValues[i].row);
Services.prefs.setIntPref(PREF_NEWTAB_COLUMNS, testValues[i].column);
existingTabGridLength = getGrid().cells.length;
is(existingTabGridLength, expectedValues[i],
"Existing page grid is updated correctly.");
yield addNewTabPageTab();
newTab = gBrowser.selectedTab;
newTabGridLength = getGrid().cells.length;
is(newTabGridLength, expectedValues[i],
"New page grid is updated correctly.");
gBrowser.removeTab(newTab);
}
gBrowser.removeTab(existingTab);
Services.prefs.clearUserPref(PREF_NEWTAB_ROWS);
Services.prefs.clearUserPref(PREF_NEWTAB_COLUMNS);
}

View File

@ -909,48 +909,63 @@ function JSPropertyProvider(aScope, aInputValue)
return null;
}
let properties = completionPart.split(".");
let matchProp;
if (properties.length > 1) {
matchProp = properties.pop().trimLeft();
for (let i = 0; i < properties.length; i++) {
let prop = properties[i].trim();
if (!prop) {
return null;
}
let matches = null;
let matchProp = "";
// If obj is undefined or null (which is what "== null" does),
// then there is no chance to run completion on it. Exit here.
if (obj == null) {
return null;
}
let lastDot = completionPart.lastIndexOf(".");
if (lastDot > 0 &&
(completionPart[0] == "'" || completionPart[0] == '"') &&
completionPart[lastDot - 1] == completionPart[0]) {
// We are completing a string literal.
obj = obj.String.prototype;
matchProp = completionPart.slice(lastDot + 1);
// Check if prop is a getter function on obj. Functions can change other
// stuff so we can't execute them to get the next object. Stop here.
if (WCU.isNonNativeGetter(obj, prop)) {
return null;
}
try {
obj = obj[prop];
}
catch (ex) {
return null;
}
}
}
else {
matchProp = properties[0].trimLeft();
}
// We are completing a variable / a property lookup.
// If obj is undefined or null (which is what "== null" does),
// then there is no chance to run completion on it. Exit here.
if (obj == null) {
return null;
}
let properties = completionPart.split(".");
if (properties.length > 1) {
matchProp = properties.pop().trimLeft();
for (let i = 0; i < properties.length; i++) {
let prop = properties[i].trim();
if (!prop) {
return null;
}
// Skip Iterators and Generators.
if (WCU.isIteratorOrGenerator(obj)) {
return null;
// If obj is undefined or null (which is what "== null" does),
// then there is no chance to run completion on it. Exit here.
if (obj == null) {
return null;
}
// Check if prop is a getter function on obj. Functions can change other
// stuff so we can't execute them to get the next object. Stop here.
if (WCU.isNonNativeGetter(obj, prop)) {
return null;
}
try {
obj = obj[prop];
}
catch (ex) {
return null;
}
}
}
else {
matchProp = properties[0].trimLeft();
}
// If obj is undefined or null (which is what "== null" does),
// then there is no chance to run completion on it. Exit here.
if (obj == null) {
return null;
}
// Skip Iterators and Generators.
if (WCU.isIteratorOrGenerator(obj)) {
return null;
}
}
let matches = Object.keys(getMatchedProps(obj, {matchProp:matchProp}));

View File

@ -105,6 +105,13 @@ function testCompletion(hud) {
is(jsterm.completeNode.value, " ice", "non-object completion");
// Test string literal autocompletion.
input.value = "'Asimov'.sl";
jsterm.complete(jsterm.COMPLETE_HINT_ONLY, testNext);
yield;
is(jsterm.completeNode.value, " ice", "string literal completion");
testDriver = jsterm = input = null;
executeSoon(finishTest);
yield;

View File

@ -24,6 +24,12 @@ XPCOMUtils.defineLazyGetter(this, "gPrincipal", function () {
// The preference that tells whether this feature is enabled.
const PREF_NEWTAB_ENABLED = "browser.newtabpage.enabled";
// The preference that tells the number of rows of the newtab grid.
const PREF_NEWTAB_ROWS = "browser.newtabpage.rows";
// The preference that tells the number of columns of the newtab grid.
const PREF_NEWTAB_COLUMNS = "browser.newtabpage.columns";
// The maximum number of results we want to retrieve from history.
const HISTORY_RESULTS_LIMIT = 100;
@ -183,6 +189,60 @@ let AllPages = {
Ci.nsISupportsWeakReference])
};
/**
* Singleton that keeps Grid preferences
*/
let GridPrefs = {
/**
* Cached value that tells the number of rows of newtab grid.
*/
_gridRows: null,
get gridRows() {
if (!this._gridRows) {
this._gridRows = Math.max(1, Services.prefs.getIntPref(PREF_NEWTAB_ROWS));
}
return this._gridRows;
},
/**
* Cached value that tells the number of columns of newtab grid.
*/
_gridColumns: null,
get gridColumns() {
if (!this._gridColumns) {
this._gridColumns = Math.max(1, Services.prefs.getIntPref(PREF_NEWTAB_COLUMNS));
}
return this._gridColumns;
},
/**
* Initializes object. Adds a preference observer
*/
init: function GridPrefs_init() {
Services.prefs.addObserver(PREF_NEWTAB_ROWS, this, false);
Services.prefs.addObserver(PREF_NEWTAB_COLUMNS, this, false);
},
/**
* Implements the nsIObserver interface to get notified when the preference
* value changes.
*/
observe: function GridPrefs_observe(aSubject, aTopic, aData) {
if (aData == PREF_NEWTAB_ROWS) {
this._gridRows = null;
} else {
this._gridColumns = null;
}
AllPages.update();
}
};
GridPrefs.init();
/**
* Singleton that keeps track of all pinned links and their positions in the
* grid.
@ -606,5 +666,6 @@ let NewTabUtils = {
allPages: AllPages,
linkChecker: LinkChecker,
pinnedLinks: PinnedLinks,
blockedLinks: BlockedLinks
blockedLinks: BlockedLinks,
gridPrefs: GridPrefs
};

View File

@ -13,7 +13,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=292789
<p id="display"></p>
<div id="content" style="display: none">
<script src="chrome://global/content/strres.js"></script>
<script src="chrome://mozapps/content/xpinstall/xpinstallConfirm.js"></script>
<script type="application/javascript;version=1.8" src="chrome://mozapps/content/xpinstall/xpinstallConfirm.js"></script>
<script id="resjs" type="application/javascript;version=1.8"></script>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
@ -36,13 +37,13 @@ function testScriptSrc(aCallback) {
/** make sure the last one didn't pass because someone
** moved the resource
**/
var resjs = document.createElement("script");
var resjs = document.getElementById("resjs");
resjs.onload = scriptOnload;
#ifdef MOZ_CHROME_FILE_FORMAT_JAR
resjs.src = "jar:resource://gre/chrome/toolkit.jar!/content/mozapps/xpinstall/xpinstallConfirm.js";
#else
resjs.src = "resource://gre/chrome/toolkit/content/mozapps/xpinstall/xpinstallConfirm.js";
#endif
resjs.onload = scriptOnload;
document.getElementById("content").appendChild(resjs);
function scriptOnload() {

View File

@ -36,7 +36,6 @@ CPPSRCS = \
nsDOMMouseScrollEvent.cpp \
nsDOMDragEvent.cpp \
nsDOMMutationEvent.cpp \
nsDOMPopupBlockedEvent.cpp \
nsDOMDeviceMotionEvent.cpp \
nsDOMBeforeUnloadEvent.cpp \
nsDOMXULCommandEvent.cpp \

View File

@ -1,83 +0,0 @@
/* -*- Mode: C++; 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 "nsDOMClassInfoID.h"
#include "nsDOMPopupBlockedEvent.h"
#include "nsIURI.h"
NS_IMPL_ADDREF_INHERITED(nsDOMPopupBlockedEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMPopupBlockedEvent, nsDOMEvent)
DOMCI_DATA(PopupBlockedEvent, nsDOMPopupBlockedEvent)
NS_INTERFACE_MAP_BEGIN(nsDOMPopupBlockedEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMPopupBlockedEvent)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(PopupBlockedEvent)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
NS_IMETHODIMP
nsDOMPopupBlockedEvent::InitPopupBlockedEvent(const nsAString & aTypeArg,
bool aCanBubbleArg, bool aCancelableArg,
nsIDOMWindow *aRequestingWindow,
nsIURI *aPopupWindowURI,
const nsAString & aPopupWindowName,
const nsAString & aPopupWindowFeatures)
{
nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
mRequestingWindow = do_GetWeakReference(aRequestingWindow);
mPopupWindowURI = aPopupWindowURI;
mPopupWindowFeatures = aPopupWindowFeatures;
mPopupWindowName = aPopupWindowName;
return NS_OK;
}
NS_IMETHODIMP
nsDOMPopupBlockedEvent::GetRequestingWindow(nsIDOMWindow **aRequestingWindow)
{
*aRequestingWindow = nullptr;
if (mRequestingWindow)
CallQueryReferent(mRequestingWindow.get(), aRequestingWindow);
return NS_OK; // Don't throw an exception
}
NS_IMETHODIMP
nsDOMPopupBlockedEvent::GetPopupWindowURI(nsIURI **aPopupWindowURI)
{
NS_ENSURE_ARG_POINTER(aPopupWindowURI);
*aPopupWindowURI = mPopupWindowURI;
NS_IF_ADDREF(*aPopupWindowURI);
return NS_OK; // Don't throw an exception
}
NS_IMETHODIMP
nsDOMPopupBlockedEvent::GetPopupWindowFeatures(nsAString &aPopupWindowFeatures)
{
aPopupWindowFeatures = mPopupWindowFeatures;
return NS_OK; // Don't throw an exception
}
NS_IMETHODIMP
nsDOMPopupBlockedEvent::GetPopupWindowName(nsAString &aPopupWindowName)
{
aPopupWindowName = mPopupWindowName;
return NS_OK; // Don't throw an exception
}
nsresult NS_NewDOMPopupBlockedEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsEvent *aEvent)
{
nsDOMPopupBlockedEvent* it = new nsDOMPopupBlockedEvent(aPresContext, aEvent);
if (nullptr == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return CallQueryInterface(it, aInstancePtrResult);
}

View File

@ -1,35 +0,0 @@
/* -*- Mode: C++; 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/. */
#ifndef nsDOMPopupBlockedEvent_h__
#define nsDOMPopupBlockedEvent_h__
#include "nsIDOMPopupBlockedEvent.h"
#include "nsDOMEvent.h"
#include "nsIURI.h"
class nsDOMPopupBlockedEvent : public nsDOMEvent,
public nsIDOMPopupBlockedEvent
{
public:
nsDOMPopupBlockedEvent(nsPresContext* aPresContext, nsEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent) {}
NS_DECL_ISUPPORTS_INHERITED
// Forward to nsDOMEvent
NS_FORWARD_TO_NSDOMEVENT
// nsIDOMPopupBlockedEvent Interface
NS_DECL_NSIDOMPOPUPBLOCKEDEVENT
protected:
nsWeakPtr mRequestingWindow;
nsCOMPtr<nsIURI> mPopupWindowURI;
nsString mPopupWindowFeatures;
nsString mPopupWindowName;
};
#endif // nsDOMPopupBlockedEvent_h__

View File

@ -512,6 +512,33 @@ while (testProps.length) {
}
}
// PopupBlockedEvent
try {
e = new PopupBlockedEvent();
} catch(exp) {
ex = true;
}
ok(ex, "PopupBlockedEvent: First parameter is required!");
ex = false;
e = new PopupBlockedEvent("hello");
ok(e.type, "hello", "PopupBlockedEvent: Wrong event type!");
ok(!e.isTrusted, "PopupBlockedEvent: Event shouldn't be trusted!");
ok(!e.bubbles, "PopupBlockedEvent: Event shouldn't bubble!");
ok(!e.cancelable, "PopupBlockedEvent: Event shouldn't be cancelable!");
document.dispatchEvent(e);
is(receivedEvent, e, "PopupBlockedEvent: Wrong event!");
e = new PopupBlockedEvent("hello",
{ requestingWindow: window,
popupWindowFeatures: "features",
popupWindowName: "name"
});
is(e.requestingWindow, window);
is(e.popupWindowFeatures, "features");
is(e.popupWindowName, "name");
// WheelEvent
try {

View File

@ -202,7 +202,6 @@
#include "nsIDOMWheelEvent.h"
#include "nsIDOMDragEvent.h"
#include "nsIDOMCommandEvent.h"
#include "nsIDOMPopupBlockedEvent.h"
#include "nsIDOMBeforeUnloadEvent.h"
#include "nsIDOMMutationEvent.h"
#include "nsIDOMSmartCardEvent.h"
@ -825,8 +824,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CompositionEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(PopupBlockedEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
#define MOZ_GENERATED_EVENT_LIST
#define MOZ_GENERATED_EVENT(_event_interface) \
@ -2610,11 +2607,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(PopupBlockedEvent, nsIDOMPopupBlockedEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMPopupBlockedEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
#define MOZ_GENERATED_EVENT_LIST
#define MOZ_GENERATED_EVENT(_event_interface) \
DOM_CLASSINFO_MAP_BEGIN(_event_interface, nsIDOM##_event_interface) \

View File

@ -43,7 +43,6 @@ DOMCI_CLASS(WheelEvent)
DOMCI_CLASS(DragEvent)
DOMCI_CLASS(KeyboardEvent)
DOMCI_CLASS(CompositionEvent)
DOMCI_CLASS(PopupBlockedEvent)
#define MOZ_GENERATED_EVENT_LIST
#define MOZ_GENERATED_EVENT(_event_interface) DOMCI_CLASS(_event_interface)
#include "GeneratedEvents.h"

View File

@ -282,8 +282,6 @@ NS_NewDOMCompositionEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPres
nsresult
NS_NewDOMMutationEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsMutationEvent* aEvent);
nsresult
NS_NewDOMPopupBlockedEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
nsresult
NS_NewDOMDeviceMotionEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
nsresult
NS_NewDOMTextEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsTextEvent* aEvent);

View File

@ -12,7 +12,7 @@ interface nsIURI;
* posted when a popup window is blocked.
*/
[scriptable, builtinclass, uuid(4eec5417-1687-46ef-9e41-e0a6fbb18927)]
[scriptable, builtinclass, uuid(80eb7f77-7f87-4559-9229-60ba5e05135f)]
interface nsIDOMPopupBlockedEvent : nsIDOMEvent
{
/**
@ -27,18 +27,18 @@ interface nsIDOMPopupBlockedEvent : nsIDOMEvent
*/
readonly attribute nsIURI popupWindowURI;
/**
* The string of features passed to the window.open() call
* (as the third argument)
*/
readonly attribute DOMString popupWindowFeatures;
/**
* The window name passed to the window.open() call
* (as the second argument)
*/
readonly attribute DOMString popupWindowName;
/**
* The string of features passed to the window.open() call
* (as the third argument)
*/
readonly attribute DOMString popupWindowFeatures;
void initPopupBlockedEvent(in DOMString typeArg,
in boolean canBubbleArg,
in boolean cancelableArg,
@ -47,3 +47,11 @@ interface nsIDOMPopupBlockedEvent : nsIDOMEvent
in DOMString popupWindowName,
in DOMString popupWindowFeatures);
};
dictionary PopupBlockedEventInit : EventInit
{
nsIDOMWindow requestingWindow;
nsIURI popupWindowURI;
DOMString popupWindowFeatures;
DOMString popupWindowName;
};

View File

@ -24,7 +24,8 @@ simple_events = [
#ifdef MOZ_B2G_BT
'BluetoothDeviceAddressEvent',
#endif
'DeviceStorageChangeEvent'
'DeviceStorageChangeEvent',
'PopupBlockedEvent'
]
""" include file names """

View File

@ -239,6 +239,7 @@ def writeAttributeParams(fd, a):
def write_cpp(eventname, iface, fd):
classname = ("nsDOM%s" % eventname)
basename = ("ns%s" % iface.base[3:])
attributes = []
ccattributes = []
for member in iface.members:
@ -247,19 +248,37 @@ def write_cpp(eventname, iface, fd):
if (member.realtype.nativeType('in').endswith('*')):
ccattributes.append(member);
fd.write("\nclass %s : public nsDOMEvent, public %s\n" % (classname, iface.name))
baseinterfaces = []
baseiface = iface.idl.getName(iface.base, iface.location)
while baseiface.name != "nsIDOMEvent":
baseinterfaces.append(baseiface)
baseiface = baseiface.idl.getName(baseiface.base, baseiface.location)
baseinterfaces.reverse()
baseattributes = []
for baseiface in baseinterfaces:
for member in baseiface.members:
if isinstance(member, xpidl.Attribute):
baseattributes.append(member)
fd.write("\nclass %s : public %s, public %s\n" % (classname, basename, iface.name))
fd.write("{\n")
fd.write("public:\n")
fd.write(" %s(nsPresContext* aPresContext, nsEvent* aEvent)\n" % classname)
fd.write(" : nsDOMEvent(aPresContext, aEvent)")
fd.write(" : %s(aPresContext, aEvent)" % basename)
for a in attributes:
fd.write(",\n m%s(%s)" % (firstCap(a.name), init_value(a)))
fd.write("\n {}\n")
fd.write(" virtual ~%s() {}\n\n" % classname)
fd.write(" NS_DECL_ISUPPORTS_INHERITED\n")
if len(ccattributes) > 0:
fd.write(" NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(%s, nsDOMEvent)\n" % classname)
fd.write(" NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(%s, %s)\n" % (classname, basename))
fd.write(" NS_FORWARD_TO_NSDOMEVENT\n")
for baseiface in baseinterfaces:
baseimpl = ("ns%s" % baseiface.name[3:])
fd.write(" NS_FORWARD_%s(%s::)\n" % (baseiface.name.upper(), baseimpl))
fd.write(" NS_DECL_%s\n" % iface.name.upper())
fd.write(" virtual nsresult InitFromCtor(const nsAString& aType, JSContext* aCx, jsval* aVal);\n")
fd.write("protected:\n")
@ -267,31 +286,25 @@ def write_cpp(eventname, iface, fd):
fd.write(" %s\n" % attributeVariableTypeAndName(a))
fd.write("};\n\n")
if len(ccattributes) > 0:
fd.write("NS_IMPL_CYCLE_COLLECTION_CLASS(%s)\n\n" % classname)
fd.write("NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(%s, nsDOMEvent)\n" % classname)
for c in ccattributes:
fd.write(" NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(m%s)\n" % firstCap(a.name))
fd.write("NS_IMPL_CYCLE_COLLECTION_UNLINK_END\n\n");
fd.write("NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(%s, nsDOMEvent)\n" % classname)
for c in ccattributes:
fd.write(" NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(m%s)\n" % firstCap(a.name))
fd.write("NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END\n\n");
fd.write("NS_IMPL_CYCLE_COLLECTION_CLASS(%s)\n\n" % classname)
fd.write("NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(%s, %s)\n" % (classname, basename))
for c in ccattributes:
fd.write(" NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(m%s)\n" % firstCap(c.name))
fd.write("NS_IMPL_CYCLE_COLLECTION_UNLINK_END\n\n");
fd.write("NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(%s, %s)\n" % (classname, basename))
for c in ccattributes:
fd.write(" NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(m%s)\n" % firstCap(c.name))
fd.write("NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END\n\n");
fd.write("NS_IMPL_ADDREF_INHERITED(%s, nsDOMEvent)\n" % classname)
fd.write("NS_IMPL_RELEASE_INHERITED(%s, nsDOMEvent)\n\n" % classname)
fd.write("NS_IMPL_ADDREF_INHERITED(%s, %s)\n" % (classname, basename))
fd.write("NS_IMPL_RELEASE_INHERITED(%s, %s)\n\n" % (classname, basename))
fd.write("DOMCI_DATA(%s, %s)\n\n" % (eventname, classname))
if len(ccattributes) > 0:
fd.write("NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(%s)\n" % classname)
else:
fd.write("NS_INTERFACE_MAP_BEGIN(%s)\n" % classname)
fd.write("NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(%s)\n" % classname)
fd.write(" NS_INTERFACE_MAP_ENTRY(nsIDOM%s)\n" % eventname)
fd.write(" NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(%s)\n" % eventname)
fd.write("NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)\n\n")
fd.write("NS_INTERFACE_MAP_END_INHERITING(%s)\n\n" % basename)
fd.write("nsresult\n")
fd.write("%s::InitFromCtor(const nsAString& aType, JSContext* aCx, jsval* aVal)\n" % classname)
@ -300,6 +313,8 @@ def write_cpp(eventname, iface, fd):
fd.write(" nsresult rv = d.Init(aCx, aVal);\n")
fd.write(" NS_ENSURE_SUCCESS(rv, rv);\n")
fd.write(" return Init%s(aType, d.bubbles, d.cancelable" % eventname)
for a in baseattributes:
fd.write(", d.%s" % a.name)
for a in attributes:
fd.write(", d.%s" % a.name)
fd.write(");\n")
@ -308,10 +323,15 @@ def write_cpp(eventname, iface, fd):
fd.write("NS_IMETHODIMP\n")
fd.write("%s::Init%s(" % (classname, eventname))
fd.write("const nsAString& aType, bool aCanBubble, bool aCancelable")
for a in baseattributes:
writeAttributeParams(fd, a)
for a in attributes:
writeAttributeParams(fd, a)
fd.write(")\n{\n")
fd.write(" nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);\n")
fd.write(" nsresult rv = %s::Init%s(aType, aCanBubble, aCancelable" % (basename, basename[5:]))
for a in baseattributes:
fd.write(", a%s" % firstCap(a.name))
fd.write(");\n");
fd.write(" NS_ENSURE_SUCCESS(rv, rv);\n")
for a in attributes:
fd.write(" m%s = a%s;\n" % (firstCap(a.name), firstCap(a.name)))

View File

@ -1023,11 +1023,11 @@ var AddonRepository = {
break;
case "authors":
let authorNodes = node.getElementsByTagName("author");
Array.forEach(authorNodes, function(aAuthorNode) {
let name = self._getDescendantTextContent(aAuthorNode, "name");
let link = self._getDescendantTextContent(aAuthorNode, "link");
for (let authorNode of authorNodes) {
let name = self._getDescendantTextContent(authorNode, "name");
let link = self._getDescendantTextContent(authorNode, "link");
if (name == null || link == null)
return;
continue;
let author = new AddonManagerPrivate.AddonAuthor(name, link);
if (addon.creator == null)
@ -1038,27 +1038,27 @@ var AddonRepository = {
addon.developers.push(author);
}
});
}
break;
case "previews":
let previewNodes = node.getElementsByTagName("preview");
Array.forEach(previewNodes, function(aPreviewNode) {
let full = self._getUniqueDescendant(aPreviewNode, "full");
for (let previewNode of previewNodes) {
let full = self._getUniqueDescendant(previewNode, "full");
if (full == null)
return;
continue;
let fullURL = self._getTextContent(full);
let fullWidth = full.getAttribute("width");
let fullHeight = full.getAttribute("height");
let thumbnailURL, thumbnailWidth, thumbnailHeight;
let thumbnail = self._getUniqueDescendant(aPreviewNode, "thumbnail");
let thumbnail = self._getUniqueDescendant(previewNode, "thumbnail");
if (thumbnail) {
thumbnailURL = self._getTextContent(thumbnail);
thumbnailWidth = thumbnail.getAttribute("width");
thumbnailHeight = thumbnail.getAttribute("height");
}
let caption = self._getDescendantTextContent(aPreviewNode, "caption");
let caption = self._getDescendantTextContent(previewNode, "caption");
let screenshot = new AddonManagerPrivate.AddonScreenshot(fullURL, fullWidth, fullHeight,
thumbnailURL, thumbnailWidth,
thumbnailHeight, caption);
@ -1066,11 +1066,11 @@ var AddonRepository = {
if (addon.screenshots == null)
addon.screenshots = [];
if (aPreviewNode.getAttribute("primary") == 1)
if (previewNode.getAttribute("primary") == 1)
addon.screenshots.unshift(screenshot);
else
addon.screenshots.push(screenshot);
});
}
break;
case "learnmore":
addon.homepageURL = addon.homepageURL || this._getTextContent(node);

View File

@ -2150,9 +2150,6 @@ var XPIProvider = {
.QueryInterface(Ci.nsIDirectoryEnumerator);
let entry;
while (entry = entries.nextFile) {
// Should never happen really
if (!(entry instanceof Ci.nsIFile))
continue;
let id = entry.leafName;

View File

@ -2422,8 +2422,7 @@ var gListView = {
return;
let prop = aIsInstall ? "mInstall" : "mAddon";
for (let i = 0; i < this._listBox.itemCount; i++) {
let item = this._listBox.childNodes[i];
for (let item of this._listBox.childNodes) {
if (item[prop] == aObj)
return;
}
@ -2436,8 +2435,7 @@ var gListView = {
removeItem: function gListView_removeItem(aObj, aIsInstall) {
let prop = aIsInstall ? "mInstall" : "mAddon";
for (let i = 0; i < this._listBox.itemCount; i++) {
let item = this._listBox.childNodes[i];
for (let item of this._listBox.childNodes) {
if (item[prop] == aObj) {
this._listBox.removeChild(item);
this.showEmptyNotice(this._listBox.itemCount == 0);
@ -2653,12 +2651,13 @@ var gDetailView = {
!gViewController.commands.cmd_showItemPreferences.isEnabled(aAddon);
var gridRows = document.querySelectorAll("#detail-grid rows row");
for (var i = 0, first = true; i < gridRows.length; ++i) {
if (first && window.getComputedStyle(gridRows[i], null).getPropertyValue("display") != "none") {
gridRows[i].setAttribute("first-row", true);
let first = true;
for (let gridRow of gridRows) {
if (first && window.getComputedStyle(gridRow, null).getPropertyValue("display") != "none") {
gridRow.setAttribute("first-row", true);
first = false;
} else {
gridRows[i].removeAttribute("first-row");
gridRow.removeAttribute("first-row");
}
}

View File

@ -30,25 +30,25 @@ XPInstallConfirm.init = function ()
var itemList = document.getElementById("itemList");
var numItemsToInstall = args.installs.length;
for (var i = 0; i < numItemsToInstall; ++i) {
for (let install of args.installs) {
var installItem = document.createElement("installitem");
itemList.appendChild(installItem);
installItem.name = args.installs[i].addon.name;
installItem.url = args.installs[i].sourceURI.spec;
var icon = args.installs[i].iconURL;
installItem.name = install.addon.name;
installItem.url = install.sourceURI.spec;
var icon = install.iconURL;
if (icon)
installItem.icon = icon;
var type = args.installs[i].type;
var type = install.type;
if (type)
installItem.type = type;
if (args.installs[i].certName) {
installItem.cert = bundle.getFormattedString("signed", [args.installs[i].certName]);
if (install.certName) {
installItem.cert = bundle.getFormattedString("signed", [install.certName]);
}
else {
installItem.cert = bundle.getString("unverified");
}
installItem.signed = args.installs[i].certName ? "true" : "false";
installItem.signed = install.certName ? "true" : "false";
}
var introString = bundle.getString("itemWarnIntroSingle");

View File

@ -17,7 +17,7 @@
ondialogaccept="return XPInstallConfirm.onOK();"
ondialogcancel="return XPInstallConfirm.onCancel();">
<script src="chrome://mozapps/content/xpinstall/xpinstallConfirm.js"/>
<script src="chrome://mozapps/content/xpinstall/xpinstallConfirm.js" type="application/javascript"/>
<stringbundle id="xpinstallConfirmStrings"
src="chrome://mozapps/locale/xpinstall/xpinstallConfirm.properties"/>

View File

@ -163,8 +163,8 @@ function wait_for_page(aWindow, aPageId, aCallback) {
function get_list_names(aList) {
var items = [];
for (let i = 0; i < aList.childNodes.length; i++)
items.push(aList.childNodes[i].label);
for (let listItem of aList.childNodes)
items.push(listItem.label);
items.sort();
return items;
}
@ -219,16 +219,16 @@ add_test(function() {
"Next button should be enabled");
// Uncheck all
for (let i = 0; i < list.childNodes.length; i++)
EventUtils.synthesizeMouse(list.childNodes[i], 2, 2, { }, aWindow);
for (let listItem of list.childNodes)
EventUtils.synthesizeMouse(listItem, 2, 2, { }, aWindow);
ok(doc.documentElement.getButton("next").disabled,
"Next button should not be enabled");
// Check the ones we want to install
for (let i = 0; i < list.childNodes.length; i++) {
if (list.childNodes[i].label != "Addon7 2.0")
EventUtils.synthesizeMouse(list.childNodes[i], 2, 2, { }, aWindow);
for (let listItem of list.childNodes) {
if (listItem.label != "Addon7 2.0")
EventUtils.synthesizeMouse(listItem, 2, 2, { }, aWindow);
}
var button = doc.documentElement.getButton("next");
@ -313,9 +313,9 @@ add_test(function() {
is(items[2], "Addon9 2.0", "Should have seen update for addon9");
// Unheck the ones we don't want to install
for (let i = 0; i < list.childNodes.length; i++) {
if (list.childNodes[i].label != "Addon7 2.0")
EventUtils.synthesizeMouse(list.childNodes[i], 2, 2, { }, aWindow);
for (let listItem of list.childNodes) {
if (listItem.label != "Addon7 2.0")
EventUtils.synthesizeMouse(listItem, 2, 2, { }, aWindow);
}
var button = doc.documentElement.getButton("next");

View File

@ -1170,9 +1170,9 @@ if ("nsIWindowsRegKey" in AM_Ci) {
},
readStringValue: function(aName) {
for (let i = 0; i < this.values.length; i++) {
if (this.values[i].name == aName)
return this.values[i].value;
for (let value of this.values) {
if (value.name == aName)
return value.value;
}
}
};