Merge mozilla-central into tracemonkey.

This commit is contained in:
Chris Leary 2011-01-14 01:45:33 -08:00
commit 4b37828aec
278 changed files with 9070 additions and 3846 deletions

View File

@ -73,6 +73,17 @@ function init(aEvent)
document.getElementById("version").value += " (" + buildDate + ")";
}
#ifdef MOZ_OFFICIAL_BRANDING
// Hide the Charlton trademark attribution for non-en-US/en-GB
// DO NOT REMOVE without consulting people involved with bug 616193
let chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIXULChromeRegistry);
let currentLocale = chromeRegistry.getSelectedLocale("global");
if (currentLocale != "en-US" && currentLocale != "en-GB") {
document.getElementById("extra-trademark").hidden = true;
}
#endif
#ifdef MOZ_UPDATER
gAppUpdater = new appUpdater();
#endif
@ -369,6 +380,17 @@ appUpdater.prototype =
self.addons = [];
self.addonsCheckedCount = 0;
aAddons.forEach(function(aAddon) {
// Protect against code that overrides the add-ons manager and doesn't
// implement the isCompatibleWith or the findUpdates method.
if (!("isCompatibleWith" in aAddon) || !("findUpdates" in aAddon)) {
let errMsg = "Add-on doesn't implement either the isCompatibleWith " +
"or the findUpdates method!";
if (aAddon.id)
errMsg += " Add-on ID: " + aAddon.id;
Components.utils.reportError(errMsg);
return;
}
// If an add-on isn't appDisabled and isn't userDisabled then it is
// either active now or the user expects it to be active after the
// restart. If that is the case and the add-on is not installed by the
@ -378,13 +400,18 @@ appUpdater.prototype =
// checking plugins compatibility information isn't supported and
// getting the scope property of a plugin breaks in some environments
// (see bug 566787).
if (aAddon.type != "plugin" &&
!aAddon.appDisabled && !aAddon.userDisabled &&
aAddon.scope != AddonManager.SCOPE_APPLICATION &&
aAddon.isCompatible &&
!aAddon.isCompatibleWith(self.update.appVersion,
self.update.platformVersion))
self.addons.push(aAddon);
try {
if (aAddon.type != "plugin" &&
!aAddon.appDisabled && !aAddon.userDisabled &&
aAddon.scope != AddonManager.SCOPE_APPLICATION &&
aAddon.isCompatible &&
!aAddon.isCompatibleWith(self.update.appVersion,
self.update.platformVersion))
self.addons.push(aAddon);
}
catch (e) {
Components.utils.reportError(e);
}
});
self.addonsTotalCount = self.addons.length;
if (self.addonsTotalCount == 0) {

View File

@ -125,7 +125,10 @@
</hbox>
<description id="trademark">
<label class="trademark-label">&trademarkInfo.part1;</label>
<label class="trademark-label">&trademarkInfo.part2;</label>
#ifdef MOZ_OFFICIAL_BRANDING
<!-- DO NOT REMOVE without consulting people involved with bug 616193 -->
<label id="extra-trademark" class="trademark-label">Some of the trademarks used under license from The Charlton Company.</label>
#endif
</description>
</vbox>
</vbox>

View File

@ -174,6 +174,17 @@
type="checkbox"
observes="View:FullScreen"
key="key_fullScreen"/>
#ifdef MOZ_SERVICES_SYNC
<!-- only one of sync-setup or sync-syncnow will be showing at once -->
<menuitem id="sync-setup-appmenu"
label="&syncSetup.label;"
observes="sync-setup-state"
oncommand="gSyncUI.openSetup()"/>
<menuitem id="sync-syncnowitem-appmenu"
label="&syncSyncNowItem.label;"
observes="sync-syncnow-state"
oncommand="gSyncUI.doSync(event);"/>
#endif
<menuitem id="appmenu-quit"
class="menuitem-iconic"
#ifdef XP_WIN
@ -361,18 +372,6 @@
oncommand="openAboutDialog();"/>
</menupopup>
</splitmenu>
#ifdef MOZ_SERVICES_SYNC
<spacer flex="1"/>
<!-- only one of sync-setup or sync-syncnow will be showing at once -->
<menuitem id="sync-setup-appmenu"
label="&syncSetup.label;"
observes="sync-setup-state"
oncommand="gSyncUI.openSetup()"/>
<menuitem id="sync-syncnowitem-appmenu"
label="&syncSyncNowItem.label;"
observes="sync-syncnow-state"
oncommand="gSyncUI.doSync(event);"/>
#endif
</vbox>
</hbox>
</menupopup>

View File

@ -44,8 +44,8 @@
datasources="rdf:charset-menu"
ref="NC:BrowserCharsetMenuRoot"
oncommand="MultiplexHandler(event)"
onpopupshowing="CreateMenu('browser');UpdateMenus(event)"
onpopupshown="CreateMenu('more-menu');"
onpopupshowing="CreateMenu('browser'); CreateMenu('more-menu');"
onpopupshown="UpdateMenus(event);"
observes="isImage">
<template>
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">

View File

@ -991,12 +991,11 @@ var PlacesStarButton = {
return;
}
let starred = this._starIcon.hasAttribute("starred");
if (this._itemIds.length > 0 && !starred) {
if (this._itemIds.length > 0) {
this._starIcon.setAttribute("starred", "true");
this._starIcon.setAttribute("tooltiptext", this._starredTooltip);
}
else if (this._itemIds.length == 0 && starred) {
else {
this._starIcon.removeAttribute("starred");
this._starIcon.setAttribute("tooltiptext", this._unstarredTooltip);
}

View File

@ -172,8 +172,8 @@ let TabView = {
// will not have happened by the time the browser tries to
// update the title.
let activeTab = window.gBrowser.selectedTab;
if (activeTab.tabItem && activeTab.tabItem.parent){
let groupName = activeTab.tabItem.parent.getTitle();
if (activeTab._tabViewTabItem && activeTab._tabViewTabItem.parent){
let groupName = activeTab._tabViewTabItem.parent.getTitle();
if (groupName)
return groupName;
}
@ -190,7 +190,7 @@ let TabView = {
let self = this;
this._initFrame(function() {
let activeGroup = tab.tabItem.parent;
let activeGroup = tab._tabViewTabItem.parent;
let groupItems = self._window.GroupItems.groupItems;
groupItems.forEach(function(groupItem) {

View File

@ -5453,48 +5453,47 @@ function BrowserSetForcedDetector(doReload)
BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
}
function UpdateCurrentCharset()
{
function charsetMenuGetElement(parent, id) {
return parent.getElementsByAttribute("id", id)[0];
}
function UpdateCurrentCharset(target) {
// extract the charset from DOM
var wnd = document.commandDispatcher.focusedWindow;
if ((window == wnd) || (wnd == null)) wnd = window.content;
// Uncheck previous item
if (gPrevCharset) {
var pref_item = document.getElementById('charset.' + gPrevCharset);
var pref_item = charsetMenuGetElement(target, "charset." + gPrevCharset);
if (pref_item)
pref_item.setAttribute('checked', 'false');
}
var menuitem = document.getElementById('charset.' + wnd.document.characterSet);
var menuitem = charsetMenuGetElement(target, "charset." + wnd.document.characterSet);
if (menuitem) {
menuitem.setAttribute('checked', 'true');
}
}
function UpdateCharsetDetector() {
var prefvalue = "off";
function UpdateCharsetDetector(target) {
var prefvalue;
try {
prefvalue = gPrefService.getComplexValue("intl.charset.detector", Ci.nsIPrefLocalizedString).data;
}
catch (ex) {}
if (!prefvalue)
prefvalue = "off";
prefvalue = "chardet." + prefvalue;
var menuitem = document.getElementById(prefvalue);
var menuitem = charsetMenuGetElement(target, "chardet." + prefvalue);
if (menuitem)
menuitem.setAttribute("checked", "true");
}
function UpdateMenus(event) {
// use setTimeout workaround to delay checkmark the menu
// when onmenucomplete is ready then use it instead of oncreate
// see bug 78290 for the detail
UpdateCurrentCharset();
setTimeout(UpdateCurrentCharset, 0);
UpdateCharsetDetector();
setTimeout(UpdateCharsetDetector, 0);
UpdateCurrentCharset(event.target);
UpdateCharsetDetector(event.target);
}
function CreateMenu(node) {
@ -7506,10 +7505,6 @@ var gIdentityHandler = {
// Update the popup strings
this.setPopupMessages(this._identityBox.className);
// Make sure the identity popup hangs toward the middle of the location bar
// in RTL builds
var position = (getComputedStyle(gNavToolbox, "").direction == "rtl") ? 'bottomcenter topright' : 'bottomcenter topleft';
// Add the "open" attribute to the identity box for styling
this._identityBox.setAttribute("open", "true");
var self = this;
@ -7519,7 +7514,7 @@ var gIdentityHandler = {
}, false);
// Now open the popup, anchored off the primary chrome element
this._identityPopup.openPopup(this._identityBox, position);
this._identityPopup.openPopup(this._identityBox, "bottomcenter topleft");
},
onDragStart: function (event) {

View File

@ -153,15 +153,19 @@ let gUsageTreeView = {
* Process the quota information as returned by info/collection_usage.
*/
displayUsageData: function displayUsageData(data) {
data = data || {};
for each (let coll in this._collections) {
coll.size = 0;
// If we couldn't retrieve any data, just blank out the label.
if (!data) {
coll.sizeLabel = "";
continue;
}
for each (let engineName in coll.engines)
coll.size += data[engineName] || 0;
let sizeLabel = "";
if (coll.size)
sizeLabel = gSyncQuota.bundle.getFormattedString(
"quota.sizeValueUnit.label", gSyncQuota.convertKB(coll.size));
sizeLabel = gSyncQuota.bundle.getFormattedString(
"quota.sizeValueUnit.label", gSyncQuota.convertKB(coll.size));
coll.sizeLabel = sizeLabel;
}
let sizeColumn = this.treeBox.columns.getNamedColumn("size");

View File

@ -131,11 +131,15 @@ var gSyncSetup = {
},
startNewAccountSetup: function () {
if (!Weave.Utils.ensureMPUnlocked())
return false;
this._settingUpNew = true;
this.wizard.pageIndex = NEW_ACCOUNT_START_PAGE;
},
useExistingAccount: function () {
if (!Weave.Utils.ensureMPUnlocked())
return false;
this._settingUpNew = false;
this.wizard.pageIndex = EXISTING_ACCOUNT_CONNECT_PAGE;
},
@ -207,7 +211,7 @@ var gSyncSetup = {
case INTRO_PAGE:
return false;
case NEW_ACCOUNT_START_PAGE:
for (i in this.status) {
for (let i in this.status) {
if (!this.status[i])
return false;
}
@ -376,6 +380,13 @@ var gSyncSetup = {
},
onWizardAdvance: function () {
// Check pageIndex so we don't prompt before the Sync setup wizard appears.
// This is a fallback in case the Master Password gets locked mid-wizard.
if ((this.wizard.pageIndex >= 0) &&
!Weave.Utils.ensureMPUnlocked()) {
return false;
}
if (!this.wizard.pageIndex)
return true;

View File

@ -174,16 +174,19 @@
accesskey="&setup.tosAgree1.accesskey;"
oncommand="this.focus(); gSyncSetup.checkFields();"/>
<description id="tosDesc"
flex="1"
onclick="document.getElementById('tos').focus();
document.getElementById('tos').click()">
&setup.tosAgree1.label;
<label class="text-link inline-link"
onclick="event.stopPropagation();gSyncUtils.openToS();"
value="&setup.tosLink.label;"/>
onclick="event.stopPropagation();gSyncUtils.openToS();">
&setup.tosLink.label;
</label>
&setup.tosAgree2.label;
<label class="text-link inline-link"
onclick="event.stopPropagation();gSyncUtils.openPrivacyPolicy();"
value="&setup.ppLink.label;"/>
onclick="event.stopPropagation();gSyncUtils.openPrivacyPolicy();">
&setup.ppLink.label;
</label>
&setup.tosAgree3.label;
</description>
</hbox>
@ -430,7 +433,7 @@
<column/>
<column flex="1"/>
</columns>
<rows>
<rows flex="1">
<row align="center">
<radio id="resetClient"
class="mergeChoiceButton"
@ -445,16 +448,18 @@
class="mergeChoiceButton"
aria-labelledby="wipeClientLabel"/>
<label id="wipeClientLabel"
control="wipeClient"
value="&choice2.client.main.label;"/>
control="wipeClient">
&choice2.client.main.label;
</label>
</row>
<row align="center">
<radio id="wipeRemote"
class="mergeChoiceButton"
aria-labelledby="wipeRemoteLabel"/>
<label id="wipeRemoteLabel"
control="wipeRemote"
value="&choice2.server.main.label;"/>
control="wipeRemote">
&choice2.server.main.label;
</label>
</row>
</rows>
</grid>

View File

@ -82,15 +82,18 @@ let gSyncUtils = {
},
changePassword: function () {
this.openChange("ChangePassword");
if (Weave.Utils.ensureMPUnlocked())
this.openChange("ChangePassword");
},
resetPassphrase: function () {
this.openChange("ResetPassphrase");
if (Weave.Utils.ensureMPUnlocked())
this.openChange("ResetPassphrase");
},
updatePassphrase: function () {
this.openChange("UpdatePassphrase");
if (Weave.Utils.ensureMPUnlocked())
this.openChange("UpdatePassphrase");
},
resetPassword: function () {

View File

@ -296,7 +296,10 @@ Drag.prototype = {
if (this.parent && this.parent.expanded)
this.parent.arrange();
if (this.item && !this.item.parent) {
if (this.item.parent)
this.item.parent.arrange();
if (!this.item.parent) {
this.item.setZ(drag.zIndex);
drag.zIndex++;

View File

@ -86,6 +86,10 @@ function GroupItem(listOfEls, options) {
this.keepProportional = false;
// Double click tracker
this._lastClick = 0;
this._lastClickPositions = null;
// Variable: _activeTab
// The <TabItem> for the groupItem's active tab.
this._activeTab = null;
@ -140,7 +144,7 @@ function GroupItem(listOfEls, options) {
// ___ Titlebar
var html =
"<div class='title-container'>" +
"<input class='name' />" +
"<input class='name' placeholder='" + this.defaultName + "'/>" +
"<div class='title-shield' />" +
"</div>";
@ -149,7 +153,7 @@ function GroupItem(listOfEls, options) {
.html(html)
.appendTo($container);
var $close = iQ('<div>')
this.$closeButton = iQ('<div>')
.addClass('close')
.click(function() {
self.closeAll();
@ -160,31 +164,7 @@ function GroupItem(listOfEls, options) {
this.$titleContainer = iQ('.title-container', this.$titlebar);
this.$title = iQ('.name', this.$titlebar);
this.$titleShield = iQ('.title-shield', this.$titlebar);
this.setTitle(options.title || this.defaultName);
var titleUnfocus = function(immediately) {
self.$titleShield.show();
if (!self.getTitle()) {
self.$title
.addClass("defaultName")
.val(self.defaultName)
.css({"background-image":null, "-moz-padding-start":null});
} else {
self.$title.css({"background-image":"none"});
if (immediately) {
self.$title.css({
"-moz-padding-start": "1px"
});
} else {
self.$title.animate({
"-moz-padding-start": "1px"
}, {
duration: 200,
easing: "tabviewBounce"
});
}
}
};
this.setTitle(options.title);
var handleKeyDown = function(e) {
if (e.which == 13 || e.which == 27) { // return & escape
@ -208,25 +188,19 @@ function GroupItem(listOfEls, options) {
};
this.$title
.css({backgroundRepeat: 'no-repeat'})
.blur(titleUnfocus)
.blur(function() {
self.$titleShield.show();
})
.focus(function() {
if (self.locked.title) {
(self.$title)[0].blur();
return;
}
(self.$title)[0].select();
if (!self.getTitle()) {
self.$title
.removeClass("defaultName")
.val('');
}
})
.keydown(handleKeyDown)
.keyup(handleKeyUp);
titleUnfocus(immediately);
if (this.locked.title)
this.$title.addClass('name-locked');
else {
@ -268,7 +242,7 @@ function GroupItem(listOfEls, options) {
$container.css({cursor: 'default'});
if (this.locked.close)
$close.hide();
this.$closeButton.hide();
// ___ Undo Close
this.$undoContainer = null;
@ -282,7 +256,7 @@ function GroupItem(listOfEls, options) {
// ___ Children
Array.prototype.forEach.call(listOfEls, function(el) {
self.add(el, null, options);
self.add(el, options);
});
// ___ Finish Up
@ -306,6 +280,8 @@ function GroupItem(listOfEls, options) {
this._inited = true;
this.save();
GroupItems.updateGroupCloseButtons();
};
// ----------
@ -383,8 +359,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// Function: getTitle
// Returns the title of this groupItem as a string.
getTitle: function GroupItem_getTitle() {
var value = (this.$title ? this.$title.val() : '');
return (value == this.defaultName ? '' : value);
return this.$title ? this.$title.val() : '';
},
// ----------
@ -454,8 +429,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
if (!options)
options = {};
rect.width = Math.max(110, rect.width);
rect.height = Math.max(125, rect.height);
GroupItems.enforceMinSize(rect);
var titleHeight = this.$titlebar.height();
@ -567,6 +541,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
this.removeTrenches();
Items.unsquish();
this._sendToSubscribers("close");
GroupItems.updateGroupCloseButtons();
} else {
let self = this;
iQ(this.container).animate({
@ -579,6 +554,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
self.removeTrenches();
Items.unsquish();
self._sendToSubscribers("close");
GroupItems.updateGroupCloseButtons();
}
});
}
@ -651,6 +627,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
}
});
GroupItems.updateGroupCloseButtons();
self._sendToSubscribers("groupShown", { groupItemId: self.id });
},
@ -783,6 +760,8 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
this.$undoContainer.mouseout(function() {
self.setupFadeAwayUndoButtonTimer();
});
GroupItems.updateGroupCloseButtons();
},
// ----------
@ -811,14 +790,14 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
//
// a - The item to add. Can be an <Item>, a DOM element or an iQ object.
// The latter two must refer to the container of an <Item>.
// dropPos - An object with left and top properties referring to the
// location dropped at. Optional.
// options - An optional object with settings for this call. See below.
// options - An object with optional settings for this call.
//
// Possible options:
// dontArrange - Don't rearrange the children for the new item
// immediately - Don't animate
add: function GroupItem_add(a, dropPos, options) {
// Options:
//
// index - (int) if set, add this tab at this index
// immediately - (bool) if true, no animation will be used
// dontArrange - (bool) if true, will not trigger an arrange on the group
add: function GroupItem_add(a, options) {
try {
var item;
var $el;
@ -846,48 +825,8 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
wasAlreadyInThisGroupItem = true;
}
// TODO: You should be allowed to drop in the white space at the bottom
// and have it go to the end (right now it can match the thumbnail above
// it and go there)
// Bug 586548
function findInsertionPoint(dropPos) {
if (self.shouldStack(self._children.length + 1))
return 0;
var best = {dist: Infinity, item: null};
var index = 0;
var box;
self._children.forEach(function(child) {
box = child.getBounds();
if (box.bottom < dropPos.top || box.top > dropPos.top)
return;
var dist = Math.sqrt(Math.pow((box.top+box.height/2)-dropPos.top,2)
+ Math.pow((box.left+box.width/2)-dropPos.left,2));
if (dist <= best.dist) {
best.item = child;
best.dist = dist;
best.index = index;
}
});
if (self._children.length) {
if (best.item) {
box = best.item.getBounds();
var insertLeft = dropPos.left <= box.left + box.width/2;
if (!insertLeft)
return best.index+1;
return best.index;
}
return self._children.length;
}
return 0;
}
// Insert the tab into the right position.
var index = dropPos ? findInsertionPoint(dropPos) : this._children.length;
var index = ("index" in options) ? options.index : this._children.length;
this._children.splice(index, 0, item);
item.setZ(this.getZ() + 1);
@ -899,6 +838,10 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
item.addSubscriber(this, "close", function() {
self.remove(item);
if (self._children.length > 0 && self._activeTab) {
GroupItems.setActiveGroupItem(self);
UI.setActiveTab(self._activeTab);
}
});
item.setParent(this);
@ -961,7 +904,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
if (index != -1)
this._children.splice(index, 1);
if (item == this._activeTab) {
if (item == this._activeTab || !this._activeTab) {
if (this._children.length > 0)
this._activeTab = this._children[0];
else
@ -980,14 +923,18 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
if (typeof item.setResizable == 'function')
item.setResizable(true, options.immediately);
if (!this._children.length && !this.locked.close && !this.getTitle() && !options.dontClose) {
this.close();
if (this._children.length == 0 && !this.locked.close && !this.getTitle() &&
!options.dontClose) {
if (!GroupItems.getUnclosableGroupItemId()) {
this.close();
} else {
// this.close(); this line is causing the leak but the leak doesn't happen after re-enabling it
}
} else if (!options.dontArrange) {
this.arrange({animate: !options.immediately});
}
this._sendToSubscribers("childRemoved",{ groupItemId: this.id, item: item });
} catch(e) {
Utils.log(e);
}
@ -1120,54 +1067,84 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// Lays out all of the children.
//
// Parameters:
// options - passed to <Items.arrange> or <_stackArrange>
// options - passed to <Items.arrange> or <_stackArrange>, except those below
//
// Options:
// addTab - (boolean) if true, we add one to the child count
// oldDropIndex - if set, we will only set any bounds if the dropIndex has
// changed
// dropPos - (<Point>) a position where a tab is currently positioned, above
// this group.
// animate - (boolean) if true, movement of children will be animated.
//
// Returns:
// dropIndex - an index value for where an item would be dropped, if
// options.dropPos is given.
arrange: function GroupItem_arrange(options) {
if (!options)
options = {};
let childrenToArrange = [];
this._children.forEach(function(child) {
if (child.isDragging)
options.addTab = true;
else
childrenToArrange.push(child);
});
if (GroupItems._arrangePaused) {
GroupItems.pushArrange(this, options);
return;
}
var dropIndex = false;
if (this.expanded) {
this.topChild = null;
var box = new Rect(this.expanded.bounds);
box.inset(8, 8);
Items.arrange(this._children, box, Utils.extend({}, options, {z: 99999}));
let result = Items.arrange(childrenToArrange, box, Utils.extend({}, options, {z: 99999}));
dropIndex = result.dropIndex;
} else {
var count = childrenToArrange.length;
var bb = this.getContentBounds();
if (!this.shouldStack()) {
if (!options)
options = {};
this._children.forEach(function(child) {
if (!this.shouldStack(count + (options.addTab ? 1 : 0))) {
childrenToArrange.forEach(function(child) {
child.removeClass("stacked")
});
this.topChild = null;
if (!this._children.length)
if (!childrenToArrange.length)
return;
var arrangeOptions = Utils.copy(options);
Utils.extend(arrangeOptions, {
var arrangeOptions = Utils.extend({}, options, {
columns: this._columns
});
// Items.arrange will rearrange the children, but also return an array
// of the Rect's used.
var rects = Items.arrange(this._children, bb, arrangeOptions);
let result = Items.arrange(childrenToArrange, bb, arrangeOptions);
dropIndex = result.dropIndex;
if ("oldDropIndex" in options && options.oldDropIndex === dropIndex)
return dropIndex;
var rects = result.rects;
// first, find the right of the rightmost tab! luckily, they're in order.
var rightMostRight = 0;
if (UI.rtl) {
rightMostRight = rects[0].right;
} else {
for each (var rect in rects) {
if (rect.right > rightMostRight)
rightMostRight = rect.right;
else
break;
let index = 0;
let self = this;
childrenToArrange.forEach(function GroupItem_arrange_children_each(child, i) {
// If dropIndex spacing is active and this is a child after index,
// bump it up one so we actually use the correct rect
// (and skip one for the dropPos)
if (self._dropSpaceActive && index === dropIndex)
index++;
if (!child.locked.bounds) {
child.setBounds(rects[index], !options.animate);
child.setRotation(0);
if (options.z)
child.setZ(options.z);
}
}
index++;
});
this._isStacked = false;
} else
@ -1176,6 +1153,8 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
if (this._isStacked && !this.expanded) this.showExpandControl();
else this.hideExpandControl();
return dropIndex;
},
// ----------
@ -1232,14 +1211,14 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
var self = this;
var children = [];
this._children.forEach(function(child) {
this._children.forEach(function GroupItem__stackArrange_order(child) {
if (child == self.topChild)
children.unshift(child);
else
children.push(child);
});
children.forEach(function(child, index) {
children.forEach(function GroupItem__stackArrange_apply(child, index) {
if (!child.locked.bounds) {
child.setZ(zIndex);
zIndex--;
@ -1415,16 +1394,105 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// Function: _addHandlers
// Helper routine for the constructor; adds various event handlers to the container.
_addHandlers: function GroupItem__addHandlers(container) {
var self = this;
let self = this;
this.dropOptions.over = function() {
// Create new tab and zoom in on it after a double click
container.mousedown(function(e) {
if (Date.now() - self._lastClick <= UI.DBLCLICK_INTERVAL &&
(self._lastClickPositions.x - UI.DBLCLICK_OFFSET) <= e.clientX &&
(self._lastClickPositions.x + UI.DBLCLICK_OFFSET) >= e.clientX &&
(self._lastClickPositions.y - UI.DBLCLICK_OFFSET) <= e.clientY &&
(self._lastClickPositions.y + UI.DBLCLICK_OFFSET) >= e.clientY) {
self.newTab();
self._lastClick = 0;
self._lastClickPositions = null;
} else {
self._lastClick = Date.now();
self._lastClickPositions = new Point(e.clientX, e.clientY);
}
});
var dropIndex = false;
var dropSpaceTimer = null;
// When the _dropSpaceActive flag is turned on on a group, and a tab is
// dragged on top, a space will open up.
this._dropSpaceActive = false;
this.dropOptions.over = function GroupItem_dropOptions_over(event) {
iQ(this.container).addClass("acceptsDrop");
};
this.dropOptions.drop = function(event) {
iQ(this.container).removeClass("acceptsDrop");
this.add(drag.info.$el, {left:event.pageX, top:event.pageY});
GroupItems.setActiveGroupItem(this);
this.dropOptions.move = function GroupItem_dropOptions_move(event) {
let oldDropIndex = dropIndex;
let dropPos = drag.info.item.getBounds().center();
let options = {dropPos: dropPos,
addTab: self._dropSpaceActive && drag.info.item.parent != self,
oldDropIndex: oldDropIndex};
newDropIndex = self.arrange(options);
// If this is a new drop index, start a timer!
if (newDropIndex !== oldDropIndex) {
dropIndex = newDropIndex;
if (this._dropSpaceActive)
return;
if (dropSpaceTimer) {
clearTimeout(dropSpaceTimer);
dropSpaceTimer = null;
}
dropSpaceTimer = setTimeout(function GroupItem_arrange_evaluateDropSpace() {
// Note that dropIndex's scope is GroupItem__addHandlers, but
// newDropIndex's scope is GroupItem_dropOptions_move. Thus,
// dropIndex may change with other movement events before we come
// back and check this. If it's still the same dropIndex, activate
// drop space display!
if (dropIndex === newDropIndex) {
self._dropSpaceActive = true;
dropIndex = self.arrange({dropPos: dropPos,
addTab: drag.info.item.parent != self,
animate: true});
}
dropSpaceTimer = null;
}, 250);
}
};
this.dropOptions.drop = function GroupItem_dropOptions_drop(event) {
iQ(this.container).removeClass("acceptsDrop");
let options = {};
if (this._dropSpaceActive)
this._dropSpaceActive = false;
if (dropSpaceTimer) {
clearTimeout(dropSpaceTimer);
dropSpaceTimer = null;
// If we drop this item before the timed rearrange was executed,
// we won't have an accurate dropIndex value. Get that now.
let dropPos = drag.info.item.getBounds().center();
dropIndex = self.arrange({dropPos: dropPos,
addTab: drag.info.item.parent != self,
animate: true});
}
if (dropIndex !== false)
options = {index: dropIndex}
this.add(drag.info.$el, options);
GroupItems.setActiveGroupItem(this);
dropIndex = false;
};
this.dropOptions.out = function GroupItem_dropOptions_out(event) {
dropIndex = false;
if (this._dropSpaceActive)
this._dropSpaceActive = false;
if (dropSpaceTimer) {
clearTimeout(dropSpaceTimer);
dropSpaceTimer = null;
}
self.arrange();
var groupItem = drag.info.item.parent;
if (groupItem)
groupItem.remove(drag.info.$el, {dontClose: true});
iQ(this.container).removeClass("acceptsDrop");
}
if (!this.locked.bounds)
this.draggable();
@ -1440,8 +1508,8 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// Function: setResizable
// Sets whether the groupItem is resizable and updates the UI accordingly.
setResizable: function GroupItem_setResizable(value, immediately) {
this.resizeOptions.minWidth = 110;
this.resizeOptions.minHeight = 125;
this.resizeOptions.minWidth = GroupItems.minGroupWidth;
this.resizeOptions.minHeight = GroupItems.minGroupHeight;
if (value) {
immediately ? this.$resizer.show() : this.$resizer.fadeIn();
@ -1462,7 +1530,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// TabItems will have handled the new tab and added the tabItem property.
// We don't have to check if it's an app tab (and therefore wouldn't have a
// TabItem), since we've just created it.
newTab.tabItem.zoomIn(!url);
newTab._tabViewTabItem.zoomIn(!url);
},
// ----------
@ -1559,7 +1627,8 @@ let GroupItems = {
_arrangePaused: false,
_arrangesPending: [],
_removingHiddenGroups: false,
_updatingTabBarPaused: false,
minGroupHeight: 110,
minGroupWidth: 125,
// ----------
// Function: init
@ -1663,6 +1732,7 @@ let GroupItems = {
this.groupItems.forEach(function(groupItem) {
groupItem.addAppTab(xulTab);
});
this.updateGroupCloseButtons();
},
// ----------
@ -1672,6 +1742,7 @@ let GroupItems = {
this.groupItems.forEach(function(groupItem) {
groupItem.removeAppTab(xulTab);
});
this.updateGroupCloseButtons();
},
// ----------
@ -1883,7 +1954,7 @@ let GroupItems = {
// tab in question): make a new group
if (activeGroupItem) {
activeGroupItem.add(tabItem, null, options);
activeGroupItem.add(tabItem, options);
return;
}
@ -1893,15 +1964,15 @@ let GroupItems = {
// find first visible non-app tab in the tabbar.
gBrowser.visibleTabs.some(function(tab) {
if (!tab.pinned && tab != tabItem.tab) {
if (tab.tabItem) {
if (!tab.tabItem.parent) {
if (tab._tabViewTabItem) {
if (!tab._tabViewTabItem.parent) {
// the first visible tab is an orphan tab, set the orphan tab, and
// create a new group for orphan tab and new tabItem
orphanTabItem = tab.tabItem;
} else if (!tab.tabItem.parent.hidden) {
orphanTabItem = tab._tabViewTabItem;
} else if (!tab._tabViewTabItem.parent.hidden) {
// the first visible tab belongs to a group, add the new tabItem to
// that group
targetGroupItem = tab.tabItem.parent;
targetGroupItem = tab._tabViewTabItem.parent;
}
}
return true;
@ -2004,25 +2075,6 @@ let GroupItems = {
this._activeOrphanTab = tabItem;
},
// ----------
// Function: pauseUpdatingTabBar
// Don't update the tab bar until resume is called.
pauseUpdatingTabBar: function GroupItems_pauseUdatingTabBar() {
Utils.assertThrow(!this._updatingTabBarPaused, "shouldn't already be paused");
this._updatingTabBarPaused = true;
},
// ----------
// Function: resumeUpdatingTabBar
// Allows updating the tab bar, and does an update.
resumeUpdatingTabBar: function GroupItems_resumeUpdatingTabBar() {
Utils.assertThrow(this._updatingTabBarPaused, "should already be paused");
this._updatingTabBarPaused = false;
this._updateTabBar();
},
// ----------
// Function: _updateTabBar
// Hides and shows tabs in the tab bar based on the active groupItem or
@ -2031,9 +2083,6 @@ let GroupItems = {
if (!window.UI)
return; // called too soon
if (this._updatingTabBarPaused)
return;
if (!this._activeGroupItem && !this._activeOrphanTab) {
Utils.assert(false, "There must be something to show in the tab bar!");
return;
@ -2173,7 +2222,11 @@ let GroupItems = {
if (tab.pinned)
return;
Utils.assertThrow(tab.tabItem, "tab must be linked to a TabItem");
Utils.assertThrow(tab._tabViewTabItem, "tab must be linked to a TabItem");
// given tab is already contained in target group
if (tab._tabViewTabItem.parent && tab._tabViewTabItem.parent.id == groupItemId)
return;
let shouldUpdateTabBar = false;
let shouldShowTabView = false;
@ -2198,13 +2251,13 @@ let GroupItems = {
shouldUpdateTabBar = true
// remove tab item from a groupItem
if (tab.tabItem.parent)
tab.tabItem.parent.remove(tab.tabItem);
if (tab._tabViewTabItem.parent)
tab._tabViewTabItem.parent.remove(tab._tabViewTabItem);
// add tab item to a groupItem
if (groupItemId) {
groupItem = GroupItems.groupItem(groupItemId);
groupItem.add(tab.tabItem);
groupItem.add(tab._tabViewTabItem);
UI.setReorderTabItemsOnShow(groupItem);
} else {
let pageBounds = Items.getPageBounds();
@ -2214,13 +2267,13 @@ let GroupItems = {
box.width = 250;
box.height = 200;
new GroupItem([ tab.tabItem ], { bounds: box });
new GroupItem([ tab._tabViewTabItem ], { bounds: box });
}
if (shouldUpdateTabBar)
this._updateTabBar();
else if (shouldShowTabView) {
tab.tabItem.setZoomPrep(false);
tab._tabViewTabItem.setZoomPrep(false);
UI.showTabView();
}
},
@ -2255,5 +2308,56 @@ let GroupItems = {
});
this._removingHiddenGroups = false;
},
// ----------
// Function: enforceMinSize
// Takes a <Rect> and modifies that <Rect> in case it is too small to be
// the bounds of a <GroupItem>.
//
// Parameters:
// bounds - (<Rect>) the target bounds of a <GroupItem>
enforceMinSize: function GroupItems_enforceMinSize(bounds) {
bounds.width = Math.max(bounds.width, this.minGroupWidth);
bounds.height = Math.max(bounds.height, this.minGroupHeight);
},
// ----------
// Function: getUnclosableGroupItemId
// If there's only one (non-hidden) group, and there are app tabs present,
// returns that group.
// Return the <GroupItem>'s Id
getUnclosableGroupItemId: function GroupItems_getUnclosableGroupItemId() {
let unclosableGroupItemId = null;
if (gBrowser._numPinnedTabs > 0) {
let hiddenGroupItems =
this.groupItems.concat().filter(function(groupItem) {
return !groupItem.hidden;
});
if (hiddenGroupItems.length == 1)
unclosableGroupItemId = hiddenGroupItems[0].id;
}
return unclosableGroupItemId;
},
// ----------
// Function: updateGroupCloseButtons
// Updates group close buttons.
updateGroupCloseButtons: function GroupItems_updateGroupCloseButtons() {
let unclosableGroupItemId = this.getUnclosableGroupItemId();
if (unclosableGroupItemId) {
let groupItem = this.groupItem(unclosableGroupItemId);
if (groupItem) {
groupItem.$closeButton.hide();
}
} else {
this.groupItems.forEach(function(groupItem) {
groupItem.$closeButton.show();
});
}
}
};

View File

@ -478,6 +478,13 @@ iQClass.prototype = {
}
properties = {};
properties[key] = b;
} else if (a instanceof Rect) {
properties = {
left: a.left,
top: a.top,
width: a.width,
height: a.height
};
} else {
properties = a;
}
@ -495,6 +502,7 @@ iQClass.prototype = {
let elem = this[i];
for (let key in properties) {
let value = properties[key];
if (pixels[key] && typeof value != 'string')
value += 'px';
@ -539,6 +547,16 @@ iQClass.prototype = {
let duration = (options.duration || 400);
let easing = (easings[options.easing] || 'ease');
if (css instanceof Rect) {
css = {
left: css.left,
top: css.top,
width: css.width,
height: css.height
};
}
// The latest versions of Firefox do not animate from a non-explicitly
// set css properties. So for each element to be animated, go through
// and explicitly define 'em.

View File

@ -179,6 +179,9 @@ Item.prototype = {
start: function(e, ui) {
if (this.isAGroupItem)
GroupItems.setActiveGroupItem(this);
// if we start dragging a tab within a group, start with dropSpace on.
else if (this.parent != null)
this.parent._dropSpaceActive = true;
drag.info = new Drag(this, e);
},
drag: function(e) {
@ -197,10 +200,9 @@ Item.prototype = {
this.dropOptions = {
over: function() {},
out: function() {
var groupItem = drag.info.item.parent;
let groupItem = drag.info.item.parent;
if (groupItem)
groupItem.remove(drag.info.$el, {dontClose: true});
iQ(this.container).removeClass("acceptsDrop");
},
drop: function(event) {
@ -345,7 +347,7 @@ Item.prototype = {
var itemsToPush = [this];
this.pushAwayData.generation = 0;
var pushOne = function(baseItem) {
var pushOne = function Item_pushAway_pushOne(baseItem) {
// the baseItem is an n-generation pushed item. (n could be 0)
var baseData = baseItem.pushAwayData;
var bb = new Rect(baseData.bounds);
@ -355,7 +357,7 @@ Item.prototype = {
// bbc = center of the base's bounds
var bbc = bb.center();
items.forEach(function(item) {
items.forEach(function Item_pushAway_pushOne_pushEach(item) {
if (item == baseItem || item.locked.bounds)
return;
@ -417,12 +419,12 @@ Item.prototype = {
// ___ Squish!
var pageBounds = Items.getSafeWindowBounds();
items.forEach(function(item) {
items.forEach(function Item_pushAway_squish(item) {
var data = item.pushAwayData;
if (data.generation == 0 || item.locked.bounds)
return;
function apply(item, posStep, posStep2, sizeStep) {
let apply = function Item_pushAway_squish_apply(item, posStep, posStep2, sizeStep) {
var data = item.pushAwayData;
if (data.generation == 0)
return;
@ -432,8 +434,11 @@ Item.prototype = {
bounds.height -= sizeStep.y;
bounds.left += posStep.x;
bounds.top += posStep.y;
if (!item.isAGroupItem) {
if (item.isAGroupItem) {
GroupItems.enforceMinSize(bounds);
} else {
TabItems.enforceMinSize(bounds);
if (sizeStep.y > sizeStep.x) {
var newWidth = bounds.height * (TabItems.tabWidth / TabItems.tabHeight);
bounds.left += (bounds.width - newWidth) / 2;
@ -461,7 +466,7 @@ Item.prototype = {
posStep.x = pageBounds.left - bounds.left;
sizeStep.x = posStep.x / data.generation;
posStep2.x = -sizeStep.x;
} else if (bounds.right > pageBounds.right) {
} else if (bounds.right > pageBounds.right) { // this may be less of a problem post-601534
posStep.x = pageBounds.right - bounds.right;
sizeStep.x = -posStep.x / data.generation;
posStep.x += sizeStep.x;
@ -472,7 +477,7 @@ Item.prototype = {
posStep.y = pageBounds.top - bounds.top;
sizeStep.y = posStep.y / data.generation;
posStep2.y = -sizeStep.y;
} else if (bounds.bottom > pageBounds.bottom) {
} else if (bounds.bottom > pageBounds.bottom) { // this may be less of a problem post-601534
posStep.y = pageBounds.bottom - bounds.bottom;
sizeStep.y = -posStep.y / data.generation;
posStep.y += sizeStep.y;
@ -485,7 +490,7 @@ Item.prototype = {
// ___ Unsquish
var pairs = [];
items.forEach(function(item) {
items.forEach(function Item_pushAway_setupUnsquish(item) {
var data = item.pushAwayData;
pairs.push({
item: item,
@ -496,7 +501,7 @@ Item.prototype = {
Items.unsquish(pairs);
// ___ Apply changes
items.forEach(function(item) {
items.forEach(function Item_pushAway_setBounds(item) {
var data = item.pushAwayData;
var bounds = data.bounds;
if (!bounds.equals(data.startBounds)) {
@ -511,7 +516,7 @@ Item.prototype = {
// This functionality is enabled only by the debug property.
_updateDebugBounds: function Item__updateDebugBounds() {
if (this.$debug) {
this.$debug.css(this.bounds.css());
this.$debug.css(this.bounds);
}
},
@ -617,7 +622,6 @@ Item.prototype = {
var box = self.getBounds();
box.left = startPos.x + (mouse.x - startMouse.x);
box.top = startPos.y + (mouse.y - startMouse.y);
self.setBounds(box, true);
if (typeof self.dragOptions.drag == "function")
@ -663,6 +667,11 @@ Item.prototype = {
dropOptions.over.apply(dropTarget, [e]);
}
}
if (dropTarget) {
dropOptions = dropTarget.dropOptions;
if (dropOptions && typeof dropOptions.move == "function")
dropOptions.move.apply(dropTarget, [e]);
}
}
e.preventDefault();
@ -919,10 +928,16 @@ let Items = {
// default: the actual item count
// padding - pixels between each item
// columns - (int) a preset number of columns to use
// dropPos - a <Point> which should have a one-tab space left open, used
// when a tab is dragged over.
//
// Returns:
// an object with the width value of the child items and the number of columns,
// if the return option is set to 'widthAndColumns'; otherwise the list of <Rect>s
// By default, an object with two properties: `rects`, the list of <Rect>s,
// and `dropIndex`, the index which a dragged tab should have if dropped
// (null if no `dropPos` was specified);
// If the `return` option is set to 'widthAndColumns', an object with the
// width value of the child items (`childWidth`) and the number of columns
// (`columns`) is returned.
arrange: function Items_arrange(items, bounds, options) {
if (typeof options == 'undefined')
options = {};
@ -936,8 +951,12 @@ let Items = {
var tabAspect = TabItems.tabHeight / TabItems.tabWidth;
var count = options.count || (items ? items.length : 0);
if (!count)
return rects;
if (options.addTab)
count++;
if (!count) {
let dropIndex = (Utils.isPoint(options.dropPos)) ? 0 : null;
return {rects: rects, dropIndex: dropIndex};
}
var columns = options.columns || 1;
// We'll assume for the time being that all the items have the same styling
@ -981,17 +1000,23 @@ let Items = {
var column = 0;
var dropIndex = false;
var dropRect = false;
if (Utils.isPoint(options.dropPos))
dropRect = new Rect(options.dropPos.x, options.dropPos.y, 1, 1);
for (let a = 0; a < count; a++) {
rects.push(new Rect(box));
if (items && a < items.length) {
let item = items[a];
if (!item.locked.bounds) {
item.setBounds(box, immediately);
item.setRotation(0);
if (options.z)
item.setZ(options.z);
}
// If we had a dropPos, see if this is where we should place it
if (dropRect) {
let activeBox = new Rect(box);
activeBox.inset(-itemMargin - 1, -itemMargin - 1);
// if the designated position (dropRect) is within the active box,
// this is where, if we drop the tab being dragged, it should land!
if (activeBox.contains(dropRect))
dropIndex = a;
}
// record the box.
rects.push(new Rect(box));
box.left += (UI.rtl ? -1 : 1) * (box.width + padding);
column++;
@ -1002,7 +1027,7 @@ let Items = {
}
}
return rects;
return {rects: rects, dropIndex: dropIndex};
},
// ----------

View File

@ -262,22 +262,6 @@ Rect.prototype = {
this.top = a.top;
this.width = a.width;
this.height = a.height;
},
// ----------
// Function: css
// Returns an object with the dimensions of this rectangle, suitable for
// passing into iQ's css method. You could of course just pass the rectangle
// straight in, but this is cleaner, as it removes all the extraneous
// properties. If you give a <Rect> to <iQClass.css> without this, it will
// ignore the extraneous properties, but result in CSS warnings.
css: function Rect_css() {
return {
left: this.left,
top: this.top,
width: this.width,
height: this.height
};
}
};

View File

@ -335,10 +335,12 @@ SearchEventHandlerClass.prototype = {
});
iQ("#searchbutton").mousedown(function() {
self.initiatedBy = "buttonclick";
ensureSearchShown(null);
self.switchToInMode();
});
this.initiatedBy = "";
this.currentHandler = null;
this.switchToBeforeMode();
},
@ -358,6 +360,7 @@ SearchEventHandlerClass.prototype = {
return;
this.switchToInMode();
this.initiatedBy = "keypress";
ensureSearchShown(event);
},
@ -367,7 +370,7 @@ SearchEventHandlerClass.prototype = {
inSearchKeyHandler: function (event) {
let term = iQ("#searchbox").val();
if ((event.keyCode == event.DOM_VK_ESCAPE) ||
(event.keyCode == event.DOM_VK_BACK_SPACE && term.length <= 1)) {
(event.keyCode == event.DOM_VK_BACK_SPACE && term.length <= 1 && this.initiatedBy == "keypress")) {
hideSearch(event);
return;
}

View File

@ -53,7 +53,7 @@ function TabItem(tab, options) {
this.tab = tab;
// register this as the tab's tabItem
this.tab.tabItem = this;
this.tab._tabViewTabItem = this;
if (!options)
options = {};
@ -142,7 +142,7 @@ function TabItem(tab, options) {
position: "absolute",
zIndex: -99
})
.css(groupItemBounds.css())
.css(groupItemBounds)
.hide()
.appendTo("body");
@ -155,7 +155,7 @@ function TabItem(tab, options) {
// Utils.log('updatedBounds:',updatedBounds);
if (updatedBounds)
phantom.css(updatedBounds.css());
phantom.css(updatedBounds);
phantom.fadeIn();
@ -351,7 +351,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
if (tabData.groupID) {
var groupItem = GroupItems.groupItem(tabData.groupID);
if (groupItem) {
groupItem.add(this, null, {immediately: true});
groupItem.add(this, {immediately: true});
// if it matches the selected tab or no active tab and the browser
// tab is hidden, the active group item would be set.
@ -364,7 +364,9 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
if (tabData.imageData)
this.showCachedData(tabData);
} else {
GroupItems.newTab(this, {immediately: true});
// create tab by double click is handled in UI_init().
if (!TabItems.creatingNewOrphanTab)
GroupItems.newTab(this, {immediately: true});
}
this._reconnected = true;
@ -392,6 +394,8 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
if (!options)
options = {};
TabItems.enforceMinSize(rect);
if (this._zoomPrep)
this.bounds.copy(rect);
else {
@ -574,7 +578,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
if (value) {
this.resizeOptions.minWidth = TabItems.minTabWidth;
this.resizeOptions.minHeight = TabItems.minTabWidth * (TabItems.tabHeight / TabItems.tabWidth);
this.resizeOptions.minHeight = TabItems.minTabHeight;
immediately ? $resizer.show() : $resizer.fadeIn();
this.resizable(true);
} else {
@ -648,7 +652,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
TabItems.resumePainting();
$tabEl
.css(orig.css())
.css(orig)
.removeClass("front");
onZoomDone();
@ -742,9 +746,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
let animateZoom = gPrefBranch.getBoolPref("animate_zoom");
var $div = iQ(this.container);
var data;
var box = this.getBounds();
if (value && animateZoom) {
this._zoomPrep = true;
@ -761,6 +763,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
.addClass('front')
.css(this.getZoomRect(2));
} else {
let box = this.getBounds();
this._zoomPrep = false;
$div.removeClass('front');
@ -787,6 +790,7 @@ let TabItems = {
_lastUpdateTime: Date.now(),
_eventListeners: [],
_pauseUpdateForTest: false,
creatingNewOrphanTab: false,
tempCanvas: null,
_reconnectingPaused: false,
@ -796,6 +800,8 @@ let TabItems = {
init: function TabItems_init() {
Utils.assert(window.AllTabs, "AllTabs must be initialized first");
let self = this;
this.minTabHeight = this.minTabWidth * this.tabHeight / this.tabWidth;
let $canvas = iQ("<canvas>");
$canvas.appendTo(iQ("body"));
@ -883,7 +889,7 @@ let TabItems = {
try {
Utils.assertThrow(tab, "tab");
Utils.assertThrow(!tab.pinned, "shouldn't be an app tab");
Utils.assertThrow(tab.tabItem, "should already be linked");
Utils.assertThrow(tab._tabViewTabItem, "should already be linked");
let shouldDefer = (
this.isPaintingPaused() ||
@ -923,16 +929,24 @@ let TabItems = {
this._tabsWaitingForUpdate.splice(index, 1);
// ___ get the TabItem
Utils.assertThrow(tab.tabItem, "must already be linked");
let tabItem = tab.tabItem;
Utils.assertThrow(tab._tabViewTabItem, "must already be linked");
let tabItem = tab._tabViewTabItem;
// ___ icon
let iconUrl = tab.image;
if (!iconUrl)
iconUrl = Utils.defaultFaviconURL;
if (this.shouldLoadFavIcon(tab.linkedBrowser)) {
let iconUrl = tab.image;
if (!iconUrl)
iconUrl = Utils.defaultFaviconURL;
if (iconUrl != tabItem.favImgEl.src)
tabItem.favImgEl.src = iconUrl;
if (iconUrl != tabItem.favImgEl.src)
tabItem.favImgEl.src = iconUrl;
iQ(tabItem.favEl).show();
} else {
if (tabItem.favImgEl.hasAttribute("src"))
tabItem.favImgEl.removeAttribute("src");
iQ(tabItem.favEl).hide();
}
// ___ URL
let tabUrl = tab.linkedBrowser.currentURI.spec;
@ -972,6 +986,14 @@ let TabItems = {
}
},
// ----------
// Function: shouldLoadFavIcon
// Takes a xul:browser and checks whether we should display a favicon for it.
shouldLoadFavIcon: function TabItems_shouldLoadFavIcon(browser) {
return !(browser.contentDocument instanceof window.ImageDocument) &&
gBrowser.shouldLoadFavIcon(browser.contentDocument.documentURIObject);
},
// ----------
// Function: link
// Takes in a xul:tab, creates a TabItem for it and adds it to the scene.
@ -979,8 +1001,8 @@ let TabItems = {
try {
Utils.assertThrow(tab, "tab");
Utils.assertThrow(!tab.pinned, "shouldn't be an app tab");
Utils.assertThrow(!tab.tabItem, "shouldn't already be linked");
new TabItem(tab, options); // sets tab.tabItem to itself
Utils.assertThrow(!tab._tabViewTabItem, "shouldn't already be linked");
new TabItem(tab, options); // sets tab._tabViewTabItem to itself
} catch(e) {
Utils.log(e);
}
@ -992,16 +1014,16 @@ let TabItems = {
unlink: function TabItems_unlink(tab) {
try {
Utils.assertThrow(tab, "tab");
Utils.assertThrow(tab.tabItem, "should already be linked");
Utils.assertThrow(tab._tabViewTabItem, "should already be linked");
// note that it's ok to unlink an app tab; see .handleTabUnpin
this.unregister(tab.tabItem);
tab.tabItem._sendToSubscribers("close");
iQ(tab.tabItem.container).remove();
tab.tabItem.removeTrenches();
Items.unsquish(null, tab.tabItem);
this.unregister(tab._tabViewTabItem);
tab._tabViewTabItem._sendToSubscribers("close");
iQ(tab._tabViewTabItem.container).remove();
tab._tabViewTabItem.removeTrenches();
Items.unsquish(null, tab._tabViewTabItem);
tab.tabItem = null;
tab._tabViewTabItem = null;
Storage.saveTab(tab, null);
let index = this._tabsWaitingForUpdate.indexOf(tab);
@ -1172,6 +1194,18 @@ let TabItems = {
}
return sane;
},
// ----------
// Function: enforceMinSize
// Takes a <Rect> and modifies that <Rect> in case it is too small to be
// the bounds of a <TabItem>.
//
// Parameters:
// bounds - (<Rect>) the target bounds of a <TabItem>
enforceMinSize: function TabItems_enforceMinSize(bounds) {
bounds.width = Math.max(bounds.width, this.minTabWidth);
bounds.height = Math.max(bounds.height, this.minTabHeight);
}
};

View File

@ -190,20 +190,13 @@ body {
display: none;
}
/* Exit button
----------------------------------*/
#exit-button {
position: absolute;
z-index: 1000;
}
/* Search
----------------------------------*/
#searchshade{
position: absolute;
top: 0px;
left: 0px;
z-index: 1000;
z-index: 1000001;
}
#search{
@ -211,7 +204,7 @@ body {
top: 0px;
left: 0px;
pointer-events: none;
z-index: 1050;
z-index: 1000050;
}
html[dir=rtl] #search {
@ -233,25 +226,14 @@ html[dir=rtl] #searchbox {
#actions{
position: absolute;
top: 100px;
right: 0px;
z-index: 10;
top: 0px;
right: -3px;
z-index: 1000000;
}
html[dir=rtl] #actions {
right: auto;
left: 0;
}
#actions #searchbutton{
position: relative;
top: 0;
left: 0;
}
html[dir=rtl] #actions #searchbutton {
left: auto;
right: 0;
left: -3px;
}
#otherresults{
@ -261,7 +243,7 @@ html[dir=rtl] #actions #searchbutton {
}
.onTop{
z-index: 1010 !important;
z-index: 1000010 !important;
}
.inlineMatch{

View File

@ -12,8 +12,8 @@
<div id="content">
<div id="bg">
</div>
<input id="exit-button" type="image" alt="" groups="0" />
<div id="actions">
<input id="exit-button" type="button" alt="" groups="0" />
<input id="searchbutton" type="button"/>
</div>
</div>

View File

@ -3,16 +3,12 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource:///modules/tabview/AllTabs.jsm");
Cu.import("resource:///modules/tabview/groups.jsm");
Cu.import("resource:///modules/tabview/utils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "gWindow", function() {
return window.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIWebNavigation).
QueryInterface(Ci.nsIDocShell).
chromeEventHandler.ownerDocument.defaultView;
return window.parent;
});
XPCOMUtils.defineLazyGetter(this, "gBrowser", function() gWindow.gBrowser);
@ -33,9 +29,7 @@ XPCOMUtils.defineLazyGetter(this, "tabviewBundle", function() {
function tabviewString(name) tabviewBundle.GetStringFromName('tabview.' + name);
XPCOMUtils.defineLazyGetter(this, "gPrefBranch", function() {
return Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService).
getBranch("browser.panorama.");
return Services.prefs.getBranch("browser.panorama.");
});
XPCOMUtils.defineLazyGetter(this, "gPrivateBrowsing", function() {

View File

@ -233,7 +233,7 @@ Trench.prototype = {
if (!this.dom.guideTrench)
this.dom.guideTrench = iQ("<div/>").addClass('guideTrench').css({id: 'guideTrench'+this.id});
var guideTrench = this.dom.guideTrench;
guideTrench.css(this.guideRect.css());
guideTrench.css(this.guideRect);
iQ("body").append(guideTrench);
} else {
if (this.dom.guideTrench) {
@ -266,8 +266,8 @@ Trench.prototype = {
else
activeVisibleTrench.removeClass('activeTrench');
visibleTrench.css(this.rect.css());
activeVisibleTrench.css((this.activeRect || this.rect).css());
visibleTrench.css(this.rect);
activeVisibleTrench.css(this.activeRect || this.rect);
iQ("body").append(visibleTrench);
iQ("body").append(activeVisibleTrench);
},

View File

@ -49,40 +49,55 @@ let Keys = { meta: false };
// Class: UI
// Singleton top-level UI manager.
let UI = {
// Constant: DBLCLICK_INTERVAL
// Defines the maximum time (in ms) between two clicks for it to count as
// a double click.
DBLCLICK_INTERVAL: 500,
// Constant: DBLCLICK_OFFSET
// Defines the maximum offset (in pixels) between two clicks for it to count as
// a double click.
DBLCLICK_OFFSET: 5,
// Variable: _frameInitialized
// True if the Tab View UI frame has been initialized.
_frameInitialized: false,
// Variable: _pageBounds
// Stores the page bounds.
_pageBounds : null,
_pageBounds: null,
// Variable: _closedLastVisibleTab
// If true, the last visible tab has just been closed in the tab strip.
_closedLastVisibleTab : false,
_closedLastVisibleTab: false,
// Variable: _closedSelectedTabInTabView
// If true, a select tab has just been closed in TabView.
_closedSelectedTabInTabView : false,
_closedSelectedTabInTabView: false,
// Variable: restoredClosedTab
// If true, a closed tab has just been restored.
restoredClosedTab : false,
restoredClosedTab: false,
// Variable: _reorderTabItemsOnShow
// Keeps track of the <GroupItem>s which their tab items' tabs have been moved
// and re-orders the tab items when switching to TabView.
_reorderTabItemsOnShow : [],
_reorderTabItemsOnShow: [],
// Variable: _reorderTabsOnHide
// Keeps track of the <GroupItem>s which their tab items have been moved in
// TabView UI and re-orders the tabs when switcing back to main browser.
_reorderTabsOnHide : [],
_reorderTabsOnHide: [],
// Variable: _currentTab
// Keeps track of which xul:tab we are currently on.
// Used to facilitate zooming down from a previous tab.
_currentTab : null,
_currentTab: null,
// Variable: _lastClick
// Keeps track of the time of last click event to detect double click.
// Used to create tabs on double-click since we cannot attach 'dblclick'
_lastClick: 0,
// Variable: _eventListeners
// Keeps track of event listeners added to the AllTabs object.
@ -151,8 +166,38 @@ let UI = {
element.blur();
});
}
if (e.originalTarget.id == "content")
self._createGroupItemOnDrag(e)
if (e.originalTarget.id == "content") {
// Create an orphan tab on double click
if (Date.now() - self._lastClick <= self.DBLCLICK_INTERVAL &&
(self._lastClickPositions.x - self.DBLCLICK_OFFSET) <= e.clientX &&
(self._lastClickPositions.x + self.DBLCLICK_OFFSET) >= e.clientX &&
(self._lastClickPositions.y - self.DBLCLICK_OFFSET) <= e.clientY &&
(self._lastClickPositions.y + self.DBLCLICK_OFFSET) >= e.clientY) {
GroupItems.setActiveGroupItem(null);
TabItems.creatingNewOrphanTab = true;
let newTab =
gBrowser.loadOneTab("about:blank", { inBackground: true });
let box =
new Rect(e.clientX - Math.floor(TabItems.tabWidth/2),
e.clientY - Math.floor(TabItems.tabHeight/2),
TabItems.tabWidth, TabItems.tabHeight);
newTab._tabViewTabItem.setBounds(box, true);
newTab._tabViewTabItem.pushAway(true);
GroupItems.setActiveOrphanTab(newTab._tabViewTabItem);
TabItems.creatingNewOrphanTab = false;
newTab._tabViewTabItem.zoomIn(true);
self._lastClick = 0;
self._lastClickPositions = null;
} else {
self._lastClick = Date.now();
self._lastClickPositions = new Point(e.clientX, e.clientY);
self._createGroupItemOnDrag(e);
}
}
});
iQ(window).bind("beforeunload", function() {
@ -295,7 +340,7 @@ let UI = {
items.forEach(function(item) {
if (item.parent)
item.parent.remove(item);
groupItem.add(item, null, {immediately: true});
groupItem.add(item, {immediately: true});
});
if (firstTime) {
@ -303,7 +348,7 @@ let UI = {
let url = gPrefBranch.getCharPref("welcome_url");
let newTab = gBrowser.loadOneTab(url, {inBackground: true});
let newTabItem = newTab.tabItem;
let newTabItem = newTab._tabViewTabItem;
let parent = newTabItem.parent;
Utils.assert(parent, "should have a parent");
@ -354,20 +399,21 @@ let UI = {
//
// Parameters:
// - Takes a <TabItem>
setActiveTab: function UI_setActiveTab(tab) {
if (tab == this._activeTab)
setActiveTab: function UI_setActiveTab(tabItem) {
if (tabItem == this._activeTab)
return;
if (this._activeTab) {
this._activeTab.makeDeactive();
this._activeTab.removeSubscriber(this, "close");
}
this._activeTab = tab;
this._activeTab = tabItem;
if (this._activeTab) {
var self = this;
this._activeTab.addSubscriber(this, "close", function() {
self._activeTab = null;
let self = this;
this._activeTab.addSubscriber(this, "close", function(closedTabItem) {
if (self._activeTab == closedTabItem)
self._activeTab = null;
});
this._activeTab.makeActive();
@ -428,15 +474,15 @@ let UI = {
let event = document.createEvent("Events");
event.initEvent("tabviewshown", true, false);
if (zoomOut && currentTab && currentTab.tabItem) {
item = currentTab.tabItem;
if (zoomOut && currentTab && currentTab._tabViewTabItem) {
item = currentTab._tabViewTabItem;
// If there was a previous currentTab we want to animate
// its thumbnail (canvas) for the zoom out.
// Note that we start the animation on the chrome thread.
// Zoom out!
item.zoomOut(function() {
if (!currentTab.tabItem) // if the tab's been destroyed
if (!currentTab._tabViewTabItem) // if the tab's been destroyed
item = null;
self.setActiveTab(item);
@ -451,8 +497,8 @@ let UI = {
dispatchEvent(event);
});
} else {
if (currentTab && currentTab.tabItem)
currentTab.tabItem.setZoomPrep(false);
if (currentTab && currentTab._tabViewTabItem)
currentTab._tabViewTabItem.setZoomPrep(false);
self.setActiveTab(null);
dispatchEvent(event);
@ -538,6 +584,7 @@ let UI = {
this.reset(false);
TabItems.resumeReconnecting();
GroupItems._updateTabBar();
}
},
@ -583,7 +630,6 @@ let UI = {
} else if (aTopic == "private-browsing-change-granted") {
if (aData == "enter" || aData == "exit") {
self._privateBrowsing.transitionMode = aData;
GroupItems.pauseUpdatingTabBar();
self.storageBusy();
}
} else if (aTopic == "private-browsing-transition-complete") {
@ -594,7 +640,6 @@ let UI = {
self._privateBrowsing.transitionMode = "";
self.storageReady();
GroupItems.resumeUpdatingTabBar();
}
}
@ -664,8 +709,8 @@ let UI = {
// for the tab focus event to pick up.
self._closedLastVisibleTab = true;
// remove the zoom prep.
if (tab && tab.tabItem)
tab.tabItem.setZoomPrep(false);
if (tab && tab._tabViewTabItem)
tab._tabViewTabItem.setZoomPrep(false);
self.showTabView();
}
}
@ -774,13 +819,15 @@ let UI = {
let oldItem = null;
let newItem = null;
if (currentTab && currentTab.tabItem)
oldItem = currentTab.tabItem;
if (currentTab && currentTab._tabViewTabItem)
oldItem = currentTab._tabViewTabItem;
// update the tab bar for the new tab's group
if (tab && tab.tabItem) {
newItem = tab.tabItem;
GroupItems.updateActiveGroupItemAndTabBar(newItem);
if (tab && tab._tabViewTabItem) {
if (!TabItems.reconnectingPaused()) {
newItem = tab._tabViewTabItem;
GroupItems.updateActiveGroupItemAndTabBar(newItem);
}
} else {
// No tabItem; must be an app tab. Base the tab bar on the current group.
// If no current group or orphan tab, figure it out based on what's
@ -789,7 +836,7 @@ let UI = {
for (let a = 0; a < gBrowser.tabs.length; a++) {
let theTab = gBrowser.tabs[a];
if (!theTab.pinned) {
let tabItem = theTab.tabItem;
let tabItem = theTab._tabViewTabItem;
if (tabItem.parent)
GroupItems.setActiveGroupItem(tabItem.parent);
else
@ -858,16 +905,15 @@ let UI = {
getClosestTab: function UI_getClosestTab(tabCenter) {
let cl = null;
let clDist;
for each(item in TabItems.getItems()) {
if (item.parent && item.parent.hidden) {
continue;
}
TabItems.getItems().forEach(function (item) {
if (item.parent && item.parent.hidden)
return;
let testDist = tabCenter.distance(item.bounds.center());
if (cl==null || testDist < clDist) {
cl = item;
clDist = testDist;
}
}
});
return cl;
},
@ -1254,7 +1300,7 @@ let UI = {
// selected tab is an app tab), just go there.
let activeTabItem = this.getActiveTab();
if (!activeTabItem) {
let tabItem = gBrowser.selectedTab.tabItem;
let tabItem = gBrowser.selectedTab._tabViewTabItem;
if (tabItem) {
if (!tabItem.parent || !tabItem.parent.hidden) {
activeTabItem = tabItem;

View File

@ -167,6 +167,7 @@ _BROWSER_FILES = \
browser_bug609700.js \
browser_bug616836.js \
browser_bug623893.js \
browser_bug624734.js \
browser_contextSearchTabPosition.js \
browser_ctrlTab.js \
browser_disablechrome.js \

View File

@ -0,0 +1,22 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Bug 624734 - Star UI has no tooltip until bookmarked page is visited
function test() {
waitForExplicitFinish();
let tab = gBrowser.selectedTab = gBrowser.addTab();
tab.linkedBrowser.addEventListener("load", (function(event) {
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
is(PlacesStarButton._starIcon.getAttribute("tooltiptext"), PlacesStarButton._unstarredTooltip,
"Star icon should have the unstarred tooltip text");
gBrowser.removeCurrentTab();
finish();
}), true);
tab.linkedBrowser.loadURI("http://example.com/browser/browser/base/content/test/dummy_page.html");
}

View File

@ -106,7 +106,6 @@ function runNextTest() {
if (!onHiddenArray.length)
goNext();
}, onHiddenArray.length);
info("[Test #" + gTestIndex + "] added listeners; panel state: " + PopupNotifications.isPanelOpen);
}
@ -136,7 +135,7 @@ var gNewTab;
function basicNotification() {
var self = this;
this.browser = gBrowser.selectedBrowser;
this.id = "test-notification";
this.id = "test-notification-" + gTestIndex;
this.message = "This is popup notification " + this.id + " from test " + gTestIndex;
this.anchorID = null;
this.mainAction = {
@ -280,7 +279,7 @@ var tests = [
},
onShown: function (popup) {
checkPopup(popup, this.notifyObj);
dismissNotification(popup);
this.notification2.remove();
},
onHidden: function (popup) {
}
@ -293,7 +292,7 @@ var tests = [
showNotification(this.testNotif1);
this.testNotif2 = new basicNotification();
this.testNotif2.message += " 2";
this.testNotif2.id = "test-notification-2";
this.testNotif2.id += "-2";
showNotification(this.testNotif2);
},
onShown: function (popup) {
@ -320,13 +319,14 @@ var tests = [
run: function () {
this.notifyObj = new basicNotification(),
this.notifyObj.mainAction = null;
showNotification(this.notifyObj);
this.notification = showNotification(this.notifyObj);
},
onShown: function (popup) {
checkPopup(popup, this.notifyObj);
dismissNotification(popup);
},
onHidden: function (popup) {
this.notification.remove();
}
},
// Test two notifications with different anchors
@ -348,14 +348,16 @@ var tests = [
dismissNotification(popup);
},
onHidden: [
// The second showing triggers a popuphidden event that we should ignore.
function (popup) {},
function (popup) {
// Remove the first notification
// Remove the notifications
this.firstNotification.remove();
this.secondNotification.remove();
ok(this.notifyObj.removedCallbackTriggered, "removed callback triggered");
},
// The removal triggers another popuphidden event.
function (popup) {}
],
ok(this.notifyObj2.removedCallbackTriggered, "removed callback triggered");
}
]
},
// Test optional params
{ // Test #10
@ -389,7 +391,12 @@ var tests = [
dismissNotification(popup);
},
onHidden: function (popup) {
let icon = document.getElementById("geo-notification-icon");
isnot(icon.boxObject.width, 0,
"geo anchor should be visible after dismissal");
this.notification.remove();
is(icon.boxObject.width, 0,
"geo anchor should not be visible after removal");
}
},
// Test that persistence allows the notification to persist across reloads
@ -414,7 +421,7 @@ var tests = [
loadURI("http://example.org/", function() {
loadURI("http://example.com/", function() {
// Next load will hide the notification
// Next load will remove the notification
self.complete = true;
loadURI("http://example.org/");
@ -423,7 +430,7 @@ var tests = [
},
onHidden: function (popup) {
ok(this.complete, "Should only have hidden the notification after 3 page loads");
this.notification.remove();
ok(this.notifyObj.removedCallbackTriggered, "removal callback triggered");
gBrowser.removeTab(gBrowser.selectedTab);
gBrowser.selectedTab = this.oldSelectedTab;
}
@ -559,6 +566,23 @@ var tests = [
ok(this.notifyObj.removedCallbackTriggered, "removed callback triggered");
}
},
// Test notification close button
{ // Test #18
run: function () {
this.notifyObj = new basicNotification(),
this.notification = showNotification(this.notifyObj);
},
onShown: function (popup) {
checkPopup(popup, this.notifyObj);
let notification = popup.childNodes[0];
EventUtils.synthesizeMouseAtCenter(notification.closebutton, {});
},
onHidden: function (popup) {
ok(this.notifyObj.dismissalCallbackTriggered, "dismissal callback triggered");
this.notification.remove();
ok(this.notifyObj.removedCallbackTriggered, "removed callback triggered");
}
},
];
function showNotification(notifyObj) {

View File

@ -137,54 +137,6 @@ var gTestSteps = [
}, true);
tab.linkedBrowser.loadURI('about:robots');
},
function() {
info("Running step 9 - enter private browsing mode, without keeping session");
let ps = Services.prefs;
ps.setBoolPref("browser.privatebrowsing.keep_current_session", false);
ps.setBoolPref("browser.tabs.warnOnClose", false);
Services.obs.addObserver(function(aSubject, aTopic, aData) {
Services.obs.removeObserver(arguments.callee, "private-browsing-transition-complete");
for (let i = 0; i < gBrowser.tabs.length; i++)
waitForRestoredTab(gBrowser.tabs[i]);
}, "private-browsing-transition-complete", false);
gPrivateBrowsing.privateBrowsingEnabled = true;
},
function() {
info("Running step 10 - open tabs in private browsing mode");
for (let i = 0; i < 3; i++) {
let tab = gBrowser.addTab();
loadTab(tab, TEST_URL_BASES[0] + (++gTabCounter));
}
},
function() {
info("Running step 11 - close tabs in private browsing mode");
gBrowser.removeCurrentTab();
ensure_opentabs_match_db(nextStep);
},
function() {
info("Running step 12 - leave private browsing mode");
Services.obs.addObserver(function(aSubject, aTopic, aData) {
Services.obs.removeObserver(arguments.callee, "private-browsing-transition-complete");
let ps = Services.prefs;
try {
ps.clearUserPref("browser.privatebrowsing.keep_current_session");
} catch (ex) {}
try {
ps.clearUserPref("browser.tabs.warnOnClose");
} catch (ex) {}
for (let i = 1; i < gBrowser.tabs.length; i++)
waitForRestoredTab(gBrowser.tabs[i]);
}, "private-browsing-transition-complete", false);
gPrivateBrowsing.privateBrowsingEnabled = false;
}
];
@ -196,7 +148,7 @@ function test() {
function loadTab(tab, url) {
// Because adding visits is async, we will not be notified immediately.
let visited = gPrivateBrowsing.privateBrowsingEnabled;
let visited = false;
let loaded = false;
function maybeCheckResults() {
@ -211,37 +163,22 @@ function loadTab(tab, url) {
maybeCheckResults();
}, true);
if (!visited) {
Services.obs.addObserver(
function (aSubject, aTopic, aData) {
if (url != aSubject.QueryInterface(Ci.nsIURI).spec)
return;
Services.obs.removeObserver(arguments.callee, aTopic);
visited = true;
maybeCheckResults();
},
"uri-visit-saved",
false
);
}
Services.obs.addObserver(
function (aSubject, aTopic, aData) {
if (url != aSubject.QueryInterface(Ci.nsIURI).spec)
return;
Services.obs.removeObserver(arguments.callee, aTopic);
visited = true;
maybeCheckResults();
},
"uri-visit-saved",
false
);
gTabWaitCount++;
info("Loading page: " + url);
tab.linkedBrowser.loadURI(url);
}
function waitForRestoredTab(tab) {
gTabWaitCount++;
tab.linkedBrowser.addEventListener("load", function () {
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
if (--gTabWaitCount == 0) {
ensure_opentabs_match_db(nextStep);
}
}, true);
}
function nextStep() {
if (gTestSteps.length == 0) {
while (gBrowser.tabs.length > 1) {

View File

@ -51,29 +51,37 @@ _BROWSER_FILES = \
browser_tabview_bug587043.js \
browser_tabview_bug587231.js \
browser_tabview_bug587351.js \
browser_tabview_bug587503.js \
browser_tabview_bug587990.js \
browser_tabview_bug588265.js \
browser_tabview_bug589324.js \
browser_tabview_bug590606.js \
browser_tabview_bug591706.js \
browser_tabview_bug594176.js \
browser_tabview_bug595191.js \
browser_tabview_bug595436.js \
browser_tabview_bug595518.js \
browser_tabview_bug595521.js \
browser_tabview_bug595560.js \
browser_tabview_bug595804.js \
browser_tabview_bug595930.js \
browser_tabview_bug595943.js \
browser_tabview_bug596781.js \
browser_tabview_bug597248.js \
browser_tabview_bug597360.js \
browser_tabview_bug597399.js \
browser_tabview_bug598600.js \
browser_tabview_bug599626.js \
browser_tabview_bug600645.js \
browser_tabview_bug604098.js \
browser_tabview_bug606657.js \
browser_tabview_bug606905.js \
browser_tabview_bug608037.js \
browser_tabview_bug608158.js \
browser_tabview_bug610242.js \
browser_tabview_bug618828.js \
browser_tabview_bug619937.js \
browser_tabview_bug624265.js \
browser_tabview_dragdrop.js \
browser_tabview_exit_button.js \
browser_tabview_group.js \

View File

@ -55,11 +55,15 @@ function onTabViewWindowLoaded() {
is(contentWindow.GroupItems.groupItems.length, 1, "There is only one group");
let currentActiveGroup = contentWindow.GroupItems.getActiveGroupItem();
// is(currentActiveGroup.getBounds.bottom(), 40,
// "There's currently 40 px between the first group and second group");
// set double click interval to negative so quick drag and drop doesn't
// trigger the double click code.
let origDBlClickInterval = contentWindow.UI.DBLCLICK_INTERVAL;
contentWindow.UI.DBLCLICK_INTERVAL = -1;
let endGame = function() {
contentWindow.UI.reset();
contentWindow.UI.DBLCLICK_INTERVAL = origDBlClickInterval;
let onTabViewHidden = function() {
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
ok(!TabView.isVisible(), "TabView is shown");
@ -68,11 +72,11 @@ function onTabViewWindowLoaded() {
window.addEventListener("tabviewhidden", onTabViewHidden, false);
ok(TabView.isVisible(), "TabView is shown");
gBrowser.selectedTab = originalTab;
TabView.hide();
}
let part1 = function() {
// move down 20 so we're far enough away from the top.
checkSnap(currentActiveGroup, 0, 20, contentWindow, function(snapped){
@ -81,10 +85,10 @@ function onTabViewWindowLoaded() {
// Just pick it up and drop it.
checkSnap(currentActiveGroup, 0, 0, contentWindow, function(snapped){
ok(!snapped,"Just pick it up and drop it");
checkSnap(currentActiveGroup, 0, 1, contentWindow, function(snapped){
ok(snapped,"Drag one pixel: should snap");
checkSnap(currentActiveGroup, 0, 5, contentWindow, function(snapped){
ok(!snapped,"Moving five pixels: shouldn't snap");
endGame();
@ -128,7 +132,7 @@ function simulateDragDrop(tabItem, offsetX, offsetY, contentWindow) {
false, false, false, false, 0, null, dataTransfer);
tabItem.container.dispatchEvent(event);
}
// drop
EventUtils.synthesizeMouse(
tabItem.container, 0, 0, { type: "mouseup" }, contentWindow);

View File

@ -61,7 +61,7 @@ function onTabViewWindowLoaded() {
ok(testGroup.isEmpty(), "This group is empty");
// place tab in group
let testTabItem = testTab.tabItem;
let testTabItem = testTab._tabViewTabItem;
if (testTabItem.parent)
testTabItem.parent.remove(testTabItem);
@ -103,8 +103,8 @@ function onTabViewWindowLoaded() {
ok((lastTime - initialUpdateTime) > hbTiming, "Tab has been updated:"+lastTime+"-"+initialUpdateTime+">"+hbTiming);
// clean up
testGroup.remove(testTab.tabItem);
testTab.tabItem.close();
testGroup.remove(testTab._tabViewTabItem);
testTab._tabViewTabItem.close();
testGroup.close();
let currentTabs = contentWindow.TabItems.getItems();

View File

@ -0,0 +1,245 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is bug 587503 test.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Yoshitaka Erlewine <mitcho@mitcho.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function test() {
waitForExplicitFinish();
window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
if (TabView.isVisible())
onTabViewWindowLoaded();
else
TabView.show();
}
function onTabViewWindowLoaded() {
window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
ok(TabView.isVisible(), "Tab View is visible");
let contentWindow = document.getElementById("tab-view").contentWindow;
let [originalTab] = gBrowser.visibleTabs;
let currentGroup = contentWindow.GroupItems.getActiveGroupItem();
// Create a group and make it active
let box = new contentWindow.Rect(100, 100, 370, 370);
let group = new contentWindow.GroupItem([], { bounds: box });
ok(group.isEmpty(), "This group is empty");
contentWindow.GroupItems.setActiveGroupItem(group);
// Create a bunch of tabs in the group
let tabs = [];
tabs.push(gBrowser.loadOneTab("about:blank#0", {inBackground: true}));
tabs.push(gBrowser.loadOneTab("about:blank#1", {inBackground: true}));
tabs.push(gBrowser.loadOneTab("about:blank#2", {inBackground: true}));
tabs.push(gBrowser.loadOneTab("about:blank#3", {inBackground: true}));
tabs.push(gBrowser.loadOneTab("about:blank#4", {inBackground: true}));
tabs.push(gBrowser.loadOneTab("about:blank#5", {inBackground: true}));
tabs.push(gBrowser.loadOneTab("about:blank#6", {inBackground: true}));
ok(!group.shouldStack(group._children.length), "Group should not stack.");
// PREPARE FINISH:
group.addSubscriber(group, "close", function() {
group.removeSubscriber(group, "close");
ok(group.isEmpty(), "The group is empty again");
contentWindow.GroupItems.setActiveGroupItem(currentGroup);
isnot(contentWindow.GroupItems.getActiveGroupItem(), null, "There is an active group");
is(gBrowser.tabs.length, 1, "There is only one tab left");
is(gBrowser.visibleTabs.length, 1, "There is also only one visible tab");
let onTabViewHidden = function() {
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
finish();
};
window.addEventListener("tabviewhidden", onTabViewHidden, false);
gBrowser.selectedTab = originalTab;
TabView.hide();
});
// STAGE 1: move the last tab to the third position
let currentTarget = tabs[6]._tabViewTabItem;
let currentPos = currentTarget.getBounds().center();
let targetPos = tabs[2]._tabViewTabItem.getBounds().center();
let vector = new contentWindow.Point(targetPos.x - currentPos.x,
targetPos.y - currentPos.y);
checkDropIndexAndDropSpace(currentTarget, group, vector.x, vector.y, contentWindow,
function(index, dropSpaceActiveValues) {
// Now: 0, 1, 6, 2, 3, 4, 5
is(index, 2, "Tab 6 is now in the third position");
is(dropSpaceActiveValues[0], true, "dropSpace was always showing");
// STAGE 2: move the second tab to the end of the list
let currentTarget = tabs[1]._tabViewTabItem;
let currentPos = currentTarget.getBounds().center();
// pick a point in that empty bottom part of the group
let groupBounds = group.getBounds();
let bottomPos = new contentWindow.Point(
(groupBounds.left + groupBounds.right) / 2,
groupBounds.bottom - 15);
let vector = new contentWindow.Point(bottomPos.x - currentPos.x,
bottomPos.y - currentPos.y);
checkDropIndexAndDropSpace(currentTarget, group, vector.x, vector.y, contentWindow,
function(index, dropSpaceActiveValues) {
// Now: 0, 6, 2, 3, 4, 5, 1
is(index, 6, "Tab 1 is now at the end of the group");
is(dropSpaceActiveValues[0], true, "dropSpace was always showing");
// STAGE 3: move the fifth tab outside the group
// Note: there should be room below the active group...
let currentTarget = tabs[4]._tabViewTabItem;
let currentPos = currentTarget.getBounds().center();
// Pick a point below the group.
let belowPos = new contentWindow.Point(
(groupBounds.left + groupBounds.right) / 2,
groupBounds.bottom + 300);
let vector = new contentWindow.Point(belowPos.x - currentPos.x,
belowPos.y - currentPos.y);
checkDropIndexAndDropSpace(currentTarget, group, vector.x, vector.y, contentWindow,
function(index, dropSpaceActiveValues) {
// Now: 0, 6, 2, 3, 5, 1
is(index, -1, "Tab 5 is no longer in the group");
contentWindow.Utils.log('dropSpaceActiveValues',dropSpaceActiveValues);
is(dropSpaceActiveValues[0], true, "The group began by showing a dropSpace");
is(dropSpaceActiveValues[dropSpaceActiveValues.length - 1], false, "In the end, the group was not showing a dropSpace");
// We wrap this in a setTimeout with 1000ms delay in order to wait for the
// tab to resize, as it does after we drop it in stage 3 outside of the group.
setTimeout(function() {
// STAGE 4: move the fifth tab back into the group, on the second row.
let currentTarget = tabs[4]._tabViewTabItem;
let currentPos = currentTarget.getBounds().center();
let targetPos = tabs[5]._tabViewTabItem.getBounds().center();
// contentWindow.Utils.log(targetPos, currentPos);
vector = new contentWindow.Point(targetPos.x - currentPos.x,
targetPos.y - currentPos.y);
// Call with time = 4000
checkDropIndexAndDropSpace(currentTarget, group, vector.x, vector.y, contentWindow,
function(index, dropSpaceActiveValues) {
// Now: 0, 6, 2, 3, 4, 5, 1
is(index, 4, "Tab 5 is back and again the fifth tab.");
contentWindow.Utils.log('dropSpaceActiveValues',dropSpaceActiveValues);
is(dropSpaceActiveValues[0], false, "The group began by not showing a dropSpace");
is(dropSpaceActiveValues[dropSpaceActiveValues.length - 1], true, "In the end, the group was showing a dropSpace");
// Get rid of the group and its children
// The group close will trigger a finish().
group.closeAll();
group.closeHidden();
}, 6000, false);
},1000);
});
});
});
}
function simulateSlowDragDrop(srcElement, offsetX, offsetY, contentWindow, time) {
// enter drag mode
let dataTransfer;
// contentWindow.Utils.log('offset', offsetX, offsetY);
let bounds = srcElement.getBoundingClientRect();
// contentWindow.Utils.log('original center', bounds.left + bounds.width / 2, bounds.top + bounds.height / 2);
EventUtils.synthesizeMouse(
srcElement, 2, 2, { type: "mousedown" }, contentWindow);
let event = contentWindow.document.createEvent("DragEvents");
event.initDragEvent(
"dragenter", true, true, contentWindow, 0, 0, 0, 0, 0,
false, false, false, false, 1, null, dataTransfer);
srcElement.dispatchEvent(event);
let steps = 20;
// drag over
let moveIncremental = function moveIncremental(i, steps) {
// calculate how much to move
let offsetXDiff = Math.round(i * offsetX / steps) - Math.round((i - 1) * offsetX / steps);
let offsetYDiff = Math.round(i * offsetY / steps) - Math.round((i - 1) * offsetY / steps);
// contentWindow.Utils.log('step', offsetXDiff, offsetYDiff);
// simulate mousemove
EventUtils.synthesizeMouse(
srcElement, offsetXDiff + 2, offsetYDiff + 2,
{ type: "mousemove" }, contentWindow);
// simulate dragover
let event = contentWindow.document.createEvent("DragEvents");
event.initDragEvent(
"dragover", true, true, contentWindow, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, dataTransfer);
srcElement.dispatchEvent(event);
let bounds = srcElement.getBoundingClientRect();
// contentWindow.Utils.log(i, 'center', bounds.left + bounds.width / 2, bounds.top + bounds.height / 2);
};
for (let i = 1; i <= steps; i++)
setTimeout(moveIncremental, i / (steps + 1) * time, i, steps);
// drop
let finalDrop = function finalDrop() {
EventUtils.synthesizeMouseAtCenter(srcElement, { type: "mouseup" }, contentWindow);
event = contentWindow.document.createEvent("DragEvents");
event.initDragEvent(
"drop", true, true, contentWindow, 0, 0, 0, 0, 0,
false, false, false, false, 0, null, dataTransfer);
srcElement.dispatchEvent(event);
contentWindow.iQ(srcElement).css({border: 'green 1px solid'});
}
setTimeout(finalDrop, time);
}
function checkDropIndexAndDropSpace(item, group, offsetX, offsetY, contentWindow, callback, time) {
contentWindow.UI.setActiveTab(item);
let dropSpaceActiveValues = [];
let recordDropSpaceValue = function() {
dropSpaceActiveValues.push(group._dropSpaceActive);
};
// contentWindow.iQ(item.container).css({border: 'red 1px solid'});
let onDrop = function() {
item.container.removeEventListener('dragover', recordDropSpaceValue, false);
item.container.removeEventListener('drop', onDrop, false);
let index = group._children.indexOf(item);
callback(index, dropSpaceActiveValues);
};
item.container.addEventListener('dragover', recordDropSpaceValue, false);
item.container.addEventListener('drop', onDrop, false);
simulateSlowDragDrop(item.container, offsetX, offsetY, contentWindow, time || 1000);
}

View File

@ -0,0 +1,131 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is bug 588265 test.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Raymond Lee <raymond@appcoast.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function test() {
waitForExplicitFinish();
window.addEventListener("tabviewshown", setup, false);
TabView.toggle();
}
function setup() {
window.removeEventListener("tabviewshown", setup, false);
let contentWindow = document.getElementById("tab-view").contentWindow;
is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
let groupItemOne = contentWindow.GroupItems.groupItems[0];
// add a blank tab to group one.
createNewTabItemInGroupItem(groupItemOne, contentWindow, function() {
is(groupItemOne.getChildren().length, 2, "Group one has 2 tab items");
// create group two with a blank tab.
let groupItemTwo = createEmptyGroupItem(contentWindow, 250, 250, 40, true);
createNewTabItemInGroupItem(groupItemTwo, contentWindow, function() {
// start the first test.
testGroups(groupItemOne, groupItemTwo, contentWindow);
});
});
}
function createNewTabItemInGroupItem(groupItem, contentWindow, callback) {
// click on the + button to create a blank tab in group item
let newTabButton = groupItem.container.getElementsByClassName("newTabButton");
ok(newTabButton[0], "New tab button exists");
let onTabViewHidden = function() {
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
ok(!TabView.isVisible(), "Tab View is hidden because we just opened a tab");
TabView.toggle();
};
let onTabViewShown = function() {
window.removeEventListener("tabviewshown", onTabViewShown, false);
ok(TabView.isVisible(), "Tab View is visible");
callback();
};
window.addEventListener("tabviewhidden", onTabViewHidden, false);
window.addEventListener("tabviewshown", onTabViewShown, false);
EventUtils.sendMouseEvent({ type: "click" }, newTabButton[0], contentWindow);
}
function testGroups(groupItemOne, groupItemTwo, contentWindow) {
// check active tab and group
is(contentWindow.GroupItems.getActiveGroupItem(), groupItemTwo,
"The group two is the active group");
is(contentWindow.UI.getActiveTab(), groupItemTwo.getChild(0),
"The first tab item in group two is active");
let tabItem = groupItemOne.getChild(1);
tabItem.addSubscriber(tabItem, "tabRemoved", function() {
tabItem.removeSubscriber(tabItem, "tabRemoved");
is(groupItemOne.getChildren().length, 1,
"The num of childen in group one is 1");
// check active group and active tab
is(contentWindow.GroupItems.getActiveGroupItem(), groupItemOne,
"The group one is the active group");
is(contentWindow.UI.getActiveTab(), groupItemOne.getChild(0),
"The first tab item in group one is active");
let onTabViewHidden = function() {
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
is(groupItemOne.getChildren().length, 2,
"The num of childen in group one is 2");
// clean up and finish
groupItemTwo.addSubscriber(groupItemTwo, "close", function() {
groupItemTwo.removeSubscriber(groupItemTwo, "close");
gBrowser.removeTab(groupItemOne.getChild(1).tab);
is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
is(groupItemOne.getChildren().length, 1,
"The num of childen in group one is 1");
is(gBrowser.tabs.length, 1, "Has only one tab");
finish();
});
gBrowser.removeTab(groupItemTwo.getChild(0).tab);
}
window.addEventListener("tabviewhidden", onTabViewHidden, false);
EventUtils.synthesizeKey("t", { accelKey: true });
});
// close a tab item in group one
tabItem.close();
}

View File

@ -55,7 +55,7 @@ function onTabViewWindowLoaded() {
// Create a first tab and orphan it
let firstTab = gBrowser.loadOneTab("about:blank#1", {inBackground: true});
let firstTabItem = firstTab.tabItem;
let firstTabItem = firstTab._tabViewTabItem;
let currentGroup = contentWindow.GroupItems.getActiveGroupItem();
ok(currentGroup.getChildren().some(function(child) child == firstTabItem),"The first tab was made in the current group");
contentWindow.GroupItems.getActiveGroupItem().remove(firstTabItem);
@ -69,7 +69,7 @@ function onTabViewWindowLoaded() {
// Create a second tab in this new group
let secondTab = gBrowser.loadOneTab("about:blank#2", {inBackground: true});
let secondTabItem = secondTab.tabItem;
let secondTabItem = secondTab._tabViewTabItem;
ok(group.getChildren().some(function(child) child == secondTabItem),"The second tab was made in our new group");
is(group.getChildren().length, 1, "Only one tab in the first group");
isnot(firstTab.linkedBrowser.contentWindow.location, secondTab.linkedBrowser.contentWindow.location, "The two tabs must have different locations");

View File

@ -0,0 +1,101 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is a test for bug 595436.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tim Taubert <tim.taubert@gmx.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function test() {
waitForExplicitFinish();
window.addEventListener('tabviewshown', onTabViewWindowLoaded, false);
TabView.toggle();
}
function onTabViewWindowLoaded() {
window.removeEventListener('tabviewshown', onTabViewWindowLoaded, false);
let contentWindow = document.getElementById('tab-view').contentWindow;
let search = contentWindow.document.getElementById('search');
let searchButton = contentWindow.document.getElementById('searchbutton');
let isSearchEnabled = function () {
return 'none' != search.style.display;
}
let assertSearchIsEnabled = function () {
ok(isSearchEnabled(), 'search is enabled');
}
let assertSearchIsDisabled = function () {
ok(!isSearchEnabled(), 'search is disabled');
}
let testSearchInitiatedByKeyPress = function () {
EventUtils.synthesizeKey('a', {});
assertSearchIsEnabled();
EventUtils.synthesizeKey('VK_BACK_SPACE', {});
assertSearchIsDisabled();
}
let testSearchInitiatedByMouseClick = function () {
EventUtils.sendMouseEvent({type: 'mousedown'}, searchButton, contentWindow);
assertSearchIsEnabled();
EventUtils.synthesizeKey('a', {});
EventUtils.synthesizeKey('VK_BACK_SPACE', {});
EventUtils.synthesizeKey('VK_BACK_SPACE', {});
assertSearchIsEnabled();
EventUtils.synthesizeKey('VK_ESCAPE', {});
assertSearchIsDisabled();
}
let finishTest = function () {
let onTabViewHidden = function () {
window.removeEventListener('tabviewhidden', onTabViewHidden, false);
finish();
}
window.addEventListener('tabviewhidden', onTabViewHidden, false);
TabView.hide();
}
assertSearchIsDisabled();
testSearchInitiatedByKeyPress();
testSearchInitiatedByMouseClick();
finishTest();
}

View File

@ -97,7 +97,7 @@ function testThree(contentWindow) {
"tabviewsearchenabled", onSearchEnabled, false);
let searchBox = contentWindow.iQ("#searchbox");
searchBox.val(newTabOne.tabItem.nameEl.innerHTML);
searchBox.val(newTabOne._tabViewTabItem.nameEl.innerHTML);
contentWindow.performSearch();

View File

@ -56,7 +56,7 @@ function onTabViewWindowLoaded() {
ok(group1.isEmpty(), "This group is empty");
contentWindow.GroupItems.setActiveGroupItem(group1);
let tab1 = gBrowser.loadOneTab("about:blank#1", {inBackground: true});
let tab1Item = tab1.tabItem;
let tab1Item = tab1._tabViewTabItem;
ok(group1.getChildren().some(function(child) child == tab1Item), "The tab was made in our new group");
is(group1.getChildren().length, 1, "Only one tab in the first group");

View File

@ -102,6 +102,6 @@ function onTabViewWindowLoaded() {
}
window.addEventListener("tabviewhidden", onTabViewHidden, false);
EventUtils.sendMouseEvent({ type: "mousedown" }, normalXulTab.tabItem.container, contentWindow);
EventUtils.sendMouseEvent({ type: "mouseup" }, normalXulTab.tabItem.container, contentWindow);
EventUtils.sendMouseEvent({ type: "mousedown" }, normalXulTab._tabViewTabItem.container, contentWindow);
EventUtils.sendMouseEvent({ type: "mouseup" }, normalXulTab._tabViewTabItem.container, contentWindow);
}

View File

@ -0,0 +1,75 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is tabview bug 596781 test.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Raymond Lee <raymond@appcoast.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
let newTab;
function test() {
waitForExplicitFinish();
newTab = gBrowser.addTab();
gBrowser.pinTab(newTab);
window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
TabView.toggle();
}
function onTabViewWindowLoaded() {
window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
ok(TabView.isVisible(), "Tab View is visible");
let contentWindow = document.getElementById("tab-view").contentWindow;
is(contentWindow.GroupItems.groupItems.length, 1, "Only one group exists");
is(gBrowser.tabs.length, 2, "Only one tab exists");
ok(newTab.pinned, "The original tab is pinned");
let groupItem = contentWindow.GroupItems.groupItems[0];
is(groupItem.$closeButton[0].style.display, "none",
"The close button is hidden");
gBrowser.unpinTab(newTab);
is(groupItem.$closeButton[0].style.display, "",
"The close button is visible");
let onTabViewHidden = function() {
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
gBrowser.removeTab(newTab);
finish();
}
window.addEventListener("tabviewhidden", onTabViewHidden, false);
TabView.toggle();
}

View File

@ -0,0 +1,121 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is a test for bug 604098.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Raymond Lee <raymond@appcoast.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
let originalTab;
let orphanedTab;
let contentWindow;
function test() {
waitForExplicitFinish();
window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
TabView.show();
}
function onTabViewWindowLoaded() {
window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
contentWindow = document.getElementById("tab-view").contentWindow;
originalTab = gBrowser.visibleTabs[0];
test1();
}
function test1() {
is(contentWindow.GroupItems.getOrphanedTabs().length, 0, "No orphaned tabs");
let onTabViewHidden = function() {
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
let onTabViewShown = function() {
window.removeEventListener("tabviewshown", onTabViewShown, false);
is(contentWindow.GroupItems.getOrphanedTabs().length, 1,
"An orphaned tab is created");
orphanedTab = contentWindow.GroupItems.getOrphanedTabs()[0].tab;
test2();
};
window.addEventListener("tabviewshown", onTabViewShown, false);
TabView.show();
};
window.addEventListener("tabviewhidden", onTabViewHidden, false);
// first click
EventUtils.sendMouseEvent(
{ type: "mousedown" }, contentWindow.document.getElementById("content"),
contentWindow);
EventUtils.sendMouseEvent(
{ type: "mouseup" }, contentWindow.document.getElementById("content"),
contentWindow);
// second click
EventUtils.sendMouseEvent(
{ type: "mousedown" }, contentWindow.document.getElementById("content"),
contentWindow);
EventUtils.sendMouseEvent(
{ type: "mouseup" }, contentWindow.document.getElementById("content"),
contentWindow);
}
function test2() {
let groupItem = createEmptyGroupItem(contentWindow, 300, 300, 200);
is(groupItem.getChildren().length, 0, "The group is empty");
let onTabViewHidden = function() {
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
is(groupItem.getChildren().length, 1, "A tab is created inside the group");
gBrowser.selectedTab = originalTab;
gBrowser.removeTab(orphanedTab);
gBrowser.removeTab(groupItem.getChildren()[0].tab);
finish();
};
window.addEventListener("tabviewhidden", onTabViewHidden, false);
// first click
EventUtils.sendMouseEvent(
{ type: "mousedown" }, groupItem.container, contentWindow);
EventUtils.sendMouseEvent(
{ type: "mouseup" }, groupItem.container, contentWindow);
// second click
EventUtils.sendMouseEvent(
{ type: "mousedown" }, groupItem.container, contentWindow);
EventUtils.sendMouseEvent(
{ type: "mouseup" }, groupItem.container, contentWindow);
}

View File

@ -11,7 +11,7 @@
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is TabView Groups.
* The Original Code is a test for bug 606657.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
@ -19,8 +19,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Edward Lee <edilee@mozilla.com>
* Ian Gilman <ian@iangilman.com>
* Tim Taubert <tim.taubert@gmx.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -36,35 +35,31 @@
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const Cr = Components.results;
function test() {
waitForExplicitFinish();
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
window.addEventListener('tabviewshown', onTabViewWindowLoaded, false);
TabView.toggle();
}
let EXPORTED_SYMBOLS = ["Groups"];
function onTabViewWindowLoaded() {
window.removeEventListener('tabviewshown', onTabViewWindowLoaded, false);
let Groups = let (T = {
//////////////////////////////////////////////////////////////////////////////
//// Public
//////////////////////////////////////////////////////////////////////////////
let [tab] = gBrowser.tabs;
let groupId = tab._tabViewTabItem.parent.id;
//////////////////////////////////////////////////////////////////////////////
//// Private
//////////////////////////////////////////////////////////////////////////////
let finishTest = function () {
let onTabViewHidden = function () {
window.removeEventListener('tabviewhidden', onTabViewHidden, false);
finish();
}
init: function init() {
// Only allow calling init once
T.init = function() T;
// load all groups data
// presumably we can load from app global, not a window
// how do we know which window has which group?
// load tab data to figure out which go into which group
// set up interface for subscribing to our data
return T;
window.addEventListener('tabviewhidden', onTabViewHidden, false);
TabView.hide();
}
}) T.init();
TabView.moveTabTo(tab, groupId);
is(tab._tabViewTabItem.parent.id, groupId, 'tab did not change its group');
finishTest();
}

View File

@ -83,8 +83,8 @@ function onTabViewWindowLoaded() {
is(groupItems[0].getChildren().length, 2, "The group has two tab items");
tabTwo = undoCloseTab(0);
tabTwo.tabItem.addSubscriber(tabTwo, "reconnected", function() {
tabTwo.tabItem.removeSubscriber(tabTwo, "reconnected");
tabTwo._tabViewTabItem.addSubscriber(tabTwo, "reconnected", function() {
tabTwo._tabViewTabItem.removeSubscriber(tabTwo, "reconnected");
ok(TabView.isVisible(), "Tab View is still visible after restoring a tab");
is(groupItems[0].getChildren().length, 3, "The group still has three tab items");

View File

@ -0,0 +1,122 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is bug 610242 test.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Yoshitaka Erlewine <mitcho@mitcho.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function test() {
waitForExplicitFinish();
newWindowWithTabView(onTabViewWindowLoaded);
}
function onTabViewWindowLoaded(win) {
win.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
ok(win.TabView.isVisible(), "Tab View is visible");
let contentWindow = win.document.getElementById("tab-view").contentWindow;
let [originalTab] = win.gBrowser.visibleTabs;
let currentGroup = contentWindow.GroupItems.getActiveGroupItem();
// Create a group and make it active
let box = new contentWindow.Rect(100, 100, 370, 370);
let group = new contentWindow.GroupItem([], { bounds: box });
ok(group.isEmpty(), "This group is empty");
contentWindow.GroupItems.setActiveGroupItem(group);
is(contentWindow.GroupItems.getActiveGroupItem(), group, "new group is active");
// Create a bunch of tabs in the group
let bg = {inBackground: true};
let datatext = win.gBrowser.loadOneTab("data:text/plain,bug610242", bg);
let datahtml = win.gBrowser.loadOneTab("data:text/html,<blink>don't blink!</blink>", bg);
let mozilla = win.gBrowser.loadOneTab("about:mozilla", bg);
let html = win.gBrowser.loadOneTab("http://example.com", bg);
let png = win.gBrowser.loadOneTab("http://mochi.test:8888/browser/browser/base/content/test/moz.png", bg);
let svg = win.gBrowser.loadOneTab("http://mochi.test:8888/browser/browser/base/content/test/title_test.svg", bg);
ok(!group.shouldStack(group._children.length), "Group should not stack.");
// PREPARE FINISH:
group.addSubscriber(group, "close", function() {
group.removeSubscriber(group, "close");
ok(group.isEmpty(), "The group is empty again");
contentWindow.GroupItems.setActiveGroupItem(currentGroup);
isnot(contentWindow.GroupItems.getActiveGroupItem(), null, "There is an active group");
is(win.gBrowser.tabs.length, 1, "There is only one tab left");
is(win.gBrowser.visibleTabs.length, 1, "There is also only one visible tab");
let onTabViewHidden = function() {
win.removeEventListener("tabviewhidden", onTabViewHidden, false);
win.close();
ok(win.closed, "new window is closed");
finish();
};
win.addEventListener("tabviewhidden", onTabViewHidden, false);
win.gBrowser.selectedTab = originalTab;
win.TabView.hide();
});
function check(tab, label, visible) {
let display = contentWindow.getComputedStyle(tab._tabViewTabItem.favEl, null).getPropertyValue("display");
if (visible) {
is(display, "block", label + " has favicon");
} else {
is(display, "none", label + " has no favicon");
}
}
afterAllTabsLoaded(function() {
afterAllTabItemsUpdated(function() {
check(datatext, "datatext", false);
check(datahtml, "datahtml", false);
check(mozilla, "about:mozilla", false);
check(html, "html", true);
check(png, "png", false);
check(svg, "svg", true);
// Get rid of the group and its children
// The group close will trigger a finish().
group.addSubscriber(group, "groupHidden", function() {
group.removeSubscriber(group, "groupHidden");
group.closeHidden();
});
group.closeAll();
}, win);
}, win);
}

View File

@ -0,0 +1,232 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is tabview bug 624265 test.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tim Taubert <tim.taubert@gmx.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
let pb = Cc['@mozilla.org/privatebrowsing;1'].
getService(Ci.nsIPrivateBrowsingService);
function test() {
let tests = [];
let getContentWindow = function () {
return TabView.getContentWindow();
}
let assertOneSingleGroupItem = function () {
is(getContentWindow().GroupItems.groupItems.length, 1, 'There is one single groupItem');
}
let assertNumberOfVisibleTabs = function (numTabs) {
is(gBrowser.visibleTabs.length, numTabs, 'There should be ' + numTabs + ' visible tabs');
}
let restoreTab = function (callback) {
let tab = undoCloseTab(0);
tab._tabViewTabItem.addSubscriber(tab, 'reconnected', function () {
tab._tabViewTabItem.removeSubscriber(tab, 'reconnected');
afterAllTabsLoaded(callback);
});
}
let next = function () {
while (gBrowser.tabs.length-1)
gBrowser.removeTab(gBrowser.tabs[1]);
hideTabView(function () {
let callback = tests.shift();
if (!callback)
callback = finish;
callback();
});
}
// ----------
// [624265] testing undo close tab
let testUndoCloseTabs = function () {
gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true});
gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true});
afterAllTabsLoaded(function () {
assertNumberOfVisibleTabs(3);
gBrowser.removeTab(gBrowser.tabs[1]);
gBrowser.selectedTab = gBrowser.tabs[1];
restoreTab(function () {
assertNumberOfVisibleTabs(3);
assertOneSingleGroupItem();
next();
});
});
}
// ----------
// [623792] duplicating tab via middle click on reload button
let testDuplicateTab = function () {
gBrowser.loadOneTab('http://mochi.test:8888/', {inBackground: true});
afterAllTabsLoaded(function () {
duplicateTabIn(gBrowser.selectedTab, 'current');
afterAllTabsLoaded(function () {
assertNumberOfVisibleTabs(3);
assertOneSingleGroupItem();
next();
});
});
}
// ----------
// [623792] duplicating tabs via middle click on forward/back buttons
let testBackForwardDuplicateTab = function () {
let tab = gBrowser.loadOneTab('http://mochi.test:8888/#1', {inBackground: true});
gBrowser.selectedTab = tab;
let continueTest = function () {
tab.linkedBrowser.loadURI('http://mochi.test:8888/#2');
afterAllTabsLoaded(function () {
ok(gBrowser.canGoBack, 'browser can go back in history');
BrowserBack({button: 1});
afterAllTabsLoaded(function () {
assertNumberOfVisibleTabs(3);
ok(gBrowser.canGoForward, 'browser can go forward in history');
BrowserForward({button: 1});
afterAllTabsLoaded(function () {
assertNumberOfVisibleTabs(4);
assertOneSingleGroupItem();
next();
});
});
});
}
// The executeSoon() call is really needed here because there's probably
// some callback waiting to be fired after gBrowser.loadOneTab(). After
// that the browser is in a state where loadURI() will create a new entry
// in the session history (that is vital for back/forward functionality).
afterAllTabsLoaded(function () SimpleTest.executeSoon(continueTest));
}
// ----------
// [624102] check state after return from private browsing
let testPrivateBrowsing = function () {
gBrowser.loadOneTab('http://mochi.test:8888/#1', {inBackground: true});
gBrowser.loadOneTab('http://mochi.test:8888/#2', {inBackground: true});
let cw = getContentWindow();
let box = new cw.Rect(20, 20, 250, 200);
let groupItem = new cw.GroupItem([], {bounds: box, immediately: true});
cw.GroupItems.setActiveGroupItem(groupItem);
gBrowser.selectedTab = gBrowser.loadOneTab('http://mochi.test:8888/#3', {inBackground: true});
gBrowser.loadOneTab('http://mochi.test:8888/#4', {inBackground: true});
afterAllTabsLoaded(function () {
assertNumberOfVisibleTabs(2);
enterAndLeavePrivateBrowsing(function () {
assertNumberOfVisibleTabs(2);
next();
});
});
}
waitForExplicitFinish();
// tests for #624265
tests.push(testUndoCloseTabs);
// tests for #623792
tests.push(testDuplicateTab);
tests.push(testBackForwardDuplicateTab);
// tests for #624102
tests.push(testPrivateBrowsing);
loadTabView(next);
}
// ----------
function loadTabView(callback) {
window.addEventListener('tabviewshown', function () {
window.removeEventListener('tabviewshown', arguments.callee, false);
hideTabView(function () {
window.removeEventListener('tabviewhidden', arguments.callee, false);
callback();
});
}, false);
TabView.show();
}
// ----------
function hideTabView(callback) {
if (!TabView.isVisible())
return callback();
window.addEventListener('tabviewhidden', function () {
window.removeEventListener('tabviewhidden', arguments.callee, false);
callback();
}, false);
TabView.hide();
}
// ----------
function enterAndLeavePrivateBrowsing(callback) {
function pbObserver(aSubject, aTopic, aData) {
if (aTopic != "private-browsing-transition-complete")
return;
if (pb.privateBrowsingEnabled)
pb.privateBrowsingEnabled = false;
else {
Services.obs.removeObserver(pbObserver, "private-browsing-transition-complete");
afterAllTabsLoaded(callback);
}
}
Services.obs.addObserver(pbObserver, "private-browsing-transition-complete", false);
pb.privateBrowsingEnabled = true;
}

View File

@ -63,7 +63,7 @@ function onTabViewWindowLoaded() {
let contentWindow = newWin.document.getElementById("tab-view").contentWindow;
// 1) the tab should belong to a group, and no orphan tabs
ok(tabOne.tabItem.parent, "Tab one belongs to a group");
ok(tabOne._tabViewTabItem.parent, "Tab one belongs to a group");
is(contentWindow.GroupItems.getOrphanedTabs().length, 0, "No orphaned tabs");
// 2) create a group, add a blank tab

View File

@ -147,7 +147,7 @@ function verifyCleanState(mode) {
let prefix = "we " + (mode || "finish") + " with ";
is(gBrowser.tabs.length, 1, prefix + "one tab");
is(contentWindow.GroupItems.groupItems.length, 1, prefix + "1 group");
ok(gBrowser.tabs[0].tabItem.parent == contentWindow.GroupItems.groupItems[0],
ok(gBrowser.tabs[0]._tabViewTabItem.parent == contentWindow.GroupItems.groupItems[0],
"the tab is in the group");
ok(!pb.privateBrowsingEnabled, prefix + "private browsing off");
}
@ -157,7 +157,7 @@ function verifyPB() {
ok(pb.privateBrowsingEnabled == true, "private browsing is on");
is(gBrowser.tabs.length, 1, "we have 1 tab in private browsing");
is(contentWindow.GroupItems.groupItems.length, 1, "we have 1 group in private browsing");
ok(gBrowser.tabs[0].tabItem.parent == contentWindow.GroupItems.groupItems[0],
ok(gBrowser.tabs[0]._tabViewTabItem.parent == contentWindow.GroupItems.groupItems[0],
"the tab is in the group");
let browser = gBrowser.tabs[0].linkedBrowser;
@ -184,7 +184,7 @@ function verifyNormal() {
let groupItem = contentWindow.GroupItems.groupItems[a];
is(groupItem.getTitle(), groupTitles[a], prefix + "correct group title");
ok(tab.tabItem.parent == groupItem,
ok(tab._tabViewTabItem.parent == groupItem,
prefix + "tab " + a + " is in group " + a);
}
}
@ -203,23 +203,3 @@ function togglePBAndThen(callback) {
Services.obs.addObserver(pbObserver, "private-browsing-transition-complete", false);
pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled;
}
// ----------
function afterAllTabsLoaded(callback) {
let stillToLoad = 0;
function onLoad() {
this.removeEventListener("load", onLoad, true);
stillToLoad--;
if (!stillToLoad)
callback();
}
for (let a = 0; a < gBrowser.tabs.length; a++) {
let browser = gBrowser.tabs[a].linkedBrowser;
if (browser.webProgress.isLoadingDocument) {
stillToLoad++;
browser.addEventListener("load", onLoad, true);
}
}
}

View File

@ -70,7 +70,14 @@ function onTabViewWindowLoaded(win) {
is(secondGroup.getBounds().top - firstGroup.getBounds().bottom, 40,
"There's currently 40 px between the first group and second group");
// set double click interval to negative so quick drag and drop doesn't
// trigger the double click code.
let origDBlClickInterval = contentWindow.UI.DBLCLICK_INTERVAL;
contentWindow.UI.DBLCLICK_INTERVAL = -1;
let endGame = function() {
contentWindow.UI.DBLCLICK_INTERVAL = origDBlClickInterval;
firstGroup.container.parentNode.removeChild(firstGroup.container);
firstGroup.close();
thirdGroup.container.parentNode.removeChild(thirdGroup.container);

View File

@ -20,6 +20,8 @@
*
* Contributor(s):
* Raymond Lee <raymond@appcoast.com>
* Michael Yoshitaka Erlewine <mitcho@mitcho.com>
* Tim Taubert <tim.taubert@gmx.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -49,3 +51,57 @@ function createEmptyGroupItem(contentWindow, width, height, padding, noAnimation
return emptyGroupItem;
}
// ----------
function afterAllTabItemsUpdated(callback, win) {
win = win || window;
let tabItems = win.document.getElementById("tab-view").contentWindow.TabItems;
for (let a = 0; a < win.gBrowser.tabs.length; a++) {
let tabItem = win.gBrowser.tabs[a]._tabViewTabItem;
if (tabItem)
tabItems._update(win.gBrowser.tabs[a]);
}
callback();
}
// ---------
function newWindowWithTabView(callback) {
let win = window.openDialog(getBrowserURL(), "_blank",
"chrome,all,dialog=no,height=800,width=800");
let onLoad = function() {
win.removeEventListener("load", onLoad, false);
let onShown = function() {
win.removeEventListener("tabviewshown", onShown, false);
callback(win);
};
win.addEventListener("tabviewshown", onShown, false);
win.TabView.toggle();
}
win.addEventListener("load", onLoad, false);
}
// ----------
function afterAllTabsLoaded(callback, win) {
win = win || window;
let stillToLoad = 0;
function onLoad() {
this.removeEventListener("load", onLoad, true);
stillToLoad--;
if (!stillToLoad)
callback();
}
for (let a = 0; a < win.gBrowser.tabs.length; a++) {
let browser = win.gBrowser.tabs[a].linkedBrowser;
if (browser.contentDocument.readyState != "complete") {
stillToLoad++;
browser.addEventListener("load", onLoad, true);
}
}
if (!stillToLoad)
callback();
}

View File

@ -1063,6 +1063,12 @@
</xul:button>
</xul:hbox>
</xul:vbox>
<xul:vbox pack="start">
<xul:toolbarbutton anonid="closebutton"
class="messageCloseButton popup-notification-closebutton"
xbl:inherits="oncommand=closebuttoncommand"
tooltiptext="&closeNotification.tooltip;"/>
</xul:vbox>
</content>
<implementation>
<constructor><![CDATA[
@ -1103,6 +1109,12 @@
</xul:button>
</xul:hbox>
</xul:vbox>
<xul:vbox pack="start">
<xul:toolbarbutton anonid="closebutton"
class="messageCloseButton popup-notification-closebutton"
xbl:inherits="oncommand=closebuttoncommand"
tooltiptext="&closeNotification.tooltip;"/>
</xul:vbox>
</content>
<implementation>
<constructor><![CDATA[

View File

@ -44,4 +44,3 @@
!define CompanyName "mozilla.org"
!define URLInfoAbout "http://www.mozilla.org"
!define URLUpdateInfo "http://www.mozilla.org/projects/firefox"
!define SurveyURL "https://survey.mozilla.com/1/Mozilla%20Firefox/${AppVersion}/${AB_CD}/exit.html"

View File

@ -1,5 +1,4 @@
<!ENTITY brandShortName "Minefield">
<!ENTITY brandFullName "Minefield">
<!ENTITY brandFullName "Minefield">
<!ENTITY vendorShortName "Mozilla">
<!ENTITY trademarkInfo.part1 " ">
<!ENTITY trademarkInfo.part2 " ">

View File

@ -44,4 +44,3 @@
!define CompanyName "mozilla.org"
!define URLInfoAbout "http://www.mozilla.org"
!define URLUpdateInfo "http://www.mozilla.org/projects/firefox"
!define SurveyURL "https://survey.mozilla.com/1/Mozilla%20Firefox/${AppVersion}/${AB_CD}/exit.html"

View File

@ -2,4 +2,3 @@
<!ENTITY brandFullName "Mozilla Developer Preview">
<!ENTITY vendorShortName "mozilla.org">
<!ENTITY trademarkInfo.part1 " ">
<!ENTITY trademarkInfo.part2 " ">

View File

@ -42,6 +42,7 @@ Components.utils.import("resource://gre/modules/Services.jsm");
const PAGE_NO_ACCOUNT = 0;
const PAGE_HAS_ACCOUNT = 1;
const PAGE_NEEDS_UPDATE = 2;
let gSyncPane = {
_stringBundle: null,
@ -60,84 +61,52 @@ let gSyncPane = {
return Weave.Svc.Prefs.isSet("serverURL");
},
onLoginStart: function () {
if (this.page == PAGE_NO_ACCOUNT)
return;
document.getElementById("loginFeedbackRow").hidden = true;
document.getElementById("connectThrobber").hidden = false;
},
onLoginError: function () {
if (this.page == PAGE_NO_ACCOUNT)
return;
document.getElementById("connectThrobber").hidden = true;
document.getElementById("loginFeedbackRow").hidden = false;
needsUpdate: function () {
this.page = PAGE_NEEDS_UPDATE;
let label = document.getElementById("loginError");
label.value = Weave.Utils.getErrorString(Weave.Status.login);
label.className = "error";
},
onLoginFinish: function () {
document.getElementById("connectThrobber").hidden = true;
this.updateWeavePrefs();
},
init: function () {
let obs = [
["weave:service:login:start", "onLoginStart"],
["weave:service:login:error", "onLoginError"],
["weave:service:login:finish", "onLoginFinish"],
["weave:service:start-over", "updateWeavePrefs"],
["weave:service:setup-complete","updateWeavePrefs"],
["weave:service:logout:finish", "updateWeavePrefs"]];
let topics = ["weave:service:login:error",
"weave:service:login:finish",
"weave:service:start-over",
"weave:service:setup-complete",
"weave:service:logout:finish"];
// Add the observers now and remove them on unload
let self = this;
let addRem = function(add) {
obs.forEach(function([topic, func]) {
//XXXzpao This should use Services.obs.* but Weave's Obs does nice handling
// of `this`. Fix in a followup. (bug 583347)
if (add)
Weave.Svc.Obs.add(topic, self[func], self);
else
Weave.Svc.Obs.remove(topic, self[func], self);
});
};
addRem(true);
window.addEventListener("unload", function() addRem(false), false);
//XXXzpao This should use Services.obs.* but Weave's Obs does nice handling
// of `this`. Fix in a followup. (bug 583347)
topics.forEach(function (topic) {
Weave.Svc.Obs.add(topic, this.updateWeavePrefs, this);
}, this);
window.addEventListener("unload", function() {
topics.forEach(function (topic) {
Weave.Svc.Obs.remove(topic, this.updateWeavePrefs, this);
}, gSyncPane);
}, false);
this._stringBundle =
Services.strings.createBundle("chrome://browser/locale/preferences/preferences.properties");;
Services.strings.createBundle("chrome://browser/locale/preferences/preferences.properties");
this.updateWeavePrefs();
},
updateWeavePrefs: function () {
if (Weave.Status.service == Weave.CLIENT_NOT_CONFIGURED ||
Weave.Svc.Prefs.get("firstSync", "") == "notReady")
Weave.Svc.Prefs.get("firstSync", "") == "notReady") {
this.page = PAGE_NO_ACCOUNT;
else {
} else if (Weave.Status.login == Weave.LOGIN_FAILED_INVALID_PASSPHRASE ||
Weave.Status.login == Weave.LOGIN_FAILED_LOGIN_REJECTED) {
this.needsUpdate();
} else {
this.page = PAGE_HAS_ACCOUNT;
document.getElementById("currentAccount").value = Weave.Service.account;
document.getElementById("accountName").value = Weave.Service.account;
document.getElementById("syncComputerName").value = Weave.Clients.localName;
if (Weave.Status.service == Weave.LOGIN_FAILED)
this.onLoginError();
this.updateConnectButton();
document.getElementById("tosPP").hidden = this._usingCustomServer;
}
},
updateConnectButton: function () {
let str = Weave.Service.isLoggedIn ? this._stringBundle.GetStringFromName("disconnect.label")
: this._stringBundle.GetStringFromName("connect.label");
document.getElementById("connectButton").label = str;
},
handleConnectCommand: function () {
Weave.Service.isLoggedIn ? Weave.Service.logout() : Weave.Service.login();
},
startOver: function (showDialog) {
if (showDialog) {
let flags = Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING +
@ -155,11 +124,8 @@ let gSyncPane = {
return;
}
this.handleExpanderClick();
Weave.Service.startOver();
this.updateWeavePrefs();
document.getElementById("manageAccountExpander").className = "expander-down";
document.getElementById("manageAccountControls").hidden = true;
},
updatePass: function () {
@ -176,26 +142,6 @@ let gSyncPane = {
gSyncUtils.resetPassphrase();
},
handleExpanderClick: function () {
//XXXzpao Might be fixed in bug 583441, otherwise we'll need a new bug.
// ok, this is pretty evil, and likely fragile if the prefwindow
// binding changes, but that won't happen in 3.6 *fingers crossed*
let prefwindow = document.documentElement;
let pane = document.getElementById("paneSync");
if (prefwindow._shouldAnimate)
prefwindow._currentHeight = pane.contentHeight;
let expander = document.getElementById("manageAccountExpander");
let expand = expander.className == "expander-down";
expander.className =
expand ? "expander-up" : "expander-down";
document.getElementById("manageAccountControls").hidden = !expand;
// and... shazam
if (prefwindow._shouldAnimate)
prefwindow.animate("null", pane);
},
openSetup: function (resetSync) {
var win = Services.wm.getMostRecentWindow("Weave:AccountSetup");
if (win)
@ -216,6 +162,9 @@ let gSyncPane = {
},
openAddDevice: function () {
if (!Weave.Utils.ensureMPUnlocked())
return;
let win = Services.wm.getMostRecentWindow("Sync:AddDevice");
if (win)
win.focus();

View File

@ -84,75 +84,76 @@
</description>
<spacer flex="3"/>
</vbox>
<vbox id="hasAccount">
<groupbox>
<caption label="&accountGroupboxCaption.label;"/>
<grid>
<rows>
<row align="center">
<label value="&currentAccount.label;" control="currentAccount"/>
<textbox id="currentAccount" readonly="true">
<image/>
</textbox>
<hbox align="center">
<button id="connectButton" oncommand="gSyncPane.handleConnectCommand()"/>
<image id="connectThrobber"
hidden="true"/>
</hbox>
</row>
<row id="loginFeedbackRow" hidden="true">
<spacer/>
<label id="loginError" value=""/>
<hbox>
<label class="text-link"
onclick="gSyncPane.updatePass(); return false;"
value="&updatePass.label;"/>
<label class="text-link"
onclick="gSyncPane.resetPass(); return false;"
value="&resetPass.label;"/>
</hbox>
</row>
<!-- XXXzpao We should make this behave like the "details" view in CRH.
do in followup (bug 583441) -->
<row id="manageAccountControls" hidden="true">
<spacer/>
<vbox class="indent">
<label class="text-link"
onclick="gSyncPane.openQuotaDialog(); return false;"
value="&viewQuota.label;"/>
<label class="text-link"
onclick="gSyncUtils.changePassword(); return false;"
value="&changePassword.label;"/>
<label class="text-link"
onclick="gSyncUtils.resetPassphrase(); return false;"
value="&mySyncKey.label;"/>
<label class="text-link"
onclick="gSyncPane.resetSync(); return false;"
value="&resetSync.label;"/>
<label class="text-link"
onclick="gSyncPane.startOver(true); return false;"
value="&stopUsingAccount.label;"/>
</vbox>
<spacer/>
</row>
<row>
<spacer/>
<button id="manageAccountExpander"
class="expander-down"
label="&manageAccount.label;"
accesskey="&manageAccount.accesskey;"
align="left"
oncommand="gSyncPane.handleExpanderClick()"/>
<spacer/>
</row>
</rows>
</grid>
<label class="text-link"
onclick="gSyncPane.openAddDevice(); return false;"
value="&addDevice.label;"/>
<groupbox class="syncGroupBox">
<!-- label is set to account name -->
<caption id="accountCaption" align="center">
<image id="accountCaptionImage"/>
<label id="accountName" value=""/>
</caption>
<hbox>
<button type="menu"
label="&manageAccount.label;"
accesskey="&manageAccount.accesskey;">
<menupopup>
<menuitem label="&viewQuota.label;"
oncommand="gSyncPane.openQuotaDialog();"/>
<menuseparator/>
<menuitem label="&changePassword.label;"
oncommand="gSyncUtils.changePassword();"/>
<menuitem label="&mySyncKey.label;"
oncommand="gSyncUtils.resetPassphrase();"/>
<menuseparator/>
<menuitem label="&resetSync.label;"
oncommand="gSyncPane.resetSync();"/>
</menupopup>
</button>
</hbox>
<hbox>
<label id="syncAddDeviceLabel"
class="text-link"
onclick="gSyncPane.openAddDevice(); return false;"
value="&addDevice.label;"/>
</hbox>
<vbox>
<label value="&syncMy.label;" />
<richlistbox id="syncEnginesList"
orient="vertical"
onselect="if (this.selectedCount) this.clearSelection();">
<richlistitem>
<checkbox label="&engine.bookmarks.label;"
accesskey="&engine.bookmarks.accesskey;"
preference="engine.bookmarks"/>
</richlistitem>
<richlistitem>
<checkbox label="&engine.passwords.label;"
accesskey="&engine.passwords.accesskey;"
preference="engine.passwords"/>
</richlistitem>
<richlistitem>
<checkbox label="&engine.prefs.label;"
accesskey="&engine.prefs.accesskey;"
preference="engine.prefs"/>
</richlistitem>
<richlistitem>
<checkbox label="&engine.history.label;"
accesskey="&engine.history.accesskey;"
preference="engine.history"/>
</richlistitem>
<richlistitem>
<checkbox label="&engine.tabs.label;"
accesskey="&engine.tabs.accesskey;"
preference="engine.tabs"/>
</richlistitem>
</richlistbox>
</vbox>
</groupbox>
<groupbox>
<caption label="&syncPrefsCaption.label;"/>
<groupbox class="syncGroupBox">
<grid>
<columns>
<column/>
@ -166,29 +167,13 @@
<textbox id="syncComputerName"
onchange="gSyncUtils.changeName(this)"/>
</row>
<row>
<label value="&syncMy.label;" />
<vbox>
<checkbox label="&engine.bookmarks.label;"
accesskey="&engine.bookmarks.accesskey;"
preference="engine.bookmarks"/>
<checkbox label="&engine.passwords.label;"
accesskey="&engine.passwords.accesskey;"
preference="engine.passwords"/>
<checkbox label="&engine.prefs.label;"
accesskey="&engine.prefs.accesskey;"
preference="engine.prefs"/>
<checkbox label="&engine.history.label;"
accesskey="&engine.history.accesskey;"
preference="engine.history"/>
<checkbox label="&engine.tabs.label;"
accesskey="&engine.tabs.accesskey;"
preference="engine.tabs"/>
</vbox>
</row>
</rows>
</grid>
<separator/>
<hbox>
<label class="text-link"
onclick="gSyncPane.startOver(true); return false;"
value="&deactivateDevice.label;"/>
</hbox>
</groupbox>
<hbox id="tosPP" pack="center">
<label class="text-link"
@ -199,6 +184,21 @@
value="&prefs.ppLink.label;"/>
</hbox>
</vbox>
<vbox id="needsUpdate" align="center" pack="center">
<hbox>
<label id="loginError" value=""/>
<label class="text-link"
onclick="gSyncPane.updatePass(); return false;"
value="&updatePass.label;"/>
<label class="text-link"
onclick="gSyncPane.resetPass(); return false;"
value="&resetPass.label;"/>
</hbox>
<label class="text-link"
onclick="gSyncPane.startOver(true); return false;"
value="&deactivateDevice.label;"/>
</vbox>
</deck>
</prefpane>
</overlay>

View File

@ -134,6 +134,7 @@ _BROWSER_TEST_FILES = \
browser_607016.js \
browser_615394-SSWindowState_events.js \
browser_618151.js \
browser_522375.js \
$(NULL)
ifneq ($(OS_ARCH),Darwin)

View File

@ -0,0 +1,13 @@
function test() {
waitForExplicitFinish();
var startup_info = Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(Components.interfaces.nsIAppStartup_MOZILLA_2_0).getStartupInfo();
// No .process info on mac
is(startup_info.process <= startup_info.main, true, "process created before main is run " + uneval(startup_info));
// on linux firstPaint can happen after everything is loaded (especially with remote X)
if (startup_info.firstPaint)
is(startup_info.main <= startup_info.firstPaint, true, "main ran before first paint " + uneval(startup_info));
is(startup_info.main < startup_info.sessionRestored, true, "Session restored after main " + uneval(startup_info));
finish();
}

View File

@ -21,6 +21,8 @@
!define PreReleaseSuffix "@PRE_RELEASE_SUFFIX@"
!define BrandFullName "${BrandFullNameInternal}${PreReleaseSuffix}"
!define NO_UNINSTALL_SURVEY
# LSP_CATEGORIES is the permitted LSP categories for the application. Each LSP
# category value is ANDed together to set multiple permitted categories.
# See http://msdn.microsoft.com/en-us/library/ms742253%28VS.85%29.aspx

View File

@ -111,10 +111,6 @@ offlinepermissionstitle=Offline Data
# %2$S = unit (MB, KB, etc.)
actualCacheSize=Your cache is currently using %1$S %2$S of disk space
#### Syncing
connect.label=Connect
disconnect.label=Disconnect
stopUsingAccount.title=Do you want to stop using this account?
differentAccount.label=This will reset all of your Sync account information and preferences.
differentAccountConfirm.label=Reset All Information

View File

@ -4,8 +4,6 @@
<!ENTITY weaveDesc.label "&syncBrand.fullName.label; lets you access your history, bookmarks, passwords and open tabs across all your devices.">
<!-- The page shown when logged in... -->
<!ENTITY accountGroupboxCaption.label "&syncBrand.fullName.label; Account">
<!ENTITY currentAccount.label "Current Account:">
<!-- Login error feedback -->
<!ENTITY updatePass.label "Update">
@ -18,14 +16,8 @@
<!ENTITY changePassword.label "Change Password">
<!ENTITY mySyncKey.label "My Sync Key">
<!ENTITY resetSync.label "Reset Sync">
<!ENTITY stopUsingAccount.label "Stop Using This Account">
<!ENTITY addDevice.label "Add a Device">
<!-- Sync Settings -->
<!ENTITY syncPrefsCaption.label "Browser Sync">
<!ENTITY syncComputerName.label "Computer Name:">
<!ENTITY syncComputerName.accesskey "c">
<!ENTITY syncMy.label "Sync My">
<!ENTITY engine.bookmarks.label "Bookmarks">
<!ENTITY engine.bookmarks.accesskey "m">
@ -38,6 +30,10 @@
<!ENTITY engine.prefs.label "Preferences">
<!ENTITY engine.prefs.accesskey "S">
<!-- Device Settings -->
<!ENTITY syncComputerName.label "Computer Name:">
<!ENTITY syncComputerName.accesskey "c">
<!ENTITY deactivateDevice.label "Deactivate This Device">
<!-- Footer stuff -->
<!ENTITY prefs.tosLink.label "Terms of Service">

View File

@ -156,7 +156,7 @@ toolbarbutton.bookmark-item[open="true"] {
menu.bookmark-item,
menuitem.bookmark-item {
min-width: 0;
max-width: 26em;
max-width: 32em;
}
.bookmark-item > .menu-iconic-left {
@ -1790,21 +1790,27 @@ panel[dimmed="true"] {
opacity: 0.5;
}
/* Vertically-center the statusbar compatibility shim, because
toolbars, even in small-icon mode, are a bit taller than
statusbars. */
#status-bar {
margin-top: .3em;
/* Add-on bar */
#addon-bar {
padding: 0;
min-height: 20px;
}
#status-bar {
min-height: 0;
}
/* Remove all borders from statusbarpanel children of
the statusbar. */
#status-bar > statusbarpanel {
border-width: 0;
-moz-appearance: none;
}
/* Add-on bar close button */
#addonbar-closebutton {
list-style-image: url("moz-icon://stock/gtk-close?size=menu");
}
#addonbar-closebutton > .toolbarbutton-icon {
margin-top: -2px;
margin-bottom: -2px;
}

View File

@ -167,37 +167,22 @@ radio[pane=paneSync] {
%ifdef MOZ_SERVICES_SYNC
/* Sync Pane */
#syncDesc {
padding: 0 12em;
}
#currentUser image {
#accountCaptionImage {
list-style-image: url("chrome://mozapps/skin/profile/profileicon.png");
}
#connectThrobber {
list-style-image: url("chrome://global/skin/icons/loading_16.png");
}
.expander-up,
.expander-down {
min-width: 0;
padding: 2px 0;
-moz-padding-start: 2px;
#syncAddDeviceLabel {
margin-top: 1em;
margin-bottom: 1em;
}
.expander-up {
list-style-image: url("chrome://global/skin/arrow/arrow-up.gif");
#syncEnginesList {
height: 10em;
}
.expander-down {
list-style-image: url("chrome://global/skin/arrow/arrow-dn.gif");
}
.expander-down:hover:active {
list-style-image: url("chrome://global/skin/arrow/arrow-dn-hov.gif");
}
.expander-up:hover:active {
list-style-image: url("chrome://global/skin/arrow/arrow-up-hov.gif");
}
%endif

View File

@ -405,15 +405,14 @@ input.name {
margin-bottom: 0;
-moz-margin-start: 3px;
padding: 1px;
background-image: url(chrome://browser/skin/tabview/edit-light.png);
-moz-padding-start: 20px;
}
html[dir=rtl] input.name {
background-position: right top;
}
.title-container:hover input.name {
.title-container:hover input.name,
.title-container input.name:focus {
border: 1px solid #ddd;
}
@ -426,13 +425,17 @@ input.name:focus {
color: #555;
}
input.defaultName {
input.name:-moz-placeholder {
font-style: italic !important;
background-image-opacity: .1;
color: transparent;
background-image: url(chrome://browser/skin/tabview/edit-light.png);
background-image-opacity: .1;
background-repeat: no-repeat;
-moz-padding-start: 20px;
-moz-padding-end: -20px;
}
.title-container:hover input.defaultName {
.title-container:hover input.name:-moz-placeholder {
color: #CCC;
}
@ -511,16 +514,14 @@ html[dir=rtl] .iq-resizable-se {
/* Exit button
+----------------------------------*/
#exit-button {
cursor: default;
top: 0;
right: 0;
width: 16px;
height: 16px;
-moz-margin-end: 7px;
margin-top: 7px;
-moz-margin-end: 8px;
margin-top: 5px;
background-image: -moz-image-rect(url(chrome://browser/skin/tabview/tabview.png), 0, 80, 16, 64);
background-attachment: scroll;
background-repeat: no-repeat;
border: none;
}
#exit-button[groups="0"] {
@ -539,11 +540,6 @@ html[dir=rtl] .iq-resizable-se {
background-image: -moz-image-rect(url(chrome://browser/skin/tabview/tabview.png), 0, 64, 16, 48);
}
html[dir=rtl] #exit-button {
right: auto;
left: 0;
}
/* Search
----------------------------------*/
#searchshade{
@ -571,10 +567,22 @@ html[dir=rtl] #exit-button {
}
#actions{
width: 26px;
height: 26px;
border: none;
top: -3px;
padding-top: 3px;
width: 29px;
text-align: center;
border: 1px solid rgba(230,230,230,1);
background-color: rgba(248,248,248,1);
border-radius: 0.4em;
box-shadow:
inset rgba(255, 255, 255, 0.6) 0 0 0 2px,
rgba(0,0,0,0.2) 1px 1px 3px;
}
html[dir=rtl] #actions {
box-shadow:
inset rgba(255, 255, 255, 0.6) 0 0 0 2px,
rgba(0,0,0,0.2) -1px 1px 3px;
}
#actions #searchbutton{
@ -583,6 +591,7 @@ html[dir=rtl] #exit-button {
width: 20px;
height: 20px;
margin-top: 3px;
-moz-margin-end: 1px;
}
.notMainMatch{

View File

@ -2302,28 +2302,25 @@ panel[dimmed="true"] {
opacity: 0.5;
}
/* Vertically-center the statusbar compatibility shim, because
toolbars, even in small-icon mode, are a bit taller than
statusbars. Also turn off the statusbar border. On Windows
we have to disable borders on statusbar *and* child statusbar
elements. */
#status-bar {
margin-top: 0.3em;
-moz-appearance: none;
}
/* Add-on bar */
/* Remove all borders from statusbarpanel children of
the statusbar. */
#status-bar > statusbarpanel {
border-width: 0;
-moz-appearance: none;
#addon-bar {
min-height: 18px;
}
#addon-bar:not(:-moz-lwtheme) {
-moz-appearance: statusbar;
}
/* Add-on bar close button */
#status-bar {
-moz-appearance: none;
}
#status-bar > statusbarpanel {
border-width: 0;
-moz-appearance: none;
}
#addonbar-closebutton {
padding: 0;
margin: 0 4px;

View File

@ -258,27 +258,17 @@ caption {
padding: 0 12em;
}
#currentUser image {
#accountCaptionImage {
list-style-image: url("chrome://mozapps/skin/profile/profileicon.png");
}
#connectThrobber {
list-style-image: url("chrome://global/skin/icons/loading_16.png");
#syncAddDeviceLabel {
margin-top: 1em;
margin-bottom: 1em;
}
.expander-up,
.expander-down {
-moz-appearance: none;
padding: 0;
min-width: 0;
}
.expander-up {
list-style-image: url("chrome://browser/skin/places/expander-open.png") !important;
}
.expander-down {
list-style-image: url('chrome://browser/skin/places/expander-closed.png') !important
#syncEnginesList {
height: 10em;
}
%endif

View File

@ -395,17 +395,16 @@ input.name {
margin-top: 3px;
-moz-margin-end: 0;
margin-bottom: 0;
-moz-margin-begin: 3px;
-moz-margin-start: 3px;
padding: 1px;
background-image: url(chrome://browser/skin/tabview/edit-light.png);
-moz-padding-start: 20px;
}
html[dir=rtl] input.name {
background-position: right top;
}
.title-container:hover input.name {
.title-container:hover input.name,
.title-container input.name:focus {
border: 1px solid #ddd;
}
@ -418,13 +417,17 @@ input.name:focus {
color: #555;
}
input.defaultName {
input.name:-moz-placeholder {
font-style: italic !important;
color: transparent;
background-image: url(chrome://browser/skin/tabview/edit-light.png);
background-image-opacity: .1;
color: transparent;
background-repeat: no-repeat;
-moz-padding-start: 20px;
-moz-margin-end: -20px;
}
.title-container:hover input.defaultName {
.title-container:hover input.name:-moz-placeholder {
color: #CCC;
}
@ -436,7 +439,7 @@ input.defaultName {
margin-top: 3px;
-moz-margin-end: 0;
margin-bottom: 0;
-moz-margin-begin: 3px;
-moz-margin-start: 3px;
padding: 1px;
left: 0;
top: 0;
@ -503,16 +506,14 @@ html[dir=rtl] .iq-resizable-se {
/* Exit button
+----------------------------------*/
#exit-button {
cursor: default;
top: 0;
right: 1px;
width: 20px;
height: 20px;
-moz-margin-end: 2px;
margin-top: 2px;
-moz-margin-end: 3px;
margin-top: 0px;
background-image: -moz-image-rect(url(chrome://browser/skin/tabview/tabview.png), 0, 100, 20, 80);
background-attachment: scroll;
background-repeat: no-repeat;
border: none;
}
#exit-button[groups="0"] {
@ -531,11 +532,6 @@ html[dir=rtl] .iq-resizable-se {
background-image: -moz-image-rect(url(chrome://browser/skin/tabview/tabview.png), 0, 80, 20, 60);
}
html[dir=rtl] #exit-button {
right: auto;
left: 1px;
}
/* Search
----------------------------------*/
#searchshade{
@ -563,10 +559,12 @@ html[dir=rtl] #exit-button {
}
#actions {
width: 26px;
height: 26px;
border: none;
width: 29px;
text-align: center;
background-color: #EBEBEB;
border-radius: 0.4em;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
border: 1px solid rgba(255, 255, 255, 0.5);
}
#actions #searchbutton {
@ -575,6 +573,7 @@ html[dir=rtl] #exit-button {
width: 20px;
height: 20px;
margin-top: 3px;
-moz-margin-end: 1px;
}
.notMainMatch {

View File

@ -39,6 +39,16 @@
background-color: @customToolbarColor@;
}
.tabbrowser-tab:not(:-moz-lwtheme),
.tabs-newtab-button:not(:-moz-lwtheme) {
background-image: @genericBgTabTexture@, -moz-linear-gradient(@customToolbarColor@, @customToolbarColor@);
}
.tabbrowser-tab:not(:-moz-lwtheme):hover,
.tabs-newtab-button:not(:-moz-lwtheme):hover {
background-image: @genericBgTabTextureHover@, -moz-linear-gradient(@customToolbarColor@, @customToolbarColor@);
}
.tabbrowser-tab[selected="true"]:not(:-moz-lwtheme) {
background-image: -moz-linear-gradient(white, @toolbarHighlight@ 30%),
-moz-linear-gradient(@customToolbarColor@, @customToolbarColor@);
@ -63,7 +73,7 @@
}
#main-window[sizemode="maximized"] #titlebar-buttonbox {
-moz-margin-end: 2px;
-moz-margin-end: 3px;
}
#main-window {

View File

@ -52,6 +52,8 @@
%filter substitution
%define toolbarHighlight rgba(255,255,255,.5)
%define navbarTextboxCustomBorder border-color: rgba(0,0,0,.25) rgba(0,0,0,.32) rgba(0,0,0,.37);
%define genericBgTabTexture -moz-linear-gradient(transparent, hsla(0,0%,36%,.15) 1px, hsla(0,0%,0%,.3) 60%)
%define genericBgTabTextureHover -moz-linear-gradient(transparent, hsla(0,0%,70%,.15) 1px, hsla(0,0%,20%,.3) 60%)
#menubar-items {
-moz-box-orient: vertical; /* for flex hack */
@ -478,7 +480,7 @@ toolbarbutton.bookmark-item[open="true"] {
menu.bookmark-item,
menuitem.bookmark-item {
min-width: 0;
max-width: 26em;
max-width: 32em;
}
.bookmark-item > .menu-iconic-left {
@ -1502,7 +1504,7 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
.tabbrowser-tab,
.tabs-newtab-button {
-moz-appearance: none;
background: -moz-linear-gradient(hsla(0,0%,50%,.1), hsla(0,0%,37%,.1) 50%);
background: @genericBgTabTexture@, -moz-linear-gradient(-moz-dialog, -moz-dialog);
background-position: -5px -2px;
background-repeat: no-repeat;
background-size: 200%;
@ -1514,9 +1516,23 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
.tabbrowser-tab:hover,
.tabs-newtab-button:hover {
background-image: -moz-linear-gradient(hsla(0,0%,100%,.4), hsla(0,0%,75%,.4) 50%);
background-image: @genericBgTabTextureHover@, -moz-linear-gradient(-moz-dialog, -moz-dialog);
}
%ifndef WINSTRIPE_AERO
@media all and (-moz-windows-theme: luna-blue) {
.tabbrowser-tab,
.tabs-newtab-button {
background-image: -moz-linear-gradient(hsla(51,34%,89%,.9), hsla(51,15%,79%,.9) 1px, hsla(51,9%,68%,.9) 60%);
}
.tabbrowser-tab:hover,
.tabs-newtab-button:hover {
background-image: -moz-linear-gradient(hsla(51,34%,100%,.9), hsla(51,15%,94%,.9) 1px, hsla(51,9%,83%,.9) 60%);
}
}
%endif
.tabbrowser-tab[selected="true"] {
background-image: -moz-linear-gradient(rgba(255,255,255,.7), @toolbarHighlight@ 30%),
-moz-linear-gradient(-moz-dialog, -moz-dialog);
@ -2187,28 +2203,26 @@ panel[dimmed="true"] {
opacity: 0.5;
}
/* Vertically-center the statusbar compatibility shim, because
toolbars, even in small-icon mode, are a bit taller than
statusbars. Also turn off the statusbar border. On Windows
we have to disable borders on statusbar *and* child statusbar
elements. */
#status-bar {
margin-top: .3em;
border-width: 0;
-moz-appearance: none;
/* Add-on bar */
#addon-bar {
min-height: 20px;
}
#status-bar {
border: none;
-moz-appearance: none;
min-height: 0;
}
/* Remove all borders from statusbarpanel children of
the statusbar. */
#status-bar > statusbarpanel {
border-width: 0;
-moz-appearance: none;
}
/* Add-on bar close button */
#addonbar-closebutton {
border: none;
padding: 3px 5px;
padding: 0 5px;
list-style-image: url("chrome://global/skin/icons/close.png");
-moz-appearance: none;
-moz-image-region: rect(0, 16px, 16px, 0);

View File

@ -181,35 +181,26 @@ radio[pane=paneSync] {
%ifdef MOZ_SERVICES_SYNC
/* Sync Pane */
#syncDesc {
padding: 0 12em;
}
#currentUser image {
.syncGroupBox {
padding: 10px;
}
#accountCaptionImage {
list-style-image: url("chrome://mozapps/skin/profile/profileicon.png");
}
#connectThrobber {
list-style-image: url("chrome://global/skin/icons/loading_16.png");
#syncAddDeviceLabel {
margin-top: 1em;
margin-bottom: 1em;
}
#syncEnginesList {
height: 11em;
}
.expander-up,
.expander-down {
min-width: 0;
margin: 0;
-moz-margin-end: 4px;
}
.expander-up > .button-box,
.expander-down > .button-box {
padding: 0;
}
.expander-up {
list-style-image: url("chrome://global/skin/icons/collapse.png");
}
.expander-down {
list-style-image: url("chrome://global/skin/icons/expand.png");
}
%endif

View File

@ -424,15 +424,14 @@ input.name {
margin-bottom: 0;
-moz-margin-start: 3px;
padding: 1px;
background-image: url(chrome://browser/skin/tabview/edit-light.png);
-moz-padding-start: 20px;
}
html[dir=rtl] input.name {
background-position: right top;
}
.title-container:hover input.name {
.title-container:hover input.name,
.title-container input.name:focus {
border: 1px solid #ddd;
}
@ -445,13 +444,17 @@ input.name:focus {
color: #555;
}
input.defaultName {
input.name:-moz-placeholder {
font-style: italic !important;
background-image-opacity: .1;
color: transparent;
background-image: url(chrome://browser/skin/tabview/edit-light.png);
background-image-opacity: .1;
background-repeat: no-repeat;
-moz-padding-start: 20px;
-moz-padding-end: -20px;
}
.title-container:hover input.defaultName {
.title-container:hover input.name:-moz-placeholder {
color: #CCC;
}
@ -530,16 +533,14 @@ html[dir=rtl] .iq-resizable-se {
/* Exit button
+----------------------------------*/
#exit-button {
cursor: default;
top: 1px;
right: 0;
width: 18px;
height: 18px;
-moz-margin-end: 3px;
margin-top: 3px;
-moz-margin-end: 4px;
margin-top: 2px;
background-image: -moz-image-rect(url(chrome://browser/skin/tabview/tabview.png), 0, 90, 18, 72);
background-attachment: scroll;
background-repeat: no-repeat;
border: none;
}
#exit-button[groups="0"] {
@ -558,11 +559,6 @@ html[dir=rtl] .iq-resizable-se {
background-image: -moz-image-rect(url(chrome://browser/skin/tabview/tabview.png), 0, 72, 18, 54);
}
html[dir=rtl] #exit-button {
right: auto;
left: 0;
}
/* Search
----------------------------------*/
#searchshade{
@ -590,10 +586,28 @@ html[dir=rtl] #exit-button {
}
#actions{
width: 26px;
height: 26px;
top: -3px;
padding-top: 3px;
width: 29px;
border: none;
text-align: center;
background-color: #E0EAF5;
border-radius: 0.4em;
box-shadow:
0 1px 0 #FFFFFF inset,
0 -1px 1px rgba(255, 255, 255, 0.8) inset,
1px 0 1px rgba(255, 255, 255, 0.8) inset,
-1px 0 1px rgba(255, 255, 255, 0.8) inset,
0 1px 3px rgba(4, 38, 60, 0.6);
}
html[dir=rtl] #actions {
box-shadow:
0 1px 0 #FFFFFF inset,
0 -1px 1px rgba(255, 255, 255, 0.8) inset,
-1px 0 1px rgba(255, 255, 255, 0.8) inset,
1px 0 1px rgba(255, 255, 255, 0.8) inset,
0 1px 3px rgba(4, 38, 60, 0.6);
}
#actions #searchbutton{
@ -602,6 +616,7 @@ html[dir=rtl] #exit-button {
width: 20px;
height: 20px;
margin-top: 3px;
-moz-margin-end: 1px;
}
.notMainMatch{

File diff suppressed because it is too large Load Diff

View File

@ -142,7 +142,7 @@ class RemoteAutomation(Automation):
@property
def pid(self):
hexpid = self.dm.processExist(self.procName)
if (hexpid == '' or hexpid == None):
if (hexpid == None):
hexpid = "0x0"
return int(hexpid, 0)

View File

@ -408,6 +408,8 @@ nsScriptSecurityManager::PushContextPrincipal(JSContext *cx,
JSStackFrame *fp,
nsIPrincipal *principal)
{
NS_ASSERTION(principal, "Must pass a non-null principal");
ContextPrincipal *cp = new ContextPrincipal(mContextPrincipals, cx, fp,
principal);
if (!cp)
@ -2545,12 +2547,32 @@ nsScriptSecurityManager::IsCapabilityEnabled(const char *capability,
JSStackFrame *fp = nsnull;
JSContext *cx = GetCurrentJSContext();
fp = cx ? JS_FrameIterator(cx, &fp) : nsnull;
JSStackFrame *target = nsnull;
nsIPrincipal *targetPrincipal = nsnull;
for (ContextPrincipal *cp = mContextPrincipals; cp; cp = cp->mNext)
{
if (cp->mCx == cx)
{
target = cp->mFp;
targetPrincipal = cp->mPrincipal;
break;
}
}
if (!fp)
{
// No script code on stack. Allow execution.
*result = PR_TRUE;
// No script code on stack. If we had a principal pushed for this
// context and fp is null, then we use that principal. Otherwise, we
// don't have enough information and have to allow execution.
*result = (targetPrincipal && !target)
? (targetPrincipal == mSystemPrincipal)
: PR_TRUE;
return NS_OK;
}
*result = PR_FALSE;
nsIPrincipal* previousPrincipal = nsnull;
do

View File

@ -606,6 +606,8 @@ OS_TARGET=@OS_TARGET@
OS_ARCH=@OS_ARCH@
OS_RELEASE=@OS_RELEASE@
OS_TEST=@OS_TEST@
CPU_ARCH=@CPU_ARCH@
INTEL_ARCHITECTURE=@INTEL_ARCHITECTURE@
# For Solaris build
SOLARIS_SUNPRO_CC = @SOLARIS_SUNPRO_CC@

View File

@ -1563,6 +1563,14 @@ if test -z "$OS_TARGET"; then
fi
OS_CONFIG="${OS_TARGET}${OS_RELEASE}"
dnl Set INTEL_ARCHITECTURE if we're compiling for x86-32 or x86-64.
dnl ===============================================================
INTEL_ARCHITECTURE=
case "$OS_TEST" in
x86_64|i?86)
INTEL_ARCHITECTURE=1
esac
dnl ========================================================
dnl GNU specific defaults
dnl ========================================================
@ -9122,6 +9130,8 @@ AC_SUBST(OS_TARGET)
AC_SUBST(OS_ARCH)
AC_SUBST(OS_RELEASE)
AC_SUBST(OS_TEST)
AC_SUBST(CPU_ARCH)
AC_SUBST(INTEL_ARCHITECTURE)
AC_SUBST(MOZ_DISABLE_JAR_PACKAGING)
AC_SUBST(MOZ_CHROME_FILE_FORMAT)

View File

@ -45,6 +45,102 @@ interface nsIFrame;
interface nsIChromeFrameMessageManager;
interface nsIVariant;
typedef unsigned long long nsContentViewId;
/**
* These interfaces do *not* scroll or scale the content document;
* instead they set a "goal" scroll/scale wrt the current content
* view. When the content document is painted, the scroll*
* attributes are used to set a compensating transform. If the
* metrics of the content document's current pixels don't match the
* view config, the transform matrix may need to translate
* content pixels and/or perform a "fuzzy-scale" that doesn't
* re-rasterize fonts or intelligently resample images.
*
* The attrs are allowed to transform content pixels in
* such a way that the <browser>'s visible rect encloses pixels that
* the content document does not (yet) define.
*
* The view scroll values are in units of chrome-document CSS
* pixels.
*
* These APIs are designed to be used with nsIDOMWindowUtils
* setDisplayPort() and setResolution().
*/
[scriptable, uuid(fbd25468-d2cf-487b-bc58-a0e105398b47)]
interface nsIContentView : nsISupports
{
/**
* Scroll view to or by the given chrome-document CSS pixels.
* Fails if the view is no longer valid.
*/
void scrollTo(in float xPx, in float yPx);
void scrollBy(in float dxPx, in float dyPx);
void setScale(in float xScale, in float yScale);
/**
* Scroll offset in chrome-document CSS pixels.
*
* When this view is active (i.e. it is being painted because it's in the
* visible region of the screen), this value is at first lined up with the
* content's scroll offset.
*
* Note that when this view becomes inactive, the new content view will have
* scroll values that are reset to the default!
*/
readonly attribute float scrollX;
readonly attribute float scrollY;
/**
* Dimensions of the viewport in chrome-document CSS pixels.
*/
readonly attribute float viewportWidth;
readonly attribute float viewportHeight;
/**
* Dimensions of scrolled content in chrome-document CSS pixels.
*/
readonly attribute float contentWidth;
readonly attribute float contentHeight;
/**
* ID that can be used in conjunction with nsIDOMWindowUtils to change
* the actual document, instead of just how it is transformed.
*/
readonly attribute nsContentViewId id;
};
[scriptable, uuid(ba5af90d-ece5-40b2-9a1d-a0154128db1c)]
interface nsIContentViewManager : nsISupports
{
/**
* Retrieve view scrolling/scaling interfaces in a given area,
* used to support asynchronous re-paints of content pixels.
* These interfaces are only meaningful for <browser>.
*
* Pixels are in chrome device pixels and are relative to the browser
* element.
*
* @param aX x coordinate that will be in target rectangle
* @param aY y coordinate that will be in target rectangle
* @param aTopSize How much to expand up the rectangle
* @param aRightSize How much to expand right the rectangle
* @param aBottomSize How much to expand down the rectangle
* @param aLeftSize How much to expand left the rectangle
*/
void getContentViewsIn(in float aXPx, in float aYPx,
in float aTopSize, in float aRightSize,
in float aBottomSize, in float aLeftSize,
[optional] out unsigned long aLength,
[retval, array, size_is(aLength)] out nsIContentView aResult);
/**
* The root content view.
*/
readonly attribute nsIContentView rootContentView;
};
[scriptable, uuid(50a67436-bb44-11df-8d9a-001e37d2764a)]
interface nsIFrameLoader : nsISupports
{
@ -121,34 +217,14 @@ interface nsIFrameLoader : nsISupports
attribute boolean delayRemoteDialogs;
/**
* Implement viewport scrolling/scaling, used to support
* asynchronous re-paints of content pixels. These interfaces are
* only meaningful for <browser>.
*
* These interfaces do *not* scroll or scale the content document;
* instead they set a "goal" scroll/scale wrt the current content
* viewport. When the content document is painted, the viewport*
* attributes are used to set a compensating transform. If the
* metrics of the content document's current pixels don't match the
* viewport* config, the transform matrix may need to translate
* content pixels and/or perform a "fuzzy-scale" that doesn't
* re-rasterize fonts or intelligently resample images.
*
* The viewport* attrs are allowed to transform content pixels in
* such a way that the <browser>'s visible rect encloses pixels that
* the content document does not (yet) define.
*
* The viewport scroll values are in units of chrome-document CSS
* pixels.
*
* These APIs are designed to be used with nsIDOMWindowUtils
* setDisplayPort() and setResolution().
* DEPRECATED. Please QI to nsIContentViewManager.
* FIXME 615368
*/
void scrollViewportTo(in float xPx, in float yPx);
void scrollViewportBy(in float dxPx, in float dyPx);
void setViewportScale(in float xScale, in float yScale);
readonly attribute float viewportScrollX;
readonly attribute float viewportScrollY;
};

View File

@ -110,14 +110,20 @@
#include "mozilla/AutoRestore.h"
#include "mozilla/unused.h"
#include "Layers.h"
#ifdef MOZ_IPC
#include "ContentParent.h"
#include "TabParent.h"
#include "mozilla/layout/RenderFrameParent.h"
using namespace mozilla;
using namespace mozilla::dom;
#endif
using namespace mozilla::layers;
typedef FrameMetrics::ViewID ViewID;
#include "jsapi.h"
class nsAsyncDocShellDestroyer : public nsRunnable
@ -139,6 +145,134 @@ public:
nsRefPtr<nsIDocShell> mDocShell;
};
static void InvalidateFrame(nsIFrame* aFrame)
{
nsRect rect = nsRect(nsPoint(0, 0), aFrame->GetRect().Size());
// NB: we pass INVALIDATE_NO_THEBES_LAYERS here to keep view
// semantics the same for both in-process and out-of-process
// <browser>. This is just a transform of the layer subtree in
// both.
aFrame->InvalidateWithFlags(rect, nsIFrame::INVALIDATE_NO_THEBES_LAYERS);
}
NS_IMPL_ISUPPORTS1(nsContentView, nsIContentView)
bool
nsContentView::IsRoot() const
{
return mScrollId == FrameMetrics::ROOT_SCROLL_ID;
}
nsresult
nsContentView::Update(const ViewConfig& aConfig)
{
if (aConfig == mConfig) {
return NS_OK;
}
mConfig = aConfig;
// View changed. Try to locate our subdoc frame and invalidate
// it if found.
if (!mOwnerContent) {
if (IsRoot()) {
// Oops, don't have a frame right now. That's OK; the view
// config persists and will apply to the next frame we get, if we
// ever get one.
return NS_OK;
} else {
// This view is no longer valid.
return NS_ERROR_NOT_AVAILABLE;
}
}
nsIFrame* frame = mOwnerContent->GetPrimaryFrame();
// XXX could be clever here and compute a smaller invalidation
// rect
InvalidateFrame(frame);
return NS_OK;
}
NS_IMETHODIMP
nsContentView::ScrollTo(float aXpx, float aYpx)
{
ViewConfig config(mConfig);
config.mScrollOffset = nsPoint(nsPresContext::CSSPixelsToAppUnits(aXpx),
nsPresContext::CSSPixelsToAppUnits(aYpx));
return Update(config);
}
NS_IMETHODIMP
nsContentView::ScrollBy(float aDXpx, float aDYpx)
{
ViewConfig config(mConfig);
config.mScrollOffset.MoveBy(nsPresContext::CSSPixelsToAppUnits(aDXpx),
nsPresContext::CSSPixelsToAppUnits(aDYpx));
return Update(config);
}
NS_IMETHODIMP
nsContentView::SetScale(float aXScale, float aYScale)
{
ViewConfig config(mConfig);
config.mXScale = aXScale;
config.mYScale = aYScale;
return Update(config);
}
NS_IMETHODIMP
nsContentView::GetScrollX(float* aViewScrollX)
{
*aViewScrollX = nsPresContext::AppUnitsToFloatCSSPixels(
mConfig.mScrollOffset.x);
return NS_OK;
}
NS_IMETHODIMP
nsContentView::GetScrollY(float* aViewScrollY)
{
*aViewScrollY = nsPresContext::AppUnitsToFloatCSSPixels(
mConfig.mScrollOffset.y);
return NS_OK;
}
NS_IMETHODIMP
nsContentView::GetViewportWidth(float* aWidth)
{
*aWidth = nsPresContext::AppUnitsToFloatCSSPixels(mViewportSize.width);
return NS_OK;
}
NS_IMETHODIMP
nsContentView::GetViewportHeight(float* aHeight)
{
*aHeight = nsPresContext::AppUnitsToFloatCSSPixels(mViewportSize.height);
return NS_OK;
}
NS_IMETHODIMP
nsContentView::GetContentWidth(float* aWidth)
{
*aWidth = nsPresContext::AppUnitsToFloatCSSPixels(mContentSize.width);
return NS_OK;
}
NS_IMETHODIMP
nsContentView::GetContentHeight(float* aHeight)
{
*aHeight = nsPresContext::AppUnitsToFloatCSSPixels(mContentSize.height);
return NS_OK;
}
NS_IMETHODIMP
nsContentView::GetId(nsContentViewId* aId)
{
NS_ASSERTION(sizeof(nsContentViewId) == sizeof(ViewID),
"ID size for XPCOM ID and internal ID type are not the same!");
*aId = mScrollId;
return NS_OK;
}
// Bug 136580: Limit to the number of nested content frames that can have the
// same URL. This is to stop content that is recursively loading
// itself. Note that "#foo" on the end of URL doesn't affect
@ -177,9 +311,30 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS(nsFrameLoader, nsIFrameLoader)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameLoader)
NS_INTERFACE_MAP_ENTRY(nsIFrameLoader)
NS_INTERFACE_MAP_ENTRY(nsIFrameLoader_MOZILLA_2_0_BRANCH)
NS_INTERFACE_MAP_ENTRY(nsIContentViewManager)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIFrameLoader)
NS_INTERFACE_MAP_END
nsFrameLoader::nsFrameLoader(nsIContent *aOwner, PRBool aNetworkCreated)
: mOwnerContent(aOwner)
, mDepthTooGreat(PR_FALSE)
, mIsTopLevelContent(PR_FALSE)
, mDestroyCalled(PR_FALSE)
, mNeedsAsyncDestroy(PR_FALSE)
, mInSwap(PR_FALSE)
, mInShow(PR_FALSE)
, mHideCalled(PR_FALSE)
, mNetworkCreated(aNetworkCreated)
#ifdef MOZ_IPC
, mDelayRemoteDialogs(PR_FALSE)
, mRemoteBrowserShown(PR_FALSE)
, mRemoteFrame(false)
, mCurrentRemoteFrame(nsnull)
, mRemoteBrowser(nsnull)
#endif
{
}
nsFrameLoader*
nsFrameLoader::Create(nsIContent* aOwner, PRBool aNetworkCreated)
{
@ -997,8 +1152,8 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
ourWindow->SetFrameElementInternal(otherFrameElement);
otherWindow->SetFrameElementInternal(ourFrameElement);
mOwnerContent = otherContent;
aOther->mOwnerContent = ourContent;
SetOwnerContent(otherContent);
aOther->SetOwnerContent(ourContent);
nsRefPtr<nsFrameMessageManager> ourMessageManager = mMessageManager;
nsRefPtr<nsFrameMessageManager> otherMessageManager = aOther->mMessageManager;
@ -1099,7 +1254,7 @@ nsFrameLoader::Destroy()
doc->SetSubDocumentFor(mOwnerContent, nsnull);
}
mOwnerContent = nsnull;
SetOwnerContent(nsnull);
}
DestroyChild();
@ -1154,6 +1309,17 @@ nsFrameLoader::GetDepthTooGreat(PRBool* aDepthTooGreat)
return NS_OK;
}
void
nsFrameLoader::SetOwnerContent(nsIContent* aContent)
{
mOwnerContent = aContent;
#ifdef MOZ_IPC
if (RenderFrameParent* rfp = GetCurrentRemoteFrame()) {
rfp->OwnerContentChanged(aContent);
}
#endif
}
#ifdef MOZ_IPC
bool
nsFrameLoader::ShouldUseRemoteProcess()
@ -1505,95 +1671,49 @@ nsFrameLoader::UpdateBaseWindowPositionAndSize(nsIFrame *aIFrame)
NS_IMETHODIMP
nsFrameLoader::ScrollViewportTo(float aXpx, float aYpx)
{
ViewportConfig config(mViewportConfig);
config.mScrollOffset = nsPoint(nsPresContext::CSSPixelsToAppUnits(aXpx),
nsPresContext::CSSPixelsToAppUnits(aYpx));
return UpdateViewportConfig(config);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::ScrollViewportBy(float aDXpx, float aDYpx)
{
ViewportConfig config(mViewportConfig);
config.mScrollOffset.MoveBy(nsPresContext::CSSPixelsToAppUnits(aDXpx),
nsPresContext::CSSPixelsToAppUnits(aDYpx));
return UpdateViewportConfig(config);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::SetViewportScale(float aXScale, float aYScale)
{
ViewportConfig config(mViewportConfig);
config.mXScale = aXScale;
config.mYScale = aYScale;
return UpdateViewportConfig(config);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::GetViewportScrollX(float* aViewportScrollX)
{
*aViewportScrollX =
nsPresContext::AppUnitsToFloatCSSPixels(mViewportConfig.mScrollOffset.x);
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::GetViewportScrollY(float* aViewportScrollY)
{
*aViewportScrollY =
nsPresContext::AppUnitsToFloatCSSPixels(mViewportConfig.mScrollOffset.y);
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFrameLoader::GetRenderMode(PRUint32* aRenderMode)
{
*aRenderMode = mViewportConfig.mRenderMode;
*aRenderMode = mRenderMode;
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::SetRenderMode(PRUint32 aRenderMode)
{
ViewportConfig config(mViewportConfig);
config.mRenderMode = aRenderMode;
return UpdateViewportConfig(config);
}
nsresult
nsFrameLoader::UpdateViewportConfig(const ViewportConfig& aNewConfig)
{
if (aNewConfig == mViewportConfig) {
return NS_OK;
} else if (!mViewportConfig.AsyncScrollEnabled() &&
!aNewConfig.AsyncScrollEnabled()) {
// The target viewport can't be set in synchronous mode
return NS_ERROR_NOT_AVAILABLE;
}
// XXX if we go from disabled->enabled, should we clear out the old
// config? Or what?
mViewportConfig = aNewConfig;
// Viewport changed. Try to locate our subdoc frame and invalidate
// it if found.
nsIFrame* frame = GetPrimaryFrameOfOwningContent();
if (!frame) {
// Oops, don't have a frame right now. That's OK; the viewport
// config persists and will apply to the next frame we get, if we
// ever get one.
if (aRenderMode == mRenderMode) {
return NS_OK;
}
// XXX could be clever here and compute a smaller invalidation
// rect
nsRect rect = nsRect(nsPoint(0, 0), frame->GetRect().Size());
// NB: we pass INVALIDATE_NO_THEBES_LAYERS here to keep viewport
// semantics the same for both in-process and out-of-process
// <browser>. This is just a transform of the layer subtree in
// both.
frame->InvalidateWithFlags(rect, nsIFrame::INVALIDATE_NO_THEBES_LAYERS);
mRenderMode = aRenderMode;
InvalidateFrame(GetPrimaryFrameOfOwningContent());
return NS_OK;
}
@ -1882,6 +2002,70 @@ nsFrameLoader::GetMessageManager(nsIChromeFrameMessageManager** aManager)
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::GetContentViewsIn(float aXPx, float aYPx,
float aTopSize, float aRightSize,
float aBottomSize, float aLeftSize,
PRUint32* aLength,
nsIContentView*** aResult)
{
#ifdef MOZ_IPC
nscoord x = nsPresContext::CSSPixelsToAppUnits(aXPx - aLeftSize);
nscoord y = nsPresContext::CSSPixelsToAppUnits(aYPx - aTopSize);
nscoord w = nsPresContext::CSSPixelsToAppUnits(aLeftSize + aRightSize) + 1;
nscoord h = nsPresContext::CSSPixelsToAppUnits(aTopSize + aBottomSize) + 1;
nsRect target(x, y, w, h);
nsIFrame* frame = GetPrimaryFrameOfOwningContent();
nsTArray<ViewID> ids;
nsLayoutUtils::GetRemoteContentIds(frame, target, ids, true);
if (ids.Length() == 0 || !GetCurrentRemoteFrame()) {
*aResult = nsnull;
*aLength = 0;
return NS_OK;
}
nsIContentView** result = reinterpret_cast<nsIContentView**>(
NS_Alloc(ids.Length() * sizeof(nsIContentView*)));
for (PRUint32 i = 0; i < ids.Length(); i++) {
nsIContentView* view = GetCurrentRemoteFrame()->GetContentView(ids[i]);
NS_ABORT_IF_FALSE(view, "Retrieved ID from RenderFrameParent, it should be valid!");
nsRefPtr<nsIContentView>(view).forget(&result[i]);
}
*aResult = result;
*aLength = ids.Length();
#else
*aResult = nsnull;
*aLength = 0;
#endif
return NS_OK;
}
NS_IMETHODIMP
nsFrameLoader::GetRootContentView(nsIContentView** aContentView)
{
#ifdef MOZ_IPC
RenderFrameParent* rfp = GetCurrentRemoteFrame();
if (!rfp) {
*aContentView = nsnull;
return NS_OK;
}
nsContentView* view = rfp->GetContentView();
NS_ABORT_IF_FALSE(view, "Should always be able to create root scrollable!");
nsRefPtr<nsIContentView>(view).forget(aContentView);
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
nsresult
nsFrameLoader::EnsureMessageManager()
{

View File

@ -52,6 +52,7 @@
#include "nsIURI.h"
#include "nsAutoPtr.h"
#include "nsFrameMessageManager.h"
#include "Layers.h"
class nsIContent;
class nsIURI;
@ -80,73 +81,38 @@ class QX11EmbedContainer;
#endif
#endif
class nsFrameLoader : public nsIFrameLoader,
public nsIFrameLoader_MOZILLA_2_0_BRANCH
/**
* Defines a target configuration for this <browser>'s content
* document's view. If the content document's actual view
* doesn't match this nsIContentView, then on paints its pixels
* are transformed to compensate for the difference.
*
* Used to support asynchronous re-paints of content pixels; see
* nsIContentView.
*/
class nsContentView : public nsIContentView
{
friend class AutoResetInShow;
#ifdef MOZ_IPC
typedef mozilla::dom::PBrowserParent PBrowserParent;
typedef mozilla::dom::TabParent TabParent;
typedef mozilla::layout::RenderFrameParent RenderFrameParent;
#endif
protected:
nsFrameLoader(nsIContent *aOwner, PRBool aNetworkCreated) :
mOwnerContent(aOwner),
mDepthTooGreat(PR_FALSE),
mIsTopLevelContent(PR_FALSE),
mDestroyCalled(PR_FALSE),
mNeedsAsyncDestroy(PR_FALSE),
mInSwap(PR_FALSE),
mInShow(PR_FALSE),
mHideCalled(PR_FALSE),
mNetworkCreated(aNetworkCreated)
#ifdef MOZ_IPC
, mDelayRemoteDialogs(PR_FALSE)
, mRemoteBrowserShown(PR_FALSE)
, mRemoteFrame(false)
, mCurrentRemoteFrame(nsnull)
, mRemoteBrowser(nsnull)
#endif
{}
public:
/**
* Defines a target configuration for this <browser>'s content
* document's viewport. If the content document's actual viewport
* doesn't match a desired ViewportConfig, then on paints its pixels
* are transformed to compensate for the difference.
*
* Used to support asynchronous re-paints of content pixels; see
* nsIFrameLoader.scrollViewport* and viewportScale.
*/
struct ViewportConfig {
ViewportConfig()
: mRenderMode(nsIFrameLoader_MOZILLA_2_0_BRANCH::RENDER_MODE_DEFAULT)
, mScrollOffset(0, 0)
typedef mozilla::layers::FrameMetrics::ViewID ViewID;
NS_DECL_ISUPPORTS
NS_DECL_NSICONTENTVIEW
struct ViewConfig {
ViewConfig()
: mScrollOffset(0, 0)
, mXScale(1.0)
, mYScale(1.0)
{}
// Default copy ctor and operator= are fine
PRBool operator==(const ViewportConfig& aOther) const
PRBool operator==(const ViewConfig& aOther) const
{
return (mRenderMode == aOther.mRenderMode &&
mScrollOffset == aOther.mScrollOffset &&
return (mScrollOffset == aOther.mScrollOffset &&
mXScale == aOther.mXScale &&
mYScale == aOther.mYScale);
}
PRBool AsyncScrollEnabled() const
{
return !!(mRenderMode & RENDER_MODE_ASYNC_SCROLL);
}
// See nsIFrameLoader.idl. Short story, if !(mRenderMode &
// RENDER_MODE_ASYNC_SCROLL), all the fields below are ignored in
// favor of what content tells.
PRUint32 mRenderMode;
// This is the scroll offset the <browser> user wishes or expects
// its enclosed content document to have. "Scroll offset" here
// means the document pixel at pixel (0,0) within the CSS
@ -163,6 +129,55 @@ public:
float mYScale;
};
nsContentView(nsIContent* aOwnerContent, ViewID aScrollId,
ViewConfig aConfig = ViewConfig())
: mViewportSize(0, 0)
, mContentSize(0, 0)
, mOwnerContent(aOwnerContent)
, mScrollId(aScrollId)
, mConfig(aConfig)
{}
bool IsRoot() const;
ViewID GetId() const
{
return mScrollId;
}
ViewConfig GetViewConfig() const
{
return mConfig;
}
nsSize mViewportSize;
nsSize mContentSize;
nsIContent *mOwnerContent; // WEAK
private:
nsresult Update(const ViewConfig& aConfig);
ViewID mScrollId;
ViewConfig mConfig;
};
class nsFrameLoader : public nsIFrameLoader,
public nsIFrameLoader_MOZILLA_2_0_BRANCH,
public nsIContentViewManager
{
friend class AutoResetInShow;
#ifdef MOZ_IPC
typedef mozilla::dom::PBrowserParent PBrowserParent;
typedef mozilla::dom::TabParent TabParent;
typedef mozilla::layout::RenderFrameParent RenderFrameParent;
#endif
protected:
nsFrameLoader(nsIContent *aOwner, PRBool aNetworkCreated);
public:
~nsFrameLoader() {
mNeedsAsyncDestroy = PR_TRUE;
if (mMessageManager) {
@ -171,12 +186,18 @@ public:
nsFrameLoader::Destroy();
}
PRBool AsyncScrollEnabled() const
{
return !!(mRenderMode & RENDER_MODE_ASYNC_SCROLL);
}
static nsFrameLoader* Create(nsIContent* aOwner, PRBool aNetworkCreated);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsFrameLoader, nsIFrameLoader)
NS_DECL_NSIFRAMELOADER
NS_DECL_NSIFRAMELOADER_MOZILLA_2_0_BRANCH
NS_DECL_NSICONTENTVIEWMANAGER
NS_HIDDEN_(nsresult) CheckForRecursiveLoad(nsIURI* aURI);
nsresult ReallyStartLoading();
void Finalize();
@ -261,7 +282,8 @@ public:
#endif
nsFrameMessageManager* GetFrameMessageManager() { return mMessageManager; }
const ViewportConfig& GetViewportConfig() { return mViewportConfig; }
nsIContent* GetOwnerContent() { return mOwnerContent; }
void SetOwnerContent(nsIContent* aContent);
private:
@ -295,8 +317,6 @@ private:
bool ShowRemoteFrame(const nsIntSize& size);
#endif
nsresult UpdateViewportConfig(const ViewportConfig& aNewConfig);
nsCOMPtr<nsIDocShell> mDocShell;
nsCOMPtr<nsIURI> mURIToLoad;
nsIContent *mOwnerContent; // WEAK
@ -327,7 +347,10 @@ private:
TabParent* mRemoteBrowser;
#endif
ViewportConfig mViewportConfig;
// See nsIFrameLoader.idl. Short story, if !(mRenderMode &
// RENDER_MODE_ASYNC_SCROLL), all the fields below are ignored in
// favor of what content tells.
PRUint32 mRenderMode;
};
#endif

View File

@ -1747,6 +1747,7 @@ GK_ATOM(DeleteTxnName, "Deleting")
// IPC stuff
GK_ATOM(Remote, "remote")
GK_ATOM(RemoteId, "_remote_id")
// Names for system metrics
GK_ATOM(scrollbar_start_backward, "scrollbar-start-backward")

View File

@ -3198,9 +3198,17 @@ WebGLContext::DOMElementToImageSurface(nsIDOMElement *imageOrCanvas,
{
gfxImageSurface *surf = nsnull;
PRUint32 flags =
nsLayoutUtils::SFE_WANT_NEW_SURFACE |
nsLayoutUtils::SFE_WANT_IMAGE_SURFACE;
if (mPixelStoreColorspaceConversion == LOCAL_GL_NONE)
flags |= nsLayoutUtils::SFE_NO_COLORSPACE_CONVERSION;
if (!mPixelStorePremultiplyAlpha)
flags |= nsLayoutUtils::SFE_NO_PREMULTIPLY_ALPHA;
nsLayoutUtils::SurfaceFromElementResult res =
nsLayoutUtils::SurfaceFromElement(imageOrCanvas,
nsLayoutUtils::SFE_WANT_NEW_SURFACE | nsLayoutUtils::SFE_WANT_IMAGE_SURFACE);
nsLayoutUtils::SurfaceFromElement(imageOrCanvas, flags);
if (!res.mSurface)
return NS_ERROR_FAILURE;
@ -4011,7 +4019,7 @@ WebGLContext::TexImage2D_dom(WebGLenum target, WebGLint level, WebGLenum interna
isurf->Width(), isurf->Height(), isurf->Stride(), 0,
format, type,
isurf->Data(), byteLength,
srcFormat, PR_TRUE);
srcFormat, mPixelStorePremultiplyAlpha);
}
NS_IMETHODIMP

View File

@ -192,16 +192,19 @@ PRBool nsBuiltinDecoderStateMachine::HaveNextFrameData() const {
(!HasVideo() || mReader->mVideoQueue.GetSize() > 0);
}
PRInt64 nsBuiltinDecoderStateMachine::GetDecodedAudioDuration() {
NS_ASSERTION(OnDecodeThread(), "Should be on decode thread.");
mDecoder->GetMonitor().AssertCurrentThreadIn();
PRInt64 audioDecoded = mReader->mAudioQueue.Duration();
if (mAudioEndTime != -1) {
audioDecoded += mAudioEndTime - GetMediaTime();
}
return audioDecoded;
}
void nsBuiltinDecoderStateMachine::DecodeLoop()
{
NS_ASSERTION(OnDecodeThread(), "Should be on decode thread.");
PRBool videoPlaying = PR_FALSE;
PRBool audioPlaying = PR_FALSE;
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
videoPlaying = HasVideo();
audioPlaying = HasAudio();
}
// We want to "pump" the decode until we've got a few frames/samples decoded
// before we consider whether decode is falling behind.
@ -228,58 +231,37 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
PRInt64 lowAudioThreshold = LOW_AUDIO_MS;
// Our local ample audio threshold. If we increase lowAudioThreshold, we'll
// also increase this to appropriately (we don't want lowAudioThreshold to
// also increase this too appropriately (we don't want lowAudioThreshold to
// be greater than ampleAudioThreshold, else we'd stop decoding!).
PRInt64 ampleAudioThreshold = AMPLE_AUDIO_MS;
// Main decode loop.
while (videoPlaying || audioPlaying) {
PRBool audioWait = !audioPlaying;
PRBool videoWait = !videoPlaying;
{
// Wait for more data to download if we've exhausted all our
// buffered data.
MonitorAutoEnter mon(mDecoder->GetMonitor());
if (mState == DECODER_STATE_SHUTDOWN || mStopDecodeThreads)
break;
}
MediaQueue<VideoData>& videoQueue = mReader->mVideoQueue;
MediaQueue<SoundData>& audioQueue = mReader->mAudioQueue;
PRUint32 videoQueueSize = mReader->mVideoQueue.GetSize();
// Don't decode any more frames if we've filled our buffers.
// Limits memory consumption.
if (videoQueueSize > AMPLE_VIDEO_FRAMES) {
videoWait = PR_TRUE;
MonitorAutoEnter mon(mDecoder->GetMonitor());
PRBool videoPlaying = HasVideo();
PRBool audioPlaying = HasAudio();
// Main decode loop.
while (mState != DECODER_STATE_SHUTDOWN &&
!mStopDecodeThreads &&
(videoPlaying || audioPlaying))
{
// We don't want to consider skipping to the next keyframe if we've
// only just started up the decode loop, so wait until we've decoded
// some frames before enabling the keyframe skip logic on video.
if (videoPump && videoQueue.GetSize() >= videoPumpThreshold) {
videoPump = PR_FALSE;
}
// We don't want to consider skipping to the next keyframe if we've
// only just started up the decode loop, so wait until we've decoded
// some frames before allowing the keyframe skip.
if (videoPump && videoQueueSize >= videoPumpThreshold) {
videoPump = PR_FALSE;
}
// Determine how much audio data is decoded ahead of the current playback
// position.
PRInt64 currentTime = 0;
PRInt64 audioDecoded = 0;
PRBool decodeCloseToDownload = PR_FALSE;
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
currentTime = GetMediaTime();
audioDecoded = mReader->mAudioQueue.Duration();
if (mAudioEndTime != -1) {
audioDecoded += mAudioEndTime - currentTime;
}
decodeCloseToDownload = IsDecodeCloseToDownload();
}
// Don't decode any audio if the audio decode is way ahead.
if (audioDecoded > ampleAudioThreshold) {
audioWait = PR_TRUE;
}
if (audioPump && audioDecoded > audioPumpThresholdMs) {
// some audio data before enabling the keyframe skip logic on audio.
if (audioPump && GetDecodedAudioDuration() >= audioPumpThresholdMs) {
audioPump = PR_FALSE;
}
// We'll skip the video decode to the nearest keyframe if we're low on
// audio, or if we're low on video, provided we're not running low on
// data to decode. If we're running low on downloaded data to decode,
@ -288,23 +270,28 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
// after buffering finishes.
if (!skipToNextKeyframe &&
videoPlaying &&
!decodeCloseToDownload &&
((!audioPump && audioPlaying && audioDecoded < lowAudioThreshold) ||
(!videoPump && videoQueueSize < LOW_VIDEO_FRAMES)))
!IsDecodeCloseToDownload() &&
((!audioPump && audioPlaying && GetDecodedAudioDuration() < lowAudioThreshold) ||
(!videoPump && videoPlaying && videoQueue.GetSize() < LOW_VIDEO_FRAMES)))
{
skipToNextKeyframe = PR_TRUE;
LOG(PR_LOG_DEBUG, ("Skipping video decode to the next keyframe"));
}
// Video decode.
if (videoPlaying && !videoWait) {
if (videoPlaying && videoQueue.GetSize() < AMPLE_VIDEO_FRAMES) {
// Time the video decode, so that if it's slow, we can increase our low
// audio threshold to reduce the chance of an audio underrun while we're
// waiting for a video decode to complete.
TimeStamp start = TimeStamp::Now();
videoPlaying = mReader->DecodeVideoFrame(skipToNextKeyframe, currentTime);
TimeDuration decodeTime = TimeStamp::Now() - start;
if (!decodeCloseToDownload &&
TimeDuration decodeTime;
{
PRInt64 currentTime = GetMediaTime();
MonitorAutoExit exitMon(mDecoder->GetMonitor());
TimeStamp start = TimeStamp::Now();
videoPlaying = mReader->DecodeVideoFrame(skipToNextKeyframe, currentTime);
decodeTime = TimeStamp::Now() - start;
}
if (!IsDecodeCloseToDownload() &&
THRESHOLD_FACTOR * decodeTime.ToMilliseconds() > lowAudioThreshold)
{
lowAudioThreshold =
@ -317,50 +304,55 @@ void nsBuiltinDecoderStateMachine::DecodeLoop()
lowAudioThreshold, ampleAudioThreshold));
}
}
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
mDecoder->GetMonitor().NotifyAll();
}
// Audio decode.
if (audioPlaying && !audioWait) {
if (audioPlaying &&
(GetDecodedAudioDuration() < ampleAudioThreshold || audioQueue.GetSize() == 0))
{
MonitorAutoExit exitMon(mDecoder->GetMonitor());
audioPlaying = mReader->DecodeAudioData();
}
// Notify to ensure that the AudioLoop() is not waiting, in case it was
// waiting for more audio to be decoded.
mDecoder->GetMonitor().NotifyAll();
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
if (!IsPlaying()) {
// Update the ready state, so that the play DOM events fire. We only
// need to do this if we're not playing; if we're playing the playback
// code will do an update whenever it advances a frame.
UpdateReadyState();
}
if (mState == DECODER_STATE_SHUTDOWN || mStopDecodeThreads) {
break;
}
if ((!HasAudio() || audioWait) &&
(!HasVideo() || videoWait))
{
// All active bitstreams' decode is well ahead of the playback
// position, we may as well wait for the playback to catch up.
mon.Wait();
}
if (!IsPlaying()) {
// Update the ready state, so that the play DOM events fire. We only
// need to do this if we're not playing; if we're playing the playback
// code will do an update whenever it advances a frame.
UpdateReadyState();
}
}
if (mState != DECODER_STATE_SHUTDOWN &&
!mStopDecodeThreads &&
(!audioPlaying || (GetDecodedAudioDuration() >= ampleAudioThreshold &&
audioQueue.GetSize() > 0))
&&
(!videoPlaying || videoQueue.GetSize() >= AMPLE_VIDEO_FRAMES))
{
// All active bitstreams' decode is well ahead of the playback
// position, we may as well wait for the playback to catch up. Note the
// audio push thread acquires and notifies the decoder monitor every time
// it pops SoundData off the audio queue. So if the audio push thread pops
// the last SoundData off the audio queue right after that queue reported
// it was non-empty here, we'll receive a notification on the decoder
// monitor which will wake us up shortly after we sleep, thus preventing
// both the decode and audio push threads waiting at the same time.
// See bug 620326.
mon.Wait();
}
} // End decode loop.
if (!mStopDecodeThreads &&
mState != DECODER_STATE_SHUTDOWN &&
mState != DECODER_STATE_SEEKING)
{
MonitorAutoEnter mon(mDecoder->GetMonitor());
if (!mStopDecodeThreads &&
mState != DECODER_STATE_SHUTDOWN &&
mState != DECODER_STATE_SEEKING)
{
mState = DECODER_STATE_COMPLETED;
mDecoder->GetMonitor().NotifyAll();
}
mState = DECODER_STATE_COMPLETED;
mDecoder->GetMonitor().NotifyAll();
}
LOG(PR_LOG_DEBUG, ("Shutting down DecodeLoop this=%p", this));
}

View File

@ -370,6 +370,15 @@ protected:
return mStartTime + mCurrentFrameTime;
}
// Returns an upper bound on the number of milliseconds of audio that is
// decoded and playable. This is the sum of the number of ms of audio which
// is decoded and in the reader's audio queue, and the ms of unplayed audio
// which has been pushed to the audio hardware for playback. Note that after
// calling this, the audio hardware may play some of the audio pushed to
// hardware, so this can only be used as a upper bound. The decoder monitor
// must be held when calling this. Called on the decoder thread.
PRInt64 GetDecodedAudioDuration();
// Monitor on mAudioStream. This monitor must be held in order to delete
// or use the audio stream. This stops us destroying the audio stream
// while it's being used on another thread (typically when it's being

View File

@ -277,6 +277,10 @@ function getPlayableVideo(candidates) {
// virtual address space. Beware!
var PARALLEL_TESTS = 2;
// When true, we'll loop forever on whatever test we run. Use this to debug
// intermittent test failures.
const DEBUG_TEST_LOOP_FOREVER = false;
// Manages a run of media tests. Runs them in chunks in order to limit
// the number of media elements/threads running in parallel. This limits peak
// memory use, particularly on Linux x86 where thread stacks use 10MB of
@ -341,7 +345,7 @@ function MediaTestManager() {
// thread stacks' address space.
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
Components.utils.forceGC();
if (this.testNum == this.tests.length) {
if (this.testNum == this.tests.length && !DEBUG_TEST_LOOP_FOREVER) {
if (this.onFinished) {
this.onFinished();
}
@ -354,6 +358,10 @@ function MediaTestManager() {
var token = (test.name ? (test.name + "-"): "") + this.testNum;
this.testNum++;
if (DEBUG_TEST_LOOP_FOREVER && this.testNum == this.tests.length) {
this.testNum = 0;
}
// Ensure we can play the resource type.
if (test.type && !document.createElement('video').canPlayType(test.type))
continue;

View File

@ -2251,17 +2251,32 @@ nsDOMClassInfo::Init()
rv = stack->GetSafeJSContext(&cx);
NS_ENSURE_SUCCESS(rv, rv);
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
DOM_CLASSINFO_MAP_END
if (nsGlobalWindow::HasIndexedDBSupport()) {
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageIndexedDB)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
DOM_CLASSINFO_MAP_END
} else {
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
DOM_CLASSINFO_MAP_END
}
DOM_CLASSINFO_MAP_BEGIN(WindowUtils, nsIDOMWindowUtils)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowUtils)
@ -2966,6 +2981,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageIndexedDB)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
DOM_CLASSINFO_MAP_END
@ -3856,6 +3872,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageIndexedDB)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMModalContentWindow)
DOM_CLASSINFO_MAP_END

View File

@ -992,6 +992,25 @@ nsDOMWindowUtils::GetFocusedInputType(char** aType)
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::FindElementWithViewId(nsViewID aID,
nsIDOMElement** aResult)
{
if (aID == FrameMetrics::ROOT_SCROLL_ID) {
nsPresContext* presContext = GetPresContext();
nsIDocument* document = presContext->Document();
mozilla::dom::Element* rootElement = document->GetRootElement();
if (!rootElement) {
return NS_ERROR_NOT_AVAILABLE;
}
CallQueryInterface(rootElement, aResult);
return NS_OK;
}
nsRefPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aID);
return CallQueryInterface(content, aResult);
}
NS_IMETHODIMP
nsDOMWindowUtils::GetScreenPixelsPerCSSPixel(float* aScreenPixels)
{

View File

@ -66,7 +66,6 @@
#include "jsdbgapi.h" // for JS_ClearWatchPointsForObject
#include "nsReadableUtils.h"
#include "nsDOMClassInfo.h"
#include "nsContentUtils.h"
// Other Classes
#include "nsIEventListenerManager.h"
@ -1316,6 +1315,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindow)
NS_INTERFACE_MAP_ENTRY(nsIDOMViewCSS)
NS_INTERFACE_MAP_ENTRY(nsIDOMAbstractView)
NS_INTERFACE_MAP_ENTRY(nsIDOMStorageWindow)
NS_INTERFACE_MAP_ENTRY(nsIDOMStorageIndexedDB)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_INTERFACE_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
@ -6277,6 +6277,13 @@ nsGlobalWindow::EnterModalState()
nsContentUtils::ContentIsCrossDocDescendantOf(activeShell->GetDocument(), mDoc) ||
nsContentUtils::ContentIsCrossDocDescendantOf(mDoc, activeShell->GetDocument()))) {
nsEventStateManager::ClearGlobalActiveContent(activeESM);
activeShell->SetCapturingContent(nsnull, 0);
if (activeShell) {
nsCOMPtr<nsFrameSelection> frameSelection = activeShell->FrameSelection();
frameSelection->SetMouseDownState(PR_FALSE);
}
}
}
@ -8001,6 +8008,10 @@ nsGlobalWindow::GetLocalStorage(nsIDOMStorage ** aLocalStorage)
return NS_OK;
}
//*****************************************************************************
// nsGlobalWindow::nsIDOMStorageIndexedDB
//*****************************************************************************
NS_IMETHODIMP
nsGlobalWindow::GetMozIndexedDB(nsIIDBFactory** _retval)
{

View File

@ -102,6 +102,7 @@
#include "nsIDOMStorageList.h"
#include "nsIDOMStorageWindow.h"
#include "nsIDOMStorageEvent.h"
#include "nsIDOMStorageIndexedDB.h"
#include "nsIDOMOfflineResourceList.h"
#include "nsPIDOMEventTarget.h"
#include "nsIArray.h"
@ -109,6 +110,7 @@
#include "nsIIDBFactory.h"
#include "nsFrameMessageManager.h"
#include "mozilla/TimeStamp.h"
#include "nsContentUtils.h"
// JS includes
#include "jsapi.h"
@ -280,6 +282,7 @@ class nsGlobalWindow : public nsPIDOMWindow,
public nsIDOMNSEventTarget,
public nsIDOMViewCSS,
public nsIDOMStorageWindow,
public nsIDOMStorageIndexedDB,
public nsSupportsWeakReference,
public nsIInterfaceRequestor,
public nsIDOMWindow_2_0_BRANCH,
@ -574,6 +577,10 @@ public:
return sOuterWindowsById ? sOuterWindowsById->Get(aWindowID) : nsnull;
}
static bool HasIndexedDBSupport() {
return nsContentUtils::GetBoolPref("indexedDB.feature.enabled", PR_TRUE);
}
private:
// Enable updates for the accelerometer.
void EnableAccelerationUpdates();

View File

@ -2137,9 +2137,8 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, void *aScope, void *aHandler
// xxxmarkh - this comment is no longer true - principals are not used at
// all now, and never were in some cases.
nsCOMPtr<nsIJSContextStack> stack =
do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
if (NS_FAILED(rv) || NS_FAILED(stack->Push(mContext)))
nsCxPusher pusher;
if (!pusher.Push(mContext, PR_TRUE))
return NS_ERROR_FAILURE;
// check if the event handler can be run on the object in question
@ -2162,15 +2161,24 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, void *aScope, void *aHandler
// in the same scope as aTarget.
rv = ConvertSupportsTojsvals(aargv, target, &argc,
&argv, poolRelease, tvr);
if (NS_FAILED(rv)) {
stack->Pop(nsnull);
return rv;
}
NS_ENSURE_SUCCESS(rv, rv);
jsval funval = OBJECT_TO_JSVAL(static_cast<JSObject *>(aHandler));
JSObject *funobj = static_cast<JSObject *>(aHandler);
nsCOMPtr<nsIPrincipal> principal;
rv = sSecurityManager->GetObjectPrincipal(mContext, funobj,
getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
JSStackFrame *currentfp = nsnull;
rv = sSecurityManager->PushContextPrincipal(mContext,
JS_FrameIterator(mContext, &currentfp),
principal);
NS_ENSURE_SUCCESS(rv, rv);
jsval funval = OBJECT_TO_JSVAL(funobj);
JSAutoEnterCompartment ac;
if (!ac.enter(mContext, target)) {
stack->Pop(nsnull);
sSecurityManager->PopContextPrincipal(mContext);
return NS_ERROR_FAILURE;
}
@ -2192,10 +2200,11 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, void *aScope, void *aHandler
// Tell the caller that the handler threw an error.
rv = NS_ERROR_FAILURE;
}
sSecurityManager->PopContextPrincipal(mContext);
}
if (NS_FAILED(stack->Pop(nsnull)))
return NS_ERROR_FAILURE;
pusher.Pop();
// Convert to variant before calling ScriptEvaluated, as it may GC, meaning
// we would need to root rval.
@ -3993,14 +4002,10 @@ SetMemoryHighWaterMarkPrefChangedCallback(const char* aPrefName, void* aClosure)
static int
SetMemoryMaxPrefChangedCallback(const char* aPrefName, void* aClosure)
{
PRUint32 max = nsContentUtils::GetIntPref(aPrefName, -1);
if (max == -1UL)
max = 0xffffffff;
else
max = max * 1024L * 1024L;
JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MAX_BYTES,
max);
PRInt32 pref = nsContentUtils::GetIntPref(aPrefName, -1);
// handle overflow and negative pref values
PRUint32 max = (pref <= 0 || pref >= 0x1000) ? -1 : (PRUint32)pref * 1024 * 1024;
JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_MAX_BYTES, max);
return 0;
}

View File

@ -278,8 +278,20 @@ IDBTransaction::GetOrCreateConnection(mozIStorageConnection** aResult)
IDBFactory::GetConnection(mDatabase->FilePath());
NS_ENSURE_TRUE(connection, NS_ERROR_FAILURE);
NS_NAMED_LITERAL_CSTRING(beginTransaction, "BEGIN TRANSACTION;");
nsresult rv = connection->ExecuteSimpleSQL(beginTransaction);
nsCString beginTransaction;
if (mMode == nsIIDBTransaction::READ_WRITE) {
beginTransaction.AssignLiteral("BEGIN IMMEDIATE TRANSACTION;");
}
else {
beginTransaction.AssignLiteral("BEGIN TRANSACTION;");
}
nsCOMPtr<mozIStorageStatement> stmt;
nsresult rv = connection->CreateStatement(beginTransaction,
getter_AddRefs(stmt));
NS_ENSURE_SUCCESS(rv, false);
rv = stmt->Execute();
NS_ENSURE_SUCCESS(rv, false);
connection.swap(mConnection);

View File

@ -822,10 +822,19 @@ interface nsIDOMWindowUtils : nsISupports {
in AString value2);
};
typedef unsigned long long nsViewID;
[scriptable, uuid(3a0334aa-b9cc-4b32-9b6c-599cd4e40d5b)]
interface nsIDOMWindowUtils_MOZILLA_2_0_BRANCH : nsISupports {
/**
* Get the type of the currently focused html input, if any.
*/
readonly attribute string focusedInputType;
/**
* Given a view ID from the compositor process, retrieve the element
* associated with a view. For scrollpanes for documents, the root
* element of the document is returned.
*/
nsIDOMElement findElementWithViewId(in nsViewID aId);
};

View File

@ -61,6 +61,7 @@ SDK_XPIDLSRCS = \
nsIDOMStorageEvent.idl \
nsIDOMStorageEventObsolete.idl \
nsIDOMStorageItem.idl \
nsIDOMStorageIndexedDB.idl \
nsIDOMStorageList.idl \
nsIDOMStorageWindow.idl \
$(NULL)

View File

@ -0,0 +1,57 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Neil Deakin <enndeakin@sympatico.ca>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "domstubs.idl"
/**
* Interface for a client side storage. See
* http://www.whatwg.org/specs/web-apps/current-work/#scs-client-side and
* http://www.w3.org/TR/IndexedDB/ for more information.
*
* Allows access to contextual storage areas.
*/
interface nsIIDBFactory;
[scriptable, uuid(d20d48e4-0b94-40c7-a9c7-ba1d6ad44442)]
interface nsIDOMStorageIndexedDB : nsISupports
{
/**
* Indexed Databases for the current browsing context.
*/
readonly attribute nsIIDBFactory mozIndexedDB;
};

View File

@ -70,6 +70,7 @@ interface nsIDOMStorageWindow : nsISupports
/**
* Indexed Databases for the current browsing context.
* NOTE: mozIndexedDB should be removed post-2.0. Bug 623316.
*/
readonly attribute nsIIDBFactory mozIndexedDB;
[noscript] readonly attribute nsIIDBFactory mozIndexedDB;
};

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=8 et tw=80 : */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -89,6 +89,24 @@ class AudioPauseEvent : public nsRunnable
PRBool mPause;
};
class AudioStreamShutdownEvent : public nsRunnable
{
public:
AudioStreamShutdownEvent(nsAudioStream* owner)
{
mOwner = owner;
}
NS_IMETHOD Run()
{
mOwner->Shutdown();
return NS_OK;
}
private:
nsRefPtr<nsAudioStream> mOwner;
};
class AudioDrainDoneEvent : public nsRunnable
{
public:
@ -134,20 +152,24 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(AudioParent, nsITimerCallback)
nsresult
AudioParent::Notify(nsITimer* timer)
{
if (!mIPCOpen || !mStream) {
if (!mIPCOpen) {
timer->Cancel();
return NS_ERROR_FAILURE;
}
NS_ASSERTION(mStream, "AudioStream not initialized.");
PRInt64 offset = mStream->GetSampleOffset();
SendSampleOffsetUpdate(offset, PR_IntervalNow());
return NS_OK;
}
bool
AudioParent::RecvWrite(
const nsCString& data,
const PRUint32& count)
{
if (!mStream)
return false;
nsCOMPtr<nsIRunnable> event = new AudioWriteEvent(mStream, data, count);
nsCOMPtr<nsIThread> thread = mStream->GetThread();
thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
@ -157,14 +179,17 @@ AudioParent::RecvWrite(
bool
AudioParent::RecvSetVolume(const float& aVolume)
{
if (mStream)
mStream->SetVolume(aVolume);
if (!mStream)
return false;
mStream->SetVolume(aVolume);
return true;
}
bool
AudioParent::RecvDrain()
{
if (!mStream)
return false;
nsCOMPtr<nsIRunnable> event = new AudioDrainEvent(this, mStream);
nsCOMPtr<nsIThread> thread = mStream->GetThread();
thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
@ -174,6 +199,8 @@ AudioParent::RecvDrain()
bool
AudioParent::RecvPause()
{
if (!mStream)
return false;
nsCOMPtr<nsIRunnable> event = new AudioPauseEvent(mStream, PR_TRUE);
nsCOMPtr<nsIThread> thread = mStream->GetThread();
thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
@ -183,6 +210,8 @@ AudioParent::RecvPause()
bool
AudioParent::RecvResume()
{
if (!mStream)
return false;
nsCOMPtr<nsIRunnable> event = new AudioPauseEvent(mStream, PR_FALSE);
nsCOMPtr<nsIThread> thread = mStream->GetThread();
thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
@ -192,15 +221,18 @@ AudioParent::RecvResume()
bool
AudioParent::Recv__delete__()
{
if (mStream) {
mStream->Shutdown();
mStream = nsnull;
}
if (mTimer) {
mTimer->Cancel();
mTimer = nsnull;
}
if (mStream) {
nsCOMPtr<nsIRunnable> event = new AudioStreamShutdownEvent(mStream);
nsCOMPtr<nsIThread> thread = mStream->GetThread();
thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
mStream = nsnull;
}
return true;
}
@ -208,12 +240,14 @@ AudioParent::AudioParent(PRInt32 aNumChannels, PRInt32 aRate, PRInt32 aFormat)
: mIPCOpen(PR_TRUE)
{
mStream = nsAudioStream::AllocateStream();
if (mStream)
mStream->Init(aNumChannels,
aRate,
(nsAudioStream::SampleFormat) aFormat);
if (!mStream)
return;
NS_ASSERTION(mStream, "AudioStream allocation failed.");
if (NS_FAILED(mStream->Init(aNumChannels,
aRate,
(nsAudioStream::SampleFormat) aFormat))) {
NS_WARNING("AudioStream initialization failed.");
mStream = nsnull;
return;
}
mTimer = do_CreateInstance("@mozilla.org/timer;1");
mTimer->InitWithCallback(this, 1000, nsITimer::TYPE_REPEATING_SLACK);

View File

@ -2090,7 +2090,7 @@ StreamNotifyChild::RecvRedirectNotify(const nsCString& url, const int32_t& statu
PluginInstanceChild* instance = static_cast<PluginInstanceChild*>(Manager());
if (instance->mPluginIface->urlredirectnotify)
instance->mPluginIface->urlredirectnotify(instance->GetNPP(), mURL.get(), status, mClosure);
instance->mPluginIface->urlredirectnotify(instance->GetNPP(), url.get(), status, mClosure);
return true;
}

View File

@ -156,6 +156,47 @@ private:
JSContext* mCx;
};
class nsDestroyJSContextRunnable : public nsIRunnable
{
public:
NS_DECL_ISUPPORTS
nsDestroyJSContextRunnable(JSContext* aCx)
: mCx(aCx)
{
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(aCx, "Null pointer!");
NS_ASSERTION(!JS_GetGlobalObject(aCx), "Should not have a global!");
// We're removing this context from this thread. Let the JS engine know.
JS_ClearContextThread(aCx);
}
NS_IMETHOD Run()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
// We're about to use this context on this thread. Let the JS engine know.
if (!!JS_SetContextThread(mCx)) {
NS_WARNING("JS_SetContextThread failed!");
}
if (nsContentUtils::XPConnect()) {
nsContentUtils::XPConnect()->ReleaseJSContext(mCx, PR_TRUE);
}
else {
NS_WARNING("Failed to release JSContext!");
}
return NS_OK;
}
private:
JSContext* mCx;
};
NS_IMPL_THREADSAFE_ISUPPORTS1(nsDestroyJSContextRunnable, nsIRunnable)
/**
* This class is used as to post an error to the worker's outer handler.
*/
@ -1396,7 +1437,14 @@ nsDOMThreadService::OnThreadShuttingDown()
gThreadJSContextStack->SetSafeJSContext(nsnull);
nsContentUtils::XPConnect()->ReleaseJSContext(cx, PR_TRUE);
// The cycle collector may be running on the main thread. If so we cannot
// simply destroy this context. Instead we proxy the context destruction to
// the main thread. If that fails somehow then we simply leak the context.
nsCOMPtr<nsIRunnable> runnable = new nsDestroyJSContextRunnable(cx);
if (NS_FAILED(NS_DispatchToMainThread(runnable, NS_DISPATCH_NORMAL))) {
NS_WARNING("Failed to dispatch release runnable!");
}
}
return NS_OK;

View File

@ -130,12 +130,17 @@ class GeckoAppShell
StatFs cacheStats = new StatFs(cacheFile.getPath());
long freeSpace = cacheStats.getFreeBlocks() * cacheStats.getBlockSize();
File downloadDir = null;
if (Build.VERSION.SDK_INT >= 8)
downloadDir = GeckoApp.mAppContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
else
downloadDir = new File(Environment.getExternalStorageDirectory().getPath(), "download");
GeckoAppShell.putenv("DOWNLOADS_DIRECTORY=" + downloadDir.getPath());
try {
File downloadDir = null;
if (Build.VERSION.SDK_INT >= 8)
downloadDir = GeckoApp.mAppContext.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS);
else
downloadDir = new File(Environment.getExternalStorageDirectory().getPath(), "download");
GeckoAppShell.putenv("DOWNLOADS_DIRECTORY=" + downloadDir.getPath());
}
catch (Exception e) {
Log.i("GeckoApp", "No download directory has been found: " + e);
}
putLocaleEnv();

View File

@ -47,7 +47,12 @@
#include "gfxPlatform.h"
using namespace mozilla::layers;
typedef FrameMetrics::ViewID ViewID;
const ViewID FrameMetrics::NULL_SCROLL_ID = 0;
const ViewID FrameMetrics::ROOT_SCROLL_ID = 1;
const ViewID FrameMetrics::START_SCROLL_ID = 2;
#ifdef MOZ_LAYERS_HAVE_LOG
FILE*
FILEOrDefault(FILE* aFile)
@ -79,6 +84,15 @@ AppendToString(nsACString& s, const gfxPattern::GraphicsFilter& f,
return s += sfx;
}
nsACString&
AppendToString(nsACString& s, ViewID n,
const char* pfx="", const char* sfx="")
{
s += pfx;
s.AppendInt(n);
return s += sfx;
}
nsACString&
AppendToString(nsACString& s, const gfxRGBA& c,
const char* pfx="", const char* sfx="")
@ -164,9 +178,10 @@ AppendToString(nsACString& s, const FrameMetrics& m,
const char* pfx="", const char* sfx="")
{
s += pfx;
AppendToString(s, m.mViewportSize, "{ viewport=");
AppendToString(s, m.mViewport, "{ viewport=");
AppendToString(s, m.mViewportScrollOffset, " viewportScroll=");
AppendToString(s, m.mDisplayPort, " displayport=", " }");
AppendToString(s, m.mDisplayPort, " displayport=");
AppendToString(s, m.mScrollId, " scrollId=", " }");
return s += sfx;
}

View File

@ -86,19 +86,30 @@ class SpecificLayerAttributes;
* useful for shadow layers, because the metrics values are updated
* atomically with new pixels.
*/
struct FrameMetrics {
struct THEBES_API FrameMetrics {
public:
// We use IDs to identify frames across processes.
typedef PRUint64 ViewID;
static const ViewID NULL_SCROLL_ID; // This container layer does not scroll.
static const ViewID ROOT_SCROLL_ID; // This is the root scroll frame.
static const ViewID START_SCROLL_ID; // This is the ID that scrolling subframes
// will begin at.
FrameMetrics()
: mViewportSize(0, 0)
: mViewport(0, 0, 0, 0)
, mContentSize(0, 0)
, mViewportScrollOffset(0, 0)
, mScrollId(NULL_SCROLL_ID)
{}
// Default copy ctor and operator= are fine
PRBool operator==(const FrameMetrics& aOther) const
{
return (mViewportSize == aOther.mViewportSize &&
return (mViewport == aOther.mViewport &&
mViewportScrollOffset == aOther.mViewportScrollOffset &&
mDisplayPort == aOther.mDisplayPort);
mDisplayPort == aOther.mDisplayPort &&
mScrollId == aOther.mScrollId);
}
PRBool IsDefault() const
@ -106,9 +117,21 @@ struct FrameMetrics {
return (FrameMetrics() == *this);
}
nsIntSize mViewportSize;
PRBool IsRootScrollable() const
{
return mScrollId == ROOT_SCROLL_ID;
}
PRBool IsScrollable() const
{
return mScrollId != NULL_SCROLL_ID;
}
nsIntRect mViewport;
nsIntSize mContentSize;
nsIntPoint mViewportScrollOffset;
nsIntRect mDisplayPort;
ViewID mScrollId;
};
#define MOZ_LAYER_DECL_NAME(n, e) \

View File

@ -40,6 +40,7 @@
#include "gfxD2DSurface.h"
#include "gfxWindowsSurface.h"
#include "yuv_convert.h"
#include "../d3d9/Nv3DVUtils.h"
namespace mozilla {
namespace layers {
@ -287,9 +288,9 @@ ImageLayerD3D10::RenderLayer()
}
if (yuvImage->mDevice != device()) {
// These shader resources were created for an old device! Can't draw
// that here.
return;
// These shader resources were created for an old device! Can't draw
// that here.
return;
}
// TODO: At some point we should try to deal with mFilter here, you don't
@ -303,6 +304,39 @@ ImageLayerD3D10::RenderLayer()
effect()->GetVariableByName("tCb")->AsShaderResource()->SetResource(yuvImage->mCbView);
effect()->GetVariableByName("tCr")->AsShaderResource()->SetResource(yuvImage->mCrView);
/*
* Send 3d control data and metadata to NV3DVUtils
*/
if (GetNv3DVUtils()) {
Nv_Stereo_Mode mode;
switch (yuvImage->mData.mStereoMode) {
case STEREO_MODE_LEFT_RIGHT:
mode = NV_STEREO_MODE_LEFT_RIGHT;
break;
case STEREO_MODE_RIGHT_LEFT:
mode = NV_STEREO_MODE_RIGHT_LEFT;
break;
case STEREO_MODE_BOTTOM_TOP:
mode = NV_STEREO_MODE_BOTTOM_TOP;
break;
case STEREO_MODE_TOP_BOTTOM:
mode = NV_STEREO_MODE_TOP_BOTTOM;
break;
case STEREO_MODE_MONO:
mode = NV_STEREO_MODE_MONO;
break;
}
// Send control data even in mono case so driver knows to leave stereo mode.
GetNv3DVUtils()->SendNv3DVControl(mode, true, FIREFOX_3DV_APP_HANDLE);
if (yuvImage->mData.mStereoMode != STEREO_MODE_MONO) {
// Dst resource is optional
GetNv3DVUtils()->SendNv3DVMetaData((unsigned int)yuvImage->mSize.width,
(unsigned int)yuvImage->mSize.height, (HANDLE)(yuvImage->mYTexture), (HANDLE)(NULL));
}
}
effect()->GetVariableByName("vLayerQuad")->AsVector()->SetFloatVector(
ShaderConstantRectD3D10(
(float)0,

View File

@ -48,6 +48,8 @@
#include "CanvasLayerD3D10.h"
#include "ImageLayerD3D10.h"
#include "../d3d9/Nv3DVUtils.h"
namespace mozilla {
namespace layers {
@ -98,11 +100,35 @@ LayerManagerD3D10::Initialize()
{
HRESULT hr;
/* Create an Nv3DVUtils instance */
if (!mNv3DVUtils) {
mNv3DVUtils = new Nv3DVUtils();
if (!mNv3DVUtils) {
NS_WARNING("Could not create a new instance of Nv3DVUtils.\n");
}
}
/* Initialize the Nv3DVUtils object */
if (mNv3DVUtils) {
mNv3DVUtils->Initialize();
}
mDevice = gfxWindowsPlatform::GetPlatform()->GetD3D10Device();
if (!mDevice) {
return false;
}
/*
* Do some post device creation setup
*/
if (mNv3DVUtils) {
IUnknown* devUnknown = NULL;
if (mDevice) {
mDevice->QueryInterface(IID_IUnknown, (void **)&devUnknown);
}
mNv3DVUtils->SetDeviceInfo(devUnknown);
}
UINT size = sizeof(ID3D10Effect*);
if (FAILED(mDevice->GetPrivateData(sEffect, &size, mEffect.StartAssignment()))) {
D3D10CreateEffectFromMemoryFunc createEffect = (D3D10CreateEffectFromMemoryFunc)

Some files were not shown because too many files have changed in this diff Show More