diff --git a/browser/metro/base/tests/mochitest/browser_selection_basic.js b/browser/metro/base/tests/mochitest/browser_selection_basic.js
index f1c510a2cbf5..bd81b820ad51 100644
--- a/browser/metro/base/tests/mochitest/browser_selection_basic.js
+++ b/browser/metro/base/tests/mochitest/browser_selection_basic.js
@@ -25,7 +25,6 @@ function setUpAndTearDown() {
yield waitForCondition(function () {
return !SelectionHelperUI.isSelectionUIVisible;
}, kCommonWaitMs, kCommonPollMs);
- yield hideContextUI();
}
gTests.push({
@@ -40,6 +39,8 @@ gTests.push({
return !StartUI.isStartPageVisible;
}, 10000, 100);
+ yield hideContextUI();
+
gWindow = Browser.selectedTab.browser.contentWindow;
InputSourceHelper.isPrecise = false;
},
diff --git a/browser/metro/base/tests/mochitest/browser_selection_frame_content.html b/browser/metro/base/tests/mochitest/browser_selection_frame_content.html
index 636d8350f021..9484ff5e1585 100644
--- a/browser/metro/base/tests/mochitest/browser_selection_frame_content.html
+++ b/browser/metro/base/tests/mochitest/browser_selection_frame_content.html
@@ -4,7 +4,7 @@
-
+
Hello there.
Hi!
diff --git a/browser/metro/base/tests/mochitest/browser_selection_frame_content.js b/browser/metro/base/tests/mochitest/browser_selection_frame_content.js
index 52351ed71dbb..bcba64c11874 100644
--- a/browser/metro/base/tests/mochitest/browser_selection_frame_content.js
+++ b/browser/metro/base/tests/mochitest/browser_selection_frame_content.js
@@ -25,7 +25,6 @@ function setUpAndTearDown() {
yield waitForCondition(function () {
return !SelectionHelperUI.isSelectionUIVisible;
}, kCommonWaitMs, kCommonPollMs);
- yield hideContextUI();
}
gTests.push({
@@ -40,6 +39,8 @@ gTests.push({
return !StartUI.isStartPageVisible;
}, 10000, 100);
+ yield hideContextUI();
+
gWindow = Browser.selectedTab.browser.contentWindow;
gFrame = gWindow.document.getElementById("frame1");
@@ -212,11 +213,6 @@ gTests.push({
});
function test() {
- if (isDebugBuild()) {
- todo(false, "selection tests can't run in debug builds.");
- return;
- }
-
if (!isLandscapeMode()) {
todo(false, "browser_selection_tests need landscape mode to run.");
return;
diff --git a/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.html b/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.html
new file mode 100644
index 000000000000..1c0ad15496c9
--- /dev/null
+++ b/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.html
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.js b/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.js
new file mode 100644
index 000000000000..3f8ca464add2
--- /dev/null
+++ b/browser/metro/base/tests/mochitest/browser_selection_frame_inputs.js
@@ -0,0 +1,162 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+let gWindow = null;
+var gFrame = null;
+var gInput = null;
+
+const kMarkerOffsetY = 12;
+const kCommonWaitMs = 5000;
+const kCommonPollMs = 100;
+
+///////////////////////////////////////////////////
+// form input tests
+///////////////////////////////////////////////////
+
+function setUpAndTearDown() {
+ emptyClipboard();
+ if (gWindow)
+ clearSelection(gWindow);
+ if (gFrame)
+ clearSelection(gFrame);
+ if (gInput)
+ clearSelection(gInput);
+ yield waitForCondition(function () {
+ return !SelectionHelperUI.isSelectionUIVisible;
+ }, kCommonWaitMs, kCommonPollMs);
+}
+
+gTests.push({
+ desc: "normalize browser",
+ setUp: setUpAndTearDown,
+ tearDown: setUpAndTearDown,
+ run: function test() {
+ info(chromeRoot + "browser_selection_frame_inputs.html");
+ yield addTab(chromeRoot + "browser_selection_frame_inputs.html");
+
+ yield waitForCondition(function () {
+ return !StartUI.isStartPageVisible;
+ }, 10000, 100);
+
+ yield hideContextUI();
+
+ gWindow = Browser.selectedTab.browser.contentWindow;
+ gFrame = gWindow.document.getElementById("frame1");
+ gInput = gFrame.contentDocument.getElementById("textinput");
+
+ ok(gWindow != null, "gWindow");
+ ok(gFrame != null, "gFrame");
+ ok(gInput != null, "gInput");
+
+ InputSourceHelper.isPrecise = false;
+ },
+});
+
+gTests.push({
+ desc: "basic selection",
+ setUp: setUpAndTearDown,
+ tearDown: setUpAndTearDown,
+ run: function test() {
+ gInput.focus();
+ gInput.selectionStart = gInput.selectionEnd = 0;
+
+ let promise = waitForEvent(document, "popupshown");
+ sendContextMenuClick(232, 583);
+ yield promise;
+
+ checkContextUIMenuItemVisibility(["context-select",
+ "context-select-all"]);
+
+ let menuItem = document.getElementById("context-select");
+ ok(menuItem, "menu item exists");
+ ok(!menuItem.hidden, "menu item visible");
+ let popupPromise = waitForEvent(document, "popuphidden");
+ EventUtils.synthesizeMouse(menuItem, 10, 10, {}, gWindow);
+ yield popupPromise;
+
+ yield waitForCondition(function () {
+ return SelectionHelperUI.isSelectionUIVisible;
+ }, kCommonWaitMs, kCommonPollMs);
+
+ is(getTrimmedSelection(gInput).toString(), "straight", "selection test");
+
+ checkMonoclePositionRange("start", 210, 220, 600, 605);
+ checkMonoclePositionRange("end", 250, 260, 600, 605);
+ },
+});
+
+gTests.push({
+ desc: "drag selection",
+ setUp: setUpAndTearDown,
+ tearDown: setUpAndTearDown,
+ run: function test() {
+ gInput.focus();
+ gInput.selectionStart = gInput.selectionEnd = 0;
+
+ let promise = waitForEvent(document, "popupshown");
+ sendContextMenuClick(232, 583);
+ yield promise;
+
+ checkContextUIMenuItemVisibility(["context-select",
+ "context-select-all"]);
+
+ let menuItem = document.getElementById("context-select");
+ ok(menuItem, "menu item exists");
+ ok(!menuItem.hidden, "menu item visible");
+ let popupPromise = waitForEvent(document, "popuphidden");
+ EventUtils.synthesizeMouse(menuItem, 10, 10, {}, gWindow);
+ yield popupPromise;
+
+ yield waitForCondition(function () {
+ return SelectionHelperUI.isSelectionUIVisible;
+ }, kCommonWaitMs, kCommonPollMs);
+
+ is(getTrimmedSelection(gInput).toString(), "straight", "selection test");
+
+ // end marker to the right
+ let xpos = SelectionHelperUI.endMark.xPos;
+ let ypos = SelectionHelperUI.endMark.yPos + 10;
+ var touchdrag = new TouchDragAndHold();
+ yield touchdrag.start(gWindow, xpos, ypos, xpos + 350, ypos);
+ yield waitForCondition(function () {
+ return getTrimmedSelection(gInput).toString() ==
+ "straight on like a tunnel for some way and then dipped suddenly down";
+ }, 6000, 2000);
+ touchdrag.end();
+
+ yield waitForCondition(function () {
+ return !SelectionHelperUI.hasActiveDrag;
+ }, kCommonWaitMs, kCommonPollMs);
+ yield SelectionHelperUI.pingSelectionHandler();
+
+ // start marker to the left
+ let xpos = SelectionHelperUI.startMark.xPos;
+ let ypos = SelectionHelperUI.startMark.yPos + 10;
+ var touchdrag = new TouchDragAndHold();
+ yield touchdrag.start(gWindow, xpos, ypos, 10, ypos);
+ yield waitForCondition(function () {
+ return getTrimmedSelection(gInput).toString() ==
+ "The rabbit-hole went straight on like a tunnel for some way and then dipped suddenly down";
+ }, 6000, 2000);
+ touchdrag.end();
+
+ yield waitForCondition(function () {
+ return !SelectionHelperUI.hasActiveDrag;
+ }, kCommonWaitMs, kCommonPollMs);
+ yield SelectionHelperUI.pingSelectionHandler();
+ },
+});
+
+function test() {
+ if (!isLandscapeMode()) {
+ todo(false, "browser_selection_tests need landscape mode to run.");
+ return;
+ }
+
+ requestLongerTimeout(3);
+ runTests();
+}
diff --git a/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.html b/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.html
new file mode 100644
index 000000000000..27e37b0e9ac3
--- /dev/null
+++ b/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.html
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.js b/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.js
new file mode 100644
index 000000000000..b94dac8f5e7f
--- /dev/null
+++ b/browser/metro/base/tests/mochitest/browser_selection_frame_textarea.js
@@ -0,0 +1,257 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+let gWindow = null;
+var gFrame = null;
+var gTextArea = null;
+
+const kMarkerOffsetY = 12;
+const kCommonWaitMs = 5000;
+const kCommonPollMs = 100;
+
+///////////////////////////////////////////////////
+// form input tests
+///////////////////////////////////////////////////
+
+function setUpAndTearDown() {
+ emptyClipboard();
+ if (gWindow)
+ clearSelection(gWindow);
+ if (gFrame)
+ clearSelection(gFrame);
+ if (gTextArea)
+ clearSelection(gTextArea);
+ yield waitForCondition(function () {
+ return !SelectionHelperUI.isSelectionUIVisible;
+ }, kCommonWaitMs, kCommonPollMs);
+}
+
+gTests.push({
+ desc: "normalize browser",
+ setUp: setUpAndTearDown,
+ tearDown: setUpAndTearDown,
+ run: function test() {
+ info(chromeRoot + "browser_selection_frame_textarea.html");
+ yield addTab(chromeRoot + "browser_selection_frame_textarea.html");
+
+ yield waitForCondition(function () {
+ return !StartUI.isStartPageVisible;
+ }, 10000, 100);
+
+ yield hideContextUI();
+
+ gWindow = Browser.selectedTab.browser.contentWindow;
+ gFrame = gWindow.document.getElementById("frame1");
+ gTextArea = gFrame.contentDocument.getElementById("textarea");
+ ok(gWindow != null, "gWindow");
+ ok(gFrame != null, "gFrame");
+ ok(gTextArea != null, "gTextArea");
+
+ InputSourceHelper.isPrecise = false;
+ },
+});
+
+gTests.push({
+ desc: "basic selection",
+ setUp: setUpAndTearDown,
+ tearDown: setUpAndTearDown,
+ run: function test() {
+ gTextArea.focus();
+ gTextArea.selectionStart = gTextArea.selectionEnd = 0;
+
+ let promise = waitForEvent(document, "popupshown");
+ sendContextMenuClick(275, 663);
+ yield promise;
+
+ checkContextUIMenuItemVisibility(["context-select",
+ "context-select-all"]);
+
+ let menuItem = document.getElementById("context-select");
+ ok(menuItem, "menu item exists");
+ ok(!menuItem.hidden, "menu item visible");
+ let popupPromise = waitForEvent(document, "popuphidden");
+ EventUtils.synthesizeMouse(menuItem, 10, 10, {}, gWindow);
+ yield popupPromise;
+
+ yield waitForCondition(function () {
+ return SelectionHelperUI.isSelectionUIVisible;
+ }, kCommonWaitMs, kCommonPollMs);
+
+ is(getTrimmedSelection(gTextArea).toString(), "wondered", "selection test");
+
+ checkMonoclePositionRange("start", 260, 275, 675, 685);
+ checkMonoclePositionRange("end", 320, 335, 675, 685);
+ },
+});
+
+gTests.push({
+ desc: "drag selection",
+ setUp: setUpAndTearDown,
+ tearDown: setUpAndTearDown,
+ run: function test() {
+ gTextArea.focus();
+ gTextArea.selectionStart = gTextArea.selectionEnd = 0;
+
+ let promise = waitForEvent(document, "popupshown");
+ sendContextMenuClick(275, 663);
+ yield promise;
+
+ checkContextUIMenuItemVisibility(["context-select",
+ "context-select-all"]);
+
+ let menuItem = document.getElementById("context-select");
+ ok(menuItem, "menu item exists");
+ ok(!menuItem.hidden, "menu item visible");
+ let popupPromise = waitForEvent(document, "popuphidden");
+ EventUtils.synthesizeMouse(menuItem, 10, 10, {}, gWindow);
+ yield popupPromise;
+
+ yield waitForCondition(function () {
+ return SelectionHelperUI.isSelectionUIVisible;
+ }, kCommonWaitMs, kCommonPollMs);
+
+ is(getTrimmedSelection(gTextArea).toString(), "wondered", "selection test");
+
+ // end marker to the right
+ let xpos = SelectionHelperUI.endMark.xPos;
+ let ypos = SelectionHelperUI.endMark.yPos + 10;
+ var touchdrag = new TouchDragAndHold();
+ yield touchdrag.start(gWindow, xpos, ypos, xpos + 150, ypos);
+ yield waitForCondition(function () {
+ return getTrimmedSelection(gTextArea).toString() ==
+ "wondered at this,";
+ }, 6000, 2000);
+ touchdrag.end();
+
+ yield waitForCondition(function () {
+ return !SelectionHelperUI.hasActiveDrag;
+ }, kCommonWaitMs, kCommonPollMs);
+ yield SelectionHelperUI.pingSelectionHandler();
+
+ // start marker up and to the left
+ let xpos = SelectionHelperUI.startMark.xPos;
+ let ypos = SelectionHelperUI.startMark.yPos + 10;
+ var touchdrag = new TouchDragAndHold();
+ yield touchdrag.start(gWindow, xpos, ypos, 40, 500);
+ yield waitForCondition(function () {
+ return getTrimmedSelection(gTextArea).toString().substring(0, 17) ==
+ "There was nothing";
+ }, 6000, 2000);
+ touchdrag.end();
+
+ let promise = waitForEvent(document, "popupshown");
+ sendContextMenuClick(250, 640);
+ yield promise;
+
+ checkContextUIMenuItemVisibility(["context-cut",
+ "context-copy"]);
+
+ let menuItem = document.getElementById("context-copy");
+ ok(menuItem, "menu item exists");
+ ok(!menuItem.hidden, "menu item visible");
+ let popupPromise = waitForEvent(document, "popuphidden");
+ EventUtils.synthesizeMouse(menuItem, 10, 10, {}, gWindow);
+ yield popupPromise;
+
+ let string = "";
+ yield waitForCondition(function () {
+ string = SpecialPowers.getClipboardData("text/unicode");
+ return string.substring(0, 17) === "There was nothing";
+ });
+ },
+});
+
+gTests.push({
+ desc: "drag selection",
+ setUp: setUpAndTearDown,
+ tearDown: setUpAndTearDown,
+ run: function test() {
+ gTextArea.focus();
+ gTextArea.selectionStart = gTextArea.selectionEnd = 0;
+
+ let scrollPromise = waitForEvent(gWindow, "scroll");
+ gWindow.scrollBy(0, 200);
+ yield scrollPromise;
+
+ let promise = waitForEvent(document, "popupshown");
+ sendContextMenuClick(275, 463);
+ yield promise;
+
+ checkContextUIMenuItemVisibility(["context-select",
+ "context-select-all"]);
+
+ let menuItem = document.getElementById("context-select");
+ ok(menuItem, "menu item exists");
+ ok(!menuItem.hidden, "menu item visible");
+ let popupPromise = waitForEvent(document, "popuphidden");
+ EventUtils.synthesizeMouse(menuItem, 10, 10, {}, gWindow);
+ yield popupPromise;
+
+ yield waitForCondition(function () {
+ return SelectionHelperUI.isSelectionUIVisible;
+ }, kCommonWaitMs, kCommonPollMs);
+
+ is(getTrimmedSelection(gTextArea).toString(), "wondered", "selection test");
+
+ // end marker to the right
+ let xpos = SelectionHelperUI.endMark.xPos;
+ let ypos = SelectionHelperUI.endMark.yPos + 10;
+ var touchdrag = new TouchDragAndHold();
+ yield touchdrag.start(gWindow, xpos, ypos, xpos + 150, ypos);
+ yield waitForCondition(function () {
+ return getTrimmedSelection(gTextArea).toString() ==
+ "wondered at this,";
+ }, 6000, 2000);
+ touchdrag.end();
+
+ yield waitForCondition(function () {
+ return !SelectionHelperUI.hasActiveDrag;
+ }, kCommonWaitMs, kCommonPollMs);
+ yield SelectionHelperUI.pingSelectionHandler();
+
+ // start marker up and to the left
+ let xpos = SelectionHelperUI.startMark.xPos;
+ let ypos = SelectionHelperUI.startMark.yPos + 10;
+ var touchdrag = new TouchDragAndHold();
+ yield touchdrag.start(gWindow, xpos, ypos, 40, 300);
+ yield waitForCondition(function () {
+ return getTrimmedSelection(gTextArea).toString().substring(0, 17) ==
+ "There was nothing";
+ }, 6000, 2000);
+ touchdrag.end();
+
+ let promise = waitForEvent(document, "popupshown");
+ sendContextMenuClick(250, 440);
+ yield promise;
+
+ checkContextUIMenuItemVisibility(["context-cut",
+ "context-copy"]);
+
+ let menuItem = document.getElementById("context-copy");
+ ok(menuItem, "menu item exists");
+ ok(!menuItem.hidden, "menu item visible");
+ let popupPromise = waitForEvent(document, "popuphidden");
+ EventUtils.synthesizeMouse(menuItem, 10, 10, {}, gWindow);
+ yield popupPromise;
+
+ let string = "";
+ yield waitForCondition(function () {
+ string = SpecialPowers.getClipboardData("text/unicode");
+ return string.substring(0, 17) === "There was nothing";
+ });
+ },
+});
+
+function test() {
+ if (!isLandscapeMode()) {
+ todo(false, "browser_selection_tests need landscape mode to run.");
+ return;
+ }
+
+ requestLongerTimeout(3);
+ runTests();
+}
diff --git a/browser/metro/base/tests/mochitest/browser_selection_inputs.html b/browser/metro/base/tests/mochitest/browser_selection_inputs.html
new file mode 100644
index 000000000000..d182a291990f
--- /dev/null
+++ b/browser/metro/base/tests/mochitest/browser_selection_inputs.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/browser/metro/base/tests/mochitest/browser_selection_inputs.js b/browser/metro/base/tests/mochitest/browser_selection_inputs.js
new file mode 100644
index 000000000000..8fb4b297fceb
--- /dev/null
+++ b/browser/metro/base/tests/mochitest/browser_selection_inputs.js
@@ -0,0 +1,205 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+let gWindow = null;
+var gInput = null;
+
+const kMarkerOffsetY = 12;
+const kCommonWaitMs = 5000;
+const kCommonPollMs = 100;
+
+///////////////////////////////////////////////////
+// form input tests
+///////////////////////////////////////////////////
+
+function setUpAndTearDown() {
+ emptyClipboard();
+ if (gWindow)
+ clearSelection(gWindow);
+ if (gInput)
+ clearSelection(gInput);
+ yield waitForCondition(function () {
+ return !SelectionHelperUI.isSelectionUIVisible;
+ }, kCommonWaitMs, kCommonPollMs);
+}
+
+/*
+ 5px top margin
+ 25px tall text input
+ 300px wide
+*/
+
+gTests.push({
+ desc: "normalize browser",
+ setUp: setUpAndTearDown,
+ tearDown: setUpAndTearDown,
+ run: function test() {
+ info(chromeRoot + "browser_selection_inputs.html");
+ yield addTab(chromeRoot + "browser_selection_inputs.html");
+
+ yield waitForCondition(function () {
+ return !StartUI.isStartPageVisible;
+ }, 10000, 100);
+
+ yield hideContextUI();
+
+ gWindow = Browser.selectedTab.browser.contentWindow;
+ gInput = gWindow.document.getElementById("a");
+ InputSourceHelper.isPrecise = false;
+ },
+});
+
+gTests.push({
+ desc: "basic text input selection",
+ setUp: setUpAndTearDown,
+ tearDown: setUpAndTearDown,
+ run: function test() {
+ gInput.focus();
+ gInput.selectionStart = gInput.selectionEnd = 0;
+
+ let promise = waitForEvent(document, "popupshown");
+ sendContextMenuClick(200, 17);
+ yield promise;
+
+ checkContextUIMenuItemVisibility(["context-select",
+ "context-select-all"]);
+
+ let menuItem = document.getElementById("context-select");
+ ok(menuItem, "menu item exists");
+ ok(!menuItem.hidden, "menu item visible");
+ let popupPromise = waitForEvent(document, "popuphidden");
+ EventUtils.synthesizeMouse(menuItem, 10, 10, {}, gWindow);
+ yield popupPromise;
+
+ yield waitForCondition(function () {
+ return SelectionHelperUI.isSelectionUIVisible;
+ }, kCommonWaitMs, kCommonPollMs);
+
+ is(getTrimmedSelection(gInput).toString(), "went", "selection test");
+ },
+});
+
+gTests.push({
+ desc: "drag left to scroll",
+ setUp: setUpAndTearDown,
+ tearDown: setUpAndTearDown,
+ run: function test() {
+ gInput.selectionStart = gInput.selectionEnd = gInput.value.length;
+
+ let promise = waitForEvent(document, "popupshown");
+ sendContextMenuClick(190, 17);
+ yield promise;
+
+ checkContextUIMenuItemVisibility(["context-select",
+ "context-select-all"]);
+
+ let menuItem = document.getElementById("context-select");
+ ok(menuItem, "menu item exists");
+ ok(!menuItem.hidden, "menu item visible");
+ let popupPromise = waitForEvent(document, "popuphidden");
+ EventUtils.synthesizeMouse(menuItem, 10, 10, {}, gWindow);
+ yield popupPromise;
+
+ yield waitForCondition(function () {
+ return SelectionHelperUI.isSelectionUIVisible;
+ }, kCommonWaitMs, kCommonPollMs);
+
+ // check text selection
+ is(getTrimmedSelection(gInput).toString(), "way", "selection test");
+
+ // to the left
+ let xpos = SelectionHelperUI.startMark.xPos;
+ let ypos = SelectionHelperUI.startMark.yPos + 10;
+ var touchdrag = new TouchDragAndHold();
+ yield touchdrag.start(gWindow, xpos, ypos, 10, ypos);
+ yield waitForCondition(function () {
+ return getTrimmedSelection(gInput).toString() ==
+ "The rabbit-hole went straight on like a tunnel for some way";
+ }, 6000, 2000);
+ touchdrag.end();
+
+ yield waitForCondition(function () {
+ return !SelectionHelperUI.hasActiveDrag;
+ }, kCommonWaitMs, kCommonPollMs);
+ yield SelectionHelperUI.pingSelectionHandler();
+ },
+});
+
+gTests.push({
+ desc: "drag right to scroll and bug 862025",
+ setUp: setUpAndTearDown,
+ tearDown: setUpAndTearDown,
+ run: function test() {
+ gInput.selectionStart = gInput.selectionEnd = 0;
+
+ let promise = waitForEvent(document, "popupshown");
+ sendContextMenuClick(230, 17);
+ yield promise;
+
+ checkContextUIMenuItemVisibility(["context-select",
+ "context-select-all"]);
+
+ let menuItem = document.getElementById("context-select");
+ ok(menuItem, "menu item exists");
+ ok(!menuItem.hidden, "menu item visible");
+ let popupPromise = waitForEvent(document, "popuphidden");
+ EventUtils.synthesizeMouse(menuItem, 10, 10, {}, gWindow);
+ yield popupPromise;
+
+ yield waitForCondition(function () {
+ return SelectionHelperUI.isSelectionUIVisible;
+ }, kCommonWaitMs, kCommonPollMs);
+
+ // check text selection
+ is(getTrimmedSelection(gInput).toString(), "straight", "selection test");
+
+ // to the right
+ let xpos = SelectionHelperUI.endMark.xPos;
+ let ypos = SelectionHelperUI.endMark.yPos + 10;
+ var touchdrag = new TouchDragAndHold();
+ yield touchdrag.start(gWindow, xpos, ypos, 510, ypos);
+ yield waitForCondition(function () {
+ return getTrimmedSelection(gInput).toString() ==
+ "straight on like a tunnel for some way and then dipped suddenly down";
+ }, 6000, 2000);
+ touchdrag.end();
+
+ yield waitForCondition(function () {
+ return !SelectionHelperUI.hasActiveDrag;
+ }, kCommonWaitMs, kCommonPollMs);
+ yield SelectionHelperUI.pingSelectionHandler();
+
+ // down - selection shouldn't change
+ let xpos = SelectionHelperUI.endMark.xPos;
+ let ypos = SelectionHelperUI.endMark.yPos + 10;
+ yield touchdrag.start(gWindow, xpos, ypos, xpos, ypos + 150);
+ yield waitForMs(2000);
+ touchdrag.end();
+
+ is(getTrimmedSelection(gInput).toString(), "straight on like a tunnel for some way and then dipped suddenly down", "selection test");
+
+ // left and up - selection should shrink
+ let xpos = SelectionHelperUI.endMark.xPos;
+ let ypos = SelectionHelperUI.endMark.yPos + 10;
+ yield touchdrag.start(gWindow, xpos, ypos, 105, 25);
+ yield waitForCondition(function () {
+ return getTrimmedSelection(gInput).toString() ==
+ "straight on like a tunnel for";
+ }, 6000, 2000);
+ touchdrag.end();
+ },
+});
+
+function test() {
+ if (!isLandscapeMode()) {
+ todo(false, "browser_selection_tests need landscape mode to run.");
+ return;
+ }
+
+ requestLongerTimeout(3);
+ runTests();
+}
diff --git a/browser/metro/base/tests/mochitest/browser_selection_textarea.js b/browser/metro/base/tests/mochitest/browser_selection_textarea.js
index 8c8d16f8fb6c..8d8b07537991 100644
--- a/browser/metro/base/tests/mochitest/browser_selection_textarea.js
+++ b/browser/metro/base/tests/mochitest/browser_selection_textarea.js
@@ -25,7 +25,6 @@ function setUpAndTearDown() {
yield waitForCondition(function () {
return !SelectionHelperUI.isSelectionUIVisible;
}, kCommonWaitMs, kCommonPollMs);
- yield hideContextUI();
}
gTests.push({
@@ -40,6 +39,8 @@ gTests.push({
return !StartUI.isStartPageVisible;
}, 10000, 100);
+ yield hideContextUI();
+
gWindow = Browser.selectedTab.browser.contentWindow;
InputSourceHelper.isPrecise = false;
},
@@ -143,11 +144,6 @@ gTests.push({
});
function test() {
- if (isDebugBuild()) {
- todo(false, "selection tests can't run in debug builds.");
- return;
- }
-
if (!isLandscapeMode()) {
todo(false, "browser_selection_tests need landscape mode to run.");
return;
diff --git a/browser/metro/base/tests/mochitest/head.js b/browser/metro/base/tests/mochitest/head.js
index bda4c8c5d8f7..1a99b78d7fa7 100644
--- a/browser/metro/base/tests/mochitest/head.js
+++ b/browser/metro/base/tests/mochitest/head.js
@@ -55,6 +55,24 @@ function checkContextUIMenuItemVisibility(aVisibleList)
is(errors, 0, "context menu item list visibility");
}
+function checkMonoclePositionRange(aMonocle, aMinX, aMaxX, aMinY, aMaxY)
+{
+ let monocle = null;
+ if (aMonocle == "start")
+ monocle = SelectionHelperUI._startMark;
+ else if (aMonocle == "end")
+ monocle = SelectionHelperUI._endMark;
+ else if (aMonocle == "caret")
+ monocle = SelectionHelperUI._caretMark;
+ else
+ ok(false, "bad monocle id");
+
+ ok(monocle.xPos > aMinX && monocle.xPos < aMaxX,
+ "X position is " + monocle.xPos + ", expected between " + aMinX + " and " + aMaxX);
+ ok(monocle.yPos > aMinY && monocle.yPos < aMaxY,
+ "Y position is " + monocle.yPos + ", expected between " + aMinY + " and " + aMaxY);
+}
+
/*
* showNotification - displays a test notification with the current
* browser and waits for the noticiation to be fully displayed.
@@ -184,7 +202,7 @@ function addTab(aUrl) {
return Task.spawn(function() {
info("Opening "+aUrl+" in a new tab");
let tab = Browser.addTab(aUrl, true);
- yield waitForEvent(tab.browser, "pageshow");
+ yield tab.pageShowPromise;
is(tab.browser.currentURI.spec, aUrl, aUrl + " is loaded");
registerCleanupFunction(function() Browser.closeTab(tab));
@@ -213,7 +231,6 @@ function addTab(aUrl) {
* @returns a Promise that resolves to the received event, or to an Error
*/
function waitForEvent(aSubject, aEventName, aTimeoutMs) {
- info("waitForEvent: on " + aSubject + " event: " + aEventName);
let eventDeferred = Promise.defer();
let timeoutMs = aTimeoutMs || kDefaultWait;
let timerID = setTimeout(function wfe_canceller() {
@@ -548,8 +565,11 @@ TouchDragAndHold.prototype = {
_timeoutStep: 2,
_numSteps: 50,
_debug: false,
+ _win: null,
callback: function callback() {
+ if (this._win == null)
+ return;
if (++this._step.steps >= this._numSteps) {
EventUtils.synthesizeTouchAtPoint(this._endPoint.xPos, this._endPoint.yPos,
{ type: "touchmove" }, this._win);
diff --git a/browser/metro/base/tests/mochitest/res/textarea01.html b/browser/metro/base/tests/mochitest/res/textarea01.html
new file mode 100644
index 000000000000..b391c8c494fc
--- /dev/null
+++ b/browser/metro/base/tests/mochitest/res/textarea01.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/browser/metro/base/tests/mochitest/text-block.html b/browser/metro/base/tests/mochitest/res/textblock01.html
similarity index 100%
rename from browser/metro/base/tests/mochitest/text-block.html
rename to browser/metro/base/tests/mochitest/res/textblock01.html
diff --git a/browser/metro/base/tests/mochitest/res/textinput01.html b/browser/metro/base/tests/mochitest/res/textinput01.html
new file mode 100644
index 000000000000..06af960d0882
--- /dev/null
+++ b/browser/metro/base/tests/mochitest/res/textinput01.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/browser/metro/modules/CrossSlide.jsm b/browser/metro/modules/CrossSlide.jsm
index 6d105a78040c..38f6e476cf73 100644
--- a/browser/metro/modules/CrossSlide.jsm
+++ b/browser/metro/modules/CrossSlide.jsm
@@ -145,7 +145,7 @@ CrossSlideHandler.prototype = {
}
},
- cancel: function(){
+ cancel: function(aEvent){
this._fireProgressEvent("cancelled", aEvent);
this.drag = null;
},
@@ -183,7 +183,7 @@ CrossSlideHandler.prototype = {
if (aEvent.touches.length!==1) {
// cancel if another touch point gets involved
- return this.cancel();
+ return this.cancel(aEvent);
}
let startPt = this.drag.origin;
@@ -202,7 +202,7 @@ CrossSlideHandler.prototype = {
if (-1 == newState) {
// out of bounds, cancel the event always
- return this.cancel();
+ return this.cancel(aEvent);
}
let isWithinCone = withinCone(crossAxisDistance, scrollAxisDistance);
@@ -213,7 +213,7 @@ CrossSlideHandler.prototype = {
if (currState >= CrossSlidingState.SELECTING && !isWithinCone) {
// we're committed to a cross-slide gesture,
// so going out of bounds at this point means aborting
- return this.cancel();
+ return this.cancel(aEvent);
}
if (currState > newState) {
@@ -232,7 +232,7 @@ CrossSlideHandler.prototype = {
aEvent.stopPropagation();
if (this.drag.state < CrossSlidingState.SELECTING) {
- return this.cancel();
+ return this.cancel(aEvent);
}
this._fireProgressEvent("completed", aEvent);
diff --git a/browser/themes/linux/Toolbar-small.png b/browser/themes/linux/Toolbar-small.png
index ca448250e601..bcc8f63dcd9f 100644
Binary files a/browser/themes/linux/Toolbar-small.png and b/browser/themes/linux/Toolbar-small.png differ
diff --git a/browser/themes/linux/Toolbar.png b/browser/themes/linux/Toolbar.png
index 5ae54323a35b..2851657ecaf3 100644
Binary files a/browser/themes/linux/Toolbar.png and b/browser/themes/linux/Toolbar.png differ
diff --git a/browser/themes/linux/browser.css b/browser/themes/linux/browser.css
index 054cbe48f15c..62ea4dd19c11 100644
--- a/browser/themes/linux/browser.css
+++ b/browser/themes/linux/browser.css
@@ -476,10 +476,6 @@ menuitem:not([type]):not(.menuitem-tooltip):not(.menuitem-iconic-tooltip) {
list-style-image: url("chrome://browser/skin/places/bookmarksToolbar.png");
}
-#BMB_bookmarkThisPage {
- list-style-image: url("chrome://browser/skin/places/starPage.png");
-}
-
#BMB_unsortedBookmarks {
list-style-image: url("chrome://browser/skin/places/unsortedBookmarks.png");
}
@@ -654,19 +650,10 @@ toolbar[mode="full"] .toolbarbutton-1 > .toolbarbutton-menubutton-button {
-moz-image-region: rect(0px 48px 24px 24px);
}
-#bookmarks-button,
-#bookmarks-menu-button {
+#bookmarks-button {
-moz-image-region: rect(0px 72px 24px 48px);
}
-#bookmarks-menu-button.bookmark-item {
- list-style-image: url("chrome://browser/skin/Toolbar-small.png");
-}
-
-#bookmarks-menu-button.toolbarbutton-1 {
- -moz-box-orient: horizontal;
-}
-
#print-button {
list-style-image: url("moz-icon://stock/gtk-print?size=toolbar");
}
@@ -727,8 +714,8 @@ toolbar[mode="full"] .toolbarbutton-1 > .toolbarbutton-menubutton-button {
-moz-image-region: rect(0px 168px 24px 144px);
}
-#feed-button[disabled="true"] > .toolbarbutton-icon {
- opacity: .3;
+#feed-button[disabled] > .toolbarbutton-icon {
+ opacity: .4;
}
#webrtc-status-button {
@@ -820,9 +807,7 @@ toolbar[iconsize="small"] #history-button {
-moz-image-region: rect(0px 32px 16px 16px);
}
-toolbar[iconsize="small"] #bookmarks-button,
-toolbar[iconsize="small"] #bookmarks-menu-button,
-#bookmarks-menu-button.bookmark-item {
+toolbar[iconsize="small"] #bookmarks-button {
-moz-image-region: rect(0px 48px 16px 32px);
}
@@ -1351,7 +1336,8 @@ toolbar[iconsize="small"] #webrtc-status-button {
.ac-result-type-bookmark,
.autocomplete-treebody::-moz-tree-image(bookmark, treecolAutoCompleteImage) {
- list-style-image: url("chrome://browser/skin/places/pageStarred.png");
+ list-style-image: url("chrome://browser/skin/places/star-icons.png");
+ -moz-image-region: rect(0px 32px 16px 16px);
width: 16px;
height: 16px;
}
@@ -1493,13 +1479,34 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
margin-top: 1em;
}
-/* Star button */
-#star-button {
- list-style-image: url("chrome://browser/skin/places/starPage.png");
+/* bookmarks menu-button */
+
+#bookmarks-menu-button {
+ list-style-image: url("chrome://browser/skin/Toolbar.png");
+ -moz-image-region: rect(0px 216px 24px 192px);
}
-#star-button[starred="true"] {
- list-style-image: url("chrome://browser/skin/places/pageStarred.png");
+#bookmarks-menu-button[starred] {
+ -moz-image-region: rect(24px 216px 48px 192px);
+}
+
+toolbar[iconsize="small"] #bookmarks-menu-button,
+#bookmarks-menu-button.bookmark-item {
+ list-style-image: url("chrome://browser/skin/Toolbar-small.png");
+ -moz-image-region: rect(0px 144px 16px 128px);
+}
+
+toolbar[iconsize="small"] #bookmarks-menu-button[starred],
+#bookmarks-menu-button.bookmark-item[starred] {
+ -moz-image-region: rect(16px 144px 32px 128px);
+}
+
+#bookmarks-menu-button[disabled] > .toolbarbutton-icon,
+#bookmarks-menu-button[disabled] > .toolbarbutton-menu-dropmarker,
+#bookmarks-menu-button[disabled] > .toolbarbutton-menubutton-dropmarker,
+#bookmarks-menu-button[disabled] > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
+#bookmarks-menu-button > .toolbarbutton-menubutton-button[disabled] > .toolbarbutton-icon {
+ opacity: .4;
}
/* Bookmarking panel */
diff --git a/browser/themes/linux/devtools/common.css b/browser/themes/linux/devtools/common.css
index 336e2c543626..8865f23cdb47 100644
--- a/browser/themes/linux/devtools/common.css
+++ b/browser/themes/linux/devtools/common.css
@@ -130,7 +130,7 @@
-moz-appearance: none !important;
list-style-image: url("chrome://browser/skin/devtools/dropmarker.png");
-moz-box-align: center;
- margin: 0 3px;
+ padding: 0 3px;
}
/* Text input */
diff --git a/browser/themes/linux/devtools/netmonitor.css b/browser/themes/linux/devtools/netmonitor.css
index 56925dfcd724..22e8b3038ce2 100644
--- a/browser/themes/linux/devtools/netmonitor.css
+++ b/browser/themes/linux/devtools/netmonitor.css
@@ -93,11 +93,13 @@
}
.requests-menu-file {
- width: 14em;
+ width: 20vw;
+ min-width: 4em;
}
.requests-menu-domain {
- width: 14em;
+ width: 14vw;
+ min-width: 10em;
}
.requests-menu-type {
@@ -303,13 +305,44 @@
#details-pane {
max-width: none;
margin: 0 !important;
- /* To prevent all the margin hacks to hide the sidebar */
+ /* To prevent all the margin hacks to hide the sidebar. */
+ }
+
+ .requests-menu-status-and-method {
+ width: 14vw;
+ }
+
+ .requests-menu-file,
+ .requests-menu-domain {
+ width: 30vw;
+ min-width: 10em;
+ }
+
+ .requests-menu-type {
+ width: 8vw;
}
.requests-menu-size {
- border-width: 0px !important;
+ width: 16vw;
+ border-width: 0 !important;
box-shadow: none !important;
- /* !important are required here because Timeline is not visible and thus
- the right border and box-shadow of Size column should be hidden */
+ /* The "Timeline" header is not visible anymore, and thus the
+ right border and box-shadow of "Size" column should be hidden. */
+ }
+}
+
+@media (min-width: 701px) {
+ #network-table[type-overflows] .requests-menu-domain {
+ border-width: 0 !important;
+ box-shadow: none !important;
+ /* The "Type" header is not visible anymore, and thus the
+ right border and box-shadow of "Domain" column should be hidden. */
+ }
+
+ #network-table[domain-overflows] .requests-menu-file {
+ border-width: 0 !important;
+ box-shadow: none !important;
+ /* The "Domain" header is not visible anymore, and thus the
+ right border and box-shadow of "File" column should be hidden. */
}
}
diff --git a/browser/themes/linux/downloads/downloads.css b/browser/themes/linux/downloads/downloads.css
index bb597a8916f1..240e37d860dd 100644
--- a/browser/themes/linux/downloads/downloads.css
+++ b/browser/themes/linux/downloads/downloads.css
@@ -155,7 +155,7 @@ richlistitem[type="download"]:last-child {
/*** Highlighted list items ***/
-#downloadsPanel:not([keyfocus]) > #downloadsListBox > richlistitem[type="download"][state="1"]:hover {
+#downloadsPanel:not([keyfocus]) > #downloadsListBox > richlistitem[type="download"][state="1"][exists]:hover {
border-radius: 3px;
border-top: 1px solid hsla(0,0%,100%,.3);
border-bottom: 1px solid hsla(0,0%,0%,.2);
diff --git a/browser/themes/linux/jar.mn b/browser/themes/linux/jar.mn
index 3d00542ba472..2e2ad9ae4773 100644
--- a/browser/themes/linux/jar.mn
+++ b/browser/themes/linux/jar.mn
@@ -83,14 +83,13 @@ browser.jar:
skin/classic/browser/places/calendar.png (places/calendar.png)
* skin/classic/browser/places/editBookmarkOverlay.css (places/editBookmarkOverlay.css)
skin/classic/browser/places/livemark-item.png (places/livemark-item.png)
- skin/classic/browser/places/pageStarred.png (places/pageStarred.png)
+ skin/classic/browser/places/star-icons.png (places/star-icons.png)
skin/classic/browser/places/starred48.png (places/starred48.png)
skin/classic/browser/places/unstarred48.png (places/unstarred48.png)
skin/classic/browser/places/places.css (places/places.css)
skin/classic/browser/places/organizer.css (places/organizer.css)
skin/classic/browser/places/organizer.xml (places/organizer.xml)
skin/classic/browser/places/query.png (places/query.png)
- skin/classic/browser/places/starPage.png (places/starPage.png)
skin/classic/browser/places/tag.png (places/tag.png)
skin/classic/browser/places/toolbarDropMarker.png (places/toolbarDropMarker.png)
skin/classic/browser/places/unsortedBookmarks.png (places/unsortedBookmarks.png)
diff --git a/browser/themes/linux/places/pageStarred.png b/browser/themes/linux/places/pageStarred.png
deleted file mode 100644
index 61a9f90e05b1..000000000000
Binary files a/browser/themes/linux/places/pageStarred.png and /dev/null differ
diff --git a/browser/themes/linux/places/star-icons.png b/browser/themes/linux/places/star-icons.png
new file mode 100644
index 000000000000..2f50c6ab973e
Binary files /dev/null and b/browser/themes/linux/places/star-icons.png differ
diff --git a/browser/themes/linux/places/starPage.png b/browser/themes/linux/places/starPage.png
deleted file mode 100644
index 3193a3535f1e..000000000000
Binary files a/browser/themes/linux/places/starPage.png and /dev/null differ
diff --git a/browser/themes/osx/Toolbar-lion.png b/browser/themes/osx/Toolbar-lion.png
index 8b83fdc84177..a91ba7bfd66d 100644
Binary files a/browser/themes/osx/Toolbar-lion.png and b/browser/themes/osx/Toolbar-lion.png differ
diff --git a/browser/themes/osx/Toolbar-lion@2x.png b/browser/themes/osx/Toolbar-lion@2x.png
index f721e5057c8a..10b799485857 100644
Binary files a/browser/themes/osx/Toolbar-lion@2x.png and b/browser/themes/osx/Toolbar-lion@2x.png differ
diff --git a/browser/themes/osx/Toolbar.png b/browser/themes/osx/Toolbar.png
index 521c6c3887b4..c1868929dd8e 100644
Binary files a/browser/themes/osx/Toolbar.png and b/browser/themes/osx/Toolbar.png differ
diff --git a/browser/themes/osx/browser.css b/browser/themes/osx/browser.css
index 54e80328abe1..3737c2fed26b 100644
--- a/browser/themes/osx/browser.css
+++ b/browser/themes/osx/browser.css
@@ -438,7 +438,8 @@ toolbarbutton.bookmark-item > menupopup {
list-style-image: url("chrome://browser/skin/Toolbar@2x.png");
}
- :-moz-any(@primaryToolbarButtons@):not(#tabview-button) > .toolbarbutton-icon {
+ :-moz-any(@primaryToolbarButtons@):not(#tabview-button) > .toolbarbutton-icon,
+ :-moz-any(@primaryToolbarButtons@):not(#tabview-button) > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
width: 20px;
}
}
@@ -474,7 +475,7 @@ toolbar:not([mode="icons"]) #restore-button {
.toolbarbutton-1[disabled="true"] > .toolbarbutton-icon,
.toolbarbutton-1[disabled="true"] > .toolbarbutton-badge-container > .toolbarbutton-icon,
-.toolbarbutton-1[type="menu-button"] > .toolbarbutton-menubutton-button[disabled="true"] > .toolbarbutton-icon,
+.toolbarbutton-1 > .toolbarbutton-menubutton-button[disabled="true"] > .toolbarbutton-icon,
#restore-button[disabled="true"] > .toolbarbutton-icon {
opacity: .4;
}
@@ -482,7 +483,7 @@ toolbar:not([mode="icons"]) #restore-button {
@media (-moz-mac-lion-theme) {
.toolbarbutton-1[disabled="true"] > .toolbarbutton-icon,
.toolbarbutton-1[disabled="true"] > .toolbarbutton-badge-container > .toolbarbutton-icon,
- .toolbarbutton-1[type="menu-button"] > .toolbarbutton-menubutton-button[disabled="true"] > .toolbarbutton-icon,
+ .toolbarbutton-1 > .toolbarbutton-menubutton-button[disabled="true"] > .toolbarbutton-icon,
#restore-button[disabled="true"] > .toolbarbutton-icon,
.toolbarbutton-1[disabled="true"] > .toolbarbutton-menu-dropmarker,
.toolbarbutton-1[disabled="true"] > .toolbarbutton-menubutton-dropmarker,
@@ -490,13 +491,14 @@ toolbar:not([mode="icons"]) #restore-button {
.toolbarbutton-1:not(:hover):-moz-window-inactive > .toolbarbutton-badge-container > .toolbarbutton-icon,
#restore-button:not(:hover):-moz-window-inactive > .toolbarbutton-icon,
.toolbarbutton-1:not(:hover):-moz-window-inactive > .toolbarbutton-menu-dropmarker,
- .toolbarbutton-1:not(:hover):-moz-window-inactive > .toolbarbutton-menubutton-dropmarker {
+ .toolbarbutton-1:not(:hover):-moz-window-inactive > .toolbarbutton-menubutton-dropmarker,
+ .toolbarbutton-1:not(:hover):-moz-window-inactive > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
opacity: .5;
}
.toolbarbutton-1:-moz-window-inactive[disabled="true"] > .toolbarbutton-icon,
.toolbarbutton-1:-moz-window-inactive[disabled="true"] > .toolbarbutton-badge-container > .toolbarbutton-icon,
- .toolbarbutton-1:-moz-window-inactive[type="menu-button"] > .toolbarbutton-menubutton-button[disabled="true"] > .toolbarbutton-icon,
+ .toolbarbutton-1:-moz-window-inactive > .toolbarbutton-menubutton-button[disabled="true"] > .toolbarbutton-icon,
#restore-button:-moz-window-inactive[disabled="true"] > .toolbarbutton-icon {
opacity: .25;
}
@@ -524,8 +526,7 @@ toolbar:not([mode="icons"]) #restore-button {
}
.toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker {
- width: 14px;
- padding-top: 2px;
+ padding: 2px 4px 0;
-moz-border-start: none !important;
}
@@ -916,8 +917,7 @@ toolbar[mode="icons"] #forward-button:-moz-lwtheme {
/* bookmark sidebar & menu buttons */
-#bookmarks-button,
-#bookmarks-menu-button {
+#bookmarks-button {
-moz-image-region: rect(0, 180px, 20px, 160px);
}
@@ -925,33 +925,14 @@ toolbar[mode="icons"] #forward-button:-moz-lwtheme {
-moz-image-region: rect(20px, 180px, 40px, 160px);
}
-#bookmarks-menu-button.bookmark-item {
- -moz-image-region: rect(2px, 178px, 18px, 162px);
- list-style-image: url("chrome://browser/skin/Toolbar.png");
-}
-
@media (min-resolution: 2dppx) {
- #bookmarks-button,
- #bookmarks-menu-button {
+ #bookmarks-button {
-moz-image-region: rect(0, 360px, 40px, 320px);
}
#bookmarks-button[checked="true"] {
-moz-image-region: rect(40px, 360px, 80px, 320px);
}
-
- #bookmarks-menu-button.bookmark-item {
- -moz-image-region: rect(4px, 356px, 36px, 324px);
- list-style-image: url("chrome://browser/skin/Toolbar@2x.png");
- }
-
- #bookmarks-menu-button.bookmark-item > .toolbarbutton-icon {
- width: 16px;
- }
-}
-
-#bookmarks-menu-button.toolbarbutton-1 {
- -moz-box-orient: horizontal;
}
/* print button */
@@ -1736,35 +1717,49 @@ window[tabsontop="false"] richlistitem[type~="action"][actiontype="switchtab"][s
margin-top: 1em;
}
-/* STAR BUTTON */
-#star-button {
+/* bookmarks menu-button */
+
+#bookmarks-menu-button {
+ -moz-image-region: rect(0px 500px 20px 480px);
+}
+
+#bookmarks-menu-button[starred] {
+ -moz-image-region: rect(20px 500px 40px 480px);
+}
+
+#bookmarks-menu-button.bookmark-item {
list-style-image: url("chrome://browser/skin/places/star-icons.png");
- -moz-image-region: rect(0, 16px, 16px, 0);
+ -moz-image-region: rect(0px 16px 16px 0px);
}
-#star-button:hover:active,
-#star-button[starred="true"] {
- -moz-image-region: rect(0, 32px, 16px, 16px);
+#bookmarks-menu-button.bookmark-item[starred] {
+ -moz-image-region: rect(0px 32px 16px 16px);
}
-#star-button:hover:active[starred="true"] {
- -moz-image-region: rect(0, 48px, 16px, 32px);
+#bookmarks-menu-button.bookmark-item > .toolbarbutton-menubutton-button {
+ padding: 0;
}
@media (min-resolution: 2dppx) {
- #star-button {
+ #bookmarks-menu-button {
+ -moz-image-region: rect(0px, 1000px, 40px, 960px);
+ }
+
+ #bookmarks-menu-button[starred] {
+ -moz-image-region: rect(40px, 1000px, 80px, 960px);
+ }
+
+ #bookmarks-menu-button.bookmark-item {
list-style-image: url("chrome://browser/skin/places/star-icons@2x.png");
- -moz-image-region: rect(0, 32px, 32px, 0);
- width: 22px;
+ -moz-image-region: rect(0px 32px 32px 0px);
}
- #star-button:hover:active,
- #star-button[starred="true"] {
- -moz-image-region: rect(0, 64px, 32px, 32px);
+ #bookmarks-menu-button.bookmark-item[starred] {
+ -moz-image-region: rect(0px 64px 32px 32px);
}
- #star-button:hover:active[starred="true"] {
- -moz-image-region: rect(0, 96px, 32px, 64px);
+ #bookmarks-menu-button.bookmark-item > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
+ width: 16px;
}
}
@@ -2517,12 +2512,16 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker {
}
:-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1:not([type="menu-button"]),
-:-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1 > .toolbarbutton-menubutton-button,
-:-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker {
+:-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1 > .toolbarbutton-menubutton-button {
margin: 0;
padding: 0 1px;
}
+:-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker {
+ padding-left: 4px;
+ padding-right: 4px;
+}
+
.tabbrowser-arrowscrollbox > .scrollbutton-up:not([disabled]):hover,
.tabbrowser-arrowscrollbox > .scrollbutton-down:not([disabled]):hover,
:-moz-any(#TabsToolbar, #addon-bar) .toolbarbutton-1:not([type="menu-button"]):not([disabled]):not([open]):hover,
diff --git a/browser/themes/osx/devtools/common.css b/browser/themes/osx/devtools/common.css
index e7b29c118f9b..8aa99db592a8 100644
--- a/browser/themes/osx/devtools/common.css
+++ b/browser/themes/osx/devtools/common.css
@@ -134,7 +134,6 @@
.devtools-toolbarbutton[type=menu-button] > .toolbarbutton-menubutton-dropmarker {
-moz-appearance: none !important;
list-style-image: url("chrome://browser/skin/devtools/dropmarker.png");
- margin: 0 3px;
border: 0;
}
diff --git a/browser/themes/osx/devtools/netmonitor.css b/browser/themes/osx/devtools/netmonitor.css
index 270fc5cf9b49..de362627ed09 100644
--- a/browser/themes/osx/devtools/netmonitor.css
+++ b/browser/themes/osx/devtools/netmonitor.css
@@ -93,11 +93,13 @@
}
.requests-menu-file {
- width: 16em;
+ width: 20vw;
+ min-width: 4em;
}
.requests-menu-domain {
- width: 16em;
+ width: 14vw;
+ min-width: 10em;
}
.requests-menu-type {
@@ -303,13 +305,44 @@
#details-pane {
max-width: none;
margin: 0 !important;
- /* To prevent all the margin hacks to hide the sidebar */
+ /* To prevent all the margin hacks to hide the sidebar. */
+ }
+
+ .requests-menu-status-and-method {
+ width: 14vw;
+ }
+
+ .requests-menu-file,
+ .requests-menu-domain {
+ width: 30vw;
+ min-width: 10em;
+ }
+
+ .requests-menu-type {
+ width: 8vw;
}
.requests-menu-size {
- border-width: 0px !important;
+ width: 16vw;
+ border-width: 0 !important;
box-shadow: none !important;
- /* !important are required here because Timeline is not visible and thus
- the right border and box-shadow of Size column should be hidden */
+ /* The "Timeline" header is not visible anymore, and thus the
+ right border and box-shadow of "Size" column should be hidden. */
+ }
+}
+
+@media (min-width: 701px) {
+ #network-table[type-overflows] .requests-menu-domain {
+ border-width: 0 !important;
+ box-shadow: none !important;
+ /* The "Type" header is not visible anymore, and thus the
+ right border and box-shadow of "Domain" column should be hidden. */
+ }
+
+ #network-table[domain-overflows] .requests-menu-file {
+ border-width: 0 !important;
+ box-shadow: none !important;
+ /* The "Domain" header is not visible anymore, and thus the
+ right border and box-shadow of "File" column should be hidden. */
}
}
diff --git a/browser/themes/osx/downloads/downloads.css b/browser/themes/osx/downloads/downloads.css
index 9a8f0620ed6f..59fb5eb573ab 100644
--- a/browser/themes/osx/downloads/downloads.css
+++ b/browser/themes/osx/downloads/downloads.css
@@ -177,7 +177,7 @@ richlistitem[type="download"]:last-child {
/*** Highlighted list items ***/
#downloadsPanel[keyfocus] > #downloadsListBox:focus > richlistitem[type="download"][selected],
-#downloadsPanel:not([keyfocus]) > #downloadsListBox > richlistitem[type="download"][state="1"]:hover {
+#downloadsPanel:not([keyfocus]) > #downloadsListBox > richlistitem[type="download"][state="1"][exists]:hover {
border-radius: 3px;
border-top: 1px solid hsla(0,0%,100%,.2);
border-bottom: 1px solid hsla(0,0%,0%,.4);
@@ -185,7 +185,7 @@ richlistitem[type="download"]:last-child {
color: HighlightText;
}
-#downloadsPanel:not([keyfocus]) > #downloadsListBox > richlistitem[type="download"][state="1"]:hover {
+#downloadsPanel:not([keyfocus]) > #downloadsListBox > richlistitem[type="download"][state="1"][exists]:hover {
cursor: pointer;
}
diff --git a/browser/themes/windows/Toolbar-inverted.png b/browser/themes/windows/Toolbar-inverted.png
index d6efac70dad7..2c3253fe80f9 100644
Binary files a/browser/themes/windows/Toolbar-inverted.png and b/browser/themes/windows/Toolbar-inverted.png differ
diff --git a/browser/themes/windows/Toolbar.png b/browser/themes/windows/Toolbar.png
index 35f0caaaea22..b84f6ddadf1a 100644
Binary files a/browser/themes/windows/Toolbar.png and b/browser/themes/windows/Toolbar.png differ
diff --git a/browser/themes/windows/browser-aero.css b/browser/themes/windows/browser-aero.css
index 1f919fd2a19b..defe92dc86cb 100644
--- a/browser/themes/windows/browser-aero.css
+++ b/browser/themes/windows/browser-aero.css
@@ -159,8 +159,8 @@
border-right-style: none !important;
}
- #navigator-toolbox[tabsontop=false] > :-moz-any(#toolbar-menubar, #nav-bar) :-moz-any(@primaryToolbarButtons@):not(:-moz-any(#alltabs-button,#tabview-button,#sync-button[status])) > .toolbarbutton-icon:not(:-moz-lwtheme),
- #nav-bar + #customToolbars + #PersonalToolbar[collapsed=true] + #TabsToolbar[tabsontop=false]:last-child :-moz-any(@primaryToolbarButtons@):not(:-moz-any(#alltabs-button,#tabview-button,#new-tab-button,#sync-button[status])) > .toolbarbutton-icon:not(:-moz-lwtheme) {
+ #navigator-toolbox[tabsontop=false] > :-moz-any(#toolbar-menubar, #nav-bar) :-moz-any(@primaryToolbarButtons@):not(:-moz-any(#alltabs-button,#tabview-button,#sync-button[status],#bookmarks-menu-button)) > .toolbarbutton-icon:not(:-moz-lwtheme),
+ #nav-bar + #customToolbars + #PersonalToolbar[collapsed=true] + #TabsToolbar[tabsontop=false]:last-child :-moz-any(@primaryToolbarButtons@):not(:-moz-any(#alltabs-button,#tabview-button,#new-tab-button,#sync-button[status],#bookmarks-menu-button)) > .toolbarbutton-icon:not(:-moz-lwtheme) {
list-style-image: url("chrome://browser/skin/Toolbar-inverted.png");
}
diff --git a/browser/themes/windows/browser.css b/browser/themes/windows/browser.css
index 75236df0ed49..0f64209738fd 100644
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/windows/browser.css
@@ -647,7 +647,7 @@ toolbarbutton.bookmark-item[open="true"] {
-moz-padding-end: 2px;
}
-.bookmark-item:not(#bookmarks-menu-button) > .toolbarbutton-icon {
+.bookmark-item > .toolbarbutton-icon {
width: 16px;
height: 16px;
}
@@ -764,7 +764,8 @@ menuitem.bookmark-item {
.toolbarbutton-1[disabled=true] > .toolbarbutton-icon,
.toolbarbutton-1[disabled=true] > .toolbarbutton-menu-dropmarker,
.toolbarbutton-1[disabled=true] > .toolbarbutton-menubutton-dropmarker,
-.toolbarbutton-1[disabled=true] > .toolbarbutton-menubutton-button > .toolbarbutton-icon {
+.toolbarbutton-1[disabled=true] > .toolbarbutton-menubutton-button > .toolbarbutton-icon,
+.toolbarbutton-1 > .toolbarbutton-menubutton-button[disabled] > .toolbarbutton-icon {
opacity: .4;
}
@@ -866,7 +867,7 @@ toolbar[mode=full] .toolbarbutton-1 > .toolbarbutton-menubutton-button {
}
@navbarLargeIcons@ .toolbarbutton-1 > .toolbarbutton-menubutton-dropmarker > .dropmarker-icon {
- padding: 8px 3px 7px;
+ padding: 8px 5px 7px;
}
@navbarLargeIcons@ .toolbarbutton-1:not(:hover):not(:active):not([open]) > .toolbarbutton-menubutton-dropmarker::before,
@@ -1115,16 +1116,9 @@ toolbar[mode=full] .toolbarbutton-1 > .toolbarbutton-menubutton-button {
-moz-image-region: rect(0, 126px, 18px, 108px);
}
-#bookmarks-button,
-#bookmarks-menu-button {
+#bookmarks-button {
-moz-image-region: rect(0, 144px, 18px, 126px);
}
-#bookmarks-menu-button.bookmark-item {
- list-style-image: url("chrome://browser/skin/Toolbar.png");
-}
-#bookmarks-menu-button.bookmark-item:-moz-lwtheme-brighttext {
- list-style-image: url("chrome://browser/skin/Toolbar-inverted.png");
-}
#print-button {
-moz-image-region: rect(0, 162px, 18px, 144px);
@@ -1580,8 +1574,8 @@ html|*.urlbar-input:-moz-lwtheme::-moz-placeholder,
.ac-result-type-bookmark,
.autocomplete-treebody::-moz-tree-image(bookmark, treecolAutoCompleteImage) {
- list-style-image: url("chrome://browser/skin/places/editBookmark.png");
- -moz-image-region: rect(0px 16px 16px 0px);
+ list-style-image: url("chrome://browser/skin/places/bookmark.png");
+ -moz-image-region: rect(0px 48px 16px 32px);
width: 16px;
height: 16px;
}
@@ -1792,28 +1786,31 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
margin-top: 1em;
}
-/* star button */
+/* bookmarks menu-button */
-#star-button {
+#bookmarks-menu-button {
+ -moz-image-region: rect(0px 378px 18px 360px);
+}
+
+#bookmarks-menu-button[starred] {
+ -moz-image-region: rect(18px 378px 36px 360px);
+}
+
+#bookmarks-menu-button.bookmark-item {
list-style-image: url("chrome://browser/skin/places/bookmark.png");
-moz-image-region: rect(0px 16px 16px 0px);
}
-#star-button:hover {
- background-image: radial-gradient(circle closest-side, hsla(45,100%,73%,.3), hsla(45,100%,73%,0));
- -moz-image-region: rect(0px 32px 16px 16px);
-}
-
-#star-button:hover:active {
- background-image: radial-gradient(circle closest-side, hsla(45,100%,73%,.1), hsla(45,100%,73%,0));
+#bookmarks-menu-button.bookmark-item[starred] {
-moz-image-region: rect(0px 48px 16px 32px);
}
-#star-button[starred="true"] {
- list-style-image: url("chrome://browser/skin/places/editBookmark.png");
+#bookmarks-menu-button.bookmark-item > .toolbarbutton-menubutton-button> .toolbarbutton-icon {
+ -moz-margin-start: 5px;
}
/* bookmarking panel */
+
#editBookmarkPanelStarIcon {
list-style-image: url("chrome://browser/skin/places/starred48.png");
width: 48px;
diff --git a/browser/themes/windows/devtools/netmonitor.css b/browser/themes/windows/devtools/netmonitor.css
index 270fc5cf9b49..de362627ed09 100644
--- a/browser/themes/windows/devtools/netmonitor.css
+++ b/browser/themes/windows/devtools/netmonitor.css
@@ -93,11 +93,13 @@
}
.requests-menu-file {
- width: 16em;
+ width: 20vw;
+ min-width: 4em;
}
.requests-menu-domain {
- width: 16em;
+ width: 14vw;
+ min-width: 10em;
}
.requests-menu-type {
@@ -303,13 +305,44 @@
#details-pane {
max-width: none;
margin: 0 !important;
- /* To prevent all the margin hacks to hide the sidebar */
+ /* To prevent all the margin hacks to hide the sidebar. */
+ }
+
+ .requests-menu-status-and-method {
+ width: 14vw;
+ }
+
+ .requests-menu-file,
+ .requests-menu-domain {
+ width: 30vw;
+ min-width: 10em;
+ }
+
+ .requests-menu-type {
+ width: 8vw;
}
.requests-menu-size {
- border-width: 0px !important;
+ width: 16vw;
+ border-width: 0 !important;
box-shadow: none !important;
- /* !important are required here because Timeline is not visible and thus
- the right border and box-shadow of Size column should be hidden */
+ /* The "Timeline" header is not visible anymore, and thus the
+ right border and box-shadow of "Size" column should be hidden. */
+ }
+}
+
+@media (min-width: 701px) {
+ #network-table[type-overflows] .requests-menu-domain {
+ border-width: 0 !important;
+ box-shadow: none !important;
+ /* The "Type" header is not visible anymore, and thus the
+ right border and box-shadow of "Domain" column should be hidden. */
+ }
+
+ #network-table[domain-overflows] .requests-menu-file {
+ border-width: 0 !important;
+ box-shadow: none !important;
+ /* The "Domain" header is not visible anymore, and thus the
+ right border and box-shadow of "File" column should be hidden. */
}
}
diff --git a/browser/themes/windows/downloads/downloads-aero.css b/browser/themes/windows/downloads/downloads-aero.css
index b9848ac9bd6a..68dbfc1117dc 100644
--- a/browser/themes/windows/downloads/downloads-aero.css
+++ b/browser/themes/windows/downloads/downloads-aero.css
@@ -12,7 +12,7 @@
border-bottom: 1px solid hsl(213,40%,90%);
}
- #downloadsPanel:not([keyfocus]) > #downloadsListBox > richlistitem[type="download"][state="1"]:hover {
+ #downloadsPanel:not([keyfocus]) > #downloadsListBox > richlistitem[type="download"][state="1"][exists]:hover {
border: 1px solid hsl(213,45%,65%);
box-shadow: 0 0 0 1px hsla(0,0%,100%,.5) inset,
0 1px 0 hsla(0,0%,100%,.3) inset;
diff --git a/browser/themes/windows/downloads/downloads.css b/browser/themes/windows/downloads/downloads.css
index 8e65d5f2c0be..bd7503862798 100644
--- a/browser/themes/windows/downloads/downloads.css
+++ b/browser/themes/windows/downloads/downloads.css
@@ -166,7 +166,7 @@ richlistitem[type="download"]:first-child {
/*** Highlighted list items ***/
-#downloadsPanel:not([keyfocus]) > #downloadsListBox > richlistitem[type="download"][state="1"]:hover {
+#downloadsPanel:not([keyfocus]) > #downloadsListBox > richlistitem[type="download"][state="1"][exists]:hover {
border-radius: 3px;
border-top: 1px solid hsla(0,0%,100%,.2);
border-bottom: 1px solid hsla(0,0%,0%,.2);
diff --git a/browser/themes/windows/jar.mn b/browser/themes/windows/jar.mn
index 0d21ef168895..d3bbadbdf1d0 100644
--- a/browser/themes/windows/jar.mn
+++ b/browser/themes/windows/jar.mn
@@ -98,7 +98,6 @@ browser.jar:
skin/classic/browser/places/places.css (places/places.css)
* skin/classic/browser/places/organizer.css (places/organizer.css)
skin/classic/browser/places/bookmark.png (places/bookmark.png)
- skin/classic/browser/places/editBookmark.png (places/editBookmark.png)
skin/classic/browser/places/query.png (places/query.png)
skin/classic/browser/places/bookmarksMenu.png (places/bookmarksMenu.png)
skin/classic/browser/places/bookmarksToolbar.png (places/bookmarksToolbar.png)
@@ -357,7 +356,6 @@ browser.jar:
* skin/classic/aero/browser/places/places.css (places/places-aero.css)
* skin/classic/aero/browser/places/organizer.css (places/organizer-aero.css)
skin/classic/aero/browser/places/bookmark.png (places/bookmark.png)
- skin/classic/aero/browser/places/editBookmark.png (places/editBookmark.png)
skin/classic/aero/browser/places/query.png (places/query-aero.png)
skin/classic/aero/browser/places/bookmarksMenu.png (places/bookmarksMenu-aero.png)
skin/classic/aero/browser/places/bookmarksToolbar.png (places/bookmarksToolbar-aero.png)
diff --git a/browser/themes/windows/places/editBookmark.png b/browser/themes/windows/places/editBookmark.png
deleted file mode 100644
index fbca0523df16..000000000000
Binary files a/browser/themes/windows/places/editBookmark.png and /dev/null differ
diff --git a/config/system-headers b/config/system-headers
index 2ea8d2fa8682..c3906a82c6a8 100644
--- a/config/system-headers
+++ b/config/system-headers
@@ -1073,6 +1073,8 @@ conic/conicstatisticsevent.h
#endif
#if MOZ_NATIVE_LIBEVENT==1
event.h
+#else
+sys/event.h
#endif
#ifdef MOZ_ENABLE_LIBPROXY
proxy.h
diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h
index a5526b9117d4..53e1fde61e8d 100644
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -425,7 +425,7 @@ public:
*
* @return The document or null if no JS Context.
*/
- static nsIDOMDocument *GetDocumentFromCaller();
+ static nsIDocument* GetDocumentFromCaller();
/**
* Get the document through the JS context that's currently on the stack.
@@ -434,7 +434,7 @@ public:
*
* @return The document or null if no JS context
*/
- static nsIDOMDocument *GetDocumentFromContext();
+ static nsIDocument* GetDocumentFromContext();
// Check if a node is in the document prolog, i.e. before the document
// element.
diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp
index 5207f657b51f..4adfb3e69c3b 100644
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -1709,7 +1709,7 @@ nsContentUtils::GetWindowFromCaller()
return nullptr;
}
-nsIDOMDocument *
+nsIDocument*
nsContentUtils::GetDocumentFromCaller()
{
JSContext *cx = nullptr;
@@ -1725,10 +1725,10 @@ nsContentUtils::GetDocumentFromCaller()
return nullptr;
}
- return win->GetExtantDocument();
+ return win->GetExtantDoc();
}
-nsIDOMDocument *
+nsIDocument*
nsContentUtils::GetDocumentFromContext()
{
JSContext *cx = nullptr;
@@ -1740,7 +1740,7 @@ nsContentUtils::GetDocumentFromContext()
if (sgo) {
nsCOMPtr
pwin = do_QueryInterface(sgo);
if (pwin) {
- return pwin->GetExtantDocument();
+ return pwin->GetExtantDoc();
}
}
}
diff --git a/content/base/src/nsDOMFile.cpp b/content/base/src/nsDOMFile.cpp
index 10490dc1b940..ac82f1868ed0 100644
--- a/content/base/src/nsDOMFile.cpp
+++ b/content/base/src/nsDOMFile.cpp
@@ -260,8 +260,7 @@ nsDOMFileBase::MozSlice(int64_t aStart, int64_t aEnd,
if (sgo) {
nsCOMPtr window = do_QueryInterface(sgo);
if (window) {
- nsCOMPtr document =
- do_QueryInterface(window->GetExtantDocument());
+ nsCOMPtr document = window->GetExtantDoc();
if (document) {
document->WarnOnceAbout(nsIDocument::eMozSlice);
}
@@ -276,7 +275,7 @@ nsDOMFileBase::GetInternalStream(nsIInputStream **aStream)
{
// Must be overridden
NS_NOTREACHED("Must override GetInternalStream");
-
+
return NS_ERROR_NOT_IMPLEMENTED;
}
diff --git a/content/base/src/nsDOMMutationObserver.h b/content/base/src/nsDOMMutationObserver.h
index a9694ad82342..f778942ecc6b 100644
--- a/content/base/src/nsDOMMutationObserver.h
+++ b/content/base/src/nsDOMMutationObserver.h
@@ -408,7 +408,7 @@ protected:
bool Suppressed()
{
if (mOwner) {
- nsCOMPtr d = do_QueryInterface(mOwner->GetExtantDocument());
+ nsCOMPtr d = mOwner->GetExtantDoc();
return d && d->IsInSyncOperation();
}
return false;
diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp
index 1259e9b15ec9..b29df07f304c 100644
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -2373,7 +2373,7 @@ CSPErrorQueue::Flush(nsIDocument* aDocument)
for (uint32_t i = 0; i < mErrors.Length(); i++) {
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
"CSP", aDocument,
- nsContentUtils::eDOM_PROPERTIES,
+ nsContentUtils::eSECURITY_PROPERTIES,
mErrors[i]);
}
mErrors.Clear();
@@ -2530,22 +2530,11 @@ nsDocument::InitCSP(nsIChannel* aChannel)
// If the old header is present, warn that it will be deprecated.
if (!cspOldHeaderValue.IsEmpty() || !cspOldROHeaderValue.IsEmpty()) {
- nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
- "CSP", this,
- nsContentUtils::eDOM_PROPERTIES,
- "OldCSPHeaderDeprecated");
-
- // Additionally log deprecated warning to Web Console.
mCSPWebConsoleErrorQueue.Add("OldCSPHeaderDeprecated");
// Also, if the new headers AND the old headers were present, warn
// that the old headers will be ignored.
if (cspSpecCompliant) {
- nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
- "CSP", this,
- nsContentUtils::eDOM_PROPERTIES,
- "BothCSPHeadersPresent");
- // Additionally log to Web Console.
mCSPWebConsoleErrorQueue.Add("BothCSPHeadersPresent");
}
}
@@ -2582,11 +2571,6 @@ nsDocument::InitCSP(nsIChannel* aChannel)
// CSP policies are present since CSP only allows one policy and it can't
// be partially report-only.
if (applyAppDefaultCSP || applyCSPFromHeader) {
- nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
- "CSP", this,
- nsContentUtils::eDOM_PROPERTIES,
- "ReportOnlyCSPIgnored");
- // Additionally log to Web Console.
mCSPWebConsoleErrorQueue.Add("ReportOnlyCSPIgnored");
#ifdef PR_LOGGING
PR_LOG(gCspPRLog, PR_LOG_DEBUG,
@@ -6239,8 +6223,6 @@ nsDocument::GetAnimationController()
return mAnimationController;
}
-static const char* dirAttributes[] = { "ltr", "rtl", "auto", 0 };
-
/**
* Retrieve the "direction" property of the document.
*
@@ -6259,14 +6241,7 @@ nsIDocument::GetDir(nsAString& aDirection) const
aDirection.Truncate();
Element* rootElement = GetHtmlElement();
if (rootElement) {
- nsAutoString dir;
- rootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::dir, dir);
- for (uint32_t i = 0; dirAttributes[i]; ++i) {
- if (dir.LowerCaseEqualsASCII(dirAttributes[i])) {
- aDirection.AssignASCII(dirAttributes[i]);
- return;
- }
- }
+ static_cast(rootElement)->GetDir(aDirection);
}
}
@@ -11261,7 +11236,7 @@ nsAutoSyncOperation::nsAutoSyncOperation(nsIDocument* aDoc)
win->GetTop(getter_AddRefs(topWindow));
nsCOMPtr top = do_QueryInterface(topWindow);
if (top) {
- nsCOMPtr doc = do_QueryInterface(top->GetExtantDocument());
+ nsCOMPtr doc = top->GetExtantDoc();
MarkDocumentTreeToBeInSyncOperation(doc, &mDocuments);
}
}
diff --git a/content/base/src/nsFrameLoader.cpp b/content/base/src/nsFrameLoader.cpp
index 0dbdc172c92b..6c24715495ab 100644
--- a/content/base/src/nsFrameLoader.cpp
+++ b/content/base/src/nsFrameLoader.cpp
@@ -1095,10 +1095,8 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
SameCOMIdentity(otherChromeEventHandler, otherContent),
"How did that happen, exactly?");
- nsCOMPtr ourChildDocument =
- do_QueryInterface(ourWindow->GetExtantDocument());
- nsCOMPtr otherChildDocument =
- do_QueryInterface(otherWindow->GetExtantDocument());
+ nsCOMPtr ourChildDocument = ourWindow->GetExtantDoc();
+ nsCOMPtr otherChildDocument = otherWindow ->GetExtantDoc();
if (!ourChildDocument || !otherChildDocument) {
// This shouldn't be happening
return NS_ERROR_NOT_IMPLEMENTED;
diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp
index 759b0b1d9530..831be08a7052 100644
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -745,6 +745,8 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading)
// Flush layout so that the frame is created if possible and the plugin is
// initialized with the latest information.
doc->FlushPendingNotifications(Flush_Layout);
+ // Flushing layout may have re-entered and loaded something underneath us
+ NS_ENSURE_TRUE(mInstantiating, NS_OK);
if (!thisContent->GetPrimaryFrame()) {
LOG(("OBJLC [%p]: Not instantiating plugin with no frame", this));
@@ -767,16 +769,42 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading)
appShell->SuspendNative();
}
+ nsRefPtr newOwner;
rv = pluginHost->InstantiatePluginInstance(mContentType.get(),
mURI.get(), this,
- getter_AddRefs(mInstanceOwner));
+ getter_AddRefs(newOwner));
+ // XXX(johns): We don't suspend native inside stopping plugins...
if (appShell) {
appShell->ResumeNative();
}
- if (NS_FAILED(rv)) {
- return rv;
+ if (!mInstantiating || NS_FAILED(rv)) {
+ LOG(("OBJLC [%p]: Plugin instantiation failed or re-entered, "
+ "killing old instance", this));
+ // XXX(johns): This needs to be de-duplicated with DoStopPlugin, but we
+ // don't want to touch the protochain or delayed stop.
+ // (Bug 767635)
+ if (newOwner) {
+ nsRefPtr inst;
+ newOwner->GetInstance(getter_AddRefs(inst));
+ newOwner->SetFrame(nullptr);
+ if (inst) {
+ pluginHost->StopPluginInstance(inst);
+ }
+ newOwner->Destroy();
+ }
+ return NS_OK;
+ }
+
+ mInstanceOwner = newOwner;
+
+ // Ensure the frame did not change during instantiation re-entry (common).
+ // HasNewFrame would not have mInstanceOwner yet, so the new frame would be
+ // dangling. (Bug 854082)
+ nsIFrame* frame = thisContent->GetPrimaryFrame();
+ if (frame && mInstanceOwner) {
+ mInstanceOwner->SetFrame(static_cast(frame));
}
// Set up scripting interfaces.
@@ -1011,16 +1039,10 @@ nsObjectLoadingContent::HasNewFrame(nsIObjectFrame* aFrame)
}
// Otherwise, we're just changing frames
- mInstanceOwner->SetFrame(nullptr);
-
// Set up relationship between instance owner and frame.
nsObjectFrame *objFrame = static_cast(aFrame);
mInstanceOwner->SetFrame(objFrame);
- // Set up new frame to draw.
- objFrame->FixupWindow(objFrame->GetContentRectRelativeToSelf().Size());
- objFrame->InvalidateFrame();
-
return NS_OK;
}
@@ -2156,6 +2178,10 @@ nsObjectLoadingContent::UnloadObject(bool aResetState)
mOriginalContentType.Truncate();
}
+ // InstantiatePluginInstance checks this after re-entrant calls and aborts if
+ // it was cleared from under it
+ mInstantiating = false;
+
mScriptRequested = false;
// This call should be last as it may re-enter
@@ -2294,7 +2320,6 @@ nsObjectLoadingContent::PluginDestroyed()
// plugins in plugin host. Invalidate instance owner / prototype but otherwise
// don't take any action.
TeardownProtoChain();
- mInstanceOwner->SetFrame(nullptr);
mInstanceOwner->Destroy();
mInstanceOwner = nullptr;
return NS_OK;
@@ -2578,6 +2603,8 @@ nsObjectLoadingContent::StopPluginInstance()
CloseChannel();
}
+ // We detach the instance owner's frame before destruction, but don't destroy
+ // the instance owner until the plugin is stopped.
mInstanceOwner->SetFrame(nullptr);
bool delayedStop = false;
diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp
index aa552f135c0b..e36112e9018e 100644
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -390,7 +390,7 @@ nsXMLHttpRequest::InitParameters(bool aAnon, bool aSystem)
// Chrome is always allowed access, so do the permission check only
// for non-chrome pages.
if (!nsContentUtils::IsCallerChrome()) {
- nsCOMPtr doc = do_QueryInterface(window->GetExtantDocument());
+ nsCOMPtr doc = window->GetExtantDoc();
if (!doc) {
return;
}
@@ -560,7 +560,7 @@ static void LogMessage(const char* aWarning, nsPIDOMWindow* aWindow)
{
nsCOMPtr doc;
if (aWindow) {
- doc = do_QueryInterface(aWindow->GetExtantDocument());
+ doc = aWindow->GetExtantDoc();
}
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
"DOM", doc,
@@ -2861,7 +2861,7 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable& aBody)
nsCOMPtr suspendedWindow(do_QueryInterface(topWindow));
if (suspendedWindow &&
(suspendedWindow = suspendedWindow->GetCurrentInnerWindow())) {
- suspendedDoc = do_QueryInterface(suspendedWindow->GetExtantDocument());
+ suspendedDoc = suspendedWindow->GetExtantDoc();
if (suspendedDoc) {
suspendedDoc->SuppressEventHandling();
}
diff --git a/content/base/test/file_x-frame-options_main.html b/content/base/test/file_x-frame-options_main.html
index cefcc650f964..e6d7fec80e34 100644
--- a/content/base/test/file_x-frame-options_main.html
+++ b/content/base/test/file_x-frame-options_main.html
@@ -21,6 +21,8 @@ window.addEventListener('load', parent.testFramesLoaded, false);
+
+
diff --git a/content/media/webaudio/test/test_delayNodeWithGain.html b/content/media/webaudio/test/test_delayNodeWithGain.html
new file mode 100644
index 000000000000..9ae2a616639a
--- /dev/null
+++ b/content/media/webaudio/test/test_delayNodeWithGain.html
@@ -0,0 +1,62 @@
+
+
+
+ Test DelayNode with a GainNode
+
+
+
+
+
+
+
+
+
+
diff --git a/content/media/webaudio/test/test_gainNode.html b/content/media/webaudio/test/test_gainNode.html
index bdecacf6612b..c772811ce11e 100644
--- a/content/media/webaudio/test/test_gainNode.html
+++ b/content/media/webaudio/test/test_gainNode.html
@@ -3,6 +3,7 @@
Test GainNode
+
@@ -18,6 +19,10 @@ addLoadEvent(function() {
for (var i = 0; i < 2048; ++i) {
buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
}
+ var expectedBuffer = context.createBuffer(1, 2048, context.sampleRate);
+ for (var i = 0; i < 2048; ++i) {
+ expectedBuffer.getChannelData(0)[i] = buffer.getChannelData(0)[i] / 2;
+ }
var destination = context.destination;
@@ -31,7 +36,9 @@ addLoadEvent(function() {
source.buffer = buffer;
source.connect(gain);
- gain.connect(destination);
+ var sp = context.createScriptProcessor(2048, 1);
+ gain.connect(sp);
+ sp.connect(destination);
ok(gain.gain, "The audioparam member must exist");
is(gain.gain.value, 1.0, "Correct initial value");
@@ -41,14 +48,15 @@ addLoadEvent(function() {
is(gain.gain.defaultValue, 1.0, "Correct default value");
source.start(0);
- SimpleTest.executeSoon(function() {
- source.stop(0);
- source.disconnect();
- gain.disconnect();
+ sp.onaudioprocess = function(e) {
+ is(e.inputBuffer.numberOfChannels, 1, "Correct input channel count");
+ compareBuffers(e.inputBuffer.getChannelData(0), expectedBuffer.getChannelData(0));
+
+ sp.onaudioprocess = null;
SpecialPowers.clearUserPref("media.webaudio.enabled");
SimpleTest.finish();
- });
+ };
});
diff --git a/content/media/webaudio/test/webaudio.js b/content/media/webaudio/test/webaudio.js
index 22c9b95f4715..fb42a455b661 100644
--- a/content/media/webaudio/test/webaudio.js
+++ b/content/media/webaudio/test/webaudio.js
@@ -24,7 +24,7 @@ function expectTypeError(func) {
}
function fuzzyCompare(a, b) {
- return Math.abs(a - b) < 1e-5;
+ return Math.abs(a - b) < 5e-5;
}
function compareBuffers(buf1, buf2,
diff --git a/content/xbl/src/nsXBLProtoImplMethod.cpp b/content/xbl/src/nsXBLProtoImplMethod.cpp
index 9f001564e1ff..902dcc202917 100644
--- a/content/xbl/src/nsXBLProtoImplMethod.cpp
+++ b/content/xbl/src/nsXBLProtoImplMethod.cpp
@@ -312,7 +312,8 @@ nsXBLProtoImplAnonymousMethod::Execute(nsIContent* aBoundElement)
// Make sure to do this before entering the compartment, since pushing Push()
// may call JS_SaveFrameChain(), which puts us back in an unentered state.
nsCxPusher pusher;
- NS_ENSURE_STATE(pusher.Push(aBoundElement));
+ if (!pusher.Push(aBoundElement))
+ return NS_ERROR_UNEXPECTED;
MOZ_ASSERT(cx == nsContentUtils::GetCurrentJSContext());
JS::Rooted thisObject(cx, &v.toObject());
diff --git a/content/xml/document/src/XMLDocument.cpp b/content/xml/document/src/XMLDocument.cpp
index 443e899b6fb3..ed3deae6fab0 100644
--- a/content/xml/document/src/XMLDocument.cpp
+++ b/content/xml/document/src/XMLDocument.cpp
@@ -320,8 +320,7 @@ XMLDocument::Load(const nsAString& aUrl, ErrorResult& aRv)
ReportUseOfDeprecatedMethod(this, "UseOfDOM3LoadMethodWarning");
- nsCOMPtr callingDoc =
- do_QueryInterface(nsContentUtils::GetDocumentFromContext());
+ nsCOMPtr callingDoc = nsContentUtils::GetDocumentFromContext();
nsIURI *baseURI = mDocumentURI;
nsAutoCString charset;
diff --git a/content/xul/templates/src/nsXULTemplateBuilder.cpp b/content/xul/templates/src/nsXULTemplateBuilder.cpp
index 5401dd38604e..a397e73e60e0 100644
--- a/content/xul/templates/src/nsXULTemplateBuilder.cpp
+++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp
@@ -1074,8 +1074,7 @@ nsXULTemplateBuilder::Observe(nsISupports* aSubject,
if (!strcmp(aTopic, DOM_WINDOW_DESTROYED_TOPIC)) {
nsCOMPtr window = do_QueryInterface(aSubject);
if (window) {
- nsCOMPtr doc =
- do_QueryInterface(window->GetExtantDocument());
+ nsCOMPtr doc = window->GetExtantDoc();
if (doc && doc == mObservedDocument)
NodeWillBeDestroyed(doc);
}
diff --git a/docshell/base/nsDSURIContentListener.cpp b/docshell/base/nsDSURIContentListener.cpp
index 9d67f646e6ae..036a64a255d6 100644
--- a/docshell/base/nsDSURIContentListener.cpp
+++ b/docshell/base/nsDSURIContentListener.cpp
@@ -260,7 +260,7 @@ nsDSURIContentListener::SetParentContentListener(nsIURIContentListener*
return NS_OK;
}
-bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIRequest *request,
+bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChannel,
const nsAString& policy) {
static const char allowFrom[] = "allow-from";
const uint32_t allowFromLen = ArrayLength(allowFrom) - 1;
@@ -273,11 +273,6 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIRequest *request,
!isAllowFrom)
return true;
- nsCOMPtr httpChannel = do_QueryInterface(request);
- if (!httpChannel) {
- return true;
- }
-
nsCOMPtr uri;
httpChannel->GetURI(getter_AddRefs(uri));
@@ -402,7 +397,20 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIRequest *request,
// in the request (comma-separated in a header, multiple headers, etc).
bool nsDSURIContentListener::CheckFrameOptions(nsIRequest *request)
{
- nsCOMPtr httpChannel = do_QueryInterface(request);
+ nsresult rv;
+ nsCOMPtr chan = do_QueryInterface(request);
+ if (!chan) {
+ return true;
+ }
+
+ nsCOMPtr httpChannel = do_QueryInterface(chan);
+ if (!httpChannel) {
+ // check if it is hiding in a multipart channel
+ rv = mDocShell->GetHttpChannel(chan, getter_AddRefs(httpChannel));
+ if (NS_FAILED(rv))
+ return false;
+ }
+
if (!httpChannel) {
return true;
}
@@ -421,7 +429,7 @@ bool nsDSURIContentListener::CheckFrameOptions(nsIRequest *request)
nsCharSeparatedTokenizer tokenizer(xfoHeaderValue, ',');
while (tokenizer.hasMoreTokens()) {
const nsSubstring& tok = tokenizer.nextToken();
- if (!CheckOneFrameOptionsPolicy(request, tok)) {
+ if (!CheckOneFrameOptionsPolicy(httpChannel, tok)) {
// cancel the load and display about:blank
httpChannel->Cancel(NS_BINDING_ABORTED);
if (mDocShell) {
diff --git a/docshell/base/nsDSURIContentListener.h b/docshell/base/nsDSURIContentListener.h
index 5247c17fd382..1c17a793f363 100644
--- a/docshell/base/nsDSURIContentListener.h
+++ b/docshell/base/nsDSURIContentListener.h
@@ -14,6 +14,7 @@
class nsDocShell;
class nsIWebNavigationInfo;
+class nsIHttpChannel;
class nsDSURIContentListener :
public nsIURIContentListener,
@@ -38,7 +39,7 @@ protected:
// Determine if X-Frame-Options allows content to be framed
// as a subdocument
bool CheckFrameOptions(nsIRequest* request);
- bool CheckOneFrameOptionsPolicy(nsIRequest* request,
+ bool CheckOneFrameOptionsPolicy(nsIHttpChannel* httpChannel,
const nsAString& policy);
enum XFOHeader {
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
index b0a4945a5f92..ffdc798c1f1c 100644
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -7048,10 +7048,7 @@ nsDocShell::CanSavePresentation(uint32_t aLoadType,
// If the document does not want its presentation cached, then don't.
nsCOMPtr doc = mScriptGlobal->GetExtantDoc();
- if (!doc || !doc->CanSavePresentation(aNewRequest))
- return false;
-
- return true;
+ return doc && doc->CanSavePresentation(aNewRequest);
}
void
@@ -8677,8 +8674,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
// document in |newWin|, if any.
nsCOMPtr piNewWin = do_QueryInterface(newWin);
if (piNewWin) {
- nsCOMPtr newDoc =
- do_QueryInterface(piNewWin->GetExtantDocument());
+ nsCOMPtr newDoc = piNewWin->GetExtantDoc();
if (!newDoc || newDoc->IsInitialDocument()) {
isNewWindow = true;
aFlags |= INTERNAL_LOAD_FLAGS_FIRST_LOAD;
diff --git a/docshell/base/nsWebNavigationInfo.cpp b/docshell/base/nsWebNavigationInfo.cpp
index 6be73dce4b7b..4ff477fbd652 100644
--- a/docshell/base/nsWebNavigationInfo.cpp
+++ b/docshell/base/nsWebNavigationInfo.cpp
@@ -57,7 +57,7 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
if (pluginHost) {
// false will ensure that currently running plugins will not
// be shut down
- rv = pluginHost->ReloadPlugins(false);
+ rv = pluginHost->ReloadPlugins();
if (NS_SUCCEEDED(rv)) {
// OK, we reloaded plugins and there were new ones
// (otherwise NS_ERROR_PLUGINS_PLUGINSNOTCHANGED would have
diff --git a/dom/apps/src/Webapps.jsm b/dom/apps/src/Webapps.jsm
index a1c05f60c570..c751670b644a 100644
--- a/dom/apps/src/Webapps.jsm
+++ b/dom/apps/src/Webapps.jsm
@@ -1969,6 +1969,7 @@ this.DOMApplicationRegistry = {
_nextLocalId: function() {
let id = Services.prefs.getIntPref("dom.mozApps.maxLocalId") + 1;
Services.prefs.setIntPref("dom.mozApps.maxLocalId", id);
+ Services.prefs.savePrefFile(null);
return id;
},
diff --git a/dom/audiochannel/AudioChannelAgent.cpp b/dom/audiochannel/AudioChannelAgent.cpp
index feadde9fe9f0..9b0cfaca4540 100644
--- a/dom/audiochannel/AudioChannelAgent.cpp
+++ b/dom/audiochannel/AudioChannelAgent.cpp
@@ -8,7 +8,15 @@
using namespace mozilla::dom;
-NS_IMPL_ISUPPORTS1(AudioChannelAgent, nsIAudioChannelAgent)
+NS_IMPL_CYCLE_COLLECTION_1(AudioChannelAgent, mCallback)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AudioChannelAgent)
+ NS_INTERFACE_MAP_ENTRY(nsIAudioChannelAgent)
+ NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_CYCLE_COLLECTING_ADDREF(AudioChannelAgent)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(AudioChannelAgent)
AudioChannelAgent::AudioChannelAgent()
: mAudioChannelType(AUDIO_AGENT_CHANNEL_ERROR)
diff --git a/dom/audiochannel/AudioChannelAgent.h b/dom/audiochannel/AudioChannelAgent.h
index 9704561f77fd..a4900f72b337 100644
--- a/dom/audiochannel/AudioChannelAgent.h
+++ b/dom/audiochannel/AudioChannelAgent.h
@@ -8,6 +8,7 @@
#define mozilla_dom_audio_channel_agent_h__
#include "nsIAudioChannelAgent.h"
+#include "nsCycleCollectionParticipant.h"
#include "nsCOMPtr.h"
#include "nsWeakPtr.h"
@@ -23,9 +24,11 @@ namespace dom {
class AudioChannelAgent : public nsIAudioChannelAgent
{
public:
- NS_DECL_ISUPPORTS
+ NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIAUDIOCHANNELAGENT
+ NS_DECL_CYCLE_COLLECTION_CLASS(AudioChannelAgent)
+
AudioChannelAgent();
virtual void NotifyAudioChannelStateChanged();
diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp
index ecf11f09c01b..4d4eaa61bab5 100644
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -481,7 +481,7 @@ Navigator::GetCookieEnabled(bool* aCookieEnabled)
return NS_OK;
}
- nsCOMPtr doc = do_QueryInterface(win->GetExtantDocument());
+ nsCOMPtr doc = win->GetExtantDoc();
if (!doc) {
return NS_OK;
}
@@ -626,17 +626,16 @@ namespace {
class VibrateWindowListener : public nsIDOMEventListener
{
public:
- VibrateWindowListener(nsIDOMWindow *aWindow, nsIDOMDocument *aDocument)
+ VibrateWindowListener(nsIDOMWindow* aWindow, nsIDocument* aDocument)
{
mWindow = do_GetWeakReference(aWindow);
mDocument = do_GetWeakReference(aDocument);
- nsCOMPtr target = do_QueryInterface(aDocument);
NS_NAMED_LITERAL_STRING(visibilitychange, "visibilitychange");
- target->AddSystemEventListener(visibilitychange,
- this, /* listener */
- true, /* use capture */
- false /* wants untrusted */);
+ aDocument->AddSystemEventListener(visibilitychange,
+ this, /* listener */
+ true, /* use capture */
+ false /* wants untrusted */);
}
virtual ~VibrateWindowListener()
@@ -754,12 +753,9 @@ Navigator::Vibrate(const JS::Value& aPattern, JSContext* cx)
nsCOMPtr win = do_QueryReferent(mWindow);
NS_ENSURE_TRUE(win, NS_OK);
- nsCOMPtr domDoc = win->GetExtantDocument();
- NS_ENSURE_TRUE(domDoc, NS_ERROR_FAILURE);
-
- bool hidden = true;
- domDoc->GetHidden(&hidden);
- if (hidden) {
+ nsCOMPtr doc = win->GetExtantDoc();
+ NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
+ if (doc->Hidden()) {
// Hidden documents cannot start or stop a vibration.
return NS_OK;
}
@@ -819,7 +815,7 @@ Navigator::Vibrate(const JS::Value& aPattern, JSContext* cx)
else {
gVibrateWindowListener->RemoveListener();
}
- gVibrateWindowListener = new VibrateWindowListener(win, domDoc);
+ gVibrateWindowListener = new VibrateWindowListener(win, doc);
nsCOMPtr domWindow =
do_QueryInterface(static_cast(win));
diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp
index fd36a09d4a14..f71dc86d2df1 100644
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -3268,7 +3268,7 @@ nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSHandleObject obj,
// The rest of this function is for HTML documents only.
//
nsCOMPtr htmlDoc =
- do_QueryInterface(win->GetExtantDocument());
+ do_QueryInterface(win->GetExtantDoc());
if (!htmlDoc)
return true;
nsHTMLDocument *document = static_cast(htmlDoc.get());
@@ -6200,7 +6200,7 @@ nsDocumentSH::PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
- nsIDOMDocument* currentDoc = win->GetExtantDocument();
+ nsIDocument* currentDoc = win->GetExtantDoc();
if (SameCOMIdentity(doc, currentDoc)) {
jsval winVal;
diff --git a/dom/base/nsDOMException.cpp b/dom/base/nsDOMException.cpp
index c203bac61ac7..3f9f710cb5a6 100644
--- a/dom/base/nsDOMException.cpp
+++ b/dom/base/nsDOMException.cpp
@@ -183,8 +183,7 @@ nsDOMException::GetCode(uint16_t* aCode)
// Warn only when the code was changed (other than DOM Core)
// or the code is useless (zero)
if (NS_ERROR_GET_MODULE(mResult) != NS_ERROR_MODULE_DOM || !mCode) {
- nsCOMPtr doc =
- do_QueryInterface(nsContentUtils::GetDocumentFromCaller());
+ nsCOMPtr doc = nsContentUtils::GetDocumentFromCaller();
if (doc) {
doc->WarnOnceAbout(nsIDocument::eDOMExceptionCode);
}
diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp
index b7556076478c..a5e7c4c2530d 100644
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -188,14 +188,14 @@ nsDOMWindowUtils::GetDocumentMetadata(const nsAString& aName,
nsCOMPtr window = do_QueryReferent(mWindow);
if (window) {
- nsCOMPtr doc(do_QueryInterface(window->GetExtantDocument()));
+ nsCOMPtr doc = window->GetExtantDoc();
if (doc) {
nsCOMPtr name = do_GetAtom(aName);
doc->GetHeaderData(name, aValue);
return NS_OK;
}
}
-
+
aValue.Truncate();
return NS_OK;
}
@@ -266,7 +266,7 @@ nsDOMWindowUtils::GetViewportInfo(uint32_t aDisplayWidth,
nsCOMPtr window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
- nsCOMPtr doc(do_QueryInterface(window->GetExtantDocument()));
+ nsCOMPtr doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
nsViewportInfo info = nsContentUtils::GetViewportInfo(doc, aDisplayWidth, aDisplayHeight);
@@ -1247,7 +1247,7 @@ nsDOMWindowUtils::ElementFromPoint(float aX, float aY,
nsCOMPtr window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
- nsCOMPtr doc(do_QueryInterface(window->GetExtantDocument()));
+ nsCOMPtr doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
Element* el =
@@ -1272,7 +1272,7 @@ nsDOMWindowUtils::NodesFromRect(float aX, float aY,
nsCOMPtr window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
- nsCOMPtr doc(do_QueryInterface(window->GetExtantDocument()));
+ nsCOMPtr doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
return doc->NodesFromRectHelper(aX, aY, aTopSize, aRightSize, aBottomSize, aLeftSize,
@@ -1424,7 +1424,7 @@ nsDOMWindowUtils::SuppressEventHandling(bool aSuppress)
nsCOMPtr window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
- nsCOMPtr doc(do_QueryInterface(window->GetExtantDocument()));
+ nsCOMPtr doc = window->GetExtantDoc();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
if (aSuppress) {
@@ -1446,7 +1446,7 @@ nsDOMWindowUtils::GetScrollXY(bool aFlushLayout, int32_t* aScrollX, int32_t* aSc
nsCOMPtr window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
- nsCOMPtr doc(do_QueryInterface(window->GetExtantDocument()));
+ nsCOMPtr doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
if (aFlushLayout) {
@@ -2460,15 +2460,15 @@ nsDOMWindowUtils::GetCursorType(int16_t *aCursor)
NS_ENSURE_ARG_POINTER(aCursor);
nsCOMPtr window = do_QueryReferent(mWindow);
- NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
+ NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
bool isSameDoc = false;
- nsCOMPtr doc(do_QueryInterface(window->GetExtantDocument()));
+ nsCOMPtr doc = window->GetExtantDoc();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
do {
- if (nsEventStateManager::sMouseOverDocument == doc.get()) {
+ if (nsEventStateManager::sMouseOverDocument == doc) {
isSameDoc = true;
break;
}
@@ -2937,17 +2937,13 @@ nsDOMWindowUtils::GetPlugins(JSContext* cx, JS::Value* aPlugins)
nsCOMPtr window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
- nsIDOMDocument* ddoc = window->GetExtantDocument();
-
- nsresult rv;
- nsCOMPtr doc = do_QueryInterface(ddoc, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
+ nsCOMPtr doc = window->GetExtantDoc();
nsTArray plugins;
doc->GetPlugins(plugins);
JSObject* jsPlugins = nullptr;
- rv = nsTArrayToJSArray(cx, plugins, &jsPlugins);
+ nsresult rv = nsTArrayToJSArray(cx, plugins, &jsPlugins);
NS_ENSURE_SUCCESS(rv, rv);
*aPlugins = OBJECT_TO_JSVAL(jsPlugins);
@@ -3014,7 +3010,7 @@ nsDOMWindowUtils::RemoteFrameFullscreenChanged(nsIDOMElement* aFrameElement,
nsCOMPtr window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
- nsCOMPtr doc(do_QueryInterface(window->GetExtantDocument()));
+ nsCOMPtr doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
doc->RemoteFrameFullscreenChanged(aFrameElement, aNewOrigin);
@@ -3031,7 +3027,7 @@ nsDOMWindowUtils::RemoteFrameFullscreenReverted()
nsCOMPtr window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
- nsCOMPtr doc(do_QueryInterface(window->GetExtantDocument()));
+ nsCOMPtr doc = window->GetExtantDoc();
NS_ENSURE_STATE(doc);
doc->RemoteFrameFullscreenReverted();
diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
index bbac0e89bf2b..9d62e6c7346c 100644
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -168,6 +168,7 @@
#endif
#include "xpcprivate.h"
+#include "nsDOMEvent.h"
#ifdef NS_PRINTING
#include "nsIPrintSettings.h"
@@ -1213,7 +1214,6 @@ nsGlobalWindow::~nsGlobalWindow()
}
}
- mDocument = nullptr; // Forces Release
mDoc = nullptr;
NS_ASSERTION(!mArguments, "mArguments wasn't cleaned up properly!");
@@ -1465,9 +1465,7 @@ nsGlobalWindow::FreeInnerObjects()
mScreen = nullptr;
}
- if (mDocument) {
- NS_ASSERTION(mDoc, "Why is mDoc null?");
-
+ if (mDoc) {
// Remember the document's principal and URI.
mDocumentPrincipal = mDoc->NodePrincipal();
mDocumentURI = mDoc->GetDocumentURI();
@@ -1475,7 +1473,6 @@ nsGlobalWindow::FreeInnerObjects()
}
// Remove our reference to the document and the document principal.
- mDocument = nullptr;
mDoc = nullptr;
mFocusedNode = nullptr;
@@ -1647,7 +1644,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow)
// Traverse stuff from nsPIDOMWindow
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentTarget)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrameElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFocusedNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAudioContexts)
@@ -1694,7 +1690,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
// Unlink stuff from nsPIDOMWindow
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentTarget)
- NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrameElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFocusedNode)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAudioContexts)
@@ -2143,8 +2138,8 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
}
NS_ASSERTION(!GetCurrentInnerWindow() ||
- GetCurrentInnerWindow()->GetExtantDocument() == mDocument,
- "Uh, mDocument doesn't match the current inner window "
+ GetCurrentInnerWindow()->GetExtantDoc() == mDoc,
+ "Uh, mDoc doesn't match the current inner window "
"document!");
bool wouldReuseInnerWindow = WouldReuseInnerWindow(aDocument);
@@ -2156,7 +2151,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
return NS_ERROR_UNEXPECTED;
}
- nsCOMPtr oldDoc(do_QueryInterface(mDocument));
+ nsCOMPtr oldDoc = mDoc;
nsIScriptContext *scx = GetContextInternal();
NS_ENSURE_TRUE(scx, NS_ERROR_NOT_INITIALIZED);
@@ -2171,7 +2166,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
}
#endif
- if (!mDocument) {
+ if (!mDoc) {
// First document load.
// Get our private root. If it is equal to us, then we need to
@@ -2198,10 +2193,9 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
nsresult rv = NS_OK;
- // Set mDocument even if this is an outer window to avoid
+ // Set mDoc even if this is an outer window to avoid
// having to *always* reach into the inner window to find the
// document.
- mDocument = do_QueryInterface(aDocument);
mDoc = aDocument;
#ifdef DEBUG
@@ -2471,7 +2465,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
if (!aState) {
if (reUseInnerWindow) {
if (newInnerWindow->mDoc != aDocument) {
- newInnerWindow->mDocument = do_QueryInterface(aDocument);
newInnerWindow->mDoc = aDocument;
// We're reusing the inner window for a new document. In this
@@ -2559,12 +2552,12 @@ nsGlobalWindow::PreloadLocalStorage()
void
nsGlobalWindow::DispatchDOMWindowCreated()
{
- if (!mDoc || !mDocument) {
+ if (!mDoc) {
return;
}
// Fire DOMWindowCreated at chrome event listeners
- nsContentUtils::DispatchChromeEvent(mDoc, mDocument, NS_LITERAL_STRING("DOMWindowCreated"),
+ nsContentUtils::DispatchChromeEvent(mDoc, mDoc, NS_LITERAL_STRING("DOMWindowCreated"),
true /* bubbles */,
false /* not cancellable */);
@@ -2605,7 +2598,6 @@ nsGlobalWindow::InnerSetNewDocument(nsIDocument* aDocument)
}
#endif
- mDocument = do_QueryInterface(aDocument);
mDoc = aDocument;
mFocusedNode = nullptr;
mLocalStorage = nullptr;
@@ -2701,14 +2693,13 @@ nsGlobalWindow::DetachFromDocShell()
if (currentInner) {
NS_ASSERTION(mDoc, "Must have doc!");
-
+
// Remember the document's principal and URI.
mDocumentPrincipal = mDoc->NodePrincipal();
mDocumentURI = mDoc->GetDocumentURI();
mDocBaseURI = mDoc->GetDocBaseURI();
// Release our document reference
- mDocument = nullptr;
mDoc = nullptr;
mFocusedNode = nullptr;
}
@@ -3043,8 +3034,7 @@ nsGlobalWindow::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
aVisitor.mEvent->mFlags.mIsTrusted) {
// Execute bindingdetached handlers before we tear ourselves
// down.
- if (mDocument) {
- NS_ASSERTION(mDoc, "Must have doc");
+ if (mDoc) {
mDoc->BindingManager()->ExecuteDetachedHandlers();
}
mIsDocumentLoaded = false;
@@ -3229,7 +3219,7 @@ nsPIDOMWindow::MaybeCreateDoc()
{
MOZ_ASSERT(!mDoc);
if (nsIDocShell* docShell = GetDocShell()) {
- // Note that |document| here is the same thing as our mDocument, but we
+ // Note that |document| here is the same thing as our mDoc, but we
// don't have to explicitly set the member variable because the docshell
// has already called SetNewDocument().
nsCOMPtr document = do_GetInterface(docShell);
@@ -3745,9 +3735,8 @@ nsGlobalWindow::GetApplicationCache(nsIDOMOfflineResourceList **aApplicationCach
nsresult rv = webNav->GetCurrentURI(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
- nsCOMPtr doc = do_QueryInterface(mDocument);
nsCOMPtr manifestURI;
- nsContentUtils::GetOfflineAppManifest(doc, getter_AddRefs(manifestURI));
+ nsContentUtils::GetOfflineAppManifest(mDoc, getter_AddRefs(manifestURI));
nsRefPtr applicationCache =
new nsDOMOfflineResourceList(manifestURI, uri, this);
@@ -4520,8 +4509,7 @@ nsGlobalWindow::CheckSecurityWidthAndHeight(int32_t* aWidth, int32_t* aHeight)
#ifdef MOZ_XUL
if (!nsContentUtils::IsCallerChrome()) {
// if attempting to resize the window, hide any open popups
- nsCOMPtr doc(do_QueryInterface(mDocument));
- nsContentUtils::HidePopupsInDocument(doc);
+ nsContentUtils::HidePopupsInDocument(mDoc);
}
#endif
@@ -4586,8 +4574,7 @@ nsGlobalWindow::CheckSecurityLeftAndTop(int32_t* aLeft, int32_t* aTop)
if (!nsContentUtils::IsCallerChrome()) {
#ifdef MOZ_XUL
// if attempting to move the window, hide any open popups
- nsCOMPtr doc(do_QueryInterface(mDocument));
- nsContentUtils::HidePopupsInDocument(doc);
+ nsContentUtils::HidePopupsInDocument(mDoc);
#endif
nsGlobalWindow* rootWindow =
@@ -4798,8 +4785,7 @@ bool
nsGlobalWindow::DispatchCustomEvent(const char *aEventName)
{
bool defaultActionEnabled = true;
- nsCOMPtr doc(do_QueryInterface(mDocument));
- nsContentUtils::DispatchTrustedEvent(doc,
+ nsContentUtils::DispatchTrustedEvent(mDoc,
GetOuterWindow(),
NS_ConvertASCIItoUTF16(aEventName),
true, true, &defaultActionEnabled);
@@ -4961,8 +4947,7 @@ nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aRequireTrust)
// DOM full-screen mode and the user exits full-screen mode with
// the browser full-screen mode toggle keyboard-shortcut, we'll detect
// that and leave DOM API full-screen mode too.
- nsCOMPtr doc(do_QueryInterface(mDocument));
- nsIDocument::ExitFullscreen(doc, /* async */ false);
+ nsIDocument::ExitFullscreen(mDoc, /* async */ false);
}
if (!mWakeLock && mFullScreen) {
@@ -5516,10 +5501,8 @@ nsGlobalWindow::Focus()
mDocShell->GetItemType(&itemType);
if (itemType == nsIDocShellTreeItem::typeChrome &&
GetPrivateRoot() == static_cast(this) &&
- mDocument) {
- nsCOMPtr doc(do_QueryInterface(mDocument));
- NS_ASSERTION(doc, "Bogus doc?");
- nsIURI* ourURI = doc->GetDocumentURI();
+ mDoc) {
+ nsIURI* ourURI = mDoc->GetDocumentURI();
if (ourURI) {
lookForPresShell = !NS_IsAboutBlank(ourURI);
}
@@ -5542,8 +5525,7 @@ nsGlobalWindow::Focus()
if (!parentdoc)
return NS_OK;
- nsCOMPtr doc = do_QueryInterface(mDocument);
- nsIContent* frame = parentdoc->FindContentForSubDocument(doc);
+ nsIContent* frame = parentdoc->FindContentForSubDocument(mDoc);
nsCOMPtr frameElement = do_QueryInterface(frame);
if (frameElement) {
uint32_t flags = nsIFocusManager::FLAG_NOSCROLL;
@@ -5585,12 +5567,11 @@ nsGlobalWindow::Blur()
// if the root is focused, clear the focus
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
- nsCOMPtr doc = do_QueryInterface(mDocument);
- if (fm && mDocument) {
+ if (fm && mDoc) {
nsCOMPtr element;
fm->GetFocusedElementForWindow(this, false, nullptr, getter_AddRefs(element));
nsCOMPtr content = do_QueryInterface(element);
- if (content == doc->GetRootElement())
+ if (content == mDoc->GetRootElement())
fm->ClearFocus(this);
}
}
@@ -6099,7 +6080,7 @@ nsGlobalWindow::SetResizable(bool aResizable)
static void
ReportUseOfDeprecatedMethod(nsGlobalWindow* aWindow, const char* aWarning)
{
- nsCOMPtr doc = do_QueryInterface(aWindow->GetExtantDocument());
+ nsCOMPtr doc = aWindow->GetExtantDoc();
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
"DOM Events", doc,
nsContentUtils::eDOM_PROPERTIES,
@@ -6140,7 +6121,7 @@ nsGlobalWindow::DisableExternalCapture()
}
static
-bool IsPopupBlocked(nsIDOMDocument* aDoc)
+bool IsPopupBlocked(nsIDocument* aDoc)
{
nsCOMPtr pm =
do_GetService(NS_POPUPWINDOWMANAGER_CONTRACTID);
@@ -6149,20 +6130,18 @@ bool IsPopupBlocked(nsIDOMDocument* aDoc)
return false;
}
- bool blocked = true;
- nsCOMPtr doc(do_QueryInterface(aDoc));
-
- if (doc) {
- uint32_t permission = nsIPopupWindowManager::ALLOW_POPUP;
- pm->TestPermission(doc->NodePrincipal(), &permission);
- blocked = (permission == nsIPopupWindowManager::DENY_POPUP);
+ if (!aDoc) {
+ return true;
}
- return blocked;
+
+ uint32_t permission = nsIPopupWindowManager::ALLOW_POPUP;
+ pm->TestPermission(aDoc->NodePrincipal(), &permission);
+ return permission == nsIPopupWindowManager::DENY_POPUP;
}
/* static */
-void
-nsGlobalWindow::FirePopupBlockedEvent(nsIDOMDocument* aDoc,
+void
+nsGlobalWindow::FirePopupBlockedEvent(nsIDocument* aDoc,
nsIDOMWindow *aRequestingWindow, nsIURI *aPopupURI,
const nsAString &aPopupWindowName,
const nsAString &aPopupWindowFeatures)
@@ -6170,9 +6149,9 @@ nsGlobalWindow::FirePopupBlockedEvent(nsIDOMDocument* aDoc,
if (aDoc) {
// Fire a "DOMPopupBlocked" event so that the UI can hear about
// blocked popups.
+ nsCOMPtr doc = do_QueryInterface(aDoc);
nsCOMPtr event;
- aDoc->CreateEvent(NS_LITERAL_STRING("PopupBlockedEvents"),
- getter_AddRefs(event));
+ doc->CreateEvent(NS_LITERAL_STRING("PopupBlockedEvents"), getter_AddRefs(event));
if (event) {
nsCOMPtr pbev(do_QueryInterface(event));
pbev->InitPopupBlockedEvent(NS_LITERAL_STRING("DOMPopupBlocked"),
@@ -6181,9 +6160,8 @@ nsGlobalWindow::FirePopupBlockedEvent(nsIDOMDocument* aDoc,
aPopupWindowFeatures);
event->SetTrusted(true);
- nsCOMPtr targ(do_QueryInterface(aDoc));
bool defaultActionEnabled;
- targ->DispatchEvent(event, &defaultActionEnabled);
+ aDoc->DispatchEvent(event, &defaultActionEnabled);
}
}
}
@@ -6214,7 +6192,7 @@ nsGlobalWindow::CanSetProperty(const char *aPrefName)
bool
nsGlobalWindow::PopupWhitelisted()
{
- if (!IsPopupBlocked(mDocument))
+ if (!IsPopupBlocked(mDoc))
return true;
nsCOMPtr parent;
@@ -6324,9 +6302,11 @@ nsGlobalWindow::FireAbuseEvents(bool aBlocked, bool aWindow,
getter_AddRefs(popupURI));
// fire an event chock full of informative URIs
- if (aBlocked)
- FirePopupBlockedEvent(topDoc, this, popupURI, aPopupWindowName,
+ if (aBlocked) {
+ nsCOMPtr topDocument = do_QueryInterface(topDoc);
+ FirePopupBlockedEvent(topDocument, this, popupURI, aPopupWindowName,
aPopupWindowFeatures);
+ }
if (aWindow)
FirePopupWindowEvent(topDoc);
}
@@ -6756,12 +6736,13 @@ PostMessageEvent::Run()
}
// Create the event
- nsCOMPtr domDoc = do_QueryInterface(targetWindow->mDocument);
- if (!domDoc)
+ nsIDocument* doc = targetWindow->mDoc;
+ if (!doc)
return NS_OK;
+
+ nsCOMPtr domDoc = do_QueryInterface(doc);
nsCOMPtr event;
- domDoc->CreateEvent(NS_LITERAL_STRING("MessageEvent"),
- getter_AddRefs(event));
+ domDoc->CreateEvent(NS_LITERAL_STRING("MessageEvent"), getter_AddRefs(event));
if (!event)
return NS_OK;
@@ -6853,7 +6834,7 @@ nsGlobalWindow::PostMessageMoz(const JS::Value& aMessage,
}
else if (callerInnerWin) {
// otherwise use the URI of the document to generate origin
- nsCOMPtr doc = do_QueryInterface(callerInnerWin->GetExtantDocument());
+ nsCOMPtr doc = callerInnerWin->GetExtantDoc();
if (!doc)
return NS_OK;
callerOuterURI = doc->GetDocumentURI();
@@ -7173,7 +7154,7 @@ nsGlobalWindow::EnterModalState()
if (topWin->mModalStateDepth == 0) {
NS_ASSERTION(!mSuspendedDoc, "Shouldn't have mSuspendedDoc here!");
- mSuspendedDoc = do_QueryInterface(topWin->GetExtantDocument());
+ mSuspendedDoc = topWin->GetExtantDoc();
if (mSuspendedDoc && mSuspendedDoc->EventHandlingSuppressed()) {
mSuspendedDoc->SuppressEventHandling();
} else {
@@ -7286,8 +7267,7 @@ nsGlobalWindow::LeaveModalState(nsIDOMWindow *aCallerWin)
NS_WARNING("failed to dispatch pending timeout runnable");
if (mSuspendedDoc) {
- nsCOMPtr currentDoc =
- do_QueryInterface(topWin->GetExtantDocument());
+ nsCOMPtr currentDoc = topWin->GetExtantDoc();
mSuspendedDoc->UnsuppressEventHandlingAndFireEvents(currentDoc == mSuspendedDoc);
mSuspendedDoc = nullptr;
}
@@ -7777,7 +7757,7 @@ nsGlobalWindow::UpdateCommands(const nsAString& anAction)
return NS_OK;
nsCOMPtr xulDoc =
- do_QueryInterface(rootWindow->GetExtantDocument());
+ do_QueryInterface(rootWindow->GetExtantDoc());
// See if we contain a XUL document.
if (xulDoc) {
// Retrieve the command dispatcher and call updateCommands on it.
@@ -8694,11 +8674,10 @@ nsGlobalWindow::UpdateCanvasFocus(bool aFocusChanged, nsIContent* aNewContent)
return;
nsCOMPtr presShell = docShell->GetPresShell();
- if (!presShell || !mDocument)
+ if (!presShell || !mDoc)
return;
- nsCOMPtr doc(do_QueryInterface(mDocument));
- Element *rootElement = doc->GetRootElement();
+ Element *rootElement = mDoc->GetRootElement();
if (rootElement) {
if ((mHasFocus || aFocusChanged) &&
(mFocusedNode == rootElement || aNewContent == rootElement)) {
@@ -8836,8 +8815,8 @@ nsGlobalWindow::GetSessionStorage(nsIDOMStorage ** aSessionStorage)
*aSessionStorage = nullptr;
nsString documentURI;
- if (mDocument) {
- mDocument->GetDocumentURI(documentURI);
+ if (mDoc) {
+ mDoc->GetDocumentURI(documentURI);
}
// If the document has the sandboxed origin flag set
@@ -8921,8 +8900,8 @@ nsGlobalWindow::GetLocalStorage(nsIDOMStorage ** aLocalStorage)
}
nsString documentURI;
- if (mDocument) {
- mDocument->GetDocumentURI(documentURI);
+ if (mDoc) {
+ mDoc->GetDocumentURI(documentURI);
}
nsIDocShell* docShell = GetDocShell();
@@ -9095,9 +9074,8 @@ nsGlobalWindow::FireOfflineStatusEvent()
}
}
else {
- nsCOMPtr documentElement;
- mDocument->GetDocumentElement(getter_AddRefs(documentElement));
- if(documentElement) {
+ Element* documentElement = mDoc->GetDocumentElement();
+ if(documentElement) {
eventTarget = documentElement;
}
}
@@ -9939,10 +9917,7 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName,
#ifdef DEBUG_jst
{
nsCOMPtr pidomwin(do_QueryInterface(*aReturn));
-
- nsIDOMDocument *temp = pidomwin->GetExtantDocument();
-
- NS_ASSERTION(temp, "No document in new window!!!");
+ NS_ASSERTION(pidomwin->GetExtantDoc(), "No document in new window!!!");
}
#endif
@@ -9950,7 +9925,7 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName,
(*aReturn)->GetDocument(getter_AddRefs(doc));
}
}
-
+
if (checkForPopup) {
if (abuseLevel >= openControlled) {
nsGlobalWindow *opened = static_cast(*aReturn);
@@ -9998,7 +9973,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
// If we don't have a document (we could have been unloaded since
// the call to setTimeout was made), do nothing.
- if (!mDocument) {
+ if (!mDoc) {
return NS_OK;
}
@@ -10821,8 +10796,8 @@ nsGlobalWindow::BuildURIfromBase(const char *aURL, nsIURI **aBuiltURI,
// get JSContext
NS_ASSERTION(scx, "opening window missing its context");
- NS_ASSERTION(mDocument, "opening window missing its document");
- if (!scx || !mDocument)
+ NS_ASSERTION(mDoc, "opening window missing its document");
+ if (!scx || !mDoc)
return NS_ERROR_FAILURE;
nsCOMPtr chrome_win = do_QueryObject(this);
diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h
index 336896427fe3..5769b9bfb81b 100644
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -584,7 +584,7 @@ public:
mCleanedUp);
}
- static void FirePopupBlockedEvent(nsIDOMDocument* aDoc,
+ static void FirePopupBlockedEvent(nsIDocument* aDoc,
nsIDOMWindow *aRequestingWindow, nsIURI *aPopupURI,
const nsAString &aPopupWindowName,
const nsAString &aPopupWindowFeatures);
diff --git a/dom/base/nsGlobalWindowCommands.cpp b/dom/base/nsGlobalWindowCommands.cpp
index e9917bd6826d..a4571b4e4a54 100644
--- a/dom/base/nsGlobalWindowCommands.cpp
+++ b/dom/base/nsGlobalWindowCommands.cpp
@@ -345,7 +345,7 @@ nsClipboardCommand::IsCommandEnabled(const char* aCommandName, nsISupports *aCon
nsCOMPtr window = do_QueryInterface(aContext);
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
- nsCOMPtr doc = do_QueryInterface(window->GetExtantDocument());
+ nsCOMPtr doc = window->GetExtantDoc();
*outCmdEnabled = nsCopySupport::CanCopy(doc);
return NS_OK;
}
diff --git a/dom/base/nsHistory.cpp b/dom/base/nsHistory.cpp
index 65c8c5f4312b..d2f08a0a99b3 100644
--- a/dom/base/nsHistory.cpp
+++ b/dom/base/nsHistory.cpp
@@ -231,8 +231,7 @@ nsHistory::Go(int32_t aDelta)
// trick to work around gecko reflow bugs, and this should have
// the same effect.
- nsCOMPtr doc =
- do_QueryInterface(window->GetExtantDocument());
+ nsCOMPtr doc = window->GetExtantDoc();
nsIPresShell *shell;
nsPresContext *pcx;
@@ -338,8 +337,7 @@ nsHistory::GetState(nsIVariant **aState)
if (!nsContentUtils::CanCallerAccess(win->GetOuterWindow()))
return NS_ERROR_DOM_SECURITY_ERR;
- nsCOMPtr doc =
- do_QueryInterface(win->GetExtantDocument());
+ nsCOMPtr doc = win->GetExtantDoc();
if (!doc)
return NS_ERROR_NOT_AVAILABLE;
diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp
index 40e8d2e8a0f9..abeca0165732 100644
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -620,7 +620,7 @@ PrintWinURI(nsGlobalWindow *win)
return;
}
- nsCOMPtr doc = do_QueryInterface(win->GetExtantDocument());
+ nsCOMPtr doc = win->GetExtantDoc();
if (!doc) {
printf("No document in the window.\n");
return;
diff --git a/dom/base/nsJSTimeoutHandler.cpp b/dom/base/nsJSTimeoutHandler.cpp
index 740eb46c5375..d5d4147639f6 100644
--- a/dom/base/nsJSTimeoutHandler.cpp
+++ b/dom/base/nsJSTimeoutHandler.cpp
@@ -241,7 +241,7 @@ nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, bool *aIsInterval,
if (expr) {
// if CSP is enabled, and setTimeout/setInterval was called with a string
// or object, disable the registration and log an error
- nsCOMPtr doc = do_QueryInterface(aWindow->GetExtantDocument());
+ nsCOMPtr doc = aWindow->GetExtantDoc();
if (doc) {
nsCOMPtr csp;
diff --git a/dom/base/nsLocation.cpp b/dom/base/nsLocation.cpp
index e2d7b7820de7..6d26b31f1035 100644
--- a/dom/base/nsLocation.cpp
+++ b/dom/base/nsLocation.cpp
@@ -787,7 +787,7 @@ nsLocation::Reload(bool aForceget)
// page since some sites may use this trick to work around gecko
// reflow bugs, and this should have the same effect.
- nsCOMPtr doc(do_QueryInterface(window->GetExtantDocument()));
+ nsCOMPtr doc = window->GetExtantDoc();
nsIPresShell *shell;
nsPresContext *pcx;
diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h
index 92ec99f3b783..d891dca59561 100644
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -172,11 +172,6 @@ public:
virtual void MaybeUpdateTouchState() {}
virtual void UpdateTouchState() {}
- // GetExtantDocument provides a backdoor to the DOM GetDocument accessor
- nsIDOMDocument* GetExtantDocument() const
- {
- return mDocument;
- }
nsIDocument* GetExtantDoc() const
{
return mDoc;
@@ -675,8 +670,7 @@ protected:
// value on both the outer window and the current inner window. Make
// sure you keep them in sync!
nsCOMPtr mChromeEventHandler; // strong
- nsCOMPtr mDocument; // strong
- nsCOMPtr mDoc; // strong, for fast access
+ nsCOMPtr mDoc; // strong
// Cache the URI when mDoc is cleared.
nsCOMPtr mDocumentURI; // strong
nsCOMPtr mDocBaseURI; // strong
diff --git a/dom/base/nsPluginArray.cpp b/dom/base/nsPluginArray.cpp
index acda27a29b12..23a2537b395a 100644
--- a/dom/base/nsPluginArray.cpp
+++ b/dom/base/nsPluginArray.cpp
@@ -211,7 +211,7 @@ nsPluginArray::Refresh(bool aReloadDocuments)
if(mPluginHost) {
res = GetLength(¤tPluginCount);
NS_ENSURE_SUCCESS(res, res);
- nsresult reloadResult = mPluginHost->ReloadPlugins(aReloadDocuments);
+ nsresult reloadResult = mPluginHost->ReloadPlugins();
// currentPluginCount is as reported by nsPluginHost. mPluginCount is
// essentially a cache of this value, and may be out of date.
pluginsNotChanged = (reloadResult == NS_ERROR_PLUGINS_PLUGINSNOTCHANGED &&
diff --git a/dom/base/nsWindowMemoryReporter.cpp b/dom/base/nsWindowMemoryReporter.cpp
index 6fe4cc7accb4..eb70158f70af 100644
--- a/dom/base/nsWindowMemoryReporter.cpp
+++ b/dom/base/nsWindowMemoryReporter.cpp
@@ -58,7 +58,7 @@ GetWindowURI(nsIDOMWindow *aWindow)
nsCOMPtr pWindow = do_QueryInterface(aWindow);
NS_ENSURE_TRUE(pWindow, NULL);
- nsCOMPtr doc = do_QueryInterface(pWindow->GetExtantDocument());
+ nsCOMPtr doc = pWindow->GetExtantDoc();
nsCOMPtr uri;
if (doc) {
diff --git a/dom/bluetooth/BluetoothOppManager.cpp b/dom/bluetooth/BluetoothOppManager.cpp
index 7847e768d66d..aec315cdadfc 100644
--- a/dom/bluetooth/BluetoothOppManager.cpp
+++ b/dom/bluetooth/BluetoothOppManager.cpp
@@ -29,7 +29,9 @@
#include "nsIOutputStream.h"
#include "nsNetUtil.h"
-#define TARGET_FOLDER "/sdcard/downloads/bluetooth/"
+#define TARGET_ROOT "/sdcard/"
+#define TARGET_SUBDIR "downloads/bluetooth/"
+#define TARGET_FOLDER TARGET_ROOT TARGET_SUBDIR
USING_BLUETOOTH_NAMESPACE
using namespace mozilla;
@@ -561,6 +563,11 @@ BluetoothOppManager::CreateFile()
*/
f->GetLeafName(sFileName);
+ nsString fullFileName;
+ f->GetPath(fullFileName);
+ MOZ_ASSERT(StringBeginsWith(fullFileName, NS_LITERAL_STRING(TARGET_ROOT)));
+ nsDependentSubstring storagePath = Substring(fullFileName, strlen(TARGET_ROOT));
+
mDsFile = nullptr;
nsCOMPtr mimeSvc = do_GetService(NS_MIMESERVICE_CONTRACTID);
@@ -570,11 +577,11 @@ BluetoothOppManager::CreateFile()
if (NS_SUCCEEDED(rv)) {
if (StringBeginsWith(mimeType, NS_LITERAL_CSTRING("image/"))) {
- mDsFile = new DeviceStorageFile(NS_LITERAL_STRING("pictures"), f);
+ mDsFile = new DeviceStorageFile(NS_LITERAL_STRING("pictures"), storagePath);
} else if (StringBeginsWith(mimeType, NS_LITERAL_CSTRING("video/"))) {
- mDsFile = new DeviceStorageFile(NS_LITERAL_STRING("movies"), f);
+ mDsFile = new DeviceStorageFile(NS_LITERAL_STRING("movies"), storagePath);
} else if (StringBeginsWith(mimeType, NS_LITERAL_CSTRING("audio/"))) {
- mDsFile = new DeviceStorageFile(NS_LITERAL_STRING("music"), f);
+ mDsFile = new DeviceStorageFile(NS_LITERAL_STRING("music"), storagePath);
} else {
NS_WARNING("Couldn't recognize the mimetype of received file.");
}
diff --git a/dom/camera/GonkCameraControl.cpp b/dom/camera/GonkCameraControl.cpp
index bf5a08ffc886..85907d7ca0f0 100644
--- a/dom/camera/GonkCameraControl.cpp
+++ b/dom/camera/GonkCameraControl.cpp
@@ -905,7 +905,8 @@ nsGonkCameraControl::StartRecordingImpl(StartRecordingTask* aStartRecording)
*/
nsCOMPtr filename = aStartRecording->mFolder;
filename->AppendRelativePath(aStartRecording->mFilename);
- mVideoFile = new DeviceStorageFile(NS_LITERAL_STRING("videos"), filename);
+ mVideoFile = new DeviceStorageFile(NS_LITERAL_STRING("videos"),
+ aStartRecording->mFilename);
nsAutoCString nativeFilename;
filename->GetNativePath(nativeFilename);
diff --git a/dom/contacts/fallback/ContactDB.jsm b/dom/contacts/fallback/ContactDB.jsm
index b85815b104a5..0b2441632279 100644
--- a/dom/contacts/fallback/ContactDB.jsm
+++ b/dom/contacts/fallback/ContactDB.jsm
@@ -26,62 +26,73 @@ const CHUNK_SIZE = 20;
const CHUNK_INTERVAL = 500;
function ContactDispatcher(aContacts, aFullContacts, aCallback, aNewTxn, aClearDispatcher) {
- this.nextIndex = 0;
+ let nextIndex = 0;
+ let interval;
- this.cancelTimeout = function() {
- if (this.interval) {
- clearTimeout(this.interval);
- this.interval = null;
+ function cancelTimeout() {
+ if (interval) {
+ clearTimeout(interval);
+ interval = null;
}
- };
+ }
+ let sendChunk;
+ let count = 0;
if (aFullContacts) {
- this.sendChunk = function() {
- if (aContacts.length > 0) {
- aCallback(aContacts.splice(0, CHUNK_SIZE));
- this.interval = setTimeout(this.sendChunk, CHUNK_INTERVAL);
- } else {
- aCallback(null);
- this.cancelTimeout();
+ sendChunk = function() {
+ try {
+ if (aContacts.length > 0) {
+ aCallback(aContacts.splice(0, CHUNK_SIZE));
+ interval = setTimeout(sendChunk, CHUNK_INTERVAL);
+ } else {
+ aCallback(null);
+ cancelTimeout();
+ aClearDispatcher();
+ }
+ } catch (e) {
aClearDispatcher();
}
- }.bind(this);
+ }
} else {
this.count = 0;
- this.sendChunk = function() {
- let chunk = [];
- aNewTxn("readonly", STORE_NAME, function(txn, store) {
- for (let i = this.nextIndex; i < Math.min(this.nextIndex+CHUNK_SIZE, aContacts.length); ++i) {
- store.get(aContacts[i]).onsuccess = function(e) {
- chunk.push(e.target.result);
- this.count++;
- if (this.count == aContacts.length) {
- aCallback(chunk)
- aCallback(null);
- this.cancelTimeout();
- aClearDispatcher();
- } else if (chunk.length == CHUNK_SIZE) {
- aCallback(chunk);
- chunk.length = 0;
- this.nextIndex += CHUNK_SIZE;
- this.interval = setTimeout(this.sendChunk, CHUNK_INTERVAL);
+ sendChunk = function() {
+ try {
+ let chunk = [];
+ aNewTxn("readonly", STORE_NAME, function(txn, store) {
+ for (let i = nextIndex; i < Math.min(nextIndex+CHUNK_SIZE, aContacts.length); ++i) {
+ store.get(aContacts[i]).onsuccess = function(e) {
+ chunk.push(e.target.result);
+ count++;
+ if (count === aContacts.length) {
+ aCallback(chunk)
+ aCallback(null);
+ cancelTimeout();
+ aClearDispatcher();
+ } else if (chunk.length === CHUNK_SIZE) {
+ aCallback(chunk);
+ chunk.length = 0;
+ nextIndex += CHUNK_SIZE;
+ interval = setTimeout(this.sendChunk, CHUNK_INTERVAL);
+ }
}
- }.bind(this);
- }
- }.bind(this));
- }.bind(this);
+ }
+ });
+ } catch (e) {
+ aClearDispatcher();
+ }
+ }
}
- this.sendChunk(0);
+ sendChunk(0);
+
+ return {
+ sendNow: function() {
+ cancelTimeout();
+ interval = setTimeout(sendChunk, 0);
+ }
+ };
}
-ContactDispatcher.prototype = {
- sendNow: function() {
- this.cancelTimeout();
- this.interval = setTimeout(this.sendChunk, 0);
- }
-};
-
this.ContactDB = function ContactDB(aGlobal) {
if (DEBUG) debug("Constructor");
this._global = aGlobal;
diff --git a/dom/contacts/fallback/ContactService.jsm b/dom/contacts/fallback/ContactService.jsm
index b67633d217b7..73b76dfb4d5d 100644
--- a/dom/contacts/fallback/ContactService.jsm
+++ b/dom/contacts/fallback/ContactService.jsm
@@ -114,7 +114,12 @@ let ContactService = {
}
this._db.getAll(
function(aContacts) {
- mm.sendAsyncMessage("Contacts:GetAll:Next", {cursorId: msg.cursorId, contacts: aContacts});
+ try {
+ mm.sendAsyncMessage("Contacts:GetAll:Next", {cursorId: msg.cursorId, contacts: aContacts});
+ } catch (e) {
+ if (DEBUG) debug("Child is dead, DB should stop sending contacts");
+ throw e;
+ }
},
function(aErrorMsg) { mm.sendAsyncMessage("Contacts:Find:Return:KO", { errorMsg: aErrorMsg }); },
msg.findOptions, msg.cursorId);
diff --git a/dom/devicestorage/DeviceStorage.h b/dom/devicestorage/DeviceStorage.h
index 4d478306548a..78d0d64d9228 100644
--- a/dom/devicestorage/DeviceStorage.h
+++ b/dom/devicestorage/DeviceStorage.h
@@ -20,10 +20,18 @@ public:
nsCOMPtr mFile;
nsString mPath;
nsString mStorageType;
+ nsString mRootDir;
bool mEditable;
- DeviceStorageFile(const nsAString& aStorageType, nsIFile* aFile, const nsAString& aPath);
- DeviceStorageFile(const nsAString& aStorageType, nsIFile* aFile);
+ // Used when the path will be set later via SetPath.
+ DeviceStorageFile(const nsAString& aStorageType);
+ // Used for non-enumeration purposes.
+ DeviceStorageFile(const nsAString& aStorageType, const nsAString& aPath);
+ // Used for enumerations. When you call Enumerate, you can pass in a directory to enumerate
+ // and the results that are returned are relative to that directory, files related to an
+ // enumeration need to know the "root of the enumeration" directory.
+ DeviceStorageFile(const nsAString& aStorageType, const nsAString& aRootDir, const nsAString& aPath);
+
void SetPath(const nsAString& aPath);
void SetEditable(bool aEditable);
@@ -32,6 +40,7 @@ public:
// we want to make sure that the names of file can't reach
// outside of the type of storage the user asked for.
bool IsSafePath();
+ bool IsSafePath(const nsAString& aPath);
nsresult Remove();
nsresult Write(nsIInputStream* aInputStream);
@@ -40,10 +49,13 @@ public:
void collectFilesInternal(nsTArray > &aFiles, PRTime aSince, nsAString& aRootPath);
static void DirectoryDiskUsage(nsIFile* aFile, uint64_t* aSoFar, const nsAString& aStorageType);
-
+ static void GetRootDirectoryForType(const nsAString& aType,
+ const nsAString& aVolName,
+ nsIFile** aFile);
private:
+ void Init(const nsAString& aStorageType);
void NormalizeFilePath();
- void AppendRelativePath();
+ void AppendRelativePath(const nsAString& aPath);
};
/*
diff --git a/dom/devicestorage/DeviceStorageRequestChild.cpp b/dom/devicestorage/DeviceStorageRequestChild.cpp
index 9b5ef97f29ee..9c90591c3b42 100644
--- a/dom/devicestorage/DeviceStorageRequestChild.cpp
+++ b/dom/devicestorage/DeviceStorageRequestChild.cpp
@@ -100,14 +100,9 @@ DeviceStorageRequestChild::Recv__delete__(const DeviceStorageResponseValue& aVal
uint32_t count = r.paths().Length();
for (uint32_t i = 0; i < count; i++) {
- nsCOMPtr f;
- nsresult rv = NS_NewLocalFile(r.paths()[i].fullpath(), false, getter_AddRefs(f));
- if (NS_FAILED(rv)) {
- continue;
- }
-
- nsRefPtr dsf = new DeviceStorageFile(r.paths()[i].type(), f);
- dsf->SetPath(r.paths()[i].name());
+ nsRefPtr dsf = new DeviceStorageFile(r.type(),
+ r.relpath(),
+ r.paths()[i].name());
cursor->mFiles.AppendElement(dsf);
}
diff --git a/dom/devicestorage/DeviceStorageRequestParent.cpp b/dom/devicestorage/DeviceStorageRequestParent.cpp
index e046024e962f..8f438445614a 100644
--- a/dom/devicestorage/DeviceStorageRequestParent.cpp
+++ b/dom/devicestorage/DeviceStorageRequestParent.cpp
@@ -34,10 +34,7 @@ DeviceStorageRequestParent::Dispatch()
{
DeviceStorageAddParams p = mParams;
- nsCOMPtr f;
- NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
-
- nsRefPtr dsf = new DeviceStorageFile(p.type(), f);
+ nsRefPtr dsf = new DeviceStorageFile(p.type(), p.relpath());
BlobParent* bp = static_cast(p.blobParent());
nsCOMPtr blob = bp->GetBlob();
@@ -56,12 +53,7 @@ DeviceStorageRequestParent::Dispatch()
case DeviceStorageParams::TDeviceStorageGetParams:
{
DeviceStorageGetParams p = mParams;
-
- nsCOMPtr f;
- NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
-
- nsRefPtr dsf = new DeviceStorageFile(p.type(), f);
- dsf->SetPath(p.name());
+ nsRefPtr dsf = new DeviceStorageFile(p.type(), p.rootDir(), p.relpath());
nsRefPtr r = new ReadFileEvent(this, dsf);
nsCOMPtr target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
@@ -74,10 +66,7 @@ DeviceStorageRequestParent::Dispatch()
{
DeviceStorageDeleteParams p = mParams;
- nsCOMPtr f;
- NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
-
- nsRefPtr dsf = new DeviceStorageFile(p.type(), f);
+ nsRefPtr dsf = new DeviceStorageFile(p.type(), p.relpath());
nsRefPtr r = new DeleteFileEvent(this, dsf);
nsCOMPtr target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
@@ -90,10 +79,7 @@ DeviceStorageRequestParent::Dispatch()
{
DeviceStorageFreeSpaceParams p = mParams;
- nsCOMPtr f;
- NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
-
- nsRefPtr dsf = new DeviceStorageFile(p.type(), f);
+ nsRefPtr dsf = new DeviceStorageFile(p.type(), p.relpath());
nsRefPtr r = new FreeSpaceFileEvent(this, dsf);
nsCOMPtr target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
@@ -106,10 +92,7 @@ DeviceStorageRequestParent::Dispatch()
{
DeviceStorageUsedSpaceParams p = mParams;
- nsCOMPtr f;
- NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
-
- nsRefPtr dsf = new DeviceStorageFile(p.type(), f);
+ nsRefPtr dsf = new DeviceStorageFile(p.type(), p.relpath());
nsRefPtr r = new UsedSpaceFileEvent(this, dsf);
nsCOMPtr target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
@@ -121,7 +104,9 @@ DeviceStorageRequestParent::Dispatch()
case DeviceStorageParams::TDeviceStorageAvailableParams:
{
DeviceStorageAvailableParams p = mParams;
- nsRefPtr r = new PostAvailableResultEvent(this, p.fullpath());
+
+ nsRefPtr dsf = new DeviceStorageFile(p.type(), p.relpath());
+ nsRefPtr r = new PostAvailableResultEvent(this, dsf);
NS_DispatchToMainThread(r);
break;
}
@@ -129,11 +114,7 @@ DeviceStorageRequestParent::Dispatch()
case DeviceStorageParams::TDeviceStorageEnumerationParams:
{
DeviceStorageEnumerationParams p = mParams;
-
- nsCOMPtr f;
- NS_NewLocalFile(p.fullpath(), false, getter_AddRefs(f));
-
- nsRefPtr dsf = new DeviceStorageFile(p.type(), f);
+ nsRefPtr dsf = new DeviceStorageFile(p.type(), p.relpath(), NS_LITERAL_STRING(""));
nsRefPtr r = new EnumerateFileEvent(this, dsf, p.since());
nsCOMPtr target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
@@ -382,8 +363,12 @@ DeviceStorageRequestParent::PostBlobSuccessEvent::CancelableRun() {
}
DeviceStorageRequestParent::PostEnumerationSuccessEvent::PostEnumerationSuccessEvent(DeviceStorageRequestParent* aParent,
+ const nsAString& aStorageType,
+ const nsAString& aRelPath,
InfallibleTArray& aPaths)
: CancelableRunnable(aParent)
+ , mStorageType(aStorageType)
+ , mRelPath(aRelPath)
, mPaths(aPaths)
{
}
@@ -394,7 +379,7 @@ nsresult
DeviceStorageRequestParent::PostEnumerationSuccessEvent::CancelableRun() {
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
- EnumerationResponse response(mPaths);
+ EnumerationResponse response(mStorageType, mRelPath, mPaths);
unused << mParent->Send__delete__(mParent, response);
return NS_OK;
}
@@ -621,13 +606,11 @@ DeviceStorageRequestParent::EnumerateFileEvent::CancelableRun()
uint32_t count = files.Length();
for (uint32_t i = 0; i < count; i++) {
- nsString fullpath;
- files[i]->mFile->GetPath(fullpath);
- DeviceStorageFileValue dsvf(mFile->mStorageType, files[i]->mPath, fullpath);
+ DeviceStorageFileValue dsvf(files[i]->mPath);
values.AppendElement(dsvf);
}
- r = new PostEnumerationSuccessEvent(mParent, values);
+ r = new PostEnumerationSuccessEvent(mParent, mFile->mStorageType, mFile->mRootDir, values);
NS_DispatchToMainThread(r);
return NS_OK;
}
@@ -655,9 +638,9 @@ DeviceStorageRequestParent::PostPathResultEvent::CancelableRun()
}
DeviceStorageRequestParent::PostAvailableResultEvent::PostAvailableResultEvent(DeviceStorageRequestParent* aParent,
- const nsAString &aPath)
+ DeviceStorageFile* aFile)
: CancelableRunnable(aParent)
- , mPath(aPath)
+ , mFile(aFile)
{
}
@@ -673,7 +656,7 @@ DeviceStorageRequestParent::PostAvailableResultEvent::CancelableRun()
nsString state;
state.Assign(NS_LITERAL_STRING("available"));
#ifdef MOZ_WIDGET_GONK
- nsresult rv = GetSDCardStatus(mPath, state);
+ nsresult rv = GetSDCardStatus(mFile->mPath, state);
if (NS_FAILED(rv)) {
state.Assign(NS_LITERAL_STRING("unavailable"));
}
diff --git a/dom/devicestorage/DeviceStorageRequestParent.h b/dom/devicestorage/DeviceStorageRequestParent.h
index 7a124a71b56f..5aee8dce45ef 100644
--- a/dom/devicestorage/DeviceStorageRequestParent.h
+++ b/dom/devicestorage/DeviceStorageRequestParent.h
@@ -105,10 +105,15 @@ private:
class PostEnumerationSuccessEvent : public CancelableRunnable
{
public:
- PostEnumerationSuccessEvent(DeviceStorageRequestParent* aParent, InfallibleTArray& aPaths);
+ PostEnumerationSuccessEvent(DeviceStorageRequestParent* aParent,
+ const nsAString& aStorageType,
+ const nsAString& aRelPath,
+ InfallibleTArray& aPaths);
virtual ~PostEnumerationSuccessEvent();
virtual nsresult CancelableRun();
private:
+ const nsString mStorageType;
+ const nsString mRelPath;
InfallibleTArray mPaths;
};
@@ -211,11 +216,11 @@ private:
class PostAvailableResultEvent : public CancelableRunnable
{
public:
- PostAvailableResultEvent(DeviceStorageRequestParent* aParent, const nsAString& aPath);
+ PostAvailableResultEvent(DeviceStorageRequestParent* aParent, DeviceStorageFile* aFile);
virtual ~PostAvailableResultEvent();
virtual nsresult CancelableRun();
private:
- nsString mPath;
+ nsRefPtr mFile;
};
protected:
diff --git a/dom/devicestorage/PDeviceStorageRequest.ipdl b/dom/devicestorage/PDeviceStorageRequest.ipdl
index 6d0073f745f5..a79ae1b3e042 100644
--- a/dom/devicestorage/PDeviceStorageRequest.ipdl
+++ b/dom/devicestorage/PDeviceStorageRequest.ipdl
@@ -27,13 +27,13 @@ struct BlobResponse
struct DeviceStorageFileValue
{
- nsString type;
nsString name;
- nsString fullpath;
};
struct EnumerationResponse
{
+ nsString type;
+ nsString relpath;
DeviceStorageFileValue[] paths;
};
diff --git a/dom/devicestorage/nsDeviceStorage.cpp b/dom/devicestorage/nsDeviceStorage.cpp
index 1a0b19fc175e..9d8358b0f091 100644
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -67,6 +67,21 @@ using namespace mozilla::dom::devicestorage;
#include "nsDirectoryServiceDefs.h"
+class GlobalDirs : public RefCounted
+{
+public:
+#if !defined(MOZ_WIDGET_GONK)
+ nsCOMPtr pictures;
+ nsCOMPtr videos;
+ nsCOMPtr music;
+ nsCOMPtr apps;
+ nsCOMPtr sdcard;
+#endif
+ nsCOMPtr temp;
+};
+
+static StaticRefPtr sDirs;
+
nsAutoPtr DeviceStorageTypeChecker::sDeviceStorageTypeChecker;
DeviceStorageTypeChecker::DeviceStorageTypeChecker()
@@ -311,35 +326,182 @@ private:
};
DeviceStorageFile::DeviceStorageFile(const nsAString& aStorageType,
- nsIFile* aFile,
+ const nsAString& aRootDir,
+ const nsAString& aPath)
+ : mPath(aPath)
+ , mStorageType(aStorageType)
+ , mRootDir(aRootDir)
+ , mEditable(false)
+{
+ Init(aStorageType);
+ AppendRelativePath(mRootDir);
+ if (!mPath.EqualsLiteral("")) {
+ AppendRelativePath(mPath);
+ }
+ NormalizeFilePath();
+}
+
+DeviceStorageFile::DeviceStorageFile(const nsAString& aStorageType,
const nsAString& aPath)
: mPath(aPath)
, mStorageType(aStorageType)
, mEditable(false)
{
- NS_ASSERTION(aFile, "Must not create a DeviceStorageFile with a null nsIFile");
- // always take a clone
- nsCOMPtr file;
- aFile->Clone(getter_AddRefs(mFile));
-
- AppendRelativePath();
+ Init(aStorageType);
+ AppendRelativePath(aPath);
NormalizeFilePath();
+}
+
+DeviceStorageFile::DeviceStorageFile(const nsAString& aStorageType)
+ : mStorageType(aStorageType)
+ , mEditable(false)
+{
+ Init(aStorageType);
+}
+
+void
+DeviceStorageFile::Init(const nsAString& aStorageType)
+{
+ // The hard-coded sdcard below will change as part of bug 858416
+ DeviceStorageFile::GetRootDirectoryForType(aStorageType,
+ NS_LITERAL_STRING("sdcard"),
+ getter_AddRefs(mFile));
DebugOnly typeChecker = DeviceStorageTypeChecker::CreateOrGet();
NS_ASSERTION(typeChecker, "DeviceStorageTypeChecker is null");
}
-DeviceStorageFile::DeviceStorageFile(const nsAString& aStorageType, nsIFile* aFile)
- : mStorageType(aStorageType)
- , mEditable(false)
+static void
+InitDirs()
{
- NS_ASSERTION(aFile, "Must not create a DeviceStorageFile with a null nsIFile");
- // always take a clone
- nsCOMPtr file;
- aFile->Clone(getter_AddRefs(mFile));
+ if (sDirs) {
+ return;
+ }
+ NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
+ sDirs = new GlobalDirs;
+ ClearOnShutdown(&sDirs);
- DebugOnly typeChecker = DeviceStorageTypeChecker::CreateOrGet();
- NS_ASSERTION(typeChecker, "DeviceStorageTypeChecker is null");
+ nsCOMPtr dirService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
+ NS_ASSERTION(dirService, "Must have directory service");
+
+#if !defined(MOZ_WIDGET_GONK)
+
+#if defined (MOZ_WIDGET_COCOA)
+ dirService->Get(NS_OSX_PICTURE_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(sDirs->pictures));
+ dirService->Get(NS_OSX_MOVIE_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(sDirs->videos));
+ dirService->Get(NS_OSX_MUSIC_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(sDirs->music));
+#elif defined (XP_UNIX)
+ dirService->Get(NS_UNIX_XDG_PICTURES_DIR, NS_GET_IID(nsIFile), getter_AddRefs(sDirs->pictures));
+ dirService->Get(NS_UNIX_XDG_VIDEOS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(sDirs->videos));
+ dirService->Get(NS_UNIX_XDG_MUSIC_DIR, NS_GET_IID(nsIFile), getter_AddRefs(sDirs->music));
+#elif defined (XP_WIN)
+ dirService->Get(NS_WIN_PICTURES_DIR, NS_GET_IID(nsIFile), getter_AddRefs(sDirs->pictures));
+ dirService->Get(NS_WIN_VIDEOS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(sDirs->videos));
+ dirService->Get(NS_WIN_MUSIC_DIR, NS_GET_IID(nsIFile), getter_AddRefs(sDirs->music));
+#endif
+
+ dirService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile), getter_AddRefs(sDirs->apps));
+ if (sDirs->apps) {
+ sDirs->apps->AppendRelativeNativePath(NS_LITERAL_CSTRING("webapps"));
+ }
+
+ // Eventually, on desktop, we want to do something smarter -- for example,
+ // detect when an sdcard is inserted, and use that instead of this.
+ dirService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile), getter_AddRefs(sDirs->sdcard));
+ if (sDirs->sdcard) {
+ sDirs->sdcard->AppendRelativeNativePath(NS_LITERAL_CSTRING("fake-sdcard"));
+ }
+#endif // !MOZ_WIDGET_GONK
+
+ if (mozilla::Preferences::GetBool("device.storage.testing", false)) {
+ dirService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsIFile), getter_AddRefs(sDirs->temp));
+ if (sDirs->temp) {
+ sDirs->temp->AppendRelativeNativePath(NS_LITERAL_CSTRING("device-storage-testing"));
+ sDirs->temp->Create(nsIFile::DIRECTORY_TYPE, 0777);
+ sDirs->temp->Normalize();
+ }
+ }
+}
+
+void
+DeviceStorageFile::GetRootDirectoryForType(const nsAString &aType, const
+ nsAString &aVolName,
+ nsIFile** aFile)
+{
+ nsCOMPtr f;
+
+ InitDirs();
+
+#ifdef MOZ_WIDGET_GONK
+ nsString volMountPoint(NS_LITERAL_STRING("/sdcard"));
+ if (!aVolName.EqualsLiteral("")) {
+ nsCOMPtr vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID);
+ if (vs) {
+ nsresult rv;
+ nsCOMPtr vol;
+ rv = vs->GetVolumeByName(aVolName, getter_AddRefs(vol));
+ if (NS_SUCCEEDED(rv)) {
+ vol->GetMountPoint(volMountPoint);
+ }
+ }
+ }
+#endif
+
+ // Picture directory
+ if (aType.EqualsLiteral(DEVICESTORAGE_PICTURES)) {
+#ifdef MOZ_WIDGET_GONK
+ NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
+#else
+ f = sDirs->pictures;
+#endif
+ }
+
+ // Video directory
+ else if (aType.EqualsLiteral(DEVICESTORAGE_VIDEOS)) {
+#ifdef MOZ_WIDGET_GONK
+ NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
+#else
+ f = sDirs->videos;
+#endif
+ }
+
+ // Music directory
+ else if (aType.EqualsLiteral(DEVICESTORAGE_MUSIC)) {
+#ifdef MOZ_WIDGET_GONK
+ NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
+#else
+ f = sDirs->music;
+#endif
+ }
+
+ // Apps directory
+ else if (aType.EqualsLiteral(DEVICESTORAGE_APPS)) {
+#ifdef MOZ_WIDGET_GONK
+ NS_NewLocalFile(NS_LITERAL_STRING("/data"), false, getter_AddRefs(f));
+#else
+ f = sDirs->apps;
+#endif
+ }
+
+ // default SDCard
+ else if (aType.EqualsLiteral(DEVICESTORAGE_SDCARD)) {
+#ifdef MOZ_WIDGET_GONK
+ NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
+#else
+ f = sDirs->sdcard;
+#endif
+ }
+
+ // in testing, we default all device storage types to a temp directory
+ if (f && mozilla::Preferences::GetBool("device.storage.testing", false)) {
+ f = sDirs->temp;
+ }
+
+ if (f) {
+ f->Clone(aFile);
+ } else {
+ *aFile = nullptr;
+ }
}
void
@@ -357,21 +519,27 @@ DeviceStorageFile::SetEditable(bool aEditable) {
// outside of the type of storage the user asked for.
bool
DeviceStorageFile::IsSafePath()
+{
+ return IsSafePath(mRootDir) && IsSafePath(mPath);
+}
+
+bool
+DeviceStorageFile::IsSafePath(const nsAString& aPath)
{
nsAString::const_iterator start, end;
- mPath.BeginReading(start);
- mPath.EndReading(end);
+ aPath.BeginReading(start);
+ aPath.EndReading(end);
// if the path is a '~' or starts with '~/', return false.
NS_NAMED_LITERAL_STRING(tilde, "~");
NS_NAMED_LITERAL_STRING(tildeSlash, "~/");
- if (mPath.Equals(tilde) ||
- StringBeginsWith(mPath, tildeSlash)) {
+ if (aPath.Equals(tilde) ||
+ StringBeginsWith(aPath, tildeSlash)) {
NS_WARNING("Path name starts with tilde!");
return false;
}
// split on /. if any token is "", ., or .., return false.
- NS_ConvertUTF16toUTF8 cname(mPath);
+ NS_ConvertUTF16toUTF8 cname(aPath);
char* buffer = cname.BeginWriting();
const char* token;
@@ -398,12 +566,12 @@ DeviceStorageFile::NormalizeFilePath() {
}
void
-DeviceStorageFile::AppendRelativePath() {
+DeviceStorageFile::AppendRelativePath(const nsAString& aPath) {
#if defined(XP_WIN)
// replace forward slashes with backslashes,
// since nsLocalFileWin chokes on them
nsString temp;
- temp.Assign(mPath);
+ temp.Assign(aPath);
PRUnichar* cur = temp.BeginWriting();
PRUnichar* end = temp.EndWriting();
@@ -414,7 +582,7 @@ DeviceStorageFile::AppendRelativePath() {
}
mFile->AppendRelativePath(temp);
#else
- mFile->AppendRelativePath(mPath);
+ mFile->AppendRelativePath(aPath);
#endif
}
@@ -536,7 +704,6 @@ DeviceStorageFile::CollectFiles(nsTArray > &aFiles,
if (NS_FAILED(rv)) {
return;
}
-
return collectFilesInternal(aFiles, aSince, rootPath);
}
@@ -585,12 +752,10 @@ DeviceStorageFile::collectFilesInternal(nsTArray > &
nsDependentSubstring newPath = Substring(fullpath, len);
if (isDir) {
- DeviceStorageFile dsf(mStorageType, f);
- dsf.SetPath(newPath);
+ DeviceStorageFile dsf(mStorageType, mRootDir, newPath);
dsf.collectFilesInternal(aFiles, aSince, aRootPath);
} else if (isFile) {
- nsRefPtr dsf = new DeviceStorageFile(mStorageType, f);
- dsf->SetPath(newPath);
+ nsRefPtr dsf = new DeviceStorageFile(mStorageType, mRootDir, newPath);
aFiles.AppendElement(dsf);
}
}
@@ -706,11 +871,13 @@ UnregisterForSDCardChanges(nsIObserver* aObserver)
#endif
void
-nsDOMDeviceStorage::SetRootDirectoryForType(const nsAString& aType, const nsAString& aVolName)
+nsDOMDeviceStorage::SetRootDirectoryForType(const nsAString& aType,
+ const nsAString& aVolName)
{
nsCOMPtr f;
- nsCOMPtr dirService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
- NS_ASSERTION(dirService, "Must have directory service");
+ DeviceStorageFile::GetRootDirectoryForType(aType,
+ aVolName,
+ getter_AddRefs(f));
mVolumeName = NS_LITERAL_STRING("");
#ifdef MOZ_WIDGET_GONK
@@ -727,84 +894,7 @@ nsDOMDeviceStorage::SetRootDirectoryForType(const nsAString& aType, const nsAStr
}
}
}
-#endif
- // Picture directory
- if (aType.EqualsLiteral(DEVICESTORAGE_PICTURES)) {
-#ifdef MOZ_WIDGET_GONK
- NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
-#elif defined (MOZ_WIDGET_COCOA)
- dirService->Get(NS_OSX_PICTURE_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
-#elif defined (XP_UNIX)
- dirService->Get(NS_UNIX_XDG_PICTURES_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
-#elif defined (XP_WIN)
- dirService->Get(NS_WIN_PICTURES_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
-#endif
- }
-
- // Video directory
- else if (aType.EqualsLiteral(DEVICESTORAGE_VIDEOS)) {
-#ifdef MOZ_WIDGET_GONK
- NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
-#elif defined (MOZ_WIDGET_COCOA)
- dirService->Get(NS_OSX_MOVIE_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
-#elif defined (XP_UNIX)
- dirService->Get(NS_UNIX_XDG_VIDEOS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
-#elif defined (XP_WIN)
- dirService->Get(NS_WIN_VIDEOS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
-#endif
- }
-
- // Music directory
- else if (aType.EqualsLiteral(DEVICESTORAGE_MUSIC)) {
-#ifdef MOZ_WIDGET_GONK
- NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
-#elif defined (MOZ_WIDGET_COCOA)
- dirService->Get(NS_OSX_MUSIC_DOCUMENTS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
-#elif defined (XP_UNIX)
- dirService->Get(NS_UNIX_XDG_MUSIC_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
-#elif defined (XP_WIN)
- dirService->Get(NS_WIN_MUSIC_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
-#endif
- }
-
- // Apps directory
- else if (aType.EqualsLiteral(DEVICESTORAGE_APPS)) {
-#ifdef MOZ_WIDGET_GONK
- NS_NewLocalFile(NS_LITERAL_STRING("/data"), false, getter_AddRefs(f));
-#else
- dirService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
- if (f) {
- f->AppendRelativeNativePath(NS_LITERAL_CSTRING("webapps"));
- }
-#endif
- }
-
- // default SDCard
- else if (aType.EqualsLiteral(DEVICESTORAGE_SDCARD)) {
-#ifdef MOZ_WIDGET_GONK
- NS_NewLocalFile(volMountPoint, false, getter_AddRefs(f));
-#else
- // Eventually, on desktop, we want to do something smarter -- for example,
- // detect when an sdcard is inserted, and use that instead of this.
- dirService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
- if (f) {
- f->AppendRelativeNativePath(NS_LITERAL_CSTRING("fake-sdcard"));
- }
-#endif
- }
-
- // in testing, we default all device storage types to a temp directory
- if (f && mozilla::Preferences::GetBool("device.storage.testing", false)) {
- dirService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsIFile), getter_AddRefs(f));
- if (f) {
- f->AppendRelativeNativePath(NS_LITERAL_CSTRING("device-storage-testing"));
- f->Create(nsIFile::DIRECTORY_TYPE, 0777);
- f->Normalize();
- }
- }
-
-#ifdef MOZ_WIDGET_GONK
RegisterForSDCardChanges(this);
#endif
@@ -1026,20 +1116,13 @@ ContinueCursorEvent::Continue()
return;
}
- nsString fullpath;
- nsresult rv = file->mFile->GetPath(fullpath);
- if (NS_FAILED(rv)) {
- NS_ASSERTION(false, "GetPath failed to return a valid path");
- return;
- }
-
nsDOMDeviceStorageCursor* cursor = static_cast(mRequest.get());
nsString cursorStorageType;
cursor->GetStorageType(cursorStorageType);
DeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, file);
child->SetCallback(cursor);
- DeviceStorageGetParams params(cursorStorageType, file->mPath, fullpath);
+ DeviceStorageGetParams params(cursorStorageType, file->mRootDir, file->mPath);
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
mRequest = nullptr;
}
@@ -1180,17 +1263,8 @@ nsDOMDeviceStorageCursor::Allow()
}
if (XRE_GetProcessType() != GeckoProcessType_Default) {
-
- nsString fullpath;
- nsresult rv = mFile->mFile->GetPath(fullpath);
-
- if (NS_FAILED(rv)) {
- // just do nothing
- return NS_OK;
- }
-
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(this, mFile);
- DeviceStorageEnumerationParams params(mFile->mStorageType, fullpath, mSince);
+ DeviceStorageEnumerationParams params(mFile->mStorageType, mFile->mRootDir, mSince);
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
@@ -1650,14 +1724,6 @@ public:
return NS_ERROR_FAILURE;
}
- nsString fullpath;
- nsresult rv = mFile->mFile->GetPath(fullpath);
-
- if (NS_FAILED(rv)) {
- // just do nothing
- return NS_OK;
- }
-
switch(mRequestType) {
case DEVICE_STORAGE_REQUEST_CREATE:
{
@@ -1687,8 +1753,7 @@ public:
DeviceStorageAddParams params;
params.blobChild() = actor;
params.type() = mFile->mStorageType;
- params.name() = mFile->mPath;
- params.fullpath() = fullpath;
+ params.relpath() = mFile->mPath;
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile);
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
@@ -1714,7 +1779,7 @@ public:
if (XRE_GetProcessType() != GeckoProcessType_Default) {
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile);
- DeviceStorageGetParams params(mFile->mStorageType, mFile->mPath, fullpath);
+ DeviceStorageGetParams params(mFile->mStorageType, mFile->mRootDir, mFile->mPath);
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
@@ -1738,7 +1803,7 @@ public:
if (XRE_GetProcessType() != GeckoProcessType_Default) {
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile);
- DeviceStorageDeleteParams params(mFile->mStorageType, fullpath);
+ DeviceStorageDeleteParams params(mFile->mStorageType, mFile->mPath);
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
@@ -1750,7 +1815,7 @@ public:
{
if (XRE_GetProcessType() != GeckoProcessType_Default) {
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile);
- DeviceStorageFreeSpaceParams params(mFile->mStorageType, fullpath);
+ DeviceStorageFreeSpaceParams params(mFile->mStorageType, mFile->mPath);
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
@@ -1762,7 +1827,7 @@ public:
{
if (XRE_GetProcessType() != GeckoProcessType_Default) {
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile);
- DeviceStorageUsedSpaceParams params(mFile->mStorageType, fullpath);
+ DeviceStorageUsedSpaceParams params(mFile->mStorageType, mFile->mPath);
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
@@ -1774,7 +1839,7 @@ public:
{
if (XRE_GetProcessType() != GeckoProcessType_Default) {
PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile);
- DeviceStorageAvailableParams params(mFile->mStorageType, fullpath);
+ DeviceStorageAvailableParams params(mFile->mStorageType, mFile->mPath);
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
@@ -2024,7 +2089,7 @@ nsDOMDeviceStorage::AddNamed(nsIDOMBlob *aBlob,
nsCOMPtr r;
- nsRefPtr dsf = new DeviceStorageFile(mStorageType, mRootDirectory, aPath);
+ nsRefPtr dsf = new DeviceStorageFile(mStorageType, aPath);
if (!dsf->IsSafePath()) {
r = new PostErrorEvent(request, POST_ERROR_EVENT_PERMISSION_DENIED);
} else if (!typeChecker->Check(mStorageType, dsf->mFile) ||
@@ -2080,7 +2145,7 @@ nsDOMDeviceStorage::GetInternal(const JS::Value & aPath,
return NS_OK;
}
- nsRefPtr dsf = new DeviceStorageFile(mStorageType, mRootDirectory, path);
+ nsRefPtr dsf = new DeviceStorageFile(mStorageType, path);
dsf->SetEditable(aEditable);
if (!dsf->IsSafePath()) {
r = new PostErrorEvent(request, POST_ERROR_EVENT_PERMISSION_DENIED);
@@ -2113,7 +2178,7 @@ nsDOMDeviceStorage::Delete(const JS::Value & aPath, JSContext* aCx, nsIDOMDOMReq
return NS_OK;
}
- nsRefPtr dsf = new DeviceStorageFile(mStorageType, mRootDirectory, path);
+ nsRefPtr dsf = new DeviceStorageFile(mStorageType, path);
if (!dsf->IsSafePath()) {
r = new PostErrorEvent(request, POST_ERROR_EVENT_PERMISSION_DENIED);
@@ -2137,7 +2202,7 @@ nsDOMDeviceStorage::FreeSpace(nsIDOMDOMRequest** aRetval)
nsRefPtr request = new DOMRequest(win);
NS_ADDREF(*aRetval = request);
- nsRefPtr dsf = new DeviceStorageFile(mStorageType, mRootDirectory);
+ nsRefPtr dsf = new DeviceStorageFile(mStorageType);
nsCOMPtr r = new DeviceStorageRequest(DEVICE_STORAGE_REQUEST_FREE_SPACE,
win,
mPrincipal,
@@ -2158,7 +2223,7 @@ nsDOMDeviceStorage::UsedSpace(nsIDOMDOMRequest** aRetval)
nsRefPtr request = new DOMRequest(win);
NS_ADDREF(*aRetval = request);
- nsRefPtr dsf = new DeviceStorageFile(mStorageType, mRootDirectory);
+ nsRefPtr dsf = new DeviceStorageFile(mStorageType);
nsCOMPtr r = new DeviceStorageRequest(DEVICE_STORAGE_REQUEST_USED_SPACE,
win,
mPrincipal,
@@ -2179,7 +2244,7 @@ nsDOMDeviceStorage::Available(nsIDOMDOMRequest** aRetval)
nsRefPtr request = new DOMRequest(win);
NS_ADDREF(*aRetval = request);
- nsRefPtr dsf = new DeviceStorageFile(mStorageType, mRootDirectory);
+ nsRefPtr dsf = new DeviceStorageFile(mStorageType);
nsCOMPtr r = new DeviceStorageRequest(DEVICE_STORAGE_REQUEST_AVAILABLE,
win,
mPrincipal,
@@ -2279,7 +2344,7 @@ nsDOMDeviceStorage::EnumerateInternal(const JS::Value & aName,
since = ExtractDateFromOptions(aCx, aOptions);
}
- nsRefPtr dsf = new DeviceStorageFile(mStorageType, mRootDirectory, path);
+ nsRefPtr dsf = new DeviceStorageFile(mStorageType, path, NS_LITERAL_STRING(""));
dsf->SetEditable(aEditable);
nsRefPtr cursor = new nsDOMDeviceStorageCursor(win, mPrincipal,
@@ -2453,7 +2518,7 @@ nsDOMDeviceStorage::AddEventListener(const nsAString & aType,
}
nsRefPtr request = new DOMRequest(win);
- nsRefPtr dsf = new DeviceStorageFile(mStorageType, mRootDirectory);
+ nsRefPtr dsf = new DeviceStorageFile(mStorageType);
nsCOMPtr r = new DeviceStorageRequest(DEVICE_STORAGE_REQUEST_WATCH,
win, mPrincipal, dsf, request, this);
NS_DispatchToMainThread(r);
@@ -2474,7 +2539,7 @@ nsDOMDeviceStorage::AddEventListener(const nsAString & aType,
}
nsRefPtr request = new DOMRequest(win);
- nsRefPtr dsf = new DeviceStorageFile(mStorageType, mRootDirectory);
+ nsRefPtr dsf = new DeviceStorageFile(mStorageType);
nsCOMPtr r = new DeviceStorageRequest(DEVICE_STORAGE_REQUEST_WATCH,
win, mPrincipal, dsf, request, this);
NS_DispatchToMainThread(r);
diff --git a/dom/indexedDB/IDBDatabase.h b/dom/indexedDB/IDBDatabase.h
index 016508fb7387..af6a5e8ba0ce 100644
--- a/dom/indexedDB/IDBDatabase.h
+++ b/dom/indexedDB/IDBDatabase.h
@@ -102,8 +102,7 @@ public:
return nullptr;
}
- nsCOMPtr doc =
- do_QueryInterface(GetOwner()->GetExtantDocument());
+ nsCOMPtr doc = GetOwner()->GetExtantDoc();
return doc.forget();
}
diff --git a/dom/interfaces/events/nsIDOMKeyEvent.idl b/dom/interfaces/events/nsIDOMKeyEvent.idl
index bd1d6e991317..f17bceeca1f9 100644
--- a/dom/interfaces/events/nsIDOMKeyEvent.idl
+++ b/dom/interfaces/events/nsIDOMKeyEvent.idl
@@ -5,7 +5,7 @@
#include "nsIDOMUIEvent.idl"
-[scriptable, builtinclass, uuid(ffbe684c-ca90-4b58-aa8c-9727f997f86d)]
+[scriptable, builtinclass, uuid(91a3d7f2-223b-4e09-a566-634e7ee0a31d)]
interface nsIDOMKeyEvent : nsIDOMUIEvent
{
const unsigned long DOM_VK_CANCEL = 0x03;
@@ -252,4 +252,6 @@ interface nsIDOMKeyEvent : nsIDOMUIEvent
const unsigned long DOM_KEY_LOCATION_JOYSTICK = 0x05;
readonly attribute unsigned long location;
+
+ readonly attribute DOMString key;
};
diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp
index 1e86af0b3092..a186189b0226 100644
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1176,10 +1176,7 @@ ContentChild::RecvLastPrivateDocShellDestroyed()
bool
ContentChild::RecvFilePathUpdate(const nsString& type, const nsString& path, const nsCString& aReason)
{
- nsCOMPtr file;
- NS_NewLocalFile(path, false, getter_AddRefs(file));
-
- nsRefPtr