Merge Places and mozilla-central

This commit is contained in:
Marco Bonardo 2011-05-17 15:40:41 +02:00
commit ca98ab7783
344 changed files with 6676 additions and 4066 deletions

View File

@ -57,7 +57,6 @@
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentXBL.h"
#include "nsIDOMDocumentTraversal.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMNodeFilter.h"
@ -3220,16 +3219,15 @@ nsAccessible::GetFirstAvailableAccessible(nsINode *aStartNode) const
if (accessible)
return accessible;
nsCOMPtr<nsIDOMDocumentTraversal> trav =
do_QueryInterface(aStartNode->GetOwnerDoc());
NS_ENSURE_TRUE(trav, nsnull);
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(aStartNode->GetOwnerDoc());
NS_ENSURE_TRUE(domDoc, nsnull);
nsCOMPtr<nsIDOMNode> currentNode = do_QueryInterface(aStartNode);
nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(GetNode()));
nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(GetNode());
nsCOMPtr<nsIDOMTreeWalker> walker;
trav->CreateTreeWalker(rootNode,
nsIDOMNodeFilter::SHOW_ELEMENT | nsIDOMNodeFilter::SHOW_TEXT,
nsnull, PR_FALSE, getter_AddRefs(walker));
domDoc->CreateTreeWalker(rootNode,
nsIDOMNodeFilter::SHOW_ELEMENT | nsIDOMNodeFilter::SHOW_TEXT,
nsnull, PR_FALSE, getter_AddRefs(walker));
NS_ENSURE_TRUE(walker, nsnull);
walker->SetCurrentNode(currentNode);

View File

@ -49,7 +49,6 @@
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentRange.h"
#include "nsIDOMRange.h"
#include "nsISelection2.h"
#include "nsISelectionPrivate.h"

View File

@ -50,8 +50,8 @@ _TEST_FILES = \
test_doc.html \
test_hypertext.html \
test_passwords.html \
test_singleline.html \
test_whitespaces.html \
$(warning test_singleline.html disabled due to bug 652459) \
$(warning test_whitespaces.html disabled due to bug 652459) \
test_words.html \
$(NULL)

View File

@ -8488,7 +8488,7 @@ var TabContextMenu = {
updateContextMenu: function updateContextMenu(aPopupMenu) {
this.contextTab = document.popupNode.localName == "tab" ?
document.popupNode : gBrowser.selectedTab;
let disabled = gBrowser.visibleTabs.length == 1;
let disabled = gBrowser.tabs.length == 1;
// Enable the "Close Tab" menuitem when the window doesn't close with the last tab.
document.getElementById("context_closeTab").disabled =
@ -8498,6 +8498,11 @@ var TabContextMenu = {
for (var i = 0; i < menuItems.length; i++)
menuItems[i].disabled = disabled;
disabled = gBrowser.visibleTabs.length == 1;
menuItems = aPopupMenu.getElementsByAttribute("tbattr", "tabbrowser-multiple-visible");
for (var i = 0; i < menuItems.length; i++)
menuItems[i].disabled = disabled;
// Session store
document.getElementById("context_undoCloseTab").disabled =
Cc["@mozilla.org/browser/sessionstore;1"].

View File

@ -139,7 +139,7 @@
oncommand="gBrowser.replaceTabWithWindow(TabContextMenu.contextTab);"/>
<menuseparator/>
<menuitem id="context_reloadAllTabs" label="&reloadAllTabs.label;" accesskey="&reloadAllTabs.accesskey;"
tbattr="tabbrowser-multiple"
tbattr="tabbrowser-multiple-visible"
oncommand="gBrowser.reloadAllTabs();"/>
<menuitem id="context_bookmarkAllTabs"
label="&bookmarkAllTabs.label;"
@ -844,9 +844,8 @@
key="key_tabview"
label="&viewTabGroups.label;"
command="Browser:ToggleTabView"
observes="tabviewGroupsNumber"
keepme="true"/>
<menuseparator id="alltabs-popup-separator" keepme="true"/>
observes="tabviewGroupsNumber"/>
<menuseparator id="alltabs-popup-separator"/>
</menupopup>
</toolbarbutton>

View File

@ -3142,12 +3142,15 @@
<method name="_handleNewTab">
<parameter name="tab"/>
<body><![CDATA[
if (tab.parentNode != this || tab._fullyOpen)
if (tab.parentNode != this)
return;
tab._fullyOpen = true;
this.adjustTabstrip();
if (tab._fullyOpen)
return;
tab._fullyOpen = true;
if (tab.getAttribute("selected") == "true") {
this._fillTrailingGap();
this._handleTabSelect();
@ -3735,7 +3738,12 @@
var tabstripBO = tabContainer.mTabstrip.scrollBoxObject;
for (var i = 0; i < this.childNodes.length; i++) {
var curTabBO = this.childNodes[i].tab.boxObject;
let curTab = this.childNodes[i].tab;
if (!curTab) // "Tab Groups" menuitem and its menuseparator
continue;
let curTabBO = curTab.boxObject;
if (!curTabBO) // "Tabs From Other Computers" menuitem
continue;
if (curTabBO.screenX >= tabstripBO.screenX &&
curTabBO.screenX + curTabBO.width <= tabstripBO.screenX + tabstripBO.width)
this.childNodes[i].setAttribute("tabIsVisible", "true");
@ -3812,7 +3820,7 @@
// clear out the menu popup and remove the listeners
for (let i = this.childNodes.length - 1; i > 0; i--) {
let menuItem = this.childNodes[i];
if (!menuItem.hasAttribute("keepme")) {
if (menuItem.tab) {
menuItem.removeEventListener("command", this, false);
menuItem.tab.mCorrespondingMenuitem = null;
this.removeChild(menuItem);

View File

@ -1913,7 +1913,7 @@ let GroupItems = {
// ----------
// Function: uninit
uninit : function GroupItems_uninit () {
uninit: function GroupItems_uninit() {
// call our cleanup functions
this._cleanupFunctions.forEach(function(func) {
func();
@ -1928,7 +1928,7 @@ let GroupItems = {
// ----------
// Function: newGroup
// Creates a new empty group.
newGroup: function () {
newGroup: function GroupItems_newGroup() {
let bounds = new Rect(20, 20, 250, 200);
return new GroupItem([], {bounds: bounds, immediately: true});
},

View File

@ -200,6 +200,7 @@ _BROWSER_FILES = \
browser_scratchpad_ui.js \
browser_scratchpad_bug_646070_chrome_context_pref.js \
browser_overflowScroll.js \
browser_locationBarExternalLoad.js \
browser_pageInfo.js \
browser_page_style_menu.js \
browser_pinnedTabs.js \

View File

@ -0,0 +1,45 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function test() {
waitForExplicitFinish();
nextTest();
}
let urls = [
"javascript:'foopy';",
"data:text/html,<script>document.write(document.domain);</script>"
];
function nextTest() {
let url = urls.shift();
if (url)
testURL(url, nextTest);
else
finish();
}
function testURL(newURL, func) {
let tab = gBrowser.selectedTab = gBrowser.addTab();
registerCleanupFunction(function () {
gBrowser.removeTab(tab);
});
addPageShowListener(function () {
let pagePrincipal = gBrowser.contentPrincipal;
gURLBar.value = newURL;
gURLBar.handleCommand();
addPageShowListener(function () {
ok(!gBrowser.contentPrincipal.equals(pagePrincipal), "load of " + newURL + " produced a page with a different principal");
func();
});
});
}
function addPageShowListener(func) {
gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() {
gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false);
func();
});
}

View File

@ -25,6 +25,12 @@ function test() {
Services.prefs.setBoolPref(prefname, true);
gURLBar.focus();
testVal("http://mozilla.org/");
gBrowser.selectedBrowser.focus();
testVal("<http://>mozilla.org");
testVal("<http://>mozilla.org</>");
testVal("<http://>mözilla.org</>");

View File

@ -56,7 +56,7 @@ function test() {
// Check the context menu with one tab.
popup(testTab);
is(TabContextMenu.contextTab, testTab, "TabContextMenu context is the test tab");
is(document.getElementById("context_closeTab").disabled, true, "Close Tab is disabled");
is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled when more than one tab exists");
is(document.getElementById("context_reloadAllTabs").disabled, true, "Reload All Tabs is disabled");
// Add a tab that will get pinned

View File

@ -105,6 +105,7 @@ _BROWSER_FILES = \
browser_tabview_bug624847.js \
browser_tabview_bug624931.js \
browser_tabview_bug624953.js \
browser_tabview_bug625195.js \
browser_tabview_bug625269.js \
browser_tabview_bug625424.js \
browser_tabview_bug625666.js \

View File

@ -0,0 +1,55 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function test() {
is(gBrowser.tabs.length, 1, "Only one tab exist");
let originalTab = gBrowser.tabs[0];
popup(originalTab);
ok(document.getElementById("context_closeTab").disabled, "The 'Close tab' menu item is disabled");
ok(document.getElementById("context_openTabInWindow").disabled, "The 'Move to New Window' menu item is disabled");
let newTabOne = gBrowser.addTab("about:blank", {skipAnimation: true});
waitForExplicitFinish();
showTabView(function() {
registerCleanupFunction(function () {
if (gBrowser.tabs[1])
gBrowser.removeTab(gBrowser.tabs[1]);
if (gBrowser.tabs[2])
gBrowser.removeTab(gBrowser.tabs[2]);
TabView.hide();
});
let contentWindow = TabView.getContentWindow();
is(contentWindow.GroupItems.groupItems.length, 1, "Has one group only");
let tabItems = contentWindow.GroupItems.groupItems[0].getChildren();
ok(tabItems.length, 2, "There are two tabItems in this group");
whenTabViewIsHidden(function() {
popup(gBrowser.tabs[0]);
ok(!document.getElementById("context_closeTab").disabled, "The 'Close tab' menu item is enabled");
ok(!document.getElementById("context_openTabInWindow").disabled, "The 'Move to New Window' menu item is enabled");
let newTabTwo = gBrowser.selectedTab;
gBrowser.selected = originalTab;
gBrowser.removeTab(newTabOne);
gBrowser.removeTab(newTabTwo);
finish();
});
let newGroup = contentWindow.GroupItems.newGroup();
newGroup.newTab();
});
}
function popup(tab) {
document.popupNode = tab;
TabContextMenu.updateContextMenu(document.getElementById("tabContextMenu"));
}

View File

@ -183,7 +183,7 @@
<field name="_formattingEnabled">true</field>
<method name="formatValue">
<body><![CDATA[
if (!this._formattingEnabled)
if (!this._formattingEnabled || this.focused)
return;
let controller = this.editor.selectionController;
@ -316,9 +316,13 @@
allowThirdPartyFixup: true});
aTriggeringEvent.preventDefault();
aTriggeringEvent.stopPropagation();
} else {
// Pass LOAD_FLAGS_DISALLOW_INHERIT_OWNER to prevent any loads from
// inheriting the currently loaded document's principal.
let flags = Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_OWNER;
gBrowser.loadURIWithFlags(url, flags, null, null, postData);
}
else
loadURI(url, null, postData, true /* allow third party fixup */);
gBrowser.selectedBrowser.focus();
]]></body>

View File

@ -910,5 +910,10 @@ var gCookiesWindow = {
var filter = document.getElementById("filter");
filter.focus();
filter.select();
},
onWindowKeyPress: function (aEvent) {
if (aEvent.keyCode == KeyEvent.DOM_VK_ESCAPE)
window.close();
}
};

View File

@ -49,7 +49,8 @@
style="width: &window.width;;"
onload="gCookiesWindow.init();"
onunload="gCookiesWindow.uninit();"
persist="screenX screenY width height">
persist="screenX screenY width height"
onkeypress="gCookiesWindow.onWindowKeyPress(event);">
<script src="chrome://browser/content/preferences/permissionsutils.js"/>
<script src="chrome://browser/content/preferences/cookies.js"/>

View File

@ -159,6 +159,12 @@ var gPermissionManager = {
document.getElementById("btnAllow").disabled = !aSiteField.value;
},
onWindowKeyPress: function (aEvent)
{
if (aEvent.keyCode == KeyEvent.DOM_VK_ESCAPE)
window.close();
},
onHostKeyPress: function (aEvent)
{
if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN)

View File

@ -51,7 +51,8 @@
style="width: &window.width;;"
onload="gPermissionManager.onLoad();"
onunload="gPermissionManager.uninit();"
persist="screenX screenY width height">
persist="screenX screenY width height"
onkeypress="gPermissionManager.onWindowKeyPress(event);">
<script src="chrome://browser/content/preferences/permissionsutils.js"/>
<script src="chrome://browser/content/preferences/permissions.js"/>

View File

@ -182,8 +182,10 @@ function onListClick(aEvent) {
#endif
if ((aEvent.button == 1 || aEvent.button == 0 && aEvent.detail == 2 || accelKey) &&
col.value.id == "title" &&
!treeView.isContainer(row.value))
!treeView.isContainer(row.value)) {
restoreSingleTab(row.value, aEvent.shiftKey);
aEvent.stopPropagation();
}
else if (col.value.id == "restore")
toggleRowChecked(row.value);
}

View File

@ -771,36 +771,41 @@ SessionStoreService.prototype = {
if (closedWindowState) {
let newWindowState;
#ifdef XP_MACOSX
// We want to split the window up into pinned tabs and unpinned tabs.
// Pinned tabs should be restored. If there are any remaining tabs,
// they should be added back to _closedWindows.
// We'll cheat a little bit and reuse _prepDataForDeferredRestore
// even though it wasn't built exactly for this.
let [appTabsState, normalTabsState] =
this._prepDataForDeferredRestore(JSON.stringify({ windows: [closedWindowState] }));
#ifndef XP_MACOSX
if (!this._doResumeSession()) {
#endif
// We want to split the window up into pinned tabs and unpinned tabs.
// Pinned tabs should be restored. If there are any remaining tabs,
// they should be added back to _closedWindows.
// We'll cheat a little bit and reuse _prepDataForDeferredRestore
// even though it wasn't built exactly for this.
let [appTabsState, normalTabsState] =
this._prepDataForDeferredRestore(JSON.stringify({ windows: [closedWindowState] }));
// These are our pinned tabs, which we should restore
if (appTabsState.windows.length) {
newWindowState = appTabsState.windows[0];
delete newWindowState.__lastSessionWindowID;
}
// These are our pinned tabs, which we should restore
if (appTabsState.windows.length) {
newWindowState = appTabsState.windows[0];
delete newWindowState.__lastSessionWindowID;
}
// In case there were no unpinned tabs, remove the window from _closedWindows
if (!normalTabsState.windows.length) {
this._closedWindows.splice(closedWindowIndex, 1);
// In case there were no unpinned tabs, remove the window from _closedWindows
if (!normalTabsState.windows.length) {
this._closedWindows.splice(closedWindowIndex, 1);
}
// Or update _closedWindows with the modified state
else {
delete normalTabsState.windows[0].__lastSessionWindowID;
this._closedWindows[closedWindowIndex] = normalTabsState.windows[0];
}
#ifndef XP_MACOSX
}
// Or update _closedWindows with the modified state
else {
delete normalTabsState.windows[0].__lastSessionWindowID;
this._closedWindows[closedWindowIndex] = normalTabsState.windows[0];
// If we're just restoring the window, make sure it gets removed from
// _closedWindows.
this._closedWindows.splice(closedWindowIndex, 1);
newWindowState = closedWindowState;
delete newWindowState.hidden;
}
#else
// If we're just restoring the window, make sure it gets removed from
// _closedWindows.
this._closedWindows.splice(closedWindowIndex, 1);
newWindowState = closedWindowState;
delete newWindowState.hidden;
#endif
if (newWindowState) {
// Ensure that the window state isn't hidden

View File

@ -21,14 +21,7 @@ function closeFirstWin(win) {
win.BrowserTryToCloseWindow();
ok(win.closed, "window closed");
// The second check will be platform dependent. After bug 592833, Win/Linux
// will restore all tabs from the last close window while OSX will just
// reopen pinned tabs.
let expectedURIs = URIS_PINNED.concat(URIS_NORMAL_B);
if (!navigator.platform.match(/Mac/))
expectedURIs = expectedURIs.concat(URIS_NORMAL_A);
openWinWithCb(checkSecondWin, URIS_NORMAL_B, expectedURIs);
openWinWithCb(checkSecondWin, URIS_NORMAL_B, URIS_PINNED.concat(URIS_NORMAL_B));
}
function checkSecondWin(win) {

View File

@ -161,7 +161,6 @@
@BINPATH@/components/dom_stylesheets.xpt
@BINPATH@/components/dom_threads.xpt
@BINPATH@/components/dom_traversal.xpt
@BINPATH@/components/dom_views.xpt
@BINPATH@/components/dom_xbl.xpt
@BINPATH@/components/dom_xpath.xpt
@BINPATH@/components/dom_xul.xpt
@ -226,9 +225,6 @@
@BINPATH@/components/satchel.xpt
@BINPATH@/components/saxparser.xpt
@BINPATH@/components/sessionstore.xpt
#ifdef MOZ_SERVICES_SYNC
@BINPATH@/components/services-crypto.xpt
#endif
@BINPATH@/components/services-crypto-component.xpt
@BINPATH@/components/shellservice.xpt
@BINPATH@/components/shistory.xpt
@ -247,7 +243,6 @@
@BINPATH@/components/urlformatter.xpt
@BINPATH@/components/webBrowser_core.xpt
@BINPATH@/components/webbrowserpersist.xpt
@BINPATH@/components/webshell_idls.xpt
@BINPATH@/components/widget.xpt
#ifdef XP_MACOSX
@BINPATH@/components/widget_cocoa.xpt
@ -283,7 +278,6 @@
@BINPATH@/components/nsBrowserGlue.js
@BINPATH@/components/nsSetDefaultBrowser.manifest
@BINPATH@/components/nsSetDefaultBrowser.js
@BINPATH@/components/nsMicrosummaryService.js
@BINPATH@/components/BrowserPlaces.manifest
@BINPATH@/components/nsPrivateBrowsingService.manifest
@BINPATH@/components/nsPrivateBrowsingService.js

View File

@ -116,12 +116,12 @@ $(DIST)/branding:
libs::
@if test -f "$(LOCALE_SRCDIR)/existing-profile-defaults.js"; then \
$(PERL) $(topsrcdir)/config/preprocessor.pl $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
$(LOCALE_SRCDIR)/existing-profile-defaults.js > $(FINAL_TARGET)/defaults/existing-profile-defaults.js; \
fi
install::
@if test -f "$(LOCALE_SRCDIR)/existing-profile-defaults.js"; then \
$(PERL) $(topsrcdir)/config/preprocessor.pl $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
$(LOCALE_SRCDIR)/existing-profile-defaults.js > $(DESTDIR)$(mozappdir)/defaults/existing-profile-defaults.js; \
fi

View File

@ -237,7 +237,7 @@ toolbarbutton.bookmark-item > menupopup {
}
.bookmark-item[livemark] .menuitem-iconic {
list-style-image: url("chrome://browser/skin/places/livemarkItem.png");
list-style-image: url("chrome://browser/skin/livemark-item.png");
}
.bookmark-item menuitem[openInTabs],

View File

@ -63,7 +63,6 @@ browser.jar:
* skin/classic/browser/places/places.css (places/places.css)
* skin/classic/browser/places/organizer.css (places/organizer.css)
skin/classic/browser/places/query.png (places/query.png)
skin/classic/browser/places/livemarkItem.png (places/livemarkItem.png)
skin/classic/browser/places/bookmarksMenu.png (places/bookmarksMenu.png)
skin/classic/browser/places/bookmarksToolbar.png (places/bookmarksToolbar.png)
skin/classic/browser/places/history.png (places/history.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 634 B

View File

@ -103,7 +103,7 @@ treechildren::-moz-tree-image(title) {
}
treechildren::-moz-tree-image(title, livemarkItem) {
list-style-image: url("chrome://browser/skin/places/livemarkItem.png");
list-style-image: url("chrome://browser/skin/livemark-item.png");
}
treechildren::-moz-tree-image(title, container),

View File

@ -1097,7 +1097,7 @@ toolbar[mode="full"] .toolbarbutton-1 > .toolbarbutton-menubutton-button {
margin: 1px 3px;
padding: 2px;
background-clip: padding-box;
border: 1px solid ThreeDDarkShadow;
border: 1px solid ThreeDShadow;
border-radius: 3.5px;
}

View File

@ -91,7 +91,7 @@ test$(DLL_SUFFIX): test.$(OBJ_SUFFIX) elfhack $(CSRCS:.c=.$(OBJ_SUFFIX))
[ $$(objdump -R $@.bak | wc -l) -gt $$(objdump -R $@ | wc -l) ]
dummy: dummy.$(OBJ_SUFFIX) test$(DLL_SUFFIX)
$(CC) $(LDFLAGS) -o $@ $^
$(CC) -o $@ $^ $(LDFLAGS)
libs:: dummy
# Will either crash or return exit code 1 if elfhack is broken

View File

@ -121,7 +121,7 @@ endif
ifdef WRAP_SYSTEM_INCLUDES
export::
if test ! -d system_wrappers; then mkdir system_wrappers; fi
$(PERL) $(topsrcdir)/config/preprocessor.pl $(DEFINES) $(ACDEFINES) \
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) \
-DBUILD_STATIC_LIBS=$(BUILD_STATIC_LIBS) \
-DMOZ_TREE_CAIRO=$(MOZ_TREE_CAIRO) \
-DMOZ_TREE_PIXMAN=$(MOZ_TREE_PIXMAN) \

View File

@ -323,7 +323,6 @@ MOZ_OPTIMIZE_SIZE_TWEAK = @MOZ_OPTIMIZE_SIZE_TWEAK@
MOZ_RTTI_FLAGS_ON = @_MOZ_RTTI_FLAGS_ON@
MOZ_EXCEPTIONS_FLAGS_ON = @_MOZ_EXCEPTIONS_FLAGS_ON@
MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE = @MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE@
PROFILE_GEN_CFLAGS = @PROFILE_GEN_CFLAGS@
PROFILE_GEN_LDFLAGS = @PROFILE_GEN_LDFLAGS@
PROFILE_USE_CFLAGS = @PROFILE_USE_CFLAGS@

View File

@ -326,11 +326,6 @@ STATIC_LIBRARY_NAME=$(LIBRARY_NAME)
endif
endif
# This comes from configure
ifdef MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE
NO_PROFILE_GUIDED_OPTIMIZE = 1
endif
# No sense in profiling tools
ifdef INTERNAL_TOOLS
NO_PROFILE_GUIDED_OPTIMIZE = 1

View File

@ -1,671 +0,0 @@
#!/usr/bin/perl -w
# -*- Mode: perl; tab-width: 4; indent-tabs-mode: nil; -*-
#
# Preprocessor
# Version 1.1
#
# Copyright (c) 2002, 2003, 2004 by Ian Hickson
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Thanks to bryner and bsmedberg for suggestions.
# Thanks to jon rekai for a patch to not require File::Spec 0.8.
use strict;
# takes as arguments the files to process
# defaults to stdin
# output to stdout
my $stack = new stack;
my $marker = '#';
# command line arguments
my @includes;
while ($_ = $ARGV[0], defined($_) && /^-./) {
shift;
last if /^--$/os;
if (/^-D(.*)$/os) {
for ($1) {
if (/^([\w\.]+)=(.*)$/os) {
$stack->define($1, $2);
} elsif (/^([\w\.]+)$/os) {
$stack->define($1, 1);
} else {
die "$0: invalid argument to -D: $_\n";
}
}
} elsif (/^-F(.*)$/os) {
for ($1) {
if (/^(\w+)$/os) {
$stack->filter($1, 1);
} else {
die "$0: invalid argument to -F: $_\n";
}
}
} elsif (/^-I(.*)$/os) {
push(@includes, $1);
} elsif (/^-E$/os) {
foreach (keys %ENV) {
# define all variables that have valid names
$stack->define($_, $ENV{$_}) unless m/\W/;
}
} elsif (/^-d$/os) {
$stack->{'dependencies'} = 1;
} elsif (/^--line-endings=crlf$/os) {
$stack->{'lineEndings'} = "\x0D\x0A";
} elsif (/^--line-endings=cr$/os) {
$stack->{'lineEndings'} = "\x0D";
} elsif (/^--line-endings=lf$/os) {
$stack->{'lineEndings'} = "\x0A";
} elsif (/^--line-endings=(.+)$/os) {
die "$0: unrecognised line ending: $1\n";
} elsif (/^--marker=(.)$/os) {
$marker = $1;
} else {
die "$0: invalid argument: $_\n";
}
}
unshift(@ARGV, '-') unless @ARGV;
unshift(@ARGV, @includes);
# do the work
foreach (@ARGV) { include($stack, $_); }
exit(0);
########################################################################
package main;
use File::Spec;
use File::Spec::Unix; # on all platforms, because the #include syntax is unix-based
# Note: Ideally we would use File::Spec 0.8. When this becomes
# possible, add "0.8" to the first "use" line above, then replace
# occurrences of "::_0_8::" with "->" below. And remove the code for
# File::Spec 0.8 much lower down the file.
sub include {
my($stack, $filename) = @_;
my $directory = $stack->{'variables'}->{'DIRECTORY'};
if ($filename ne '-') {
$filename = File::Spec::_0_8::rel2abs($filename, $directory);
# splitpath expects forward-slash paths on windows, so we have to
# change the slashes if using Activestate Perl.
$filename =~ s?\\?/?g if "$^O" eq "MSWin32";
my($volume, $path) = File::Spec::_0_8::splitpath($filename);
$directory = File::Spec::_0_8::catpath($volume, $path, '');
}
local $stack->{'variables'}->{'DIRECTORY'} = $directory;
local $stack->{'variables'}->{'FILE'} = $filename;
local $stack->{'variables'}->{'LINE'} = 0;
local *FILE;
open(FILE, $filename) or die "Couldn't open $filename: $!\n";
my $lineout = 0;
while (<FILE>) {
# on cygwin, line endings are screwed up, so normalise them.
s/[\x0D\x0A]+$/\n/os if ($^O eq 'msys' || $^O eq 'cygwin' || "$^O" eq "MSWin32");
$stack->newline;
if (/^\Q$marker\E([a-z]+)\n?$/os) { # argumentless processing instruction
process($stack, $1);
} elsif (/^\Q$marker\E([a-z]+)\s(.*?)\n?$/os) { # processing instruction with arguments
process($stack, $1, $2);
} elsif (/^\Q$marker\E/os) { # comment
# ignore it
} elsif ($stack->enabled) {
next if $stack->{'dependencies'};
# set the current line number in JavaScript if necessary
my $linein = $stack->{'variables'}->{'LINE'};
if (++$lineout != $linein) {
if ($filename =~ /\.js(|\.in)$/o) {
$stack->print("//\@line $linein \"$filename\"\n")
}
$lineout = $linein;
}
# print it, including any newlines
$stack->print(filtered($stack, $_));
}
}
close(FILE);
}
sub process {
my($stack, $instruction, @arguments) = @_;
my $method = 'preprocessor'->can($instruction);
if (not defined($method)) {
fatal($stack, 'unknown instruction', $instruction);
}
eval { &$method($stack, @arguments) };
if ($@) {
fatal($stack, "error evaluating $instruction:", $@);
}
}
sub filtered {
my($stack, $text) = @_;
foreach my $filter (sort keys %{$stack->{'filters'}}) {
next unless $stack->{'filters'}->{$filter};
my $method = 'filter'->can($filter);
if (not defined($method)) {
fatal($stack, 'unknown filter', $filter);
}
$text = eval { &$method($stack, $text) };
if ($@) {
fatal($stack, "error using $filter:", $@);
}
}
return $text;
}
sub fatal {
my $stack = shift;
my $filename = $stack->{'variables'}->{'FILE'};
local $" = ' ';
print STDERR "$0:$filename:$.: @_\n";
exit(1);
}
########################################################################
package stack;
# condition evaluated just prior to this context was false
use constant COND_FALSE => 0;
# condition evaluated just prior to this context was true
use constant COND_TRUE => 1;
# some prior condition at this level already evaluated to true (or a
# parent condition evaluated to false or must be ignored), so we're
# ignoring all remaining conditions at current level (and nested
# conditions, too)
use constant COND_COMPLETED => 2;
sub new {
return bless {
'variables' => {
# %ENV,
'LINE' => 0, # the line number in the source file
'DIRECTORY' => '', # current directory
'FILE' => '', # source filename
'1' => 1, # for convenience (the constant '1' is thus true)
},
'filters' => {
# filters
},
'values' => [], # the value of the last condition evaluated at the nth level
'lastConditionState' => [], # whether the condition in the nth-level context was true, false, or not applicable
'conditionState' => COND_TRUE,
'dependencies' => 0, # whether we are showing dependencies
'lineEndings' => "\n", # default to platform conventions
};
}
sub newline {
my $self = shift;
$self->{'variables'}->{'LINE'}++;
}
sub define {
my $self = shift;
my($variable, $value) = @_;
die "not a valid variable name: '$variable'\n" if $variable =~ m/[^\w\.]/;
$self->{'variables'}->{$variable} = $value;
}
sub defined {
my $self = shift;
my($variable) = @_;
die "not a valid variable name: '$variable'\n" if $variable =~ m/[^\w\.]/;
return defined($self->{'variables'}->{$variable});
}
sub undefine {
my $self = shift;
my($variable) = @_;
die "not a valid variable name: '$variable'\n" if $variable =~ m/[^\w\.]/;
delete($self->{'variables'}->{$variable});
}
sub get {
my $self = shift;
my($variable, $required) = @_;
die "not a valid variable name: '$variable'\n" if $variable =~ m/[^\w\.]/;
my $value = $self->{'variables'}->{$variable};
if (defined($value)) {
return $value;
} else {
die "variable '$variable' is not defined\n" if $required;
return '';
}
}
sub replace {
my $self = shift;
my ($value) = @_;
${$self->{'values'}}[-1] = $value;
$self->{'conditionState'} = $self->{'conditionState'} != COND_FALSE
? COND_COMPLETED
: $value ? COND_TRUE : COND_FALSE;
}
sub push {
my $self = shift;
my($value) = @_;
push(@{$self->{'values'}}, $value);
my $lastCondition = $self->{'conditionState'};
push(@{$self->{'lastConditionState'}}, $lastCondition);
$self->{'conditionState'} = $lastCondition != COND_TRUE
? COND_COMPLETED
: $value ? COND_TRUE : COND_FALSE;
}
sub pop {
my $self = shift;
$self->{'conditionState'} = pop(@{$self->{'lastConditionState'}});
return pop(@{$self->{'values'}});
}
sub enabled {
my $self = shift;
return $self->{'conditionState'} == COND_TRUE;
}
sub disabled {
my $self = shift;
return $self->{'conditionState'} != COND_TRUE;
}
sub filter {
my $self = shift;
my($filter, $value) = @_;
die "not a valid filter name: '$filter'\n" if $filter =~ m/\W/;
$self->{'filters'}->{$filter} = $value;
}
sub expand {
my $self = shift;
my($line) = @_;
$line =~ s/__(\w+)__/$self->get($1)/gose;
return $line;
}
sub print {
my $self = shift;
return if $self->{'dependencies'};
foreach my $line (@_) {
if (chomp $line) {
CORE::print("$line$self->{'lineEndings'}");
} else {
CORE::print($line);
}
}
}
sub visit {
my $self = shift;
my($filename) = @_;
my $directory = $stack->{'variables'}->{'DIRECTORY'};
$filename = File::Spec::_0_8::abs2rel(File::Spec::_0_8::rel2abs($filename, $directory));
CORE::print("$filename\n");
}
########################################################################
package preprocessor;
sub define {
my $stack = shift;
return if $stack->disabled;
die "argument expected\n" unless @_;
my $argument = shift;
for ($argument) {
/^(\w+)\s(.*)$/os && do {
return $stack->define($1, $2);
};
/^(\w+)$/os && do {
return $stack->define($1, 1);
};
die "invalid argument: '$_'\n";
}
}
sub undef {
my $stack = shift;
return if $stack->disabled;
die "argument expected\n" unless @_;
$stack->undefine(@_);
}
sub ifdef {
my $stack = shift;
my $variable = shift;
my $replace = defined(shift);
die "argument expected\n" unless defined($variable);
if ($replace) {
$stack->replace($stack->defined($variable));
} else {
$stack->push($stack->defined($variable));
}
}
sub ifndef {
my $stack = shift;
my $variable = shift;
my $replace = defined(shift);
die "argument expected\n" unless defined($variable);
if ($replace) {
$stack->replace(not $stack->defined($variable));
} else {
$stack->push(not $stack->defined($variable));
}
}
sub if {
my $stack = shift;
die "argument expected\n" unless @_;
my $argument = shift;
my $replace = defined(shift);
for ($argument) {
/^(\w+)==(.*)$/os && do {
# equality
if ($replace) {
return $stack->replace($stack->get($1) eq $2);
} else {
return $stack->push($stack->get($1) eq $2);
}
};
/^(\w+)!=(.*)$/os && do {
# inequality
if ($replace) {
return $stack->replace($stack->get($1) ne $2);
} else {
return $stack->push($stack->get($1) ne $2);
}
};
/^(\w+)$/os && do {
# true value
if ($replace) {
return $stack->replace($stack->get($1));
} else {
return $stack->push($stack->get($1));
}
};
/^!(\w+)$/os && do {
# false value
if ($replace) {
return $stack->replace(not $stack->get($1));
} else {
return $stack->push(not $stack->get($1));
}
};
die "invalid argument: '$_'\n";
}
}
sub else {
my $stack = shift;
die "argument unexpected\n" if @_;
$stack->replace(1);
}
sub elif {
my $stack = shift;
die "argument expected\n" unless @_;
&if($stack, @_, 1);
}
sub elifdef {
my $stack = shift;
die "argument expected\n" unless @_;
&ifdef($stack, @_, 1);
}
sub elifndef {
my $stack = shift;
die "argument expected\n" unless @_;
&ifndef($stack, @_, 1);
}
sub endif {
my $stack = shift;
die "argument unexpected\n" if @_;
$stack->pop;
}
sub error {
my $stack = shift;
return if $stack->disabled;
die "argument expected\n" unless @_;
my $line = $stack->expand(@_);
die "$line\n";
}
sub expand {
my $stack = shift;
return if $stack->disabled;
die "argument expected\n" unless @_;
my $line = $stack->expand(@_);
$stack->print("$line\n");
}
sub literal {
my $stack = shift;
return if $stack->disabled;
die "argument expected\n" unless @_;
my $line = shift;
$stack->print("$line\n");
}
sub include {
my $stack = shift;
return if $stack->disabled;
die "argument expected\n" unless @_;
my $filename = File::Spec::_0_8::catpath(File::Spec::_0_8::splitpath(@_));
if ($stack->{'dependencies'}) {
$stack->visit($filename);
} else {
main::include($stack, $filename);
}
}
sub includesubst {
my ($stack, $filename) = @_;
return if $stack->disabled;
die "argument expected\n" unless $filename;
$filename =~ s/@(\w+)@/$stack->get($1, 1)/gose;
$filename = File::Spec::_0_8::catpath(File::Spec::_0_8::splitpath($filename));
if ($stack->{'dependencies'}) {
$stack->visit($filename);
} else {
main::include($stack, $filename);
}
}
sub filter {
my $stack = shift;
return if $stack->disabled;
die "argument expected\n" unless @_;
foreach (split(/\s/os, shift)) {
$stack->filter($_, 1);
}
}
sub unfilter {
my $stack = shift;
return if $stack->disabled;
die "argument expected\n" unless @_;
foreach (split(/\s/os, shift)) {
$stack->filter($_, 0);
}
}
########################################################################
package filter;
sub emptyLines {
my($stack, $text) = @_;
$text = "" if $text eq "\n";
return $text;
}
sub spaces {
my($stack, $text) = @_;
$text =~ s/ +/ /gos; # middle spaces
$text =~ s/^ //gos; # start spaces
$text =~ s/ (\n?)$/$1/gos; # end spaces
return $text;
}
sub slashslash {
my($stack, $text) = @_;
$text =~ s|//.*?(\n?)$|$1|gos;
return $text;
}
sub substitution {
my($stack, $text) = @_;
$text =~ s/@(\w+)@/$stack->get($1, 1)/gose;
return $text;
}
sub attemptSubstitution {
my($stack, $text) = @_;
$text =~ s/@(\w+)@/$stack->get($1, 0)/gose;
return $text;
}
########################################################################
########################################################################
# This code is from File::Spec::Unix 0.8.
# It is not considered a part of the preprocessor.pl source file
# This code is licensed under the same license as File::Spec itself.
package File::Spec::_0_8;
use Cwd;
sub rel2abs {
my ($path, $base) = @_;
if ( ! File::Spec->file_name_is_absolute( $path ) ) {
if ( !defined( $base ) || $base eq '' ) {
$base = cwd() ;
} elsif ( ! File::Spec->file_name_is_absolute( $base ) ) {
$base = rel2abs( $base );
} else {
$base = File::Spec->canonpath( $base );
}
$path = File::Spec->catdir( $base, $path );
}
return File::Spec->canonpath( $path );
}
sub splitdir {
return split m|/|, $_[1], -1; # Preserve trailing fields
}
sub splitpath {
my ($path, $nofile) = @_;
my ($volume,$directory,$file) = ('','','');
if ( $nofile ) {
$directory = $path;
}
else {
$path =~ m|^ ( (?: .* / (?: \.\.?\Z(?!\n) )? )? ) ([^/]*) |xs;
$directory = $1;
$file = $2;
}
return ($volume,$directory,$file);
}
sub catpath {
my ($volume,$directory,$file) = @_;
if ( $directory ne '' &&
$file ne '' &&
substr( $directory, -1 ) ne '/' &&
substr( $file, 0, 1 ) ne '/'
) {
$directory .= "/$file" ;
}
else {
$directory .= $file ;
}
return $directory ;
}
sub abs2rel {
my($path,$base) = @_;
# Clean up $path
if ( ! File::Spec->file_name_is_absolute( $path ) ) {
$path = rel2abs( $path ) ;
}
else {
$path = File::Spec->canonpath( $path ) ;
}
# Figure out the effective $base and clean it up.
if ( !defined( $base ) || $base eq '' ) {
$base = cwd();
}
elsif ( ! File::Spec->file_name_is_absolute( $base ) ) {
$base = rel2abs( $base ) ;
}
else {
$base = File::Spec->canonpath( $base ) ;
}
# Now, remove all leading components that are the same
my @pathchunks = File::Spec::_0_8::splitdir( $path);
my @basechunks = File::Spec::_0_8::splitdir( $base);
while (@pathchunks && @basechunks && $pathchunks[0] eq $basechunks[0]) {
shift @pathchunks ;
shift @basechunks ;
}
$path = CORE::join( '/', @pathchunks );
$base = CORE::join( '/', @basechunks );
# $base now contains the directories the resulting relative path
# must ascend out of before it can descend to $path_directory. So,
# replace all names with $parentDir
$base =~ s|[^/]+|..|g ;
# Glue the two together, using a separator if necessary, and preventing an
# empty result.
if ( $path ne '' && $base ne '' ) {
$path = "$base/$path" ;
} else {
$path = "$base$path" ;
}
return File::Spec->canonpath( $path ) ;
}
# End code from File::Spec::Unix 0.8.
########################################################################

View File

@ -1,252 +0,0 @@
Preprocessor
============
This is a very primitive line based preprocessor, for times when using
a C preprocessor isn't an option.
Instructions
------------
Any line starting with a hash # and a letter is considered to be a
preprocessor instruction. Other lines starting with a hash are ignored
as comments.
The following preprocessor instructions are recognised.
#define VARIABLE
#define VARIABLE STRING
#undef VARIABLE
#ifdef VARIABLE
#ifndef VARIABLE
#if VARIABLE
#if !VARIABLE
#if VARIABLE==STRING
#if VARIABLE!=STRING
#else
#elifdef VARIABLE
#elifndef VARIABLE
#elif VARIABLE
#elif !VARIABLE
#elif VARIABLE==STRING
#elif VARIABLE!=STRING
#endif
#error STRING
#include FILENAME
#includesubst @VAR@FILENAME
#expand STRING
#literal STRING
#filter FILTER1 FILTER2 ... FILTERn
#unfilter FILTER1 FILTER2 ... FILTERn
Whitespace is significant -- for instance, '#define TEST foo' is not
the same as '#define TEST foo '. The first defines TEST to be a three
character string, the second defines it to be four characters long.
The conditionals (#ifdef, #ifndef, #if, #else, #elifdef, #elifndef,
#elif, #endif) can be nested to arbitrary depth.
The #elifdef, #elifndef, and #elif instructions are equivalent to
#else instructions combined with the relevant conditional. For
example,
#ifdef foo
block 1
#elifdef bar
block 2
#endif
...could be written as:
#ifdef foo
block 1
#else
#ifdef bar
block 2
#endif
#endif
An #else block is included if all previous conditions were false, and
is equivalent to #elif 1, i.e.:
#ifdef foo
foo is defined
#else
foo is not defined
#endif
...is equivalent to:
#ifdef foo
foo is defined
#elif 1
foo is not defined
#endif
#else is not required to be the last condition in an if/el*/endif
series. In particular, along with #else's equivalence to #elif 1
this means that the following holds:
#if 0
never included
#else
always included
#else
never included
#elif 1
never included
#endif
The #error instruction stops execution at this point with a fatal
error. The error message will include the given STRING.
The #include instruction causes the specified file FILENAME to be
recursively processed, as if it was inserted at the current position
in the file. This means conditionals can be started in one file and
ended in another, although this practice is strongly discouraged.
There is no predefined limit to the depth of #includes, and there is
no restriction on self-inclusion, so care should be taken to avoid
infinite loops.
The #includesubst instruction behaves like #include, except that any
variables in @ATSIGNS@ are expanded, like the substitution filter.
The #expand instruction will print the given STRING with variable
substitutions. See the substitution section below.
The #literal instruction will print the given STRING with a newline,
with absolutely no other fixups, guaranteed. This can be used to
output lines starting with a #, which would otherwise be stripped out
as comments.
The #filter instruction enables the specified filters. You can turn
off filters using #unfilter. See the Filters section below.
Variables
---------
Variables consist of any alphanumeric string. They are defined using
the -D command line argument and the #define instruction.
To define all environment variables, so that you can use __HOME__,
etc, with #expand, use the -E argument. Note that arguments that use
non-word characters (like "!") are not included. (In particular,
cygwin is known to include all kinds of weird characters in its
environment variables.)
Two special variables are predefined, FILE and LINE. They can be
passed to #define and #undef, but FILE is automatically redefined at
the top of each file, and LINE is increased by one at the start of
each line.
The variable '1' is predefined with value 1. The variable '0' is not
defined. This allows constructs such as
#if 0
...
#endif
...to be used to quickly comment out large sections. Note, however,
that these are simply variables, and can be redefined. This is
strongly discouraged.
Substitution
------------
In any line starting with the instruction #expand, variable names
contained between double underscores, like __THIS__, are expanded to
their string values, or the empty string if they are not defined.
For example to print the current filename:
#expand <!-- This file is automatically generated from __FILE__ -->
Normal lines are not affected.
See also the substitution filter below.
Filters
-------
The following filters are supported:
emptyLines
Strips blank lines from the output.
slashslash
Strips everything from the first two consecutive slash (/)
characters until the end of the line.
spaces
Collapses sequences of spaces into a single space.
substitution
Replaces occurrences of "@foo@" by the value of the variable
"foo". If @foo@ is not defined, the preprocessor will terminate
with a fatal error.
attemptSubstitution
Replaces occurrences of "@foo@" by the value of the variable
"foo". If @foo@ is not defined, the empty string is used instead.
Filters are run in alphabetical order, on a per-line basis.
Command Line Arguments
----------------------
Syntax:
preprocessor.pl [-Dvariable[=value]] [-E] [-Ffilter]
[-Ifilename] [-d] [--marker=<c>] [--] filenames...
-Dvariable
Set variable to 1 before processing the files.
-Dvariable=value
Set variable to value before processing the files.
-E
Define all environment variables.
-Ffilter
Enables the specified filter.
-Ifilename
Include filename before any other files.
-d
Run through the files on the command line, listing the files they
depend on given the specified environment variables and filters.
Doesn't recurse into those files. The output is given as one
dependency per line, and filenames are given relative to the
current directory.
--line-endings=type
Set the type of line endings to use. "type" can be either "cr",
"lf", or "crlf". The default is whatever your platform uses for
perl's "\n" character.
--marker=<c>
Use the character <c> instead of '#' as the marker for preprocessor
instructions.
--
Indicates the end of non-filename arguments.
-
Indicates that input should come from standard input.
If no filenames are provided, standard input is used instead. If many
files are provided, they are processed sequentially, as if they were
one big file. -I files are handled before the other files, in the
order specified, but after handling any -D, -E, -F, and -d arguments.
Contact Details
---------------
Feel free to e-mail me if you have any questions:
Ian Hickson <preprocessor@software.hixie.ch>

View File

@ -220,7 +220,7 @@ AC_SUBST(COMPILE_ENVIRONMENT)
MOZ_ARG_WITH_STRING(l10n-base,
[ --with-l10n-base=DIR path to l10n repositories],
L10NBASEDIR=$withval)
if test ! -z "$L10NBASEDIR"; then
if test -n "$L10NBASEDIR"; then
if test "$L10NBASEDIR" = "yes" -o "$L10NBASEDIR" = "no"; then
AC_MSG_ERROR([--with-l10n-base must specify a path])
elif test -d "$L10NBASEDIR"; then
@ -4378,8 +4378,7 @@ if test "$ac_cv_i18n_lc_messages" = yes; then
fi
AC_HAVE_FUNCS(localeconv)
fi # SKIP_COMPILER_CHECKS
fi # ! SKIP_COMPILER_CHECKS
TARGET_XPCOM_ABI=
if test -n "${CPU_ARCH}" -a -n "${TARGET_COMPILER_ABI}"; then
@ -7812,20 +7811,11 @@ else
fi
dnl ========================================================
dnl Profile guided optimization
dnl Profile guided optimization (gcc checks)
dnl ========================================================
dnl Test for profiling options
dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
dnl Provide a switch to disable PGO even when called via profiledbuild.
MOZ_ARG_DISABLE_BOOL(profile-guided-optimization,
[ --disable-profile-guided-optimization
Don't build with PGO even if called via make profiledbuild],
MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE=1,
MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE=)
AC_SUBST(MOZ_PROFILE_GUIDED_OPTIMIZE_DISABLE)
_SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
@ -7963,7 +7953,7 @@ CXXFLAGS="$_SAVE_CXXFLAGS"
if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
fi
fi # SKIP_COMPILER_CHECKS
fi # ! SKIP_COMPILER_CHECKS
dnl ========================================================
dnl C++ exceptions (g++/VC/irix6/Sun only - for now)
@ -9085,7 +9075,7 @@ if test "$MOZ_X11"; then
[ AC_MSG_ERROR([Could not compile basic X program.]) ])
CFLAGS="$_SAVE_CFLAGS"
if test ! -z "$MISSING_X"; then
if test -n "$MISSING_X"; then
AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
fi

View File

@ -1698,16 +1698,6 @@ public:
*/
static nsresult CreateStructuredClone(JSContext* cx, jsval val, jsval* rval);
/**
* Reparents the given object and all subobjects to the given scope. Also
* fixes all the prototypes. Assumes obj is properly rooted, that obj has no
* getter functions that can cause side effects, and that the only types of
* objects nested within obj are the types that are cloneable via the
* CreateStructuredClone function above.
*/
static nsresult ReparentClonedObjectToScope(JSContext* cx, JSObject* obj,
JSObject* scope);
/**
* Strip all \n, \r and nulls from the given string
* @param aString the string to remove newlines from [in/out]

View File

@ -56,7 +56,6 @@
#include "nsIDOMDragEvent.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentRange.h"
#include "nsIDOMRange.h"
#include "nsIFormControl.h"
#include "nsIDOMHTMLAreaElement.h"
@ -399,10 +398,9 @@ DragDataProducer::GetNodeString(nsIContent* inNode,
// use a range to get the text-equivalent of the node
nsCOMPtr<nsIDOMDocument> doc;
node->GetOwnerDocument(getter_AddRefs(doc));
nsCOMPtr<nsIDOMDocumentRange> docRange(do_QueryInterface(doc));
if (docRange) {
if (doc) {
nsCOMPtr<nsIDOMRange> range;
docRange->CreateRange(getter_AddRefs(range));
doc->CreateRange(getter_AddRefs(range));
if (range) {
range->SelectNode(node);
range->ToString(outNodeString);

View File

@ -695,8 +695,10 @@ nsContentUtils::InitializeEventTable() {
,
{ nsGkAtoms::onanimationstart, NS_ANIMATION_START, EventNameType_None, NS_ANIMATION_EVENT },
{ nsGkAtoms::onanimationend, NS_ANIMATION_END, EventNameType_None, NS_ANIMATION_EVENT },
{ nsGkAtoms::onanimationiteration, NS_ANIMATION_ITERATION, EventNameType_None, NS_ANIMATION_EVENT }
{ nsGkAtoms::onanimationiteration, NS_ANIMATION_ITERATION, EventNameType_None, NS_ANIMATION_EVENT },
#endif
{ nsGkAtoms::onbeforeprint, NS_BEFOREPRINT, EventNameType_HTMLXUL, NS_EVENT },
{ nsGkAtoms::onafterprint, NS_AFTERPRINT, EventNameType_HTMLXUL, NS_EVENT }
};
sAtomEventTable = new nsDataHashtable<nsISupportsHashKey, EventNameMapping>;
@ -6100,89 +6102,6 @@ nsContentUtils::CreateStructuredClone(JSContext* cx,
*rval = output;
return NS_OK;
}
// static
nsresult
nsContentUtils::ReparentClonedObjectToScope(JSContext* cx,
JSObject* obj,
JSObject* scope)
{
JSAutoRequest ar(cx);
scope = JS_GetGlobalForObject(cx, scope);
nsAutoTArray<ReparentObjectData, 20> objectData;
objectData.AppendElement(ReparentObjectData(cx, obj));
while (!objectData.IsEmpty()) {
ReparentObjectData& data = objectData[objectData.Length() - 1];
if (!data.ids) {
NS_ASSERTION(!data.index, "Shouldn't have index here");
// Typed arrays are special and don't need to be enumerated.
if (js_IsTypedArray(data.obj)) {
if (!js_ReparentTypedArrayToScope(cx, data.obj, scope)) {
return NS_ERROR_FAILURE;
}
// No need to enumerate anything here.
objectData.RemoveElementAt(objectData.Length() - 1);
continue;
}
JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(JS_GET_CLASS(cx, data.obj));
if (!key) {
// We should never be reparenting an object that doesn't have a standard
// proto key.
return NS_ERROR_FAILURE;
}
// Fix the prototype and parent first.
JSObject* proto;
if (!js_GetClassPrototype(cx, scope, key, &proto) ||
!JS_SetPrototype(cx, data.obj, proto) ||
!JS_SetParent(cx, data.obj, scope)) {
return NS_ERROR_FAILURE;
}
// Primitive arrays don't need to be enumerated either but the proto and
// parent needed to be fixed above. Now we can just move on.
if (js_IsDensePrimitiveArray(data.obj)) {
objectData.RemoveElementAt(objectData.Length() - 1);
continue;
}
// And now enumerate the object's properties.
if (!(data.ids = JS_Enumerate(cx, data.obj))) {
return NS_ERROR_FAILURE;
}
}
// If we've gone through all the object's properties then we're done with
// this frame.
if (data.index == data.ids->length) {
objectData.RemoveElementAt(objectData.Length() - 1);
continue;
}
// Get the id and increment!
jsid id = data.ids->vector[data.index++];
jsval prop;
if (!JS_GetPropertyById(cx, data.obj, id, &prop)) {
return NS_ERROR_FAILURE;
}
// Push a new frame if this property is an object.
if (!JSVAL_IS_PRIMITIVE(prop)) {
objectData.AppendElement(ReparentObjectData(cx, JSVAL_TO_OBJECT(prop)));
}
}
return NS_OK;
}
struct ClassMatchingInfo {
nsAttrValue::AtomArray mClasses;
nsCaseTreatment mCaseTreatment;

View File

@ -324,17 +324,18 @@ nsDOMFile::MozSlice(PRInt64 aStart, PRInt64 aEnd,
return NS_OK;
}
const PRUint32 sFileStreamFlags =
nsIFileInputStream::CLOSE_ON_EOF |
nsIFileInputStream::REOPEN_ON_REWIND |
nsIFileInputStream::DEFER_OPEN;
NS_IMETHODIMP
nsDOMFile::GetInternalStream(nsIInputStream **aStream)
{
return mIsFullFile ?
NS_NewLocalFileInputStream(aStream, mFile, -1, -1,
nsIFileInputStream::CLOSE_ON_EOF |
nsIFileInputStream::REOPEN_ON_REWIND) :
NS_NewLocalFileInputStream(aStream, mFile, -1, -1, sFileStreamFlags) :
NS_NewPartialLocalFileInputStream(aStream, mFile, mStart, mLength,
-1, -1,
nsIFileInputStream::CLOSE_ON_EOF |
nsIFileInputStream::REOPEN_ON_REWIND);
-1, -1, sFileStreamFlags);
}
NS_IMETHODIMP
@ -628,32 +629,50 @@ nsDOMFile::Initialize(nsISupports* aOwner,
PRUint32 aArgc,
jsval* aArgv)
{
nsresult rv;
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR; // Real short trip
}
NS_ENSURE_TRUE(aArgc > 0, NS_ERROR_UNEXPECTED);
// We expect to get a path to represent as a File object
if (!JSVAL_IS_STRING(aArgv[0]))
return NS_ERROR_UNEXPECTED;
// We expect to get a path to represent as a File object,
// or an nsIFile
nsCOMPtr<nsIFile> file;
if (!JSVAL_IS_STRING(aArgv[0])) {
// Lets see if it's an nsIFile
if (!JSVAL_IS_OBJECT(aArgv[0])) {
return NS_ERROR_UNEXPECTED; // We're not interested
}
JSString* str = JS_ValueToString(aCx, aArgv[0]);
NS_ENSURE_TRUE(str, NS_ERROR_XPC_BAD_CONVERT_JS);
JSObject* obj = JSVAL_TO_OBJECT(aArgv[0]);
NS_ASSERTION(obj, "This is a bit odd");
nsDependentJSString xpcomStr;
if (!xpcomStr.init(aCx, str)) {
return NS_ERROR_XPC_BAD_CONVERT_JS;
// Is it an nsIFile
file = do_QueryInterface(
nsContentUtils::XPConnect()->
GetNativeOfWrapper(aCx, obj));
if (!file)
return NS_ERROR_UNEXPECTED;
} else {
// It's a string
JSString* str = JS_ValueToString(aCx, aArgv[0]);
NS_ENSURE_TRUE(str, NS_ERROR_XPC_BAD_CONVERT_JS);
nsDependentJSString xpcomStr;
if (!xpcomStr.init(aCx, str)) {
return NS_ERROR_XPC_BAD_CONVERT_JS;
}
nsCOMPtr<nsILocalFile> localFile;
rv = NS_NewLocalFile(xpcomStr, PR_FALSE, getter_AddRefs(localFile));
NS_ENSURE_SUCCESS(rv, rv);
file = do_QueryInterface(localFile);
NS_ASSERTION(file, "This should never happen");
}
nsCOMPtr<nsILocalFile> localFile;
nsresult rv = NS_NewLocalFile(xpcomStr,
PR_FALSE, getter_AddRefs(localFile));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> file = do_QueryInterface(localFile, &rv);
NS_ENSURE_SUCCESS(rv, rv);
PRBool exists;
rv = file->Exists(&exists);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -1695,7 +1695,6 @@ NS_INTERFACE_TABLE_HEAD(nsDocument)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3DocumentEvent)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentStyle)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNSDocumentStyle)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentRange)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentXBL)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIScriptObjectPrincipal)
NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3EventTarget)

View File

@ -55,8 +55,6 @@
#include "nsIDOMDocumentXBL.h"
#include "nsIDOMNSDocument.h"
#include "nsIDOMNSDocumentStyle.h"
#include "nsIDOMDocumentRange.h"
#include "nsIDOMDocumentTraversal.h"
#include "nsStubDocumentObserver.h"
#include "nsIDOM3EventTarget.h"
#include "nsIDOMNSEventTarget.h"
@ -498,8 +496,6 @@ class nsDocument : public nsIDocument,
public nsIDOMDocumentEvent,
public nsIDOM3DocumentEvent,
public nsIDOMNSDocumentStyle,
public nsIDOMDocumentRange,
public nsIDOMDocumentTraversal,
public nsIDOMDocumentXBL,
public nsSupportsWeakReference,
public nsIDOMEventTarget,
@ -814,12 +810,6 @@ public:
// nsIDOMNSDocumentStyle
NS_DECL_NSIDOMNSDOCUMENTSTYLE
// nsIDOMDocumentRange
NS_DECL_NSIDOMDOCUMENTRANGE
// nsIDOMDocumentTraversal
NS_DECL_NSIDOMDOCUMENTTRAVERSAL
// nsIDOMDocumentXBL
NS_DECL_NSIDOMDOCUMENTXBL
@ -1263,8 +1253,6 @@ protected:
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocument, nsDocument) \
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNSDocument, nsDocument) \
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocumentEvent, nsDocument) \
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocumentTraversal, \
nsDocument) \
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMEventTarget, nsDocument) \
NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNode, nsDocument)

View File

@ -862,6 +862,31 @@ nsFrameLoader::Show(PRInt32 marginWidth, PRInt32 marginHeight,
return PR_TRUE;
}
void
nsFrameLoader::MarginsChanged(PRUint32 aMarginWidth,
PRUint32 aMarginHeight)
{
// We assume that the margins are always zero for remote frames.
if (mRemoteFrame)
return;
// If there's no docshell, we're probably not up and running yet.
// nsFrameLoader::Show() will take care of setting the right
// margins.
if (!mDocShell)
return;
// Set the margins
mDocShell->SetMarginWidth(aMarginWidth);
mDocShell->SetMarginHeight(aMarginHeight);
// Trigger a restyle if there's a prescontext
nsRefPtr<nsPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
if (presContext)
presContext->RebuildAllStyleData(nsChangeHint(0));
}
bool
nsFrameLoader::ShowRemoteFrame(const nsIntSize& size)
{

View File

@ -207,6 +207,11 @@ public:
PRInt32 scrollbarPrefX, PRInt32 scrollbarPrefY,
nsSubDocumentFrame* frame);
/**
* Called when the margin properties of the containing frame are changed.
*/
void MarginsChanged(PRUint32 aMarginWidth, PRUint32 aMarginHeight);
/**
* Called from the layout frame associated with this frame loader, when
* the frame is being torn down; this notifies us that out widget and view

View File

@ -631,6 +631,7 @@ GK_ATOM(OFF, "OFF")
GK_ATOM(ol, "ol")
GK_ATOM(omitXmlDeclaration, "omit-xml-declaration")
GK_ATOM(onabort, "onabort")
GK_ATOM(onafterprint, "onafterprint")
GK_ATOM(onafterscriptexecute, "onafterscriptexecute")
#ifdef MOZ_CSS_ANIMATIONS
GK_ATOM(onanimationend, "onanimationend")
@ -640,6 +641,7 @@ GK_ATOM(onanimationstart, "onanimationstart")
GK_ATOM(onbeforecopy, "onbeforecopy")
GK_ATOM(onbeforecut, "onbeforecut")
GK_ATOM(onbeforepaste, "onbeforepaste")
GK_ATOM(onbeforeprint, "onbeforeprint")
GK_ATOM(onbeforescriptexecute, "onbeforescriptexecute")
GK_ATOM(onbeforeunload, "onbeforeunload")
GK_ATOM(onblur, "onblur")

View File

@ -45,10 +45,13 @@ file.append("test");
file.append("chrome");
file.append("fileconstructor_file.png");
var domfile = new File(file.path);
ok(domfile instanceof File, "File() should return a File");
is(domfile.type, "image/png", "File should be a PNG");
is(domfile.size, 95, "File has size 95 (and more importantly we can read it)");
doTest(new File(file.path));
doTest(new File(file));
function doTest(domfile) {
ok(domfile instanceof File, "File() should return a File");
is(domfile.type, "image/png", "File should be a PNG");
is(domfile.size, 95, "File has size 95 (and more importantly we can read it)");
}
try {
var boomfile = new File();

View File

@ -202,12 +202,10 @@ WebGLContext::BindBuffer(WebGLenum target, nsIWebGLBuffer *bobj)
if (!GetConcreteObjectAndGLName("bindBuffer", bobj, &buf, &bufname, &isNull))
return NS_OK;
if (target == LOCAL_GL_ARRAY_BUFFER) {
mBoundArrayBuffer = buf;
} else if (target == LOCAL_GL_ELEMENT_ARRAY_BUFFER) {
mBoundElementArrayBuffer = buf;
} else {
return ErrorInvalidEnumInfo("BindBuffer: target", target);
if (target != LOCAL_GL_ARRAY_BUFFER &&
target != LOCAL_GL_ELEMENT_ARRAY_BUFFER)
{
return ErrorInvalidEnumInfo("bindBuffer: target", target);
}
if (!isNull) {
@ -217,6 +215,14 @@ WebGLContext::BindBuffer(WebGLenum target, nsIWebGLBuffer *bobj)
buf->SetHasEverBeenBound(PR_TRUE);
}
// we really want to do this AFTER all the validation is done, otherwise our bookkeeping could get confused.
// see bug 656752
if (target == LOCAL_GL_ARRAY_BUFFER) {
mBoundArrayBuffer = buf;
} else if (target == LOCAL_GL_ELEMENT_ARRAY_BUFFER) {
mBoundElementArrayBuffer = buf;
}
MakeContextCurrent();
gl->fBindBuffer(target, bufname);

View File

@ -1390,6 +1390,12 @@ nsDOMEvent::GetPreventDefault(PRBool* aReturn)
return NS_OK;
}
NS_IMETHODIMP
nsDOMEvent::GetDefaultPrevented(PRBool* aReturn)
{
return GetPreventDefault(aReturn);
}
void
nsDOMEvent::Serialize(IPC::Message* aMsg, PRBool aSerializeInterfaceType)
{

View File

@ -113,7 +113,6 @@
#include "nsIObserverService.h"
#include "nsIDocShell.h"
#include "nsIMarkupDocumentViewer.h"
#include "nsIDOMDocumentRange.h"
#include "nsIDOMDocumentEvent.h"
#include "nsIDOMMouseScrollEvent.h"
#include "nsIDOMDragEvent.h"
@ -1395,6 +1394,12 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext,
handler.OnQueryDOMWidgetHittest(static_cast<nsQueryContentEvent*>(aEvent));
}
break;
case NS_QUERY_SCROLL_TARGET_INFO:
{
DoQueryScrollTargetInfo(static_cast<nsQueryContentEvent*>(aEvent),
aTargetFrame);
break;
}
case NS_SELECTION_SET:
{
nsSelectionEvent *selectionEvent =
@ -2565,7 +2570,8 @@ nsresult
nsEventStateManager::DoScrollText(nsIFrame* aTargetFrame,
nsMouseScrollEvent* aMouseEvent,
nsIScrollableFrame::ScrollUnit aScrollQuantity,
PRBool aAllowScrollSpeedOverride)
PRBool aAllowScrollSpeedOverride,
nsQueryContentEvent* aQueryEvent)
{
nsIScrollableFrame* frameToScroll = nsnull;
nsIFrame* scrollFrame = aTargetFrame;
@ -2644,6 +2650,19 @@ nsEventStateManager::DoScrollText(nsIFrame* aTargetFrame,
}
if (!passToParent && frameToScroll) {
if (aQueryEvent) {
nscoord appUnitsPerDevPixel =
aTargetFrame->PresContext()->AppUnitsPerDevPixel();
aQueryEvent->mReply.mLineHeight =
frameToScroll->GetLineScrollAmount().height / appUnitsPerDevPixel;
aQueryEvent->mReply.mPageHeight =
frameToScroll->GetPageScrollAmount().height / appUnitsPerDevPixel;
aQueryEvent->mReply.mPageWidth =
frameToScroll->GetPageScrollAmount().width / appUnitsPerDevPixel;
aQueryEvent->mSucceeded = PR_TRUE;
return NS_OK;
}
if (aScrollQuantity == nsIScrollableFrame::LINES) {
numLines =
nsMouseWheelTransaction::AccelerateWheelDelta(numLines, isHorizontal,
@ -2671,7 +2690,9 @@ nsEventStateManager::DoScrollText(nsIFrame* aTargetFrame,
nsIScrollableFrame::ScrollMode mode;
if (aMouseEvent->scrollFlags & nsMouseScrollEvent::kNoDefer) {
mode = nsIScrollableFrame::INSTANT;
} else if (aScrollQuantity != nsIScrollableFrame::DEVICE_PIXELS) {
} else if (aScrollQuantity != nsIScrollableFrame::DEVICE_PIXELS ||
(aMouseEvent->scrollFlags &
nsMouseScrollEvent::kAllowSmoothScroll) != 0) {
mode = nsIScrollableFrame::SMOOTH;
} else {
mode = nsIScrollableFrame::NORMAL;
@ -2689,7 +2710,7 @@ nsEventStateManager::DoScrollText(nsIFrame* aTargetFrame,
aTargetFrame->PresContext()->FrameManager()->GetRootFrame());
if (newFrame)
return DoScrollText(newFrame, aMouseEvent, aScrollQuantity,
aAllowScrollSpeedOverride);
aAllowScrollSpeedOverride, aQueryEvent);
}
aMouseEvent->scrollOverflow = numLines;
@ -3052,7 +3073,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
}
if (aEvent->message == NS_MOUSE_PIXEL_SCROLL) {
if (action == MOUSE_SCROLL_N_LINES ||
if (action == MOUSE_SCROLL_N_LINES || action == MOUSE_SCROLL_PAGE ||
(msEvent->scrollFlags & nsMouseScrollEvent::kIsMomentum)) {
action = MOUSE_SCROLL_PIXELS;
} else {
@ -3060,7 +3081,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
action = -1;
}
} else if (msEvent->scrollFlags & nsMouseScrollEvent::kHasPixels) {
if (action == MOUSE_SCROLL_N_LINES ||
if (useSysNumLines || action == MOUSE_SCROLL_N_LINES ||
(msEvent->scrollFlags & nsMouseScrollEvent::kIsMomentum)) {
// Don't scroll lines when a pixel scroll event will follow.
// Also, don't do history scrolling or zooming for momentum scrolls.
@ -4647,6 +4668,20 @@ nsEventStateManager::DoContentCommandScrollEvent(nsContentCommandEvent* aEvent)
return NS_OK;
}
void
nsEventStateManager::DoQueryScrollTargetInfo(nsQueryContentEvent* aEvent,
nsIFrame* aTargetFrame)
{
nsMouseScrollEvent* msEvent = aEvent->mInput.mMouseScrollEvent;
nsIScrollableFrame::ScrollUnit unit;
if (msEvent->scrollFlags & nsMouseScrollEvent::kIsFullPage) {
unit = nsIScrollableFrame::PAGES;
} else {
unit = nsIScrollableFrame::LINES;
}
DoScrollText(aTargetFrame, msEvent, unit, PR_FALSE, aEvent);
}
void
nsEventStateManager::SetActiveManager(nsEventStateManager* aNewESM,
nsIContent* aContent)

View File

@ -324,10 +324,19 @@ protected:
nsMouseScrollEvent* aEvent,
nsPresContext* aPresContext,
nsEventStatus* aStatus);
/**
* @param aQueryEvent If you set vailid pointer for this, DoScrollText()
* computes the line-height and page size of current
* mouse wheel scroll target and sets it to the event.
* And then, this method does NOT scroll any scrollable
* elements. I.e., you can just query the scroll target
* information.
*/
nsresult DoScrollText(nsIFrame* aTargetFrame,
nsMouseScrollEvent* aMouseEvent,
nsIScrollableFrame::ScrollUnit aScrollQuantity,
PRBool aAllowScrollSpeedOverride);
PRBool aAllowScrollSpeedOverride,
nsQueryContentEvent* aQueryEvent = nsnull);
void DoScrollHistory(PRInt32 direction);
void DoScrollZoom(nsIFrame *aTargetFrame, PRInt32 adjustment);
nsresult GetMarkupDocumentViewer(nsIMarkupDocumentViewer** aMv);
@ -397,6 +406,9 @@ protected:
nsresult DoContentCommandEvent(nsContentCommandEvent* aEvent);
nsresult DoContentCommandScrollEvent(nsContentCommandEvent* aEvent);
void DoQueryScrollTargetInfo(nsQueryContentEvent* aEvent,
nsIFrame* aTargetFrame);
PRBool RemoteQueryContentEvent(nsEvent *aEvent);
mozilla::dom::TabParent *GetCrossProcessTarget();
PRBool IsTargetCrossProcess(nsGUIEvent *aEvent);

View File

@ -82,7 +82,6 @@ _TEST_FILES = \
bug457672.html \
test_draggableprop.html \
test_bug489671.html \
test_bug493251.html \
test_bug502818.html \
test_bug508479.html \
test_bug508906.html \
@ -105,6 +104,7 @@ _TEST_FILES = \
test_bug641477.html \
test_bug648573.html \
test_bug615597.html \
test_bug656954.html \
$(NULL)
#bug 585630
@ -114,6 +114,13 @@ _TEST_FILES += \
$(NULL)
endif
# bug 565245
ifneq (Linux,$(OS_ARCH))
_TEST_FILES += \
test_bug493251.html \
$(NULL)
endif
_CHROME_FILES = \
test_bug415498.xul \
bug415498-doc1.html \

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=656954
-->
<head>
<title>Test for Bug 656954</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=656954">Mozilla Bug 656954</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 656954 **/
var e = document.createEvent("Event");
is(e.defaultPrevented, false,
"After creating event defaultPrevented should be false");
e.initEvent("foo", true, true);
var el = document.createElement("div");
el.addEventListener("foo",
function(evt) {
evt.preventDefault();
}, false);
el.dispatchEvent(e);
is(e.defaultPrevented, true, "preventDefault() should have been called!");
e = document.createEvent("Event");
e.initEvent("foo", true, false);
el.dispatchEvent(e);
is(e.defaultPrevented, false, "preventDefault() should not have any effect!");
</script>
</pre>
</body>
</html>

View File

@ -36,6 +36,9 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsTimeRanges_h__
#define nsTimeRanges_h__
#include "nsIDOMTimeRanges.h"
#include "nsISupports.h"
#include "nsTArray.h"
@ -64,3 +67,5 @@ private:
nsAutoTArray<TimeRange,4> mRanges;
};
#endif // nsTimeRanges_h__

View File

@ -226,6 +226,27 @@ class AudioSetVolumeEvent : public nsRunnable
double mVolume;
};
class AudioMinWriteSampleEvent : public nsRunnable
{
public:
AudioMinWriteSampleEvent(AudioChild* aChild)
{
mAudioChild = aChild;
}
NS_IMETHOD Run()
{
if (!mAudioChild->IsIPCOpen())
return NS_OK;
mAudioChild->SendMinWriteSample();
return NS_OK;
}
nsRefPtr<AudioChild> mAudioChild;
};
class AudioDrainEvent : public nsRunnable
{
public:
@ -670,9 +691,11 @@ nsAudioStreamRemote::Available()
PRInt32 nsAudioStreamRemote::GetMinWriteSamples()
{
/** TODO: Implement this function for remoting. We could potentially remote
to a backend which has a start threshold... */
return 1;
if (!mAudioChild)
return -1;
nsCOMPtr<nsIRunnable> event = new AudioMinWriteSampleEvent(mAudioChild);
NS_DispatchToMainThread(event);
return mAudioChild->WaitForMinWriteSample();
}
void

View File

@ -8,7 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500174
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<body onload="run()">
<script class="testbody" type="text/javascript">
<![CDATA[
@ -18,16 +18,21 @@ function run()
{
var svgDoc = document.getElementById('svg');
var div = document.getElementById("div");
var x = div.offsetLeft;
var y = div.offsetTop;
var good = document.getElementById('good');
var fo = document.getElementById('fo');
var elementFromPoint = document.elementFromPoint(55 + x, 55 + y);
is(good, elementFromPoint, 'pointer-events="all"');
elementFromPoint = document.elementFromPoint(205 + x, 55 + y);
is(good, elementFromPoint, 'foreignObject with clip-path');
elementFromPoint = document.elementFromPoint(205 + x + 20, 55 + y + 20);
is(fo, elementFromPoint, 'foreignObject with clip-path');
// Get the coords of the origin of the SVG canvas:
var originX = div.offsetLeft;
var originY = div.offsetTop;
var circle = document.getElementById('circle');
var path = document.getElementById('path');
var elementFromPoint = document.elementFromPoint(originX + 55, originY + 55);
is(elementFromPoint, circle, 'Over circle stroke with pointer-events="all"');
elementFromPoint = document.elementFromPoint(originX + 205, originY + 55);
is(elementFromPoint, circle, 'Over foreignObject, outside clip path');
elementFromPoint = document.elementFromPoint(originX + 225, originY + 75);
// XXX disabled. See See https://bugzilla.mozilla.org/show_bug.cgi?id=580983#c116
//is(elementFromPoint, path, 'Over foreignObject, inside clip path');
SimpleTest.finish();
}
@ -43,14 +48,14 @@ function run()
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" id="svg">
<defs>
<clipPath id="clip">
<rect x="20" y="20" width="50" height="50"/>
<rect x="20" y="20" width="30" height="30"/>
</clipPath>
</defs>
<rect id="bad" width="100%" height="100%" fill="green"/>
<circle id="good" cx="50%" cy="50%" r="1" stroke-width="1000" fill="black" pointer-events="all"/>
<foreignObject id="fo" x="200" y="50" width="50" height="50" clip-path="url(#clip)">
<svg onload="run()">
<rect width="100%" height="100%" fill="green"/>
<rect id="bad" width="100%" height="100%" fill="blue"/>
<circle id="circle" cx="50%" cy="50%" r="1" stroke-width="1000" fill="black" pointer-events="all"/>
<foreignObject id="fo" x="200" y="50" width="50" height="50" clip-path="url(#clip)">
<svg>
<path id="path" d="M0,0 H50 V50 H0 Z" fill="green"/>
</svg>
</foreignObject>
</svg>

View File

@ -217,9 +217,8 @@ function getRange(aSourceNode, aFragment) {
function getParsedDocument(aPath) {
var doc = do_parse_document(aPath, "application/xml");
do_check_true(doc.documentElement.localName != "parsererror");
do_check_true(doc instanceof C_i.nsIDOMDocumentTraversal);
do_check_true(doc instanceof C_i.nsIDOMXPathEvaluator);
do_check_true(doc instanceof C_i.nsIDOMDocumentRange);
do_check_true(doc instanceof C_i.nsIDOMDocument);
// Clean out whitespace.
var walker = doc.createTreeWalker(doc,
@ -517,7 +516,7 @@ function run_miscellaneous_tests() {
// Requested by smaug: A range involving a comment as a document child.
doc = parser.parseFromString("<!-- foo --><foo/>", "application/xml");
do_check_true(doc instanceof C_i.nsIDOMDocumentRange);
do_check_true(doc instanceof C_i.nsIDOMDocument);
do_check_eq(doc.childNodes.length, 2);
baseRange = doc.createRange();
baseRange.setStart(doc.firstChild, 1);

View File

@ -135,6 +135,11 @@ DEFINES += -DOS2_HIGH_MEMORY
endif
endif
ifeq ($(OS_TARGET),Android)
# default to user readable only to fit Android security model
DEFINES += -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600
endif
include $(topsrcdir)/config/rules.mk
# next line allows use of MOZ_OBJDIR in .mozconfig with older gcc on BeOS, maybe others

View File

@ -1389,6 +1389,11 @@ nsDocShell::LoadURI(nsIURI * aURI,
}
}
if (aLoadFlags & LOAD_FLAGS_DISALLOW_INHERIT_OWNER) {
inheritOwner = PR_FALSE;
owner = do_CreateInstance("@mozilla.org/nullprincipal;1");
}
PRUint32 flags = 0;
if (inheritOwner)
@ -9696,6 +9701,18 @@ nsDocShell::AddState(nsIVariant *aData, const nsAString& aTitle,
document->SetDocumentURI(newURI);
AddURIVisit(newURI, oldURI, oldURI, 0);
// AddURIVisit doesn't set the title for the new URI in global history,
// so do that here.
if (mUseGlobalHistory) {
nsCOMPtr<IHistory> history = services::GetHistoryService();
if (history) {
history->SetURITitle(newURI, mTitle);
}
else if (mGlobalHistory) {
mGlobalHistory->SetPageTitle(newURI, mTitle);
}
}
}
else {
FireDummyOnLocationChange();

View File

@ -214,6 +214,11 @@ interface nsIWebNavigation : nsISupports
*/
const unsigned long LOAD_FLAGS_FORCE_ALLOW_COOKIES = 0x20000;
/**
* Prevent the owner principal from being inherited for this load.
*/
const unsigned long LOAD_FLAGS_DISALLOW_INHERIT_OWNER = 0x40000;
/**
* Loads a given URI. This will give priority to loading the requested URI
* in the object implementing this interface. If it can't be loaded here

View File

@ -52,6 +52,7 @@ _BROWSER_TEST_FILES = \
browser_bug388121-2.js \
browser_bug441169.js \
browser_bug503832.js \
browser_loadDisallowInherit.js \
file_bug503832.html \
browser_bug554155.js \
$(NULL)

View File

@ -0,0 +1,63 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function test() {
waitForExplicitFinish();
let tab = gBrowser.selectedTab = gBrowser.addTab();
registerCleanupFunction(function () {
gBrowser.removeTab(tab);
});
let browser = gBrowser.getBrowserForTab(tab);
function loadURL(url, flags, func) {
browser.addEventListener("load", function loadListener(e) {
if (browser.currentURI.spec != url)
return;
browser.removeEventListener(e.type, loadListener, true);
func();
}, true);
browser.loadURIWithFlags(url, flags, null, null, null);
}
// Load a normal http URL
function testURL(url, func) {
loadURL("http://example.com/", 0, function () {
let pagePrincipal = browser.contentPrincipal;
ok(pagePrincipal, "got principal for http:// page");
// Now load the URL normally
loadURL(url, 0, function () {
ok(browser.contentPrincipal.equals(pagePrincipal), url + " should inherit principal");
// Now load the URL and disallow inheriting the principal
let webNav = Components.interfaces.nsIWebNavigation;
loadURL(url, webNav.LOAD_FLAGS_DISALLOW_INHERIT_OWNER, function () {
let newPrincipal = browser.contentPrincipal;
ok(newPrincipal, "got inner principal");
ok(!newPrincipal.equals(pagePrincipal),
url + " should not inherit principal when loaded with DISALLOW_INHERIT_OWNER");
func();
});
});
});
}
let urls = [
"data:text/html,<body>hi",
"javascript:1;"
];
function nextTest() {
let url = urls.shift();
if (url)
testURL(url, nextTest);
else
finish();
}
nextTest();
}

View File

@ -71,7 +71,7 @@
#include "nsIRunnable.h"
#include "nsThreadUtils.h"
#include "nsDOMEventTargetWrapperCache.h"
#include "xpcpublic.h"
#include "xpcprivate.h"
// General helper includes
#include "nsGlobalWindow.h"
@ -248,8 +248,6 @@
#include "nsIDOMAnimationEvent.h"
#endif
#include "nsIDOMNSDocumentStyle.h"
#include "nsIDOMDocumentRange.h"
#include "nsIDOMDocumentTraversal.h"
#include "nsIDOMDocumentXBL.h"
#include "nsIDOMElementCSSInlineStyle.h"
#include "nsIDOMLinkStyle.h"
@ -1687,6 +1685,8 @@ jsid nsDOMClassInfo::sOntouchmove_id = JSID_VOID;
jsid nsDOMClassInfo::sOntouchenter_id = JSID_VOID;
jsid nsDOMClassInfo::sOntouchleave_id = JSID_VOID;
jsid nsDOMClassInfo::sOntouchcancel_id = JSID_VOID;
jsid nsDOMClassInfo::sOnbeforeprint_id = JSID_VOID;
jsid nsDOMClassInfo::sOnafterprint_id = JSID_VOID;
static const JSClass *sObjectClass = nsnull;
@ -2023,6 +2023,8 @@ nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
SET_JSID_TO_STRING(sOntouchenter_id, cx, "ontouchenter");
SET_JSID_TO_STRING(sOntouchleave_id, cx, "ontouchleave");
SET_JSID_TO_STRING(sOntouchcancel_id, cx, "ontouchcancel");
SET_JSID_TO_STRING(sOnbeforeprint_id, cx, "onbeforeprint");
SET_JSID_TO_STRING(sOnafterprint_id, cx, "onafterprint");
return NS_OK;
}
@ -2302,8 +2304,6 @@ nsDOMClassInfo::RegisterExternalClasses()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentEvent) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentStyle) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSDocumentStyle) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentRange) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentTraversal) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentXBL) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget) \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) \
@ -5145,6 +5145,8 @@ nsDOMClassInfo::ShutDown()
sOntouchenter_id = JSID_VOID;
sOntouchleave_id = JSID_VOID;
sOntouchcancel_id = JSID_VOID;
sOnbeforeprint_id = JSID_VOID;
sOnafterprint_id = JSID_VOID;
NS_IF_RELEASE(sXPConnect);
NS_IF_RELEASE(sSecMan);
@ -7618,11 +7620,13 @@ nsEventReceiverSH::ReallyIsEventName(jsid id, jschar aFirstChar)
switch (aFirstChar) {
case 'a' :
return (id == sOnabort_id ||
id == sOnafterscriptexecute_id);
id == sOnafterscriptexecute_id ||
id == sOnafterprint_id);
case 'b' :
return (id == sOnbeforeunload_id ||
id == sOnbeforescriptexecute_id ||
id == sOnblur_id);
id == sOnblur_id ||
id == sOnbeforeprint_id);
case 'c' :
return (id == sOnchange_id ||
id == sOnclick_id ||
@ -10201,12 +10205,11 @@ nsStringArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSAutoRequest ar(cx);
JSString *str =
::JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>(val.get()),
val.Length());
NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY);
*vp = STRING_TO_JSVAL(str);
nsStringBuffer* sharedBuffer = nsnull;
*vp = XPCStringConvert::ReadableToJSVal(cx, val, &sharedBuffer);
if (sharedBuffer) {
val.ForgetSharedBuffer();
}
return NS_SUCCESS_I_DID_SOMETHING;
}

View File

@ -365,6 +365,8 @@ public:
static jsid sOntouchenter_id;
static jsid sOntouchleave_id;
static jsid sOntouchcancel_id;
static jsid sOnbeforeprint_id;
static jsid sOnafterprint_id;
protected:
static JSPropertyOp sXPCNativeWrapperGetPropertyOp;

View File

@ -53,7 +53,7 @@
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMHTMLMapElement.h"
#include "nsIDOMHTMLLegendElement.h"
#include "nsIDOMDocumentRange.h"
#include "nsIDOMDocument.h"
#include "nsIDOMRange.h"
#include "nsIHTMLDocument.h"
#include "nsIFormControlFrame.h"
@ -2009,9 +2009,9 @@ nsFocusManager::UpdateCaret(PRBool aMoveCaretToFocus,
void
nsFocusManager::MoveCaretToFocus(nsIPresShell* aPresShell, nsIContent* aContent)
{
// rangeDoc is a document interface we can create a range with
nsCOMPtr<nsIDOMDocumentRange> rangeDoc(do_QueryInterface(aPresShell->GetDocument()));
if (rangeDoc) {
// domDoc is a document interface we can create a range with
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(aPresShell->GetDocument());
if (domDoc) {
nsCOMPtr<nsFrameSelection> frameSelection = aPresShell->FrameSelection();
nsCOMPtr<nsISelection> domSelection = frameSelection->
GetSelection(nsISelectionController::SELECTION_NORMAL);
@ -2022,7 +2022,7 @@ nsFocusManager::MoveCaretToFocus(nsIPresShell* aPresShell, nsIContent* aContent)
domSelection->RemoveAllRanges();
if (currentFocusNode) {
nsCOMPtr<nsIDOMRange> newRange;
nsresult rv = rangeDoc->CreateRange(getter_AddRefs(newRange));
nsresult rv = domDoc->CreateRange(getter_AddRefs(newRange));
if (NS_SUCCEEDED(rv)) {
// Set the range to the start of the currently focused node
// Make sure it's collapsed

View File

@ -8447,8 +8447,6 @@ nsGlobalWindow::FireDelayedDOMEvents()
if (mPendingStorageEventsObsolete) {
// Fire pending storage events.
mPendingStorageEventsObsolete->EnumerateRead(FirePendingStorageEvents, this);
delete mPendingStorageEventsObsolete;
mPendingStorageEventsObsolete = nsnull;
}

View File

@ -3646,14 +3646,6 @@ SetMemoryMaxPrefChangedCallback(const char* aPrefName, void* aClosure)
return 0;
}
static int
SetMemoryGCFrequencyPrefChangedCallback(const char* aPrefName, void* aClosure)
{
PRInt32 triggerFactor = nsContentUtils::GetIntPref(aPrefName, 300);
JS_SetGCParameter(nsJSRuntime::sRuntime, JSGC_TRIGGER_FACTOR, triggerFactor);
return 0;
}
static int
SetMemoryGCModePrefChangedCallback(const char* aPrefName, void* aClosure)
{
@ -3796,12 +3788,6 @@ nsJSRuntime::Init()
SetMemoryMaxPrefChangedCallback("javascript.options.mem.max",
nsnull);
nsContentUtils::RegisterPrefCallback("javascript.options.mem.gc_frequency",
SetMemoryGCFrequencyPrefChangedCallback,
nsnull);
SetMemoryGCFrequencyPrefChangedCallback("javascript.options.mem.gc_frequency",
nsnull);
nsContentUtils::RegisterPrefCallback("javascript.options.mem.gc_per_compartment",
SetMemoryGCModePrefChangedCallback,
nsnull);

View File

@ -97,6 +97,10 @@ nsStructuredCloneContainer::InitFromVariant(nsIVariant *aData, JSContext *aCx)
if (!mData) {
mSize = 0;
mVersion = 0;
// FIXME This should really be js::Foreground::Free, but that's not public.
JS_free(aCx, jsBytes);
return NS_ERROR_FAILURE;
}
else {
@ -104,6 +108,9 @@ nsStructuredCloneContainer::InitFromVariant(nsIVariant *aData, JSContext *aCx)
}
memcpy(mData, jsBytes, mSize);
// FIXME Similarly, this should be js::Foreground::free.
JS_free(aCx, jsBytes);
return NS_OK;
}

View File

@ -22,6 +22,8 @@
* Contributor(s):
* Vidur Apparao <vidur@netscape.com> (original author)
* Johnny Stenback <jst@netscape.com>
* Jonas Sicking <sicking@bigfoot.com>
* Ms2ger <ms2ger@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -39,6 +41,10 @@
#include "nsIDOMNode.idl"
interface nsIDOMNodeIterator;
interface nsIDOMNodeFilter;
interface nsIDOMTreeWalker;
/**
* The nsIDOMDocument interface represents the entire HTML or XML document.
* Conceptually, it is the root of the document tree, and provides the
@ -52,7 +58,7 @@
* http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
*/
[scriptable, uuid(d12f0ecf-434a-4b5c-81ad-354e3b9037b9)]
[scriptable, uuid(e286fcde-873d-4902-874b-49255737ee7d)]
interface nsIDOMDocument : nsIDOMNode
{
readonly attribute nsIDOMDocumentType doctype;
@ -115,4 +121,22 @@ interface nsIDOMDocument : nsIDOMNode
* @see http://www.whatwg.org/html/#dom-document-defaultview
*/
readonly attribute nsIDOMWindow defaultView;
/**
* Create a range
*
* @see http://html5.org/specs/dom-range.html#dom-document-createrange
*/
nsIDOMRange createRange();
nsIDOMNodeIterator createNodeIterator(in nsIDOMNode root,
in unsigned long whatToShow,
in nsIDOMNodeFilter filter,
in boolean entityReferenceExpansion)
raises(DOMException);
nsIDOMTreeWalker createTreeWalker(in nsIDOMNode root,
in unsigned long whatToShow,
in nsIDOMNodeFilter filter,
in boolean entityReferenceExpansion)
raises(DOMException);
};

View File

@ -38,7 +38,7 @@
#include "nsIDOMDocument.idl"
[scriptable, uuid(68e4448c-eb64-48ea-801a-0c83008d2607)]
[scriptable, uuid(305a78cc-da33-402c-bcd5-44eb993ab391)]
interface nsIDOMXMLDocument : nsIDOMDocument
{
// DOM Level 3 Load & Save, DocumentLS

View File

@ -555,6 +555,9 @@ interface nsIDOMCSS2Properties : nsISupports
attribute DOMString MozOpacity;
// raises(DOMException) on setting
attribute DOMString MozOrient;
// raises(DOMException) on setting
attribute DOMString MozOutline;
// raises(DOMException) on setting

View File

@ -49,7 +49,7 @@ interface nsIDOMEventTarget;
* http://www.w3.org/TR/DOM-Level-2-Events/
*/
[scriptable, uuid(a66b7b80-ff46-bd97-0080-5f8ae38add32)]
[scriptable, uuid(548137e8-fd2c-48c4-8635-3033f7db79e0)]
interface nsIDOMEvent : nsISupports
{
// PhaseType
@ -169,4 +169,9 @@ interface nsIDOMEvent : nsISupports
void initEvent(in DOMString eventTypeArg,
in boolean canBubbleArg,
in boolean cancelableArg);
/**
* Used to indicate whether preventDefault() has been called for this event.
*/
readonly attribute boolean defaultPrevented;
};

View File

@ -50,7 +50,7 @@
* http://www.whatwg.org/specs/web-apps/current-work/
*/
[scriptable, uuid(42bb545e-be46-4f4f-8c0a-6c948ea0c1d4)]
[scriptable, uuid(4b21c9f8-68bc-4bce-b452-0f844c532dfc)]
interface nsIDOMHTMLDocument : nsIDOMDocument
{
attribute DOMString title;

View File

@ -48,7 +48,6 @@ GRE_MODULE = 1
SDK_XPIDLSRCS = \
nsIDOMRange.idl \
nsIDOMDocumentRange.idl \
$(NULL)
XPIDLSRCS = \

View File

@ -39,7 +39,7 @@
interface nsIDOMSVGSVGElement;
[scriptable, uuid(907f1ada-5ace-4789-8c25-0c79f251044d)]
[scriptable, uuid(32f1cd80-9328-4f55-938a-0734217a7944)]
interface nsIDOMSVGDocument : nsIDOMDocument
/* , nsIDOMDocumentEvent */
{

View File

@ -48,7 +48,6 @@ XPIDL_MODULE = dom_traversal
GRE_MODULE = 1
XPIDLSRCS = \
nsIDOMDocumentTraversal.idl \
nsIDOMNodeFilter.idl \
nsIDOMNodeIterator.idl \
nsIDOMTreeWalker.idl \

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=8 et tw=80 : */
/* vim: set sw=2 ts=2 et tw=80 : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -41,13 +41,13 @@
namespace mozilla {
namespace dom {
NS_IMPL_THREADSAFE_ADDREF(AudioChild);
NS_IMPL_THREADSAFE_RELEASE(AudioChild);
AudioChild::AudioChild()
: mLastSampleOffset(-1),
mLastSampleOffsetTime(0),
mMinWriteSample(-2),// Initial value, -2, error on -1
mAudioReentrantMonitor("AudioChild.mReentrantMonitor"),
mIPCOpen(PR_TRUE),
mDrained(PR_FALSE)
@ -84,6 +84,25 @@ AudioChild::RecvDrainDone()
return true;
}
PRInt32
AudioChild::WaitForMinWriteSample()
{
ReentrantMonitorAutoEnter mon(mAudioReentrantMonitor);
// -2 : initial value
while (mMinWriteSample == -2 && mIPCOpen)
mAudioReentrantMonitor.Wait();
return mMinWriteSample;
}
bool
AudioChild::RecvMinWriteSampleDone(const PRInt32& minSamples)
{
ReentrantMonitorAutoEnter mon(mAudioReentrantMonitor);
mMinWriteSample = minSamples;
mAudioReentrantMonitor.NotifyAll();
return true;
}
void
AudioChild::WaitForDrain()
{

View File

@ -56,9 +56,11 @@ class AudioChild : public PAudioChild
virtual ~AudioChild();
virtual bool RecvSampleOffsetUpdate(const PRInt64&, const PRInt64&);
virtual bool RecvDrainDone();
virtual PRInt32 WaitForMinWriteSample();
virtual bool RecvMinWriteSampleDone(const PRInt32& sampleCount);
virtual void WaitForDrain();
virtual void ActorDestroy(ActorDestroyReason);
PRInt64 GetLastKnownSampleOffset();
PRInt64 GetLastKnownSampleOffsetTime();
@ -67,6 +69,7 @@ class AudioChild : public PAudioChild
nsAutoRefCnt mRefCnt;
NS_DECL_OWNINGTHREAD
PRInt64 mLastSampleOffset, mLastSampleOffsetTime;
PRInt32 mMinWriteSample;
mozilla::ReentrantMonitor mAudioReentrantMonitor;
PRPackedBool mIPCOpen;
PRPackedBool mDrained;

View File

@ -108,6 +108,49 @@ class AudioStreamShutdownEvent : public nsRunnable
nsRefPtr<nsAudioStream> mOwner;
};
class AudioMinWriteSampleDone : public nsRunnable
{
public:
AudioMinWriteSampleDone(AudioParent* owner, PRInt32 minSamples)
{
mOwner = owner;
mMinSamples = minSamples;
}
NS_IMETHOD Run()
{
mOwner->SendMinWriteSampleDone(mMinSamples);
return NS_OK;
}
private:
nsRefPtr<AudioParent> mOwner;
PRInt32 mMinSamples;
};
class AudioMinWriteSampleEvent : public nsRunnable
{
public:
AudioMinWriteSampleEvent(AudioParent* parent, nsAudioStream* owner)
{
mParent = parent;
mOwner = owner;
}
NS_IMETHOD Run()
{
PRInt32 minSamples = mOwner->GetMinWriteSamples();
nsCOMPtr<nsIRunnable> event = new AudioMinWriteSampleDone(mParent, minSamples);
NS_DispatchToMainThread(event);
return NS_OK;
}
private:
nsRefPtr<nsAudioStream> mOwner;
nsRefPtr<AudioParent> mParent;
};
class AudioDrainDoneEvent : public nsRunnable
{
public:
@ -186,6 +229,17 @@ AudioParent::RecvSetVolume(const float& aVolume)
return true;
}
bool
AudioParent::RecvMinWriteSample()
{
if (!mStream)
return false;
nsCOMPtr<nsIRunnable> event = new AudioMinWriteSampleEvent(this, mStream);
nsCOMPtr<nsIThread> thread = mStream->GetThread();
thread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
return true;
}
bool
AudioParent::RecvDrain()
{
@ -227,6 +281,14 @@ AudioParent::RecvShutdown()
return true;
}
bool
AudioParent::SendMinWriteSampleDone(PRInt32 minSamples)
{
if (mIPCOpen)
return PAudioParent::SendMinWriteSampleDone(minSamples);
return true;
}
bool
AudioParent::SendDrainDone()
{

View File

@ -61,6 +61,9 @@ class AudioParent : public PAudioParent, public nsITimerCallback
virtual bool
RecvSetVolume(const float& aVolume);
virtual bool
RecvMinWriteSample();
virtual bool
RecvDrain();
@ -73,6 +76,9 @@ class AudioParent : public PAudioParent, public nsITimerCallback
virtual bool
RecvShutdown();
virtual bool
SendMinWriteSampleDone(PRInt32 minSamples);
virtual bool
SendDrainDone();

View File

@ -52,6 +52,7 @@ parent:
SetVolume(float aVolume);
MinWriteSample();
Drain();
Pause();
@ -63,6 +64,7 @@ parent:
__delete__();
SampleOffsetUpdate(PRInt64 offset, PRInt64 time);
MinWriteSampleDone(PRInt32 sampleCount);
DrainDone();
};

View File

@ -1982,8 +1982,12 @@ PluginInstanceChild::AnswerSetPluginFocus()
PR_LOG(gPluginLog, PR_LOG_DEBUG, ("%s", FULLFUNCTION));
#if defined(OS_WIN)
// Parent is letting us know something set focus to the plugin.
if (::GetFocus() == mPluginWindowHWND)
// Parent is letting us know the dom set focus to the plugin. Note,
// focus can change during transit in certain edge cases, for example
// when a button click brings up a full screen window. Since we send
// this in response to a WM_SETFOCUS event on our parent, the parent
// should have focus when we receive this. If not, ignore the call.
if (::GetFocus() == mPluginWindowHWND || ::GetFocus() != mPluginParentHWND)
return true;
::SetFocus(mPluginWindowHWND);
return true;

View File

@ -105,6 +105,13 @@ nsDOMWorkerPrivateEvent::PreventDefault()
return mEvent->PreventDefault();
}
NS_IMETHODIMP
nsDOMWorkerPrivateEvent::GetDefaultPrevented(PRBool* aRetVal)
{
*aRetVal = mPreventDefaultCalled;
return NS_OK;
}
NS_IMETHODIMP
nsDOMWorkerPrivateEvent::InitEvent(const nsAString& aEventType,
PRBool aCanBubble,
@ -242,6 +249,13 @@ nsDOMWorkerEvent::PreventDefault()
return NS_OK;
}
NS_IMETHODIMP
nsDOMWorkerEvent::GetDefaultPrevented(PRBool* aRetVal)
{
*aRetVal = mPreventDefaultCalled;
return NS_OK;
}
NS_IMETHODIMP
nsDOMWorkerEvent::InitEvent(const nsAString& aEventTypeArg,
PRBool aCanBubbleArg,

View File

@ -160,6 +160,8 @@ public:
const nsAString& aFilenameArg,
PRUint32 aLinenoArg);
NS_IMETHOD GetDefaultPrevented(PRBool* aRetVal);
virtual PRBool PreventDefaultCalled();
private:

View File

@ -552,14 +552,10 @@ nsEditorEventListener::DragEnter(nsIDOMDragEvent* aDragEvent)
nsCOMPtr<nsIPresShell> presShell = GetPresShell();
NS_ENSURE_TRUE(presShell, NS_OK);
if (!mCaret)
{
NS_NewCaret(getter_AddRefs(mCaret));
if (mCaret)
{
mCaret->Init(presShell);
mCaret->SetCaretReadOnly(PR_TRUE);
}
if (!mCaret) {
mCaret = new nsCaret();
mCaret->Init(presShell);
mCaret->SetCaretReadOnly(PR_TRUE);
}
presShell->SetCaret(mCaret);

View File

@ -21,6 +21,7 @@
*
* Contributor(s):
* Original Author: Daniel Glazman <glazman@netscape.com>
* Ms2ger <ms2ger@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -296,31 +297,23 @@ const nsHTMLCSSUtils::CSSEquivTable hrAlignEquivTable[] = {
{ nsHTMLCSSUtils::eCSSEditableProperty_NONE, 0 }
};
nsHTMLCSSUtils::nsHTMLCSSUtils()
: mIsCSSPrefChecked(PR_FALSE)
nsHTMLCSSUtils::nsHTMLCSSUtils(nsHTMLEditor* aEditor)
: mHTMLEditor(aEditor)
, mIsCSSPrefChecked(PR_FALSE)
{
// let's retrieve the value of the "CSS editing" pref
nsresult result = NS_OK;
nsCOMPtr<nsIPrefBranch> prefBranch =
do_GetService(NS_PREFSERVICE_CONTRACTID, &result);
if (NS_SUCCEEDED(result) && prefBranch) {
prefBranch->GetBoolPref("editor.use_css", &mIsCSSPrefChecked);
}
}
nsHTMLCSSUtils::~nsHTMLCSSUtils()
{
}
nsresult
nsHTMLCSSUtils::Init(nsHTMLEditor *aEditor)
{
nsresult result = NS_OK;
mHTMLEditor = static_cast<nsHTMLEditor*>(aEditor);
// let's retrieve the value of the "CSS editing" pref
nsCOMPtr<nsIPrefBranch> prefBranch =
do_GetService(NS_PREFSERVICE_CONTRACTID, &result);
if (NS_SUCCEEDED(result) && prefBranch) {
result = prefBranch->GetBoolPref("editor.use_css", &mIsCSSPrefChecked);
NS_ENSURE_SUCCESS(result, result);
}
return result;
}
// Answers true if we have some CSS equivalence for the HTML style defined
// by aProperty and/or aAttribute for the node aNode
PRBool
@ -617,19 +610,6 @@ nsHTMLCSSUtils::GetDefaultViewCSS(nsIDOMNode *aNode, nsIDOMWindow **aViewCSS)
return NS_OK;
}
nsresult
NS_NewHTMLCSSUtils(nsHTMLCSSUtils** aInstancePtrResult)
{
nsHTMLCSSUtils * rules = new nsHTMLCSSUtils();
if (rules) {
*aInstancePtrResult = rules;
return NS_OK;
}
*aInstancePtrResult = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
// remove the CSS style "aProperty : aPropertyValue" and possibly remove the whole node
// if it is a span and if its only attribute is _moz_dirty
nsresult

View File

@ -21,6 +21,7 @@
*
* Contributor(s):
* Original Author: Daniel Glazman <glazman@netscape.com>
* Ms2ger <ms2ger@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -62,7 +63,7 @@ typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & a
class nsHTMLCSSUtils
{
public:
nsHTMLCSSUtils();
explicit nsHTMLCSSUtils(nsHTMLEditor* aEditor);
~nsHTMLCSSUtils();
enum nsCSSEditableProperty {
@ -99,9 +100,6 @@ public:
PRBool caseSensitiveValue;
};
public:
nsresult Init(nsHTMLEditor * aEditor);
/** answers true if the given combination element_name/attribute_name
* has a CSS equivalence in this implementation
*
@ -401,11 +399,8 @@ private:
private:
nsHTMLEditor *mHTMLEditor;
PRBool mIsCSSPrefChecked;
};
nsresult NS_NewHTMLCSSUtils(nsHTMLCSSUtils** aInstancePtrResult);
#define NS_EDITOR_INDENT_INCREMENT_IN 0.4134f
#define NS_EDITOR_INDENT_INCREMENT_CM 1.05f
#define NS_EDITOR_INDENT_INCREMENT_MM 10.5f

View File

@ -103,7 +103,6 @@
// for relativization
#include "nsUnicharUtils.h"
#include "nsIDOMDocumentTraversal.h"
#include "nsIDOMTreeWalker.h"
#include "nsIDOMNodeFilter.h"
#include "nsIDOMNamedNodeMap.h"
@ -949,16 +948,14 @@ nsHTMLEditor::RelativizeURIInFragmentList(const nsCOMArray<nsIDOMNode> &aNodeLis
// determine destination URL
nsCOMPtr<nsIDOMDocument> domDoc;
GetDocument(getter_AddRefs(domDoc));
NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocument> destDoc = do_QueryInterface(domDoc);
NS_ENSURE_TRUE(destDoc, NS_ERROR_FAILURE);
nsCOMPtr<nsIURL> destURL = do_QueryInterface(destDoc->GetDocBaseURI());
NS_ENSURE_TRUE(destURL, NS_ERROR_FAILURE);
nsresult rv;
nsCOMPtr<nsIDOMDocumentTraversal> trav = do_QueryInterface(domDoc, &rv);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
PRInt32 listCount = aNodeList.Count();
PRInt32 j;
for (j = 0; j < listCount; j++)
@ -966,8 +963,10 @@ nsHTMLEditor::RelativizeURIInFragmentList(const nsCOMArray<nsIDOMNode> &aNodeLis
nsIDOMNode* somenode = aNodeList[j];
nsCOMPtr<nsIDOMTreeWalker> walker;
rv = trav->CreateTreeWalker(somenode, nsIDOMNodeFilter::SHOW_ELEMENT,
nsnull, PR_TRUE, getter_AddRefs(walker));
nsresult rv = domDoc->CreateTreeWalker(somenode,
nsIDOMNodeFilter::SHOW_ELEMENT,
nsnull, PR_TRUE,
getter_AddRefs(walker));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMNode> currentNode;

View File

@ -170,19 +170,6 @@ class nsEditableTextFunctor : public nsBoolDomIterFunctor
};
/********************************************************
* routine for making new rules instance
********************************************************/
nsresult
NS_NewHTMLEditRules(nsIEditRules** aInstancePtrResult)
{
nsHTMLEditRules * rules = new nsHTMLEditRules();
if (rules)
return rules->QueryInterface(NS_GET_IID(nsIEditRules), (void**) aInstancePtrResult);
return NS_ERROR_OUT_OF_MEMORY;
}
/********************************************************
* Constructor/Destructor
********************************************************/

View File

@ -318,7 +318,5 @@ protected:
StyleCache mCachedStyles[SIZE_STYLE_TABLE];
};
nsresult NS_NewHTMLEditRules(nsIEditRules** aInstancePtrResult);
#endif //nsHTMLEditRules_h__

View File

@ -22,6 +22,7 @@
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Daniel Glazman <glazman@netscape.com>
* Ms2ger <ms2ger@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -106,10 +107,6 @@ static char namedanchorText[] = "namedanchor";
nsIRangeUtils* nsHTMLEditor::sRangeHelper;
// some prototypes for rules creation shortcuts
nsresult NS_NewTextEditRules(nsIEditRules** aInstancePtrResult);
nsresult NS_NewHTMLEditRules(nsIEditRules** aInstancePtrResult);
#define IsLinkTag(s) (s.EqualsIgnoreCase(hrefText))
#define IsNamedAnchorTag(s) (s.EqualsIgnoreCase(anchorTxt) || s.EqualsIgnoreCase(namedanchorText))
@ -305,9 +302,7 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc,
}
// Init the HTML-CSS utils
result = NS_NewHTMLCSSUtils(getter_Transfers(mHTMLCSSUtils));
if (NS_FAILED(result)) { return result; }
mHTMLCSSUtils->Init(this);
mHTMLCSSUtils = new nsHTMLCSSUtils(this);
// disable links
nsCOMPtr<nsIPresShell> presShell;
@ -323,11 +318,9 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc,
// init the type-in state
mTypeInState = new TypeInState();
if (!mTypeInState) {return NS_ERROR_NULL_POINTER;}
// init the selection listener for image resizing
mSelectionListenerP = new ResizerSelectionListener(this);
if (!mSelectionListenerP) {return NS_ERROR_NULL_POINTER;}
if (!IsInteractionAllowed()) {
// ignore any errors from this in case the file is missing
@ -536,12 +529,8 @@ NS_IMETHODIMP
nsHTMLEditor::InitRules()
{
// instantiate the rules for the html editor
nsresult res = NS_NewHTMLEditRules(getter_AddRefs(mRules));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(mRules, NS_ERROR_UNEXPECTED);
res = mRules->Init(static_cast<nsPlaintextEditor*>(this));
return res;
mRules = new nsHTMLEditRules();
return mRules->Init(static_cast<nsPlaintextEditor*>(this));
}
NS_IMETHODIMP

View File

@ -87,9 +87,6 @@
#include "mozilla/FunctionTimer.h"
// prototype for rules creation shortcut
nsresult NS_NewTextEditRules(nsIEditRules** aInstancePtrResult);
nsPlaintextEditor::nsPlaintextEditor()
: nsEditor()
, mIgnoreSpuriousDragEvent(PR_FALSE)
@ -329,9 +326,7 @@ nsPlaintextEditor::SetDocumentCharacterSet(const nsACString & characterSet)
NS_IMETHODIMP nsPlaintextEditor::InitRules()
{
// instantiate the rules for this text editor
nsresult res = NS_NewTextEditRules(getter_AddRefs(mRules));
NS_ENSURE_SUCCESS(res, res);
NS_ENSURE_TRUE(mRules, NS_ERROR_UNEXPECTED);
mRules = new nsTextEditRules();
return mRules->Init(this);
}

View File

@ -80,16 +80,6 @@ static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
};
nsresult
NS_NewTextEditRules(nsIEditRules** aInstancePtrResult)
{
nsTextEditRules * rules = new nsTextEditRules();
if (rules)
return rules->QueryInterface(NS_GET_IID(nsIEditRules), (void**) aInstancePtrResult);
return NS_ERROR_OUT_OF_MEMORY;
}
/********************************************************
* Constructor/Destructor
********************************************************/

View File

@ -373,8 +373,4 @@ class nsAutoLockListener
PRPackedBool mOldState;
};
nsresult NS_NewTextEditRules(nsIEditRules** aInstancePtrResult);
#endif //nsTextEditRules_h__

View File

@ -44,8 +44,6 @@
#include "nsIEnumerator.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMDocumentRange.h"
#include "nsIDOMDocumentTraversal.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsIFrame.h"

View File

@ -72,7 +72,6 @@
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMXMLDocument.h"
#include "nsIDOMDocumentTraversal.h"
#include "nsIDOMTreeWalker.h"
#include "nsIDOMNode.h"
#include "nsIDOMComment.h"
@ -1644,10 +1643,8 @@ nsresult nsWebBrowserPersist::SaveDocumentInternal(
mDocList.AppendElement(docData);
// Walk the DOM gathering a list of externally referenced URIs in the uri map
nsCOMPtr<nsIDOMDocumentTraversal> trav = do_QueryInterface(docData->mDocument, &rv);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMTreeWalker> walker;
rv = trav->CreateTreeWalker(docAsNode,
rv = aDocument->CreateTreeWalker(docAsNode,
nsIDOMNodeFilter::SHOW_ELEMENT |
nsIDOMNodeFilter::SHOW_DOCUMENT |
nsIDOMNodeFilter::SHOW_PROCESSING_INSTRUCTION,

View File

@ -66,7 +66,7 @@ const tests = [
["checkcompounddup", "iso-8859-1"],
["checkcompoundtriple", "iso-8859-1"],
["simplifiedtriple", "iso-8859-1"],
["checkcompoundrep", "iso-8859-1", null, {2: "todo"}],
["checkcompoundrep", "iso-8859-1"],
["checkcompoundcase2", "iso-8859-1"],
["checkcompoundcaseutf", "UTF-8"],
["checkcompoundpattern", "iso-8859-1"],
@ -111,16 +111,16 @@ const tests = [
["korean", "UTF-8"],
["opentaal_forbiddenword1", "UTF-8"],
["opentaal_forbiddenword2", "UTF-8"],
["opentaal_keepcase", "UTF-8", null, {7: "todo"}],
["opentaal_keepcase", "UTF-8"],
["arabic", "UTF-8"],
["2970240", "iso-8859-1"],
["2970242", "iso-8859-1"],
["breakoff", "iso-8859-1"],
["opentaal_cpdpat", "iso-8859-1"],
["opentaal_cpdpat2", "iso-8859-1"],
["2999225", "iso-8859-1", {1: "todo"}],
["onlyincompound2", "iso-8859-1", null, {2: "todo"}],
["forceucase", "iso-8859-1", null, {1: "todo"}],
["2999225", "iso-8859-1"],
["onlyincompound2", "iso-8859-1"],
["forceucase", "iso-8859-1"],
["warn", "iso-8859-1"]
];

View File

@ -295,6 +295,11 @@ NS_IMETHODIMP mozOSXSpell::Suggest(const PRUnichar *aWord, PRUnichar ***aSuggest
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}
NS_IMETHODIMP mozOSXSpell::LoadDictionariesFromDir(nsIFile* aFile)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
#pragma mark -
//

View File

@ -71,7 +71,6 @@
#include "nsCRT.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentRange.h"
#include "nsIDOMElement.h"
#include "nsIDOMEventTarget.h"
#include "nsPIDOMEventTarget.h"
@ -145,12 +144,12 @@ mozInlineSpellStatus::InitForEditorChange(
{
nsresult rv;
nsCOMPtr<nsIDOMDocumentRange> docRange;
rv = GetDocumentRange(getter_AddRefs(docRange));
nsCOMPtr<nsIDOMDocument> doc;
rv = GetDocument(getter_AddRefs(doc));
NS_ENSURE_SUCCESS(rv, rv);
// save the anchor point as a range so we can find the current word later
rv = PositionToCollapsedRange(docRange, aAnchorNode, aAnchorOffset,
rv = PositionToCollapsedRange(doc, aAnchorNode, aAnchorOffset,
getter_AddRefs(mAnchorRange));
NS_ENSURE_SUCCESS(rv, rv);
@ -166,7 +165,7 @@ mozInlineSpellStatus::InitForEditorChange(
mOp = eOpChange;
// range to check
rv = docRange->CreateRange(getter_AddRefs(mRange));
rv = doc->CreateRange(getter_AddRefs(mRange));
NS_ENSURE_SUCCESS(rv, rv);
// ...we need to put the start and end in the correct order
@ -253,14 +252,14 @@ mozInlineSpellStatus::InitForNavigation(
return NS_OK;
}
nsCOMPtr<nsIDOMDocumentRange> docRange;
rv = GetDocumentRange(getter_AddRefs(docRange));
nsCOMPtr<nsIDOMDocument> doc;
rv = GetDocument(getter_AddRefs(doc));
NS_ENSURE_SUCCESS(rv, rv);
rv = PositionToCollapsedRange(docRange, aOldAnchorNode, aOldAnchorOffset,
rv = PositionToCollapsedRange(doc, aOldAnchorNode, aOldAnchorOffset,
getter_AddRefs(mOldNavigationAnchorRange));
NS_ENSURE_SUCCESS(rv, rv);
rv = PositionToCollapsedRange(docRange, aNewAnchorNode, aNewAnchorOffset,
rv = PositionToCollapsedRange(doc, aNewAnchorNode, aNewAnchorOffset,
getter_AddRefs(mAnchorRange));
NS_ENSURE_SUCCESS(rv, rv);
@ -441,16 +440,16 @@ mozInlineSpellStatus::FillNoCheckRangeFromAnchor(
getter_AddRefs(mNoCheckRange));
}
// mozInlineSpellStatus::GetDocumentRange
// mozInlineSpellStatus::GetDocument
//
// Returns the nsIDOMDocumentRange object for the document for the
// Returns the nsIDOMDocument object for the document for the
// current spellchecker.
nsresult
mozInlineSpellStatus::GetDocumentRange(nsIDOMDocumentRange** aDocRange)
mozInlineSpellStatus::GetDocument(nsIDOMDocument** aDocument)
{
nsresult rv;
*aDocRange = nsnull;
*aDocument = nsnull;
if (! mSpellChecker->mEditor)
return NS_ERROR_UNEXPECTED;
@ -460,11 +459,8 @@ mozInlineSpellStatus::GetDocumentRange(nsIDOMDocumentRange** aDocRange)
nsCOMPtr<nsIDOMDocument> domDoc;
rv = editor->GetDocument(getter_AddRefs(domDoc));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMDocumentRange> docRange = do_QueryInterface(domDoc, &rv);
NS_ENSURE_SUCCESS(rv, rv);
docRange.swap(*aDocRange);
NS_ENSURE_TRUE(domDoc, NS_ERROR_NULL_POINTER);
domDoc.forget(aDocument);
return NS_OK;
}
@ -475,12 +471,12 @@ mozInlineSpellStatus::GetDocumentRange(nsIDOMDocumentRange** aDocRange)
// updated as the DOM is changed.
nsresult
mozInlineSpellStatus::PositionToCollapsedRange(nsIDOMDocumentRange* aDocRange,
mozInlineSpellStatus::PositionToCollapsedRange(nsIDOMDocument* aDocument,
nsIDOMNode* aNode, PRInt32 aOffset, nsIDOMRange** aRange)
{
*aRange = nsnull;
nsCOMPtr<nsIDOMRange> range;
nsresult rv = aDocRange->CreateRange(getter_AddRefs(range));
nsresult rv = aDocument->CreateRange(getter_AddRefs(range));
NS_ENSURE_SUCCESS(rv, rv);
rv = range->SetStart(aNode, aOffset);
@ -1032,12 +1028,10 @@ mozInlineSpellChecker::MakeSpellCheckRange(
nsCOMPtr<nsIDOMDocument> doc;
rv = editor->GetDocument(getter_AddRefs(doc));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMDocumentRange> docrange = do_QueryInterface(doc);
NS_ENSURE_TRUE(docrange, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMRange> range;
rv = docrange->CreateRange(getter_AddRefs(range));
rv = doc->CreateRange(getter_AddRefs(range));
NS_ENSURE_SUCCESS(rv, rv);
// possibly use full range of the editor

View File

@ -55,7 +55,6 @@
#include "mozISpellI18NUtil.h"
#include "nsCycleCollectionParticipant.h"
class nsIDOMDocumentRange;
class nsIDOMMouseEventListener;
class mozInlineSpellWordUtil;
class mozInlineSpellChecker;
@ -134,8 +133,8 @@ protected:
nsresult FillNoCheckRangeFromAnchor(mozInlineSpellWordUtil& aWordUtil);
nsresult GetDocumentRange(nsIDOMDocumentRange** aDocRange);
nsresult PositionToCollapsedRange(nsIDOMDocumentRange* aDocRange,
nsresult GetDocument(nsIDOMDocument** aDocument);
nsresult PositionToCollapsedRange(nsIDOMDocument* aDocument,
nsIDOMNode* aNode, PRInt32 aOffset,
nsIDOMRange** aRange);
};

View File

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -95,12 +95,10 @@ mozInlineSpellWordUtil::Init(nsWeakPtr aWeakEditor)
nsCOMPtr<nsIDOMDocument> domDoc;
rv = editor->GetDocument(getter_AddRefs(domDoc));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(domDoc, NS_ERROR_NULL_POINTER);
mDocument = do_QueryInterface(domDoc, &rv);
NS_ENSURE_SUCCESS(rv, rv);
mDOMDocumentRange = do_QueryInterface(domDoc, &rv);
NS_ENSURE_SUCCESS(rv, rv);
mDOMDocument = domDoc;
mDocument = do_QueryInterface(domDoc);
// Window
nsCOMPtr<nsIDOMWindow> window;
@ -375,10 +373,10 @@ nsresult
mozInlineSpellWordUtil::MakeRange(NodeOffset aBegin, NodeOffset aEnd,
nsIDOMRange** aRange)
{
if (! mDOMDocumentRange)
if (!mDOMDocument)
return NS_ERROR_NOT_INITIALIZED;
nsresult rv = mDOMDocumentRange->CreateRange(aRange);
nsresult rv = mDOMDocument->CreateRange(aRange);
NS_ENSURE_SUCCESS(rv, rv);
rv = (*aRange)->SetStart(aBegin.mNode, aBegin.mOffset);

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