Automerge with mc. no manual changes

This commit is contained in:
Doug Turner 2010-04-21 03:31:13 -07:00
Родитель 612f1cd867 9d6a2f9408
Коммит 9a784d5dfd
509 изменённых файлов: 27818 добавлений и 9517 удалений

Просмотреть файл

@ -605,18 +605,6 @@ nsAccessible::GetChildren(nsIArray **aOutChildren)
return NS_OK;
}
nsIAccessible *nsAccessible::NextChild(nsCOMPtr<nsIAccessible>& aAccessible)
{
nsCOMPtr<nsIAccessible> nextChild;
if (!aAccessible) {
GetFirstChild(getter_AddRefs(nextChild));
}
else {
aAccessible->GetNextSibling(getter_AddRefs(nextChild));
}
return (aAccessible = nextChild);
}
PRBool
nsAccessible::GetAllowsAnonChildAccessibles()
{
@ -931,8 +919,10 @@ nsAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY, PRBool aDeepestChild,
// where layout won't walk into things for us, such as image map areas and
// sub documents (XXX: subdocuments should be handled by methods of
// nsOuterDocAccessibles).
nsCOMPtr<nsIAccessible> child;
while (NextChild(child)) {
PRInt32 childCount = GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible *child = GetChildAt(childIdx);
PRInt32 childX, childY, childWidth, childHeight;
child->GetBounds(&childX, &childY, &childWidth, &childHeight);
if (aX >= childX && aX < childX + childWidth &&
@ -2994,7 +2984,7 @@ void
nsAccessible::TestChildCache(nsAccessible *aCachedChild)
{
#ifdef DEBUG
PRUint32 childCount = mChildren.Length();
PRInt32 childCount = mChildren.Length();
if (childCount == 0) {
NS_ASSERTION(!mAreChildrenInitialized, "No children but initialized!");
return;

Просмотреть файл

@ -350,10 +350,6 @@ protected:
// helper method to verify frames
static nsresult GetFullKeyName(const nsAString& aModifierName, const nsAString& aKeyName, nsAString& aStringOut);
static nsresult GetTranslatedString(const nsAString& aKey, nsAString& aStringOut);
// nsCOMPtr<>& is useful here, because getter_AddRefs() nulls the comptr's value, and NextChild
// depends on the passed-in comptr being null or already set to a child (finding the next sibling).
nsIAccessible *NextChild(nsCOMPtr<nsIAccessible>& aAccessible);
already_AddRefed<nsIAccessible> GetNextWithState(nsIAccessible *aStart, PRUint32 matchState);

Просмотреть файл

@ -322,23 +322,24 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset,
*aEndAcc = nsnull;
nsIntRect unionRect;
nsCOMPtr<nsIAccessible> accessible, lastAccessible;
nsAccessible *lastAccessible = nsnull;
gfxSkipChars skipChars;
gfxSkipCharsIterator iter;
// Loop through children and collect valid offsets, text and bounds
// depending on what we need for out parameters
while (NextChild(accessible)) {
lastAccessible = accessible;
nsRefPtr<nsAccessNode> accessNode = nsAccUtils::QueryAccessNode(accessible);
// depending on what we need for out parameters.
PRInt32 childCount = GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible *childAcc = mChildren[childIdx];
lastAccessible = childAcc;
nsIFrame *frame = accessNode->GetFrame();
nsIFrame *frame = childAcc->GetFrame();
if (!frame) {
continue;
}
nsIFrame *primaryFrame = frame;
if (nsAccUtils::IsText(accessible)) {
if (nsAccUtils::IsText(childAcc)) {
// We only need info up to rendered offset -- that is what we're
// converting to content offset
PRInt32 substringEndOffset = -1;
@ -357,7 +358,7 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset,
if (substringEndOffset < 0) {
// XXX for non-textframe text like list bullets,
// should go away after list bullet rewrite
substringEndOffset = nsAccUtils::TextLength(accessible);
substringEndOffset = nsAccUtils::TextLength(childAcc);
}
if (startOffset < substringEndOffset) {
// Our start is within this substring
@ -378,7 +379,7 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset,
if (aEndFrame) {
*aEndFrame = frame; // We ended in the current frame
if (aEndAcc)
NS_ADDREF(*aEndAcc = accessible);
NS_ADDREF(*aEndAcc = childAcc);
}
if (substringEndOffset > endOffset) {
// Need to stop before the end of the available text
@ -392,9 +393,8 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset,
*aText += '*'; // Show *'s only for password text
}
else {
nsRefPtr<nsAccessible> acc(nsAccUtils::QueryAccessible(accessible));
acc->AppendTextTo(*aText, startOffset,
substringEndOffset - startOffset);
childAcc->AppendTextTo(*aText, startOffset,
substringEndOffset - startOffset);
}
}
if (aBoundsRect) { // Caller wants the bounds of the text
@ -406,7 +406,7 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset,
startFrame = frame;
aStartOffset = startOffset;
if (aStartAcc)
NS_ADDREF(*aStartAcc = accessible);
NS_ADDREF(*aStartAcc = childAcc);
}
// We already started copying in this accessible's string,
// for the next accessible we'll start at offset 0
@ -448,7 +448,7 @@ nsHyperTextAccessible::GetPosAndText(PRInt32& aStartOffset, PRInt32& aEndOffset,
startFrame = frame;
aStartOffset = 0;
if (aStartAcc)
NS_ADDREF(*aStartAcc = accessible);
NS_ADDREF(*aStartAcc = childAcc);
}
}
-- endOffset;
@ -483,15 +483,17 @@ NS_IMETHODIMP nsHyperTextAccessible::GetText(PRInt32 aStartOffset, PRInt32 aEndO
*/
NS_IMETHODIMP nsHyperTextAccessible::GetCharacterCount(PRInt32 *aCharacterCount)
{
NS_ENSURE_ARG_POINTER(aCharacterCount);
*aCharacterCount = 0;
if (!mDOMNode) {
if (IsDefunct())
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIAccessible> accessible;
PRInt32 childCount = GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible *childAcc = mChildren[childIdx];
while (NextChild(accessible)) {
PRInt32 textLength = nsAccUtils::TextLength(accessible);
PRInt32 textLength = nsAccUtils::TextLength(childAcc);
NS_ENSURE_TRUE(textLength >= 0, nsnull);
*aCharacterCount += textLength;
}
@ -596,15 +598,19 @@ nsresult nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode* aNode, PRI
}
descendantAccessible = GetFirstAvailableAccessible(findNode);
}
// From the descendant, go up and get the immediate child of this hypertext
nsCOMPtr<nsIAccessible> childAccessible;
while (descendantAccessible) {
nsCOMPtr<nsIAccessible> parentAccessible;
descendantAccessible->GetParent(getter_AddRefs(parentAccessible));
if (this == parentAccessible) {
childAccessible = descendantAccessible;
nsRefPtr<nsAccessible> childAccAtOffset;
nsRefPtr<nsAccessible> descendantAcc =
nsAccUtils::QueryObject<nsAccessible>(descendantAccessible);
while (descendantAcc) {
nsRefPtr<nsAccessible> parentAcc = descendantAcc->GetParent();
if (parentAcc == this) {
childAccAtOffset = descendantAcc;
break;
}
// This offset no longer applies because the passed-in text object is not a child
// of the hypertext. This happens when there are nested hypertexts, e.g.
// <div>abc<h1>def</h1>ghi</div>
@ -622,29 +628,40 @@ nsresult nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode* aNode, PRI
// Make sure the offset lands on the embedded object character in order to indicate
// the true inner offset is inside the subtree for that link
addTextOffset =
(nsAccUtils::TextLength(descendantAccessible) == static_cast<PRInt32>(addTextOffset)) ? 1 : 0;
(nsAccUtils::TextLength(descendantAcc) == static_cast<PRInt32>(addTextOffset)) ? 1 : 0;
}
descendantAccessible = parentAccessible;
}
descendantAcc.swap(parentAcc);
}
// Loop through, adding offsets until we reach childAccessible
// If childAccessible is null we will end up adding up the entire length of
// the hypertext, which is good -- it just means our offset node
// came after the last accessible child's node
nsCOMPtr<nsIAccessible> accessible;
while (NextChild(accessible) && accessible != childAccessible) {
PRInt32 textLength = nsAccUtils::TextLength(accessible);
PRInt32 childCount = GetChildCount();
PRInt32 childIdx = 0;
nsAccessible *childAcc = nsnull;
for (; childIdx < childCount; childIdx++) {
childAcc = mChildren[childIdx];
if (childAcc == childAccAtOffset)
break;
PRInt32 textLength = nsAccUtils::TextLength(childAcc);
NS_ENSURE_TRUE(textLength >= 0, nsnull);
*aHyperTextOffset += textLength;
}
if (accessible) {
if (childIdx < childCount) {
*aHyperTextOffset += addTextOffset;
NS_ASSERTION(accessible == childAccessible, "These should be equal whenever we exit loop and accessible != nsnull");
NS_ASSERTION(childAcc == childAccAtOffset,
"These should be equal whenever we exit loop and childAcc != nsnull");
if (aFinalAccessible &&
(NextChild(accessible) ||
static_cast<PRInt32>(addTextOffset) < nsAccUtils::TextLength(childAccessible))) {
(childIdx < childCount - 1 ||
static_cast<PRInt32>(addTextOffset) < nsAccUtils::TextLength(childAccAtOffset))) {
// If not at end of last text node, we will return the accessible we were in
NS_ADDREF(*aFinalAccessible = childAccessible);
NS_ADDREF(*aFinalAccessible = childAccAtOffset);
}
}
@ -1277,13 +1294,12 @@ nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY,
// We have an point in an accessible child of this, now we need to add up the
// offsets before it to what we already have
nsCOMPtr<nsIAccessible> accessible;
PRInt32 offset = 0;
PRInt32 childCount = GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible *childAcc = mChildren[childIdx];
while (NextChild(accessible)) {
nsRefPtr<nsAccessNode> accessNode = nsAccUtils::QueryAccessNode(accessible);
nsIFrame *primaryFrame = accessNode->GetFrame();
nsIFrame *primaryFrame = childAcc->GetFrame();
NS_ENSURE_TRUE(primaryFrame, NS_ERROR_FAILURE);
nsIFrame *frame = primaryFrame;
@ -1311,7 +1327,7 @@ nsHyperTextAccessible::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY,
}
frame = frame->GetNextContinuation();
}
PRInt32 textLength = nsAccUtils::TextLength(accessible);
PRInt32 textLength = nsAccUtils::TextLength(childAcc);
NS_ENSURE_TRUE(textLength >= 0, NS_ERROR_FAILURE);
offset += textLength;
}
@ -1325,14 +1341,13 @@ nsHyperTextAccessible::GetLinkCount(PRInt32 *aLinkCount)
{
NS_ENSURE_ARG_POINTER(aLinkCount);
*aLinkCount = 0;
if (!mDOMNode) {
if (IsDefunct())
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIAccessible> accessible;
while (NextChild(accessible)) {
if (nsAccUtils::IsEmbeddedObject(accessible))
PRInt32 childCount = GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible *childAcc = mChildren[childIdx];
if (nsAccUtils::IsEmbeddedObject(childAcc))
++*aLinkCount;
}
return NS_OK;
@ -1349,10 +1364,12 @@ nsHyperTextAccessible::GetLink(PRInt32 aLinkIndex, nsIAccessibleHyperLink **aLin
return NS_ERROR_FAILURE;
PRInt32 linkIndex = aLinkIndex;
nsCOMPtr<nsIAccessible> accessible;
while (NextChild(accessible)) {
if (nsAccUtils::IsEmbeddedObject(accessible) && linkIndex-- == 0)
return CallQueryInterface(accessible, aLink);
PRInt32 childCount = GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible *childAcc = mChildren[childIdx];
if (nsAccUtils::IsEmbeddedObject(childAcc) && linkIndex-- == 0)
return CallQueryInterface(childAcc, aLink);
}
return NS_ERROR_INVALID_ARG;
@ -1364,19 +1381,21 @@ nsHyperTextAccessible::GetLinkIndex(PRInt32 aCharIndex, PRInt32 *aLinkIndex)
NS_ENSURE_ARG_POINTER(aLinkIndex);
*aLinkIndex = -1; // API says this magic value means 'not found'
if (IsDefunct())
return NS_ERROR_FAILURE;
PRInt32 characterCount = 0;
PRInt32 linkIndex = 0;
if (!mDOMNode) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIAccessible> accessible;
PRInt32 childCount = GetChildCount();
for (PRInt32 childIdx = 0;
childIdx < childCount && characterCount <= aCharIndex; childIdx++) {
nsAccessible *childAcc = mChildren[childIdx];
while (NextChild(accessible) && characterCount <= aCharIndex) {
PRUint32 role = nsAccUtils::Role(accessible);
PRUint32 role = nsAccUtils::Role(childAcc);
if (role == nsIAccessibleRole::ROLE_TEXT_LEAF ||
role == nsIAccessibleRole::ROLE_STATICTEXT) {
PRInt32 textLength = nsAccUtils::TextLength(accessible);
PRInt32 textLength = nsAccUtils::TextLength(childAcc);
NS_ENSURE_TRUE(textLength >= 0, NS_ERROR_FAILURE);
characterCount += textLength;
}

Просмотреть файл

@ -185,7 +185,7 @@ nsAccessibleWrap::FirePlatformEvent(nsAccEvent *aEvent)
return NS_OK;
nsCOMPtr<nsIAccessible> accessible;
nsresult rv = aEvent->GetAccessible(getter_AddRefs(accessible));
aEvent->GetAccessible(getter_AddRefs(accessible));
NS_ENSURE_STATE(accessible);
mozAccessible *nativeAcc = nil;
@ -227,35 +227,34 @@ nsAccessibleWrap::GetUnignoredChildCount(PRBool aDeepCount)
// if we're flat, we have no children.
if (nsAccUtils::MustPrune(this))
return 0;
PRInt32 childCount = 0;
GetChildCount(&childCount);
nsCOMPtr<nsIAccessible> curAcc;
while (NextChild(curAcc)) {
nsAccessibleWrap *childWrap = static_cast<nsAccessibleWrap*>(curAcc.get());
PRInt32 resultChildCount = 0;
PRInt32 childCount = GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessibleWrap *childAcc =
static_cast<nsAccessibleWrap*>(GetChildAt(childIdx));
// if the current child is not ignored, count it.
if (!childWrap->IsIgnored())
++childCount;
if (!childAcc->IsIgnored())
++resultChildCount;
// if it's flat, we don't care to inspect its children.
if (nsAccUtils::MustPrune(childWrap))
if (nsAccUtils::MustPrune(childAcc))
continue;
if (aDeepCount) {
// recursively count the unignored children of our children since it's a deep count.
childCount += childWrap->GetUnignoredChildCount(PR_TRUE);
resultChildCount += childAcc->GetUnignoredChildCount(PR_TRUE);
} else {
// no deep counting, but if the child is ignored, we want to substitute it for its
// children.
if (childWrap->IsIgnored())
childCount += childWrap->GetUnignoredChildCount(PR_FALSE);
if (childAcc->IsIgnored())
resultChildCount += childAcc->GetUnignoredChildCount(PR_FALSE);
}
}
return childCount;
return resultChildCount;
}
// if we for some reason have no native accessible, we should be skipped over (and traversed)
@ -269,19 +268,20 @@ nsAccessibleWrap::IsIgnored()
void
nsAccessibleWrap::GetUnignoredChildren(nsTArray<nsRefPtr<nsAccessibleWrap> > &aChildrenArray)
{
nsCOMPtr<nsIAccessible> curAcc;
// we're flat; there are no children.
if (nsAccUtils::MustPrune(this))
return;
while (NextChild(curAcc)) {
nsAccessibleWrap *childWrap = static_cast<nsAccessibleWrap*>(curAcc.get());
if (childWrap->IsIgnored()) {
PRInt32 childCount = GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessibleWrap *childAcc =
static_cast<nsAccessibleWrap*>(GetChildAt(childIdx));
if (childAcc->IsIgnored()) {
// element is ignored, so try adding its children as substitutes, if it has any.
if (!nsAccUtils::MustPrune(childWrap)) {
if (!nsAccUtils::MustPrune(childAcc)) {
nsTArray<nsRefPtr<nsAccessibleWrap> > children;
childWrap->GetUnignoredChildren(children);
childAcc->GetUnignoredChildren(children);
if (!children.IsEmpty()) {
// add the found unignored descendants to the array.
aChildrenArray.AppendElements(children);
@ -289,7 +289,7 @@ nsAccessibleWrap::GetUnignoredChildren(nsTArray<nsRefPtr<nsAccessibleWrap> > &aC
}
} else
// simply add the element, since it's not ignored.
aChildrenArray.AppendElement(childWrap);
aChildrenArray.AppendElement(childAcc);
}
}

Просмотреть файл

@ -492,20 +492,21 @@ nsXULGroupboxAccessible::GetRelationByType(PRUint32 aRelationType,
// The label for xul:groupbox is generated from xul:label that is
// inside the anonymous content of the xul:caption.
// The xul:label has an accessible object but the xul:caption does not
nsCOMPtr<nsIAccessible> testLabelAccessible;
while (NextChild(testLabelAccessible)) {
if (nsAccUtils::Role(testLabelAccessible) == nsIAccessibleRole::ROLE_LABEL) {
PRInt32 childCount = GetChildCount();
for (PRInt32 childIdx = 0; childIdx < childCount; childIdx++) {
nsAccessible *childAcc = GetChildAt(childIdx);
if (nsAccUtils::Role(childAcc) == nsIAccessibleRole::ROLE_LABEL) {
// Ensure that it's our label
// XXX: we'll fail if group accessible expose more than one relation
// targets.
nsCOMPtr<nsIAccessible> testGroupboxAccessible =
nsRelUtils::GetRelatedAccessible(testLabelAccessible,
nsRelUtils::GetRelatedAccessible(childAcc,
nsIAccessibleRelation::RELATION_LABEL_FOR);
if (testGroupboxAccessible == this) {
// The <label> points back to this groupbox
return nsRelUtils::
AddTarget(aRelationType, aRelation, testLabelAccessible);
AddTarget(aRelationType, aRelation, childAcc);
}
}
}

Просмотреть файл

@ -36,6 +36,8 @@
Components.utils.import("resource://gre/modules/Services.jsm");
var handleDroppedLink = null;
var XULBrowserWindow = {
isBusy: false,
setOverLink: function (link, b) {

Просмотреть файл

@ -22,7 +22,9 @@
gOpenerWnd.SimpleTest.is(aExpected, aActual, aMsg);
}
// Hack to make xul:tabbrowser work.
// Hacks to make xul:tabbrowser work.
var handleDroppedLink = null; // needed for tabbrowser usage
Components.utils.import("resource://gre/modules/Services.jsm");
var XULBrowserWindow = {
isBusy: false,

Просмотреть файл

@ -33,6 +33,7 @@
// Hack to make xul:tabbrowser work.
Components.utils.import("resource://gre/modules/Services.jsm");
var handleDroppedLink = null;
var XULBrowserWindow = {
isBusy: false,
setOverLink: function (link, b) {

Просмотреть файл

@ -411,7 +411,7 @@ var PlacesCommandHook = {
var parent = aParent != undefined ?
aParent : PlacesUtils.unfiledBookmarksFolderId;
var descAnno = { name: DESCRIPTION_ANNO, value: description };
var descAnno = { name: PlacesUIUtils.DESCRIPTION_ANNO, value: description };
var txn = PlacesUIUtils.ptm.createItem(uri, parent, -1,
title, null, [descAnno]);
PlacesUIUtils.ptm.doTransaction(txn);

Просмотреть файл

@ -1097,16 +1097,14 @@ function HandleAppCommandEvent(evt) {
function prepareForStartup() {
gBrowser.addEventListener("DOMUpdatePageReport", gPopupBlockerObserver.onUpdatePageReport, false);
// Note: we need to listen to untrusted events, because the pluginfinder XBL
// binding can't fire trusted ones (runs with page privileges).
gBrowser.addEventListener("PluginNotFound", gMissingPluginInstaller.newMissingPlugin, true, true);
gBrowser.addEventListener("PluginCrashed", gMissingPluginInstaller.pluginInstanceCrashed, true, true);
gBrowser.addEventListener("PluginBlocklisted", gMissingPluginInstaller.newMissingPlugin, true, true);
gBrowser.addEventListener("PluginOutdated", gMissingPluginInstaller.newMissingPlugin, true, true);
gBrowser.addEventListener("PluginDisabled", gMissingPluginInstaller.newDisabledPlugin, true, true);
gBrowser.addEventListener("NewPluginInstalled", gMissingPluginInstaller.refreshBrowser, false);
gBrowser.addEventListener("PluginNotFound", gPluginHandler, true);
gBrowser.addEventListener("PluginCrashed", gPluginHandler, true);
gBrowser.addEventListener("PluginBlocklisted", gPluginHandler, true);
gBrowser.addEventListener("PluginOutdated", gPluginHandler, true);
gBrowser.addEventListener("PluginDisabled", gPluginHandler, true);
gBrowser.addEventListener("NewPluginInstalled", gPluginHandler.newPluginInstalled, true);
Services.obs.addObserver(gMissingPluginInstaller.pluginCrashed, "plugin-crashed", false);
Services.obs.addObserver(gPluginHandler.pluginCrashed, "plugin-crashed", false);
window.addEventListener("AppCommand", HandleAppCommandEvent, true);
@ -1400,7 +1398,7 @@ function BrowserShutdown()
Services.obs.removeObserver(gSessionHistoryObserver, "browser:purge-session-history");
Services.obs.removeObserver(gXPInstallObserver, "xpinstall-install-blocked");
Services.obs.removeObserver(gMissingPluginInstaller.pluginCrashed, "plugin-crashed");
Services.obs.removeObserver(gPluginHandler.pluginCrashed, "plugin-crashed");
try {
gBrowser.removeProgressListener(window.XULBrowserWindow);
@ -2697,48 +2695,9 @@ function FillInHTMLTooltip(tipElement)
}
var browserDragAndDrop = {
getDragURLFromDataTransfer : function (dt)
dragOver: function (aEvent, statusString)
{
var types = dt.types;
for (var t = 0; t < types.length; t++) {
var type = types[t];
switch (type) {
case "text/uri-list":
var url = dt.getData("URL").replace(/^\s+|\s+$/g, "");
return [url, url];
case "text/plain":
case "text/x-moz-text-internal":
var url = dt.getData(type).replace(/^\s+|\s+$/g, "");
return [url, url];
case "text/x-moz-url":
var split = dt.getData(type).split("\n");
return [split[0], split[1]];
}
}
// For shortcuts, we want to check for the file type last, so that the
// url pointed to in one of the url types is found first before the file
// type, which points to the actual file.
var file = dt.mozGetDataAt("application/x-moz-file", 0);
if (file) {
var name = file instanceof Ci.nsIFile ? file.leafName : "";
var fileHandler = ContentAreaUtils.ioService
.getProtocolHandler("file")
.QueryInterface(Ci.nsIFileProtocolHandler);
return [fileHandler.getURLSpecFromFile(file), name];
}
return [ , ];
},
dragOver : function (aEvent, statusString)
{
var types = aEvent.dataTransfer.types;
if (types.contains("application/x-moz-file") ||
types.contains("text/x-moz-url") ||
types.contains("text/uri-list") ||
types.contains("text/x-moz-text-internal") ||
types.contains("text/plain")) {
if (Services.droppedLinkHandler.canDropLink(aEvent, true)) {
aEvent.preventDefault();
if (statusString) {
@ -2746,9 +2705,10 @@ var browserDragAndDrop = {
statusTextFld.label = gNavigatorBundle.getString(statusString);
}
}
}
}
},
drop: function (aEvent, aName) Services.droppedLinkHandler.dropLink(aEvent, aName)
}
var proxyIconDNDObserver = {
onDragStart: function (aEvent, aXferData, aDragAction)
@ -2771,8 +2731,7 @@ var proxyIconDNDObserver = {
var homeButtonObserver = {
onDrop: function (aEvent)
{
let url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
setTimeout(openHomeDialog, 0, url);
setTimeout(openHomeDialog, 0, browserDragAndDrop.drop(aEvent, { }));
},
onDragOver: function (aEvent)
@ -2813,7 +2772,8 @@ function openHomeDialog(aURL)
var bookmarksButtonObserver = {
onDrop: function (aEvent)
{
let [url, name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
let name = { };
let url = browserDragAndDrop.drop(aEvent, name);
try {
PlacesUIUtils.showMinimalAddBookmarkUI(makeURI(url), name);
} catch(ex) { }
@ -2846,11 +2806,10 @@ var newTabButtonObserver = {
onDrop: function (aEvent)
{
let url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
let url = browserDragAndDrop.drop(aEvent, { });
var postData = {};
url = getShortcutOrURI(url, postData);
if (url) {
nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
// allow third-party services to fixup this URL
openNewTabWith(url, null, postData.value, aEvent, true);
}
@ -2869,11 +2828,10 @@ var newWindowButtonObserver = {
},
onDrop: function (aEvent)
{
let url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
let url = browserDragAndDrop.drop(aEvent, { });
var postData = {};
url = getShortcutOrURI(url, postData);
if (url) {
nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
// allow third-party services to fixup this URL
openNewWindowWith(url, null, postData.value, true);
}
@ -2902,9 +2860,10 @@ var DownloadsButtonDNDObserver = {
onDrop: function (aEvent)
{
let [url, name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
saveURL(url, name, null, true, true);
let name = { };
let url = browserDragAndDrop.drop(aEvent, name);
if (url)
saveURL(url, name, null, true, true);
}
}
@ -5067,56 +5026,16 @@ function middleMousePaste(event)
event.stopPropagation();
}
/*
* Note that most of this routine has been moved into C++ in order to
* be available for all <browser> tags as well as gecko embedding. See
* mozilla/content/base/src/nsContentAreaDragDrop.cpp.
*
* Do not add any new fuctionality here other than what is needed for
* a standalone product.
*/
function handleDroppedLink(event, url, name)
{
let postData = { };
let uri = getShortcutOrURI(url, postData);
if (uri)
loadURI(uri, null, postData.value, false);
var contentAreaDNDObserver = {
onDrop: function (aEvent)
{
if (aEvent.getPreventDefault())
return;
var types = aEvent.dataTransfer.types;
if (!types.contains("application/x-moz-file") &&
!types.contains("text/x-moz-url") &&
!types.contains("text/uri-list") &&
!types.contains("text/plain")) {
aEvent.preventDefault();
return;
}
let [url, name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
// valid urls don't contain spaces ' '; if we have a space it
// isn't a valid url, or if it's a javascript: or data: url,
// bail out
if (!url || !url.length || url.indexOf(" ", 0) != -1 ||
/^\s*(javascript|data):/.test(url))
return;
nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
switch (document.documentElement.getAttribute('windowtype')) {
case "navigator:browser":
var postData = { };
var uri = getShortcutOrURI(url, postData);
loadURI(uri, null, postData.value, false);
break;
case "navigator:view-source":
viewSource(url);
break;
}
// keep the event from being handled by the dragDrop listeners
// built-in to gecko if they happen to be above us.
aEvent.preventDefault();
}
// Keep the event from being handled by the dragDrop listeners
// built-in to gecko if they happen to be above us.
event.preventDefault();
};
function MultiplexHandler(event)
@ -5928,7 +5847,7 @@ function getPluginInfo(pluginElement)
return {mimetype: tagMimetype, pluginsPage: pluginsPage};
}
var gMissingPluginInstaller = {
var gPluginHandler = {
get CrashSubmit() {
delete this.CrashSubmit;
@ -5955,6 +5874,16 @@ var gMissingPluginInstaller = {
return newName;
},
isTooSmall : function (plugin, overlay) {
// Is the <object>'s size too small to hold what we want to show?
let pluginRect = plugin.getBoundingClientRect();
// XXX bug 446693. The text-shadow on the submitted-report text at
// the bottom causes scrollHeight to be larger than it should be.
let overflows = (overlay.scrollWidth > pluginRect.width) ||
(overlay.scrollHeight - 5 > pluginRect.height);
return overflows;
},
addLinkClickCallback: function (linkNode, callbackName /*callbackArgs...*/) {
// XXX just doing (callback)(arg) was giving a same-origin error. bug?
let self = this;
@ -5985,6 +5914,58 @@ var gMissingPluginInstaller = {
true);
},
handleEvent : function(event) {
let self = gPluginHandler;
let plugin = event.target;
// We're expecting the target to be a plugin.
if (!(plugin instanceof Ci.nsIObjectLoadingContent))
return;
switch (event.type) {
case "PluginCrashed":
self.pluginInstanceCrashed(plugin, event);
break;
case "PluginNotFound":
// For non-object plugin tags, register a click handler to install the
// plugin. Object tags can, and often do, deal with that themselves,
// so don't stomp on the page developers toes.
if (!(plugin instanceof HTMLObjectElement))
self.addLinkClickCallback(plugin, "installSinglePlugin");
/* FALLTHRU */
case "PluginBlocklisted":
case "PluginOutdated":
let hideBarPrefName = event.type == "PluginOutdated" ?
"plugins.hide_infobar_for_outdated_plugin" :
"plugins.hide_infobar_for_missing_plugin";
if (gPrefService.getBoolPref(hideBarPrefName))
return;
self.pluginUnavailable(plugin, event.type);
break;
case "PluginDisabled":
self.addLinkClickCallback(plugin, "managePlugins");
break;
}
},
newPluginInstalled : function(event) {
// browser elements are anonymous so we can't just use target.
var browser = event.originalTarget;
// clear the plugin list, now that at least one plugin has been installed
browser.missingPlugins = null;
var notificationBox = gBrowser.getNotificationBox(browser);
var notification = notificationBox.getNotificationWithValue("missing-plugins");
if (notification)
notificationBox.removeNotification(notification);
// reload the browser to make the new plugin show.
browser.reload();
},
// Callback for user clicking on a missing (unsupported) plugin.
installSinglePlugin: function (aEvent) {
var missingPluginsArray = {};
@ -6022,51 +6003,27 @@ var gMissingPluginInstaller = {
},
// event listener for missing/blocklisted/outdated plugins.
newMissingPlugin: function (aEvent) {
// Since we are expecting also untrusted events, make sure
// that the target is a plugin
if (!(aEvent.target instanceof Ci.nsIObjectLoadingContent))
return;
// For broken non-object plugin tags, register a click handler so
// that the user can click the plugin replacement to get the new
// plugin. Object tags can, and often do, deal with that themselves,
// so don't stomp on the page developers toes.
if (aEvent.type != "PluginBlocklisted" &&
aEvent.type != "PluginOutdated" &&
!(aEvent.target instanceof HTMLObjectElement)) {
gMissingPluginInstaller.addLinkClickCallback(aEvent.target, "installSinglePlugin");
}
let hideBarPrefName = aEvent.type == "PluginOutdated" ?
"plugins.hide_infobar_for_outdated_plugin" :
"plugins.hide_infobar_for_missing_plugin";
if (gPrefService.getBoolPref(hideBarPrefName))
return;
var browser = gBrowser.getBrowserForDocument(aEvent.target.ownerDocument
pluginUnavailable: function (plugin, eventType) {
let browser = gBrowser.getBrowserForDocument(plugin.ownerDocument
.defaultView.top.document);
if (!browser.missingPlugins)
browser.missingPlugins = {};
var pluginInfo = getPluginInfo(aEvent.target);
var pluginInfo = getPluginInfo(plugin);
browser.missingPlugins[pluginInfo.mimetype] = pluginInfo;
var notificationBox = gBrowser.getNotificationBox(browser);
// Should only display one of these warnings per page.
// In order of priority, they are: outdated > missing > blocklisted
let outdatedNotification = notificationBox.getNotificationWithValue("outdated-plugins");
let blockedNotification = notificationBox.getNotificationWithValue("blocked-plugins");
let missingNotification = notificationBox.getNotificationWithValue("missing-plugins");
// If there is already an outdated plugin notification then do nothing
if (notificationBox.getNotificationWithValue("outdated-plugins"))
if (outdatedNotification)
return;
var blockedNotification = notificationBox.getNotificationWithValue("blocked-plugins");
var missingNotification = notificationBox.getNotificationWithValue("missing-plugins");
var priority = notificationBox.PRIORITY_WARNING_MEDIUM;
function showBlocklistInfo() {
var url = formatURL("extensions.blocklist.detailsURL", true);
@ -6091,75 +6048,72 @@ var gMissingPluginInstaller = {
}
}
if (aEvent.type == "PluginBlocklisted") {
let notifications = {
PluginBlocklisted : {
barID : "blocked-plugins",
iconURL : "chrome://mozapps/skin/plugins/pluginBlocked-16.png",
message : gNavigatorBundle.getString("blockedpluginsMessage.title"),
buttons : [{
label : gNavigatorBundle.getString("blockedpluginsMessage.infoButton.label"),
accessKey : gNavigatorBundle.getString("blockedpluginsMessage.infoButton.accesskey"),
popup : null,
callback : showBlocklistInfo
},
{
label : gNavigatorBundle.getString("blockedpluginsMessage.searchButton.label"),
accessKey : gNavigatorBundle.getString("blockedpluginsMessage.searchButton.accesskey"),
popup : null,
callback : showOutdatedPluginsInfo
}],
},
PluginOutdated : {
barID : "outdated-plugins",
iconURL : "chrome://mozapps/skin/plugins/pluginOutdated-16.png",
message : gNavigatorBundle.getString("outdatedpluginsMessage.title"),
buttons : [{
label : gNavigatorBundle.getString("outdatedpluginsMessage.updateButton.label"),
accessKey : gNavigatorBundle.getString("outdatedpluginsMessage.updateButton.accesskey"),
popup : null,
callback : showOutdatedPluginsInfo
}],
},
PluginNotFound : {
barID : "missing-plugins",
iconURL : "chrome://mozapps/skin/plugins/pluginGeneric-16.png",
message : gNavigatorBundle.getString("missingpluginsMessage.title"),
buttons : [{
label : gNavigatorBundle.getString("missingpluginsMessage.button.label"),
accessKey : gNavigatorBundle.getString("missingpluginsMessage.button.accesskey"),
popup : null,
callback : showPluginsMissing
}],
}
};
if (eventType == "PluginBlocklisted") {
if (blockedNotification || missingNotification)
return;
let iconURL = "chrome://mozapps/skin/plugins/pluginBlocked-16.png";
let messageString = gNavigatorBundle.getString("blockedpluginsMessage.title");
let buttons = [{
label: gNavigatorBundle.getString("blockedpluginsMessage.infoButton.label"),
accessKey: gNavigatorBundle.getString("blockedpluginsMessage.infoButton.accesskey"),
popup: null,
callback: showBlocklistInfo
}, {
label: gNavigatorBundle.getString("blockedpluginsMessage.searchButton.label"),
accessKey: gNavigatorBundle.getString("blockedpluginsMessage.searchButton.accesskey"),
popup: null,
callback: showOutdatedPluginsInfo
}];
notificationBox.appendNotification(messageString, "blocked-plugins",
iconURL, priority, buttons);
}
else if (aEvent.type == "PluginOutdated") {
else if (eventType == "PluginOutdated") {
// Cancel any notification about blocklisting/missing plugins
if (blockedNotification)
blockedNotification.close();
if (missingNotification)
missingNotification.close();
let iconURL = "chrome://mozapps/skin/plugins/pluginOutdated-16.png";
let messageString = gNavigatorBundle.getString("outdatedpluginsMessage.title");
let buttons = [{
label: gNavigatorBundle.getString("outdatedpluginsMessage.updateButton.label"),
accessKey: gNavigatorBundle.getString("outdatedpluginsMessage.updateButton.accesskey"),
popup: null,
callback: showOutdatedPluginsInfo
}];
notificationBox.appendNotification(messageString, "outdated-plugins",
iconURL, priority, buttons);
}
else if (aEvent.type == "PluginNotFound") {
else if (eventType == "PluginNotFound") {
if (missingNotification)
return;
// Cancel any notification about blocklisting plugins
if (blockedNotification)
blockedNotification.close();
let iconURL = "chrome://mozapps/skin/plugins/pluginGeneric-16.png";
let messageString = gNavigatorBundle.getString("missingpluginsMessage.title");
let buttons = [{
label: gNavigatorBundle.getString("missingpluginsMessage.button.label"),
accessKey: gNavigatorBundle.getString("missingpluginsMessage.button.accesskey"),
popup: null,
callback: showPluginsMissing
}];
notificationBox.appendNotification(messageString, "missing-plugins",
iconURL, priority, buttons);
}
},
newDisabledPlugin: function (aEvent) {
// Since we are expecting also untrusted events, make sure
// that the target is a plugin
if (!(aEvent.target instanceof Ci.nsIObjectLoadingContent))
return;
gMissingPluginInstaller.addLinkClickCallback(aEvent.target, "managePlugins");
let notify = notifications[eventType];
notificationBox.appendNotification(notify.message, notify.barID, notify.iconURL,
notificationBox.PRIORITY_WARNING_MEDIUM,
notify.buttons);
},
// Crashed-plugin observer. Notified once per plugin crash, before events
@ -6187,17 +6141,9 @@ var gMissingPluginInstaller = {
// Crashed-plugin event listener. Called for every instance of a
// plugin in content.
pluginInstanceCrashed: function (aEvent) {
let self = gMissingPluginInstaller;
// Evil content could fire a fake event at us, ignore them.
if (!aEvent.isTrusted)
return;
pluginInstanceCrashed: function (plugin, aEvent) {
// Ensure the plugin and event are of the right type.
let plugin = aEvent.target;
if (!(aEvent instanceof Ci.nsIDOMDataContainerEvent) ||
!(plugin instanceof Ci.nsIObjectLoadingContent))
if (!(aEvent instanceof Ci.nsIDOMDataContainerEvent))
return;
let submittedReport = aEvent.getData("submittedCrashReport");
@ -6209,7 +6155,7 @@ var gMissingPluginInstaller = {
let browserDumpID = aEvent.getData("browserDumpID");
// Remap the plugin name to a more user-presentable form.
pluginName = self.makeNicePluginName(pluginName, pluginFilename);
pluginName = this.makeNicePluginName(pluginName, pluginFilename);
// Force a style flush, so that we ensure our binding is attached.
plugin.clientTop;
@ -6243,7 +6189,7 @@ var gMissingPluginInstaller = {
// XXX can we make the link target actually be blank?
let pleaseLink = doc.getAnonymousElementByAttribute(
plugin, "class", "pleaseSubmitLink");
self.addLinkClickCallback(pleaseLink, "submitReport",
this.addLinkClickCallback(pleaseLink, "submitReport",
pluginDumpID, browserDumpID);
}
@ -6258,7 +6204,7 @@ var gMissingPluginInstaller = {
let bottomLinks = doc.getAnonymousElementByAttribute(plugin, "class", "msg msgBottomLinks");
bottomLinks.style.display = "block";
let helpIcon = doc.getAnonymousElementByAttribute(plugin, "class", "helpIcon");
self.addLinkClickCallback(helpIcon, "openHelpPage");
this.addLinkClickCallback(helpIcon, "openHelpPage");
// If we're showing the link to manually trigger report submission, we'll
// want to be able to update all the instances of the UI for this crash to
@ -6299,17 +6245,12 @@ var gMissingPluginInstaller = {
let browser = gBrowser.getBrowserForDocument(doc.defaultView.top.document);
let link = doc.getAnonymousElementByAttribute(plugin, "class", "reloadLink");
self.addLinkClickCallback(link, "reloadPage", browser);
this.addLinkClickCallback(link, "reloadPage", browser);
let notificationBox = gBrowser.getNotificationBox(browser);
// Is the <object>'s size too small to hold what we want to show?
let pluginRect = plugin.getBoundingClientRect();
// XXX bug 446693. The text-shadow on the submitted-report text at
// the bottom causes scrollHeight to be larger than it should be.
let isObjectTooSmall = (overlay.scrollWidth > pluginRect.width) ||
(overlay.scrollHeight - 5 > pluginRect.height);
if (isObjectTooSmall) {
if (this.isTooSmall(plugin, overlay)) {
// Hide the overlay's contents. Use visibility style, so that it
// doesn't collapse down to 0x0.
overlay.style.visibility = "hidden";
@ -6356,7 +6297,7 @@ var gMissingPluginInstaller = {
label: submitLabel,
accessKey: submitKey,
popup: null,
callback: function() { gMissingPluginInstaller.submitReport(pluginDumpID, browserDumpID); },
callback: function() { gPluginHandler.submitReport(pluginDumpID, browserDumpID); },
};
if (pluginDumpID)
buttons.push(submitButton);
@ -6370,27 +6311,11 @@ var gMissingPluginInstaller = {
let link = notification.ownerDocument.createElementNS(XULNS, "label");
link.className = "text-link";
link.setAttribute("value", gNavigatorBundle.getString("crashedpluginsMessage.learnMore"));
link.href = gMissingPluginInstaller.crashReportHelpURL;
link.href = gPluginHandler.crashReportHelpURL;
let description = notification.ownerDocument.getAnonymousElementByAttribute(notification, "anonid", "messageText");
description.appendChild(link);
}
},
refreshBrowser: function (aEvent) {
// browser elements are anonymous so we can't just use target.
var browser = aEvent.originalTarget;
var notificationBox = gBrowser.getNotificationBox(browser);
var notification = notificationBox.getNotificationWithValue("missing-plugins");
// clear the plugin list, now that at least one plugin has been installed
browser.missingPlugins = null;
if (notification) {
// reset UI
notificationBox.removeNotification(notification);
}
// reload the browser to make the new plugin show.
browser.reload();
}
};

Просмотреть файл

@ -665,7 +665,6 @@
tabcontainer="tabbrowser-tabs"
contentcontextmenu="contentAreaContextMenu"
autocompletepopup="PopupAutoComplete"
ondrop="contentAreaDNDObserver.onDrop(event)"
onclick="return contentAreaClick(event, false);"/>
</vbox>
</hbox>
@ -677,7 +676,7 @@
#ifdef WINCE
hidden="true"
#endif
ondrop="contentAreaDNDObserver.onDrop(event)">
>
<statusbarpanel id="statusbar-display" label="" flex="1"/>
<statusbarpanel class="statusbarpanel-progress" collapsed="true" id="statusbar-progresspanel">
<progressmeter class="progressmeter-statusbar" id="statusbar-icon" mode="normal" value="0"/>

Просмотреть файл

@ -278,6 +278,10 @@ function onLoadPageInfo()
gStrings.mediaEmbed = gBundle.getString("mediaEmbed");
gStrings.mediaLink = gBundle.getString("mediaLink");
gStrings.mediaInput = gBundle.getString("mediaInput");
#ifdef MOZ_MEDIA
gStrings.mediaVideo = gBundle.getString("mediaVideo");
gStrings.mediaAudio = gBundle.getString("mediaAudio");
#endif
var args = "arguments" in window &&
window.arguments.length >= 1 &&
@ -621,6 +625,14 @@ function grabAll(elem)
addImage(href, gStrings.mediaImg, "", elem, false);
} catch (e) { }
}
#endif
#ifdef MOZ_MEDIA
else if (elem instanceof HTMLVideoElement) {
addImage(elem.currentSrc, gStrings.mediaVideo, "", elem, false);
}
else if (elem instanceof HTMLAudioElement) {
addImage(elem.currentSrc, gStrings.mediaAudio, "", elem, false);
}
#endif
else if (elem instanceof HTMLLinkElement) {
if (elem.rel && /\bicon\b/i.test(elem.rel))
@ -813,6 +825,7 @@ function makePreview(row)
var item = getSelectedImage(imageTree);
var url = gImageView.data[row][COL_IMAGE_ADDRESS];
var isBG = gImageView.data[row][COL_IMAGE_BG];
var isAudo = false;
setItemValue("imageurltext", url);
@ -914,8 +927,8 @@ function makePreview(row)
if (/^data:/.test(url) && /^image\//.test(mimeType))
isProtocolAllowed = true;
var newImage = new Image();
newImage.setAttribute("id", "thepreviewimage");
var newImage = new Image;
newImage.id = "thepreviewimage";
var physWidth = 0, physHeight = 0;
var width = 0, height = 0;
@ -956,6 +969,33 @@ function makePreview(row)
document.getElementById("theimagecontainer").collapsed = false
document.getElementById("brokenimagecontainer").collapsed = true;
}
#ifdef MOZ_MEDIA
else if (item instanceof HTMLVideoElement && isProtocolAllowed) {
newImage = document.createElementNS("http://www.w3.org/1999/xhtml", "video");
newImage.id = "thepreviewimage";
newImage.mozLoadFrom(item);
newImage.controls = true;
physWidth = item.videoWidth;
physHeight = item.videoHeight;
width = item.width != -1 ? item.width : physWidth;
height = item.height != -1 ? item.height : physHeight;
newImage.width = width;
newImage.height = height;
document.getElementById("theimagecontainer").collapsed = false;
document.getElementById("brokenimagecontainer").collapsed = true;
}
else if (item instanceof HTMLAudioElement && isProtocolAllowed) {
newImage = new Audio;
newImage.id = "thepreviewimage";
newImage.src = url;
newImage.controls = true;
isAudo = true;
document.getElementById("theimagecontainer").collapsed = false;
document.getElementById("brokenimagecontainer").collapsed = true;
}
#endif
else {
// fallback image for protocols not allowed (e.g., data: or javascript:)
// or elements not [yet] handled (e.g., object, embed).
@ -964,7 +1004,7 @@ function makePreview(row)
}
var imageSize = "";
if (url) {
if (url && !isAudo) {
if (width != physWidth || height != physHeight) {
imageSize = gBundle.getFormattedString("mediaDimensionsScaled",
[formatNumber(physWidth),

Просмотреть файл

@ -75,10 +75,12 @@
#ifdef CRH_DIALOG_TREE_VIEW
<script type="application/javascript"
src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript"
src="chrome://browser/content/places/utils.js"/>
<script type="application/javascript"
src="chrome://browser/content/places/treeView.js"/>
<script type="application/javascript"><![CDATA[
Components.utils.import("resource://gre/modules/utils.js");
Components.utils.import("resource:///modules/PlacesUIUtils.jsm");
]]></script>
#endif
<script type="application/javascript"

Просмотреть файл

@ -1213,6 +1213,7 @@
this.mTabFilters[position] = filter;
b._fastFind = this.fastFind;
b.droppedLinkHandler = handleDroppedLink;
var uniqueId = "panel" + Date.now() + position;
this.mPanelContainer.lastChild.id = uniqueId;
@ -2269,6 +2270,7 @@
this._autoScrollPopup.id = "autoscroller";
this.appendChild(this._autoScrollPopup);
this.mCurrentBrowser.setAttribute("autoscrollpopup", this._autoScrollPopup.id);
this.mCurrentBrowser.droppedLinkHandler = handleDroppedLink;
]]>
</constructor>

Просмотреть файл

@ -242,24 +242,31 @@ function test() {
// Clear Today
Sanitizer.prefs.setIntPref("timeSpan", 4);
s.sanitize();
ok(!bhist.isVisited(makeURI("http://today.com")), "Pretend visit to today.com should now be deleted");
// Be careful. If we add our objectss just before midnight, and sanitize
// runs immediately after, they won't be expired. This is expected, but
// we should not test in that case. We cannot just test for opposite
// condition because we could cross midnight just one moment after we
// cache our time, then we would have an even worse random failure.
var today = isToday(new Date(now_uSec/1000));
if (today) {
ok(!bhist.isVisited(makeURI("http://today.com")), "Pretend visit to today.com should now be deleted");
ok(!formhist.nameExists("today"), "today form entry should be deleted");
ok(!downloadExists(5555554), "'Today' download should now be deleted");
}
ok(bhist.isVisited(makeURI("http://before-today.com")), "Pretend visit to before-today.com should still exist");
ok(!formhist.nameExists("today"), "today form entry should be deleted");
ok(formhist.nameExists("b4today"), "b4today form entry should still exist");
ok(!downloadExists(5555554), "'Today' download should now be deleted");
ok(downloadExists(5555550), "Year old download should still be present");
// Choose everything
Sanitizer.prefs.setIntPref("timeSpan", 0);
s.sanitize();
ok(!bhist.isVisited(makeURI("http://before-today.com")), "Pretend visit to before-today.com should now be deleted");
ok(!formhist.nameExists("b4today"), "b4today form entry should be deleted");
ok(!downloadExists(5555550), "Year old download should now be deleted");
}
@ -595,3 +602,7 @@ function downloadExists(aID)
stmt.finalize();
return rows;
}
function isToday(aDate) {
return aDate.getDate() == new Date().getDate();
}

Просмотреть файл

@ -303,14 +303,12 @@
<method name="onDrop">
<parameter name="aEvent"/>
<body><![CDATA[
aEvent.stopPropagation();
var url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
let url = browserDragAndDrop.drop(aEvent, { })
// The URL bar automatically handles inputs with newline characters,
// so we can get away with treating text/x-moz-url flavours as text/plain.
if (url) {
nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
aEvent.preventDefault();
this.value = url;
SetPageProxyState("invalid");
try {

Просмотреть файл

@ -50,6 +50,7 @@ const Cu = Components.utils;
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const PREF_EM_NEW_ADDONS_LIST = "extensions.newAddons";
const PREF_PLUGINS_NOTIFYUSER = "plugins.update.notifyUser";
@ -77,14 +78,6 @@ const BrowserGlueServiceFactory = {
// Constructor
function BrowserGlue() {
XPCOMUtils.defineLazyServiceGetter(this, "_prefs",
"@mozilla.org/preferences-service;1",
"nsIPrefBranch");
XPCOMUtils.defineLazyServiceGetter(this, "_bundleService",
"@mozilla.org/intl/stringbundle;1",
"nsIStringBundleService");
XPCOMUtils.defineLazyServiceGetter(this, "_idleService",
"@mozilla.org/widget/idleservice;1",
"nsIIdleService");
@ -97,17 +90,10 @@ function BrowserGlue() {
XPCOMUtils.defineLazyGetter(this, "_sanitizer",
function() {
let sanitizerScope = {};
Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader).
loadSubScript("chrome://browser/content/sanitize.js", sanitizerScope);
Services.scriptloader.loadSubScript("chrome://browser/content/sanitize.js", sanitizerScope);
return sanitizerScope.Sanitizer;
});
// The observer service is immediately used in _init(), so there's no reason
// to have a getter.
this._observerService = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
this._init();
}
@ -128,12 +114,12 @@ BrowserGlue.prototype = {
if (!this._saveSession && !aForce)
return;
this._prefs.setBoolPref("browser.sessionstore.resume_session_once", true);
Services.prefs.setBoolPref("browser.sessionstore.resume_session_once", true);
// This method can be called via [NSApplication terminate:] on Mac, which
// ends up causing prefs not to be flushed to disk, so we need to do that
// explicitly here. See bug 497652.
this._prefs.QueryInterface(Ci.nsIPrefService).savePrefFile(null);
Services.prefs.savePrefFile(null);
},
// nsIObserver implementation
@ -153,10 +139,8 @@ BrowserGlue.prototype = {
break;
case "browser:purge-session-history":
// reset the console service's error buffer
const cs = Cc["@mozilla.org/consoleservice;1"].
getService(Ci.nsIConsoleService);
cs.logStringMessage(null); // clear the console (in case it's open)
cs.reset();
Services.console.logStringMessage(null); // clear the console (in case it's open)
Services.console.reset();
break;
case "quit-application-requested":
this._onQuitRequest(subject, data);
@ -184,10 +168,10 @@ BrowserGlue.prototype = {
break;
case "places-init-complete":
this._initPlaces();
this._observerService.removeObserver(this, "places-init-complete");
Services.obs.removeObserver(this, "places-init-complete");
this._isPlacesInitObserver = false;
// no longer needed, since history was initialized completely.
this._observerService.removeObserver(this, "places-database-locked");
Services.obs.removeObserver(this, "places-database-locked");
this._isPlacesLockedObserver = false;
// Now apply distribution customized bookmarks.
@ -198,7 +182,7 @@ BrowserGlue.prototype = {
this._isPlacesDatabaseLocked = true;
// Stop observing, so further attempts to load history service
// will not show the prompt.
this._observerService.removeObserver(this, "places-database-locked");
Services.obs.removeObserver(this, "places-database-locked");
this._isPlacesLockedObserver = false;
break;
case "idle":
@ -206,21 +190,20 @@ BrowserGlue.prototype = {
this._backupBookmarks();
break;
case "distribution-customization-complete":
this._observerService
.removeObserver(this, "distribution-customization-complete");
Services.obs.removeObserver(this, "distribution-customization-complete");
// Customization has finished, we don't need the customizer anymore.
delete this._distributionCustomizer;
break;
case "bookmarks-restore-success":
case "bookmarks-restore-failed":
this._observerService.removeObserver(this, "bookmarks-restore-success");
this._observerService.removeObserver(this, "bookmarks-restore-failed");
Services.obs.removeObserver(this, "bookmarks-restore-success");
Services.obs.removeObserver(this, "bookmarks-restore-failed");
if (topic == "bookmarks-restore-success" && data == "html-initial")
this.ensurePlacesDefaultQueriesInitialized();
break;
case "browser-glue-test": // used by tests
if (data == "post-update-notification") {
if (this._prefs.prefHasUserValue("app.update.postupdate"))
if (Services.prefs.prefHasUserValue("app.update.postupdate"))
this._showUpdateNotification();
break;
}
@ -231,48 +214,46 @@ BrowserGlue.prototype = {
// initialization (called on application startup)
_init: function BG__init() {
// observer registration
const osvr = this._observerService;
osvr.addObserver(this, "xpcom-shutdown", false);
osvr.addObserver(this, "prefservice:after-app-defaults", false);
osvr.addObserver(this, "final-ui-startup", false);
osvr.addObserver(this, "sessionstore-windows-restored", false);
osvr.addObserver(this, "browser:purge-session-history", false);
osvr.addObserver(this, "quit-application-requested", false);
osvr.addObserver(this, "quit-application-granted", false);
Services.obs.addObserver(this, "xpcom-shutdown", false);
Services.obs.addObserver(this, "prefservice:after-app-defaults", false);
Services.obs.addObserver(this, "final-ui-startup", false);
Services.obs.addObserver(this, "sessionstore-windows-restored", false);
Services.obs.addObserver(this, "browser:purge-session-history", false);
Services.obs.addObserver(this, "quit-application-requested", false);
Services.obs.addObserver(this, "quit-application-granted", false);
#ifdef OBSERVE_LASTWINDOW_CLOSE_TOPICS
osvr.addObserver(this, "browser-lastwindow-close-requested", false);
osvr.addObserver(this, "browser-lastwindow-close-granted", false);
Services.obs.addObserver(this, "browser-lastwindow-close-requested", false);
Services.obs.addObserver(this, "browser-lastwindow-close-granted", false);
#endif
osvr.addObserver(this, "session-save", false);
osvr.addObserver(this, "places-init-complete", false);
Services.obs.addObserver(this, "session-save", false);
Services.obs.addObserver(this, "places-init-complete", false);
this._isPlacesInitObserver = true;
osvr.addObserver(this, "places-database-locked", false);
Services.obs.addObserver(this, "places-database-locked", false);
this._isPlacesLockedObserver = true;
osvr.addObserver(this, "distribution-customization-complete", false);
Services.obs.addObserver(this, "distribution-customization-complete", false);
},
// cleanup (called on application shutdown)
_dispose: function BG__dispose() {
// observer removal
const osvr = this._observerService;
osvr.removeObserver(this, "xpcom-shutdown");
osvr.removeObserver(this, "prefservice:after-app-defaults");
osvr.removeObserver(this, "final-ui-startup");
osvr.removeObserver(this, "sessionstore-windows-restored");
osvr.removeObserver(this, "browser:purge-session-history");
osvr.removeObserver(this, "quit-application-requested");
osvr.removeObserver(this, "quit-application-granted");
// observer removal
Services.obs.removeObserver(this, "xpcom-shutdown");
Services.obs.removeObserver(this, "prefservice:after-app-defaults");
Services.obs.removeObserver(this, "final-ui-startup");
Services.obs.removeObserver(this, "sessionstore-windows-restored");
Services.obs.removeObserver(this, "browser:purge-session-history");
Services.obs.removeObserver(this, "quit-application-requested");
Services.obs.removeObserver(this, "quit-application-granted");
#ifdef OBSERVE_LASTWINDOW_CLOSE_TOPICS
osvr.removeObserver(this, "browser-lastwindow-close-requested");
osvr.removeObserver(this, "browser-lastwindow-close-granted");
Services.obs.removeObserver(this, "browser-lastwindow-close-requested");
Services.obs.removeObserver(this, "browser-lastwindow-close-granted");
#endif
osvr.removeObserver(this, "session-save");
Services.obs.removeObserver(this, "session-save");
if (this._isIdleObserver)
this._idleService.removeIdleObserver(this, BOOKMARKS_BACKUP_IDLE_TIME);
if (this._isPlacesInitObserver)
osvr.removeObserver(this, "places-init-complete");
Services.obs.removeObserver(this, "places-init-complete");
if (this._isPlacesLockedObserver)
osvr.removeObserver(this, "places-database-locked");
Services.obs.removeObserver(this, "places-database-locked");
},
_onAppDefaults: function BG__onAppDefaults() {
@ -285,13 +266,9 @@ BrowserGlue.prototype = {
_onProfileStartup: function BG__onProfileStartup() {
this._sanitizer.onStartup();
// check if we're in safe mode
var app = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo).
QueryInterface(Ci.nsIXULRuntime);
if (app.inSafeMode) {
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
ww.openWindow(null, "chrome://browser/content/safeMode.xul",
"_blank", "chrome,centerscreen,modal,resizable=no", null);
if (Services.appinfo.inSafeMode) {
Services.ww.openWindow(null, "chrome://browser/content/safeMode.xul",
"_blank", "chrome,centerscreen,modal,resizable=no", null);
}
// apply distribution customizations
@ -301,24 +278,20 @@ BrowserGlue.prototype = {
// handle any UI migration
this._migrateUI();
var ioService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService2);
// if ioService is managing the offline status, then ioservice.offline
// is already set correctly. We will continue to allow the ioService
// to manage its offline state until the user uses the "Work Offline" UI.
if (!ioService.manageOfflineStatus) {
if (!Services.io.manageOfflineStatus) {
// set the initial state
try {
ioService.offline = this._prefs.getBoolPref("browser.offline");
Services.io.offline = Services.prefs.getBoolPref("browser.offline");
}
catch (e) {
ioService.offline = false;
Services.io.offline = false;
}
}
this._observerService
.notifyObservers(null, "browser-ui-startup-complete", "");
Services.obs.notifyObservers(null, "browser-ui-startup-complete", "");
},
// profile shutdown handler (contains profile cleanup routines)
@ -348,11 +321,11 @@ BrowserGlue.prototype = {
this._showRightsNotification();
// Show update notification, if needed.
if (this._prefs.prefHasUserValue("app.update.postupdate"))
if (Services.prefs.prefHasUserValue("app.update.postupdate"))
this._showUpdateNotification();
// If new add-ons were installed during startup open the add-ons manager.
if (this._prefs.prefHasUserValue(PREF_EM_NEW_ADDONS_LIST)) {
if (Services.prefs.prefHasUserValue(PREF_EM_NEW_ADDONS_LIST)) {
var args = Cc["@mozilla.org/supports-array;1"].
createInstance(Ci.nsISupportsArray);
var str = Cc["@mozilla.org/supports-string;1"].
@ -361,14 +334,12 @@ BrowserGlue.prototype = {
args.AppendElement(str);
var str = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
str.data = this._prefs.getCharPref(PREF_EM_NEW_ADDONS_LIST);
str.data = Services.prefs.getCharPref(PREF_EM_NEW_ADDONS_LIST);
args.AppendElement(str);
const EMURL = "chrome://mozapps/content/extensions/extensions.xul";
const EMFEATURES = "chrome,menubar,extra-chrome,toolbar,dialog=no,resizable";
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
ww.openWindow(null, EMURL, "_blank", EMFEATURES, args);
this._prefs.clearUserPref(PREF_EM_NEW_ADDONS_LIST);
Services.ww.openWindow(null, EMURL, "_blank", EMFEATURES, args);
Services.prefs.clearUserPref(PREF_EM_NEW_ADDONS_LIST);
}
// Load the "more info" page for a locked places.sqlite
@ -382,7 +353,7 @@ BrowserGlue.prototype = {
// If there are plugins installed that are outdated, and the user hasn't
// been warned about them yet, open the plugins update page.
if (this._prefs.getBoolPref(PREF_PLUGINS_NOTIFYUSER))
if (Services.prefs.getBoolPref(PREF_PLUGINS_NOTIFYUSER))
this._showPluginUpdatePage();
#ifdef XP_WIN
@ -404,12 +375,9 @@ BrowserGlue.prototype = {
if ((aCancelQuit instanceof Ci.nsISupportsPRBool) && aCancelQuit.data)
return;
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
var windowcount = 0;
var pagecount = 0;
var browserEnum = wm.getEnumerator("navigator:browser");
var browserEnum = Services.wm.getEnumerator("navigator:browser");
while (browserEnum.hasMoreElements()) {
windowcount++;
@ -432,14 +400,14 @@ BrowserGlue.prototype = {
// browser.warnOnRestart specifically covers app-initiated restarts where we restart the app
// browser.tabs.warnOnClose is the global "warn when closing multiple tabs" pref
var sessionWillBeSaved = this._prefs.getIntPref("browser.startup.page") == 3 ||
this._prefs.getBoolPref("browser.sessionstore.resume_session_once");
if (sessionWillBeSaved || !this._prefs.getBoolPref("browser.warnOnQuit"))
var sessionWillBeSaved = Services.prefs.getIntPref("browser.startup.page") == 3 ||
Services.prefs.getBoolPref("browser.sessionstore.resume_session_once");
if (sessionWillBeSaved || !Services.prefs.getBoolPref("browser.warnOnQuit"))
showPrompt = false;
else if (aQuitType == "restart")
showPrompt = this._prefs.getBoolPref("browser.warnOnRestart");
showPrompt = Services.prefs.getBoolPref("browser.warnOnRestart");
else
showPrompt = this._prefs.getBoolPref("browser.tabs.warnOnClose");
showPrompt = Services.prefs.getBoolPref("browser.tabs.warnOnClose");
} catch (ex) {}
// Never show a prompt inside the private browsing mode
@ -449,8 +417,8 @@ BrowserGlue.prototype = {
if (!showPrompt || inPrivateBrowsing)
return false;
var quitBundle = this._bundleService.createBundle("chrome://browser/locale/quitDialog.properties");
var brandBundle = this._bundleService.createBundle("chrome://branding/locale/brand.properties");
var quitBundle = Services.strings.createBundle("chrome://browser/locale/quitDialog.properties");
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
var appName = brandBundle.GetStringFromName("brandShortName");
var quitDialogTitle = quitBundle.formatStringFromName(aQuitType + "DialogTitle",
@ -467,8 +435,7 @@ BrowserGlue.prototype = {
message = quitBundle.formatStringFromName("message",
[appName], 1);
var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService);
var promptService = Services.prompt;
var flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0 +
promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_1 +
@ -487,7 +454,7 @@ BrowserGlue.prototype = {
button2Title = quitBundle.GetStringFromName("quitTitle");
}
var mostRecentBrowserWindow = wm.getMostRecentWindow("navigator:browser");
var mostRecentBrowserWindow = Services.wm.getMostRecentWindow("navigator:browser");
var buttonChoice =
promptService.confirmEx(mostRecentBrowserWindow, quitDialogTitle, message,
flags, button0Title, button1Title, button2Title,
@ -496,7 +463,7 @@ BrowserGlue.prototype = {
switch (buttonChoice) {
case 2: // Quit
if (neverAsk.value)
this._prefs.setBoolPref("browser.tabs.warnOnClose", false);
Services.prefs.setBoolPref("browser.tabs.warnOnClose", false);
break;
case 1: // Cancel
aCancelQuit.QueryInterface(Ci.nsISupportsPRBool);
@ -506,10 +473,10 @@ BrowserGlue.prototype = {
this._saveSession = true;
if (neverAsk.value) {
if (aQuitType == "restart")
this._prefs.setBoolPref("browser.warnOnRestart", false);
Services.prefs.setBoolPref("browser.warnOnRestart", false);
else {
// always save state when shutting down
this._prefs.setIntPref("browser.startup.page", 3);
Services.prefs.setIntPref("browser.startup.page", 3);
}
}
break;
@ -528,11 +495,11 @@ BrowserGlue.prototype = {
// Look for an unconditional override pref. If set, do what it says.
// (true --> never show, false --> always show)
try {
return !this._prefs.getBoolPref("browser.rights.override");
return !Services.prefs.getBoolPref("browser.rights.override");
} catch (e) { }
// Ditto, for the legacy EULA pref.
try {
return !this._prefs.getBoolPref("browser.EULA.override");
return !Services.prefs.getBoolPref("browser.EULA.override");
} catch (e) { }
#ifndef OFFICIAL_BUILD
@ -541,15 +508,15 @@ BrowserGlue.prototype = {
#endif
// Look to see if the user has seen the current version or not.
var currentVersion = this._prefs.getIntPref("browser.rights.version");
var currentVersion = Services.prefs.getIntPref("browser.rights.version");
try {
return !this._prefs.getBoolPref("browser.rights." + currentVersion + ".shown");
return !Services.prefs.getBoolPref("browser.rights." + currentVersion + ".shown");
} catch (e) { }
// Legacy: If the user accepted a EULA, we won't annoy them with the
// equivalent about:rights page until the version changes.
try {
return !this._prefs.getBoolPref("browser.EULA." + currentVersion + ".accepted");
return !Services.prefs.getBoolPref("browser.EULA." + currentVersion + ".accepted");
} catch (e) { }
// We haven't shown the notification before, so do so now.
@ -562,8 +529,8 @@ BrowserGlue.prototype = {
var browser = win.gBrowser; // for closure in notification bar callback
var notifyBox = browser.getNotificationBox();
var brandBundle = this._bundleService.createBundle("chrome://branding/locale/brand.properties");
var rightsBundle = this._bundleService.createBundle("chrome://global/locale/aboutRights.properties");
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
var rightsBundle = Services.strings.createBundle("chrome://global/locale/aboutRights.properties");
var buttonLabel = rightsBundle.GetStringFromName("buttonLabel");
var buttonAccessKey = rightsBundle.GetStringFromName("buttonAccessKey");
@ -582,15 +549,15 @@ BrowserGlue.prototype = {
];
// Set pref to indicate we've shown the notification.
var currentVersion = this._prefs.getIntPref("browser.rights.version");
this._prefs.setBoolPref("browser.rights." + currentVersion + ".shown", true);
var currentVersion = Services.prefs.getIntPref("browser.rights.version");
Services.prefs.setBoolPref("browser.rights." + currentVersion + ".shown", true);
var box = notifyBox.appendNotification(notifyRightsText, "about-rights", null, notifyBox.PRIORITY_INFO_LOW, buttons);
box.persistence = 3; // arbitrary number, just so bar sticks around for a bit
},
_showUpdateNotification: function BG__showUpdateNotification() {
this._prefs.clearUserPref("app.update.postupdate");
Services.prefs.clearUserPref("app.update.postupdate");
var um = Cc["@mozilla.org/updates/update-manager;1"].
getService(Ci.nsIUpdateManager);
@ -610,10 +577,8 @@ BrowserGlue.prototype = {
var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
getService(Ci.nsIURLFormatter);
var browserBundle = this._bundleService.
createBundle("chrome://browser/locale/browser.properties");
var brandBundle = this._bundleService.
createBundle("chrome://branding/locale/brand.properties");
var browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
var appName = brandBundle.GetStringFromName("brandShortName");
function getNotifyString(aPropData) {
@ -706,7 +671,7 @@ BrowserGlue.prototype = {
},
_showPluginUpdatePage: function BG__showPluginUpdatePage() {
this._prefs.setBoolPref(PREF_PLUGINS_NOTIFYUSER, false);
Services.prefs.setBoolPref(PREF_PLUGINS_NOTIFYUSER, false);
var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
getService(Ci.nsIURLFormatter);
@ -766,7 +731,7 @@ BrowserGlue.prototype = {
var importBookmarksHTML = false;
try {
importBookmarksHTML =
this._prefs.getBoolPref("browser.places.importBookmarksHTML");
Services.prefs.getBoolPref("browser.places.importBookmarksHTML");
if (importBookmarksHTML)
importBookmarks = true;
} catch(ex) {}
@ -776,7 +741,7 @@ BrowserGlue.prototype = {
var restoreDefaultBookmarks = false;
try {
restoreDefaultBookmarks =
this._prefs.getBoolPref("browser.bookmarks.restore_default_bookmarks");
Services.prefs.getBoolPref("browser.bookmarks.restore_default_bookmarks");
if (restoreDefaultBookmarks) {
// Ensure that we already have a bookmarks backup for today.
this._backupBookmarks();
@ -826,14 +791,14 @@ BrowserGlue.prototype = {
// smart bookmarks are disabled.
var autoExportHTML = false;
try {
autoExportHTML = this._prefs.getBoolPref("browser.bookmarks.autoExportHTML");
autoExportHTML = Services.prefs.getBoolPref("browser.bookmarks.autoExportHTML");
} catch(ex) {}
var smartBookmarksVersion = 0;
try {
smartBookmarksVersion = this._prefs.getIntPref("browser.places.smartBookmarksVersion");
smartBookmarksVersion = Services.prefs.getIntPref("browser.places.smartBookmarksVersion");
} catch(ex) {}
if (!autoExportHTML && smartBookmarksVersion != -1)
this._prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
// Get bookmarks.html file location
var dirService = Cc["@mozilla.org/file/directory_service;1"].
@ -851,8 +816,8 @@ BrowserGlue.prototype = {
if (bookmarksFile.exists()) {
// Add an import observer. It will ensure that smart bookmarks are
// created once the operation is complete.
this._observerService.addObserver(this, "bookmarks-restore-success", false);
this._observerService.addObserver(this, "bookmarks-restore-failed", false);
Services.obs.addObserver(this, "bookmarks-restore-success", false);
Services.obs.addObserver(this, "bookmarks-restore-failed", false);
// Import from bookmarks.html file.
try {
@ -862,8 +827,8 @@ BrowserGlue.prototype = {
} catch (err) {
// Report the error, but ignore it.
Cu.reportError("Bookmarks.html file could be corrupt. " + err);
this._observerService.removeObserver(this, "bookmarks-restore-success");
this._observerService.removeObserver(this, "bookmarks-restore-failed");
Services.obs.removeObserver(this, "bookmarks-restore-success");
Services.obs.removeObserver(this, "bookmarks-restore-failed");
}
}
else
@ -871,10 +836,10 @@ BrowserGlue.prototype = {
// Reset preferences, so we won't try to import again at next run
if (importBookmarksHTML)
this._prefs.setBoolPref("browser.places.importBookmarksHTML", false);
Services.prefs.setBoolPref("browser.places.importBookmarksHTML", false);
if (restoreDefaultBookmarks)
this._prefs.setBoolPref("browser.bookmarks.restore_default_bookmarks",
false);
Services.prefs.setBoolPref("browser.bookmarks.restore_default_bookmarks",
false);
}
// Initialize bookmark archiving on idle.
@ -900,7 +865,7 @@ BrowserGlue.prototype = {
// on the legacy format.
var autoExportHTML = false;
try {
autoExportHTML = this._prefs.getBoolPref("browser.bookmarks.autoExportHTML");
autoExportHTML = Services.prefs.getBoolPref("browser.bookmarks.autoExportHTML");
} catch(ex) { /* Don't export */ }
if (autoExportHTML) {
@ -924,7 +889,7 @@ BrowserGlue.prototype = {
new Date() - PlacesUtils.backups.getDateForFile(lastBackupFile) > BOOKMARKS_BACKUP_INTERVAL) {
let maxBackups = BOOKMARKS_BACKUP_MAX_BACKUPS;
try {
maxBackups = this._prefs.getIntPref("browser.bookmarks.max_backups");
maxBackups = Services.prefs.getIntPref("browser.bookmarks.max_backups");
}
catch(ex) { /* Use default. */ }
@ -936,9 +901,9 @@ BrowserGlue.prototype = {
* Show the notificationBox for a locked places database.
*/
_showPlacesLockedNotificationBox: function BG__showPlacesLockedNotificationBox() {
var brandBundle = this._bundleService.createBundle("chrome://branding/locale/brand.properties");
var brandBundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
var applicationName = brandBundle.GetStringFromName("brandShortName");
var placesBundle = this._bundleService.createBundle("chrome://browser/locale/places/places.properties");
var placesBundle = Services.strings.createBundle("chrome://browser/locale/places/places.properties");
var title = placesBundle.GetStringFromName("lockPrompt.title");
var text = placesBundle.formatStringFromName("lockPrompt.text", [applicationName], 1);
var buttonText = placesBundle.GetStringFromName("lockPromptInfoButton.label");
@ -973,7 +938,7 @@ BrowserGlue.prototype = {
_migrateUI: function BG__migrateUI() {
var migration = 0;
try {
migration = this._prefs.getIntPref("browser.migration.version");
migration = Services.prefs.getIntPref("browser.migration.version");
} catch(ex) {}
if (migration == 0) {
@ -1017,7 +982,7 @@ BrowserGlue.prototype = {
this._dataSource = null;
// update the migration version
this._prefs.setIntPref("browser.migration.version", 1);
Services.prefs.setIntPref("browser.migration.version", 1);
}
},
@ -1072,7 +1037,7 @@ BrowserGlue.prototype = {
// By default, if the pref is not set up, we must create Smart Bookmarks
var smartBookmarksCurrentVersion = 0;
try {
smartBookmarksCurrentVersion = this._prefs.getIntPref(SMART_BOOKMARKS_PREF);
smartBookmarksCurrentVersion = Services.prefs.getIntPref(SMART_BOOKMARKS_PREF);
} catch(ex) { /* no version set, new profile */ }
// bail out if we don't have to create or update Smart Bookmarks
@ -1087,9 +1052,7 @@ BrowserGlue.prototype = {
var callback = {
_uri: function BG_EPDQI__uri(aSpec) {
return Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService).
newURI(aSpec, null, null);
return Services.io.newURI(aSpec, null, null);
},
runBatched: function BG_EPDQI_runBatched() {
@ -1097,9 +1060,7 @@ BrowserGlue.prototype = {
var bookmarksMenuIndex = 0;
var bookmarksToolbarIndex = 0;
var placesBundle = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
createBundle("chrome://browser/locale/places/places.properties");
var placesBundle = Services.strings.createBundle("chrome://browser/locale/places/places.properties");
// MOST VISITED
var smart = {queryId: "MostVisited", // don't change this
@ -1207,8 +1168,8 @@ BrowserGlue.prototype = {
Components.utils.reportError(ex);
}
finally {
this._prefs.setIntPref(SMART_BOOKMARKS_PREF, SMART_BOOKMARKS_VERSION);
this._prefs.QueryInterface(Ci.nsIPrefService).savePrefFile(null);
Services.prefs.setIntPref(SMART_BOOKMARKS_PREF, SMART_BOOKMARKS_VERSION);
Services.prefs.savePrefFile(null);
}
},
@ -1218,21 +1179,18 @@ BrowserGlue.prototype = {
// this returns the most recent non-popup browser window
getMostRecentBrowserWindow: function BG_getMostRecentBrowserWindow() {
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
function isFullBrowserWindow(win) {
return !win.closed &&
!win.document.documentElement.getAttribute("chromehidden");
}
#ifdef BROKEN_WM_Z_ORDER
var win = wm.getMostRecentWindow("navigator:browser");
var win = Services.wm.getMostRecentWindow("navigator:browser");
// if we're lucky, this isn't a popup, and we can just return this
if (win && !isFullBrowserWindow(win)) {
win = null;
let windowList = wm.getEnumerator("navigator:browser");
let windowList = Services.wm.getEnumerator("navigator:browser");
// this is oldest to newest, so this gets a bit ugly
while (windowList.hasMoreElements()) {
let nextWin = windowList.getNext();
@ -1242,7 +1200,7 @@ BrowserGlue.prototype = {
}
return win;
#else
var windowList = wm.getZOrderDOMWindowEnumerator("navigator:browser", true);
var windowList = Services.wm.getZOrderDOMWindowEnumerator("navigator:browser", true);
while (windowList.hasMoreElements()) {
let win = windowList.getNext();
if (isFullBrowserWindow(win))
@ -1282,9 +1240,7 @@ GeolocationPrompt.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIGeolocationPrompt]),
prompt: function GP_prompt(request) {
var pm = Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager);
var result = pm.testExactPermission(request.requestingURI, "geo");
var result = Services.perms.testExactPermission(request.requestingURI, "geo");
if (result == Ci.nsIPermissionManager.ALLOW_ACTION) {
request.allow();
@ -1298,9 +1254,9 @@ GeolocationPrompt.prototype = {
function setPagePermission(uri, allow) {
if (allow == true)
pm.add(uri, "geo", Ci.nsIPermissionManager.ALLOW_ACTION);
Services.perms.add(uri, "geo", Ci.nsIPermissionManager.ALLOW_ACTION);
else
pm.add(uri, "geo", Ci.nsIPermissionManager.DENY_ACTION);
Services.perms.add(uri, "geo", Ci.nsIPermissionManager.DENY_ACTION);
}
function getChromeWindow(aWindow) {
@ -1323,8 +1279,7 @@ GeolocationPrompt.prototype = {
var notification = notificationBox.getNotificationWithValue("geolocation");
if (!notification) {
var bundleService = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
var browserBundle = bundleService.createBundle("chrome://browser/locale/browser.properties");
var browserBundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
var buttons = [{
label: browserBundle.GetStringFromName("geolocation.shareLocation"),

Просмотреть файл

@ -279,7 +279,7 @@ var BookmarkPropertiesPanel = {
// Load In Sidebar
this._loadInSidebar = PlacesUtils.annotations
.itemHasAnnotation(this._itemId,
LOAD_IN_SIDEBAR_ANNO);
PlacesUIUtils.LOAD_IN_SIDEBAR_ANNO);
break;
case "folder":
@ -295,10 +295,10 @@ var BookmarkPropertiesPanel = {
// Description
if (PlacesUtils.annotations
.itemHasAnnotation(this._itemId, DESCRIPTION_ANNO)) {
.itemHasAnnotation(this._itemId, PlacesUIUtils.DESCRIPTION_ANNO)) {
this._description = PlacesUtils.annotations
.getItemAnnotation(this._itemId,
DESCRIPTION_ANNO);
PlacesUIUtils.DESCRIPTION_ANNO);
}
}
},

Просмотреть файл

@ -114,6 +114,9 @@ InsertionPoint.prototype = {
function PlacesController(aView) {
this._view = aView;
XPCOMUtils.defineLazyServiceGetter(this, "clipboard",
"@mozilla.org/widget/clipboard;1",
"nsIClipboard");
}
PlacesController.prototype = {
@ -170,7 +173,7 @@ PlacesController.prototype = {
return this._canInsert();
case "placesCmd_new:separator":
return this._canInsert() &&
!asQuery(this._view.getResultNode()).queryOptions.excludeItems &&
!PlacesUtils.asQuery(this._view.getResultNode()).queryOptions.excludeItems &&
this._view.getResult().sortingMode ==
Ci.nsINavHistoryQueryOptions.SORT_BY_NONE;
case "placesCmd_show:info":
@ -183,7 +186,7 @@ PlacesController.prototype = {
case "placesCmd_reloadMicrosummary":
var selectedNode = this._view.selectedNode;
return selectedNode && PlacesUtils.nodeIsBookmark(selectedNode) &&
PlacesUIUtils.microsummaries.hasMicrosummary(selectedNode.itemId);
PlacesUtils.microsummaries.hasMicrosummary(selectedNode.itemId);
case "placesCmd_reload":
// Livemark containers
var selectedNode = this._view.selectedNode;
@ -389,7 +392,7 @@ PlacesController.prototype = {
// pasteable, with no need to unwrap all the nodes.
var flavors = PlacesControllerDragHelper.placesFlavors;
var clipboard = PlacesUIUtils.clipboard;
var clipboard = this.clipboard;
var hasPlacesData =
clipboard.hasDataMatchingFlavors(flavors, flavors.length,
Ci.nsIClipboard.kGlobalClipboard);
@ -465,7 +468,7 @@ PlacesController.prototype = {
case Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY:
nodeData["query"] = true;
if (node.parent) {
switch (asQuery(node.parent).queryOptions.resultType) {
switch (PlacesUtils.asQuery(node.parent).queryOptions.resultType) {
case Ci.nsINavHistoryQueryOptions.RESULTS_AS_SITE_QUERY:
nodeData["host"] = true;
break;
@ -494,7 +497,7 @@ PlacesController.prototype = {
if (PlacesUtils.nodeIsBookmark(node)) {
nodeData["bookmark"] = true;
PlacesUtils.nodeIsTagQuery(node.parent)
var mss = PlacesUIUtils.microsummaries;
var mss = PlacesUtils.microsummaries;
if (mss.hasMicrosummary(node.itemId))
nodeData["microsummary"] = true;
@ -732,7 +735,7 @@ PlacesController.prototype = {
*/
reloadSelectedMicrosummary: function PC_reloadSelectedMicrosummary() {
var selectedNode = this._view.selectedNode;
var mss = PlacesUIUtils.microsummaries;
var mss = PlacesUtils.microsummaries;
if (mss.hasMicrosummary(selectedNode.itemId))
mss.refreshMicrosummary(selectedNode.itemId);
},
@ -940,7 +943,7 @@ PlacesController.prototype = {
}
else if (PlacesUtils.nodeIsTagQuery(node) && node.parent &&
PlacesUtils.nodeIsQuery(node.parent) &&
asQuery(node.parent).queryOptions.resultType ==
PlacesUtils.asQuery(node.parent).queryOptions.resultType ==
Ci.nsINavHistoryQueryOptions.RESULTS_AS_TAG_QUERY) {
// This is a tag container.
// Untag all URIs tagged with this tag only if the tag container is
@ -953,7 +956,7 @@ PlacesController.prototype = {
}
else if (PlacesUtils.nodeIsURI(node) &&
PlacesUtils.nodeIsQuery(node.parent) &&
asQuery(node.parent).queryOptions.queryType ==
PlacesUtils.asQuery(node.parent).queryOptions.queryType ==
Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) {
// This is a uri node inside an history query.
var bhist = PlacesUtils.history.QueryInterface(Ci.nsIBrowserHistory);
@ -962,7 +965,7 @@ PlacesController.prototype = {
}
else if (node.itemId == -1 &&
PlacesUtils.nodeIsQuery(node) &&
asQuery(node).queryOptions.queryType ==
PlacesUtils.asQuery(node).queryOptions.queryType ==
Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY) {
// This is a dynamically generated history query, like queries
// grouped by site, time or both. Dynamically generated queries don't
@ -1022,7 +1025,7 @@ PlacesController.prototype = {
}
}
else if (PlacesUtils.nodeIsQuery(node) &&
asQuery(node).queryOptions.queryType ==
PlacesUtils.asQuery(node).queryOptions.queryType ==
Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY)
this._removeHistoryContainer(node);
}
@ -1090,7 +1093,7 @@ PlacesController.prototype = {
if (PlacesUtils.nodeIsFolder(root))
this._removeRowsFromBookmarks(aTxnName);
else if (PlacesUtils.nodeIsQuery(root)) {
var queryType = asQuery(root).queryOptions.queryType;
var queryType = PlacesUtils.asQuery(root).queryOptions.queryType;
if (queryType == Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS)
this._removeRowsFromBookmarks(aTxnName);
else if (queryType == Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY)
@ -1216,7 +1219,7 @@ PlacesController.prototype = {
addData(PlacesUtils.TYPE_HTML, htmlString);
if (placeString || unicodeString || htmlString || mozURLString) {
PlacesUIUtils.clipboard.setData(xferable, null, Ci.nsIClipboard.kGlobalClipboard);
this.clipboard.setData(xferable, null, Ci.nsIClipboard.kGlobalClipboard);
}
}
finally {
@ -1260,7 +1263,7 @@ PlacesController.prototype = {
return xferable;
}
var clipboard = PlacesUIUtils.clipboard;
var clipboard = this.clipboard;
var ip = this._view.insertionPoint;
if (!ip)

Просмотреть файл

@ -174,7 +174,7 @@ var gEditItemOverlay = {
// Load In Sidebar checkbox
this._element("loadInSidebarCheckbox").checked =
PlacesUtils.annotations.itemHasAnnotation(this._itemId,
LOAD_IN_SIDEBAR_ANNO);
PlacesUIUtils.LOAD_IN_SIDEBAR_ANNO);
}
else {
if (!this._readOnly) // If readOnly wasn't forced through aInfo
@ -446,8 +446,8 @@ var gEditItemOverlay = {
if (this._itemId != -1 &&
this._itemType == Ci.nsINavBookmarksService.TYPE_BOOKMARK &&
!this._readOnly)
this._microsummaries = PlacesUIUtils.microsummaries
.getMicrosummaries(this._uri, -1);
this._microsummaries = PlacesUtils.microsummaries
.getMicrosummaries(this._uri, -1);
}
catch(ex) {
// getMicrosummaries will throw an exception in at least two cases:
@ -458,6 +458,7 @@ var gEditItemOverlay = {
// content types the service knows how to summarize).
this._microsummaries = null;
}
if (this._microsummaries) {
var enumerator = this._microsummaries.Enumerate();
@ -468,8 +469,8 @@ var gEditItemOverlay = {
var microsummary = enumerator.getNext()
.QueryInterface(Ci.nsIMicrosummary);
var menuItem = this._createMicrosummaryMenuItem(microsummary);
if (PlacesUIUtils.microsummaries
.isMicrosummary(this._itemId, microsummary))
if (PlacesUtils.microsummaries
.isMicrosummary(this._itemId, microsummary))
itemToSelect = menuItem;
menupopup.appendChild(menuItem);
@ -693,7 +694,7 @@ var gEditItemOverlay = {
var newTitle = this._element("userEnteredName").label;
if (this._getItemStaticTitle() != newTitle) {
this._mayUpdateFirstEditField("namePicker");
if (PlacesUIUtils.microsummaries.hasMicrosummary(this._itemId)) {
if (PlacesUtils.microsummaries.hasMicrosummary(this._itemId)) {
// Note: this implicitly also takes care of the microsummary->static
// title case, the removeMicorosummary method in the service will set
// the item-title to the value of this annotation.
@ -714,10 +715,10 @@ var gEditItemOverlay = {
// bookmark previously had one, or the user selected a microsummary which
// is not the one the bookmark previously had
if ((newMicrosummary == null &&
PlacesUIUtils.microsummaries.hasMicrosummary(this._itemId)) ||
PlacesUtils.microsummaries.hasMicrosummary(this._itemId)) ||
(newMicrosummary != null &&
!PlacesUIUtils.microsummaries
.isMicrosummary(this._itemId, newMicrosummary))) {
!PlacesUtils.microsummaries
.isMicrosummary(this._itemId, newMicrosummary))) {
txns.push(ptm.editBookmarkMicrosummary(this._itemId, newMicrosummary));
}
@ -1122,20 +1123,20 @@ var gEditItemOverlay = {
PlacesUtils.bookmarks
.getKeywordForBookmark(this._itemId));
break;
case DESCRIPTION_ANNO:
case PlacesUIUtils.DESCRIPTION_ANNO:
this._initTextField("descriptionField",
PlacesUIUtils.getItemDescription(this._itemId));
break;
case LOAD_IN_SIDEBAR_ANNO:
case PlacesUIUtils.LOAD_IN_SIDEBAR_ANNO:
this._element("loadInSidebarCheckbox").checked =
PlacesUtils.annotations.itemHasAnnotation(this._itemId,
LOAD_IN_SIDEBAR_ANNO);
PlacesUIUtils.LOAD_IN_SIDEBAR_ANNO);
break;
case LMANNO_FEEDURI:
case PlacesUtils.LMANNO_FEEDURI:
var feedURISpec = PlacesUtils.livemarks.getFeedURI(this._itemId).spec;
this._initTextField("feedLocationField", feedURISpec);
break;
case LMANNO_SITEURI:
case PlacesUtils.LMANNO_SITEURI:
var siteURISpec = "";
var siteURI = PlacesUtils.livemarks.getSiteURI(this._itemId);
if (siteURI)

Просмотреть файл

@ -604,7 +604,8 @@
<parameter name="aParentPopup"/>
<parameter name="aBefore"/>
<body><![CDATA[
let element = PlacesUIUtils.createMenuItemForNode(aChild);
let element = PlacesUIUtils.createMenuItemForNode(aChild,
aParentPopup.ownerDocument);
if (aBefore)
aParentPopup.insertBefore(element, aBefore);
else {
@ -981,7 +982,7 @@
// so bail out now and save a lot of work when updating commands
var resultNode = this._resultNode;
if (PlacesUtils.nodeIsQuery(resultNode) &&
asQuery(resultNode).queryOptions.queryType ==
PlacesUtils.asQuery(resultNode).queryOptions.queryType ==
Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY)
return null;

Просмотреть файл

@ -62,7 +62,7 @@ var PlacesOrganizer = {
this._places.selectItems([itemId]);
// Forcefully expand all-bookmarks
if (aQueryName == "AllBookmarks")
asContainer(this._places.selectedNode).containerOpen = true;
PlacesUtils.asContainer(this._places.selectedNode).containerOpen = true;
},
init: function PO_init() {
@ -216,7 +216,7 @@ var PlacesOrganizer = {
return;
var node = this._places.selectedNode;
var queries = asQuery(node).getQueries();
var queries = PlacesUtils.asQuery(node).getQueries();
// Items are only excluded on the left pane.
var options = node.queryOptions.clone();
@ -351,7 +351,7 @@ var PlacesOrganizer = {
* main places pane.
*/
getCurrentOptions: function PO_getCurrentOptions() {
return asQuery(this._content.getResult().root).queryOptions;
return PlacesUtils.asQuery(this._content.getResult().root).queryOptions;
},
/**
@ -359,7 +359,7 @@ var PlacesOrganizer = {
* main places pane.
*/
getCurrentQueries: function PO_getCurrentQueries() {
return asQuery(this._content.getResult().root).getQueries();
return PlacesUtils.asQuery(this._content.getResult().root).getQueries();
},
/**
@ -1324,7 +1324,7 @@ var ViewMenu = {
lastModified: { key: "LASTMODIFIED", dir: "descending" },
description: { key: "ANNOTATION",
dir: "ascending",
anno: DESCRIPTION_ANNO }
anno: PlacesUIUtils.DESCRIPTION_ANNO }
};
// Make sure we have a valid column.

Просмотреть файл

@ -51,8 +51,16 @@
src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript"
src="chrome://browser/content/utilityOverlay.js"/>
<script type="application/javascript"
src="chrome://browser/content/places/utils.js"/>
<script type="application/javascript"><![CDATA[
// TODO: Bug 406371.
// A bunch of browser code depends on us defining these, sad but true :(
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
Components.utils.import("resource://gre/modules/utils.js");
Components.utils.import("resource:///modules/PlacesUIUtils.jsm");
]]></script>
<script type="application/javascript"
src="chrome://browser/content/places/controller.js"/>
<script type="application/javascript"

Просмотреть файл

@ -250,7 +250,7 @@
var popup = document.createElement("menupopup");
popup.setAttribute("placespopup", "true");
button.appendChild(popup);
popup._resultNode = asContainer(aChild);
popup._resultNode = PlacesUtils.asContainer(aChild);
#ifndef XP_MACOSX
popup.setAttribute("context", "placesContext");
#endif
@ -809,7 +809,8 @@
<parameter name="aParentPopup"/>
<parameter name="aBefore"/>
<body><![CDATA[
var element = PlacesUIUtils.createMenuItemForNode(aChild);
var element = PlacesUIUtils.createMenuItemForNode(aChild,
aParentPopup.ownerDocument);
if (aBefore)
aParentPopup.insertBefore(element, aBefore);

Просмотреть файл

@ -98,7 +98,7 @@
<parameter name="folderRestrict"/>
<body><![CDATA[
// preserve grouping
var queryNode = asQuery(this.getResultNode());
var queryNode = PlacesUtils.asQuery(this.getResultNode());
var options = queryNode.queryOptions.clone();
// Make sure we're getting uri results.
@ -214,7 +214,7 @@
if (childURI == placeURI)
return child;
else if (PlacesUtils.nodeIsContainer(child)) {
var nested = findNode(asContainer(child), placeURI, nodesURIChecked);
var nested = findNode(PlacesUtils.asContainer(child), placeURI, nodesURIChecked);
if (nested)
return nested;
}
@ -442,7 +442,7 @@
// so bail out now and save a lot of work when updating commands
var resultNode = this.getResultNode();
if (PlacesUtils.nodeIsQuery(resultNode) &&
asQuery(resultNode).queryOptions.queryType ==
PlacesUtils.asQuery(resultNode).queryOptions.queryType ==
Ci.nsINavHistoryQueryOptions.QUERY_TYPE_HISTORY)
return this._cachedInsertionPoint = null;
@ -535,7 +535,7 @@
if (PlacesControllerDragHelper.disallowInsertion(container))
return null;
var queryOptions = asQuery(result.root).queryOptions;
var queryOptions = PlacesUtils.asQuery(result.root).queryOptions;
if (queryOptions.sortingMode !=
Ci.nsINavHistoryQueryOptions.SORT_BY_NONE) {
// If we are within a sorted view, insert at the end
@ -618,7 +618,7 @@
var index = ids.indexOf(node.itemId);
if (index == -1 &&
node.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER_SHORTCUT)
index = ids.indexOf(asQuery(node).folderItemId);
index = ids.indexOf(PlacesUtils.asQuery(node).folderItemId);
if (index != -1) {
nodes.push(node);
@ -630,7 +630,7 @@
nodesURIChecked.indexOf(node.uri) != -1)
return foundOne;
asContainer(node);
PlacesUtils.asContainer(node);
if (!aOpenContainers && !node.containerOpen)
return foundOne;

Просмотреть файл

@ -570,11 +570,11 @@ PlacesTreeView.prototype = {
case Ci.nsINavHistoryQueryOptions.SORT_BY_KEYWORD_DESCENDING:
return [this.COLUMN_TYPE_KEYWORD, true];
case Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_ASCENDING:
if (this._result.sortingAnnotation == DESCRIPTION_ANNO)
if (this._result.sortingAnnotation == PlacesUIUtils.DESCRIPTION_ANNO)
return [this.COLUMN_TYPE_DESCRIPTION, false];
break;
case Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_DESCENDING:
if (this._result.sortingAnnotation == DESCRIPTION_ANNO)
if (this._result.sortingAnnotation == PlacesUIUtils.DESCRIPTION_ANNO)
return [this.COLUMN_TYPE_DESCRIPTION, true];
case Ci.nsINavHistoryQueryOptions.SORT_BY_DATEADDED_ASCENDING:
return [this.COLUMN_TYPE_DATEADDED, false];
@ -653,7 +653,7 @@ PlacesTreeView.prototype = {
this._rows.splice(row, 0, aNode);
this._tree.rowCountChanged(row, 1);
if (PlacesUtils.nodeIsContainer(aNode) && asContainer(aNode).containerOpen)
if (PlacesUtils.nodeIsContainer(aNode) && PlacesUtils.asContainer(aNode).containerOpen)
this.invalidateContainer(aNode);
},
@ -827,7 +827,7 @@ PlacesTreeView.prototype = {
},
nodeAnnotationChanged: function PTV_nodeAnnotationChanged(aNode, aAnno) {
if (aAnno == DESCRIPTION_ANNO)
if (aAnno == PlacesUIUtils.DESCRIPTION_ANNO)
this._invalidateCellValue(aNode, this.COLUMN_TYPE_DESCRIPTION);
},
@ -1124,7 +1124,7 @@ PlacesTreeView.prototype = {
if ((PlacesUtils.nodeIsQuery(parent) ||
PlacesUtils.nodeIsFolder(parent)) &&
!node.hasChildren)
return asQuery(parent).queryOptions.expandQueries;
return PlacesUtils.asQuery(parent).queryOptions.expandQueries;
}
return true;
}
@ -1210,7 +1210,7 @@ PlacesTreeView.prototype = {
if (PlacesControllerDragHelper.disallowInsertion(container))
return null;
let queryOptions = asQuery(this._result.root).queryOptions;
let queryOptions = PlacesUtils.asQuery(this._result.root).queryOptions;
if (queryOptions.sortingMode !=
Ci.nsINavHistoryQueryOptions.SORT_BY_NONE) {
// If we are within a sorted view, insert at the end.
@ -1338,7 +1338,7 @@ PlacesTreeView.prototype = {
if (node.itemId != -1) {
try {
return PlacesUtils.annotations.
getItemAnnotation(node.itemId, DESCRIPTION_ANNO);
getItemAnnotation(node.itemId, PlacesUIUtils.DESCRIPTION_ANNO);
}
catch (ex) { /* has no description */ }
}
@ -1472,17 +1472,17 @@ PlacesTreeView.prototype = {
break;
case this.COLUMN_TYPE_DESCRIPTION:
if (oldSort == NHQO.SORT_BY_ANNOTATION_ASCENDING &&
oldSortingAnnotation == DESCRIPTION_ANNO) {
oldSortingAnnotation == PlacesUIUtils.DESCRIPTION_ANNO) {
newSort = NHQO.SORT_BY_ANNOTATION_DESCENDING;
newSortingAnnotation = DESCRIPTION_ANNO;
newSortingAnnotation = PlacesUIUtils.DESCRIPTION_ANNO;
}
else if (allowTriState &&
oldSort == NHQO.SORT_BY_ANNOTATION_DESCENDING &&
oldSortingAnnotation == DESCRIPTION_ANNO)
oldSortingAnnotation == PlacesUIUtils.DESCRIPTION_ANNO)
newSort = NHQO.SORT_BY_NONE;
else {
newSort = NHQO.SORT_BY_ANNOTATION_ASCENDING;
newSortingAnnotation = DESCRIPTION_ANNO;
newSortingAnnotation = PlacesUIUtils.DESCRIPTION_ANNO;
}
break;

Просмотреть файл

@ -12,7 +12,6 @@ browser.jar:
* content/browser/places/toolbar.xml (content/toolbar.xml)
* content/browser/places/menu.xml (content/menu.xml)
* content/browser/places/tree.xml (content/tree.xml)
* content/browser/places/utils.js (content/utils.js)
* content/browser/places/controller.js (content/controller.js)
* content/browser/places/treeView.js (content/treeView.js)
# keep the Places version of the history sidebar at history/history-panel.xul

Просмотреть файл

@ -49,6 +49,10 @@ EXTRA_COMPONENTS = \
PlacesProtocolHandler.js \
$(NULL)
EXTRA_PP_JS_MODULES = \
PlacesUIUtils.jsm \
$(NULL)
include $(topsrcdir)/config/rules.mk
XPIDL_FLAGS += -I$(topsrcdir)/browser/components

Просмотреть файл

@ -40,30 +40,24 @@
*
* ***** END LICENSE BLOCK ***** */
function LOG(str) {
dump("*** " + str + "\n");
}
var EXPORTED_SYMBOLS = ["PlacesUIUtils"];
var Ci = Components.interfaces;
var Cc = Components.classes;
var Cr = Components.results;
var Cu = Components.utils;
__defineGetter__("PlacesUtils", function() {
delete this.PlacesUtils
var tmpScope = {};
Components.utils.import("resource://gre/modules/utils.js", tmpScope);
return this.PlacesUtils = tmpScope.PlacesUtils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "Services", function() {
Cu.import("resource://gre/modules/Services.jsm");
return Services;
});
const LOAD_IN_SIDEBAR_ANNO = "bookmarkProperties/loadInSidebar";
const DESCRIPTION_ANNO = "bookmarkProperties/description";
const GUID_ANNO = "placesInternal/GUID";
const LMANNO_FEEDURI = "livemark/feedURI";
const LMANNO_SITEURI = "livemark/siteURI";
const ORGANIZER_FOLDER_ANNO = "PlacesOrganizer/OrganizerFolder";
const ORGANIZER_QUERY_ANNO = "PlacesOrganizer/OrganizerQuery";
const ORGANIZER_LEFTPANE_VERSION = 6;
const EXCLUDE_FROM_BACKUP_ANNO = "places/excludeFromBackup";
XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
Cu.import("resource://gre/modules/utils.js");
return PlacesUtils;
});
#ifdef XP_MACOSX
// On Mac OSX, the transferable system converts "\r\n" to "\n\n", where we
@ -74,66 +68,15 @@ const NEWLINE= "\n";
const NEWLINE = "\r\n";
#endif
function QI_node(aNode, aIID) {
return aNode.QueryInterface(aIID);
}
function asVisit(aNode) { return QI_node(aNode, Ci.nsINavHistoryVisitResultNode); }
function asFullVisit(aNode){ return QI_node(aNode, Ci.nsINavHistoryFullVisitResultNode);}
function asContainer(aNode){ return QI_node(aNode, Ci.nsINavHistoryContainerResultNode);}
function asQuery(aNode) { return QI_node(aNode, Ci.nsINavHistoryQueryResultNode); }
var PlacesUIUtils = {
/**
* The Microsummary Service
*/
get microsummaries() {
delete this.microsummaries;
return this.microsummaries = Cc["@mozilla.org/microsummary/service;1"].
getService(Ci.nsIMicrosummaryService);
},
ORGANIZER_LEFTPANE_VERSION: 6,
ORGANIZER_FOLDER_ANNO: "PlacesOrganizer/OrganizerFolder",
ORGANIZER_QUERY_ANNO: "PlacesOrganizer/OrganizerQuery",
get RDF() {
delete this.RDF;
return this.RDF = Cc["@mozilla.org/rdf/rdf-service;1"].
getService(Ci.nsIRDFService);
},
LOAD_IN_SIDEBAR_ANNO: "bookmarkProperties/loadInSidebar",
DESCRIPTION_ANNO: "bookmarkProperties/description",
get localStore() {
delete this.localStore;
return this.localStore = this.RDF.GetDataSource("rdf:local-store");
},
get ptm() {
delete this.ptm;
return this.ptm = Cc["@mozilla.org/browser/placesTransactionsService;1"].
getService(Ci.nsIPlacesTransactionsService);
},
get clipboard() {
delete this.clipboard;
return this.clipboard = Cc["@mozilla.org/widget/clipboard;1"].
getService(Ci.nsIClipboard);
},
get URIFixup() {
delete this.URIFixup;
return this.URIFixup = Cc["@mozilla.org/docshell/urifixup;1"].
getService(Ci.nsIURIFixup);
},
get ellipsis() {
delete this.ellipsis;
var pref = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
return this.ellipsis = pref.getComplexValue("intl.ellipsis",
Ci.nsIPrefLocalizedString).data;
},
get privateBrowsing() {
delete this.privateBrowsing;
return this.privateBrowsing = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
},
TYPE_TAB_DROP: "application/x-moz-tabbrowser-tab",
/**
* Makes a URI from a spec, and do fixup
@ -141,7 +84,7 @@ var PlacesUIUtils = {
* The string spec of the URI
* @returns A URI object for the spec.
*/
createFixedURI: function PU_createFixedURI(aSpec) {
createFixedURI: function PUIU_createFixedURI(aSpec) {
return this.URIFixup.createFixupURI(aSpec, 0);
},
@ -151,30 +94,18 @@ var PlacesUIUtils = {
* The string to wrap
* @returns A nsISupportsString object containing a string.
*/
_wrapString: function PU__wrapString(aString) {
_wrapString: function PUIU__wrapString(aString) {
var s = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
s.data = aString;
return s;
},
/**
* String bundle helpers
*/
get _bundle() {
const PLACES_STRING_BUNDLE_URI =
"chrome://browser/locale/places/places.properties";
delete this._bundle;
return this._bundle = Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
createBundle(PLACES_STRING_BUNDLE_URI);
},
getFormattedString: function PU_getFormattedString(key, params) {
getFormattedString: function PUIU_getFormattedString(key, params) {
return this._bundle.formatStringFromName(key, params, params.length);
},
getString: function PU_getString(key) {
getString: function PUIU_getString(key) {
return this._bundle.GetStringFromName(key);
},
@ -209,14 +140,14 @@ var PlacesUIUtils = {
* @returns A nsITransaction object that performs the copy.
*/
_getBookmarkItemCopyTransaction:
function PU__getBookmarkItemCopyTransaction(aData, aContainer, aIndex,
function PUIU__getBookmarkItemCopyTransaction(aData, aContainer, aIndex,
aExcludeAnnotations) {
var itemURL = PlacesUtils._uri(aData.uri);
var itemTitle = aData.title;
var keyword = aData.keyword || null;
var annos = aData.annos || [];
// always exclude GUID when copying any item
var excludeAnnos = [GUID_ANNO];
var excludeAnnos = [PlacesUtils.GUID_ANNO];
if (aExcludeAnnotations)
excludeAnnos = excludeAnnos.concat(aExcludeAnnotations);
annos = annos.filter(function(aValue, aIndex, aArray) {
@ -256,8 +187,7 @@ var PlacesUIUtils = {
* @returns A nsITransaction object that will perform the copy.
*/
_getFolderCopyTransaction:
function PU__getFolderCopyTransaction(aData, aContainer, aIndex) {
var self = this;
function PUIU__getFolderCopyTransaction(aData, aContainer, aIndex) {
function getChildItemsTransactions(aChildren) {
var childItemsTransactions = [];
var cc = aChildren.length;
@ -274,18 +204,19 @@ var PlacesUIUtils = {
if (node.type == PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER) {
if (node.livemark && node.annos) // node is a livemark
txn = self._getLivemarkCopyTransaction(node, aContainer, index);
txn = PlacesUIUtils._getLivemarkCopyTransaction(node, aContainer, index);
else
txn = self._getFolderCopyTransaction(node, aContainer, index);
txn = PlacesUIUtils._getFolderCopyTransaction(node, aContainer, index);
}
else if (node.type == PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR)
txn = self.ptm.createSeparator(-1, index);
txn = PlacesUIUtils.ptm.createSeparator(-1, index);
else if (node.type == PlacesUtils.TYPE_X_MOZ_PLACE)
txn = self._getBookmarkItemCopyTransaction(node, -1, index);
txn = PlacesUIUtils._getBookmarkItemCopyTransaction(node, -1, index);
NS_ASSERT(txn, "Unexpected item under a bookmarks folder");
if (txn)
childItemsTransactions.push(txn);
else
throw("Unexpected item under a bookmarks folder");
}
return childItemsTransactions;
}
@ -314,29 +245,30 @@ var PlacesUIUtils = {
var annos = aData.annos || [];
annos = annos.filter(function(aAnno) {
// always exclude GUID when copying any item
return aAnno.name != GUID_ANNO;
return aAnno.name != PlacesUtils.GUID_ANNO;
});
return this.ptm.createFolder(aData.title, aContainer, aIndex, annos, childItems);
}
},
_getLivemarkCopyTransaction:
function PU__getLivemarkCopyTransaction(aData, aContainer, aIndex) {
NS_ASSERT(aData.livemark && aData.annos, "node is not a livemark");
function PUIU__getLivemarkCopyTransaction(aData, aContainer, aIndex) {
if (!aData.livemark || !aData.annos)
throw("node is not a livemark");
// Place is a Livemark Container
var feedURI = null;
var siteURI = null;
aData.annos = aData.annos.filter(function(aAnno) {
if (aAnno.name == LMANNO_FEEDURI) {
if (aAnno.name == PlacesUtils.LMANNO_FEEDURI) {
feedURI = PlacesUtils._uri(aAnno.value);
return false;
}
else if (aAnno.name == LMANNO_SITEURI) {
else if (aAnno.name == PlacesUtils.LMANNO_SITEURI) {
siteURI = PlacesUtils._uri(aAnno.value);
return false;
}
// always exclude GUID when copying any item
return aAnno.name != GUID_ANNO;
return aAnno.name != PlacesUtils.GUID_ANNO;
});
return this.ptm.createLivemark(feedURI, siteURI, aData.title, aContainer,
aIndex, aData.annos);
@ -358,7 +290,7 @@ var PlacesUIUtils = {
* @returns An object implementing nsITransaction that can perform
* the move/insert.
*/
makeTransaction: function PU_makeTransaction(data, type, container,
makeTransaction: function PUIU_makeTransaction(data, type, container,
index, copy) {
switch (data.type) {
case PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER:
@ -387,7 +319,7 @@ var PlacesUIUtils = {
default:
if (type == PlacesUtils.TYPE_X_MOZ_URL ||
type == PlacesUtils.TYPE_UNICODE ||
type == TAB_DROP_TYPE) {
type == this.TYPE_TAB_DROP) {
var title = (type != PlacesUtils.TYPE_UNICODE) ? data.title :
data.uri;
return this.ptm.createItem(PlacesUtils._uri(data.uri),
@ -441,7 +373,7 @@ var PlacesUIUtils = {
* - When aDefaultInsertionPoint is not set, the dialog defaults to the
* bookmarks root folder.
*/
showAddBookmarkUI: function PU_showAddBookmarkUI(aURI,
showAddBookmarkUI: function PUIU_showAddBookmarkUI(aURI,
aTitle,
aDescription,
aDefaultInsertionPoint,
@ -497,7 +429,7 @@ var PlacesUIUtils = {
* was used.
*/
showMinimalAddBookmarkUI:
function PU_showMinimalAddBookmarkUI(aURI, aTitle, aDescription,
function PUIU_showMinimalAddBookmarkUI(aURI, aTitle, aDescription,
aDefaultInsertionPoint, aShowPicker,
aLoadInSidebar, aKeyword, aPostData,
aCharSet) {
@ -540,7 +472,7 @@ var PlacesUIUtils = {
else
info.hiddenRows.push("keyword");
this._showBookmarkDialog(info, true);
return this._showBookmarkDialog(info, true);
},
/**
@ -565,7 +497,7 @@ var PlacesUIUtils = {
* - When aDefaultInsertionPoint is not set, the dialog defaults to the
* bookmarks root folder.
*/
showAddLivemarkUI: function PU_showAddLivemarkURI(aFeedURI,
showAddLivemarkUI: function PUIU_showAddLivemarkURI(aFeedURI,
aSiteURI,
aTitle,
aDescription,
@ -605,7 +537,7 @@ var PlacesUIUtils = {
* for the new live-bookmark.
*/
showMinimalAddLivemarkUI:
function PU_showMinimalAddLivemarkURI(aFeedURI, aSiteURI, aTitle,
function PUIU_showMinimalAddLivemarkURI(aFeedURI, aSiteURI, aTitle,
aDescription, aDefaultInsertionPoint,
aShowPicker) {
var info = {
@ -631,7 +563,7 @@ var PlacesUIUtils = {
if (!aShowPicker)
info.hiddenRows.push("folderPicker");
}
this._showBookmarkDialog(info, true);
return this._showBookmarkDialog(info, true);
},
/**
@ -643,16 +575,16 @@ var PlacesUIUtils = {
* to be bookmarked.
* @return true if any transaction has been performed.
*/
showMinimalAddMultiBookmarkUI: function PU_showAddMultiBookmarkUI(aURIList) {
NS_ASSERT(aURIList.length,
"showAddMultiBookmarkUI expects a list of nsIURI objects");
showMinimalAddMultiBookmarkUI: function PUIU_showAddMultiBookmarkUI(aURIList) {
if (aURIList.length == 0)
throw("showAddMultiBookmarkUI expects a list of nsIURI objects");
var info = {
action: "add",
type: "folder",
hiddenRows: ["description"],
URIList: aURIList
};
this._showBookmarkDialog(info, true);
return this._showBookmarkDialog(info, true);
},
/**
@ -666,7 +598,7 @@ var PlacesUIUtils = {
* states if properties dialog should be readonly
* @return true if any transaction has been performed.
*/
showItemProperties: function PU_showItemProperties(aItemId, aType, aReadOnly) {
showItemProperties: function PUIU_showItemProperties(aItemId, aType, aReadOnly) {
var info = {
action: "edit",
type: aType,
@ -691,7 +623,7 @@ var PlacesUIUtils = {
* @return true if any transaction has been performed.
*/
showAddFolderUI:
function PU_showAddFolderUI(aTitle, aDefaultInsertionPoint, aShowPicker) {
function PUIU_showAddFolderUI(aTitle, aDefaultInsertionPoint, aShowPicker) {
var info = {
action: "add",
type: "folder",
@ -722,7 +654,7 @@ var PlacesUIUtils = {
*
* @return true if any transaction has been performed, false otherwise.
*/
_showBookmarkDialog: function PU__showBookmarkDialog(aInfo, aMinimalUI) {
_showBookmarkDialog: function PUIU__showBookmarkDialog(aInfo, aMinimalUI) {
var dialogURL = aMinimalUI ?
"chrome://browser/content/places/bookmarkProperties2.xul" :
"chrome://browser/content/places/bookmarkProperties.xul";
@ -732,17 +664,25 @@ var PlacesUIUtils = {
features = "centerscreen,chrome,dialog,resizable,modal";
else
features = "centerscreen,chrome,modal,resizable=no";
window.openDialog(dialogURL, "", features, aInfo);
this._getCurrentActiveWin().openDialog(dialogURL, "", features, aInfo);
return ("performed" in aInfo && aInfo.performed);
},
_getTopBrowserWin: function PUIU__getTopBrowserWin() {
return Services.wm.getMostRecentWindow("navigator:browser");
},
_getCurrentActiveWin: function PUIU__getCurrentActiveWin() {
return this.fm.activeWindow;
},
/**
* Returns the closet ancestor places view for the given DOM node
* @param aNode
* a DOM node
* @return the closet ancestor places view if exists, null otherwsie.
*/
getViewForNode: function PU_getViewForNode(aNode) {
getViewForNode: function PUIU_getViewForNode(aNode) {
var node = aNode;
// the view for a <menu> of which its associated menupopup is a places view,
@ -770,7 +710,7 @@ var PlacesUIUtils = {
* organizer. If this is not called visits will be marked as
* TRANSITION_LINK.
*/
markPageAsTyped: function PU_markPageAsTyped(aURL) {
markPageAsTyped: function PUIU_markPageAsTyped(aURL) {
PlacesUtils.history.QueryInterface(Ci.nsIBrowserHistory)
.markPageAsTyped(this.createFixedURI(aURL));
},
@ -782,7 +722,7 @@ var PlacesUIUtils = {
* personal toolbar, and bookmarks from within the places organizer.
* If this is not called visits will be marked as TRANSITION_LINK.
*/
markPageAsFollowedBookmark: function PU_markPageAsFollowedBookmark(aURL) {
markPageAsFollowedBookmark: function PUIU_markPageAsFollowedBookmark(aURL) {
PlacesUtils.history.markPageAsFollowedBookmark(this.createFixedURI(aURL));
},
@ -792,7 +732,7 @@ var PlacesUIUtils = {
* This is actually used to distinguish user-initiated visits in frames
* so automatic visits can be correctly ignored.
*/
markPageAsFollowedLink: function PU_markPageAsUserClicked(aURL) {
markPageAsFollowedLink: function PUIU_markPageAsUserClicked(aURL) {
PlacesUtils.history.QueryInterface(Ci.nsIBrowserHistory)
.markPageAsFollowedLink(this.createFixedURI(aURL));
},
@ -805,7 +745,7 @@ var PlacesUIUtils = {
* @return true if it's safe to open the node in the browser, false otherwise.
*
*/
checkURLSecurity: function PU_checkURLSecurity(aURINode) {
checkURLSecurity: function PUIU_checkURLSecurity(aURINode, aWindow) {
if (!PlacesUtils.nodeIsBookmark(aURINode)) {
var uri = PlacesUtils._uri(aURINode.uri);
if (uri.schemeIs("javascript") || uri.schemeIs("data")) {
@ -814,11 +754,9 @@ var PlacesUIUtils = {
getService(Ci.nsIStringBundleService).
createBundle(BRANDING_BUNDLE_URI).
GetStringFromName("brandShortName");
var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService);
var errorStr = this.getString("load-js-data-url-error");
promptService.alert(window, brandShortName, errorStr);
Services.prompt.alert(aWindow, brandShortName, errorStr);
return false;
}
}
@ -833,7 +771,7 @@ var PlacesUIUtils = {
* @returns A description string if a META element was discovered with a
* "description" or "httpequiv" attribute, empty string otherwise.
*/
getDescriptionFromDocument: function PU_getDescriptionFromDocument(doc) {
getDescriptionFromDocument: function PUIU_getDescriptionFromDocument(doc) {
var metaElements = doc.getElementsByTagName("META");
for (var i = 0; i < metaElements.length; ++i) {
if (metaElements[i].name.toLowerCase() == "description" ||
@ -851,26 +789,23 @@ var PlacesUIUtils = {
* @returns the description of the given item, or an empty string if it is
* not set.
*/
getItemDescription: function PU_getItemDescription(aItemId) {
if (PlacesUtils.annotations.itemHasAnnotation(aItemId, DESCRIPTION_ANNO))
return PlacesUtils.annotations.getItemAnnotation(aItemId, DESCRIPTION_ANNO);
getItemDescription: function PUIU_getItemDescription(aItemId) {
if (PlacesUtils.annotations.itemHasAnnotation(aItemId, this.DESCRIPTION_ANNO))
return PlacesUtils.annotations.getItemAnnotation(aItemId, this.DESCRIPTION_ANNO);
return "";
},
/**
* Gives the user a chance to cancel loading lots of tabs at once
*/
_confirmOpenInTabs: function PU__confirmOpenInTabs(numTabsToOpen) {
var pref = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
const kWarnOnOpenPref = "browser.tabs.warnOnOpen";
_confirmOpenInTabs: function PUIU__confirmOpenInTabs(numTabsToOpen) {
let pref = Services.prefs;
let prompt = Services.prompt;
const WARN_ON_OPEN_PREF = "browser.tabs.warnOnOpen";
var reallyOpen = true;
if (pref.getBoolPref(kWarnOnOpenPref)) {
if (numTabsToOpen >= pref.getIntPref("browser.tabs.maxOpenBeforeWarn")) {
var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
getService(Ci.nsIPromptService);
if (pref.getBoolPref(WARN_ON_OPEN_PREF)) {
if (numTabsToOpen >= pref.getIntPref("browser.tabs.maxOpenBeforeWarn")) {
// default to true: if it were false, we wouldn't get this far
var warnOnOpen = { value: true };
@ -882,28 +817,32 @@ var PlacesUIUtils = {
createBundle(BRANDING_BUNDLE_URI).
GetStringFromName("brandShortName");
var buttonPressed = promptService.confirmEx(window,
var buttonPressed = prompt.confirmEx(
this._getCurrentActiveWin(),
this.getString("tabs.openWarningTitle"),
this.getFormattedString(messageKey, [numTabsToOpen, brandShortName]),
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0)
+ (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
(prompt.BUTTON_TITLE_IS_STRING * prompt.BUTTON_POS_0) +
(prompt.BUTTON_TITLE_CANCEL * prompt.BUTTON_POS_1),
this.getString(openKey), null, null,
this.getFormattedString("tabs.openWarningPromptMeBranded",
[brandShortName]), warnOnOpen);
[brandShortName]),
warnOnOpen
);
reallyOpen = (buttonPressed == 0);
// don't set the pref unless they press OK and it's false
if (reallyOpen && !warnOnOpen.value)
pref.setBoolPref(kWarnOnOpenPref, false);
pref.setBoolPref(WARN_ON_OPEN_PREF, false);
}
}
return reallyOpen;
},
/** aItemsToOpen needs to be an array of objects of the form:
* {uri: string, isBookmark: boolean}
*/
_openTabset: function PU__openTabset(aItemsToOpen, aEvent) {
_openTabset: function PUIU__openTabset(aItemsToOpen, aEvent) {
if (!aItemsToOpen.length)
return;
@ -918,12 +857,13 @@ var PlacesUIUtils = {
urls.push(item.uri);
}
var browserWindow = getTopWin();
var browserWindow = this._getTopBrowserWin();
var where = browserWindow ?
whereToOpenLink(aEvent, false, true) : "window";
browserWindow.whereToOpenLink(aEvent, false, true) : "window";
if (where == "window") {
window.openDialog(getBrowserURL(), "_blank",
"chrome,all,dialog=no", urls.join("|"));
let win = this._getCurrentActiveWin();
win.openDialog(win.getBrowserURL(), "_blank",
"chrome,all,dialog=no", urls.join("|"));
return;
}
@ -932,7 +872,7 @@ var PlacesUIUtils = {
browserWindow.gBrowser.loadTabs(urls, loadInBackground, replaceCurrentTab);
},
openContainerNodeInTabs: function PU_openContainerInTabs(aNode, aEvent) {
openContainerNodeInTabs: function PUIU_openContainerInTabs(aNode, aEvent) {
var urlsToOpen = PlacesUtils.getURLsForContainerNode(aNode);
if (!this._confirmOpenInTabs(urlsToOpen.length))
return;
@ -940,7 +880,7 @@ var PlacesUIUtils = {
this._openTabset(urlsToOpen, aEvent);
},
openURINodesInTabs: function PU_openURINodesInTabs(aNodes, aEvent) {
openURINodesInTabs: function PUIU_openURINodesInTabs(aNodes, aEvent) {
var urlsToOpen = [];
for (var i=0; i < aNodes.length; i++) {
// skip over separators and folders
@ -960,8 +900,8 @@ var PlacesUIUtils = {
* The DOM mouse/key event with modifier keys set that track the
* user's preferred destination window or tab.
*/
openNodeWithEvent: function PU_openNodeWithEvent(aNode, aEvent) {
this.openNodeIn(aNode, whereToOpenLink(aEvent));
openNodeWithEvent: function PUIU_openNodeWithEvent(aNode, aEvent) {
this.openNodeIn(aNode, this._getCurrentActiveWin().whereToOpenLink(aEvent));
},
/**
@ -969,9 +909,9 @@ var PlacesUIUtils = {
* web panel.
* see also openUILinkIn
*/
openNodeIn: function PU_openNodeIn(aNode, aWhere) {
openNodeIn: function PUIU_openNodeIn(aNode, aWhere) {
if (aNode && PlacesUtils.nodeIsURI(aNode) &&
this.checkURLSecurity(aNode)) {
this.checkURLSecurity(aNode, this._getCurrentActiveWin())) {
var isBookmark = PlacesUtils.nodeIsBookmark(aNode);
if (isBookmark)
@ -983,15 +923,15 @@ var PlacesUIUtils = {
// a web panel
if (aWhere == "current" && isBookmark) {
if (PlacesUtils.annotations
.itemHasAnnotation(aNode.itemId, LOAD_IN_SIDEBAR_ANNO)) {
var w = getTopWin();
if (w) {
w.openWebPanel(aNode.title, aNode.uri);
.itemHasAnnotation(aNode.itemId, this.LOAD_IN_SIDEBAR_ANNO)) {
var browserWin = this._getTopBrowserWin();
if (browserWin) {
browserWin.openWebPanel(aNode.title, aNode.uri);
return;
}
}
}
openUILinkIn(aNode.uri, aWhere);
this._getCurrentActiveWin().openUILinkIn(aNode.uri, aWhere);
}
},
@ -1010,14 +950,24 @@ var PlacesUIUtils = {
},
/**
* Helper for the toolbar and menu views
* Creates a menu item ready to be added to a popup.
* Helper for the toolbar and menu views.
* @param aNode
* Places node used as source for DOM node.
* @param aDocument
* The node will be created in this document.
* @return a DOM menuitem node.
*/
createMenuItemForNode:
function PUU_createMenuItemForNode(aNode) {
function PUU_createMenuItemForNode(aNode, aDocument) {
var element;
// For add-ons backwards compatibility, if the caller does not provide
// a document, we guess one.
var document = aDocument || this._getTopBrowserWin().document;
var type = aNode.type;
if (type == Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR)
if (type == Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR) {
element = document.createElement("menuseparator");
}
else {
if (PlacesUtils.uriTypes.indexOf(type) != -1) {
element = document.createElement("menuitem");
@ -1044,7 +994,7 @@ var PlacesUIUtils = {
var popup = document.createElement("menupopup");
popup.setAttribute("placespopup", "true");
popup._resultNode = asContainer(aNode);
popup._resultNode = PlacesUtils.asContainer(aNode);
#ifdef XP_MACOSX
// Binding on Mac native menus is lazy attached, so onPopupShowing,
// in the capturing phase, fields are not yet initialized.
@ -1074,7 +1024,7 @@ var PlacesUIUtils = {
return element;
},
cleanPlacesPopup: function PU_cleanPlacesPopup(aPopup) {
cleanPlacesPopup: function PUIU_cleanPlacesPopup(aPopup) {
// Remove places popup children and update markers to keep track of
// their indices.
var start = aPopup._startMarker != -1 ? aPopup._startMarker + 1 : 0;
@ -1097,10 +1047,11 @@ var PlacesUIUtils = {
}
else {
// This is static content...
if (!placesNodeFound)
if (!placesNodeFound) {
// ...at the start of the popup
// Initialized in menu.xml, in the base binding
aPopup._startMarker++;
}
else {
// ...after places nodes
aPopup._endMarker = i;
@ -1116,7 +1067,7 @@ var PlacesUIUtils = {
}
},
getBestTitle: function PU_getBestTitle(aNode) {
getBestTitle: function PUIU_getBestTitle(aNode) {
var title;
if (!aNode.title && PlacesUtils.uriTypes.indexOf(aNode.type) != -1) {
// if node title is empty, try to set the label using host and filename
@ -1181,16 +1132,16 @@ var PlacesUIUtils = {
// Removes an item and associated annotations, ignoring eventual errors.
function safeRemoveItem(aItemId) {
try {
if (as.itemHasAnnotation(aItemId, ORGANIZER_QUERY_ANNO) &&
!(as.getItemAnnotation(aItemId, ORGANIZER_QUERY_ANNO) in queries)) {
if (as.itemHasAnnotation(aItemId, PlacesUIUtils.ORGANIZER_QUERY_ANNO) &&
!(as.getItemAnnotation(aItemId, PlacesUIUtils.ORGANIZER_QUERY_ANNO) in queries)) {
// Some extension annotated their roots with our query annotation,
// so we should not delete them.
return;
}
// removeItemAnnotation does not check if item exists, nor the anno,
// so this is safe to do.
as.removeItemAnnotation(aItemId, ORGANIZER_FOLDER_ANNO);
as.removeItemAnnotation(aItemId, ORGANIZER_QUERY_ANNO);
as.removeItemAnnotation(aItemId, PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
as.removeItemAnnotation(aItemId, PlacesUIUtils.ORGANIZER_QUERY_ANNO);
// This will throw if the annotation is an orphan.
bs.removeItem(aItemId);
}
@ -1209,7 +1160,7 @@ var PlacesUIUtils = {
}
// Get all items marked as being the left pane folder.
let items = as.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
let items = as.getItemsWithAnnotation(this.ORGANIZER_FOLDER_ANNO);
if (items.length > 1) {
// Something went wrong, we cannot have more than one left pane folder,
// remove all left pane folders and continue. We will create a new one.
@ -1217,10 +1168,10 @@ var PlacesUIUtils = {
}
else if (items.length == 1 && items[0] != -1) {
leftPaneRoot = items[0];
// Check that organizer left pane root is valid.
let version = as.getItemAnnotation(leftPaneRoot, ORGANIZER_FOLDER_ANNO);
if (version != ORGANIZER_LEFTPANE_VERSION || !itemExists(leftPaneRoot)) {
let version = as.getItemAnnotation(leftPaneRoot, this.ORGANIZER_FOLDER_ANNO);
if (version != this.ORGANIZER_LEFTPANE_VERSION ||
!itemExists(leftPaneRoot)) {
// Invalid root, we must rebuild the left pane.
safeRemoveItem(leftPaneRoot);
leftPaneRoot = -1;
@ -1234,11 +1185,12 @@ var PlacesUIUtils = {
delete this.leftPaneQueries;
this.leftPaneQueries = {};
let items = as.getItemsWithAnnotation(ORGANIZER_QUERY_ANNO);
let items = as.getItemsWithAnnotation(this.ORGANIZER_QUERY_ANNO);
// While looping through queries we will also check for their validity.
let queriesCount = 0;
for(let i = 0; i < items.length; i++) {
let queryName = as.getItemAnnotation(items[i], ORGANIZER_QUERY_ANNO);
for (let i = 0; i < items.length; i++) {
let queryName = as.getItemAnnotation(items[i], this.ORGANIZER_QUERY_ANNO);
// Some extension did use our annotation to decorate their items
// with icons, so we should check only our elements, to avoid dataloss.
if (!(queryName in queries))
@ -1289,7 +1241,6 @@ var PlacesUIUtils = {
}
// Create a new left pane folder.
var self = this;
var callback = {
// Helper to create an organizer special query.
create_query: function CB_create_query(aQueryName, aParentId, aQueryUrl) {
@ -1298,13 +1249,13 @@ var PlacesUIUtils = {
bs.DEFAULT_INDEX,
queries[aQueryName].title);
// Mark as special organizer query.
as.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO, aQueryName,
as.setItemAnnotation(itemId, PlacesUIUtils.ORGANIZER_QUERY_ANNO, aQueryName,
0, as.EXPIRE_NEVER);
// We should never backup this, since it changes between profiles.
as.setItemAnnotation(itemId, EXCLUDE_FROM_BACKUP_ANNO, 1,
as.setItemAnnotation(itemId, PlacesUtils.EXCLUDE_FROM_BACKUP_ANNO, 1,
0, as.EXPIRE_NEVER);
// Add to the queries map.
self.leftPaneQueries[aQueryName] = itemId;
PlacesUIUtils.leftPaneQueries[aQueryName] = itemId;
return itemId;
},
@ -1315,29 +1266,29 @@ var PlacesUIUtils = {
queries[aFolderName].title,
bs.DEFAULT_INDEX);
// We should never backup this, since it changes between profiles.
as.setItemAnnotation(folderId, EXCLUDE_FROM_BACKUP_ANNO, 1,
as.setItemAnnotation(folderId, PlacesUtils.EXCLUDE_FROM_BACKUP_ANNO, 1,
0, as.EXPIRE_NEVER);
// Disallow manipulating this folder within the organizer UI.
bs.setFolderReadonly(folderId, true);
if (aIsRoot) {
// Mark as special left pane root.
as.setItemAnnotation(folderId, ORGANIZER_FOLDER_ANNO,
ORGANIZER_LEFTPANE_VERSION,
as.setItemAnnotation(folderId, PlacesUIUtils.ORGANIZER_FOLDER_ANNO,
PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION,
0, as.EXPIRE_NEVER);
}
else {
// Mark as special organizer folder.
as.setItemAnnotation(folderId, ORGANIZER_QUERY_ANNO, aFolderName,
as.setItemAnnotation(folderId, PlacesUIUtils.ORGANIZER_QUERY_ANNO, aFolderName,
0, as.EXPIRE_NEVER);
self.leftPaneQueries[aFolderName] = folderId;
PlacesUIUtils.leftPaneQueries[aFolderName] = folderId;
}
return folderId;
},
runBatched: function CB_runBatched(aUserData) {
delete self.leftPaneQueries;
self.leftPaneQueries = { };
delete PlacesUIUtils.leftPaneQueries;
PlacesUIUtils.leftPaneQueries = { };
// Left Pane Root Folder.
leftPaneRoot = this.create_folder("PlacesRoot", bs.placesRoot, true);
@ -1397,14 +1348,14 @@ var PlacesUIUtils = {
* @param aItemId id of a container
* @returns the name of the query, or empty string if not a left-pane query
*/
getLeftPaneQueryNameFromId: function PU_getLeftPaneQueryNameFromId(aItemId) {
getLeftPaneQueryNameFromId: function PUIU_getLeftPaneQueryNameFromId(aItemId) {
var queryName = "";
// If the let pane hasn't been built, use the annotation service
// directly, to avoid building the left pane too early.
if (this.__lookupGetter__("leftPaneFolderId")) {
try {
queryName = PlacesUtils.annotations.
getItemAnnotation(aItemId, ORGANIZER_QUERY_ANNO);
getItemAnnotation(aItemId, this.ORGANIZER_QUERY_ANNO);
}
catch (ex) {
// doesn't have the annotation
@ -1428,7 +1379,7 @@ var PlacesUIUtils = {
* The livemark container popup
*/
ensureLivemarkStatusMenuItem:
function PU_ensureLivemarkStatusMenuItem(aPopup) {
function PUIU_ensureLivemarkStatusMenuItem(aPopup) {
var itemId = aPopup._resultNode.itemId;
var lmStatus = null;
@ -1441,6 +1392,7 @@ var PlacesUIUtils = {
if (lmStatus && !aPopup._lmStatusMenuItem) {
// Create the status menuitem and cache it in the popup object.
let document = aPopup.ownerDocument;
aPopup._lmStatusMenuItem = document.createElement("menuitem");
aPopup._lmStatusMenuItem.setAttribute("lmStatus", lmStatus);
aPopup._lmStatusMenuItem.setAttribute("label", this.getString(lmStatus));
@ -1463,3 +1415,40 @@ var PlacesUIUtils = {
}
}
};
XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "RDF",
"@mozilla.org/rdf/rdf-service;1",
"nsIRDFService");
XPCOMUtils.defineLazyGetter(PlacesUIUtils, "localStore", function() {
return PlacesUIUtils.RDF.GetDataSource("rdf:local-store");
});
XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "ptm",
"@mozilla.org/browser/placesTransactionsService;1",
"nsIPlacesTransactionsService");
XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "URIFixup",
"@mozilla.org/docshell/urifixup;1",
"nsIURIFixup");
XPCOMUtils.defineLazyGetter(PlacesUIUtils, "ellipsis", function() {
return Services.prefs.getComplexValue("intl.ellipsis",
Ci.nsIPrefLocalizedString).data;
});
XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "privateBrowsing",
"@mozilla.org/privatebrowsing;1",
"nsIPrivateBrowsingService");
XPCOMUtils.defineLazyGetter(PlacesUIUtils, "_bundle", function() {
const PLACES_STRING_BUNDLE_URI =
"chrome://browser/locale/places/places.properties";
return Cc["@mozilla.org/intl/stringbundle;1"].
getService(Ci.nsIStringBundleService).
createBundle(PLACES_STRING_BUNDLE_URI);
});
XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "fm",
"@mozilla.org/focus-manager;1",
"nsIFocusManager");

Просмотреть файл

@ -41,21 +41,24 @@
let Ci = Components.interfaces;
let Cc = Components.classes;
let Cr = Components.results;
let Cu = Components.utils;
const LOAD_IN_SIDEBAR_ANNO = "bookmarkProperties/loadInSidebar";
const DESCRIPTION_ANNO = "bookmarkProperties/description";
const GUID_ANNO = "placesInternal/GUID";
const CLASS_ID = Components.ID("c0844a84-5a12-4808-80a8-809cb002bb4f");
const CONTRACT_ID = "@mozilla.org/browser/placesTransactionsService;1";
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
__defineGetter__("PlacesUtils", function() {
delete this.PlacesUtils
var tmpScope = {};
Components.utils.import("resource://gre/modules/utils.js", tmpScope);
return this.PlacesUtils = tmpScope.PlacesUtils;
XPCOMUtils.defineLazyGetter(this, "Services", function() {
Cu.import("resource://gre/modules/Services.jsm");
return Services;
});
XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
Cu.import("resource://gre/modules/utils.js");
return PlacesUtils;
});
// The minimum amount of transactions we should tell our observers to begin
@ -63,6 +66,7 @@ __defineGetter__("PlacesUtils", function() {
const MIN_TRANSACTIONS_FOR_BATCH = 5;
function placesTransactionsService() {
Services.obs.addObserver(this, "xpcom-shutdown", false);
this.mTransactionManager = Cc["@mozilla.org/transactionmanager;1"].
createInstance(Ci.nsITransactionManager);
}
@ -72,8 +76,19 @@ placesTransactionsService.prototype = {
classID: CLASS_ID,
contractID: CONTRACT_ID,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPlacesTransactionsService,
Ci.nsITransactionManager]),
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIPlacesTransactionsService,
Ci.nsITransactionManager,
Ci.nsIObserver,
]),
// nsIObserver
observe: function PlacesTxn_observe(aSubject, aTopic, aData) {
if (aTopic == "xpcom-shutdown") {
Services.obs.removeObserver(this, "xpcom-shutdown");
delete this.mTransactionManager;
}
},
aggregateTransactions:
function placesTxn_aggregateTransactions(aName, aTransactions) {
@ -228,9 +243,7 @@ placesTransactionsService.prototype = {
// Update commands in the undo group of the active window
// commands in inactive windows will are updated on-focus
_updateCommands: function placesTxn__updateCommands() {
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
var win = wm.getMostRecentWindow(null);
var win = Services.wm.getMostRecentWindow(null);
if (win)
win.updateCommands("undo");
},
@ -445,7 +458,7 @@ placesCreateFolderTransactions.prototype = {
}
// If a GUID exists for this item, preserve it before removing the item.
if (PlacesUtils.annotations.itemHasAnnotation(this._id, GUID_ANNO))
if (PlacesUtils.annotations.itemHasAnnotation(this._id, PlacesUtils.GUID_ANNO))
this._GUID = PlacesUtils.bookmarks.getItemGUID(this._id);
// Remove item only after all child transactions have been reverted.
@ -503,7 +516,7 @@ placesCreateItemTransactions.prototype = {
}
// If a GUID exists for this item, preserve it before removing the item.
if (PlacesUtils.annotations.itemHasAnnotation(this._id, GUID_ANNO))
if (PlacesUtils.annotations.itemHasAnnotation(this._id, PlacesUtils.GUID_ANNO))
this._GUID = PlacesUtils.bookmarks.getItemGUID(this._id);
// Remove item only after all child transactions have been reverted.
@ -534,7 +547,7 @@ placesCreateSeparatorTransactions.prototype = {
undoTransaction: function PCST_undoTransaction() {
// If a GUID exists for this item, preserve it before removing the item.
if (PlacesUtils.annotations.itemHasAnnotation(this._id, GUID_ANNO))
if (PlacesUtils.annotations.itemHasAnnotation(this._id, PlacesUtils.GUID_ANNO))
this._GUID = PlacesUtils.bookmarks.getItemGUID(this._id);
PlacesUtils.bookmarks.removeItem(this._id);
@ -572,7 +585,7 @@ placesCreateLivemarkTransactions.prototype = {
undoTransaction: function PCLT_undoTransaction() {
// If a GUID exists for this item, preserve it before removing the item.
if (PlacesUtils.annotations.itemHasAnnotation(this._id, GUID_ANNO))
if (PlacesUtils.annotations.itemHasAnnotation(this._id, PlacesUtils.GUID_ANNO))
this._GUID = PlacesUtils.bookmarks.getItemGUID(this._id);
PlacesUtils.bookmarks.removeItem(this._id);
@ -1134,7 +1147,7 @@ placesTagURITransaction.prototype = {
undoTransaction: function PTU_undoTransaction() {
if (this._unfiledItemId != -1) {
// If a GUID exists for this item, preserve it before removing the item.
if (PlacesUtils.annotations.itemHasAnnotation(this._unfiledItemId, GUID_ANNO)) {
if (PlacesUtils.annotations.itemHasAnnotation(this._unfiledItemId, PlacesUtils.GUID_ANNO)) {
this._GUID = PlacesUtils.bookmarks.getItemGUID(this._unfiledItemId);
}
PlacesUtils.bookmarks.removeItem(this._unfiledItemId);

Просмотреть файл

@ -44,6 +44,7 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_BROWSER_TEST_FILES = \
head.js \
browser_0_library_left_pane_migration.js \
browser_library_left_pane_fixnames.js \
browser_425884.js \

Просмотреть файл

@ -60,7 +60,7 @@ function windowObserver(aSubject, aTopic, aData) {
"Left pane folder correctly created");
var leftPaneItems =
PlacesUtils.annotations
.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
is(leftPaneItems.length, 1,
"We correctly have only 1 left pane folder");
var leftPaneRoot = leftPaneItems[0];
@ -69,8 +69,8 @@ function windowObserver(aSubject, aTopic, aData) {
// Check version has been upgraded.
var version =
PlacesUtils.annotations.getItemAnnotation(leftPaneRoot,
ORGANIZER_FOLDER_ANNO);
is(version, ORGANIZER_LEFTPANE_VERSION,
PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
is(version, PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION,
"Left pane version has been correctly upgraded");
// Check left pane is populated.
@ -92,20 +92,20 @@ function test() {
// Sanity checks.
ok(PlacesUtils, "PlacesUtils is running in chrome context");
ok(PlacesUIUtils, "PlacesUIUtils is running in chrome context");
ok(ORGANIZER_LEFTPANE_VERSION > 0,
"Left pane version in chrome context, current version is: " + ORGANIZER_LEFTPANE_VERSION );
ok(PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION > 0,
"Left pane version in chrome context, current version is: " + PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION );
// Check if we have any left pane folder already set, remove it eventually.
var leftPaneItems = PlacesUtils.annotations
.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
if (leftPaneItems.length > 0) {
// The left pane has already been created, touching it now would cause
// next tests to rely on wrong values (and possibly crash)
is(leftPaneItems.length, 1, "We correctly have only 1 left pane folder");
// Check version.
var version = PlacesUtils.annotations.getItemAnnotation(leftPaneItems[0],
ORGANIZER_FOLDER_ANNO);
is(version, ORGANIZER_LEFTPANE_VERSION, "Left pane version is actual");
PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
is(version, PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION, "Left pane version is actual");
ok(true, "left pane has already been created, skipping test");
finish();
return;
@ -116,21 +116,21 @@ function test() {
PlacesUtils.bookmarks.createFolder(PlacesUtils.placesRootId, "",
PlacesUtils.bookmarks.DEFAULT_INDEX);
PlacesUtils.annotations.setItemAnnotation(fakeLeftPaneRoot,
ORGANIZER_FOLDER_ANNO,
ORGANIZER_LEFTPANE_VERSION - 1,
PlacesUIUtils.ORGANIZER_FOLDER_ANNO,
PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION - 1,
0,
PlacesUtils.annotations.EXPIRE_NEVER);
// Check fake left pane root has been correctly created.
var leftPaneItems =
PlacesUtils.annotations.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
PlacesUtils.annotations.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
is(leftPaneItems.length, 1, "We correctly have only 1 left pane folder");
is(leftPaneItems[0], fakeLeftPaneRoot, "left pane root itemId is correct");
// Check version.
var version = PlacesUtils.annotations.getItemAnnotation(fakeLeftPaneRoot,
ORGANIZER_FOLDER_ANNO);
is(version, ORGANIZER_LEFTPANE_VERSION - 1, "Left pane version correctly set");
PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
is(version, PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION - 1, "Left pane version correctly set");
// Open Library, this will upgrade our left pane version.
ww.registerNotification(windowObserver);

Просмотреть файл

@ -143,7 +143,9 @@ function test() {
var xferable = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
xferable.addDataFlavor(PU.TYPE_X_MOZ_PLACE);
PUIU.clipboard.getData(xferable, Ci.nsIClipboard.kGlobalClipboard);
var clipboard = Cc["@mozilla.org/widget/clipboard;1"].
getService(Ci.nsIClipboard);
clipboard.getData(xferable, Ci.nsIClipboard.kGlobalClipboard);
var data = { }, type = { };
xferable.getAnyTransferData(type, data, { });
// Data is in the clipboard

Просмотреть файл

@ -172,11 +172,11 @@ function test() {
is(shortcutNode.itemId, shortcutId, "shortcut id and shortcut node item id match");
LOG("can move shortcut id?");
dump("can move shortcut id?\n");
is(PlacesControllerDragHelper.canMoveContainer(shortcutId),
true, "should be able to move special folder shortcut id");
LOG("can move shortcut node?");
dump("can move shortcut node?\n");
is(PlacesControllerDragHelper.canMoveNode(shortcutNode),
true, "should be able to move special folder shortcut node");
}

Просмотреть файл

@ -118,12 +118,12 @@ function populate(aFolderId) {
}
function validate(aNode) {
asContainer(aNode);
PlacesUtils.asContainer(aNode);
aNode.containerOpen = true;
is(aNode.childCount, 1, "confirm child count match");
var folderNode = aNode.getChild(0);
is(folderNode.title, "test folder", "confirm folder title");
asContainer(folderNode);
PlacesUtils.asContainer(folderNode);
folderNode.containerOpen = true;
is(folderNode.childCount, 2, "confirm child count match");
var bookmarkNode = folderNode.getChild(0);

Просмотреть файл

@ -57,7 +57,7 @@ function test() {
var testRootId = PlacesUtils.bookmarks.createFolder(toolbarId, "test root", -1);
is(toolbarNode.childCount, oldCount+1, "confirm test root node is a container, and is empty");
var testRootNode = toolbarNode.getChild(toolbarNode.childCount-1);
asContainer(testRootNode);
PlacesUtils.asContainer(testRootNode);
testRootNode.containerOpen = true;
is(testRootNode.childCount, 0, "confirm test root node is a container, and is empty");
@ -120,7 +120,7 @@ function test() {
}
function getGUIDs(aNode) {
asContainer(aNode);
PlacesUtils.asContainer(aNode);
aNode.containerOpen = true;
var GUIDs = {
folder: PlacesUtils.bookmarks.getItemGUID(aNode.itemId),
@ -139,7 +139,7 @@ function checkGUIDs(aFolderNode, aGUIDs, aShouldMatch) {
return aEquals ? (nodeGUID == aGUID) : (nodeGUID != aGUID);
}
asContainer(aFolderNode);
PlacesUtils.asContainer(aFolderNode);
aFolderNode.containerOpen = true;
var allMatch = check(aFolderNode, aGUIDs.folder, aShouldMatch) &&

Просмотреть файл

@ -530,6 +530,10 @@ gTests.push({
function test() {
waitForExplicitFinish();
// This test can take some time, if we timeout too early it could run
// in the middle of other tests, or hang them.
requestLongerTimeout(2);
// Sanity checks.
ok(PlacesUtils, "PlacesUtils in context");
ok(PlacesUIUtils, "PlacesUIUtils in context");

Просмотреть файл

@ -81,32 +81,32 @@ function test() {
// Sanity checks.
ok(PlacesUtils, "PlacesUtils is running in chrome context");
ok(PlacesUIUtils, "PlacesUIUtils is running in chrome context");
ok(ORGANIZER_LEFTPANE_VERSION > 0,
"Left pane version in chrome context, current version is: " + ORGANIZER_LEFTPANE_VERSION );
ok(PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION > 0,
"Left pane version in chrome context, current version is: " + PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION );
// Ensure left pane is initialized.
ok(PlacesUIUtils.leftPaneFolderId > 0, "left pane folder is initialized");
// Get the left pane folder.
var leftPaneItems = PlacesUtils.annotations
.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
is(leftPaneItems.length, 1, "We correctly have only 1 left pane folder");
// Check version.
var version = PlacesUtils.annotations
.getItemAnnotation(leftPaneItems[0],
ORGANIZER_FOLDER_ANNO);
is(version, ORGANIZER_LEFTPANE_VERSION, "Left pane version is actual");
PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
is(version, PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION, "Left pane version is actual");
// Get all left pane queries.
var items = PlacesUtils.annotations
.getItemsWithAnnotation(ORGANIZER_QUERY_ANNO);
.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_QUERY_ANNO);
// Get current queries names.
for (var i = 0; i < items.length; i++) {
var itemId = items[i];
var queryName = PlacesUtils.annotations
.getItemAnnotation(items[i],
ORGANIZER_QUERY_ANNO);
PlacesUIUtils.ORGANIZER_QUERY_ANNO);
var query = { name: queryName,
itemId: itemId,
correctTitle: PlacesUtils.bookmarks.getItemTitle(itemId) }
@ -131,6 +131,8 @@ function test() {
PlacesUtils.bookmarks.setItemTitle(query.concreteId, "badName");
}
PlacesUIUtils.__defineGetter__("leftPaneFolderId", cachedLeftPaneFolderIdGetter);
// Open Library, this will kick-off left pane code.
ww.registerNotification(windowObserver);
ww.openWindow(null,

Просмотреть файл

@ -82,10 +82,6 @@ var gTabsListener = {
if (gCurrentTest.URIs.indexOf(spec) != -1 )
this._loadedURIs.push(spec);
var fm = Components.classes["@mozilla.org/focus-manager;1"].
getService(Components.interfaces.nsIFocusManager);
is(fm.activeWindow, gBrowser.ownerDocument.defaultView, "window made active");
if (this._loadedURIs.length == gCurrentTest.URIs.length) {
// We have correctly opened all URIs.
@ -97,7 +93,7 @@ var gTabsListener = {
this._openTabsCount = 0;
// Test finished. This will move to the next one.
gCurrentTest.finish();
waitForFocus(gCurrentTest.finish, gBrowser.ownerDocument.defaultView);
}
},
@ -252,6 +248,8 @@ gTests.push({
function test() {
waitForExplicitFinish();
// Increase timeout, this test can be quite slow due to waitForFocus calls.
requestLongerTimeout(2);
// Sanity checks.
ok(PlacesUtils, "PlacesUtils in context");
@ -302,8 +300,10 @@ function runNextTest() {
gCurrentTest.setup();
// Middle click on first node in the content tree of the Library.
gLibrary.PlacesOrganizer._content.focus();
mouseEventOnCell(gLibrary.PlacesOrganizer._content, 0, 0, { button: 1 });
gLibrary.focus();
waitForFocus(function() {
mouseEventOnCell(gLibrary.PlacesOrganizer._content, 0, 0, { button: 1 });
}, gLibrary);
}
else {
// No more tests.

Просмотреть файл

@ -0,0 +1,15 @@
// We need to cache this before test runs...
let cachedLeftPaneFolderIdGetter;
let (getter = PlacesUIUtils.__lookupGetter__("leftPaneFolderId")) {
if (!cachedLeftPaneFolderIdGetter && typeof(getter) == "function")
cachedLeftPaneFolderIdGetter = getter;
}
// ...And restore it when test ends.
registerCleanupFunction(function(){
let (getter = PlacesUIUtils.__lookupGetter__("leftPaneFolderId")) {
if (cachedLeftPaneFolderIdGetter && typeof(getter) != "function")
PlacesUIUtils.__defineGetter__("leftPaneFolderId",
cachedLeftPaneFolderIdGetter);
}
});

Просмотреть файл

@ -47,8 +47,8 @@ _CHROME_TEST_FILES = \
test_treeview_date.xul \
test_bug485100-change-case-loses-tag.xul \
test_bug427633_no_newfolder_if_noip.xul \
test_multiple_left_pane.xul \
test_bug510634.xul \
test_0_multiple_left_pane.xul \
test_0_bug510634.xul \
$(NULL)
libs:: $(_CHROME_TEST_FILES)

Просмотреть файл

@ -108,7 +108,7 @@
tree.place = "place:queryType=1&folder=" + leftPaneFolderId;
// Open All Bookmarks
asContainer(tree.view.nodeForTreeIndex(2)).containerOpen = true;
PlacesUtils.asContainer(tree.view.nodeForTreeIndex(2)).containerOpen = true;
// The query-property is set on the title column for each row.
let titleColumn = tree.treeBoxObject.columns.getColumnAt(0);
@ -127,6 +127,9 @@
// Close the root node
tree.getResult().root.containerOpen = false;
// Restore the getter for the next test.
PlacesUIUtils.__defineGetter__("leftPaneFolderId", cachedLeftPaneFolderIdGetter);
SimpleTest.finish();
}

Просмотреть файл

@ -71,9 +71,9 @@
// Sanity checks.
ok(PlacesUtils, "PlacesUtils is running in chrome context");
ok(PlacesUIUtils, "PlacesUIUtils is running in chrome context");
ok(ORGANIZER_LEFTPANE_VERSION > 0,
ok(PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION > 0,
"Left pane version in chrome context, " +
"current version is: " + ORGANIZER_LEFTPANE_VERSION );
"current version is: " + PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION );
var fakeLeftPanes = [];
var as = PlacesUtils.annotations;
@ -81,12 +81,12 @@
// We need 2 left pane folders to simulate a corrupt profile.
do {
let leftPaneItems = as.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
let leftPaneItems = as.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
// Create a fake left pane folder.
let fakeLeftPaneRoot = bs.createFolder(PlacesUtils.placesRootId, "",
bs.DEFAULT_INDEX);
as.setItemAnnotation(fakeLeftPaneRoot, ORGANIZER_FOLDER_ANNO,
ORGANIZER_LEFTPANE_VERSION, 0,
as.setItemAnnotation(fakeLeftPaneRoot, PlacesUIUtils.ORGANIZER_FOLDER_ANNO,
PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION, 0,
as.EXPIRE_NEVER);
fakeLeftPanes.push(fakeLeftPaneRoot);
} while (fakeLeftPanes.length < 2);
@ -97,7 +97,7 @@
// Check left pane.
ok(PlacesUIUtils.leftPaneFolderId > 0,
"Left pane folder correctly created");
var leftPaneItems = as.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
var leftPaneItems = as.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
is(leftPaneItems.length, 1,
"We correctly have only 1 left pane folder");

Просмотреть файл

@ -53,6 +53,16 @@ let (commonFile = do_get_file("../../test_places/head_common.js", false)) {
// Put any other stuff relative to this test folder below.
XPCOMUtils.defineLazyGetter(this, "PlacesUIUtils", function() {
Cu.import("resource:///modules/PlacesUIUtils.jsm");
return PlacesUIUtils;
});
const ORGANIZER_FOLDER_ANNO = "PlacesOrganizer/OrganizerFolder";
const ORGANIZER_QUERY_ANNO = "PlacesOrganizer/OrganizerQuery";
// Needed by some test that relies on having an app registered.
let (XULAppInfo = {
vendor: "Mozilla",

Просмотреть файл

@ -116,10 +116,7 @@ function run_test() {
// We want empty roots.
remove_all_bookmarks();
// Import PlacesUIUtils.
let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci.mozIJSSubScriptLoader);
scriptLoader.loadSubScript("chrome://browser/content/places/utils.js", this);
// Sanity check.
do_check_true(!!PlacesUIUtils);
// Check getters.

Просмотреть файл

@ -723,29 +723,6 @@
}
}
})]]></field>
<!-- DND Observer -->
<field name="searchbarDNDObserver" readonly="true"><![CDATA[({
mOuter: this,
onDrop: function (aEvent, aXferData, aDragSession) {
var data = transferUtils.retrieveURLFromData(aXferData.data,
aXferData.flavour.contentType);
if (data) {
this.mOuter.value = data;
this.mOuter.onTextEntered(aEvent);
}
},
getSupportedFlavours: function () {
var flavourSet = new FlavourSet();
flavourSet.appendFlavour("text/unicode");
flavourSet.appendFlavour("text/x-moz-url");
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
return flavourSet;
}
})]]></field>
</implementation>
<handlers>
@ -771,8 +748,26 @@
action="return this.openSearch();"/>
#endif
<handler event="drop" phase="capturing">
nsDragAndDrop.drop(event, this.searchbarDNDObserver);
<handler event="dragover">
<![CDATA[
var types = event.dataTransfer.types;
if (types.contains("text/plain") || types.contains("text/x-moz-text-internal"))
event.preventDefault();
]]>
</handler>
<handler event="drop">
<![CDATA[
var dataTransfer = event.dataTransfer;
var data = dataTransfer.getData("text/plain");
if (!data)
data = dataTransfer.getData("text/x-moz-text-internal");
if (data) {
event.preventDefault();
this.value = data;
this.onTextEntered(event);
}
]]>
</handler>
</handlers>

Просмотреть файл

@ -125,12 +125,44 @@ function test() {
isnot(event.originalTarget, gBrowser.contentDocument,
"Shift+MiddleClick loaded results in background tab");
testRightClick();
testDropText();
});
}
// prevent the search buttonmenu from opening during the drag tests
function stopPopup(event) { event.preventDefault(); }
function testDropText() {
init();
searchBar.addEventListener("popupshowing", stopPopup, true);
// drop on the search button so that we don't need to worry about the
// default handlers for textboxes.
EventUtils.synthesizeDrop(searchBar.searchButton, [[ {type: "text/plain", data: "Some Text" } ]], "copy", window);
doOnloadOnce(function(event) {
is(searchBar.value, "Some Text", "drop text/plain on searchbar");
testDropInternalText();
});
}
function testDropInternalText() {
init();
EventUtils.synthesizeDrop(searchBar.searchButton, [[ {type: "text/x-moz-text-internal", data: "More Text" } ]], "copy", window);
doOnloadOnce(function(event) {
is(searchBar.value, "More Text", "drop text/x-moz-text-internal on searchbar");
testDropLink();
});
}
function testDropLink() {
init();
EventUtils.synthesizeDrop(searchBar.searchButton, [[ {type: "text/uri-list", data: "http://www.mozilla.org" } ]], "copy", window);
is(searchBar.value, "More Text", "drop text/uri-list on searchbar");
SimpleTest.executeSoon(testRightClick);
}
function testRightClick() {
init();
searchBar.removeEventListener("popupshowing", stopPopup, true);
content.location.href = "about:blank";
simulateClick({ button: 2 }, searchButton);
setTimeout(function() {

Просмотреть файл

@ -326,6 +326,7 @@
@BINPATH@/components/nsBadCertHandler.js
@BINPATH@/components/nsFormAutoComplete.js
@BINPATH@/components/contentSecurityPolicy.js
@BINPATH@/components/contentAreaDropListener.js
#ifdef XP_MACOSX
@BINPATH@/components/libalerts_s.dylib
#endif

Просмотреть файл

@ -48,6 +48,8 @@ yes=Yes
no=No
mediaImg=Image
mediaVideo=Video
mediaAudio=Audio
mediaBGImg=Background
mediaObject=Object
mediaEmbed=Embed

Просмотреть файл

@ -49,23 +49,22 @@
background-color: white;
}
#TabsToolbar:not(:-moz-lwtheme) {
margin-bottom: 0;
-moz-box-shadow: ThreeDDarkShadow 0 -1px inset;
}
.tabbrowser-tab:not(:-moz-lwtheme),
.tabbrowser-arrowscrollbox > .scrollbutton-up:not(:-moz-lwtheme),
.tabbrowser-arrowscrollbox > .scrollbutton-down:not(:-moz-lwtheme),
.tabs-newtab-button:not(:-moz-lwtheme),
.tabs-alltabs-button:not(:-moz-lwtheme) {
background-color: rgba(255,255,255,.5);
.tabbrowser-arrowscrollbox > .tabs-newtab-button:not(:-moz-lwtheme) {
background-image: -moz-linear-gradient(left, transparent, transparent 1px,
rgba(255,255,255,.4) 1px, rgba(255,255,255,.4));
text-shadow: 0 1px 0 rgba(255,255,255,.4);
}
.tabbrowser-tab:not(:-moz-lwtheme):not([selected="true"]):hover,
.tabbrowser-arrowscrollbox > .tabs-newtab-button:not(:-moz-lwtheme):hover {
background-image: -moz-linear-gradient(left, transparent, transparent 1px,
rgba(255,255,255,.6) 1px, rgba(255,255,255,.6));
}
.tabbrowser-tab[selected="true"]:not(:-moz-lwtheme) {
background-color: white;
text-shadow: none;
background-image: -moz-linear-gradient(left, transparent, transparent 1px,
white 1px, white);
}
#allTabs-panel,

Просмотреть файл

@ -941,8 +941,8 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
min-height: 0;
padding: 0;
border-style: none;
margin-bottom: 2px;
-moz-box-shadow: ThreeDShadow 0 -1px inset, -moz-dialog 0 2px;
background: -moz-linear-gradient(transparent, transparent 10%,
rgba(0,0,0,.03) 50%, rgba(0,0,0,.1) 90%, rgba(0,0,0,.2));
}
.tabbrowser-tabs:-moz-system-metric(touch-enabled) {
@ -955,65 +955,53 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
/* Tabs */
.tabbrowser-tab,
.tabbrowser-arrowscrollbox > .scrollbutton-up,
.tabbrowser-arrowscrollbox > .scrollbutton-down,
.tabs-newtab-button,
.tabs-alltabs-button {
.tabbrowser-arrowscrollbox > .tabs-newtab-button {
-moz-appearance: none;
background: url("chrome://browser/skin/tabbrowser/tab-bkgnd.png") repeat-x;
margin: 3px 0 1px;
border: 2px solid;
border-right-width: 1px;
border-bottom: none;
-moz-border-top-colors: ThreeDShadow rgba(255,255,255,.3);
-moz-border-left-colors: ThreeDShadow rgba(255,255,255,.3);
}
.tabbrowser-tab:-moz-lwtheme-brighttext,
.tabbrowser-arrowscrollbox > .scrollbutton-up:-moz-lwtheme-brighttext,
.tabbrowser-arrowscrollbox > .scrollbutton-down:-moz-lwtheme-brighttext,
.tabs-newtab-button:-moz-lwtheme-brighttext,
.tabs-alltabs-button:-moz-lwtheme-brighttext {
background-color: rgba(0,0,0,.5);
}
.tabbrowser-tab:-moz-lwtheme-darktext,
.tabbrowser-arrowscrollbox > .scrollbutton-up:-moz-lwtheme-darktext,
.tabbrowser-arrowscrollbox > .scrollbutton-down:-moz-lwtheme-darktext,
.tabs-newtab-button:-moz-lwtheme-darktext,
.tabs-alltabs-button:-moz-lwtheme-darktext {
background-color: rgba(255,255,255,.5);
}
.tabbrowser-tab {
padding: 0 1px 1px 0;
-moz-border-radius-topleft: 2px;
-moz-border-radius-topright: 2px;
-moz-border-right-colors: rgba(0,0,0,.1);
background: -moz-linear-gradient(left, transparent, transparent 1px,
rgba(255,255,255,.15) 1px, rgba(255,255,255,.15));
background-position: -6px 0;
-moz-background-size: 200%;
margin: 0;
padding: 0;
-moz-border-image: url(tabbrowser/tab.png) 3 5 3 6 / 3px 5px 3px 6px;
-moz-border-radius: 6px 4px 0 0;
}
.tabbrowser-tab:hover,
.tabbrowser-tab[selected="true"] {
border-width: 1px;
-moz-border-radius-topleft: 4px;
-moz-border-radius-topright: 4px;
-moz-border-top-colors: ThreeDShadow;
-moz-border-right-colors: ThreeDShadow;
-moz-border-left-colors: ThreeDShadow;
.tabbrowser-arrowscrollbox > .tabs-newtab-button:hover {
background-image: -moz-linear-gradient(left, transparent, transparent 1px,
rgba(255,255,255,.4) 1px, rgba(255,255,255,.4));
}
.tabbrowser-tab:not([selected="true"]):hover {
margin: 2px 0 1px;
padding: 2px 1px 1px;
background-image: url("chrome://browser/skin/tabbrowser/tab-hover-bkgnd.png");
.tabbrowser-tab:-moz-lwtheme-brighttext,
.tabbrowser-arrowscrollbox > .tabs-newtab-button:-moz-lwtheme-brighttext {
background-image: -moz-linear-gradient(left, transparent, transparent 1px,
rgba(40%,40%,40%,.6) 1px, rgba(40%,40%,40%,.6));
}
.tabbrowser-tab:-moz-lwtheme-brighttext:not([selected="true"]):hover,
.tabbrowser-arrowscrollbox > .tabs-newtab-button:-moz-lwtheme-brighttext:hover {
background-image: -moz-linear-gradient(left, transparent, transparent 1px,
rgba(60%,60%,60%,.6) 1px, rgba(60%,60%,60%,.6));
}
.tabbrowser-tab:-moz-lwtheme-darktext,
.tabbrowser-arrowscrollbox > .tabs-newtab-button:-moz-lwtheme-darktext {
background-image: -moz-linear-gradient(left, transparent, transparent 1px,
rgba(255,255,255,.4) 1px, rgba(255,255,255,.4));
}
.tabbrowser-tab:-moz-lwtheme-darktext:not([selected="true"]):hover,
.tabbrowser-arrowscrollbox > .tabs-newtab-button:-moz-lwtheme-darktext:hover {
background-image: -moz-linear-gradient(left, transparent, transparent 1px,
rgba(255,255,255,.6) 1px, rgba(255,255,255,.6));
}
.tabbrowser-tab[selected="true"] {
margin: 2px 0 0;
padding: 1px;
background-image: url("chrome://browser/skin/tabbrowser/tab-active-bkgnd.png");
background-color: -moz-dialog;
font-weight: bold;
background-image: -moz-linear-gradient(left, transparent, transparent 1px,
rgba(255,255,255,.4) 1px, rgba(255,255,255,.4)),
-moz-linear-gradient(left, transparent, transparent 1px,
-moz-dialog 1px, -moz-dialog);
}
.tabbrowser-tab:-moz-lwtheme[selected="true"] {
@ -1057,8 +1045,6 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
}
.tab-icon-image {
margin-top: 1px;
-moz-margin-start: 7px;
-moz-margin-end: 3px;
width: 16px;
height: 16px;
@ -1081,15 +1067,9 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
}
/* Tab close button */
.tab-close-button > .toolbarbutton-icon {
-moz-margin-end: 0px !important;
margin-top: 1px;
}
.tab-close-button {
-moz-appearance: none;
-moz-image-region: rect(0px, 56px, 14px, 42px);
-moz-margin-end: 6px;
border: none;
padding: 0px;
list-style-image: url("chrome://global/skin/icons/close.png");
@ -1121,16 +1101,6 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
}
/* Tab scrollbox arrow, tabstrip new tab and all-tabs buttons */
.tabbrowser-arrowscrollbox > .scrollbutton-up,
.tabbrowser-arrowscrollbox > .scrollbutton-down,
.tabs-newtab-button,
.tabs-alltabs-button {
width: 18px;
padding: 0;
-moz-border-right-colors: ThreeDShadow;
-moz-image-region: rect(0, 11px, 14px, 0);
}
.tabbrowser-arrowscrollbox > .scrollbutton-up:-moz-system-metric(touch-enabled),
.tabbrowser-arrowscrollbox > .scrollbutton-down:-moz-system-metric(touch-enabled),
.tabs-alltabs-button:-moz-system-metric(touch-enabled) {
@ -1141,21 +1111,12 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
min-width: 1cm;
}
.tabbrowser-arrowscrollbox > .scrollbutton-up:not([disabled="true"]):hover,
.tabbrowser-arrowscrollbox > .scrollbutton-down:not([disabled="true"]):hover,
.tabs-newtab-button:hover,
.tabs-alltabs-button:hover {
border-top-width: 1px;
padding-top: 1px;
-moz-border-top-colors: ThreeDShadow;
-moz-border-right-colors: ThreeDShadow;
-moz-border-left-colors: ThreeDShadow transparent;
background-image: url("chrome://browser/skin/tabbrowser/tab-hover-bkgnd.png");
}
.tabbrowser-arrowscrollbox > .scrollbutton-up,
.tabbrowser-arrowscrollbox > .scrollbutton-down {
-moz-image-region: rect(0, 15px, 17px, 0);
margin: 0;
padding-top: 0;
padding-bottom: 0;
}
.tabbrowser-arrowscrollbox > .scrollbutton-up:not([disabled="true"]):hover,
@ -1174,24 +1135,13 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
}
.tabbrowser-arrowscrollbox > .scrollbutton-up:-moz-locale-dir(ltr) {
border-left-style: none;
-moz-border-radius-topright: 2px;
list-style-image: url("chrome://browser/skin/tabbrowser/tab-arrow-left.png");
}
.tabbrowser-arrowscrollbox > .scrollbutton-up:-moz-locale-dir(rtl) {
border-right-style: none;
-moz-border-radius-topleft: 2px;
list-style-image: url("chrome://browser/skin/tabbrowser/tab-arrow-right.png");
}
.tabbrowser-arrowscrollbox > .scrollbutton-down:-moz-locale-dir(ltr),
.tabbrowser-tabs > .tabs-newtab-button:-moz-locale-dir(ltr),
.tabs-alltabs-button:-moz-locale-dir(ltr) {
border-right-style: none;
-moz-border-radius-topleft: 2px;
}
.tabbrowser-arrowscrollbox > .scrollbutton-down {
list-style-image: url("chrome://browser/skin/tabbrowser/tab-arrow-right.png");
-moz-transition: 1s background-color ease-out;
@ -1202,30 +1152,21 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
-moz-transition: none;
}
.tabbrowser-arrowscrollbox > .scrollbutton-down:-moz-locale-dir(rtl),
.tabbrowser-tabs > .tabs-newtab-button:-moz-locale-dir(rtl),
.tabs-alltabs-button:-moz-locale-dir(rtl) {
border-left-style: none;
-moz-border-radius-topright: 2px;
}
.tabbrowser-arrowscrollbox > .scrollbutton-down:-moz-locale-dir(rtl) {
list-style-image: url("chrome://browser/skin/tabbrowser/tab-arrow-left.png");
}
.tabs-newtab-button {
list-style-image: url(chrome://browser/skin/tabbrowser/newtab.png);
-moz-image-region: rect(0, 18px, 18px, 0);
-moz-image-region: rect(0, 16px, 18px, 0);
}
.tabs-newtab-button:hover:active {
-moz-image-region: rect(0, 36px, 18px, 18px);
-moz-image-region: rect(0, 32px, 18px, 16px);
}
.tabbrowser-arrowscrollbox > .tabs-newtab-button {
width: 31px;
-moz-border-radius-topright: 2px;
-moz-border-radius-topleft: 2px;
}
.tabs-alltabs-button > .toolbarbutton-text {
@ -1234,16 +1175,16 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
.tabs-alltabs-button > .toolbarbutton-icon {
list-style-image: url("chrome://browser/skin/tabbrowser/alltabs.png");
-moz-image-region: rect(0, 14px, 20px, 0);
-moz-image-region: rect(0, 14px, 17px, 0);
}
.tabs-alltabs-button:hover:active > .toolbarbutton-icon {
-moz-image-region: rect(0, 28px, 20px, 14px);
-moz-image-region: rect(0, 28px, 17px, 14px);
}
.tabs-alltabs-button[type="menu"] > .toolbarbutton-icon {
list-style-image: url("chrome://browser/skin/mainwindow-dropdown-arrow.png");
margin: 5px 0 4px;
margin: 3px 0;
-moz-image-region: rect(0, 13px, 11px, 0);
}
@ -1295,25 +1236,12 @@ richlistitem[type="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-i
}
.tabbrowser-tabs > .tabs-closebutton {
margin: 3px 0px 3px;
margin: 0;
padding: 4px 2px 2px;
background: -moz-dialog url("chrome://browser/skin/tabbrowser/tab-active-bkgnd.png") repeat-x;
border-left: 1px solid threedshadow;
border-top: 1px solid threedshadow;
-moz-border-radius-topleft: 2px;
}
.tabbrowser-tabs > .tabs-closebutton:-moz-locale-dir(rtl) {
border-left: none;
border-right: 1px solid threedshadow;
-moz-border-radius-topleft: 0px;
-moz-border-radius-topright: 2px;
}
#sidebar-box .tabs-closebutton {
#sidebar-header > .tabs-closebutton {
list-style-image: url("chrome://global/skin/icons/closeSidebar.png");
margin-bottom: 0px !important;
padding: 0px 2px 0px 2px !important;
}
toolbarbutton.chevron {

Просмотреть файл

@ -79,12 +79,10 @@ browser.jar:
skin/classic/browser/tabbrowser/newtab.png (tabbrowser/newtab.png)
skin/classic/browser/tabbrowser/progress.png (tabbrowser/progress.png)
skin/classic/browser/tabbrowser/progress-pulsing.png (tabbrowser/progress-pulsing.png)
skin/classic/browser/tabbrowser/tab.png (tabbrowser/tab.png)
skin/classic/browser/tabbrowser/tab-arrow-left.png (tabbrowser/tab-arrow-left.png)
skin/classic/browser/tabbrowser/tab-arrow-right.png (tabbrowser/tab-arrow-right.png)
skin/classic/browser/tabbrowser/tabDragIndicator.png (tabbrowser/tabDragIndicator.png)
skin/classic/browser/tabbrowser/tab-bkgnd.png (tabbrowser/tab-bkgnd.png)
skin/classic/browser/tabbrowser/tab-active-bkgnd.png (tabbrowser/tab-active-bkgnd.png)
skin/classic/browser/tabbrowser/tab-hover-bkgnd.png (tabbrowser/tab-hover-bkgnd.png)
#ifdef XP_WIN
browser.jar:
@ -167,10 +165,8 @@ browser.jar:
skin/classic/aero/browser/tabbrowser/newtab.png (tabbrowser/newtab-aero.png)
skin/classic/aero/browser/tabbrowser/progress.png (tabbrowser/progress.png)
skin/classic/aero/browser/tabbrowser/progress-pulsing.png (tabbrowser/progress-pulsing.png)
skin/classic/aero/browser/tabbrowser/tab.png (tabbrowser/tab.png)
skin/classic/aero/browser/tabbrowser/tab-arrow-left.png (tabbrowser/tab-arrow-left-aero.png)
skin/classic/aero/browser/tabbrowser/tab-arrow-right.png (tabbrowser/tab-arrow-right-aero.png)
skin/classic/aero/browser/tabbrowser/tabDragIndicator.png (tabbrowser/tabDragIndicator-aero.png)
skin/classic/aero/browser/tabbrowser/tab-bkgnd.png (tabbrowser/tab-bkgnd.png)
skin/classic/aero/browser/tabbrowser/tab-active-bkgnd.png (tabbrowser/tab-active-bkgnd.png)
skin/classic/aero/browser/tabbrowser/tab-hover-bkgnd.png (tabbrowser/tab-hover-bkgnd.png)
#endif

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 731 B

После

Ширина:  |  Высота:  |  Размер: 726 B

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 719 B

После

Ширина:  |  Высота:  |  Размер: 715 B

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 687 B

После

Ширина:  |  Высота:  |  Размер: 692 B

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 687 B

После

Ширина:  |  Высота:  |  Размер: 700 B

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 188 B

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 189 B

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 892 B

Двоичные данные
browser/themes/winstripe/browser/tabbrowser/tab.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 681 B

Просмотреть файл

@ -198,4 +198,6 @@ ifeq ($(OS_ARCH),Linux)
libs:: $(topsrcdir)/tools/rb/fix-linux-stack.pl
$(INSTALL) $< $(DIST)/bin
endif
GARBAGE += automationutils.pyc
endif # ENABLE_TESTS

Просмотреть файл

@ -78,4 +78,4 @@ automation.py: $(MOZILLA_DIR)/build/automation.py.in $(MOZILLA_DIR)/build/automa
$(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
$(AUTOMATION_PPARGS) $(DEFINES) $(ACDEFINES) $< > $@
GARBAGE += automation.py
GARBAGE += automation.py automation.pyc

Просмотреть файл

@ -131,6 +131,7 @@ export::
-DMOZ_NATIVE_ZLIB=$(MOZ_NATIVE_ZLIB) \
-DMOZ_NATIVE_PNG=$(MOZ_NATIVE_PNG) \
-DMOZ_NATIVE_JPEG=$(MOZ_NATIVE_JPEG) \
-DMOZ_NATIVE_LIBEVENT=$(MOZ_NATIVE_LIBEVENT) \
$(srcdir)/system-headers | $(PERL) $(topsrcdir)/nsprpub/config/make-system-wrappers.pl system_wrappers
$(INSTALL) system_wrappers $(DIST)

Просмотреть файл

@ -210,7 +210,6 @@ MOZ_RDF = @MOZ_RDF@
NECKO_PROTOCOLS = @NECKO_PROTOCOLS@
NECKO_DISK_CACHE = @NECKO_DISK_CACHE@
NECKO_SMALL_BUFFERS = @NECKO_SMALL_BUFFERS@
NECKO_COOKIES = @NECKO_COOKIES@
NECKO_WIFI = @NECKO_WIFI@
MOZ_AUTH_EXTENSION = @MOZ_AUTH_EXTENSION@
@ -219,6 +218,10 @@ MOZ_NATIVE_HUNSPELL = @SYSTEM_HUNSPELL@
MOZ_HUNSPELL_LIBS = @MOZ_HUNSPELL_LIBS@
MOZ_HUNSPELL_CFLAGS = @MOZ_HUNSPELL_CFLAGS@
MOZ_NATIVE_LIBEVENT = @MOZ_NATIVE_LIBEVENT@
MOZ_LIBEVENT_LIBS = @MOZ_LIBEVENT_LIBS@
MOZ_LIBEVENT_INCLUDES = @MOZ_LIBEVENT_INCLUDES@
MOZ_NATIVE_ZLIB = @SYSTEM_ZLIB@
MOZ_NATIVE_BZ2 = @SYSTEM_BZ2@
MOZ_NATIVE_JPEG = @SYSTEM_JPEG@

Просмотреть файл

@ -526,7 +526,7 @@ OS_COMPILE_CMMFLAGS += -fobjc-exceptions
endif
COMPILE_CFLAGS = $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CFLAGS)
COMPILE_CXXFLAGS = $(VISIBILITY_FLAGS) $(STL_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS)
COMPILE_CXXFLAGS = $(STL_FLAGS) $(VISIBILITY_FLAGS) $(DEFINES) $(INCLUDES) $(DSO_CFLAGS) $(DSO_PIC_CFLAGS) $(CXXFLAGS) $(RTL_FLAGS) $(OS_COMPILE_CXXFLAGS)
COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS)
COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS)

Просмотреть файл

@ -45,13 +45,23 @@
# error "STL code can only be used with -fno-exceptions"
#endif
// Silence "warning: #include_next is a GCC extension"
#pragma GCC system_header
// mozalloc.h wants <new>; break the cycle by always explicitly
// including <new> here. NB: this is a tad sneaky. Sez the gcc docs:
//
// `#include_next' does not distinguish between <file> and "file"
// inclusion, nor does it check that the file you specify has the
// same name as the current file. It simply looks for the file
// named, starting with the directory in the search path after the
// one where the current file was found.
#include_next <new>
// See if we're in code that can use mozalloc. NB: this duplicates
// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
// can't build with that being included before base/basictypes.h.
#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
# include <new> // to give mozalloc std::bad_alloc
# include <stdlib.h> // to give mozalloc malloc/free decls
# include <string.h>
# include "mozilla/mozalloc.h"
#else
# error "STL code can only be used with infallible ::operator new()"
@ -78,8 +88,8 @@
// these __throw_*() functions will always throw exceptions (shades of
// -fshort-wchar). We don't want that and so define our own inlined
// __throw_*().
#ifndef mozilla_functexcept_h
# include "mozilla/functexcept.h"
#ifndef mozilla_throw_gcc_h
# include "mozilla/throw_gcc.h"
#endif
#endif // if mozilla_${HEADER}_h

Просмотреть файл

@ -62,7 +62,8 @@ def main(outdir, compiler, template_file, header_list_file):
os.mkdir(outdir)
template = open(template_file, 'r').read()
path_to_new = header_path('new', compiler)
for header in open(header_list_file, 'r'):
header = header.rstrip()
if 0 == len(header) or is_comment(header):
@ -72,7 +73,8 @@ def main(outdir, compiler, template_file, header_list_file):
try:
f = open(os.path.join(outdir, header), 'w')
f.write(string.Template(template).substitute(HEADER=header,
HEADER_PATH=path))
HEADER_PATH=path,
NEW_HEADER_PATH=path_to_new))
finally:
f.close()

Просмотреть файл

@ -45,13 +45,22 @@
# error "STL code can only be used with -fno-exceptions"
#endif
// Code built with !_HAS_EXCEPTIONS calls std::_Throw(), but the win2k
// CRT doesn't export std::_Throw(). So we define it.
#ifndef mozilla_Throw_h
# include "mozilla/throw_msvc.h"
#endif
// Code might include <new> before other wrapped headers, but <new>
// includes <exception> and so we want to wrap it. But mozalloc.h
// wants <new> also, so we break the cycle by always explicitly
// including <new> here.
#include <${NEW_HEADER_PATH}>
// See if we're in code that can use mozalloc. NB: this duplicates
// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
// can't build with that being included before base/basictypes.h.
#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
# include <new> // to give mozalloc std::bad_alloc
# include <stdlib.h> // to give mozalloc malloc/free decls
# include <string.h>
# include "mozilla/mozalloc.h"
#else
# error "STL code can only be used with infallible ::operator new()"

Просмотреть файл

@ -606,15 +606,6 @@ endif
endif
endif
ifeq ($(OS_ARCH),Linux)
ifneq (,$(filter mips mipsel,$(OS_TEST)))
ifeq ($(MODULE),layout)
OS_CFLAGS += -Wa,-xgot
OS_CXXFLAGS += -Wa,-xgot
endif
endif
endif
#
# HP-UXBeOS specific section: for COMPONENTS only, add -Bsymbolic flag
# which uses internal symbols first
@ -664,6 +655,14 @@ EXTRA_DSO_LDOPTS += -Wl,-Bsymbolic
endif
endif
#
# GNU doesn't have path length limitation
#
ifeq ($(OS_ARCH),GNU)
OS_CPPFLAGS += -DPATH_MAX=1024 -DMAXPATHLEN=1024
endif
#
# MINGW32
#

Просмотреть файл

@ -12,8 +12,17 @@
# safety of <foo> for gcc and MSVC".
#
new
# FIXME: these headers haven't been reviewed yet, but we use them
# unsafely in modules/libpr0n, so we might as well prevent it from
# unsafely in Gecko, so we might as well prevent them from
# throwing exceptions
algorithm
deque
iostream
list
map
memory
stack
string
vector

Просмотреть файл

@ -1024,3 +1024,6 @@ conic/conicconnection.h
conic/conicconnectionevent.h
conic/conicstatisticsevent.h
#endif
#if MOZ_NATIVE_LIBEVENT==1
event.h
#endif

Просмотреть файл

@ -760,8 +760,43 @@ EOF
AC_DEFINE_UNQUOTED(MOZ_NTDDI_LONGHORN, 0x06000000)
AC_DEFINE_UNQUOTED(MOZ_NTDDI_WIN7, 0x06010000)
STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
WRAP_STL_INCLUDES=1
AC_CACHE_CHECK(for std::_Throw, ac_cv_have_std__Throw,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
AC_TRY_COMPILE([#include <exception>],
[std::_Throw(std::exception()); return 0;],
ac_cv_have_std__Throw="yes",
ac_cv_have_std__Throw="no")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cv_have_std__Throw" = "no"; then
AC_MSG_ERROR([Your MSVC/SDK doesn't export std::_Throw. This breaks assumptions in Gecko. Please file a bug describing this error along with your build configuration.])
fi
AC_CACHE_CHECK(for |class __declspec(dllimport) exception| bug,
ac_cv_have_dllimport_exception_bug,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="${CXXFLAGS} -D_HAS_EXCEPTIONS=0"
AC_TRY_LINK([#include <vector>],
[std::vector<int> v; return v.at(1);],
ac_cv_have_dllimport_exception_bug="no",
ac_cv_have_dllimport_exception_bug="yes")
CXXFLAGS="$_SAVE_CXXFLAGS"
AC_LANG_RESTORE
])
if test "$ac_cv_have_dllimport_exception_bug" = "no"; then
STL_FLAGS='-D_HAS_EXCEPTIONS=0 -I$(DIST)/stl_wrappers'
WRAP_STL_INCLUDES=1
fi
;;
esac
@ -1094,6 +1129,7 @@ if test -n "$CROSS_COMPILE"; then
case "${target_os}" in
linux*) OS_ARCH=Linux OS_TARGET=Linux ;;
kfreebsd*-gnu) OS_ARCH=GNU_kFreeBSD OS_TARGET=GNU_kFreeBSD ;;
gnu*) OS_ARCH=GNU ;;
solaris*) OS_ARCH=SunOS OS_RELEASE=5 ;;
mingw*) OS_ARCH=WINNT ;;
wince*) OS_ARCH=WINCE ;;
@ -1390,9 +1426,7 @@ x86_64 | ia64)
;;
arm)
if test "$OS_TARGET" = "WINCE"; then
CPU_ARCH="$OS_TEST"
fi
CPU_ARCH=arm
;;
esac
@ -1434,8 +1468,8 @@ if test "$GNU_CC"; then
if test -z "$INTEL_CC"; then
# Don't use -Wcast-align with ICC
case "$CPU_ARCH" in
# And don't use it on hppa, ia64, sparc, since it's noisy there
hppa | ia64 | sparc)
# And don't use it on hppa, ia64, sparc, arm, since it's noisy there
hppa | ia64 | sparc | arm)
;;
*)
_WARNINGS_CFLAGS="${_WARNINGS_CFLAGS} -Wcast-align"
@ -1497,8 +1531,8 @@ if test "$GNU_CXX"; then
if test -z "$INTEL_CC"; then
# Don't use -Wcast-align with ICC
case "$CPU_ARCH" in
# And don't use it on hppa, ia64, sparc, since it's noisy there
hppa | ia64 | sparc)
# And don't use it on hppa, ia64, sparc, arm, since it's noisy there
hppa | ia64 | sparc | arm)
;;
*)
_WARNINGS_CXXFLAGS="${_WARNINGS_CXXFLAGS} -Wcast-align"
@ -1738,7 +1772,7 @@ case "$host" in
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
;;
*-linux*|*-kfreebsd*-gnu)
*-linux*|*-kfreebsd*-gnu|*-gnu*)
HOST_CFLAGS="$HOST_CFLAGS -DXP_UNIX"
HOST_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
@ -2767,7 +2801,7 @@ dnl ========================================================
dnl = Flags to strip unused symbols from .so components
dnl ========================================================
case "$target" in
*-linux*|*-kfreebsd*-gnu)
*-linux*|*-kfreebsd*-gnu|*-gnu*)
MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS='-Wl,--version-script -Wl,$(BUILD_TOOLS)/gnu-ld-scripts/components-version-script'
;;
*-solaris*)
@ -3550,7 +3584,7 @@ then
fi
;;
*-*-linux*|*-*-kfreebsd*-gnu)
*-*-linux*|*-*-kfreebsd*-gnu|*-*-gnu*)
AC_DEFINE(_REENTRANT)
;;
@ -3947,8 +3981,30 @@ dnl Put your C++ language/feature checks below
dnl ========================================================
AC_LANG_CPLUSPLUS
ARM_ABI_PREFIX=
HAVE_GCC3_ABI=
if test "$GNU_CC"; then
if test "$CPU_ARCH" = "arm" ; then
AC_CACHE_CHECK(for ARM EABI,
ac_cv_gcc_arm_eabi,
[AC_TRY_COMPILE([],
[
#if defined(__ARM_EABI__)
return 0;
#else
#error Not ARM EABI.
#endif
],
ac_cv_gcc_arm_eabi="yes",
ac_cv_gcc_arm_eabi="no")])
if test "$ac_cv_gcc_arm_eabi" = "yes"; then
HAVE_ARM_EABI=1
ARM_ABI_PREFIX=eabi-
else
ARM_ABI_PREFIX=oabi-
fi
fi
AC_CACHE_CHECK(for gcc 3.0 ABI,
ac_cv_gcc_three_abi,
[AC_TRY_COMPILE([],
@ -3962,10 +4018,10 @@ if test "$GNU_CC"; then
ac_cv_gcc_three_abi="yes",
ac_cv_gcc_three_abi="no")])
if test "$ac_cv_gcc_three_abi" = "yes"; then
TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-gcc3}"
TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc3}"
HAVE_GCC3_ABI=1
else
TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-gcc2}"
TARGET_COMPILER_ABI="${TARGET_COMPILER_ABI-${ARM_ABI_PREFIX}gcc2}"
fi
fi
AC_SUBST(HAVE_GCC3_ABI)
@ -4268,7 +4324,16 @@ AC_CACHE_CHECK(for __thread keyword for TLS variables,
ac_cv_thread_keyword=no)])
LDFLAGS=$_SAVE_LDFLAGS
if test "$ac_cv_thread_keyword" = yes; then
AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
# mips builds fail with TLS variables because of a binutils bug.
# See bug 528687
case "${target_cpu}" in
mips*)
:
;;
*)
AC_DEFINE(HAVE_THREAD_TLS_KEYWORD)
;;
esac
fi
dnl Check for the existence of various allocation headers/functions
@ -4469,6 +4534,43 @@ else
fi
fi
dnl system libevent Support
dnl ========================================================
MOZ_ARG_WITH_STRING(system-libevent,
[ --with-system-libevent=[PFX]
Use system libevent [installed at prefix PFX]],
LIBEVENT_DIR=$withval)
_SAVE_CFLAGS=$CFLAGS
_SAVE_LDFLAGS=$LDFLAGS
_SAVE_LIBS=$LIBS
if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then
MOZ_NATIVE_LIBEVENT=
else
if test "${LIBEVENT_DIR}" = "yes"; then
LIBEVENT_DIR=/usr
fi
CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS"
LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS"
AC_CHECK_HEADER(event.h,
[if test ! -f "${LIBEVENT_DIR}/include/event.h"; then
AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include])
fi],
AC_MSG_ERROR([--with-system-libevent requested but event.h not found]))
AC_CHECK_LIB(event, event_init,
[MOZ_NATIVE_LIBEVENT=1
MOZ_LIBEVENT_INCLUDES="${LIBEVENT_DIR}/include"
MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"],
[MOZ_NATIVE_LIBEVENT= MOZ_LIBEVENT_INCLUDES= MOZ_LIBEVENT_LIBS=])
fi
CFLAGS=$_SAVE_CFLAGS
LDFLAGS=$_SAVE_LDFLAGS
LIBS=$_SAVE_LIBS
AC_SUBST(MOZ_NATIVE_LIBEVENT)
AC_SUBST(MOZ_LIBEVENT_INCLUDES)
AC_SUBST(MOZ_LIBEVENT_LIBS)
dnl ========================================================
dnl = If NSS was not detected in the system,
dnl = use the one in the source tree (mozilla/security/nss)
@ -4769,7 +4871,6 @@ NECKO_WIFI=1
NECKO_COOKIES=1
NECKO_DISK_CACHE=1
NECKO_PROTOCOLS_DEFAULT="about data file ftp gopher http res viewsource"
NECKO_SMALL_BUFFERS=
BUILD_CTYPES=1
XPC_IDISPATCH_SUPPORT=
@ -7135,6 +7236,19 @@ if test -n "$MOZ_TIMELINE"; then
AC_DEFINE(MOZ_TIMELINE)
fi
dnl ========================================================
dnl = Enable NS_FUNCTION_TIMER, which provides Function
dnl = timing for identifying code bottlenecks
dnl = NS_FUNCTION_TIMER is off by default.
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(functiontimer,
[ --enable-functiontimer Enable NS_FUNCTION_TIMER ],
NS_FUNCTION_TIMER=1,
NS_FUNCTION_TIMER= )
if test -n "$NS_FUNCTION_TIMER"; then
AC_DEFINE(NS_FUNCTION_TIMER)
fi
dnl ========================================================
dnl Turn on reflow counting
dnl ========================================================
@ -8099,19 +8213,6 @@ if test "$NECKO_WIFI"; then
fi
AC_SUBST(NECKO_WIFI)
dnl
dnl option to minimize size of necko's i/o buffers
dnl
MOZ_ARG_ENABLE_BOOL(necko-small-buffers,
[ --enable-necko-small-buffers
Minimize size of necko's i/o buffers],
NECKO_SMALL_BUFFERS=1,
NECKO_SMALL_BUFFERS=)
AC_SUBST(NECKO_SMALL_BUFFERS)
if test "$NECKO_SMALL_BUFFERS"; then
AC_DEFINE(NECKO_SMALL_BUFFERS)
fi
dnl
dnl option to disable cookies
dnl

Просмотреть файл

@ -107,7 +107,7 @@ XPIDLSRCS = \
nsISelectionPrivate.idl \
nsIScriptLoaderObserver.idl \
nsISyncLoadDOMService.idl \
nsIDragDropHandler.idl \
nsIDroppedLinkHandler.idl \
nsIScriptEventHandler.idl \
nsIScriptEventManager.idl \
nsIImageLoadingContent.idl \

Просмотреть файл

@ -71,8 +71,8 @@ enum nsLinkState {
// IID for the nsIContent interface
#define NS_ICONTENT_IID \
{ 0x07734640, 0x0900, 0x480d, \
{ 0x97, 0x5a, 0x31, 0xc7, 0x0e, 0xcd, 0x15, 0x2b } }
{ 0x9d15dea4, 0xa112, 0x40f4, \
{ 0xbd, 0xa9, 0x23, 0xc0, 0xed, 0xde, 0x08, 0x9c } }
/**
* A node of content in a document's content model. This interface
@ -642,6 +642,14 @@ public:
*/
virtual nsIContent *GetBindingParent() const = 0;
/**
* Returns the content node that is the parent of this node in the flattened
* tree.
*
* @return the flattened tree parent
*/
nsIContent *GetFlattenedTreeParent() const;
/**
* Get the base URI for any relative URIs within this piece of
* content. Generally, this is the document's base URI, but certain

Просмотреть файл

@ -115,8 +115,8 @@ class Link;
} // namespace mozilla
#define NS_IDOCUMENT_IID \
{ 0x3e162645, 0x4827, 0x4600, \
{ 0x9c, 0xaa, 0xe8, 0xdd, 0xcb, 0x05, 0xfd, 0x85 } }
{ 0x17e1c0ce, 0x3883, 0x4efc, \
{ 0xbf, 0xdf, 0x40, 0xa6, 0x26, 0x9f, 0xbd, 0x2c } }
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -641,7 +641,10 @@ public:
* this document. If you're not absolutely sure you need this, use
* GetWindow().
*/
virtual nsPIDOMWindow *GetInnerWindow() = 0;
nsPIDOMWindow* GetInnerWindow()
{
return mRemovedFromDocShell ? GetInnerWindowInternal() : mWindow;
}
/**
* Get the script loader for this document
@ -1353,6 +1356,9 @@ protected:
// want to expose to users of the nsIDocument API outside of Gecko.
}
// Never ever call this. Only call GetInnerWindow!
virtual nsPIDOMWindow *GetInnerWindowInternal() = 0;
/**
* These methods should be called before and after dispatching
* a mutation event.
@ -1486,6 +1492,10 @@ protected:
PRUint32 mEventsSuppressed;
nsString mPendingStateObject;
// Weak reference to mScriptGlobalObject QI:d to nsPIDOMWindow,
// updated on every set of mSecriptGlobalObject.
nsPIDOMWindow *mWindow;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocument, NS_IDOCUMENT_IID)

Просмотреть файл

@ -0,0 +1,70 @@
/* ***** 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 the Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Neil Deakin <enndeakin@gmail.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 ***** */
#include "nsISupports.idl"
interface nsIDOMDragEvent;
interface nsIURI;
[scriptable, uuid(F266B79B-7026-4D2D-B4BD-4F2C6B6C59B4)]
interface nsIDroppedLinkHandler : nsISupports
{
/**
* Determines if a link being dragged can be dropped and returns true if so.
* aEvent should be a dragenter or dragover event.
*
* If aAllowSameDocument is false, drops are only allowed if the document
* of the source of the drag is different from the destination. This check
* includes any parent, sibling and child frames in the same content tree.
* If true, the source is not checked.
*/
boolean canDropLink(in nsIDOMDragEvent aEvent, in PRBool aAllowSameDocument);
/**
* Given a drop event aEvent, determines the link being dragged and returns
* it. If a uri is returned the caller can, for instance, load it. If null
* is returned, there is no valid link to be dropped. A
* NS_ERROR_DOM_SECURITY_ERR error will be thrown and the event cancelled if
* the receiving target should not load the uri for security reasons. This
* will occur if the source of the drag initiated a link for dragging that
* it itself cannot access. This prevents a source document from tricking
* the user into a dragging a chrome url for example.
*
* aName is filled in with the link title if it exists, or an empty string
* otherwise.
*/
AString dropLink(in nsIDOMDragEvent aEvent, out AString aName);
};

Просмотреть файл

@ -145,8 +145,17 @@ enum {
NODE_ATTACH_BINDING_ON_POSTCREATE
= 0x00040000U,
// This node needs to go through frame construction to get a frame (or
// undisplayed entry).
NODE_NEEDS_FRAME = 0x00080000U,
// At least one descendant in the flattened tree has NODE_NEEDS_FRAME set.
// This should be set on every node on the flattened tree path between the
// node(s) with NODE_NEEDS_FRAME and the root content.
NODE_DESCENDANTS_NEED_FRAMES = 0x00100000U,
// Four bits for the script-type ID
NODE_SCRIPT_TYPE_OFFSET = 20,
NODE_SCRIPT_TYPE_OFFSET = 21,
NODE_SCRIPT_TYPE_SIZE = 4,
@ -242,9 +251,9 @@ private:
// IID for the nsINode interface
#define NS_INODE_IID \
{ 0xe71b48a8, 0xeead, 0x4320, \
{ 0xb4, 0xb0, 0x15, 0xcd, 0x7c, 0x53, 0x96, 0x8c } }
{ 0xbc347b50, 0xa9b8, 0x419e, \
{ 0xb1, 0x21, 0x76, 0x8f, 0x90, 0x05, 0x8d, 0xbf } }
/**
* An internal interface that abstracts some DOMNode-related parts that both
* nsIContent and nsIDocument share. An instance of this interface has a list
@ -765,7 +774,9 @@ public:
NS_ASSERTION(!(aFlagsToSet & (NODE_IS_ANONYMOUS |
NODE_IS_NATIVE_ANONYMOUS_ROOT |
NODE_IS_IN_ANONYMOUS_SUBTREE |
NODE_ATTACH_BINDING_ON_POSTCREATE)) ||
NODE_ATTACH_BINDING_ON_POSTCREATE |
NODE_DESCENDANTS_NEED_FRAMES |
NODE_NEEDS_FRAME)) ||
IsNodeOfType(eCONTENT),
"Flag only permitted on nsIContent nodes");
PtrBits* flags = HasSlots() ? &FlagsAsSlots()->mFlags :

Просмотреть файл

@ -155,6 +155,7 @@ FORCE_STATIC_LIB = 1
EXTRA_COMPONENTS = \
$(srcdir)/nsBadCertHandler.js \
contentSecurityPolicy.js \
contentAreaDropListener.js \
$(NULL)
EXTRA_JS_MODULES = \

Просмотреть файл

@ -0,0 +1,150 @@
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const Cc = Components.classes;
const Ci = Components.interfaces;
// This component is used for handling dragover and drop of urls.
//
// It checks to see whether a drop of a url is allowed. For instance, a url
// cannot be dropped if it is not a valid uri or the source of the drag cannot
// access the uri. This prevents, for example, a source document from tricking
// the user into dragging a chrome url.
function ContentAreaDropListener() { };
ContentAreaDropListener.prototype =
{
classDescription: "A component that handles dragover and drop events on a content area",
classID: Components.ID("{1f34bc80-1bc7-11d6-a384-d705dd0746fc}"),
contractID: "@mozilla.org/content/dropped-link-handler;1",
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDroppedLinkHandler, Ci.nsISupports]),
_getDropURL : function (dt)
{
let types = dt.types;
for (let t = 0; t < types.length; t++) {
let type = types[t];
switch (type) {
case "text/uri-list":
var url = dt.getData("URL").replace(/^\s+|\s+$/g, "");
return [url, url];
case "text/plain":
case "text/x-moz-text-internal":
var url = dt.getData(type).replace(/^\s+|\s+$/g, "");
return [url, url];
case "text/x-moz-url":
return dt.getData(type).split("\n");
}
}
// For shortcuts, we want to check for the file type last, so that the
// url pointed to in one of the url types is found first before the file
// type, which points to the actual file.
let file = dt.mozGetDataAt("application/x-moz-file", 0);
if (file instanceof Ci.nsIFile) {
let ioService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
let fileHandler = ioService.getProtocolHandler("file")
.QueryInterface(Ci.nsIFileProtocolHandler);
return [fileHandler.getURLSpecFromFile(file), file.leafName];
}
return [ ];
},
_validateURI: function(dataTransfer, uriString)
{
if (!uriString)
return "";
// Strip leading and trailing whitespace, then try to create a
// URI from the dropped string. If that succeeds, we're
// dropping a URI and we need to do a security check to make
// sure the source document can load the dropped URI.
uriString = uriString.replace(/^\s*|\s*$/g, '');
let uri;
try {
// Check that the uri is valid first and return an empty string if not.
// It may just be plain text and should be ignored here
uri = Cc["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService).
newURI(uriString, null, null);
} catch (ex) { }
if (!uri)
return uriString;
// uriString is a valid URI, so do the security check.
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager);
let sourceNode = dataTransfer.mozSourceNode;
// Use file:/// as the default uri so that drops of file URIs are always allowed
if (sourceNode)
secMan.checkLoadURIStrWithPrincipal(sourceNode.nodePrincipal, uriString, secMan.STANDARD);
else
secMan.checkLoadURIStr("file:///", uriString, secMan.STANDARD);
return uriString;
},
canDropLink: function(aEvent, aAllowSameDocument)
{
let dataTransfer = aEvent.dataTransfer;
let types = dataTransfer.types;
if (!types.contains("application/x-moz-file") &&
!types.contains("text/x-moz-url") &&
!types.contains("text/uri-list") &&
!types.contains("text/x-moz-text-internal") &&
!types.contains("text/plain"))
return false;
if (aAllowSameDocument)
return true;
let sourceNode = dataTransfer.mozSourceNode;
if (!sourceNode)
return true;
// don't allow a drop of a node from the same document onto this one
let sourceDocument = sourceNode.ownerDocument;
let eventDocument = aEvent.originalTarget.ownerDocument;
if (sourceDocument == eventDocument)
return false;
// also check for nodes in other child or sibling frames by checking
// if both have the same top window.
if (sourceDocument && eventDocument) {
let sourceRoot = sourceDocument.defaultView.top;
if (sourceRoot && sourceRoot == eventDocument.defaultView.top)
return false;
}
return true;
},
dropLink: function(aEvent, aName)
{
aName.value = "";
let dataTransfer = aEvent.dataTransfer;
let [url, name] = this._getDropURL(dataTransfer);
try {
url = this._validateURI(dataTransfer, url);
} catch (ex) {
aEvent.stopPropagation();
aEvent.preventDefault();
throw ex;
}
if (name)
aName.value = name;
return url;
}
};
var components = [ContentAreaDropListener];
function NSGetModule(compMgr, fileSpec) {
return XPCOMUtils.generateModule(components);
}

Просмотреть файл

@ -65,8 +65,6 @@
#include "nsIDOMHTMLAreaElement.h"
#include "nsIDOMHTMLAnchorElement.h"
#include "nsITransferable.h"
#include "nsIDragService.h"
#include "nsIDragSession.h"
#include "nsComponentManagerUtils.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
@ -96,7 +94,6 @@
#include "nsDOMDataTransfer.h"
#include "nsISelectionController.h"
#include "nsFrameSelection.h"
#include "nsIDOMEventTarget.h"
#include "nsWidgetsCID.h"
static NS_DEFINE_CID(kHTMLConverterCID, NS_HTMLFORMATCONVERTER_CID);
@ -106,23 +103,13 @@ static NS_DEFINE_CID(kHTMLConverterCID, NS_HTMLFORMATCONVERTER_CID);
#define kHTMLInfo "text/_moz_htmlinfo"
NS_IMPL_ADDREF(nsContentAreaDragDrop)
NS_IMPL_RELEASE(nsContentAreaDragDrop)
NS_INTERFACE_MAP_BEGIN(nsContentAreaDragDrop)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMEventListener)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
NS_INTERFACE_MAP_ENTRY(nsIDragDropHandler)
NS_INTERFACE_MAP_END
class NS_STACK_CLASS nsTransferableFactory
class NS_STACK_CLASS DragDataProducer
{
public:
nsTransferableFactory(nsIDOMWindow* aWindow,
nsIContent* aTarget,
nsIContent* aSelectionTargetNode,
PRBool aIsAltKeyPressed);
DragDataProducer(nsIDOMWindow* aWindow,
nsIContent* aTarget,
nsIContent* aSelectionTargetNode,
PRBool aIsAltKeyPressed);
nsresult Produce(nsDOMDataTransfer* aDataTransfer,
PRBool* aCanDrag,
PRBool* aDragSelection,
@ -173,382 +160,6 @@ private:
};
//
// nsContentAreaDragDrop ctor
//
nsContentAreaDragDrop::nsContentAreaDragDrop()
: mNavigator(nsnull)
{
} // ctor
//
// ChromeTooltipListener dtor
//
nsContentAreaDragDrop::~nsContentAreaDragDrop()
{
RemoveDragListener();
} // dtor
NS_IMETHODIMP
nsContentAreaDragDrop::HookupTo(nsIDOMEventTarget *inAttachPoint,
nsIWebNavigation* inNavigator)
{
NS_ASSERTION(inAttachPoint, "Can't hookup Drag Listeners to NULL receiver");
mEventTarget = inAttachPoint;
mNavigator = inNavigator;
return AddDragListener();
}
NS_IMETHODIMP
nsContentAreaDragDrop::Detach()
{
return RemoveDragListener();
}
//
// AddDragListener
//
// Subscribe to the events that will allow us to track drags.
//
nsresult
nsContentAreaDragDrop::AddDragListener()
{
if (mEventTarget) {
nsresult rv = mEventTarget->AddEventListener(NS_LITERAL_STRING("dragover"),
this, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
rv = mEventTarget->AddEventListener(NS_LITERAL_STRING("drop"), this,
PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
}
//
// RemoveDragListener
//
// Unsubscribe from all the various drag events that we were listening to.
//
nsresult
nsContentAreaDragDrop::RemoveDragListener()
{
if (mEventTarget) {
nsresult rv =
mEventTarget->RemoveEventListener(NS_LITERAL_STRING("dragover"), this,
PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
rv = mEventTarget->RemoveEventListener(NS_LITERAL_STRING("drop"), this,
PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
mEventTarget = nsnull;
}
return NS_OK;
}
//
// DragOver
//
// Called when an OS drag is in process and the mouse is over a gecko
// window. The main purpose of this routine is to set the |canDrop|
// property on the drag session to false if we want to disallow the
// drop so that the OS can provide the appropriate feedback. All this
// does is show feedback, it doesn't actually cancel the drop; that
// comes later.
//
nsresult
nsContentAreaDragDrop::DragOver(nsIDOMDragEvent* inEvent)
{
// first check that someone hasn't already handled this event
PRBool preventDefault = PR_TRUE;
nsCOMPtr<nsIDOMNSUIEvent> nsuiEvent(do_QueryInterface(inEvent));
if ( nsuiEvent )
nsuiEvent->GetPreventDefault(&preventDefault);
if ( preventDefault )
return NS_OK;
// if the drag originated w/in this content area, bail
// early. This avoids loading a URL dragged from the content
// area into the very same content area (which is almost never
// the desired action).
nsCOMPtr<nsIDragSession> session = nsContentUtils::GetDragSession();
NS_ENSURE_TRUE(session, NS_OK);
PRBool dropAllowed = PR_TRUE;
nsCOMPtr<nsIDOMDocument> sourceDoc;
session->GetSourceDocument(getter_AddRefs(sourceDoc));
nsCOMPtr<nsIDOMDocument> eventDoc;
GetEventDocument(inEvent, getter_AddRefs(eventDoc));
if (sourceDoc == eventDoc) { // common case
dropAllowed = PR_FALSE;
} else if (sourceDoc && eventDoc) {
// dig deeper
// XXXbz we need better ways to get from a document to the docshell!
nsCOMPtr<nsIDocument> sourceDocument(do_QueryInterface(sourceDoc));
nsCOMPtr<nsIDocument> eventDocument(do_QueryInterface(eventDoc));
NS_ASSERTION(sourceDocument, "Confused document object");
NS_ASSERTION(eventDocument, "Confused document object");
nsPIDOMWindow* sourceWindow = sourceDocument->GetWindow();
nsPIDOMWindow* eventWindow = eventDocument->GetWindow();
if (sourceWindow && eventWindow) {
nsCOMPtr<nsIDocShellTreeItem> sourceShell =
do_QueryInterface(sourceWindow->GetDocShell());
nsCOMPtr<nsIDocShellTreeItem> eventShell =
do_QueryInterface(eventWindow->GetDocShell());
if (sourceShell && eventShell) {
// Whew. Almost there. Get the roots that are of the same type
// (otherwise we'll always end up with the root docshell for the
// window, and drag/drop from chrom to content won't work).
nsCOMPtr<nsIDocShellTreeItem> sourceRoot;
nsCOMPtr<nsIDocShellTreeItem> eventRoot;
sourceShell->GetSameTypeRootTreeItem(getter_AddRefs(sourceRoot));
eventShell->GetSameTypeRootTreeItem(getter_AddRefs(eventRoot));
if (sourceRoot && sourceRoot == eventRoot) {
dropAllowed = PR_FALSE;
}
}
}
}
session->SetCanDrop(dropAllowed);
return NS_OK;
}
//
// ExtractURLFromData
//
// build up a url from whatever data we get from the OS. How we
// interpret the data depends on the flavor as it tells us the
// nsISupports* primitive type we have.
//
void
nsContentAreaDragDrop::ExtractURLFromData(const nsACString & inFlavor,
nsISupports* inDataWrapper,
PRUint32 inDataLen,
nsAString & outURL)
{
if (!inDataWrapper) {
return;
}
outURL.Truncate();
if (inFlavor.Equals(kUnicodeMime) || inFlavor.Equals(kURLDataMime)) {
// the data is regular unicode, just go with what we get. It may
// be a url, it may not be. *shrug*
nsCOMPtr<nsISupportsString> stringData(do_QueryInterface(inDataWrapper));
if (stringData) {
stringData->GetData(outURL);
}
}
else if (inFlavor.Equals(kURLMime)) {
// the data is an internet shortcut of the form
// <url>\n<title>. Strip out the url piece and return that.
nsCOMPtr<nsISupportsString> stringData(do_QueryInterface(inDataWrapper));
if (stringData) {
nsAutoString data;
stringData->GetData(data);
PRInt32 separator = data.FindChar('\n');
if (separator >= 0)
outURL = Substring(data, 0, separator);
else
outURL = data;
}
}
else if (inFlavor.Equals(kFileMime)) {
// the data is a file. Use the necko parsing utils to get a file:// url
// from the OS data.
nsCOMPtr<nsIFile> file(do_QueryInterface(inDataWrapper));
if (file) {
nsCAutoString url;
NS_GetURLSpecFromFile(file, url);
CopyUTF8toUTF16(url, outURL);
}
}
}
//
// drop
//
// Called when an OS drag is in process and the mouse is released a
// gecko window. Extract the data from the OS and do something with
// it.
//
nsresult
nsContentAreaDragDrop::Drop(nsIDOMDragEvent* inDragEvent)
{
// if we don't have a nsIWebNavigation object to do anything with,
// just bail. The client will have to have another way to deal with it
if (!mNavigator) {
return NS_OK;
}
// check that someone hasn't already handled this event
PRBool preventDefault = PR_TRUE;
nsCOMPtr<nsIDOMNSUIEvent> nsuiEvent(do_QueryInterface(inDragEvent));
if (nsuiEvent) {
nsuiEvent->GetPreventDefault(&preventDefault);
}
if (preventDefault) {
return NS_OK;
}
// pull the transferable out of the drag service. at the moment, we
// only care about the first item of the drag. We don't allow
// dropping multiple items into a content area.
nsCOMPtr<nsIDragSession> session = nsContentUtils::GetDragSession();
NS_ENSURE_TRUE(session, NS_OK);
nsCOMPtr<nsITransferable> trans =
do_CreateInstance("@mozilla.org/widget/transferable;1");
if (!trans) {
return NS_ERROR_FAILURE;
}
// add the relevant flavors. order is important (highest fidelity to lowest)
trans->AddDataFlavor(kURLDataMime);
trans->AddDataFlavor(kURLMime);
trans->AddDataFlavor(kFileMime);
trans->AddDataFlavor(kUnicodeMime);
// again, we only care about the first object
nsresult rv = session->GetData(trans, 0);
if (NS_SUCCEEDED(rv)) {
nsXPIDLCString flavor;
nsCOMPtr<nsISupports> dataWrapper;
PRUint32 dataLen = 0;
rv = trans->GetAnyTransferData(getter_Copies(flavor),
getter_AddRefs(dataWrapper), &dataLen);
if (NS_SUCCEEDED(rv) && dataLen > 0) {
// get the url from one of several possible formats
nsAutoString url;
ExtractURLFromData(flavor, dataWrapper, dataLen, url);
NS_ASSERTION(!url.IsEmpty(), "Didn't get anything we can use as a url");
// valid urls don't have spaces. bail if this does.
if (url.IsEmpty() || url.FindChar(' ') >= 0)
return NS_OK;
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), url);
if (!uri) {
// Not actually a URI
return NS_OK;
}
nsCOMPtr<nsIDOMDocument> sourceDocument;
session->GetSourceDocument(getter_AddRefs(sourceDocument));
nsCOMPtr<nsIDocument> sourceDoc(do_QueryInterface(sourceDocument));
if (sourceDoc) {
rv = nsContentUtils::GetSecurityManager()->
CheckLoadURIWithPrincipal(sourceDoc->NodePrincipal(), uri,
nsIScriptSecurityManager::STANDARD);
if (NS_FAILED(rv)) {
// Security check failed, stop event propagation right here
// and return the error.
inDragEvent->StopPropagation();
return rv;
}
}
// ok, we have the url, load it.
mNavigator->LoadURI(url.get(), nsIWebNavigation::LOAD_FLAGS_NONE, nsnull,
nsnull, nsnull);
}
}
return NS_OK;
}
//
// NormalizeSelection
//
void
nsContentAreaDragDrop::NormalizeSelection(nsIDOMNode* inBaseNode,
nsISelection* inSelection)
{
nsCOMPtr<nsIDOMNode> parent;
inBaseNode->GetParentNode(getter_AddRefs(parent));
if (!parent || !inSelection)
return;
nsCOMPtr<nsIDOMNodeList> childNodes;
parent->GetChildNodes(getter_AddRefs(childNodes));
if (!childNodes)
return;
PRUint32 listLen = 0;
childNodes->GetLength(&listLen);
PRUint32 index = 0;
for (; index < listLen; ++index) {
nsCOMPtr<nsIDOMNode> indexedNode;
childNodes->Item(index, getter_AddRefs(indexedNode));
if (indexedNode == inBaseNode) {
break;
}
}
if (index >= listLen) {
return;
}
// now make the selection contain all of |inBaseNode|'s siblings up
// to and including |inBaseNode|
inSelection->Collapse(parent, index);
inSelection->Extend(parent, index+1);
}
//
// GetEventDocument
//
// Get the DOM document associated with a given DOM event
//
void
nsContentAreaDragDrop::GetEventDocument(nsIDOMEvent* inEvent,
nsIDOMDocument** outDocument)
{
*outDocument = nsnull;
nsCOMPtr<nsIDOMUIEvent> uiEvent(do_QueryInterface(inEvent));
if (uiEvent) {
nsCOMPtr<nsIDOMAbstractView> view;
uiEvent->GetView(getter_AddRefs(view));
nsCOMPtr<nsIDOMWindow> window(do_QueryInterface(view));
if (window) {
window->GetDocument(outDocument);
}
}
}
nsresult
nsContentAreaDragDrop::GetDragData(nsIDOMWindow* aWindow,
nsIContent* aTarget,
@ -563,33 +174,12 @@ nsContentAreaDragDrop::GetDragData(nsIDOMWindow* aWindow,
*aCanDrag = PR_TRUE;
nsTransferableFactory
factory(aWindow, aTarget, aSelectionTargetNode, aIsAltKeyPressed);
return factory.Produce(aDataTransfer, aCanDrag, aDragSelection, aDragNode);
DragDataProducer
provider(aWindow, aTarget, aSelectionTargetNode, aIsAltKeyPressed);
return provider.Produce(aDataTransfer, aCanDrag, aDragSelection, aDragNode);
}
NS_IMETHODIMP
nsContentAreaDragDrop::HandleEvent(nsIDOMEvent *event)
{
// make sure it's a drag event
nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(event);
if (dragEvent) {
nsAutoString eventType;
event->GetType(eventType);
if (eventType.EqualsLiteral("dragover"))
return DragOver(dragEvent);
if (eventType.EqualsLiteral("drop"))
return Drop(dragEvent);
}
return NS_OK;
}
#if 0
#pragma mark -
#endif
NS_IMPL_ISUPPORTS1(nsContentAreaDragDropDataProvider, nsIFlavorDataProvider)
// SaveURIToFile
@ -703,14 +293,15 @@ nsContentAreaDragDropDataProvider::GetFlavorData(nsITransferable *aTransferable,
return rv;
}
nsTransferableFactory::nsTransferableFactory(nsIDOMWindow* aWindow,
nsIContent* aTarget,
nsIContent* aSelectionTargetNode,
PRBool aIsAltKeyPressed)
DragDataProducer::DragDataProducer(nsIDOMWindow* aWindow,
nsIContent* aTarget,
nsIContent* aSelectionTargetNode,
PRBool aIsAltKeyPressed)
: mWindow(aWindow),
mTarget(aTarget),
mSelectionTargetNode(aSelectionTargetNode),
mIsAltKeyPressed(aIsAltKeyPressed)
mIsAltKeyPressed(aIsAltKeyPressed),
mIsAnchor(PR_FALSE)
{
}
@ -723,7 +314,7 @@ nsTransferableFactory::nsTransferableFactory(nsIDOMWindow* aWindow,
// return null.
//
already_AddRefed<nsIContent>
nsTransferableFactory::FindParentLinkNode(nsIContent* inNode)
DragDataProducer::FindParentLinkNode(nsIContent* inNode)
{
nsIContent* content = inNode;
if (!content) {
@ -746,7 +337,7 @@ nsTransferableFactory::FindParentLinkNode(nsIContent* inNode)
// GetAnchorURL
//
void
nsTransferableFactory::GetAnchorURL(nsIContent* inNode, nsAString& outURL)
DragDataProducer::GetAnchorURL(nsIContent* inNode, nsAString& outURL)
{
nsCOMPtr<nsIURI> linkURI;
if (!inNode || !inNode->IsLink(getter_AddRefs(linkURI))) {
@ -768,9 +359,9 @@ nsTransferableFactory::GetAnchorURL(nsIContent* inNode, nsAString& outURL)
// <a href="inURL">inText</a>
//
void
nsTransferableFactory::CreateLinkText(const nsAString& inURL,
const nsAString & inText,
nsAString& outLinkText)
DragDataProducer::CreateLinkText(const nsAString& inURL,
const nsAString & inText,
nsAString& outLinkText)
{
// use a temp var in case |inText| is the same string as
// |outLinkText| to avoid overwriting it while building up the
@ -791,8 +382,8 @@ nsTransferableFactory::CreateLinkText(const nsAString& inURL,
// Gets the text associated with a node
//
void
nsTransferableFactory::GetNodeString(nsIContent* inNode,
nsAString & outNodeString)
DragDataProducer::GetNodeString(nsIContent* inNode,
nsAString & outNodeString)
{
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(inNode);
@ -814,10 +405,10 @@ nsTransferableFactory::GetNodeString(nsIContent* inNode,
nsresult
nsTransferableFactory::Produce(nsDOMDataTransfer* aDataTransfer,
PRBool* aCanDrag,
PRBool* aDragSelection,
nsIContent** aDragNode)
DragDataProducer::Produce(nsDOMDataTransfer* aDataTransfer,
PRBool* aCanDrag,
PRBool* aDragSelection,
nsIContent** aDragNode)
{
NS_PRECONDITION(aCanDrag && aDragSelection && aDataTransfer && aDragNode,
"null pointer passed to Produce");
@ -828,8 +419,6 @@ nsTransferableFactory::Produce(nsDOMDataTransfer* aDataTransfer,
nsIContent* dragNode = nsnull;
mIsAnchor = PR_FALSE;
// find the selection to see what we could be dragging and if
// what we're dragging is in what is selected.
nsCOMPtr<nsISelection> selection;
@ -1091,13 +680,6 @@ nsTransferableFactory::Produce(nsDOMDataTransfer* aDataTransfer,
kUnicodeMime, getter_AddRefs(text), &textLen);
NS_ENSURE_TRUE(text, NS_ERROR_FAILURE);
text->GetData(mTitleString);
#ifdef CHANGE_SELECTION_ON_DRAG
// We used to change the selection to wrap the dragged node (mainly
// to work around now-fixed issues with dragging unselected elements).
// There is no reason to do this any more.
NormalizeSelection(selectionNormalizeNode, selection);
#endif
}
// default text value is the URL
@ -1120,10 +702,10 @@ nsTransferableFactory::Produce(nsDOMDataTransfer* aDataTransfer,
}
void
nsTransferableFactory::AddString(nsDOMDataTransfer* aDataTransfer,
const nsAString& aFlavor,
const nsAString& aData,
nsIPrincipal* aPrincipal)
DragDataProducer::AddString(nsDOMDataTransfer* aDataTransfer,
const nsAString& aFlavor,
const nsAString& aData,
nsIPrincipal* aPrincipal)
{
nsCOMPtr<nsIWritableVariant> variant = do_CreateInstance(NS_VARIANT_CONTRACTID);
if (variant) {
@ -1133,8 +715,8 @@ nsTransferableFactory::AddString(nsDOMDataTransfer* aDataTransfer,
}
nsresult
nsTransferableFactory::AddStringsToDataTransfer(nsIContent* aDragNode,
nsDOMDataTransfer* aDataTransfer)
DragDataProducer::AddStringsToDataTransfer(nsIContent* aDragNode,
nsDOMDataTransfer* aDataTransfer)
{
NS_ASSERTION(aDragNode, "adding strings for null node");
@ -1215,10 +797,10 @@ nsTransferableFactory::AddStringsToDataTransfer(nsIContent* aDragNode,
// note that this can return NS_OK, but a null out param (by design)
// static
nsresult
nsTransferableFactory::GetDraggableSelectionData(nsISelection* inSelection,
nsIContent* inRealTargetNode,
nsIContent **outImageOrLinkNode,
PRBool* outDragSelectedText)
DragDataProducer::GetDraggableSelectionData(nsISelection* inSelection,
nsIContent* inRealTargetNode,
nsIContent **outImageOrLinkNode,
PRBool* outDragSelectedText)
{
NS_ENSURE_ARG(inSelection);
NS_ENSURE_ARG(inRealTargetNode);
@ -1287,8 +869,9 @@ nsTransferableFactory::GetDraggableSelectionData(nsISelection* inSelection,
}
// static
void nsTransferableFactory::GetSelectedLink(nsISelection* inSelection,
nsIContent **outLinkNode)
void
DragDataProducer::GetSelectedLink(nsISelection* inSelection,
nsIContent **outLinkNode)
{
*outLinkNode = nsnull;
@ -1401,11 +984,11 @@ void nsTransferableFactory::GetSelectedLink(nsISelection* inSelection,
// static
nsresult
nsTransferableFactory::SerializeNodeOrSelection(nsIDOMWindow* inWindow,
nsIContent* inNode,
nsAString& outResultString,
nsAString& outContext,
nsAString& outInfo)
DragDataProducer::SerializeNodeOrSelection(nsIDOMWindow* inWindow,
nsIContent* inNode,
nsAString& outResultString,
nsAString& outContext,
nsAString& outInfo)
{
NS_ENSURE_ARG_POINTER(inWindow);

Просмотреть файл

@ -42,7 +42,6 @@
#include "nsCOMPtr.h"
#include "nsIDragDropHandler.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMEventListener.h"
#include "nsITransferable.h"
@ -59,33 +58,12 @@ class nsIFile;
class nsISimpleEnumerator;
class nsDOMDataTransfer;
// {1f34bc80-1bc7-11d6-a384-d705dd0746fc}
#define NS_CONTENTAREADRAGDROP_CID \
{ 0x1f34bc80, 0x1bc7, 0x11d6, \
{ 0xa3, 0x84, 0xd7, 0x05, 0xdd, 0x07, 0x46, 0xfc } }
#define NS_CONTENTAREADRAGDROP_CONTRACTID "@mozilla.org:/content/content-area-dragdrop;1"
//
// class nsContentAreaDragDrop
// class nsContentAreaDragDrop, used to generate the dragdata
//
// The class that listens to the chrome events handles anything
// related to drag and drop. Registers itself with the DOM with
// AddChromeListeners() and removes itself with
// RemoveChromeListeners().
//
class nsContentAreaDragDrop : public nsIDragDropHandler,
public nsIDOMEventListener
class nsContentAreaDragDrop
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDRAGDROPHANDLER
nsContentAreaDragDrop();
virtual ~nsContentAreaDragDrop();
NS_IMETHOD HandleEvent(nsIDOMEvent *event);
/**
* Determine what data in the content area, if any, is being dragged.
@ -113,32 +91,6 @@ public:
PRBool* aCanDrag,
PRBool* aDragSelection,
nsIContent** aDragNode);
private:
// Add/remove the relevant listeners
nsresult AddDragListener();
nsresult RemoveDragListener();
nsresult DragOver(nsIDOMDragEvent* aDragEvent);
nsresult Drop(nsIDOMDragEvent* aDragEvent);
// utility routines
static void NormalizeSelection(nsIDOMNode* inBaseNode,
nsISelection* inSelection);
static void GetEventDocument(nsIDOMEvent* inEvent,
nsIDOMDocument** outDocument);
static void ExtractURLFromData(const nsACString & inFlavor,
nsISupports* inDataWrapper, PRUint32 inDataLen,
nsAString & outURL);
nsCOMPtr<nsIDOMEventTarget> mEventTarget;
// weak ref, this is probably my owning webshell
// FIXME: we set this and never null it out. That's bad! See bug 332187.
nsIWebNavigation* mNavigator;
};
// this is used to save images to disk lazily when the image data is asked for

Просмотреть файл

@ -3736,6 +3736,7 @@ nsContentUtils::CreateContextualFragment(nsIDOMNode* aContextNode,
if (!parser) {
return NS_ERROR_OUT_OF_MEMORY;
}
document->SetFragmentParser(parser);
}
nsCOMPtr<nsIDOMDocumentFragment> frag;
rv = NS_NewDocumentFragment(getter_AddRefs(frag), document->NodeInfoManager());
@ -3765,7 +3766,6 @@ nsContentUtils::CreateContextualFragment(nsIDOMNode* aContextNode,
}
NS_ADDREF(*aReturn = frag);
document->SetFragmentParser(parser);
return NS_OK;
}

Просмотреть файл

@ -3810,11 +3810,10 @@ nsDocument::GetWindow()
}
nsPIDOMWindow *
nsDocument::GetInnerWindow()
nsDocument::GetInnerWindowInternal()
{
if (!mRemovedFromDocShell) {
return mWindow;
}
NS_ASSERTION(mRemovedFromDocShell,
"This document should have been removed from docshell!");
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(GetScriptGlobalObject()));
@ -7121,6 +7120,34 @@ nsDocument::GetLayoutHistoryState() const
return state;
}
void
nsDocument::EnsureOnloadBlocker()
{
// If mScriptGlobalObject is null, we shouldn't be messing with the loadgroup
// -- it's not ours.
if (mOnloadBlockCount != 0 && mScriptGlobalObject) {
nsCOMPtr<nsILoadGroup> loadGroup = GetDocumentLoadGroup();
if (loadGroup) {
// Check first to see if mOnloadBlocker is in the loadgroup.
nsCOMPtr<nsISimpleEnumerator> requests;
loadGroup->GetRequests(getter_AddRefs(requests));
PRBool hasMore = PR_FALSE;
while (NS_SUCCEEDED(requests->HasMoreElements(&hasMore)) && hasMore) {
nsCOMPtr<nsISupports> elem;
requests->GetNext(getter_AddRefs(elem));
nsCOMPtr<nsIRequest> request = do_QueryInterface(elem);
if (request && request == mOnloadBlocker) {
return;
}
}
// Not in the loadgroup, so add it.
loadGroup->AddRequest(mOnloadBlocker, nsnull);
}
}
}
void
nsDocument::BlockOnload()
{

Просмотреть файл

@ -655,13 +655,6 @@ public:
*/
virtual nsPIDOMWindow *GetWindow();
/**
* Return the inner window used as the script compilation scope for
* this document. If you're not absolutely sure you need this, use
* GetWindow().
*/
virtual nsPIDOMWindow *GetInnerWindow();
/**
* Get the script loader for this document
*/
@ -1016,6 +1009,8 @@ protected:
const nsAString& aType,
PRBool aPersisted);
virtual nsPIDOMWindow *GetInnerWindowInternal();
// nsContentList match functions for GetElementsByClassName
static PRBool MatchClassNames(nsIContent* aContent, PRInt32 aNamespaceID,
nsIAtom* aAtom, void* aData);
@ -1033,6 +1028,8 @@ protected:
nsDocument(const char* aContentType);
virtual ~nsDocument();
void EnsureOnloadBlocker();
nsCString mReferrer;
nsString mLastModified;
@ -1062,9 +1059,6 @@ protected:
// document can get its script context and scope. This is the
// *inner* window object.
nsCOMPtr<nsIScriptGlobalObject> mScriptGlobalObject;
// Weak reference to mScriptGlobalObject QI:d to nsPIDOMWindow,
// updated on every set of mSecriptGlobalObject.
nsPIDOMWindow *mWindow;
// If document is created for example using
// document.implementation.createDocument(...), mScriptObject points to

Просмотреть файл

@ -587,6 +587,8 @@ nsGenericDOMDataNode::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
if (mText.IsBidi()) {
aDocument->SetBidiEnabled();
}
// Clear the lazy frame construction bits.
UnsetFlags(NODE_NEEDS_FRAME | NODE_DESCENDANTS_NEED_FRAMES);
}
nsNodeUtils::ParentChainChanged(this);

Просмотреть файл

@ -631,6 +631,23 @@ nsIContent::FindFirstNonNativeAnonymous() const
return nsnull;
}
nsIContent*
nsIContent::GetFlattenedTreeParent() const
{
nsIContent *parent = GetParent();
if (parent && parent->HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
nsIDocument *doc = parent->GetOwnerDoc();
if (doc) {
nsIContent* insertionElement =
doc->BindingManager()->GetNestedInsertionPoint(parent, this);
if (insertionElement) {
parent = insertionElement;
}
}
}
return parent;
}
//----------------------------------------------------------------------
NS_IMPL_ADDREF(nsChildContentList)
@ -2592,7 +2609,9 @@ nsGenericElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
mParentPtrBits |= PARENT_BIT_INDOCUMENT;
// Unset this flag since we now really are in a document.
UnsetFlags(NODE_FORCE_XBL_BINDINGS);
UnsetFlags(NODE_FORCE_XBL_BINDINGS |
// And clear the lazy frame construction bits.
NODE_NEEDS_FRAME | NODE_DESCENDANTS_NEED_FRAMES);
}
// If NODE_FORCE_XBL_BINDINGS was set we might have anonymous children

Просмотреть файл

@ -138,32 +138,6 @@ nsNodeInfoManager::~nsNodeInfoManager()
}
nsrefcnt
nsNodeInfoManager::AddRef()
{
NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");
nsrefcnt count = PR_AtomicIncrement((PRInt32*)&mRefCnt);
NS_LOG_ADDREF(this, count, "nsNodeInfoManager", sizeof(*this));
return count;
}
nsrefcnt
nsNodeInfoManager::Release()
{
NS_PRECONDITION(0 != mRefCnt, "dup release");
nsrefcnt count = PR_AtomicDecrement((PRInt32 *)&mRefCnt);
NS_LOG_RELEASE(this, count, "nsNodeInfoManager");
if (count == 0) {
mRefCnt = 1; /* stabilize */
delete this;
}
return count;
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsNodeInfoManager)
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsNodeInfoManager, AddRef)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsNodeInfoManager, Release)

Просмотреть файл

@ -68,8 +68,7 @@ public:
NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsNodeInfoManager)
nsrefcnt AddRef(void);
nsrefcnt Release(void);
NS_INLINE_DECL_REFCOUNTING(nsNodeInfoManager)
/**
* Initialize the nodeinfo manager with a document.
@ -154,9 +153,6 @@ private:
static PRIntn NodeInfoInnerKeyCompare(const void *key1, const void *key2);
static PLHashNumber GetNodeInfoInnerHashValue(const void *key);
nsAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
PLHashTable *mNodeInfoHash;
nsIDocument *mDocument; // WEAK
nsIPrincipal *mPrincipal; // STRONG, but not nsCOMPtr to avoid include hell

Просмотреть файл

@ -301,7 +301,7 @@ nsNodeIterator::NextOrPrevNode(NodePointer::MoveToMethodType aMove,
*_retval = nsnull;
if (mDetached)
if (mDetached || mInAcceptNode)
return NS_ERROR_DOM_INVALID_STATE_ERR;
mWorkingPointer = mPointer;

Просмотреть файл

@ -54,7 +54,8 @@ nsTraversal::nsTraversal(nsINode *aRoot,
mRoot(aRoot),
mWhatToShow(aWhatToShow),
mFilter(aFilter),
mExpandEntityReferences(aExpandEntityReferences)
mExpandEntityReferences(aExpandEntityReferences),
mInAcceptNode(PR_FALSE)
{
NS_ASSERTION(aRoot, "invalid root in call to nsTraversal constructor");
}
@ -73,6 +74,8 @@ nsTraversal::~nsTraversal()
*/
nsresult nsTraversal::TestNode(nsINode* aNode, PRInt16* _filtered)
{
NS_ENSURE_TRUE(!mInAcceptNode, NS_ERROR_DOM_INVALID_STATE_ERR);
nsresult rv;
*_filtered = nsIDOMNodeFilter::FILTER_SKIP;
@ -114,7 +117,10 @@ nsresult nsTraversal::TestNode(nsINode* aNode, PRInt16* _filtered)
domNode = do_QueryInterface(aNode);
}
return mFilter->AcceptNode(domNode, _filtered);
mInAcceptNode = PR_TRUE;
rv = mFilter->AcceptNode(domNode, _filtered);
mInAcceptNode = PR_FALSE;
return rv;
}
*_filtered = nsIDOMNodeFilter::FILTER_ACCEPT;

Просмотреть файл

@ -62,7 +62,8 @@ protected:
nsCOMPtr<nsINode> mRoot;
PRUint32 mWhatToShow;
nsCOMPtr<nsIDOMNodeFilter> mFilter;
PRBool mExpandEntityReferences;
PRPackedBool mExpandEntityReferences;
PRPackedBool mInAcceptNode;
/*
* Tests if and how a node should be filtered. Uses mWhatToShow and

Просмотреть файл

@ -372,6 +372,7 @@ _TEST_FILES = test_bug5141.html \
test_bug558726.html \
test_bug557892.html \
file_bug557892.html \
test_bug559526.html \
$(NULL)
# This test fails on the Mac for some reason

Просмотреть файл

@ -0,0 +1,97 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=559526
-->
<head>
<title>Test for Bug 559526</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=559526">Mozilla Bug 559526</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<div id="nodes" style="display:none">
<div id="child1"></div>
<div id="child2"></div>
<div id="child3"></div>
<div id="child4"></div>
<div id="child5"></div>
<div id="child6"></div>
<div id="child7"></div>
<div id="child8"></div>
</div>
<script type="application/javascript">
/** Test for Bug 559526 **/
var it;
var recurse = false;
var testCount = 0;
function filter(node) {
if (node.id == "child3" && ! recurse) {
recurse = true;
var ex = null;
try {
var foo = it.nextNode();
} catch(e) {
ex = e;
}
++testCount;
is(ex.code, DOMException.INVALID_STATE_ERR, "Should have thrown an exception!");
recurse = false;
}
return NodeFilter.FILTER_ACCEPT;
}
(function testNodeIterator() {
it = document.createNodeIterator(
document.getElementById("nodes"),
NodeFilter.SHOW_ELEMENT,
filter,
false
);
while (it.nextNode());
})();
(function testTreeWalker() {
it = document.createTreeWalker(
document.getElementById("nodes"),
NodeFilter.SHOW_ELEMENT,
filter,
false
);
while(it.nextNode());
it = document.createTreeWalker(
document.getElementById("nodes"),
NodeFilter.SHOW_ELEMENT,
filter,
false
);
it.firstChild();
while(it.nextSibling());
it = document.createTreeWalker(
document.getElementById("nodes"),
NodeFilter.SHOW_ELEMENT,
filter,
false
);
it.lastChild();
while(it.previousSibling());
})();
is(testCount, 4, "Should have tests 3 filter calls!");
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -141,7 +141,8 @@ static inline bool
DoubleIsFinite(double d)
{
#ifdef WIN32
return _finite(d);
// NOTE: '!!' casts an int to bool without spamming MSVC warning C4800.
return !!_finite(d);
#else
return finite(d);
#endif
@ -778,8 +779,8 @@ nsCanvasRenderingContext2D::~nsCanvasRenderingContext2D()
sNumLivingContexts--;
if (!sNumLivingContexts) {
delete sUnpremultiplyTable;
delete sPremultiplyTable;
delete[] sUnpremultiplyTable;
delete[] sPremultiplyTable;
sUnpremultiplyTable = nsnull;
sPremultiplyTable = nsnull;
}
@ -1732,7 +1733,7 @@ nsCanvasRenderingContext2D::ShadowInitialize(const gfxRect& extents, gfxAlphaBox
blurRadius.height, blurRadius.width);
drawExtents = drawExtents.Intersect(clipExtents - CurrentState().shadowOffset);
gfxContext* ctx = blur.Init(drawExtents, blurRadius, nsnull);
gfxContext* ctx = blur.Init(drawExtents, blurRadius, nsnull, nsnull);
if (!ctx)
return nsnull;
@ -2210,7 +2211,7 @@ nsCanvasRenderingContext2D::SetFont(const nsAString& font)
gfxFontStyle style(fontStyle->mFont.style,
fontStyle->mFont.weight,
fontStyle->mFont.stretch,
NSAppUnitsToFloatPixels(fontSize, aupcp),
NSAppUnitsToFloatPixels(fontSize, float(aupcp)),
language,
fontStyle->mFont.sizeAdjust,
fontStyle->mFont.systemFont,
@ -3473,7 +3474,8 @@ nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, float aX, float aY
// protect against too-large surfaces that will cause allocation
// or overflow issues
if (!gfxASurface::CheckSurfaceSize(gfxIntSize(aW, aH), 0xffff))
if (!gfxASurface::CheckSurfaceSize(gfxIntSize(PRInt32(aW), PRInt32(aH)),
0xffff))
return NS_ERROR_FAILURE;
// We can't allow web apps to call this until we fix at least the

Просмотреть файл

@ -56,8 +56,8 @@ class nsCxPusher;
* Event listener manager interface.
*/
#define NS_IEVENTLISTENERMANAGER_IID \
{ 0x2412fcd0, 0xd168, 0x4a1c, \
{ 0xaa, 0x28, 0x70, 0xed, 0x58, 0xf0, 0x4c, 0xec } }
{ 0xe86a148b, 0x0563, 0x454f, \
{ 0x8c, 0xf2, 0xbd, 0xc4, 0x7c, 0xe6, 0xbe, 0x91 } }
class nsIEventListenerManager : public nsISupports {
@ -140,19 +140,6 @@ public:
nsIAtom* aName,
PRBool *aDidCompile) = 0;
/**
* Causes a check for event listeners and processing by them if they exist.
* Event flags live in nsGUIEvent.h
* @param an event listener
*/
NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
nsPIDOMEventTarget* aCurrentTarget,
PRUint32 aFlags,
nsEventStatus* aEventStatus,
nsCxPusher* aPusher) = 0;
/**
* Tells the event listener manager that its target (which owns it) is
* no longer using it (and could go away).

Просмотреть файл

@ -198,7 +198,8 @@ public:
if (!MayHaveListenerManager() && !aMayHaveNewListenerManagers) {
return NS_OK;
}
mManager = mTarget->GetListenerManager(PR_FALSE);
mManager =
static_cast<nsEventListenerManager*>(mTarget->GetListenerManager(PR_FALSE));
}
if (mManager) {
NS_ASSERTION(aVisitor.mEvent->currentTarget == nsnull,
@ -240,7 +241,7 @@ public:
// Event retargeting must happen whenever mNewTarget is non-null.
nsCOMPtr<nsPIDOMEventTarget> mNewTarget;
// Cache mTarget's event listener manager.
nsCOMPtr<nsIEventListenerManager> mManager;
nsRefPtr<nsEventListenerManager> mManager;
static PRUint32 sMaxEtciCount;
static PRUint32 sCurrentEtciCount;

Просмотреть файл

@ -1095,34 +1095,14 @@ static const EventDispatchData* sLatestEventDispData = nsnull;
*/
nsresult
nsEventListenerManager::HandleEvent(nsPresContext* aPresContext,
nsEvent* aEvent, nsIDOMEvent** aDOMEvent,
nsPIDOMEventTarget* aCurrentTarget,
PRUint32 aFlags,
nsEventStatus* aEventStatus,
nsCxPusher* aPusher)
nsEventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
nsPIDOMEventTarget* aCurrentTarget,
PRUint32 aFlags,
nsEventStatus* aEventStatus,
nsCxPusher* aPusher)
{
if (mListeners.IsEmpty() || aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) {
return NS_OK;
}
if (!mMayHaveCapturingListeners &&
!(aEvent->flags & NS_EVENT_FLAG_BUBBLE)) {
return NS_OK;
}
if (!mMayHaveSystemGroupListeners &&
aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) {
return NS_OK;
}
// Check if we already know that there is no event listener for the event.
if (mNoListenerForEvent == aEvent->message &&
(mNoListenerForEvent != NS_USER_DEFINED_EVENT ||
mNoListenerForEventAtom == aEvent->userType)) {
return NS_OK;
}
//Set the value of the internal PreventDefault flag properly based on aEventStatus
if (*aEventStatus == nsEventStatus_eConsumeNoDefault) {
aEvent->flags |= NS_EVENT_FLAG_NO_DEFAULT;

Просмотреть файл

@ -112,13 +112,45 @@ public:
nsISupports *aObject,
nsIAtom* aName, PRBool *aDidCompile);
NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
nsPIDOMEventTarget* aCurrentTarget,
PRUint32 aFlags,
nsEventStatus* aEventStatus,
nsCxPusher* aPusher);
nsresult HandleEvent(nsPresContext* aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
nsPIDOMEventTarget* aCurrentTarget,
PRUint32 aFlags,
nsEventStatus* aEventStatus,
nsCxPusher* aPusher)
{
if (mListeners.IsEmpty() || aEvent->flags & NS_EVENT_FLAG_STOP_DISPATCH) {
return NS_OK;
}
if (!mMayHaveCapturingListeners &&
!(aEvent->flags & NS_EVENT_FLAG_BUBBLE)) {
return NS_OK;
}
if (!mMayHaveSystemGroupListeners &&
aFlags & NS_EVENT_FLAG_SYSTEM_EVENT) {
return NS_OK;
}
// Check if we already know that there is no event listener for the event.
if (mNoListenerForEvent == aEvent->message &&
(mNoListenerForEvent != NS_USER_DEFINED_EVENT ||
mNoListenerForEventAtom == aEvent->userType)) {
return NS_OK;
}
return HandleEventInternal(aPresContext, aEvent, aDOMEvent, aCurrentTarget,
aFlags, aEventStatus, aPusher);
}
nsresult HandleEventInternal(nsPresContext* aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
nsPIDOMEventTarget* aCurrentTarget,
PRUint32 aFlags,
nsEventStatus* aEventStatus,
nsCxPusher* aPusher);
NS_IMETHOD Disconnect();

Просмотреть файл

@ -21,15 +21,32 @@ function fireEvent(target, event) {
utils.dispatchDOMEventViaPresShell(target, event, true);
}
function fireDrop(element, dragData, shouldAllowDrop, shouldAllowOnlyChromeDrop) {
function fireDrop(element, shouldAllowDrop, shouldAllowOnlyChromeDrop) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var ds = Components.classes["@mozilla.org/widget/dragservice;1"].
getService(Components.interfaces.nsIDragService);
var dataTransfer;
var trapDrag = function(event) {
dataTransfer = event.dataTransfer;
dataTransfer.setData("text/plain", "Hello");;
dataTransfer.dropEffect = "move";
event.preventDefault();
event.stopPropagation();
}
// need to use real mouse action
window.addEventListener("dragstart", trapDrag, true);
synthesizeMouse(element, 2, 2, { type: "mousedown" });
synthesizeMouse(element, 11, 11, { type: "mousemove" });
synthesizeMouse(element, 20, 20, { type: "mousemove" });
window.removeEventListener("dragstart", trapDrag, true);
synthesizeMouse(element, 20, 20, { type: "mouseup" });
ds.startDragSession();
var event = document.createEvent("DragEvents");
event.initDragEvent("dragover", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, null);
event.initDragEvent("dragover", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, dataTransfer);
fireEvent(element, event);
is(ds.getCurrentSession().canDrop, shouldAllowDrop, "Unexpected .canDrop");
@ -37,7 +54,7 @@ function fireDrop(element, dragData, shouldAllowDrop, shouldAllowOnlyChromeDrop)
"Unexpected .onlyChromeDrop");
event = document.createEvent("DragEvents");
event.initDragEvent("drop", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, null);
event.initDragEvent("drop", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, dataTransfer);
fireEvent(element, event);
ds.endDragSession(false);
@ -47,7 +64,7 @@ function fireDrop(element, dragData, shouldAllowDrop, shouldAllowOnlyChromeDrop)
function runTests()
{
var targetHandling = document.getElementById("handling_target");
fireDrop(targetHandling, [{"test/plain": "Hello!"}], false, false);
fireDrop(targetHandling, true, false);
is(gGotHandlingDrop, true, "Got drop on accepting element (1)");
is(gGotNotHandlingDrop, false, "Didn't get drop on unaccepting element (1)");
@ -57,7 +74,7 @@ function runTests()
gGotNotHandlingDrop = false;
var targetNotHandling = document.getElementById("nothandling_target");
fireDrop(targetNotHandling, [{"test/plain": "Hello!"}], true, true);
fireDrop(targetNotHandling, true, true);
is(gGotHandlingDrop, false, "Didn't get drop on accepting element (2)");
is(gGotNotHandlingDrop, false, "Didn't get drop on unaccepting element (2)");

Просмотреть файл

@ -72,9 +72,7 @@ CPPSRCS = \
nsHTMLFrameElement.cpp \
nsHTMLFrameSetElement.cpp \
nsHTMLHRElement.cpp \
nsHTMLHeadElement.cpp \
nsHTMLHeadingElement.cpp \
nsHTMLHtmlElement.cpp \
nsHTMLIFrameElement.cpp \
nsHTMLImageElement.cpp \
nsHTMLInputElement.cpp \

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше