diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp
index fd82e4e1161d..2981a0495c09 100644
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -36,7 +36,7 @@
#ifdef XP_WIN
#include "nsHTMLWin32ObjectAccessible.h"
#endif
-#include "TextLeafAccessible.h"
+#include "TextLeafAccessibleWrap.h"
#ifdef DEBUG
#include "Logging.h"
@@ -416,7 +416,7 @@ nsAccessibilityService::CreateTextLeafAccessible(nsIContent* aContent,
nsIPresShell* aPresShell)
{
Accessible* accessible =
- new TextLeafAccessible(aContent, GetDocAccessible(aPresShell));
+ new TextLeafAccessibleWrap(aContent, GetDocAccessible(aPresShell));
NS_ADDREF(accessible);
return accessible;
}
diff --git a/accessible/tests/mochitest/common.js b/accessible/tests/mochitest/common.js
index 16718610f60a..fb6bfdee641e 100644
--- a/accessible/tests/mochitest/common.js
+++ b/accessible/tests/mochitest/common.js
@@ -554,6 +554,13 @@ function relationTypeToString(aRelationType)
return gAccRetrieval.getStringRelationType(aRelationType);
}
+function getLoadContext() {
+ const Ci = Components.interfaces;
+ return window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsILoadContext);
+}
+
/**
* Return text from clipboard.
*/
@@ -566,6 +573,7 @@ function getTextFromClipboard()
var trans = Components.classes["@mozilla.org/widget/transferable;1"].
createInstance(Components.interfaces.nsITransferable);
+ trans.init(getLoadContext());
if (!trans)
return;
diff --git a/accessible/tests/mochitest/events/test_fromUserInput.html b/accessible/tests/mochitest/events/test_fromUserInput.html
index 64a33fbadfe7..1cfeedf0b360 100644
--- a/accessible/tests/mochitest/events/test_fromUserInput.html
+++ b/accessible/tests/mochitest/events/test_fromUserInput.html
@@ -68,7 +68,7 @@
var selection = window.getSelection();
var range = document.createRange();
range.setStart(this.textNode, aStart);
- range.setEnd(this.textNode, aEnd-1);
+ range.setEnd(this.textNode, aEnd);
selection.addRange(range);
synthesizeKey("VK_DELETE", {});
diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js
index 8416f1ea38d4..155c8e3717cc 100644
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -591,16 +591,15 @@ window.addEventListener('ContentStart', function(evt) {
});
})();
-// This is the backend for Gaia's screenshot feature.
-// Gaia requests a screenshot by sending a mozContentEvent with
-// detail.type set to 'save-screenshot'. Then we take a screenshot
-// save it in device storage (external) and send a mozChromeEvent with
-// detail.type set to 'saved-screenshot' and detail.filename set to
-// the filename.
+// This is the backend for Gaia's screenshot feature. Gaia requests a
+// screenshot by sending a mozContentEvent with detail.type set to
+// 'take-screenshot'. Then we take a screenshot and send a
+// mozChromeEvent with detail.type set to 'take-screenshot-success'
+// and detail.file set to the an image/png blob
window.addEventListener('ContentStart', function ss_onContentStart() {
let content = shell.contentBrowser.contentWindow;
content.addEventListener('mozContentEvent', function ss_onMozContentEvent(e) {
- if (e.detail.type !== 'save-screenshot')
+ if (e.detail.type !== 'take-screenshot')
return;
try {
@@ -619,44 +618,14 @@ window.addEventListener('ContentStart', function ss_onContentStart() {
context.drawWindow(window, 0, 0, width, height,
'rgb(255,255,255)', flags);
- var filename = 'screenshots/' +
- new Date().toISOString().slice(0,-5).replace(/[:T]/g, '-') +
- '.png';
-
- var file = canvas.mozGetAsFile(filename, 'image/png');
- var storage = navigator.getDeviceStorage('pictures')[0];
- if (!storage) { // If we don't have an SD card to save to, send an error
- shell.sendEvent(content, 'mozChromeEvent', {
- type: 'save-screenshot-no-card'
- });
- return;
- }
-
- var saveRequest = storage.addNamed(file, filename);
- saveRequest.onsuccess = function ss_onsuccess() {
- try {
- shell.sendEvent(content, 'mozChromeEvent', {
- type: 'save-screenshot-success',
- filename: filename
- });
- } catch(e) {
- dump('exception in onsuccess ' + e + '\n');
- }
- };
- saveRequest.onerror = function ss_onerror() {
- try {
- shell.sendEvent(content, 'mozChromeEvent', {
- type: 'save-screenshot-error',
- error: saveRequest.error.name
- });
- } catch(e) {
- dump('exception in onerror ' + e + '\n');
- }
- };
- } catch(e) {
- dump('exception while saving screenshot: ' + e + '\n');
shell.sendEvent(content, 'mozChromeEvent', {
- type: 'save-screenshot-error',
+ type: 'take-screenshot-success',
+ file: canvas.mozGetAsFile('screenshot', 'image/png')
+ });
+ } catch (e) {
+ dump('exception while creating screenshot: ' + e + '\n');
+ shell.sendEvent(content, 'mozChromeEvent', {
+ type: 'take-screenshot-error',
error: String(e)
});
}
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index 120192362ce7..26b65e30dbaf 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -2227,6 +2227,12 @@ function getPostDataStream(aStringData, aKeyword, aEncKeyword, aType) {
return mimeStream.QueryInterface(Ci.nsIInputStream);
}
+function getLoadContext() {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsILoadContext);
+}
+
function readFromClipboard()
{
var url;
@@ -2239,6 +2245,7 @@ function readFromClipboard()
// Create transferable that will transfer the text.
var trans = Components.classes["@mozilla.org/widget/transferable;1"]
.createInstance(Components.interfaces.nsITransferable);
+ trans.init(getLoadContext());
trans.addDataFlavor("text/unicode");
diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js
index c50b66948725..3edfa6596870 100644
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -1117,7 +1117,7 @@ nsContextMenu.prototype = {
var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
getService(Ci.nsIClipboardHelper);
- clipboard.copyString(addresses);
+ clipboard.copyString(addresses, document);
},
///////////////
@@ -1453,7 +1453,7 @@ nsContextMenu.prototype = {
copyMediaLocation : function () {
var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
getService(Ci.nsIClipboardHelper);
- clipboard.copyString(this.mediaURL);
+ clipboard.copyString(this.mediaURL, document);
},
get imageURL() {
diff --git a/browser/base/content/pageinfo/pageInfo.js b/browser/base/content/pageinfo/pageInfo.js
index aaa8e9d82dfc..3dcc3cc6fecb 100644
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -1243,7 +1243,7 @@ function doCopy()
elem.removeAttribute("copybuffer");
}
}
- gClipboardHelper.copyString(text.join("\n"));
+ gClipboardHelper.copyString(text.join("\n"), document);
}
}
diff --git a/browser/base/content/sanitizeDialog.js b/browser/base/content/sanitizeDialog.js
index 6fea403a41a8..68e33cca2b66 100644
--- a/browser/base/content/sanitizeDialog.js
+++ b/browser/base/content/sanitizeDialog.js
@@ -654,6 +654,7 @@ var gContiguousSelectionTreeHelper = {
createInstance(Ci.nsISupportsArray);
var trans = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
+ trans.init(null);
trans.setTransferData('dummy-flavor', null, 0);
arr.AppendElement(trans);
var reg = Cc["@mozilla.org/gfx/region;1"].
diff --git a/browser/base/content/test/browser_bug321000.js b/browser/base/content/test/browser_bug321000.js
index 88ccfe13cb92..8f0280a99a3e 100644
--- a/browser/base/content/test/browser_bug321000.js
+++ b/browser/base/content/test/browser_bug321000.js
@@ -32,7 +32,7 @@ function test() {
// Put a multi-line string in the clipboard.
// Setting the clipboard value is an async OS operation, so we need to poll
// the clipboard for valid data before going on.
- waitForClipboard(kTestString, function() { cbHelper.copyString(kTestString); },
+ waitForClipboard(kTestString, function() { cbHelper.copyString(kTestString, document); },
next_test, finish);
}
diff --git a/browser/base/content/test/browser_middleMouse_inherit.js b/browser/base/content/test/browser_middleMouse_inherit.js
index 121cb6da2e10..891ea2ed0918 100644
--- a/browser/base/content/test/browser_middleMouse_inherit.js
+++ b/browser/base/content/test/browser_middleMouse_inherit.js
@@ -25,7 +25,7 @@ function test() {
function() {
Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper)
- .copyString(url);
+ .copyString(url, document);
},
function () {
// Middle click on the content area
diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml
index 783d4d84a0ce..6b8a902b4a81 100644
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -550,7 +550,7 @@
Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(Ci.nsIClipboardHelper)
- .copyString(val);
+ .copyString(val, document);
},
supportsCommand: function(aCommand) {
switch (aCommand) {
@@ -751,7 +751,7 @@
Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(Ci.nsIClipboardHelper)
- .copyStringToClipboard(val, Ci.nsIClipboard.kSelectionClipboard);
+ .copyStringToClipboard(val, document, Ci.nsIClipboard.kSelectionClipboard);
]]>
diff --git a/browser/components/downloads/content/downloads.js b/browser/components/downloads/content/downloads.js
index cca869e71e61..c79aebcb86d5 100644
--- a/browser/components/downloads/content/downloads.js
+++ b/browser/components/downloads/content/downloads.js
@@ -1167,7 +1167,7 @@ DownloadsViewItemController.prototype = {
{
let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(Ci.nsIClipboardHelper);
- clipboard.copyString(this.dataItem.uri);
+ clipboard.copyString(this.dataItem.uri, document);
},
downloadsCmd_doDefault: function DVIC_downloadsCmd_doDefault()
diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js
index 5ebe789ff5c8..6478cc38ed10 100644
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -492,13 +492,6 @@ BrowserGlue.prototype = {
if (!aQuitType)
aQuitType = "quit";
- // Never show a prompt inside private browsing mode
- var inPrivateBrowsing = Cc["@mozilla.org/privatebrowsing;1"].
- getService(Ci.nsIPrivateBrowsingService).
- privateBrowsingEnabled;
- if (inPrivateBrowsing)
- return;
-
var showPrompt = false;
var mostRecentBrowserWindow;
@@ -530,6 +523,12 @@ BrowserGlue.prototype = {
return;
}
+ var inPrivateBrowsing = Cc["@mozilla.org/privatebrowsing;1"].
+ getService(Ci.nsIPrivateBrowsingService).
+ privateBrowsingEnabled;
+ if (inPrivateBrowsing)
+ return;
+
if (!showPrompt)
return;
diff --git a/browser/components/places/content/controller.js b/browser/components/places/content/controller.js
index e57cb18858ab..25a5570e2d1d 100644
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -376,6 +376,7 @@ PlacesController.prototype = {
// pasting of valid "text/unicode" and "text/x-moz-url" data
var xferable = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
+ xferable.init(null);
xferable.addDataFlavor(PlacesUtils.TYPE_X_MOZ_URL);
xferable.addDataFlavor(PlacesUtils.TYPE_UNICODE);
@@ -1061,6 +1062,7 @@ PlacesController.prototype = {
try {
let xferable = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
+ xferable.init(null);
xferable.addDataFlavor(PlacesUtils.TYPE_X_MOZ_PLACE_ACTION)
this.clipboard.getData(xferable, Ci.nsIClipboard.kGlobalClipboard);
xferable.getTransferData(PlacesUtils.TYPE_X_MOZ_PLACE_ACTION, action, {});
@@ -1090,6 +1092,7 @@ PlacesController.prototype = {
_clearClipboard: function PC__clearClipboard() {
let xferable = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
+ xferable.init(null);
// Empty transferables may cause crashes, so just add an unknown type.
const TYPE = "text/x-moz-place-empty";
xferable.addDataFlavor(TYPE);
@@ -1135,6 +1138,7 @@ PlacesController.prototype = {
let xferable = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
+ xferable.init(null);
let hasData = false;
// This order matters here! It controls how this and other applications
// select data to be inserted based on type.
@@ -1224,6 +1228,7 @@ PlacesController.prototype = {
let xferable = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
+ xferable.init(null);
// This order matters here! It controls the preferred flavors for this
// paste operation.
[ PlacesUtils.TYPE_X_MOZ_PLACE,
diff --git a/browser/components/search/content/search.xml b/browser/components/search/content/search.xml
index fc4328a3dc1f..289b40c77ba0 100644
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -67,25 +67,25 @@
+ // Make sure we rebuild the popup in onpopupshowing
+ this._needToBuildPopup = true;
-
-
-
+ this._addedObserver = true;
+
+ this.searchService.init((function search_init_cb(aStatus) {
+ if (Components.isSuccessCode(aStatus)) {
+ // Refresh the display (updating icon, etc)
+ this.updateDisplay();
+ } else {
+ Components.utils.reportError("Cannot initialize search service, bailing out: " + aStatus);
+ }
+ }).bind(this));
+ ]]>
container = GetContainer();
+ if (container) {
+ nsCOMPtr loadContext = do_QueryInterface(container);
+ return loadContext;
+ }
+ return nsnull;
+ }
+
/**
* Set and get XML declaration. If aVersion is null there is no declaration.
* aStandalone takes values -1, 0 and 1 indicating respectively that there
diff --git a/content/base/src/nsCCUncollectableMarker.cpp b/content/base/src/nsCCUncollectableMarker.cpp
index e0987c47226d..e1e19347f1f9 100644
--- a/content/base/src/nsCCUncollectableMarker.cpp
+++ b/content/base/src/nsCCUncollectableMarker.cpp
@@ -265,6 +265,8 @@ nsCCUncollectableMarker::Observe(nsISupports* aSubject, const char* aTopic,
const PRUnichar* aData)
{
if (!strcmp(aTopic, "xpcom-shutdown")) {
+ nsGenericElement::ClearContentUnbinder();
+
nsCOMPtr obs =
mozilla::services::GetObserverService();
if (!obs)
@@ -289,7 +291,9 @@ nsCCUncollectableMarker::Observe(nsISupports* aSubject, const char* aTopic,
!strcmp(aTopic, "cycle-collector-forget-skippable");
bool prepareForCC = !strcmp(aTopic, "cycle-collector-begin");
-
+ if (prepareForCC) {
+ nsGenericElement::ClearContentUnbinder();
+ }
// Increase generation to effectivly unmark all current objects
if (!++sGeneration) {
diff --git a/content/base/src/nsCopySupport.cpp b/content/base/src/nsCopySupport.cpp
index 90957d8289fb..9f10fac66afa 100644
--- a/content/base/src/nsCopySupport.cpp
+++ b/content/base/src/nsCopySupport.cpp
@@ -182,6 +182,7 @@ SelectionCopyHelper(nsISelection *aSel, nsIDocument *aDoc,
// Create a transferable for putting data on the Clipboard
nsCOMPtr trans = do_CreateInstance(kCTransferableCID);
if (trans) {
+ trans->Init(aDoc->GetLoadContext());
if (bIsHTMLCopy) {
// Set up a format converter so that clipboard flavor queries work.
// This converter isn't really used for conversions.
@@ -459,6 +460,7 @@ nsCopySupport::GetContents(const nsACString& aMimeType, PRUint32 aFlags, nsISele
nsresult
nsCopySupport::ImageCopy(nsIImageLoadingContent* aImageElement,
+ nsILoadContext* aLoadContext,
PRInt32 aCopyFlags)
{
nsresult rv;
@@ -466,6 +468,7 @@ nsCopySupport::ImageCopy(nsIImageLoadingContent* aImageElement,
// create a transferable for putting data on the Clipboard
nsCOMPtr trans(do_CreateInstance(kCTransferableCID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
+ trans->Init(aLoadContext);
if (aCopyFlags & nsIContentViewerEdit::COPY_IMAGE_TEXT) {
// get the location from the element
diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp
index 7d7b1749649e..9e3979000322 100644
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -8991,6 +8991,7 @@ nsDocument::RequestFullScreen(Element* aElement, bool aWasCallerChrome)
// to the document's principal's host, if it has one.
if (!mIsApprovedForFullscreen) {
mIsApprovedForFullscreen =
+ GetWindow()->IsPartOfApp() ||
nsContentUtils::IsSitePermAllow(NodePrincipal(), "fullscreen");
}
diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h
index 30d1df1ec78e..30e300ed8d70 100644
--- a/content/base/src/nsGenericDOMDataNode.h
+++ b/content/base/src/nsGenericDOMDataNode.h
@@ -309,6 +309,11 @@ protected:
nsTextFragment mText;
public:
+ virtual bool OwnedOnlyByTheDOMTree()
+ {
+ return GetParent() && mRefCnt.get() == 1;
+ }
+
virtual bool IsPurple()
{
return mRefCnt.IsPurple();
diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp
index 81e7e93f0bd8..69e802d382ae 100644
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -1045,6 +1045,44 @@ nsGenericElement::GetScrollWidth(PRInt32 *aScrollWidth)
return NS_OK;
}
+PRInt32
+nsGenericElement::GetScrollLeftMax()
+{
+ nsIScrollableFrame* sf = GetScrollFrame();
+ if (!sf) {
+ return 0;
+ }
+
+ return nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollRange().XMost());
+}
+
+NS_IMETHODIMP
+nsGenericElement::GetScrollLeftMax(PRInt32 *aScrollLeftMax)
+{
+ *aScrollLeftMax = GetScrollLeftMax();
+
+ return NS_OK;
+}
+
+PRInt32
+nsGenericElement::GetScrollTopMax()
+{
+ nsIScrollableFrame* sf = GetScrollFrame();
+ if (!sf) {
+ return 0;
+ }
+
+ return nsPresContext::AppUnitsToIntCSSPixels(sf->GetScrollRange().YMost());
+}
+
+NS_IMETHODIMP
+nsGenericElement::GetScrollTopMax(PRInt32 *aScrollTopMax)
+{
+ *aScrollTopMax = GetScrollTopMax();
+
+ return NS_OK;
+}
+
nsRect
nsGenericElement::GetClientAreaRect()
{
@@ -2809,6 +2847,16 @@ public:
return NS_OK;
}
+ static void UnbindAll()
+ {
+ nsRefPtr ub = sContentUnbinder;
+ sContentUnbinder = nsnull;
+ while (ub) {
+ ub->Run();
+ ub = ub->mNext;
+ }
+ }
+
static void Append(nsIContent* aSubtreeRoot)
{
if (!sContentUnbinder) {
@@ -2835,6 +2883,12 @@ private:
ContentUnbinder* ContentUnbinder::sContentUnbinder = nsnull;
+void
+nsGenericElement::ClearContentUnbinder()
+{
+ ContentUnbinder::UnbindAll();
+}
+
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGenericElement)
nsINode::Unlink(tmp);
@@ -3078,19 +3132,29 @@ nsGenericElement::CanSkipInCC(nsINode* aNode)
}
nsAutoTArray* gPurpleRoots = nsnull;
+nsAutoTArray* gNodesToUnbind = nsnull;
-void ClearPurpleRoots()
+void ClearCycleCollectorCleanupData()
{
- if (!gPurpleRoots) {
- return;
+ if (gPurpleRoots) {
+ PRUint32 len = gPurpleRoots->Length();
+ for (PRUint32 i = 0; i < len; ++i) {
+ nsINode* n = gPurpleRoots->ElementAt(i);
+ n->SetIsPurpleRoot(false);
+ }
+ delete gPurpleRoots;
+ gPurpleRoots = nsnull;
}
- PRUint32 len = gPurpleRoots->Length();
- for (PRUint32 i = 0; i < len; ++i) {
- nsINode* n = gPurpleRoots->ElementAt(i);
- n->SetIsPurpleRoot(false);
+ if (gNodesToUnbind) {
+ PRUint32 len = gNodesToUnbind->Length();
+ for (PRUint32 i = 0; i < len; ++i) {
+ nsIContent* c = gNodesToUnbind->ElementAt(i);
+ c->SetIsPurpleRoot(false);
+ ContentUnbinder::Append(c);
+ }
+ delete gNodesToUnbind;
+ gNodesToUnbind = nsnull;
}
- delete gPurpleRoots;
- gPurpleRoots = nsnull;
}
static bool
@@ -3164,8 +3228,8 @@ nsGenericElement::CanSkip(nsINode* aNode, bool aRemovingAllowed)
return false;
}
- // Subtree has been traversed already, and aNode
- // wasn't removed from purple buffer. No need to do more here.
+ // Subtree has been traversed already, and aNode has
+ // been handled in a way that doesn't require revisiting it.
if (root->IsPurpleRoot()) {
return false;
}
@@ -3175,8 +3239,12 @@ nsGenericElement::CanSkip(nsINode* aNode, bool aRemovingAllowed)
nsAutoTArray nodesToClear;
bool foundBlack = root->IsBlack();
+ bool domOnlyCycle = false;
if (root != currentDoc) {
currentDoc = nsnull;
+ if (!foundBlack) {
+ domOnlyCycle = static_cast(root)->OwnedOnlyByTheDOMTree();
+ }
if (ShouldClearPurple(static_cast(root))) {
nodesToClear.AppendElement(static_cast(root));
}
@@ -3190,6 +3258,7 @@ nsGenericElement::CanSkip(nsINode* aNode, bool aRemovingAllowed)
node = node->GetNextNode(root)) {
foundBlack = foundBlack || node->IsBlack();
if (foundBlack) {
+ domOnlyCycle = false;
if (currentDoc) {
// If we can mark the whole document black, no need to optimize
// so much, since when the next purple node in the document will be
@@ -3202,19 +3271,36 @@ nsGenericElement::CanSkip(nsINode* aNode, bool aRemovingAllowed)
node->RemovePurple();
}
MarkNodeChildren(node);
- } else if (ShouldClearPurple(node)) {
- // Collect interesting nodes which we can clear if we find that
- // they are kept alive in a black tree.
- nodesToClear.AppendElement(node);
+ } else {
+ domOnlyCycle = domOnlyCycle && node->OwnedOnlyByTheDOMTree();
+ if (ShouldClearPurple(node)) {
+ // Collect interesting nodes which we can clear if we find that
+ // they are kept alive in a black tree or are in a DOM-only cycle.
+ nodesToClear.AppendElement(node);
+ }
}
}
if (!currentDoc || !foundBlack) {
- if (!gPurpleRoots) {
- gPurpleRoots = new nsAutoTArray();
- }
root->SetIsPurpleRoot(true);
- gPurpleRoots->AppendElement(root);
+ if (domOnlyCycle) {
+ if (!gNodesToUnbind) {
+ gNodesToUnbind = new nsAutoTArray();
+ }
+ gNodesToUnbind->AppendElement(static_cast(root));
+ for (PRUint32 i = 0; i < nodesToClear.Length(); ++i) {
+ nsIContent* n = nodesToClear[i];
+ if ((n != aNode || aRemovingAllowed) && n->IsPurple()) {
+ n->RemovePurple();
+ }
+ }
+ return true;
+ } else {
+ if (!gPurpleRoots) {
+ gPurpleRoots = new nsAutoTArray();
+ }
+ gPurpleRoots->AppendElement(root);
+ }
}
if (!foundBlack) {
@@ -3261,7 +3347,7 @@ nsGenericElement::CanSkipThis(nsINode* aNode)
void
nsGenericElement::InitCCCallbacks()
{
- nsCycleCollector_setForgetSkippableCallback(ClearPurpleRoots);
+ nsCycleCollector_setForgetSkippableCallback(ClearCycleCollectorCleanupData);
nsCycleCollector_setBeforeUnlinkCallback(ClearBlackMarkedNodes);
}
@@ -4676,6 +4762,11 @@ nsGenericElement::MozRequestPointerLock()
static const char*
GetFullScreenError(nsIDocument* aDoc)
{
+ nsCOMPtr win = aDoc->GetWindow();
+ if (win && win->IsPartOfApp()) {
+ return nsnull;
+ }
+
if (!nsContentUtils::IsRequestFullScreenAllowed()) {
return "FullScreenDeniedNotInputDriven";
}
diff --git a/content/base/src/nsGenericElement.h b/content/base/src/nsGenericElement.h
index 6962c0c1b609..c86637fc6f2d 100644
--- a/content/base/src/nsGenericElement.h
+++ b/content/base/src/nsGenericElement.h
@@ -547,6 +547,8 @@ public:
PRInt32 GetScrollLeft();
PRInt32 GetScrollHeight();
PRInt32 GetScrollWidth();
+ PRInt32 GetScrollLeftMax();
+ PRInt32 GetScrollTopMax();
PRInt32 GetClientTop()
{
return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().y);
@@ -591,6 +593,16 @@ public:
*/
void FireNodeRemovedForChildren();
+ virtual bool OwnedOnlyByTheDOMTree()
+ {
+ PRUint32 rc = mRefCnt.get();
+ if (GetParent()) {
+ --rc;
+ }
+ rc -= mAttrsAndChildren.ChildCount();
+ return rc == 0;
+ }
+
virtual bool IsPurple()
{
return mRefCnt.IsPurple();
@@ -601,6 +613,7 @@ public:
mRefCnt.RemovePurple();
}
+ static void ClearContentUnbinder();
static bool CanSkip(nsINode* aNode, bool aRemovingAllowed);
static bool CanSkipInCC(nsINode* aNode);
static bool CanSkipThis(nsINode* aNode);
diff --git a/content/base/src/nsRange.cpp b/content/base/src/nsRange.cpp
index 7d37e893b4fe..9c96de864793 100644
--- a/content/base/src/nsRange.cpp
+++ b/content/base/src/nsRange.cpp
@@ -2017,30 +2017,23 @@ nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
return NS_OK;
}
-nsresult
-nsRange::CloneRange(nsRange** aReturn) const
+already_AddRefed
+nsRange::CloneRange() const
{
- if (aReturn == 0)
- return NS_ERROR_NULL_POINTER;
-
nsRefPtr range = new nsRange();
range->SetMaySpanAnonymousSubtrees(mMaySpanAnonymousSubtrees);
range->DoSetRange(mStartParent, mStartOffset, mEndParent, mEndOffset, mRoot);
- range.forget(aReturn);
-
- return NS_OK;
+ return range.forget();
}
NS_IMETHODIMP
nsRange::CloneRange(nsIDOMRange** aReturn)
{
- nsRefPtr range;
- nsresult rv = CloneRange(getter_AddRefs(range));
- range.forget(aReturn);
- return rv;
+ *aReturn = CloneRange().get();
+ return NS_OK;
}
NS_IMETHODIMP
diff --git a/content/base/src/nsRange.h b/content/base/src/nsRange.h
index a82b2bfabe54..b4bacc785974 100644
--- a/content/base/src/nsRange.h
+++ b/content/base/src/nsRange.h
@@ -118,7 +118,7 @@ public:
void Reset();
nsresult SetStart(nsINode* aParent, PRInt32 aOffset);
nsresult SetEnd(nsINode* aParent, PRInt32 aOffset);
- nsresult CloneRange(nsRange** aNewRange) const;
+ already_AddRefed CloneRange() const;
nsresult Set(nsINode* aStartParent, PRInt32 aStartOffset,
nsINode* aEndParent, PRInt32 aEndOffset)
diff --git a/content/base/test/test_bug166235.html b/content/base/test/test_bug166235.html
index 71fc1839c4df..e6c6e19df767 100644
--- a/content/base/test/test_bug166235.html
+++ b/content/base/test/test_bug166235.html
@@ -22,6 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=166235
/** Test for Bug 166235 **/
var Cc = SpecialPowers.wrap(Components).classes;
+ var Ci = SpecialPowers.wrap(Components).interfaces;
var webnav = SpecialPowers.wrap(window).QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
@@ -36,6 +37,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=166235
var textarea = SpecialPowers.wrap(document).getElementById('input');
+ function getLoadContext() {
+ return SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsILoadContext);
+ }
+
function copyChildrenToClipboard(id) {
textarea.blur();
clipboard.emptyClipboard(1);
@@ -48,6 +55,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=166235
function getClipboardData(mime) {
var transferable = Cc['@mozilla.org/widget/transferable;1']
.createInstance(Components.interfaces.nsITransferable);
+ transferable.init(getLoadContext());
transferable.addDataFlavor(mime);
clipboard.getData(transferable, 1);
var data = SpecialPowers.wrap({});
diff --git a/content/base/test/test_copypaste.html b/content/base/test/test_copypaste.html
index c1e8712c7357..dbdf2cc1b176 100644
--- a/content/base/test/test_copypaste.html
+++ b/content/base/test/test_copypaste.html
@@ -35,6 +35,13 @@ function modifySelection(s) {
}, 0)
}
+function getLoadContext() {
+ var Ci = SpecialPowers.wrap(Components).interfaces;
+ return SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsILoadContext);
+}
+
function testCopyPaste () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
@@ -86,6 +93,7 @@ function testCopyPaste () {
function getClipboardData(mime) {
var transferable = Components.classes['@mozilla.org/widget/transferable;1']
.createInstance(Components.interfaces.nsITransferable);
+ transferable.init(getLoadContext());
transferable.addDataFlavor(mime);
clipboard.getData(transferable, 1);
var data = {};
diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp
index 6b0dd890f834..32b046e2902f 100644
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -2447,7 +2447,7 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
case LOCAL_GL_COMPRESSED_TEXTURE_FORMATS:
{
uint32_t length = mCompressedTextureFormats.Length();
- JSObject* obj = Uint32Array::Create(cx, length, mCompressedTextureFormats.Elements());
+ JSObject* obj = Uint32Array::Create(cx, this, length, mCompressedTextureFormats.Elements());
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
@@ -2524,7 +2524,7 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
{
GLfloat fv[2] = { 0 };
gl->fGetFloatv(pname, fv);
- JSObject* obj = Float32Array::Create(cx, 2, fv);
+ JSObject* obj = Float32Array::Create(cx, this, 2, fv);
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
@@ -2536,7 +2536,7 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
{
GLfloat fv[4] = { 0 };
gl->fGetFloatv(pname, fv);
- JSObject* obj = Float32Array::Create(cx, 4, fv);
+ JSObject* obj = Float32Array::Create(cx, this, 4, fv);
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
@@ -2547,7 +2547,7 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
{
GLint iv[2] = { 0 };
gl->fGetIntegerv(pname, iv);
- JSObject* obj = Int32Array::Create(cx, 2, iv);
+ JSObject* obj = Int32Array::Create(cx, this, 2, iv);
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
@@ -2559,7 +2559,7 @@ WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
{
GLint iv[4] = { 0 };
gl->fGetIntegerv(pname, iv);
- JSObject* obj = Int32Array::Create(cx, 4, iv);
+ JSObject* obj = Int32Array::Create(cx, this, 4, iv);
if (!obj) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
@@ -3323,7 +3323,7 @@ WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
if (unitSize == 1) {
return JS::DoubleValue(fv[0]);
} else {
- JSObject* obj = Float32Array::Create(cx, unitSize, fv);
+ JSObject* obj = Float32Array::Create(cx, this, unitSize, fv);
if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
}
@@ -3335,7 +3335,7 @@ WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
if (unitSize == 1) {
return JS::Int32Value(iv[0]);
} else {
- JSObject* obj = Int32Array::Create(cx, unitSize, iv);
+ JSObject* obj = Int32Array::Create(cx, this, unitSize, iv);
if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
}
@@ -3462,7 +3462,7 @@ WebGLContext::GetVertexAttrib(JSContext* cx, WebGLuint index, WebGLenum pname,
vec[2] = mVertexAttrib0Vector[2];
vec[3] = mVertexAttrib0Vector[3];
}
- JSObject* obj = Float32Array::Create(cx, 4, vec);
+ JSObject* obj = Float32Array::Create(cx, this, 4, vec);
if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
}
diff --git a/content/events/src/nsDOMDataTransfer.cpp b/content/events/src/nsDOMDataTransfer.cpp
index f11597332334..04eaae7c4484 100644
--- a/content/events/src/nsDOMDataTransfer.cpp
+++ b/content/events/src/nsDOMDataTransfer.cpp
@@ -627,8 +627,11 @@ nsDOMDataTransfer::Clone(PRUint32 aEventType, bool aUserCancelled,
}
void
-nsDOMDataTransfer::GetTransferables(nsISupportsArray** aArray)
+nsDOMDataTransfer::GetTransferables(nsISupportsArray** aArray,
+ nsIDOMNode* aDragTarget)
{
+ MOZ_ASSERT(aDragTarget);
+
*aArray = nsnull;
nsCOMPtr transArray =
@@ -636,6 +639,14 @@ nsDOMDataTransfer::GetTransferables(nsISupportsArray** aArray)
if (!transArray)
return;
+ nsCOMPtr dragNode = do_QueryInterface(aDragTarget);
+ if (!dragNode)
+ return;
+ nsIDocument* doc = dragNode->GetCurrentDoc();
+ if (!doc)
+ return;
+ nsILoadContext* loadContext = doc->GetLoadContext();
+
bool added = false;
PRUint32 count = mItems.Length();
for (PRUint32 i = 0; i < count; i++) {
@@ -649,6 +660,7 @@ nsDOMDataTransfer::GetTransferables(nsISupportsArray** aArray)
do_CreateInstance("@mozilla.org/widget/transferable;1");
if (!transferable)
return;
+ transferable->Init(loadContext);
for (PRUint32 f = 0; f < count; f++) {
TransferItem& formatitem = item[f];
diff --git a/content/events/src/nsDOMDataTransfer.h b/content/events/src/nsDOMDataTransfer.h
index 4249368ca77b..d946351d8be1 100644
--- a/content/events/src/nsDOMDataTransfer.h
+++ b/content/events/src/nsDOMDataTransfer.h
@@ -97,7 +97,8 @@ public:
// converts the data into an array of nsITransferable objects to be used for
// drag and drop or clipboard operations.
- void GetTransferables(nsISupportsArray** transferables);
+ void GetTransferables(nsISupportsArray** transferables,
+ nsIDOMNode* aDragTarget);
// converts the data in the variant to an nsISupportString if possible or
// an nsISupports or null otherwise.
diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp
index 85902028454b..387eeb343d26 100644
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -2317,7 +2317,7 @@ nsEventStateManager::DoDefaultDragStart(nsPresContext* aPresContext,
nsIDOMElement* dragImage = aDataTransfer->GetDragImage(&imageX, &imageY);
nsCOMPtr transArray;
- aDataTransfer->GetTransferables(getter_AddRefs(transArray));
+ aDataTransfer->GetTransferables(getter_AddRefs(transArray), dragTarget);
if (!transArray)
return false;
diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp
index 00dbc5641a77..fa7e7266b4aa 100644
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -4286,3 +4286,41 @@ nsGenericHTMLElement::GetProperties(nsIDOMHTMLPropertiesCollection** aReturn)
return NS_OK;
}
+nsSize
+nsGenericHTMLElement::GetWidthHeightForImage(imgIRequest *aImageRequest)
+{
+ nsSize size(0,0);
+
+ nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
+
+ if (frame) {
+ size = frame->GetContentRect().Size();
+
+ size.width = nsPresContext::AppUnitsToIntCSSPixels(size.width);
+ size.height = nsPresContext::AppUnitsToIntCSSPixels(size.height);
+ } else {
+ const nsAttrValue* value;
+ nsCOMPtr image;
+ if (aImageRequest) {
+ aImageRequest->GetImage(getter_AddRefs(image));
+ }
+
+ if ((value = GetParsedAttr(nsGkAtoms::width)) &&
+ value->Type() == nsAttrValue::eInteger) {
+ size.width = value->GetIntegerValue();
+ } else if (image) {
+ image->GetWidth(&size.width);
+ }
+
+ if ((value = GetParsedAttr(nsGkAtoms::height)) &&
+ value->Type() == nsAttrValue::eInteger) {
+ size.height = value->GetIntegerValue();
+ } else if (image) {
+ image->GetHeight(&size.height);
+ }
+ }
+
+ NS_ASSERTION(size.width >= 0, "negative width");
+ NS_ASSERTION(size.height >= 0, "negative height");
+ return size;
+}
diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h
index 015d37ef794a..844cd5c45965 100644
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -147,6 +147,11 @@ public:
nsresult ClearDataset();
nsresult GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu);
+ /**
+ * Get width and height, using given image request if attributes are unset.
+ */
+ nsSize GetWidthHeightForImage(imgIRequest *aImageRequest);
+
protected:
nsresult GetMarkup(bool aIncludeSelf, nsAString& aMarkup);
diff --git a/content/html/content/src/nsHTMLImageElement.cpp b/content/html/content/src/nsHTMLImageElement.cpp
index 812334e48de6..cc611afd3c45 100644
--- a/content/html/content/src/nsHTMLImageElement.cpp
+++ b/content/html/content/src/nsHTMLImageElement.cpp
@@ -196,49 +196,10 @@ nsHTMLImageElement::GetY(PRInt32* aY)
return NS_OK;
}
-nsSize
-nsHTMLImageElement::GetWidthHeight()
-{
- nsSize size(0,0);
-
- nsIFrame* frame = GetPrimaryFrame(Flush_Layout);
-
- if (frame) {
- size = frame->GetContentRect().Size();
-
- size.width = nsPresContext::AppUnitsToIntCSSPixels(size.width);
- size.height = nsPresContext::AppUnitsToIntCSSPixels(size.height);
- } else {
- const nsAttrValue* value;
- nsCOMPtr image;
- if (mCurrentRequest) {
- mCurrentRequest->GetImage(getter_AddRefs(image));
- }
-
- if ((value = GetParsedAttr(nsGkAtoms::width)) &&
- value->Type() == nsAttrValue::eInteger) {
- size.width = value->GetIntegerValue();
- } else if (image) {
- image->GetWidth(&size.width);
- }
-
- if ((value = GetParsedAttr(nsGkAtoms::height)) &&
- value->Type() == nsAttrValue::eInteger) {
- size.height = value->GetIntegerValue();
- } else if (image) {
- image->GetHeight(&size.height);
- }
- }
-
- NS_ASSERTION(size.width >= 0, "negative width");
- NS_ASSERTION(size.height >= 0, "negative height");
- return size;
-}
-
NS_IMETHODIMP
nsHTMLImageElement::GetHeight(PRUint32* aHeight)
{
- *aHeight = GetWidthHeight().height;
+ *aHeight = GetWidthHeightForImage(mCurrentRequest).height;
return NS_OK;
}
@@ -246,17 +207,13 @@ nsHTMLImageElement::GetHeight(PRUint32* aHeight)
NS_IMETHODIMP
nsHTMLImageElement::SetHeight(PRUint32 aHeight)
{
- nsAutoString val;
- val.AppendInt(aHeight);
-
- return nsGenericHTMLElement::SetAttr(kNameSpaceID_None, nsGkAtoms::height,
- val, true);
+ return nsGenericHTMLElement::SetUnsignedIntAttr(nsGkAtoms::height, aHeight);
}
NS_IMETHODIMP
nsHTMLImageElement::GetWidth(PRUint32* aWidth)
{
- *aWidth = GetWidthHeight().width;
+ *aWidth = GetWidthHeightForImage(mCurrentRequest).width;
return NS_OK;
}
@@ -264,11 +221,7 @@ nsHTMLImageElement::GetWidth(PRUint32* aWidth)
NS_IMETHODIMP
nsHTMLImageElement::SetWidth(PRUint32 aWidth)
{
- nsAutoString val;
- val.AppendInt(aWidth);
-
- return nsGenericHTMLElement::SetAttr(kNameSpaceID_None, nsGkAtoms::width,
- val, true);
+ return nsGenericHTMLElement::SetUnsignedIntAttr(nsGkAtoms::width, aWidth);
}
bool
diff --git a/content/html/content/src/nsHTMLImageElement.h b/content/html/content/src/nsHTMLImageElement.h
index 99c0a00a31a9..6aff140b5ed1 100644
--- a/content/html/content/src/nsHTMLImageElement.h
+++ b/content/html/content/src/nsHTMLImageElement.h
@@ -102,7 +102,6 @@ public:
virtual nsIDOMNode* AsDOMNode() { return this; }
protected:
nsIntPoint GetXY();
- nsSize GetWidthHeight();
virtual void GetItemValueText(nsAString& text);
virtual void SetItemValueText(const nsAString& text);
};
diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp
index 9c5021ca75ea..8aa443f316ff 100644
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -858,6 +858,19 @@ NS_IMPL_STRING_ATTR(nsHTMLInputElement, Placeholder, placeholder)
NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(nsHTMLInputElement, Type, type,
kInputDefaultType->tag)
+NS_IMETHODIMP
+nsHTMLInputElement::GetHeight(PRUint32 *aHeight)
+{
+ *aHeight = GetWidthHeightForImage(mCurrentRequest).height;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsHTMLInputElement::SetHeight(PRUint32 aHeight)
+{
+ return nsGenericHTMLElement::SetUnsignedIntAttr(nsGkAtoms::height, aHeight);
+}
+
NS_IMETHODIMP
nsHTMLInputElement::GetIndeterminate(bool* aValue)
{
@@ -889,6 +902,19 @@ nsHTMLInputElement::SetIndeterminate(bool aValue)
return SetIndeterminateInternal(aValue, true);
}
+NS_IMETHODIMP
+nsHTMLInputElement::GetWidth(PRUint32 *aWidth)
+{
+ *aWidth = GetWidthHeightForImage(mCurrentRequest).width;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsHTMLInputElement::SetWidth(PRUint32 aWidth)
+{
+ return nsGenericHTMLElement::SetUnsignedIntAttr(nsGkAtoms::width, aWidth);
+}
+
NS_IMETHODIMP
nsHTMLInputElement::GetValue(nsAString& aValue)
{
diff --git a/content/html/content/test/forms/test_input_attributes_reflection.html b/content/html/content/test/forms/test_input_attributes_reflection.html
index dfa7e271c507..b15f305ef708 100644
--- a/content/html/content/test/forms/test_input_attributes_reflection.html
+++ b/content/html/content/test/forms/test_input_attributes_reflection.html
@@ -99,7 +99,12 @@ reflectString({
otherValues: [ "_blank", "_self", "_parent", "_top" ],
});
-// TODO: height (non-negative integer)
+// .height
+reflectUnsignedInt({
+ element: document.createElement("input"),
+ attribute: "height",
+ nonZero: false
+});
// .indeterminate doesn't reflect a content attribute.
@@ -204,7 +209,12 @@ todo("valueAsNumber" in document.createElement("input"),
todo("selectedOption" in document.createElement("input"),
"selectedOption isn't implemented yet");
-// TODO: width (non-negative integer)
+// .width
+reflectUnsignedInt({
+ element: document.createElement("input"),
+ attribute: "width",
+ nonZero: false
+});
// .willValidate doesn't reflect a content attribute.
// .validity doesn't reflect a content attribute.
diff --git a/content/media/test/seek_with_sound.ogg b/content/media/test/seek_with_sound.ogg
new file mode 100644
index 000000000000..c86d9946bddc
Binary files /dev/null and b/content/media/test/seek_with_sound.ogg differ
diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp
index 75c3ee515df8..2a931cebfb9a 100644
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -470,12 +470,7 @@
#include "nsHTMLSelectElement.h"
#include "nsHTMLLegendElement.h"
-#include "DOMSVGLengthList.h"
-#include "DOMSVGNumberList.h"
-#include "DOMSVGPathSegList.h"
-#include "DOMSVGPointList.h"
#include "DOMSVGStringList.h"
-#include "DOMSVGTransformList.h"
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
#include "mozilla/dom/indexedDB/IDBFactory.h"
@@ -780,10 +775,10 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(DOMException, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
- NS_DEFINE_CLASSINFO_DATA(DOMTokenList, nsDOMTokenListSH,
- ARRAY_SCRIPTABLE_FLAGS)
- NS_DEFINE_CLASSINFO_DATA(DOMSettableTokenList, nsDOMTokenListSH,
- ARRAY_SCRIPTABLE_FLAGS)
+ NS_DEFINE_CLASSINFO_DATA(DOMTokenList, nsDOMGenericSH,
+ DOM_DEFAULT_SCRIPTABLE_FLAGS)
+ NS_DEFINE_CLASSINFO_DATA(DOMSettableTokenList, nsDOMGenericSH,
+ DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(DocumentFragment, nsNodeSH, NODE_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(Element, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
@@ -1262,14 +1257,14 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGLength, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
- NS_DEFINE_CLASSINFO_DATA(SVGLengthList, nsSVGLengthListSH,
- ARRAY_SCRIPTABLE_FLAGS)
+ NS_DEFINE_CLASSINFO_DATA(SVGLengthList, nsDOMGenericSH,
+ DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGMatrix, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGNumber, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
- NS_DEFINE_CLASSINFO_DATA(SVGNumberList, nsSVGNumberListSH,
- ARRAY_SCRIPTABLE_FLAGS)
+ NS_DEFINE_CLASSINFO_DATA(SVGNumberList, nsDOMGenericSH,
+ DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPathSegArcAbs, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPathSegArcRel, nsDOMGenericSH,
@@ -1304,16 +1299,16 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPathSegLinetoVerticalRel, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
- NS_DEFINE_CLASSINFO_DATA(SVGPathSegList, nsSVGPathSegListSH,
- ARRAY_SCRIPTABLE_FLAGS)
+ NS_DEFINE_CLASSINFO_DATA(SVGPathSegList, nsDOMGenericSH,
+ DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPathSegMovetoAbs, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPathSegMovetoRel, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPoint, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
- NS_DEFINE_CLASSINFO_DATA(SVGPointList, nsSVGPointListSH,
- ARRAY_SCRIPTABLE_FLAGS)
+ NS_DEFINE_CLASSINFO_DATA(SVGPointList, nsDOMGenericSH,
+ DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGPreserveAspectRatio, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGRect, nsDOMGenericSH,
@@ -1322,8 +1317,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
ARRAY_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGTransform, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
- NS_DEFINE_CLASSINFO_DATA(SVGTransformList, nsSVGTransformListSH,
- ARRAY_SCRIPTABLE_FLAGS)
+ NS_DEFINE_CLASSINFO_DATA(SVGTransformList, nsDOMGenericSH,
+ DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGZoomEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -1397,8 +1392,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(ClientRect, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
- NS_DEFINE_CLASSINFO_DATA(ClientRectList, nsClientRectListSH,
- ARRAY_SCRIPTABLE_FLAGS)
+ NS_DEFINE_CLASSINFO_DATA(ClientRectList, nsDOMGenericSH,
+ DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(SVGForeignObjectElement, nsElementSH,
ELEMENT_SCRIPTABLE_FLAGS)
@@ -1411,8 +1406,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(OfflineResourceList, nsOfflineResourceListSH,
ARRAY_SCRIPTABLE_FLAGS)
- NS_DEFINE_CLASSINFO_DATA(FileList, nsFileListSH,
- ARRAY_SCRIPTABLE_FLAGS)
+ NS_DEFINE_CLASSINFO_DATA(FileList, nsDOMGenericSH,
+ DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(Blob, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(File, nsDOMGenericSH,
@@ -1578,8 +1573,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(PaintRequest, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
- NS_DEFINE_CLASSINFO_DATA(PaintRequestList, nsPaintRequestListSH,
- ARRAY_SCRIPTABLE_FLAGS)
+ NS_DEFINE_CLASSINFO_DATA(PaintRequestList, nsDOMGenericSH,
+ DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(ScrollAreaEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -1637,8 +1632,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(Touch, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
- NS_DEFINE_CLASSINFO_DATA(TouchList, nsDOMTouchListSH,
- ARRAY_SCRIPTABLE_FLAGS)
+ NS_DEFINE_CLASSINFO_DATA(TouchList, nsDOMGenericSH,
+ DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(TouchEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -8351,27 +8346,6 @@ nsStringListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
}
-// DOMTokenList scriptable helper
-
-nsresult
-nsDOMTokenListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
- nsAString& aResult)
-{
- nsCOMPtr list(do_QueryInterface(aNative));
- NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
-
- nsresult rv = list->Item(aIndex, aResult);
-#ifdef DEBUG
- if (DOMStringIsNull(aResult)) {
- PRUint32 length = 0;
- list->GetLength(&length);
- NS_ASSERTION(PRUint32(aIndex) >= length, "Item should only return null for out-of-bounds access");
- }
-#endif
- return rv;
-}
-
-
// Named Array helper
NS_IMETHODIMP
@@ -10287,36 +10261,6 @@ nsCSSRuleListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
return list->GetItemAt(aIndex, aResult);
}
-// ClientRectList scriptable helper
-
-nsISupports*
-nsClientRectListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
- nsWrapperCache **aCache, nsresult *aResult)
-{
- nsClientRectList* list = nsClientRectList::FromSupports(aNative);
-
- return list->GetItemAt(aIndex);
-}
-
-// PaintRequestList scriptable helper
-
-nsISupports*
-nsPaintRequestListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
- nsWrapperCache **aCache, nsresult *aResult)
-{
- nsPaintRequestList* list = nsPaintRequestList::FromSupports(aNative);
-
- return list->GetItemAt(aIndex);
-}
-
-nsISupports*
-nsDOMTouchListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
- nsWrapperCache **aCache, nsresult *aResult)
-{
- nsDOMTouchList* list = static_cast(aNative);
- return list->GetItemAt(aIndex);
-}
-
#ifdef MOZ_XUL
// TreeColumns helper
@@ -10755,39 +10699,6 @@ nsOfflineResourceListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
return rv;
}
-// nsFileListSH
-nsISupports*
-nsFileListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex,
- nsWrapperCache **aCache, nsresult *aResult)
-{
- nsDOMFileList* list = nsDOMFileList::FromSupports(aNative);
-
- return list->GetItemAt(aIndex);
-}
-
-// Template for SVGXXXList helpers
-template nsISupports*
-nsSVGListSH::GetItemAt(nsISupports *aNative,
- PRUint32 aIndex,
- nsWrapperCache **aCache,
- nsresult *aResult)
-{
- ListType* list = static_cast(static_cast(aNative));
-#ifdef DEBUG
- {
- nsCOMPtr list_qi = do_QueryInterface(aNative);
-
- // If this assertion fires the QI implementation for the object in
- // question doesn't use the nsIDOMSVGXXXList pointer as the nsISupports
- // pointer. That must be fixed, or we'll crash...
- NS_ABORT_IF_FALSE(list_qi == list, "Uh, fix QI!");
- }
-#endif
-
- return list->GetItemAt(aIndex);
-}
-
-
// SVGStringList helper
nsresult
diff --git a/dom/base/nsDOMClassInfo.h b/dom/base/nsDOMClassInfo.h
index cf0bda03ec72..ab87d49fbe28 100644
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -1088,31 +1088,6 @@ public:
};
-// DOMTokenList scriptable helper
-
-class nsDOMTokenListSH : public nsStringArraySH
-{
-protected:
- nsDOMTokenListSH(nsDOMClassInfoData* aData) : nsStringArraySH(aData)
- {
- }
-
- virtual ~nsDOMTokenListSH()
- {
- }
-
- virtual nsresult GetStringAt(nsISupports *aNative, PRInt32 aIndex,
- nsAString& aResult);
-
-public:
-
- static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
- {
- return new nsDOMTokenListSH(aData);
- }
-};
-
-
// MediaList helper
class nsMediaListSH : public nsStringArraySH
@@ -1235,74 +1210,6 @@ public:
}
};
-// ClientRectList helper
-
-class nsClientRectListSH : public nsArraySH
-{
-protected:
- nsClientRectListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
- {
- }
-
- virtual ~nsClientRectListSH()
- {
- }
-
- virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex,
- nsWrapperCache **aCache, nsresult *aResult);
-
-public:
- static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
- {
- return new nsClientRectListSH(aData);
- }
-};
-
-
-// PaintRequestList helper
-
-class nsPaintRequestListSH : public nsArraySH
-{
-protected:
- nsPaintRequestListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
- {
- }
-
- virtual ~nsPaintRequestListSH()
- {
- }
-
- virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex,
- nsWrapperCache **aCache, nsresult *aResult);
-
-public:
- static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
- {
- return new nsPaintRequestListSH(aData);
- }
-};
-
-class nsDOMTouchListSH : public nsArraySH
-{
-protected:
- nsDOMTouchListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
- {
- }
-
- virtual ~nsDOMTouchListSH()
- {
- }
-
- virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex,
- nsWrapperCache **aCache, nsresult *aResult);
-
-public:
- static nsIClassInfo* doCreate(nsDOMClassInfoData* aData)
- {
- return new nsDOMTouchListSH(aData);
- }
-};
-
#ifdef MOZ_XUL
// TreeColumns helper
@@ -1507,53 +1414,6 @@ public:
}
};
-class nsFileListSH : public nsArraySH
-{
-protected:
- nsFileListSH(nsDOMClassInfoData *aData) : nsArraySH(aData)
- {
- }
-
- virtual ~nsFileListSH()
- {
- }
-
- virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex,
- nsWrapperCache **aCache, nsresult *aResult);
-
-public:
- static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
- {
- return new nsFileListSH(aData);
- }
-};
-
-// Template for SVGXXXList helpers
-
-template
-class nsSVGListSH : public nsArraySH
-{
-protected:
- nsSVGListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
- {
- }
-
-public:
- virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex,
- nsWrapperCache **aCache, nsresult *aResult);
-
- static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
- {
- return new nsSVGListSH(aData);
- }
-};
-
-typedef nsSVGListSH nsSVGLengthListSH;
-typedef nsSVGListSH nsSVGNumberListSH;
-typedef nsSVGListSH nsSVGPathSegListSH;
-typedef nsSVGListSH nsSVGPointListSH;
-typedef nsSVGListSH nsSVGTransformListSH;
-
// SVGStringList helper
class nsSVGStringListSH : public nsStringArraySH
diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp
index 4c401d82d285..af159ec80d02 100644
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -50,7 +50,7 @@
#include "nsIMarkupDocumentViewer.h"
#include "nsClientRect.h"
-#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK)
#include
#include
#endif
@@ -213,8 +213,8 @@ nsDOMWindowUtils::Redraw(PRUint32 aCount, PRUint32 *aDurationOut)
for (PRUint32 i = 0; i < aCount; i++)
rootFrame->InvalidateWithFlags(r, nsIFrame::INVALIDATE_IMMEDIATE);
-#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK2)
- XSync(GDK_DISPLAY(), False);
+#if defined(MOZ_X11) && defined(MOZ_WIDGET_GTK)
+ XSync(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), False);
#endif
*aDurationOut = PR_IntervalToMilliseconds(PR_IntervalNow() - iStart);
diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h
index de18e6b9ae16..0b77d008697f 100644
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -340,6 +340,7 @@ public:
virtual NS_HIDDEN_(bool) DispatchCustomEvent(const char *aEventName);
virtual NS_HIDDEN_(void) RefreshCompartmentPrincipal();
virtual NS_HIDDEN_(nsresult) SetFullScreenInternal(bool aIsFullScreen, bool aRequireTrust);
+ virtual NS_HIDDEN_(bool) IsPartOfApp();
// nsIDOMStorageIndexedDB
NS_DECL_NSIDOMSTORAGEINDEXEDDB
@@ -545,13 +546,6 @@ public:
void AddEventTargetObject(nsDOMEventTargetHelper* aObject);
void RemoveEventTargetObject(nsDOMEventTargetHelper* aObject);
- /**
- * Returns if the window is part of an application.
- * It will check for the window app state and its parents until a window has
- * an app state different from |TriState_Unknown|.
- */
- bool IsPartOfApp();
-
protected:
friend class HashchangeCallback;
friend class nsBarProp;
diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp
index 3c02c24da634..0dcdebb50a5a 100644
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -2960,10 +2960,70 @@ nsJSContext::ShrinkGCBuffersNow()
JS_ShrinkGCBuffers(nsJSRuntime::sRuntime);
}
-//Static
+// Return true if any JSContext has a "global object" with a gray
+// parent. The intent is to look for JS Object windows. We don't merge
+// system compartments, so we don't use them to trigger merging CCs.
+static bool
+AnyGrayGlobalParent()
+{
+ if (!nsJSRuntime::sRuntime) {
+ return false;
+ }
+ JSContext *iter = nsnull;
+ JSContext *cx;
+ while ((cx = JS_ContextIterator(nsJSRuntime::sRuntime, &iter))) {
+ if (JSObject *global = JS_GetGlobalObject(cx)) {
+ if (JSObject *parent = js::GetObjectParent(global)) {
+ if (js::GCThingIsMarkedGray(parent) &&
+ !js::IsSystemCompartment(js::GetGCThingCompartment(parent))) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+static bool
+DoMergingCC(bool aForced)
+{
+ // Don't merge too many times in a row, and do at least a minimum
+ // number of unmerged CCs in a row.
+ static const PRInt32 kMinConsecutiveUnmerged = 3;
+ static const PRInt32 kMaxConsecutiveMerged = 3;
+
+ static PRInt32 sUnmergedNeeded = 0;
+ static PRInt32 sMergedInARow = 0;
+
+ MOZ_ASSERT(0 <= sUnmergedNeeded <= kMinConsecutiveUnmerged);
+ MOZ_ASSERT(0 <= sMergedInARow <= kMaxConsecutiveMerged);
+
+ if (sMergedInARow == kMaxConsecutiveMerged) {
+ MOZ_ASSERT(sUnmergedNeeded == 0);
+ sUnmergedNeeded = kMinConsecutiveUnmerged;
+ }
+
+ if (sUnmergedNeeded > 0) {
+ sUnmergedNeeded--;
+ sMergedInARow = 0;
+ return false;
+ }
+
+ if (!aForced && AnyGrayGlobalParent()) {
+ sMergedInARow++;
+ return true;
+ } else {
+ sMergedInARow = 0;
+ return false;
+ }
+
+}
+
+//static
void
nsJSContext::CycleCollectNow(nsICycleCollectorListener *aListener,
- PRInt32 aExtraForgetSkippableCalls)
+ PRInt32 aExtraForgetSkippableCalls,
+ bool aForced)
{
if (!NS_IsMainThread()) {
return;
@@ -2995,8 +3055,10 @@ nsJSContext::CycleCollectNow(nsICycleCollectorListener *aListener,
++sCleanupsSinceLastGC;
}
+ bool mergingCC = DoMergingCC(aForced);
+
nsCycleCollectorResults ccResults;
- nsCycleCollector_collect(&ccResults, aListener);
+ nsCycleCollector_collect(mergingCC, &ccResults, aListener);
sCCollectedWaitingForGC += ccResults.mFreedRefCounted + ccResults.mFreedGCed;
// If we collected a substantial amount of cycles, poke the GC since more objects
@@ -3024,13 +3086,18 @@ nsJSContext::CycleCollectNow(nsICycleCollectorListener *aListener,
sFirstCollectionTime = now;
}
+ nsCString mergeMsg;
+ if (mergingCC) {
+ mergeMsg.AssignLiteral(" merged");
+ }
+
nsCString gcMsg;
if (ccResults.mForcedGC) {
gcMsg.AssignLiteral(", forced a GC");
}
NS_NAMED_MULTILINE_LITERAL_STRING(kFmt,
- NS_LL("CC(T+%.1f) duration: %llums, suspected: %lu, visited: %lu RCed and %lu GCed, collected: %lu RCed and %lu GCed (%lu waiting for GC)%s\n")
+ NS_LL("CC(T+%.1f) duration: %llums, suspected: %lu, visited: %lu RCed and %lu%s GCed, collected: %lu RCed and %lu GCed (%lu waiting for GC)%s\n")
NS_LL("ForgetSkippable %lu times before CC, min: %lu ms, max: %lu ms, avg: %lu ms, total: %lu ms, removed: %lu"));
nsString msg;
PRUint32 cleanups = sForgetSkippableBeforeCC ? sForgetSkippableBeforeCC : 1;
@@ -3038,7 +3105,7 @@ nsJSContext::CycleCollectNow(nsICycleCollectorListener *aListener,
? 0 : sMinForgetSkippableTime;
msg.Adopt(nsTextFormatter::smprintf(kFmt.get(), double(delta) / PR_USEC_PER_SEC,
(now - start) / PR_USEC_PER_MSEC, suspected,
- ccResults.mVisitedRefCounted, ccResults.mVisitedGCed,
+ ccResults.mVisitedRefCounted, ccResults.mVisitedGCed, mergeMsg.get(),
ccResults.mFreedRefCounted, ccResults.mFreedGCed,
sCCollectedWaitingForGC, gcMsg.get(),
sForgetSkippableBeforeCC,
@@ -3191,7 +3258,7 @@ CCTimerFired(nsITimer *aTimer, void *aClosure)
} else {
// We are in the final timer fire and still meet the conditions for
// triggering a CC.
- nsJSContext::CycleCollectNow();
+ nsJSContext::CycleCollectNow(nsnull, 0, false);
}
} else if ((sPreviousSuspectedCount + 100) <= suspected) {
// Only do a forget skippable if there are more than a few new objects.
diff --git a/dom/base/nsJSEnvironment.h b/dom/base/nsJSEnvironment.h
index 073beed81fbc..a1bc0423889f 100644
--- a/dom/base/nsJSEnvironment.h
+++ b/dom/base/nsJSEnvironment.h
@@ -153,7 +153,8 @@ public:
// If aExtraForgetSkippableCalls is -1, forgetSkippable won't be
// called even if the previous collection was GC.
static void CycleCollectNow(nsICycleCollectorListener *aListener = nsnull,
- PRInt32 aExtraForgetSkippableCalls = 0);
+ PRInt32 aExtraForgetSkippableCalls = 0,
+ bool aForced = true);
static void PokeGC(js::gcreason::Reason aReason, int aDelay = 0);
static void KillGCTimer();
diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h
index 1b39640cae92..6a21b4b4c4f1 100644
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -592,6 +592,13 @@ public:
*/
virtual void RefreshCompartmentPrincipal() = 0;
+ /**
+ * Returns if the window is part of an application.
+ * It will check for the window app state and its parents until a window has
+ * an app state different from |TriState_Unknown|.
+ */
+ virtual bool IsPartOfApp() = 0;
+
protected:
// The nsPIDOMWindow constructor. The aOuterWindow argument should
// be null if and only if the created window itself is an outer
diff --git a/dom/bindings/TypedArray.h b/dom/bindings/TypedArray.h
index e1d4a8d78c87..b2fdffaf1ab9 100644
--- a/dom/bindings/TypedArray.h
+++ b/dom/bindings/TypedArray.h
@@ -44,7 +44,15 @@ struct TypedArray : public TypedArray_base {
{}
static inline JSObject*
- Create(JSContext* cx, uint32_t length, T* data = NULL) {
+ Create(JSContext* cx, nsWrapperCache* creator, uint32_t length,
+ T* data = NULL) {
+ JSObject* creatorWrapper;
+ JSAutoEnterCompartment ac;
+ if (creator && (creatorWrapper = creator->GetWrapperPreserveColor())) {
+ if (!ac.enter(cx, creatorWrapper)) {
+ return NULL;
+ }
+ }
JSObject* obj = CreateNew(cx, length);
if (!obj) {
return NULL;
@@ -64,7 +72,7 @@ typedef TypedArray
Uint8Array;
typedef TypedArray
+ JS_GetTypedArrayLength, JS_NewUint8ClampedArray>
Uint8ClampedArray;
typedef TypedArray
diff --git a/dom/devicestorage/Makefile.in b/dom/devicestorage/Makefile.in
index be8b0f586607..23bce76d9daf 100644
--- a/dom/devicestorage/Makefile.in
+++ b/dom/devicestorage/Makefile.in
@@ -32,6 +32,8 @@ LOCAL_INCLUDES = \
-I$(topsrcdir)/content/events/src \
$(NULL)
+TEST_DIRS += test
+
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
include $(topsrcdir)/config/rules.mk
diff --git a/dom/devicestorage/nsDeviceStorage.cpp b/dom/devicestorage/nsDeviceStorage.cpp
index 5a9c20b36256..2a877c60e542 100644
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -28,9 +28,11 @@ public:
nsCOMPtr mFile;
nsString mPath;
+ bool mEditable;
DeviceStorageFile(nsIFile* aFile, const nsAString& aPath)
: mPath(aPath)
+ , mEditable(false)
{
NS_ASSERTION(aFile, "Must not create a DeviceStorageFile with a null nsIFile");
// always take a clone
@@ -43,6 +45,7 @@ public:
}
DeviceStorageFile(nsIFile* aFile)
+ : mEditable(false)
{
NS_ASSERTION(aFile, "Must not create a DeviceStorageFile with a null nsIFile");
// always take a clone
@@ -56,6 +59,11 @@ public:
NormalizeFilePath();
}
+ void
+ setEditable(bool aEditable) {
+ mEditable = aEditable;
+ }
+
NS_DECL_ISUPPORTS
// we want to make sure that the names of file can't reach
@@ -220,12 +228,12 @@ nsDOMDeviceStorage::SetRootFileForType(const nsAString& aType, const PRInt32 aIn
return typeResult;
}
-static jsval nsIFileToJsval(nsPIDOMWindow* aWindow, DeviceStorageFile* aFile, bool aEditable)
+static jsval nsIFileToJsval(nsPIDOMWindow* aWindow, DeviceStorageFile* aFile)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(aWindow, "Null Window");
- if (aEditable) {
+ if (aFile->mEditable) {
// TODO - needs janv's file handle support.
return JSVAL_NULL;
}
@@ -309,7 +317,6 @@ public:
nsDOMDeviceStorageCursor(nsIDOMWindow* aWindow,
nsIURI* aURI,
DeviceStorageFile* aFile,
- bool aEditable,
PRUint64 aSince);
private:
@@ -321,7 +328,6 @@ protected:
bool mOkToCallContinue;
nsRefPtr mFile;
nsCOMPtr mURI;
- bool mEditable;
PRUint64 mSince;
// to access mFiles
@@ -453,7 +459,7 @@ public:
else {
nsRefPtr file = cursor->mFiles[0];
cursor->mFiles.RemoveElementAt(0);
- val = nsIFileToJsval(cursor->GetOwner(), file, cursor->mEditable);
+ val = nsIFileToJsval(cursor->GetOwner(), file);
cursor->mOkToCallContinue = true;
}
@@ -578,13 +584,11 @@ NS_IMPL_RELEASE_INHERITED(nsDOMDeviceStorageCursor, DOMRequest)
nsDOMDeviceStorageCursor::nsDOMDeviceStorageCursor(nsIDOMWindow* aWindow,
nsIURI* aURI,
DeviceStorageFile* aFile,
- bool aEditable,
PRUint64 aSince)
: DOMRequest(aWindow)
, mOkToCallContinue(false)
, mFile(aFile)
, mURI(aURI)
- , mEditable(aEditable)
, mSince(aSince)
{
}
@@ -677,9 +681,8 @@ nsDOMDeviceStorageCursor::Continue()
class PostResultEvent : public nsRunnable
{
public:
- PostResultEvent(nsRefPtr& aRequest, bool aEditable, DeviceStorageFile* aFile)
- : mEditable(aEditable)
- , mFile(aFile)
+ PostResultEvent(nsRefPtr& aRequest, DeviceStorageFile* aFile)
+ : mFile(aFile)
{
mRequest.swap(aRequest);
}
@@ -698,7 +701,7 @@ public:
jsval result = JSVAL_NULL;
if (mFile) {
- result = nsIFileToJsval(mRequest->GetOwner(), mFile, mEditable);
+ result = nsIFileToJsval(mRequest->GetOwner(), mFile);
} else {
result = StringToJsval(mRequest->GetOwner(), mPath);
}
@@ -709,7 +712,6 @@ public:
}
private:
- bool mEditable;
nsRefPtr mFile;
nsString mPath;
nsRefPtr mRequest;
@@ -808,16 +810,12 @@ private:
nsRefPtr mFile;
nsRefPtr mRequest;
};
-
-
class ReadFileEvent : public nsRunnable
{
public:
ReadFileEvent(DeviceStorageFile* aFile,
- bool aEditable,
nsRefPtr& aRequest)
: mFile(aFile)
- , mEditable(aEditable)
{
mRequest.swap(aRequest);
}
@@ -830,7 +828,7 @@ public:
nsRefPtr r;
- if (!mEditable) {
+ if (!mFile->mEditable) {
bool check = false;
mFile->mFile->Exists(&check);
if (!check) {
@@ -839,7 +837,7 @@ public:
}
if (!r) {
- r = new PostResultEvent(mRequest, mEditable, mFile);
+ r = new PostResultEvent(mRequest, mFile);
}
NS_DispatchToMainThread(r);
return NS_OK;
@@ -847,7 +845,6 @@ public:
private:
nsRefPtr mFile;
- bool mEditable;
nsRefPtr mRequest;
};
@@ -902,14 +899,12 @@ public:
nsIURI *aURI,
DeviceStorageFile *aFile,
DOMRequest* aRequest,
- bool aEditable,
nsIDOMBlob *aBlob = nsnull)
: mRequestType(aRequestType)
, mWindow(aWindow)
, mURI(aURI)
, mFile(aFile)
, mRequest(aRequest)
- , mEditable(aEditable)
, mBlob(aBlob) {}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@@ -982,7 +977,7 @@ public:
}
case DEVICE_STORAGE_REQUEST_READ:
{
- r = new ReadFileEvent(mFile, mEditable, mRequest);
+ r = new ReadFileEvent(mFile, mRequest);
break;
}
case DEVICE_STORAGE_REQUEST_DELETE:
@@ -1007,7 +1002,6 @@ private:
nsRefPtr mFile;
nsRefPtr mRequest;
- bool mEditable;
nsCOMPtr mBlob;
};
@@ -1165,7 +1159,7 @@ nsDOMDeviceStorage::AddNamed(nsIDOMBlob *aBlob,
}
else {
r = new DeviceStorageRequest(DeviceStorageRequest::DEVICE_STORAGE_REQUEST_WRITE,
- win, mURI, dsf, request, true, aBlob);
+ win, mURI, dsf, request, aBlob);
}
NS_DispatchToMainThread(r);
return NS_OK;
@@ -1215,12 +1209,13 @@ nsDOMDeviceStorage::GetInternal(const JS::Value & aPath,
}
nsRefPtr dsf = new DeviceStorageFile(mFile, path);
+ dsf->setEditable(aEditable);
if (!dsf->isSafePath()) {
r = new PostErrorEvent(request, POST_ERROR_EVENT_ILLEGAL_FILE_NAME, dsf);
} else {
r = new DeviceStorageRequest(DeviceStorageRequest::DEVICE_STORAGE_REQUEST_READ,
- win, mURI, dsf, request, aEditable);
+ win, mURI, dsf, request);
}
NS_DispatchToMainThread(r);
return NS_OK;
@@ -1255,7 +1250,7 @@ nsDOMDeviceStorage::Delete(const JS::Value & aPath, JSContext* aCx, nsIDOMDOMReq
}
else {
r = new DeviceStorageRequest(DeviceStorageRequest::DEVICE_STORAGE_REQUEST_DELETE,
- win, mURI, dsf, request, true);
+ win, mURI, dsf, request);
}
NS_DispatchToMainThread(r);
return NS_OK;
@@ -1336,7 +1331,9 @@ nsDOMDeviceStorage::EnumerateInternal(const JS::Value & aName,
}
nsRefPtr dsf = new DeviceStorageFile(mFile, path);
- nsRefPtr cursor = new nsDOMDeviceStorageCursor(win, mURI, dsf, aEditable, since);
+ dsf->setEditable(aEditable);
+
+ nsRefPtr cursor = new nsDOMDeviceStorageCursor(win, mURI, dsf, since);
nsRefPtr r = new DeviceStorageCursorRequest(cursor);
NS_ADDREF(*aRetval = cursor);
diff --git a/dom/tests/mochitest/devicestorage/Makefile.in b/dom/devicestorage/test/Makefile.in
similarity index 90%
rename from dom/tests/mochitest/devicestorage/Makefile.in
rename to dom/devicestorage/test/Makefile.in
index 844f0f1e0621..7a2d5b843f3f 100644
--- a/dom/tests/mochitest/devicestorage/Makefile.in
+++ b/dom/devicestorage/test/Makefile.in
@@ -2,11 +2,11 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
-DEPTH = ../../../..
+DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
-relativesrcdir = dom/tests/mochitest/devicestorage
+relativesrcdir = dom/devicestorage/test/
include $(DEPTH)/config/autoconf.mk
diff --git a/dom/tests/mochitest/devicestorage/devicestorage_common.js b/dom/devicestorage/test/devicestorage_common.js
similarity index 100%
rename from dom/tests/mochitest/devicestorage/devicestorage_common.js
rename to dom/devicestorage/test/devicestorage_common.js
diff --git a/dom/tests/mochitest/devicestorage/test_basic.html b/dom/devicestorage/test/test_basic.html
similarity index 100%
rename from dom/tests/mochitest/devicestorage/test_basic.html
rename to dom/devicestorage/test/test_basic.html
diff --git a/dom/tests/mochitest/devicestorage/test_dotdot.html b/dom/devicestorage/test/test_dotdot.html
similarity index 100%
rename from dom/tests/mochitest/devicestorage/test_dotdot.html
rename to dom/devicestorage/test/test_dotdot.html
diff --git a/dom/tests/mochitest/devicestorage/test_enumerate.html b/dom/devicestorage/test/test_enumerate.html
similarity index 100%
rename from dom/tests/mochitest/devicestorage/test_enumerate.html
rename to dom/devicestorage/test/test_enumerate.html
diff --git a/dom/tests/mochitest/devicestorage/test_enumerateMultipleContinue.html b/dom/devicestorage/test/test_enumerateMultipleContinue.html
similarity index 100%
rename from dom/tests/mochitest/devicestorage/test_enumerateMultipleContinue.html
rename to dom/devicestorage/test/test_enumerateMultipleContinue.html
diff --git a/dom/tests/mochitest/devicestorage/test_enumerateNoParam.html b/dom/devicestorage/test/test_enumerateNoParam.html
similarity index 100%
rename from dom/tests/mochitest/devicestorage/test_enumerateNoParam.html
rename to dom/devicestorage/test/test_enumerateNoParam.html
diff --git a/dom/tests/mochitest/devicestorage/test_enumerateOptions.html b/dom/devicestorage/test/test_enumerateOptions.html
similarity index 100%
rename from dom/tests/mochitest/devicestorage/test_enumerateOptions.html
rename to dom/devicestorage/test/test_enumerateOptions.html
diff --git a/dom/tests/mochitest/devicestorage/test_lastModificationFilter.html b/dom/devicestorage/test/test_lastModificationFilter.html
similarity index 100%
rename from dom/tests/mochitest/devicestorage/test_lastModificationFilter.html
rename to dom/devicestorage/test/test_lastModificationFilter.html
diff --git a/dom/tests/mochitest/devicestorage/test_overwrite.html b/dom/devicestorage/test/test_overwrite.html
similarity index 100%
rename from dom/tests/mochitest/devicestorage/test_overwrite.html
rename to dom/devicestorage/test/test_overwrite.html
diff --git a/dom/tests/mochitest/devicestorage/test_sanity.html b/dom/devicestorage/test/test_sanity.html
similarity index 100%
rename from dom/tests/mochitest/devicestorage/test_sanity.html
rename to dom/devicestorage/test/test_sanity.html
diff --git a/dom/interfaces/core/nsIDOMElement.idl b/dom/interfaces/core/nsIDOMElement.idl
index 6b4f47c89d45..7c7f3b07851d 100644
--- a/dom/interfaces/core/nsIDOMElement.idl
+++ b/dom/interfaces/core/nsIDOMElement.idl
@@ -156,6 +156,12 @@ interface nsIDOMElement : nsIDOMNode
*/
readonly attribute long clientHeight;
+ /* The maximum offset that the element can be scrolled to
+ (i.e., the value that scrollLeft/scrollTop would be clamped to if they were
+ set to arbitrarily large values. */
+ readonly attribute long scrollLeftMax;
+ readonly attribute long scrollTopMax;
+
// Selectors API
/**
diff --git a/dom/interfaces/html/nsIDOMHTMLInputElement.idl b/dom/interfaces/html/nsIDOMHTMLInputElement.idl
index 09c28953f3a8..17fc3ea9828c 100644
--- a/dom/interfaces/html/nsIDOMHTMLInputElement.idl
+++ b/dom/interfaces/html/nsIDOMHTMLInputElement.idl
@@ -20,7 +20,7 @@ interface nsIDOMValidityState;
* http://www.whatwg.org/specs/web-apps/current-work/
*/
-[scriptable, uuid(05FEDF7E-3050-4143-AB97-B994F3CC9329)]
+[scriptable, uuid(ac2e2b14-b987-452c-a071-5823b2406b85)]
interface nsIDOMHTMLInputElement : nsIDOMHTMLElement
{
attribute DOMString accept;
@@ -40,6 +40,7 @@ interface nsIDOMHTMLInputElement : nsIDOMHTMLElement
readonly attribute nsIDOMFileList files;
+ attribute unsigned long height;
attribute boolean indeterminate;
readonly attribute nsIDOMHTMLElement list;
@@ -56,6 +57,7 @@ interface nsIDOMHTMLInputElement : nsIDOMHTMLElement
attribute DOMString align;
attribute unsigned long size;
+ attribute unsigned long width;
attribute DOMString src;
attribute DOMString type;
diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
index 05243027cf42..82920b9e9a11 100644
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
#include
#endif
@@ -218,7 +218,7 @@ ContentChild::Init(MessageLoop* aIOLoop,
base::ProcessHandle aParentHandle,
IPC::Channel* aChannel)
{
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
// sigh
gtk_init(NULL, NULL);
#endif
diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp
index 38052bd8e83c..b378cc59f6d9 100644
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -507,6 +507,7 @@ ContentParent::RecvSetClipboardText(const nsString& text, const PRInt32& whichCl
nsCOMPtr trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
NS_ENSURE_SUCCESS(rv, true);
+ trans->Init(nsnull);
// If our data flavor has already been added, this will fail. But we don't care
trans->AddDataFlavor(kUnicodeMime);
@@ -531,6 +532,7 @@ ContentParent::RecvGetClipboardText(const PRInt32& whichClipboard, nsString* tex
nsCOMPtr trans = do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
NS_ENSURE_SUCCESS(rv, true);
+ trans->Init(nsnull);
clipboard->GetData(trans, whichClipboard);
nsCOMPtr tmp;
diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp
index e703161b51f4..a5927897127d 100644
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -56,11 +56,13 @@
#endif
// needed for nppdf plugin
-#ifdef MOZ_WIDGET_GTK2
+#if (MOZ_WIDGET_GTK)
#include
#include
+#if (MOZ_WIDGET_GTK == 2)
#include "gtk2xtbin.h"
#endif
+#endif
#ifdef XP_OS2
#define INCL_DOS
@@ -2013,7 +2015,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
}
case NPNVToolkit: {
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
*((NPNToolkitType*)result) = NPNVGtk2;
#endif
@@ -2028,7 +2030,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
}
case NPNVSupportsXEmbedBool: {
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
*(NPBool*)result = true;
#elif defined(MOZ_WIDGET_QT)
// Desktop Flash fail to initialize if browser does not support NPNVSupportsXEmbedBool
@@ -2055,7 +2057,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
case NPNVSupportsWindowless: {
#if defined(XP_WIN) || defined(XP_MACOSX) || \
- (defined(MOZ_X11) && (defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_QT)))
+ (defined(MOZ_X11) && (defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)))
*(NPBool*)result = true;
#else
*(NPBool*)result = false;
diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp
index ef8c5de34ed8..4fb58bfae2bf 100644
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -734,7 +734,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value)
}
return rv;
-#elif (defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_QT)) && defined(MOZ_X11)
+#elif (defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)) && defined(MOZ_X11)
// X11 window managers want the toplevel window for WM_TRANSIENT_FOR.
nsIWidget* win = mObjectFrame->GetNearestWidget();
if (!win)
@@ -2432,7 +2432,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
nsIntPoint rootPoint(-1,-1);
if (widget)
rootPoint = anEvent.refPoint + widget->WidgetToScreenOffset();
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
Window root = GDK_ROOT_WINDOW();
#elif defined(MOZ_WIDGET_QT)
Window root = RootWindowOfScreen(DefaultScreenOfDisplay(mozilla::DefaultXDisplay()));
@@ -2520,7 +2520,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
if (anEvent.pluginEvent)
{
XKeyEvent &event = pluginEvent.xkey;
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
event.root = GDK_ROOT_WINDOW();
event.time = anEvent.time;
const GdkEventKey* gdkEvent =
@@ -3046,17 +3046,11 @@ void nsPluginInstanceOwner::Paint(gfxContext* aContext,
aContext->Translate(pluginRect.TopLeft());
Renderer renderer(window, this, pluginSize, pluginDirtyRect);
-#ifdef MOZ_WIDGET_GTK2
- // This is the visual used by the widgets, 24-bit if available.
- GdkVisual* gdkVisual = gdk_rgb_get_visual();
- Visual* visual = gdk_x11_visual_get_xvisual(gdkVisual);
- Screen* screen =
- gdk_x11_screen_get_xscreen(gdk_visual_get_screen(gdkVisual));
-#else
+
Display* dpy = mozilla::DefaultXDisplay();
Screen* screen = DefaultScreenOfDisplay(dpy);
Visual* visual = DefaultVisualOfScreen(screen);
-#endif
+
renderer.Draw(aContext, nsIntSize(window->width, window->height),
rendererFlags, screen, visual, nsnull);
}
diff --git a/dom/plugins/base/nsPluginNativeWindowGtk2.cpp b/dom/plugins/base/nsPluginNativeWindowGtk2.cpp
index 2d9a5dbcdf03..09ec470c7fdf 100644
--- a/dom/plugins/base/nsPluginNativeWindowGtk2.cpp
+++ b/dom/plugins/base/nsPluginNativeWindowGtk2.cpp
@@ -16,6 +16,7 @@
#include
#include
+#include "gtk2compat.h"
#include "gtk2xtbin.h"
class nsPluginNativeWindowGtk2 : public nsPluginNativeWindow {
@@ -147,8 +148,8 @@ nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsRefPtr
nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow() {
NS_ASSERTION(!mSocketWidget,"Already created a socket widget!");
-
- GdkWindow *parent_win = gdk_window_lookup((XID)window);
+ GdkDisplay *display = gdk_display_get_default();
+ GdkWindow *parent_win = gdk_x11_window_lookup_for_display(display, (XID)window);
mSocketWidget = gtk_socket_new();
//attach the socket to the container widget
@@ -179,7 +180,10 @@ nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow() {
// background and this would happen immediately (before the plug is
// created). Setting the background to None prevents the server from
// painting this window, avoiding flicker.
- gdk_window_set_back_pixmap(mSocketWidget->window, NULL, FALSE);
+ // TODO GTK3
+#if (MOZ_WIDGET_GTK == 2)
+ gdk_window_set_back_pixmap(gtk_widget_get_window(mSocketWidget), NULL, FALSE);
+#endif
// Resize before we show
SetAllocation();
@@ -196,11 +200,17 @@ nsresult nsPluginNativeWindowGtk2::CreateXEmbedWindow() {
return NS_ERROR_FAILURE;
mWsInfo.display = GDK_WINDOW_XDISPLAY(gdkWindow);
+#if (MOZ_WIDGET_GTK == 2)
mWsInfo.colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(gdkWindow));
GdkVisual* gdkVisual = gdk_drawable_get_visual(gdkWindow);
- mWsInfo.visual = GDK_VISUAL_XVISUAL(gdkVisual);
mWsInfo.depth = gdkVisual->depth;
-
+#else
+ mWsInfo.colormap = None;
+ GdkVisual* gdkVisual = gdk_window_get_visual(gdkWindow);
+ mWsInfo.depth = gdk_visual_get_depth(gdkVisual);
+#endif
+ mWsInfo.visual = GDK_VISUAL_XVISUAL(gdkVisual);
+
return NS_OK;
}
@@ -223,7 +233,8 @@ nsresult nsPluginNativeWindowGtk2::CreateXtWindow() {
printf("About to create new xtbin of %i X %i from %p...\n",
width, height, (void*)window);
#endif
- GdkWindow *gdkWindow = gdk_window_lookup((XID)window);
+ GdkDisplay *display = gdk_display_get_default();
+ GdkWindow *gdkWindow = gdk_x11_window_lookup_for_display(display, (XID)window);
mSocketWidget = gtk_xtbin_new(gdkWindow, 0);
// Check to see if creating the xtbin failed for some reason.
// if it did, we can't go any further.
@@ -270,8 +281,9 @@ socket_unrealize_cb(GtkWidget *widget, gpointer data)
{
// Unmap and reparent any child windows that GDK does not yet know about.
// (See bug 540114 comment 10.)
- GdkWindow* socket_window = widget->window;
- Display* display = GDK_DISPLAY();
+ GdkWindow* socket_window = gtk_widget_get_window(widget);
+ GdkDisplay* gdkDisplay = gdk_display_get_default();
+ Display* display = GDK_DISPLAY_XDISPLAY(gdkDisplay);
// Ignore X errors that may happen if windows get destroyed (possibly
// requested by the plugin) between XQueryTree and when we operate on them.
@@ -280,13 +292,13 @@ socket_unrealize_cb(GtkWidget *widget, gpointer data)
Window root, parent;
Window* children;
unsigned int nchildren;
- if (!XQueryTree(display, gdk_x11_drawable_get_xid(socket_window),
+ if (!XQueryTree(display, gdk_x11_window_get_xid(socket_window),
&root, &parent, &children, &nchildren))
return;
for (unsigned int i = 0; i < nchildren; ++i) {
Window child = children[i];
- if (!gdk_window_lookup(child)) {
+ if (!gdk_x11_window_lookup_for_display(gdkDisplay, child)) {
// This window is not known to GDK.
XUnmapWindow(display, child);
XReparentWindow(display, child, DefaultRootWindow(display), 0, 0);
diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp
index c1dfbe3a9982..8e7193b3e8cf 100644
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -44,9 +44,12 @@ using mozilla::ipc::ProcessChild;
using namespace mozilla::plugins;
using namespace std;
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
#include
+#if (MOZ_WIDGET_GTK == 3)
+#include
+#endif
#include
#include
#include "gtk2xtbin.h"
diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp
index dce4333a819c..19b66b65aee9 100644
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -36,7 +36,7 @@ extern const PRUnichar* kOOPPPluginFocusEventId;
UINT gOOPPPluginFocusEvent =
RegisterWindowMessage(kOOPPPluginFocusEventId);
extern const PRUnichar* kFlashFullscreenClass;
-#elif defined(MOZ_WIDGET_GTK2)
+#elif defined(MOZ_WIDGET_GTK)
#include
#elif defined(XP_MACOSX)
#include
@@ -1268,7 +1268,7 @@ PluginInstanceParent::NPP_HandleEvent(void* event)
// Release any active pointer grab so that the plugin X client can
// grab the pointer if it wishes.
Display *dpy = DefaultXDisplay();
-# ifdef MOZ_WIDGET_GTK2
+# ifdef MOZ_WIDGET_GTK
// GDK attempts to (asynchronously) track whether there is an active
// grab so ungrab through GDK.
gdk_pointer_ungrab(npevent->xbutton.time);
diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp
index 4a1eed0ef266..83d6e2fb26a4 100644
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -17,8 +17,12 @@
#include "mozilla/ipc/SyncChannel.h"
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
#include
+#if (MOZ_WIDGET_GTK == 3)
+#include
+#endif
+#include "gtk2compat.h"
#endif
#include "nsIFile.h"
@@ -90,7 +94,7 @@ PluginModuleChild::PluginModuleChild()
, mInitializeFunc(0)
#if defined(OS_WIN) || defined(OS_MACOSX)
, mGetEntryPointsFunc(0)
-#elif defined(MOZ_WIDGET_GTK2)
+#elif defined(MOZ_WIDGET_GTK)
, mNestedLoopTimerId(0)
#elif defined(MOZ_WIDGET_QT)
, mNestedLoopTimerObject(0)
@@ -229,7 +233,7 @@ PluginModuleChild::Init(const std::string& aPluginFilename,
return true;
}
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
typedef void (*GObjectDisposeFn)(GObject*);
typedef gboolean (*GtkWidgetScrollEventFn)(GtkWidget*, GdkEventScroll*);
typedef void (*GtkPlugEmbeddedFn)(GtkPlug*);
@@ -269,16 +273,16 @@ wrap_gtk_plug_dispose(GObject* object) {
static gboolean
gtk_plug_scroll_event(GtkWidget *widget, GdkEventScroll *gdk_event)
{
- if (!GTK_WIDGET_TOPLEVEL(widget)) // in same process as its GtkSocket
+ if (!gtk_widget_is_toplevel(widget)) // in same process as its GtkSocket
return FALSE; // event not handled; propagate to GtkSocket
- GdkWindow* socket_window = GTK_PLUG(widget)->socket_window;
+ GdkWindow* socket_window = gtk_plug_get_socket_window(GTK_PLUG(widget));
if (!socket_window)
return FALSE;
// Propagate the event to the embedder.
- GdkScreen* screen = gdk_drawable_get_screen(socket_window);
- GdkWindow* plug_window = widget->window;
+ GdkScreen* screen = gdk_window_get_screen(socket_window);
+ GdkWindow* plug_window = gtk_widget_get_window(widget);
GdkWindow* event_window = gdk_event->window;
gint x = gdk_event->x;
gint y = gdk_event->y;
@@ -324,9 +328,9 @@ gtk_plug_scroll_event(GtkWidget *widget, GdkEventScroll *gdk_event)
memset(&xevent, 0, sizeof(xevent));
xevent.xbutton.type = ButtonPress;
- xevent.xbutton.window = GDK_WINDOW_XWINDOW(socket_window);
- xevent.xbutton.root = GDK_WINDOW_XWINDOW(gdk_screen_get_root_window(screen));
- xevent.xbutton.subwindow = GDK_WINDOW_XWINDOW(plug_window);
+ xevent.xbutton.window = gdk_x11_window_get_xid(socket_window);
+ xevent.xbutton.root = gdk_x11_window_get_xid(gdk_screen_get_root_window(screen));
+ xevent.xbutton.subwindow = gdk_x11_window_get_xid(plug_window);
xevent.xbutton.time = gdk_event->time;
xevent.xbutton.x = x;
xevent.xbutton.y = y;
@@ -354,7 +358,7 @@ gtk_plug_scroll_event(GtkWidget *widget, GdkEventScroll *gdk_event)
static void
wrap_gtk_plug_embedded(GtkPlug* plug) {
- GdkWindow* socket_window = plug->socket_window;
+ GdkWindow* socket_window = gtk_plug_get_socket_window(plug);
if (socket_window) {
if (gtk_check_version(2,18,7) != NULL // older
&& g_object_get_data(G_OBJECT(socket_window),
@@ -497,7 +501,7 @@ PluginModuleChild::ShouldContinueFromReplyTimeout()
bool
PluginModuleChild::InitGraphics()
{
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
// Work around plugins that don't interact well with GDK
// client-side windows.
PR_SetEnv("GDK_NATIVE_WINDOWS=1");
@@ -1072,7 +1076,7 @@ _getvalue(NPP aNPP,
switch (aVariable) {
// Copied from nsNPAPIPlugin.cpp
case NPNVToolkit:
-#if defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_QT)
+#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)
*static_cast(aValue) = NPNVGtk2;
return NPERR_NO_ERROR;
#endif
diff --git a/dom/plugins/ipc/PluginModuleChild.h b/dom/plugins/ipc/PluginModuleChild.h
index dc170c95b18a..ac7709bb707b 100644
--- a/dom/plugins/ipc/PluginModuleChild.h
+++ b/dom/plugins/ipc/PluginModuleChild.h
@@ -306,7 +306,7 @@ private:
void InitQuirksModes(const nsCString& aMimeType);
bool InitGraphics();
void DeinitGraphics();
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
static gboolean DetectNestedEventLoop(gpointer data);
static gboolean ProcessBrowserEvents(gpointer data);
@@ -340,7 +340,7 @@ private:
NPPluginFuncs mFunctions;
NPSavedData mSavedData;
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
// If a plugin spins a nested glib event loop in response to a
// synchronous IPC message from the browser, the loop might break
// only after the browser responds to a request sent by the
diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp
index ff66d60f92e8..bb7d4f227ed9 100644
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#ifdef MOZ_WIDGET_GTK2
+#ifdef MOZ_WIDGET_GTK
#include
#elif XP_MACOSX
#include "PluginInterposeOSX.h"
@@ -964,7 +964,7 @@ PluginModuleParent::AnswerProcessSomeEvents()
return true;
}
-#elif !defined(MOZ_WIDGET_GTK2)
+#elif !defined(MOZ_WIDGET_GTK)
bool
PluginModuleParent::AnswerProcessSomeEvents()
{
diff --git a/dom/plugins/test/testplugin/nptest.cpp b/dom/plugins/test/testplugin/nptest.cpp
index 5112137dc1c3..e9336bba1850 100644
--- a/dom/plugins/test/testplugin/nptest.cpp
+++ b/dom/plugins/test/testplugin/nptest.cpp
@@ -3221,7 +3221,7 @@ hangPlugin(NPObject* npobj, const NPVariant* args, uint32_t argCount,
return true;
}
-#if defined(MOZ_WIDGET_GTK2)
+#if defined(MOZ_WIDGET_GTK)
bool
getClipboardText(NPObject* npobj, const NPVariant* args, uint32_t argCount,
NPVariant* result)
diff --git a/dom/system/OSFileConstants.cpp b/dom/system/OSFileConstants.cpp
index 8e7e1c810539..f112be88d78d 100644
--- a/dom/system/OSFileConstants.cpp
+++ b/dom/system/OSFileConstants.cpp
@@ -202,6 +202,19 @@ static dom::ConstantSpec gLibcProperties[] =
#endif // defined(EWOULDBLOCK)
INT_CONSTANT(EXDEV),
+ // Constants used to define data structures
+ //
+ // Many data structures have different fields/sizes/etc. on
+ // various OSes / versions of the same OS / platforms. For these
+ // data structures, we need to compute and export from C the size
+ // and, if necessary, the offset of fields, so as to be able to
+ // define the structure in JS.
+
+#if defined(XP_UNIX)
+ // The size of |mode_t|.
+ {"OSFILE_SIZEOF_MODE_T", INT_TO_JSVAL(sizeof (mode_t)) },
+#endif // defined(XP_UNIX)
+
PROP_END
};
@@ -349,7 +362,7 @@ bool DefineOSFileConstants(JSContext *cx, JSObject *global)
}
jsval valVersion = STRING_TO_JSVAL(strVersion);
- if (!JS_SetProperty(cx, objSys, "Version", &valVersion)) {
+ if (!JS_SetProperty(cx, objSys, "Name", &valVersion)) {
return false;
}
}
diff --git a/dom/tests/mochitest/Makefile.in b/dom/tests/mochitest/Makefile.in
index 481e24a89842..6411d139867c 100644
--- a/dom/tests/mochitest/Makefile.in
+++ b/dom/tests/mochitest/Makefile.in
@@ -18,7 +18,6 @@ DIRS += \
ajax \
bugs \
chrome \
- devicestorage \
general \
whatwg \
geolocation \
diff --git a/dom/tests/mochitest/general/test_clipboard_events.html b/dom/tests/mochitest/general/test_clipboard_events.html
index 1e5c5c875e0c..24abb2bf4ab8 100644
--- a/dom/tests/mochitest/general/test_clipboard_events.html
+++ b/dom/tests/mochitest/general/test_clipboard_events.html
@@ -74,10 +74,17 @@ window.onfocus = function()
SimpleTest.waitForExplicitFinish();
window.focus();
+function getLoadContext() {
+ return window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIWebNavigation)
+ .QueryInterface(Components.interfaces.nsILoadContext);
+}
+
function getClipboardText() {
var trans = Components.classes["@mozilla.org/widget/transferable;1"]
.createInstance();
trans = trans.QueryInterface(Components.interfaces.nsITransferable);
+ trans.init(getLoadContext());
trans.addDataFlavor("text/unicode");
var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"]
diff --git a/editor/libeditor/base/DeleteRangeTxn.cpp b/editor/libeditor/base/DeleteRangeTxn.cpp
index f8edcbb48bd2..64266042b60f 100644
--- a/editor/libeditor/base/DeleteRangeTxn.cpp
+++ b/editor/libeditor/base/DeleteRangeTxn.cpp
@@ -4,33 +4,21 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DeleteRangeTxn.h"
-#include "nsIDOMRange.h"
-#include "nsIDOMNodeList.h"
#include "DeleteTextTxn.h"
#include "DeleteElementTxn.h"
#include "nsIContentIterator.h"
-#include "nsIContent.h"
#include "nsComponentManagerUtils.h"
#include "mozilla/Util.h"
using namespace mozilla;
-#ifdef DEBUG
-static bool gNoisy = false;
-#endif
-
// note that aEditor is not refcounted
DeleteRangeTxn::DeleteRangeTxn()
-: EditAggregateTxn()
-,mRange()
-,mStartParent()
-,mStartOffset(0)
-,mEndParent()
-,mCommonParent()
-,mEndOffset(0)
-,mEditor(nsnull)
-,mRangeUpdater(nsnull)
+ : EditAggregateTxn(),
+ mRange(),
+ mEditor(nsnull),
+ mRangeUpdater(nsnull)
{
}
@@ -39,264 +27,203 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(DeleteRangeTxn)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DeleteRangeTxn,
EditAggregateTxn)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mRange)
- NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mStartParent)
- NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mEndParent)
- NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCommonParent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DeleteRangeTxn,
EditAggregateTxn)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mRange)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mStartParent)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mEndParent)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCommonParent)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mRange, nsIDOMRange)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DeleteRangeTxn)
NS_INTERFACE_MAP_END_INHERITING(EditAggregateTxn)
-NS_IMETHODIMP DeleteRangeTxn::Init(nsEditor *aEditor,
- nsIDOMRange *aRange,
- nsRangeUpdater *aRangeUpdater)
+nsresult
+DeleteRangeTxn::Init(nsEditor* aEditor,
+ nsRange* aRange,
+ nsRangeUpdater* aRangeUpdater)
{
- NS_ASSERTION(aEditor && aRange, "bad state");
- if (!aEditor || !aRange) { return NS_ERROR_NOT_INITIALIZED; }
+ MOZ_ASSERT(aEditor && aRange);
mEditor = aEditor;
- mRange = do_QueryInterface(aRange);
+ mRange = aRange->CloneRange();
mRangeUpdater = aRangeUpdater;
-
- DebugOnly result = aRange->GetStartContainer(getter_AddRefs(mStartParent));
- NS_ASSERTION((NS_SUCCEEDED(result)), "GetStartParent failed.");
- result = aRange->GetEndContainer(getter_AddRefs(mEndParent));
- NS_ASSERTION((NS_SUCCEEDED(result)), "GetEndParent failed.");
- result = aRange->GetStartOffset(&mStartOffset);
- NS_ASSERTION((NS_SUCCEEDED(result)), "GetStartOffset failed.");
- result = aRange->GetEndOffset(&mEndOffset);
- NS_ASSERTION((NS_SUCCEEDED(result)), "GetEndOffset failed.");
- result = aRange->GetCommonAncestorContainer(getter_AddRefs(mCommonParent));
- NS_ASSERTION((NS_SUCCEEDED(result)), "GetCommonParent failed.");
- if (!mEditor->IsModifiableNode(mStartParent)) {
- return NS_ERROR_FAILURE;
- }
-
- if (mStartParent!=mEndParent &&
- (!mEditor->IsModifiableNode(mEndParent) ||
- !mEditor->IsModifiableNode(mCommonParent)))
- {
- return NS_ERROR_FAILURE;
- }
-
-#ifdef DEBUG
- {
- nsCOMPtr start = do_QueryInterface(mStartParent);
- MOZ_ASSERT(start);
- NS_ASSERTION(mStartOffset <= PRInt32(start->Length()), "bad start offset");
-
- nsCOMPtr end = do_QueryInterface(mEndParent);
- MOZ_ASSERT(end);
- NS_ASSERTION(mEndOffset <= PRInt32(end->Length()), "bad end offset");
-
- if (gNoisy) {
- printf ("DeleteRange: %d of %p to %d of %p\n",
- mStartOffset, (void *)mStartParent, mEndOffset, (void *)mEndParent);
- }
- }
-#endif // DEBUG
+ NS_ENSURE_TRUE(mEditor->IsModifiableNode(mRange->GetStartParent()),
+ NS_ERROR_FAILURE);
+ NS_ENSURE_TRUE(mEditor->IsModifiableNode(mRange->GetEndParent()),
+ NS_ERROR_FAILURE);
+ NS_ENSURE_TRUE(mEditor->IsModifiableNode(mRange->GetCommonAncestor()),
+ NS_ERROR_FAILURE);
return NS_OK;
}
-NS_IMETHODIMP DeleteRangeTxn::DoTransaction(void)
+NS_IMETHODIMP
+DeleteRangeTxn::DoTransaction()
{
-#ifdef DEBUG
- if (gNoisy) { printf("Do Delete Range\n"); }
-#endif
+ MOZ_ASSERT(mRange && mEditor);
+ nsresult res;
- NS_ENSURE_TRUE(mStartParent && mEndParent && mCommonParent && mEditor, NS_ERROR_NOT_INITIALIZED);
-
- nsresult result;
// build the child transactions
+ nsCOMPtr startParent = mRange->GetStartParent();
+ PRInt32 startOffset = mRange->StartOffset();
+ nsCOMPtr endParent = mRange->GetEndParent();
+ PRInt32 endOffset = mRange->EndOffset();
+ MOZ_ASSERT(startParent && endParent);
- if (mStartParent==mEndParent)
- { // the selection begins and ends in the same node
- result = CreateTxnsToDeleteBetween(mStartParent, mStartOffset, mEndOffset);
- }
- else
- { // the selection ends in a different node from where it started
- // delete the relevant content in the start node
- result = CreateTxnsToDeleteContent(mStartParent, mStartOffset, nsIEditor::eNext);
- if (NS_SUCCEEDED(result))
- {
- // delete the intervening nodes
- result = CreateTxnsToDeleteNodesBetween();
- if (NS_SUCCEEDED(result))
- {
- // delete the relevant content in the end node
- result = CreateTxnsToDeleteContent(mEndParent, mEndOffset, nsIEditor::ePrevious);
- }
- }
+ if (startParent == endParent) {
+ // the selection begins and ends in the same node
+ res = CreateTxnsToDeleteBetween(startParent, startOffset, endOffset);
+ NS_ENSURE_SUCCESS(res, res);
+ } else {
+ // the selection ends in a different node from where it started. delete
+ // the relevant content in the start node
+ res = CreateTxnsToDeleteContent(startParent, startOffset, nsIEditor::eNext);
+ NS_ENSURE_SUCCESS(res, res);
+ // delete the intervening nodes
+ res = CreateTxnsToDeleteNodesBetween();
+ NS_ENSURE_SUCCESS(res, res);
+ // delete the relevant content in the end node
+ res = CreateTxnsToDeleteContent(endParent, endOffset, nsIEditor::ePrevious);
+ NS_ENSURE_SUCCESS(res, res);
}
// if we've successfully built this aggregate transaction, then do it.
- if (NS_SUCCEEDED(result)) {
- result = EditAggregateTxn::DoTransaction();
- }
+ res = EditAggregateTxn::DoTransaction();
+ NS_ENSURE_SUCCESS(res, res);
- NS_ENSURE_SUCCESS(result, result);
-
// only set selection to deletion point if editor gives permission
bool bAdjustSelection;
mEditor->ShouldTxnSetSelection(&bAdjustSelection);
- if (bAdjustSelection)
- {
- nsCOMPtr selection;
- result = mEditor->GetSelection(getter_AddRefs(selection));
- // At this point, it is possible that the frame for our root element
- // might have been destroyed, in which case, the above call returns
- // an error. We eat that error here intentionally. See bug 574558
- // for a sample case where this happens.
- NS_ENSURE_SUCCESS(result, NS_OK);
+ if (bAdjustSelection) {
+ nsRefPtr selection = mEditor->GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
- result = selection->Collapse(mStartParent, mStartOffset);
- }
- else
- {
- // do nothing - dom range gravity will adjust selection
+ res = selection->Collapse(startParent, startOffset);
+ NS_ENSURE_SUCCESS(res, res);
}
+ // else do nothing - dom range gravity will adjust selection
- return result;
+ return NS_OK;
}
-NS_IMETHODIMP DeleteRangeTxn::UndoTransaction(void)
+NS_IMETHODIMP
+DeleteRangeTxn::UndoTransaction()
{
-#ifdef DEBUG
- if (gNoisy) { printf("Undo Delete Range\n"); }
-#endif
-
- NS_ENSURE_TRUE(mStartParent && mEndParent && mCommonParent && mEditor, NS_ERROR_NOT_INITIALIZED);
+ MOZ_ASSERT(mRange && mEditor);
return EditAggregateTxn::UndoTransaction();
}
-NS_IMETHODIMP DeleteRangeTxn::RedoTransaction(void)
+NS_IMETHODIMP
+DeleteRangeTxn::RedoTransaction()
{
-#ifdef DEBUG
- if (gNoisy) { printf("Redo Delete Range\n"); }
-#endif
-
- NS_ENSURE_TRUE(mStartParent && mEndParent && mCommonParent && mEditor, NS_ERROR_NOT_INITIALIZED);
+ MOZ_ASSERT(mRange && mEditor);
return EditAggregateTxn::RedoTransaction();
}
-NS_IMETHODIMP DeleteRangeTxn::GetTxnDescription(nsAString& aString)
+NS_IMETHODIMP
+DeleteRangeTxn::GetTxnDescription(nsAString& aString)
{
aString.AssignLiteral("DeleteRangeTxn");
return NS_OK;
}
-NS_IMETHODIMP
-DeleteRangeTxn::CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent,
- PRUint32 aStartOffset,
- PRUint32 aEndOffset)
+nsresult
+DeleteRangeTxn::CreateTxnsToDeleteBetween(nsINode* aNode,
+ PRInt32 aStartOffset,
+ PRInt32 aEndOffset)
{
// see what kind of node we have
- nsCOMPtr textNode = do_QueryInterface(aStartParent);
- if (textNode) {
- // if the node is a text node, then delete text content
+ if (aNode->IsNodeOfType(nsINode::eDATA_NODE)) {
+ // if the node is a chardata node, then delete chardata content
nsRefPtr txn = new DeleteTextTxn();
PRInt32 numToDel;
- if (aStartOffset==aEndOffset)
+ if (aStartOffset == aEndOffset) {
numToDel = 1;
- else
- numToDel = aEndOffset-aStartOffset;
+ } else {
+ numToDel = aEndOffset - aStartOffset;
+ }
- nsresult rv = txn->Init(mEditor, textNode, aStartOffset, numToDel, mRangeUpdater);
- NS_ENSURE_SUCCESS(rv, rv);
+ nsCOMPtr charDataNode = do_QueryInterface(aNode);
+ nsresult res = txn->Init(mEditor, charDataNode, aStartOffset, numToDel,
+ mRangeUpdater);
+ NS_ENSURE_SUCCESS(res, res);
AppendChild(txn);
return NS_OK;
}
- nsCOMPtr startParent = do_QueryInterface(aStartParent);
- NS_ENSURE_STATE(startParent);
- NS_ASSERTION(aEndOffset <= startParent->GetChildCount(), "bad aEndOffset");
-
- nsCOMPtr child = startParent->GetChildAt(aStartOffset);
+ nsCOMPtr child = aNode->GetChildAt(aStartOffset);
NS_ENSURE_STATE(child);
- nsresult result = NS_OK;
- for (PRUint32 i = aStartOffset; i < aEndOffset; ++i) {
+ nsresult res = NS_OK;
+ for (PRInt32 i = aStartOffset; i < aEndOffset; ++i) {
nsRefPtr txn = new DeleteElementTxn();
- result = txn->Init(mEditor, child->AsDOMNode(), mRangeUpdater);
- if (NS_SUCCEEDED(result))
+ res = txn->Init(mEditor, child->AsDOMNode(), mRangeUpdater);
+ if (NS_SUCCEEDED(res)) {
AppendChild(txn);
+ }
child = child->GetNextSibling();
}
- return result;
+
+ NS_ENSURE_SUCCESS(res, res);
+ return NS_OK;
}
-NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteContent(nsIDOMNode *aParent,
- PRUint32 aOffset,
- nsIEditor::EDirection aAction)
+nsresult
+DeleteRangeTxn::CreateTxnsToDeleteContent(nsINode* aNode,
+ PRInt32 aOffset,
+ nsIEditor::EDirection aAction)
{
- nsresult result = NS_OK;
// see what kind of node we have
- nsCOMPtr textNode = do_QueryInterface(aParent);
- if (textNode)
- { // if the node is a text node, then delete text content
+ if (aNode->IsNodeOfType(nsINode::eDATA_NODE)) {
+ // if the node is a chardata node, then delete chardata content
PRUint32 start, numToDelete;
- if (nsIEditor::eNext == aAction)
- {
- start=aOffset;
- textNode->GetLength(&numToDelete);
- numToDelete -= aOffset;
+ if (nsIEditor::eNext == aAction) {
+ start = aOffset;
+ numToDelete = aNode->Length() - aOffset;
+ } else {
+ start = 0;
+ numToDelete = aOffset;
}
- else
- {
- start=0;
- numToDelete=aOffset;
- }
-
- if (numToDelete)
- {
- nsRefPtr txn = new DeleteTextTxn();
- NS_ENSURE_TRUE(txn, NS_ERROR_OUT_OF_MEMORY);
- result = txn->Init(mEditor, textNode, start, numToDelete, mRangeUpdater);
- if (NS_SUCCEEDED(result))
- AppendChild(txn);
+ if (numToDelete) {
+ nsRefPtr txn = new DeleteTextTxn();
+
+ nsCOMPtr charDataNode = do_QueryInterface(aNode);
+ nsresult res = txn->Init(mEditor, charDataNode, start, numToDelete,
+ mRangeUpdater);
+ NS_ENSURE_SUCCESS(res, res);
+
+ AppendChild(txn);
}
}
- return result;
+ return NS_OK;
}
-NS_IMETHODIMP DeleteRangeTxn::CreateTxnsToDeleteNodesBetween()
+nsresult
+DeleteRangeTxn::CreateTxnsToDeleteNodesBetween()
{
- nsCOMPtr iter = do_CreateInstance("@mozilla.org/content/subtree-content-iterator;1");
- NS_ENSURE_TRUE(iter, NS_ERROR_NULL_POINTER);
+ nsCOMPtr iter = NS_NewContentSubtreeIterator();
- nsresult result = iter->Init(mRange);
- NS_ENSURE_SUCCESS(result, result);
+ nsresult res = iter->Init(mRange);
+ NS_ENSURE_SUCCESS(res, res);
- while (!iter->IsDone() && NS_SUCCEEDED(result))
- {
- nsCOMPtr node = do_QueryInterface(iter->GetCurrentNode());
+ while (!iter->IsDone()) {
+ nsCOMPtr node = iter->GetCurrentNode();
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
nsRefPtr txn = new DeleteElementTxn();
- NS_ENSURE_TRUE(txn, NS_ERROR_OUT_OF_MEMORY);
- result = txn->Init(mEditor, node, mRangeUpdater);
- if (NS_SUCCEEDED(result))
- AppendChild(txn);
+ res = txn->Init(mEditor, node->AsDOMNode(), mRangeUpdater);
+ NS_ENSURE_SUCCESS(res, res);
+ AppendChild(txn);
+
iter->Next();
}
- return result;
+ return NS_OK;
}
-
diff --git a/editor/libeditor/base/DeleteRangeTxn.h b/editor/libeditor/base/DeleteRangeTxn.h
index d47ddf2c3342..67dda71f81bf 100644
--- a/editor/libeditor/base/DeleteRangeTxn.h
+++ b/editor/libeditor/base/DeleteRangeTxn.h
@@ -7,12 +7,10 @@
#define DeleteRangeTxn_h__
#include "EditAggregateTxn.h"
-#include "nsIDOMNode.h"
-#include "nsIDOMRange.h"
+#include "nsRange.h"
#include "nsEditor.h"
#include "nsCOMPtr.h"
-class nsIDOMRange;
class nsRangeUpdater;
/**
@@ -25,9 +23,9 @@ public:
* @param aEditor the object providing basic editing operations
* @param aRange the range to delete
*/
- NS_IMETHOD Init(nsEditor *aEditor,
- nsIDOMRange *aRange,
- nsRangeUpdater *aRangeUpdater);
+ nsresult Init(nsEditor* aEditor,
+ nsRange* aRange,
+ nsRangeUpdater* aRangeUpdater);
DeleteRangeTxn();
@@ -40,41 +38,26 @@ public:
protected:
- NS_IMETHOD CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent,
- PRUint32 aStartOffset,
- PRUint32 aEndOffset);
+ nsresult CreateTxnsToDeleteBetween(nsINode* aNode,
+ PRInt32 aStartOffset,
+ PRInt32 aEndOffset);
- NS_IMETHOD CreateTxnsToDeleteNodesBetween();
+ nsresult CreateTxnsToDeleteNodesBetween();
+
+ nsresult CreateTxnsToDeleteContent(nsINode* aParent,
+ PRInt32 aOffset,
+ nsIEditor::EDirection aAction);
- NS_IMETHOD CreateTxnsToDeleteContent(nsIDOMNode *aParent,
- PRUint32 aOffset,
- nsIEditor::EDirection aAction);
-
protected:
-
- /** p1 in the range */
- nsCOMPtr mRange; // is this really an owning ptr?
/** p1 in the range */
- nsCOMPtr mStartParent;
-
- /** p1 offset */
- PRInt32 mStartOffset;
-
- /** p2 in the range */
- nsCOMPtr mEndParent;
-
- /** the closest common parent of p1 and p2 */
- nsCOMPtr mCommonParent;
-
- /** p2 offset */
- PRInt32 mEndOffset;
+ nsRefPtr mRange;
/** the editor for this transaction */
nsEditor* mEditor;
/** range updater object */
- nsRangeUpdater *mRangeUpdater;
+ nsRangeUpdater* mRangeUpdater;
};
#endif
diff --git a/editor/libeditor/base/crashtests/766845.xhtml b/editor/libeditor/base/crashtests/766845.xhtml
new file mode 100644
index 000000000000..409e210109b8
--- /dev/null
+++ b/editor/libeditor/base/crashtests/766845.xhtml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
diff --git a/editor/libeditor/base/crashtests/crashtests.list b/editor/libeditor/base/crashtests/crashtests.list
index fee7b0210baf..649278a9946a 100644
--- a/editor/libeditor/base/crashtests/crashtests.list
+++ b/editor/libeditor/base/crashtests/crashtests.list
@@ -13,3 +13,4 @@ load 713427-2.xhtml
load 762183.html
load 766360.html
load 766413.html
+load 766845.xhtml
diff --git a/editor/libeditor/html/nsHTMLDataTransfer.cpp b/editor/libeditor/html/nsHTMLDataTransfer.cpp
index 2243b4f0021d..7b89bbdddb75 100644
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -93,6 +93,7 @@
#include "nsContentUtils.h"
#include "mozilla/Preferences.h"
#include "nsIParserUtils.h"
+#include "nsILoadContext.h"
using namespace mozilla;
@@ -985,6 +986,10 @@ NS_IMETHODIMP nsHTMLEditor::PrepareHTMLTransferable(nsITransferable **aTransfera
// Get the nsITransferable interface for getting the data from the clipboard
if (aTransferable)
{
+ nsCOMPtr destdoc = GetDocument();
+ nsILoadContext* loadContext = destdoc ? destdoc->GetLoadContext() : nsnull;
+ (*aTransferable)->Init(loadContext);
+
// Create the desired DataFlavor for the type of data
// we want to get out of the transferable
// This should only happen in html editors, not plaintext
@@ -1535,6 +1540,7 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
nsCOMPtr contextTrans =
do_CreateInstance("@mozilla.org/widget/transferable;1");
NS_ENSURE_TRUE(contextTrans, NS_ERROR_NULL_POINTER);
+ contextTrans->Init(nsnull);
contextTrans->AddDataFlavor(kHTMLContext);
clipboard->GetData(contextTrans, aSelectionType);
contextTrans->GetTransferData(kHTMLContext, getter_AddRefs(contextDataObj), &contextLen);
@@ -1542,6 +1548,7 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
nsCOMPtr infoTrans =
do_CreateInstance("@mozilla.org/widget/transferable;1");
NS_ENSURE_TRUE(infoTrans, NS_ERROR_NULL_POINTER);
+ infoTrans->Init(nsnull);
infoTrans->AddDataFlavor(kHTMLInfo);
clipboard->GetData(infoTrans, aSelectionType);
infoTrans->GetTransferData(kHTMLInfo, getter_AddRefs(infoDataObj), &infoLen);
@@ -1775,6 +1782,10 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlaintextQuotation(PRInt32 aSelectionType)
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(trans, NS_ERROR_FAILURE);
+ nsCOMPtr destdoc = GetDocument();
+ nsILoadContext* loadContext = destdoc ? destdoc->GetLoadContext() : nsnull;
+ trans->Init(loadContext);
+
// We only handle plaintext pastes here
trans->AddDataFlavor(kUnicodeMime);
diff --git a/editor/libeditor/html/tests/test_CF_HTML_clipboard.html b/editor/libeditor/html/tests/test_CF_HTML_clipboard.html
index 02a84bfa8fa7..3bfb217cc7c0 100644
--- a/editor/libeditor/html/tests/test_CF_HTML_clipboard.html
+++ b/editor/libeditor/html/tests/test_CF_HTML_clipboard.html
@@ -27,6 +27,12 @@ function copyCF_HTML(cfhtml, success, failure) {
const Ci = Components.interfaces;
const CF_HTML = "application/x-moz-nativehtml";
+ function getLoadContext() {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsILoadContext);
+ }
+
var cb = Cc["@mozilla.org/widget/clipboard;1"].
getService(Ci.nsIClipboard);
@@ -47,6 +53,7 @@ function copyCF_HTML(cfhtml, success, failure) {
var trans = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
+ trans.init(getLoadContext());
trans.addDataFlavor(CF_HTML);
cb.getData(trans, cb.kGlobalClipboard);
var data = {};
@@ -62,6 +69,7 @@ function copyCF_HTML(cfhtml, success, failure) {
var trans = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
+ trans.init(getLoadContext());
trans.addDataFlavor(CF_HTML);
var data = Cc["@mozilla.org/supports-cstring;1"].
createInstance(Ci.nsISupportsCString);
diff --git a/editor/libeditor/html/tests/test_bug489202.xul b/editor/libeditor/html/tests/test_bug489202.xul
index 01395753688e..5cedbb9f9517 100644
--- a/editor/libeditor/html/tests/test_bug489202.xul
+++ b/editor/libeditor/html/tests/test_bug489202.xul
@@ -33,11 +33,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=489202
var Cc = Components.classes;
var Ci = Components.interfaces;
+function getLoadContext() {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsILoadContext);
+}
+
function runTest() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var trans = Cc["@mozilla.org/widget/transferable;1"]
.createInstance(Ci.nsITransferable);
+ trans.init(getLoadContext());
trans.addDataFlavor("text/html");
var test_data = 'mozilla.org';
var cstr = Cc["@mozilla.org/supports-string;1"]
diff --git a/editor/libeditor/html/tests/test_bug520189.html b/editor/libeditor/html/tests/test_bug520189.html
index 1491260b68f4..36a014e2f0d7 100644
--- a/editor/libeditor/html/tests/test_bug520189.html
+++ b/editor/libeditor/html/tests/test_bug520189.html
@@ -548,6 +548,13 @@ function doNextTest() {
doNextTest();
}
+function getLoadContext() {
+ const Ci = Components.interfaces;
+ return window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsILoadContext);
+}
+
function runTest(test) {
var elem = document.getElementById(test.id);
if ("isIFrame" in test) {
@@ -560,6 +567,7 @@ function runTest(test) {
var trans = Components.classes["@mozilla.org/widget/transferable;1"]
.createInstance(Components.interfaces.nsITransferable);
+ trans.init(getLoadContext());
var data = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
data.data = test.payload;
diff --git a/editor/libeditor/html/tests/test_bug525389.html b/editor/libeditor/html/tests/test_bug525389.html
index 416eec529fe2..5c8b3940e27b 100644
--- a/editor/libeditor/html/tests/test_bug525389.html
+++ b/editor/libeditor/html/tests/test_bug525389.html
@@ -12,6 +12,12 @@
var Cc = Components.classes;
var Ci = Components.interfaces;
+function getLoadContext() {
+ return window.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebNavigation)
+ .QueryInterface(Ci.nsILoadContext);
+}
+
function runTest() {
var pasteCount = 0;
var pasteFunc = function (event) { pasteCount++; };
@@ -49,6 +55,7 @@ function runTest() {
function getTransferableFromClipboard(asHTML) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
+ trans.init(getLoadContext());
if (asHTML) {
trans.addDataFlavor("text/html");
} else {
@@ -88,6 +95,7 @@ function runTest() {
// Create the transferable.
var trans = Cc["@mozilla.org/widget/transferable;1"].createInstance(Ci.nsITransferable);
+ trans.init(getLoadContext());
// Add the data to the transferable.
if (asHTML) {
diff --git a/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/editor/libeditor/text/nsPlaintextDataTransfer.cpp
index 4ac126b0b165..9b6bce8117c6 100644
--- a/editor/libeditor/text/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/text/nsPlaintextDataTransfer.cpp
@@ -30,7 +30,6 @@
#include "nsIDragService.h"
#include "nsIDOMUIEvent.h"
#include "nsCopySupport.h"
-#include "nsITransferable.h"
// Misc
#include "nsEditorUtils.h"
@@ -50,6 +49,10 @@ NS_IMETHODIMP nsPlaintextEditor::PrepareTransferable(nsITransferable **transfera
// Get the nsITransferable interface for getting the data from the clipboard
if (transferable) {
+ nsCOMPtr destdoc = GetDocument();
+ nsILoadContext* loadContext = destdoc ? destdoc->GetLoadContext() : nsnull;
+ (*transferable)->Init(loadContext);
+
(*transferable)->AddDataFlavor(kUnicodeMime);
(*transferable)->AddDataFlavor(kMozTextInternal);
};
diff --git a/editor/libeditor/text/tests/test_bug596333.html b/editor/libeditor/text/tests/test_bug596333.html
index c0b6a5ee9fc3..bdc4307e5053 100644
--- a/editor/libeditor/text/tests/test_bug596333.html
+++ b/editor/libeditor/text/tests/test_bug596333.html
@@ -19,6 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=596333
+
+
+
+
+
+