Commit f8550279 authored by Gijs Kruitbosch's avatar Gijs Kruitbosch
Browse files

Bug 1222490 - part 1: remove browser/components/tabview and its references, r=ttaubert

--HG--
extra : commitid : 32uPFrV2zvJ
extra : rebase_source : d626d0de588ef9188f30084fefd0cd6f6b8e31fd
parent 585185b9
......@@ -21,7 +21,6 @@ DIRS += [
'sessionstore',
'shell',
'selfsupport',
'tabview',
'uitour',
'translation',
]
......
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var Cu = Components.utils;
var Ci = Components.interfaces;
Cu.import("resource:///modules/tabview/utils.jsm");
// Bug 671101 - directly using webProgress in this context
// causes docShells to leak
this.__defineGetter__("webProgress", function () {
let ifaceReq = docShell.QueryInterface(Ci.nsIInterfaceRequestor);
return ifaceReq.getInterface(Ci.nsIWebProgress);
});
// ----------
// WindowEventHandler
//
// Handles events dispatched by the content window.
var WindowEventHandler = {
// ----------
// Function: onDOMWillOpenModalDialog
// Sends a synchronous message when the "onDOMWillOpenModalDialog" event
// is fired right before a modal dialog will be opened by the current page.
onDOMWillOpenModalDialog: function WEH_onDOMWillOpenModalDialog(event) {
// (event.isTrusted == true) when the event is generated by a user action
// and does not originate from a script.
if (!event.isTrusted)
return;
// we're intentionally sending a synchronous message to handle this event
// as quick as possible, switch the selected tab and hide the tabview
// before the modal dialog is shown
sendSyncMessage("Panorama:DOMWillOpenModalDialog");
},
// ----------
// Function: onMozAfterPaint
// Sends an asynchronous message when the "onMozAfterPaint" event
// is fired.
onMozAfterPaint: function WEH_onMozAfterPaint(event) {
if (event.clientRects.length > 0) {
sendAsyncMessage("Panorama:MozAfterPaint");
}
}
};
// add event listeners
addEventListener("DOMWillOpenModalDialog", WindowEventHandler.onDOMWillOpenModalDialog, false);
addEventListener("MozAfterPaint", WindowEventHandler.onMozAfterPaint, false);
// ----------
// WindowMessageHandler
//
// Handles messages sent by the chrome process.
var WindowMessageHandler = {
// ----------
// Function: isDocumentLoaded
// Checks if the currently active document is loaded.
isDocumentLoaded: function WMH_isDocumentLoaded(cx) {
let isLoaded = (content &&
content.document.readyState != "uninitialized" &&
!webProgress.isLoadingDocument);
sendAsyncMessage(cx.name, {isLoaded: isLoaded});
},
// ----------
// Function: isImageDocument
// Checks if the currently active document is an image document or not.
isImageDocument: function WMH_isImageDocument(cx) {
let isImageDocument = (content &&
content.document instanceof Ci.nsIImageDocument);
sendAsyncMessage(cx.name, {isImageDocument: isImageDocument});
},
waitForDocumentLoad: function WMH_waitForDocumentLoad() {
addEventListener("load", function listener() {
removeEventListener("load", listener, true);
sendAsyncMessage("Panorama:documentLoaded");
}, true);
},
};
// add message listeners
addMessageListener("Panorama:isDocumentLoaded", WindowMessageHandler.isDocumentLoaded);
addMessageListener("Panorama:isImageDocument", WindowMessageHandler.isImageDocument);
addMessageListener("Panorama:waitForDocumentLoad", WindowMessageHandler.waitForDocumentLoad);
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// **********
// Title: drag.js
// ----------
// Variable: drag
// The Drag that's currently in process.
var drag = {
info: null,
zIndex: 100,
lastMoveTime: 0
};
//----------
//Variable: resize
//The resize (actually a Drag) that is currently in process
var resize = {
info: null,
lastMoveTime: 0
};
// ##########
// Class: Drag (formerly DragInfo)
// Helper class for dragging <Item>s
//
// ----------
// Constructor: Drag
// Called to create a Drag in response to an <Item> draggable "start" event.
// Note that it is also used partially during <Item>'s resizable method as well.
//
// Parameters:
// item - The <Item> being dragged
// event - The DOM event that kicks off the drag
function Drag(item, event) {
Utils.assert(item && (item.isAnItem || item.isAFauxItem),
'must be an item, or at least a faux item');
this.item = item;
this.el = item.container;
this.$el = iQ(this.el);
this.parent = this.item.parent;
this.startPosition = new Point(event.clientX, event.clientY);
this.startTime = Date.now();
this.item.isDragging = true;
this.item.setZ(999999);
this.safeWindowBounds = Items.getSafeWindowBounds();
Trenches.activateOthersTrenches(this.el);
};
Drag.prototype = {
// ----------
// Function: toString
// Prints [Drag (item)] for debug use
toString: function Drag_toString() {
return "[Drag (" + this.item + ")]";
},
// ----------
// Function: snapBounds
// Adjusts the given bounds according to the currently active trenches. Used by <Drag.snap>
//
// Parameters:
// bounds - (<Rect>) bounds
// stationaryCorner - which corner is stationary? by default, the top left in LTR mode,
// and top right in RTL mode.
// "topleft", "bottomleft", "topright", "bottomright"
// assumeConstantSize - (boolean) whether the bounds' dimensions are sacred or not.
// keepProportional - (boolean) if assumeConstantSize is false, whether we should resize
// proportionally or not
// checkItemStatus - (boolean) make sure this is a valid item which should be snapped
snapBounds: function Drag_snapBounds(bounds, stationaryCorner, assumeConstantSize, keepProportional, checkItemStatus) {
if (!stationaryCorner)
stationaryCorner = UI.rtl ? 'topright' : 'topleft';
var update = false; // need to update
var updateX = false;
var updateY = false;
var newRect;
var snappedTrenches = {};
// OH SNAP!
// if we aren't holding down the meta key or have trenches disabled...
if (!Keys.meta && !Trenches.disabled) {
// snappable = true if we aren't a tab on top of something else, and
// there's no active drop site...
let snappable = !(this.item.isATabItem &&
this.item.overlapsWithOtherItems()) &&
!iQ(".acceptsDrop").length;
if (!checkItemStatus || snappable) {
newRect = Trenches.snap(bounds, stationaryCorner, assumeConstantSize,
keepProportional);
if (newRect) { // might be false if no changes were made
update = true;
snappedTrenches = newRect.snappedTrenches || {};
bounds = newRect;
}
}
}
// make sure the bounds are in the window.
newRect = this.snapToEdge(bounds, stationaryCorner, assumeConstantSize,
keepProportional);
if (newRect) {
update = true;
bounds = newRect;
Utils.extend(snappedTrenches, newRect.snappedTrenches);
}
Trenches.hideGuides();
for (var edge in snappedTrenches) {
var trench = snappedTrenches[edge];
if (typeof trench == 'object') {
trench.showGuide = true;
trench.show();
}
}
return update ? bounds : false;
},
// ----------
// Function: snap
// Called when a drag or mousemove occurs. Set the bounds based on the mouse move first, then
// call snap and it will adjust the item's bounds if appropriate. Also triggers the display of
// trenches that it snapped to.
//
// Parameters:
// stationaryCorner - which corner is stationary? by default, the top left in LTR mode,
// and top right in RTL mode.
// "topleft", "bottomleft", "topright", "bottomright"
// assumeConstantSize - (boolean) whether the bounds' dimensions are sacred or not.
// keepProportional - (boolean) if assumeConstantSize is false, whether we should resize
// proportionally or not
snap: function Drag_snap(stationaryCorner, assumeConstantSize, keepProportional) {
var bounds = this.item.getBounds();
bounds = this.snapBounds(bounds, stationaryCorner, assumeConstantSize, keepProportional, true);
if (bounds) {
this.item.setBounds(bounds, true);
return true;
}
return false;
},
// --------
// Function: snapToEdge
// Returns a version of the bounds snapped to the edge if it is close enough. If not,
// returns false. If <Keys.meta> is true, this function will simply enforce the
// window edges.
//
// Parameters:
// rect - (<Rect>) current bounds of the object
// stationaryCorner - which corner is stationary? by default, the top left in LTR mode,
// and top right in RTL mode.
// "topleft", "bottomleft", "topright", "bottomright"
// assumeConstantSize - (boolean) whether the rect's dimensions are sacred or not
// keepProportional - (boolean) if we are allowed to change the rect's size, whether the
// dimensions should scaled proportionally or not.
snapToEdge: function Drag_snapToEdge(rect, stationaryCorner, assumeConstantSize, keepProportional) {
var swb = this.safeWindowBounds;
var update = false;
var updateX = false;
var updateY = false;
var snappedTrenches = {};
var snapRadius = (Keys.meta ? 0 : Trenches.defaultRadius);
if (rect.left < swb.left + snapRadius ) {
if (stationaryCorner.indexOf('right') > -1 && !assumeConstantSize)
rect.width = rect.right - swb.left;
rect.left = swb.left;
update = true;
updateX = true;
snappedTrenches.left = 'edge';
}
if (rect.right > swb.right - snapRadius) {
if (updateX || !assumeConstantSize) {
var newWidth = swb.right - rect.left;
if (keepProportional)
rect.height = rect.height * newWidth / rect.width;
rect.width = newWidth;
update = true;
} else if (!updateX || !Trenches.preferLeft) {
rect.left = swb.right - rect.width;
update = true;
}
snappedTrenches.right = 'edge';
delete snappedTrenches.left;
}
if (rect.top < swb.top + snapRadius) {
if (stationaryCorner.indexOf('bottom') > -1 && !assumeConstantSize)
rect.height = rect.bottom - swb.top;
rect.top = swb.top;
update = true;
updateY = true;
snappedTrenches.top = 'edge';
}
if (rect.bottom > swb.bottom - snapRadius) {
if (updateY || !assumeConstantSize) {
var newHeight = swb.bottom - rect.top;
if (keepProportional)
rect.width = rect.width * newHeight / rect.height;
rect.height = newHeight;
update = true;
} else if (!updateY || !Trenches.preferTop) {
rect.top = swb.bottom - rect.height;
update = true;
}
snappedTrenches.top = 'edge';
delete snappedTrenches.bottom;
}
if (update) {
rect.snappedTrenches = snappedTrenches;
return rect;
}
return false;
},
// ----------
// Function: drag
// Called in response to an <Item> draggable "drag" event.
drag: function Drag_drag(event) {
this.snap(UI.rtl ? 'topright' : 'topleft', true);
if (this.parent && this.parent.expanded) {
var distance = this.startPosition.distance(new Point(event.clientX, event.clientY));
if (distance > 100) {
this.parent.remove(this.item);
this.parent.collapse();
}
}
},
// ----------
// Function: stop
// Called in response to an <Item> draggable "stop" event.
//
// Parameters:
// immediately - bool for doing the pushAway immediately, without animation
stop: function Drag_stop(immediately) {
Trenches.hideGuides();
this.item.isDragging = false;
if (this.parent && this.parent != this.item.parent)
this.parent.closeIfEmpty();
if (this.parent && this.parent.expanded)
this.parent.arrange();
if (this.item.parent)
this.item.parent.arrange();
if (this.item.isAGroupItem) {
this.item.setZ(drag.zIndex);
drag.zIndex++;
this.item.pushAway(immediately);
}
Trenches.disactivate();
}
};
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import('resource://gre/modules/PlacesUtils.jsm');
var FavIcons = {
// Pref that controls whether to display site icons.
PREF_CHROME_SITE_ICONS: "browser.chrome.site_icons",
// Pref that controls whether to display fav icons.
PREF_CHROME_FAVICONS: "browser.chrome.favicons",
// Lazy getter for pref browser.chrome.site_icons.
get _prefSiteIcons() {
delete this._prefSiteIcons;
this._prefSiteIcons = Services.prefs.getBoolPref(this.PREF_CHROME_SITE_ICONS);
},
// Lazy getter for pref browser.chrome.favicons.
get _prefFavicons() {
delete this._prefFavicons;
this._prefFavicons = Services.prefs.getBoolPref(this.PREF_CHROME_FAVICONS);
},
get defaultFavicon() {
return this._favIconService.defaultFavicon.spec;
},
init: function FavIcons_init() {
XPCOMUtils.defineLazyServiceGetter(this, "_favIconService",
"@mozilla.org/browser/favicon-service;1", "nsIFaviconService");
Services.prefs.addObserver(this.PREF_CHROME_SITE_ICONS, this, false);
Services.prefs.addObserver(this.PREF_CHROME_FAVICONS, this, false);
},
uninit: function FavIcons_uninit() {
Services.prefs.removeObserver(this.PREF_CHROME_SITE_ICONS, this);
Services.prefs.removeObserver(this.PREF_CHROME_FAVICONS, this);
},
observe: function FavIcons_observe(subject, topic, data) {
let value = Services.prefs.getBoolPref(data);
if (data == this.PREF_CHROME_SITE_ICONS)
this._prefSiteIcons = value;
else if (data == this.PREF_CHROME_FAVICONS)
this._prefFavicons = value;
},
// ----------
// Function: getFavIconUrlForTab
// Gets the "favicon link URI" for the given xul:tab, or null if unavailable.
getFavIconUrlForTab: function FavIcons_getFavIconUrlForTab(tab, callback) {
this._isImageDocument(tab, function (isImageDoc) {
if (isImageDoc) {
callback(tab.pinned ? tab.image : null);
} else {
this._getFavIconForNonImageDocument(tab, callback);
}
}.bind(this));
},
// ----------
// Function: _getFavIconForNonImageDocument
// Retrieves the favicon for a tab containing a non-image document.
_getFavIconForNonImageDocument:
function FavIcons_getFavIconForNonImageDocument(tab, callback) {
if (tab.image)
this._getFavIconFromTabImage(tab, callback);
else if (this._shouldLoadFavIcon(tab))
this._getFavIconForHttpDocument(tab, callback);
else
callback(null);
},
// ----------
// Function: _getFavIconFromTabImage
// Retrieves the favicon for tab with a tab image.
_getFavIconFromTabImage:
function FavIcons_getFavIconFromTabImage(tab, callback) {
let tabImage = gBrowser.getIcon(tab);
// If the tab image's url starts with http(s), fetch icon from favicon
// service via the moz-anno protocol.
if (/^https?:/.test(tabImage)) {
let tabImageURI = gWindow.makeURI(tabImage);
tabImage = this._favIconService.getFaviconLinkForIcon(tabImageURI).spec;
}
callback(tabImage);
},
// ----------
// Function: _getFavIconForHttpDocument
// Retrieves the favicon for tab containg a http(s) document.
_getFavIconForHttpDocument:
function FavIcons_getFavIconForHttpDocument(tab, callback) {
let {currentURI} = tab.linkedBrowser;
this._favIconService.getFaviconURLForPage(currentURI, function (uri) {
if (uri) {
let icon = this._favIconService.getFaviconLinkForIcon(uri).spec;
callback(icon);
} else {
callback(this.defaultFavicon);
}
}.bind(this));
},
// ----------
// Function: _isImageDocument
// Checks whether an image is loaded into the given tab.
_isImageDocument: function UI__isImageDocument(tab, callback) {
let mm = tab.linkedBrowser.messageManager;
let message = "Panorama:isImageDocument";
mm.addMessageListener(message, function onMessage(cx) {
mm.removeMessageListener(cx.name, onMessage);
callback(cx.json.isImageDocument);
});
mm.sendAsyncMessage(message);
},
// ----------
// Function: _shouldLoadFavIcon
// Checks whether fav icon should be loaded for a given tab.
_shouldLoadFavIcon: function FavIcons_shouldLoadFavIcon(tab) {
// No need to load a favicon if the user doesn't want site or favicons.
if (!this._prefSiteIcons || !this._prefFavicons)
return false;
let uri = tab.linkedBrowser.currentURI;
// Stop here if we don't have a valid nsIURI.
if (!uri || !(uri instanceof Ci.nsIURI))
return false;
// Load favicons for http(s) pages only.
return uri.schemeIs("http") || uri.schemeIs("https");
}
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
browser.jar:
content/browser/tabview.css
* content/browser/tabview.js
content/browser/tabview.html
content/browser/tabview-content.js (content.js)
This diff is collapsed.
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_JS_MODULES.tabview = ['modules/utils.jsm']
BROWSER_CHROME_MANIFESTS += [
'test/browser.ini',
]
JAR_MANIFESTS += ['jar.mn']
with Files('**'):
BUG_COMPONENT = ('Firefox', 'Panorama')
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
<head>
<title>&nbsp;</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<link rel="stylesheet" href="tabview.css" type="text/css"/>
<link rel="stylesheet" href="chrome://browser/skin/tabview/tabview.css" type="text/css"/>
</head>
<body transparent="true">
<div id="content">
<div id="bg">
</div>
<div id="actions">
<input id="exit-button" type="button" alt="" groups="0" />
<input id="searchbutton" type="button"/>
</div>
</div>
<div id="searchshade"></div>
<div id="search">
<input id="searchbox" type="text"/>
<div id="otherresults">
<span class="label"></span>
<span id="results"></span>
</div>
</div>
<script type="text/javascript;version=1.8" src="tabview.js"></script>
</body>
</html>
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this