Merge last green changeset of mozilla-inbound to mozilla-central

This commit is contained in:
Ed Morley 2012-01-21 02:31:32 +00:00
Родитель fcb73495b2 88a1823ba1
Коммит 23deb13da3
260 изменённых файлов: 8208 добавлений и 2566 удалений

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

@ -49,6 +49,9 @@ namespace statistics {
inline void A11yInitialized()
{ Telemetry::Accumulate(Telemetry::A11Y_INSTANTIATED, true); }
inline void A11yConsumers(PRUint32 aConsumer)
{ Telemetry::Accumulate(Telemetry::A11Y_CONSUMERS, aConsumer); }
/**
* Report that ISimpleDOM* has been used.
*/

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

@ -909,19 +909,8 @@ static bool HasRelatedContent(nsIContent *aContent)
// If the given ID is referred by relation attribute then create an accessible
// for it. Take care of HTML elements only for now.
if (aContent->IsHTML() &&
nsAccUtils::GetDocAccessibleFor(aContent)->IsDependentID(id))
return true;
nsIContent *ancestorContent = aContent;
while ((ancestorContent = ancestorContent->GetParent()) != nsnull) {
if (ancestorContent->HasAttr(kNameSpaceID_None, nsGkAtoms::aria_activedescendant)) {
// ancestor has activedescendant property, this content could be active
return true;
}
}
return false;
return aContent->IsHTML() &&
nsAccUtils::GetDocAccessibleFor(aContent)->IsDependentID(id);
}
nsAccessible*

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

@ -2914,21 +2914,18 @@ nsAccessible::SetCurrentItem(nsAccessible* aItem)
nsAccessible*
nsAccessible::ContainerWidget() const
{
nsIAtom* idAttribute = mContent->GetIDAttributeName();
if (idAttribute) {
if (mContent->HasAttr(kNameSpaceID_None, idAttribute)) {
for (nsAccessible* parent = Parent(); parent; parent = parent->Parent()) {
nsIContent* parentContent = parent->GetContent();
if (parentContent &&
parentContent->HasAttr(kNameSpaceID_None,
nsGkAtoms::aria_activedescendant)) {
return parent;
}
// Don't cross DOM document boundaries.
if (parent->IsDocumentNode())
break;
if (HasARIARole() && mContent->HasID()) {
for (nsAccessible* parent = Parent(); parent; parent = parent->Parent()) {
nsIContent* parentContent = parent->GetContent();
if (parentContent &&
parentContent->HasAttr(kNameSpaceID_None,
nsGkAtoms::aria_activedescendant)) {
return parent;
}
// Don't cross DOM document boundaries.
if (parent->IsDocumentNode())
break;
}
}
return nsnull;

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

@ -166,6 +166,14 @@ public:
return ARIARoleInternal();
}
/**
* Return true if ARIA role is specified on the element.
*/
inline bool HasARIARole() const
{
return mRoleMapEntry;
}
/**
* Return accessible role specified by ARIA (see constants in
* roles).

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

@ -40,6 +40,7 @@
#include "Compatibility.h"
#include "nsWinUtils.h"
#include "Statistics.h"
#include "mozilla/Preferences.h"
@ -84,18 +85,37 @@ PRUint32 Compatibility::sMode = Compatibility::NoCompatibilityMode;
void
Compatibility::Init()
{
// Note we collect some AT statistics/telemetry here for convenience.
HMODULE jawsHandle = ::GetModuleHandleW(L"jhook");
if (jawsHandle) {
sMode |= JAWSMode;
// IA2 off mode for JAWS versions below 8.0.2173.
if (IsModuleVersionLessThan(jawsHandle, 8, 2173))
if (IsModuleVersionLessThan(jawsHandle, 8, 2173)) {
sMode |= IA2OffMode;
statistics::A11yConsumers(OLDJAWS);
} else {
statistics::A11yConsumers(JAWS);
}
}
if (::GetModuleHandleW(L"gwm32inc"))
if (::GetModuleHandleW(L"gwm32inc")) {
sMode |= WEMode;
if (::GetModuleHandleW(L"dolwinhk"))
statistics::A11yConsumers(WE);
}
if (::GetModuleHandleW(L"dolwinhk")) {
sMode |= DolphinMode;
statistics::A11yConsumers(DOLPHIN);
}
if (::GetModuleHandleW(L"STSA32"))
statistics::A11yConsumers(SEROTEK);
if (::GetModuleHandleW(L"nvdaHelperRemote"))
statistics::A11yConsumers(NVDA);
if (::GetModuleHandleW(L"OsmHooks"))
statistics::A11yConsumers(COBRA);
// Turn off new tab switching for Jaws and WE.
if (sMode & JAWSMode || sMode & WEMode) {

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

@ -97,6 +97,19 @@ private:
IA2OffMode = 1 << 3
};
/**
* List of detected consumers of a11y (used for statistics/telemetry)
*/
enum {
NVDA = 0,
JAWS = 1,
OLDJAWS = 2,
WE = 3,
DOLPHIN = 4,
SEROTEK = 5,
COBRA = 6
};
private:
static PRUint32 sMode;
};

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

@ -394,6 +394,10 @@ pref("layers.acceleration.force-enabled", true);
pref("dom.screenEnabledProperty.enabled", true);
pref("dom.screenBrightnessProperty.enabled", true);
// Enable browser frame
pref("dom.mozBrowserFramesEnabled", true);
pref("dom.mozBrowserFramesWhitelist", "http://localhost:6666");
// Temporary permission hack for WebSMS
pref("dom.sms.enabled", true);
pref("dom.sms.whitelist", "file://,http://localhost:6666");

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

@ -83,6 +83,10 @@ LIBS += \
$(XPCOM_STANDALONE_GLUE_LDOPTS) \
$(NULL)
ifdef MOZ_LINKER
LIBS += $(ZLIB_LIBS)
endif
ifndef MOZ_WINCONSOLE
ifdef MOZ_DEBUG
MOZ_WINCONSOLE = 1

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

@ -804,6 +804,10 @@ pref("browser.sessionstore.max_resumed_crashes", 1);
pref("browser.sessionstore.restore_on_demand", false);
// Whether to automatically restore hidden tabs (i.e., tabs in other tab groups) or not
pref("browser.sessionstore.restore_hidden_tabs", false);
// If restore_on_demand is set, pinned tabs are restored on startup by default.
// When set to true, this pref overrides that behavior, and pinned tabs will only
// be restored when they are focused.
pref("browser.sessionstore.restore_pinned_tabs_on_demand", false);
// allow META refresh by default
pref("accessibility.blockautorefresh", false);

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

@ -232,8 +232,8 @@ var FullZoom = {
let browser = aBrowser || gBrowser.selectedBrowser;
// Image documents should always start at 1, and are not affected by prefs.
if (!aIsTabSwitch && browser.contentDocument instanceof ImageDocument) {
// Media documents should always start at 1, and are not affected by prefs.
if (!aIsTabSwitch && browser.contentDocument.mozSyntheticDocument) {
ZoomManager.setZoomForBrowser(browser, 1);
return;
}
@ -309,7 +309,7 @@ var FullZoom = {
var browser = aBrowser || (gBrowser && gBrowser.selectedBrowser);
try {
if (browser.contentDocument instanceof ImageDocument)
if (browser.contentDocument.mozSyntheticDocument)
return;
if (typeof aValue != "undefined")
@ -324,7 +324,7 @@ var FullZoom = {
_applySettingToPref: function FullZoom__applySettingToPref() {
if (!this.siteSpecific || gInPrintPreviewMode ||
content.document instanceof ImageDocument)
content.document.mozSyntheticDocument)
return;
var zoomLevel = ZoomManager.zoom;
@ -332,7 +332,7 @@ var FullZoom = {
},
_removePref: function FullZoom__removePref() {
if (!(content.document instanceof ImageDocument))
if (!(content.document.mozSyntheticDocument))
Services.contentPrefs.removePref(gBrowser.currentURI, this.name);
},

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

@ -3040,7 +3040,7 @@ function FillInHTMLTooltip(tipElement)
// Don't show the tooltip if the tooltip node is a XUL element, a document or is disconnected.
if (tipElement.namespaceURI == "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" ||
!tipElement.ownerDocument ||
tipElement.ownerDocument.compareDocumentPosition(tipElement) == document.DOCUMENT_POSITION_DISCONNECTED)
(tipElement.ownerDocument.compareDocumentPosition(tipElement) & document.DOCUMENT_POSITION_DISCONNECTED))
return retVal;
const XLinkNS = "http://www.w3.org/1999/xlink";

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

@ -174,6 +174,7 @@ _BROWSER_FILES = \
browser_bug655584.js \
browser_bug664672.js \
browser_bug710878.js \
browser_bug719271.js \
browser_canonizeURL.js \
browser_findbarClose.js \
browser_keywordBookmarklets.js \
@ -231,6 +232,7 @@ _BROWSER_FILES = \
discovery.html \
domplate_test.js \
moz.png \
video.ogg \
test_bug435035.html \
test_bug462673.html \
page_style_sample.html \

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

@ -0,0 +1,141 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const TEST_PAGE = "http://example.org/browser/browser/base/content/test/zoom_test.html";
const TEST_VIDEO = "http://example.org/browser/browser/base/content/test/video.ogg";
var gTab1, gTab2, gLevel1, gLevel2;
function test() {
waitForExplicitFinish();
gTab1 = gBrowser.addTab();
gTab2 = gBrowser.addTab();
gBrowser.selectedTab = gTab1;
load(gTab1, TEST_PAGE, function() {
load(gTab2, TEST_VIDEO, zoomTab1);
});
}
function zoomTab1() {
is(gBrowser.selectedTab, gTab1, "Tab 1 is selected");
zoomTest(gTab1, 1, "Initial zoom of tab 1 should be 1");
zoomTest(gTab2, 1, "Initial zoom of tab 2 should be 1");
FullZoom.enlarge();
gLevel1 = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab1));
ok(gLevel1 > 1, "New zoom for tab 1 should be greater than 1");
zoomTest(gTab2, 1, "Zooming tab 1 should not affect tab 2");
gBrowser.selectedTab = gTab2;
zoomTest(gTab2, 1, "Tab 2 is still unzoomed after it is selected");
zoomTest(gTab1, gLevel1, "Tab 1 is still zoomed");
zoomTab2();
}
function zoomTab2() {
is(gBrowser.selectedTab, gTab2, "Tab 2 is selected");
FullZoom.reduce();
let gLevel2 = ZoomManager.getZoomForBrowser(gBrowser.getBrowserForTab(gTab2));
ok(gLevel2 < 1, "New zoom for tab 2 should be less than 1");
zoomTest(gTab1, gLevel1, "Zooming tab 2 should not affect tab 1");
afterZoom(function() {
zoomTest(gTab1, gLevel1, "Tab 1 should have the same zoom after it's selected");
testNavigation();
});
gBrowser.selectedTab = gTab1;
}
function testNavigation() {
load(gTab1, TEST_VIDEO, function() {
zoomTest(gTab1, 1, "Zoom should be 1 when a video was loaded");
navigate(BACK, function() {
zoomTest(gTab1, gLevel1, "Zoom should be restored when a page is loaded");
navigate(FORWARD, function() {
zoomTest(gTab1, 1, "Zoom should be 1 again when navigating back to a video");
finishTest();
});
});
});
}
var finishTestStarted = false;
function finishTest() {
ok(!finishTestStarted, "finishTest called more than once");
finishTestStarted = true;
gBrowser.selectedTab = gTab1;
FullZoom.reset();
gBrowser.removeTab(gTab1);
gBrowser.selectedTab = gTab2;
FullZoom.reset();
gBrowser.removeTab(gTab2);
finish();
}
function zoomTest(tab, val, msg) {
is(ZoomManager.getZoomForBrowser(tab.linkedBrowser), val, msg);
}
function load(tab, url, cb) {
let didLoad = false;
let didZoom = false;
tab.linkedBrowser.addEventListener("load", function onload(event) {
event.currentTarget.removeEventListener("load", onload, true);
didLoad = true;
if (didZoom)
executeSoon(cb);
}, true);
afterZoom(function() {
didZoom = true;
if (didLoad)
executeSoon(cb);
});
tab.linkedBrowser.loadURI(url);
}
const BACK = 0;
const FORWARD = 1;
function navigate(direction, cb) {
let didPs = false;
let didZoom = false;
gBrowser.addEventListener("pageshow", function onpageshow(event) {
gBrowser.removeEventListener("pageshow", onpageshow, true);
didPs = true;
if (didZoom)
executeSoon(cb);
}, true);
afterZoom(function() {
didZoom = true;
if (didPs)
executeSoon(cb);
});
if (direction == BACK)
gBrowser.goBack();
else if (direction == FORWARD)
gBrowser.goForward();
}
function afterZoom(cb) {
let oldSZFB = ZoomManager.setZoomForBrowser;
ZoomManager.setZoomForBrowser = function(browser, value) {
oldSZFB.call(ZoomManager, browser, value);
ZoomManager.setZoomForBrowser = oldSZFB;
executeSoon(cb);
};
}

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

@ -56,6 +56,9 @@ _BROWSER_TEST_FILES = \
browser_privatebrowsing_geoprompt.js \
browser_privatebrowsing_geoprompt_page.html \
browser_privatebrowsing_import.js \
browser_privatebrowsing_localStorage.js \
browser_privatebrowsing_localStorage_page1.html \
browser_privatebrowsing_localStorage_page2.html \
browser_privatebrowsing_newwindow_stopcmd.js \
browser_privatebrowsing_opendir.js \
browser_privatebrowsing_openlocation.js \
@ -92,8 +95,7 @@ _BROWSER_TEST_FILES = \
# Turn off private browsing tests that perma-timeout on Linux.
ifneq (Linux,$(OS_ARCH))
_BROWSER_TEST_FILES += \
browser_privatebrowsing_beforeunload_enter.js \
browser_privatebrowsing_beforeunload_exit.js \
browser_privatebrowsing_beforeunload.js \
browser_privatebrowsing_cookieacceptdialog.js \
$(NULL)
endif

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

@ -98,14 +98,66 @@ function test() {
"Incorrect page displayed after private browsing transition");
is(acceptDialog, 0, "Two confirm dialogs should have been accepted");
gBrowser.addTab();
gBrowser.removeTab(gBrowser.selectedTab);
Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
pb.privateBrowsingEnabled = false;
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
Services.obs.removeObserver(promptObserver, "common-dialog-loaded", false);
gBrowser.getBrowserAtIndex(gBrowser.tabContainer.selectedIndex).contentWindow.focus();
finish();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
confirmCalls = 0;
rejectDialog = 1;
pb.privateBrowsingEnabled = false;
ok(pb.privateBrowsingEnabled, "Private browsing mode should not have been deactivated");
is(confirmCalls, 1, "Only one confirm box should be shown");
is(gBrowser.tabs.length, 2,
"No tabs should be closed because private browsing mode transition was canceled");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild).currentURI.spec, TEST_PAGE_1,
"The first tab should be the same one we opened");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, TEST_PAGE_2,
"The last tab should be the same one we opened");
is(rejectDialog, 0, "Only one confirm dialog should have been rejected");
confirmCalls = 0;
acceptDialog = 2;
pb.privateBrowsingEnabled = false;
ok(!pb.privateBrowsingEnabled, "Private browsing mode should have been deactivated");
is(confirmCalls, 2, "Only two confirm boxes should be shown");
is(gBrowser.tabs.length, 3,
"Incorrect number of tabs after transition into private browsing");
let loads = 0;
function waitForLoad(event) {
gBrowser.removeEventListener("load", arguments.callee, true);
if (++loads != 3)
return;
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild).currentURI.spec, "about:blank",
"The first tab should be a blank tab");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild.nextSibling).currentURI.spec, TEST_PAGE_1,
"The middle tab should be the same one we opened");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, TEST_PAGE_2,
"The last tab should be the same one we opened");
is(acceptDialog, 0, "Two confirm dialogs should have been accepted");
is(acceptDialog, 0, "Two prompts should have been raised");
acceptDialog = 2;
gBrowser.removeTab(gBrowser.tabContainer.lastChild);
gBrowser.removeTab(gBrowser.tabContainer.lastChild);
gBrowser.getBrowserAtIndex(gBrowser.tabContainer.selectedIndex).contentWindow.focus();
Services.obs.removeObserver(promptObserver, "common-dialog-loaded", false);
finish();
}
for (let i = 0; i < gBrowser.browsers.length; ++i)
gBrowser.browsers[i].addEventListener("load", waitForLoad, true);
}, true);
gBrowser.selectedBrowser.loadURI(TEST_PAGE_2);
}, true);
gBrowser.selectedBrowser.loadURI(TEST_PAGE_1);
}, true);
}, true);
browser2.loadURI(TEST_PAGE_2);

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

@ -1,125 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Private Browsing Tests.
*
* The Initial Developer of the Original Code is
* Nochum Sossonko.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Nochum Sossonko <highmind63@gmail.com> (Original Author)
* Ehsan Akhgari <ehsan@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// This test makes sure that cancelling the unloading of a page with a beforeunload
// handler prevents the private browsing mode transition.
function test() {
const TEST_PAGE_1 = "data:text/html,<body%20onbeforeunload='return%20false;'>first</body>";
const TEST_PAGE_2 = "data:text/html,<body%20onbeforeunload='return%20false;'>second</body>";
let pb = Cc["@mozilla.org/privatebrowsing;1"]
.getService(Ci.nsIPrivateBrowsingService);
let rejectDialog = 0;
let acceptDialog = 0;
let confirmCalls = 0;
function promptObserver(aSubject, aTopic, aData) {
let dialogWin = aSubject.QueryInterface(Ci.nsIDOMWindow);
confirmCalls++;
if (acceptDialog-- > 0)
dialogWin.document.documentElement.getButton("accept").click();
else if (rejectDialog-- > 0)
dialogWin.document.documentElement.getButton("cancel").click();
}
Services.obs.addObserver(promptObserver, "common-dialog-loaded", false);
pb.privateBrowsingEnabled = true;
waitForExplicitFinish();
let browser1 = gBrowser.getBrowserForTab(gBrowser.addTab());
browser1.addEventListener("load", function() {
browser1.removeEventListener("load", arguments.callee, true);
let browser2 = gBrowser.getBrowserForTab(gBrowser.addTab());
browser2.addEventListener("load", function() {
browser2.removeEventListener("load", arguments.callee, true);
confirmCalls = 0;
rejectDialog = 1;
pb.privateBrowsingEnabled = false;
ok(pb.privateBrowsingEnabled, "Private browsing mode should not have been deactivated");
is(confirmCalls, 1, "Only one confirm box should be shown");
is(gBrowser.tabs.length, 3,
"No tabs should be closed because private browsing mode transition was canceled");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild).currentURI.spec, "about:privatebrowsing",
"The first tab should be the same one we opened");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, TEST_PAGE_2,
"The last tab should be the same one we opened");
is(rejectDialog, 0, "Only one confirm dialog should have been rejected");
confirmCalls = 0;
acceptDialog = 2;
pb.privateBrowsingEnabled = false;
ok(!pb.privateBrowsingEnabled, "Private browsing mode should have been deactivated");
is(confirmCalls, 2, "Only two confirm boxes should be shown");
is(gBrowser.tabs.length, 3,
"Incorrect number of tabs after transition into private browsing");
let loads = 0;
function waitForLoad(event) {
gBrowser.removeEventListener("load", arguments.callee, true);
if (++loads != 3)
return;
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild).currentURI.spec, "about:blank",
"The first tab should be a blank tab");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.firstChild.nextSibling).currentURI.spec, TEST_PAGE_1,
"The middle tab should be the same one we opened");
is(gBrowser.getBrowserForTab(gBrowser.tabContainer.lastChild).currentURI.spec, TEST_PAGE_2,
"The last tab should be the same one we opened");
is(acceptDialog, 0, "Two confirm dialogs should have been accepted");
is(acceptDialog, 0, "Two prompts should have been raised");
acceptDialog = 2;
gBrowser.removeTab(gBrowser.tabContainer.lastChild);
gBrowser.removeTab(gBrowser.tabContainer.lastChild);
gBrowser.getBrowserAtIndex(gBrowser.tabContainer.selectedIndex).contentWindow.focus();
Services.obs.removeObserver(promptObserver, "common-dialog-loaded", false);
finish();
}
for (let i = 0; i < gBrowser.browsers.length; ++i)
gBrowser.browsers[i].addEventListener("load", waitForLoad, true);
}, true);
browser2.loadURI(TEST_PAGE_2);
}, true);
browser1.loadURI(TEST_PAGE_1);
}

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

@ -1,4 +1,3 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -12,15 +11,15 @@
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla code.
* The Original Code is Private Browsing Tests.
*
* The Initial Developer of the Original Code is the Mozilla Foundation.
*
* Portions created by the Initial Developer are Copyright (C) 2011
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2012
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Justin Lebar <justin.lebar@gmail.com>
* Josh Matthews <josh@joshmatthews.net> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@ -36,33 +35,25 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
[scriptable, function, uuid(37687881-1801-489f-ad03-7af651a93448)]
interface nsIDOMMozGetContentStateCallback : nsISupports
{
void callback(in DOMString value);
};
[scriptable, uuid(2ff0f421-64e4-4186-b0dd-619629f46048)]
interface nsIDOMMozBrowserFrameElement : nsISupports
{
/**
* If true, a privileged page can call mozGetContentState on this element.
* If false, mozGetContentState will fail.
*/
attribute boolean mozBrowser;
/**
* Get a piece of state from this element's content window, returning its
* value via |callback|.
*
* At the moment, the only valid property is "location", which returns the
* content window's location. Passing any other property causes an error.
*
* If the iframe's mozBrowser is false, or if the calling window is not
* privileged, this function fails.
*/
void mozGetContentState(in DOMString property,
in nsIDOMMozGetContentStateCallback callback);
};
function test() {
let pb = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
waitForExplicitFinish();
pb.privateBrowsingEnabled = true;
let tab = gBrowser.selectedTab = gBrowser.addTab();
let browser = gBrowser.selectedBrowser;
browser.addEventListener('load', function() {
browser.removeEventListener('load', arguments.callee, true);
let tab2 = gBrowser.selectedTab = gBrowser.addTab();
browser.contentWindow.location = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/' +
'browser_privatebrowsing_localStorage_page2.html';
browser.addEventListener('load', function() {
browser.removeEventListener('load', arguments.callee, true);
is(browser.contentWindow.document.title, '2', "localStorage should contain 2 items");
pb.privateBrowsingEnabled = false;
finish();
}, true);
}, true);
browser.loadURI('http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/' +
'browser_privatebrowsing_localStorage_page1.html');
}

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

@ -0,0 +1,10 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
localStorage.clear();
localStorage.setItem('test1', 'value1');
</script>
</head>
<body>
</body>
</html>

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

@ -0,0 +1,10 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
localStorage.setItem('test2', 'value2');
document.title = localStorage.length;
</script>
</head>
<body>
</body>
</html>

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

@ -251,6 +251,9 @@ SessionStoreService.prototype = {
// whether to restore hidden tabs or not, pref controlled.
_restoreHiddenTabs: null,
// whether to restore app tabs on demand or not, pref controlled.
_restorePinnedTabsOnDemand: null,
// The state from the previous session (after restoring pinned tabs). This
// state is persisted and passed through to the next session during an app
@ -313,6 +316,10 @@ SessionStoreService.prototype = {
this._restoreHiddenTabs =
this._prefBranch.getBoolPref("sessionstore.restore_hidden_tabs");
this._prefBranch.addObserver("sessionstore.restore_hidden_tabs", this, true);
this._restorePinnedTabsOnDemand =
this._prefBranch.getBoolPref("sessionstore.restore_pinned_tabs_on_demand");
this._prefBranch.addObserver("sessionstore.restore_pinned_tabs_on_demand", this, true);
// Make sure gRestoreTabsProgressListener has a reference to sessionstore
// so that it can make calls back in
@ -688,6 +695,10 @@ SessionStoreService.prototype = {
this._restoreHiddenTabs =
this._prefBranch.getBoolPref("sessionstore.restore_hidden_tabs");
break;
case "sessionstore.restore_pinned_tabs_on_demand":
this._restorePinnedTabsOnDemand =
this._prefBranch.getBoolPref("sessionstore.restore_pinned_tabs_on_demand");
break;
}
break;
case "timer-callback": // timer call back for delayed saving
@ -3187,7 +3198,8 @@ SessionStoreService.prototype = {
return;
// If it's not possible to restore anything, then just bail out.
if ((!this._tabsToRestore.priority.length && this._restoreOnDemand) ||
if ((this._restoreOnDemand &&
(this._restorePinnedTabsOnDemand || !this._tabsToRestore.priority.length)) ||
this._tabsRestoringCount >= MAX_CONCURRENT_TAB_RESTORES)
return;

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

@ -56,11 +56,13 @@ let tests = [test_cascade, test_select, test_multiWindowState,
test_setWindowStateNoOverwrite, test_setWindowStateOverwrite,
test_setBrowserStateInterrupted, test_reload,
/* test_reloadReload, */ test_reloadCascadeSetup,
/* test_reloadCascade, */ test_apptabs_only];
/* test_reloadCascade, */ test_apptabs_only,
test_restore_apptabs_ondemand];
function runNextTest() {
// Reset the pref
try {
Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
Services.prefs.clearUserPref("browser.sessionstore.restore_pinned_tabs_on_demand");
} catch (e) {}
// set an empty state & run the next test, or finish
@ -777,6 +779,69 @@ function test_apptabs_only() {
}
// This test ensures that app tabs are not restored when restore_pinned_tabs_on_demand is set
function test_restore_apptabs_ondemand() {
Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
Services.prefs.setBoolPref("browser.sessionstore.restore_pinned_tabs_on_demand", true);
// We have our own progress listener for this test, which we'll attach before our state is set
let progressListener = {
onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
if (aBrowser.__SS_restoreState == TAB_STATE_RESTORING &&
aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK &&
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW)
test_restore_apptabs_ondemand_progressCallback(aBrowser);
}
}
let state = { windows: [{ tabs: [
{ entries: [{ url: "http://example.org/#1" }], extData: { "uniq": r() }, pinned: true },
{ entries: [{ url: "http://example.org/#2" }], extData: { "uniq": r() }, pinned: true },
{ entries: [{ url: "http://example.org/#3" }], extData: { "uniq": r() }, pinned: true },
{ entries: [{ url: "http://example.org/#4" }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org/#5" }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org/#6" }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org/#7" }], extData: { "uniq": r() } },
], selected: 5 }] };
let loadCount = 0;
let nextTestTimer;
function test_restore_apptabs_ondemand_progressCallback(aBrowser) {
loadCount++;
// get the tab
let tab;
for (let i = 0; i < window.gBrowser.tabs.length; i++) {
if (!tab && window.gBrowser.tabs[i].linkedBrowser == aBrowser)
tab = window.gBrowser.tabs[i];
}
// Check that the load only comes from the selected tab.
ok(gBrowser.selectedTab == tab,
"test_restore_apptabs_ondemand: load came from selected tab");
// We should get only 1 load: the selected tab
if (loadCount == 1) {
nextTestTimer = setTimeout(nextTest, 1000);
return;
}
else if (loadCount > 1) {
clearTimeout(nextTestTimer);
}
function nextTest() {
window.gBrowser.removeTabsProgressListener(progressListener);
runNextTest();
}
nextTest();
}
window.gBrowser.addTabsProgressListener(progressListener);
ss.setBrowserState(JSON.stringify(state));
}
function countTabs() {
let needsRestore = 0,
isRestoring = 0,

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

@ -189,7 +189,6 @@ typedef struct {
#define APP_REG_NAME L"Firefox"
#define CLS_HTML "FirefoxHTML"
#define CLS_URL "FirefoxURL"
#define CPL_DESKTOP L"Control Panel\\Desktop"
#define VAL_OPEN "\"%APPPATH%\" -requestPending -osint -url \"%1\""
#define VAL_FILE_ICON "%APPPATH%,1"
#define DI "\\DefaultIcon"
@ -617,44 +616,41 @@ nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement,
// if the file was written successfully, set it as the system wallpaper
if (NS_SUCCEEDED(rv)) {
bool result = false;
DWORD dwDisp = 0;
HKEY key;
// Try to create/open a subkey under HKCU.
DWORD res = ::RegCreateKeyExW(HKEY_CURRENT_USER, CPL_DESKTOP,
0, NULL, REG_OPTION_NON_VOLATILE,
KEY_WRITE, NULL, &key, &dwDisp);
if (REG_SUCCEEDED(res)) {
PRUnichar tile[2], style[2];
switch (aPosition) {
case BACKGROUND_TILE:
tile[0] = '1';
style[0] = '1';
break;
case BACKGROUND_CENTER:
tile[0] = '0';
style[0] = '0';
break;
case BACKGROUND_STRETCH:
tile[0] = '0';
style[0] = '2';
break;
}
tile[1] = '\0';
style[1] = '\0';
nsCOMPtr<nsIWindowsRegKey> regKey =
do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
// The size is always 3 unicode characters.
PRInt32 size = 3 * sizeof(PRUnichar);
::RegSetValueExW(key, L"TileWallpaper",
0, REG_SZ, (const BYTE *)tile, size);
::RegSetValueExW(key, L"WallpaperStyle",
0, REG_SZ, (const BYTE *)style, size);
::SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, (PVOID)path.get(),
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
rv = regKey->Create(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
NS_LITERAL_STRING("Control Panel\\Desktop"),
nsIWindowsRegKey::ACCESS_SET_VALUE);
NS_ENSURE_SUCCESS(rv, rv);
// Close the key we opened.
::RegCloseKey(key);
nsAutoString tile;
nsAutoString style;
switch (aPosition) {
case BACKGROUND_TILE:
style.AssignLiteral("0");
tile.AssignLiteral("1");
break;
case BACKGROUND_CENTER:
style.AssignLiteral("0");
tile.AssignLiteral("0");
break;
case BACKGROUND_STRETCH:
style.AssignLiteral("2");
tile.AssignLiteral("0");
break;
}
rv = regKey->WriteStringValue(NS_LITERAL_STRING("TileWallpaper"), tile);
NS_ENSURE_SUCCESS(rv, rv);
rv = regKey->WriteStringValue(NS_LITERAL_STRING("WallpaperStyle"), style);
NS_ENSURE_SUCCESS(rv, rv);
rv = regKey->Close();
NS_ENSURE_SUCCESS(rv, rv);
::SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, (PVOID)path.get(),
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
}
return rv;
}
@ -779,28 +775,24 @@ nsWindowsShellService::SetDesktopBackgroundColor(PRUint32 aColor)
::SetSysColors(sizeof(aParameters) / sizeof(int), aParameters, colors);
bool result = false;
DWORD dwDisp = 0;
HKEY key;
// Try to create/open a subkey under HKCU.
DWORD rv = ::RegCreateKeyExW(HKEY_CURRENT_USER,
L"Control Panel\\Colors", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
&key, &dwDisp);
nsresult rv;
nsCOMPtr<nsIWindowsRegKey> regKey =
do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
if (REG_SUCCEEDED(rv)) {
char rgb[12];
sprintf((char*)rgb, "%u %u %u\0", r, g, b);
NS_ConvertUTF8toUTF16 backColor(rgb);
rv = regKey->Create(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
NS_LITERAL_STRING("Control Panel\\Colors"),
nsIWindowsRegKey::ACCESS_SET_VALUE);
NS_ENSURE_SUCCESS(rv, rv);
::RegSetValueExW(key, L"Background",
0, REG_SZ, (const BYTE *)backColor.get(),
(backColor.Length() + 1) * sizeof(PRUnichar));
}
// Close the key we opened.
::RegCloseKey(key);
return NS_OK;
PRUnichar rgb[12];
_snwprintf(rgb, 12, L"%u %u %u", r, g, b);
rv = regKey->WriteStringValue(NS_LITERAL_STRING("Background"),
nsDependentString(rgb));
NS_ENSURE_SUCCESS(rv, rv);
return regKey->Close();
}
NS_IMETHODIMP

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

@ -0,0 +1,22 @@
diff -ru a/binutils/ar.c b/binutils/ar.c
--- a/binutils/ar.c 2011-03-16 04:35:58.000000000 -0400
+++ b/binutils/ar.c 2012-01-19 15:44:46.211226017 -0500
@@ -98,7 +98,7 @@
/* Operate in deterministic mode: write zero for timestamps, uids,
and gids for archive members and the archive symbol table, and write
consistent file modes. */
-int deterministic = 0;
+int deterministic = TRUE;
/* Nonzero means it's the name of an existing member; position new or moved
files with respect to this one. */
@@ -634,9 +634,6 @@
if (newer_only && operation != replace)
fatal (_("`u' is only meaningful with the `r' option."));
- if (newer_only && deterministic)
- fatal (_("`u' is not meaningful with the `D' option."));
-
if (postype != pos_default)
posname = argv[arg_index++];

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

@ -40,12 +40,6 @@ def build_package(package_source_dir, package_build_dir, configure_args):
run_in(package_build_dir, ["make", "-j8"])
run_in(package_build_dir, ["make", "install"])
def build_binutils(base_dir, binutils_inst_dir):
binutils_build_dir = base_dir + '/binutils_build'
build_package(binutils_source_dir, binutils_build_dir,
["--prefix=%s" % binutils_inst_dir])
# FIXME: factor this with build_binutils
def build_tar(base_dir, tar_inst_dir):
tar_build_dir = base_dir + '/tar_build'
build_package(tar_source_dir, tar_build_dir,
@ -71,10 +65,15 @@ def build_one_stage(env, stage_dir):
"--with-gmp=%s" % lib_inst_dir,
"--with-mpfr=%s" % lib_inst_dir])
tool_inst_dir = stage_dir + '/inst'
binutils_build_dir = stage_dir + '/binutils'
build_package(binutils_source_dir, binutils_build_dir,
["--prefix=%s" % tool_inst_dir])
gcc_build_dir = stage_dir + '/gcc'
gcc_inst_dir = stage_dir + '/inst'
build_package(gcc_source_dir, gcc_build_dir,
["--prefix=%s" % gcc_inst_dir,
["--prefix=%s" % tool_inst_dir,
"--enable-__cxa_atexit",
"--with-gmp=%s" % lib_inst_dir,
"--with-mpfr=%s" % lib_inst_dir,
@ -134,6 +133,7 @@ gcc_source_dir = build_source_dir('gcc-', gcc_version)
if not os.path.exists(source_dir):
os.mkdir(source_dir)
extract(binutils_source_tar, source_dir)
patch('binutils-deterministic.patch', 1, binutils_source_dir)
extract(tar_source_tar, source_dir)
extract(mpc_source_tar, source_dir)
extract(mpfr_source_tar, source_dir)
@ -147,21 +147,18 @@ if os.path.exists(build_dir):
shutil.rmtree(build_dir)
os.mkdir(build_dir)
tools_inst_dir = build_dir + '/tools_inst'
build_binutils(build_dir, tools_inst_dir)
build_tar(build_dir, tools_inst_dir)
os.environ["AR"] = os.path.realpath('det-ar.sh')
os.environ["MOZ_AR"] = tools_inst_dir + '/bin/ar'
os.environ["RANLIB"] = "true"
tar_inst_dir = build_dir + '/tar_inst'
build_tar(build_dir, tar_inst_dir)
stage1_dir = build_dir + '/stage1'
build_one_stage({"CC": "gcc", "CXX" : "g++"}, stage1_dir)
stage1_gcc_inst_dir = stage1_dir + '/inst'
stage1_tool_inst_dir = stage1_dir + '/inst'
stage2_dir = build_dir + '/stage2'
build_one_stage({"CC" : stage1_gcc_inst_dir + "/bin/gcc",
"CXX" : stage1_gcc_inst_dir + "/bin/g++"}, stage2_dir)
build_one_stage({"CC" : stage1_tool_inst_dir + "/bin/gcc",
"CXX" : stage1_tool_inst_dir + "/bin/g++",
"AR" : stage1_tool_inst_dir + "/bin/ar",
"RANLIB" : "true" })
build_tar_package(tools_inst_dir + "/bin/tar",
build_tar_package(tar_inst_dir + "/bin/tar",
"toolchain.tar", stage2_dir, "inst")

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

@ -1,5 +0,0 @@
#!/bin/sh
shift
echo $MOZ_AR "crD" "$@"
exec $MOZ_AR "crD" "$@"

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

@ -0,0 +1,179 @@
Index: gcc/doc/plugins.texi
===================================================================
--- gcc/doc/plugins.texi (revision 162126)
+++ gcc/doc/plugins.texi (working copy)
@@ -144,6 +144,7 @@
@{
PLUGIN_PASS_MANAGER_SETUP, /* To hook into pass manager. */
PLUGIN_FINISH_TYPE, /* After finishing parsing a type. */
+ PLUGIN_FINISH_DECL, /* After finishing parsing a declaration. */
PLUGIN_FINISH_UNIT, /* Useful for summary processing. */
PLUGIN_PRE_GENERICIZE, /* Allows to see low level AST in C and C++ frontends. */
PLUGIN_FINISH, /* Called before GCC exits. */
Index: gcc/plugin.def
===================================================================
--- gcc/plugin.def (revision 162126)
+++ gcc/plugin.def (working copy)
@@ -24,6 +24,9 @@
/* After finishing parsing a type. */
DEFEVENT (PLUGIN_FINISH_TYPE)
+/* After finishing parsing a declaration. */
+DEFEVENT (PLUGIN_FINISH_DECL)
+
/* Useful for summary processing. */
DEFEVENT (PLUGIN_FINISH_UNIT)
Index: gcc/testsuite/g++.dg/plugin/plugin.exp
===================================================================
--- gcc/testsuite/g++.dg/plugin/plugin.exp (revision 162126)
+++ gcc/testsuite/g++.dg/plugin/plugin.exp (working copy)
@@ -51,7 +51,8 @@
{ pragma_plugin.c pragma_plugin-test-1.C } \
{ selfassign.c self-assign-test-1.C self-assign-test-2.C self-assign-test-3.C } \
{ dumb_plugin.c dumb-plugin-test-1.C } \
- { header_plugin.c header-plugin-test.C } ]
+ { header_plugin.c header-plugin-test.C } \
+ { decl_plugin.c decl-plugin-test.C } ]
foreach plugin_test $plugin_test_list {
# Replace each source file with its full-path name
Index: gcc/testsuite/g++.dg/plugin/decl-plugin-test.C
===================================================================
--- gcc/testsuite/g++.dg/plugin/decl-plugin-test.C (revision 0)
+++ gcc/testsuite/g++.dg/plugin/decl-plugin-test.C (revision 0)
@@ -0,0 +1,32 @@
+
+
+extern int global; // { dg-warning "Decl Global global" }
+int global_array[] = { 1, 2, 3 }; // { dg-warning "Decl Global global_array" }
+
+int takes_args(int arg1, int arg2)
+{
+ int local = arg1 + arg2 + global; // { dg-warning "Decl Local local" }
+ return local + 1;
+}
+
+int global = 12; // { dg-warning "Decl Global global" }
+
+struct test_str {
+ int field; // { dg-warning "Decl Field field" }
+};
+
+class test_class {
+ int class_field1; // { dg-warning "Decl Field class_field1" }
+ int class_field2; // { dg-warning "Decl Field class_field2" }
+
+ test_class() // { dg-warning "Decl Function test_class" }
+ : class_field1(0), class_field2(0)
+ {}
+
+ void swap_fields(int bias) // { dg-warning "Decl Function swap_fields" }
+ {
+ int temp = class_field1 + bias; // { dg-warning "Decl Local temp" }
+ class_field1 = class_field2 - bias;
+ class_field2 = temp;
+ }
+};
Index: gcc/testsuite/g++.dg/plugin/decl_plugin.c
===================================================================
--- gcc/testsuite/g++.dg/plugin/decl_plugin.c (revision 0)
+++ gcc/testsuite/g++.dg/plugin/decl_plugin.c (revision 0)
@@ -0,0 +1,51 @@
+/* A plugin example that shows which declarations are caught by FINISH_DECL */
+
+#include "gcc-plugin.h"
+#include <stdlib.h>
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tree.h"
+#include "tree-pass.h"
+#include "intl.h"
+
+int plugin_is_GPL_compatible;
+
+/* Callback function to invoke after GCC finishes a declaration. */
+
+void plugin_finish_decl (void *event_data, void *data)
+{
+ tree decl = (tree) event_data;
+
+ const char *kind = NULL;
+ switch (TREE_CODE(decl)) {
+ case FUNCTION_DECL:
+ kind = "Function"; break;
+ case PARM_DECL:
+ kind = "Parameter"; break;
+ case VAR_DECL:
+ if (DECL_CONTEXT(decl) != NULL)
+ kind = "Local";
+ else
+ kind = "Global";
+ break;
+ case FIELD_DECL:
+ kind = "Field"; break;
+ default:
+ kind = "Unknown";
+ }
+
+ warning (0, G_("Decl %s %s"),
+ kind, IDENTIFIER_POINTER (DECL_NAME (decl)));
+}
+
+int
+plugin_init (struct plugin_name_args *plugin_info,
+ struct plugin_gcc_version *version)
+{
+ const char *plugin_name = plugin_info->base_name;
+
+ register_callback (plugin_name, PLUGIN_FINISH_DECL,
+ plugin_finish_decl, NULL);
+ return 0;
+}
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c (revision 162126)
+++ gcc/cp/decl.c (working copy)
@@ -5967,6 +5967,8 @@
/* If this was marked 'used', be sure it will be output. */
if (lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
mark_decl_referenced (decl);
+
+ invoke_plugin_callbacks (PLUGIN_FINISH_DECL, decl);
}
/* Returns a declaration for a VAR_DECL as if:
Index: gcc/c-decl.c
===================================================================
--- gcc/c-decl.c (revision 162126)
+++ gcc/c-decl.c (working copy)
@@ -4392,6 +4392,8 @@
&& DECL_INITIAL (decl) == NULL_TREE)
warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
"uninitialized const %qD is invalid in C++", decl);
+
+ invoke_plugin_callbacks (PLUGIN_FINISH_DECL, decl);
}
/* Given a parsed parameter declaration, decode it into a PARM_DECL. */
Index: gcc/plugin.c
===================================================================
--- gcc/plugin.c (revision 162126)
+++ gcc/plugin.c (working copy)
@@ -400,6 +400,7 @@
}
/* Fall through. */
case PLUGIN_FINISH_TYPE:
+ case PLUGIN_FINISH_DECL:
case PLUGIN_START_UNIT:
case PLUGIN_FINISH_UNIT:
case PLUGIN_PRE_GENERICIZE:
@@ -481,6 +482,7 @@
gcc_assert (event < event_last);
/* Fall through. */
case PLUGIN_FINISH_TYPE:
+ case PLUGIN_FINISH_DECL:
case PLUGIN_START_UNIT:
case PLUGIN_FINISH_UNIT:
case PLUGIN_PRE_GENERICIZE:

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

@ -0,0 +1,274 @@
diff -ru gcc-4.5.2/gcc/double-int.c gcc-4.5.2-new/gcc/double-int.c
--- gcc-4.5.2/gcc/double-int.c 2009-11-25 05:55:54.000000000 -0500
+++ gcc-4.5.2-new/gcc/double-int.c 2011-11-29 10:20:27.625583810 -0500
@@ -296,7 +296,12 @@
tree
double_int_to_tree (tree type, double_int cst)
{
- cst = double_int_ext (cst, TYPE_PRECISION (type), TYPE_UNSIGNED (type));
+ /* Size types *are* sign extended. */
+ bool sign_extended_type = (!TYPE_UNSIGNED (type)
+ || (TREE_CODE (type) == INTEGER_TYPE
+ && TYPE_IS_SIZETYPE (type)));
+
+ cst = double_int_ext (cst, TYPE_PRECISION (type), !sign_extended_type);
return build_int_cst_wide (type, cst.low, cst.high);
}
diff -ru gcc-4.5.2/gcc/tree.c gcc-4.5.2-new/gcc/tree.c
--- gcc-4.5.2/gcc/tree.c 2010-07-07 11:24:27.000000000 -0400
+++ gcc-4.5.2-new/gcc/tree.c 2011-11-29 10:20:27.626583813 -0500
@@ -9750,7 +9750,7 @@
tree
upper_bound_in_type (tree outer, tree inner)
{
- unsigned HOST_WIDE_INT lo, hi;
+ double_int high;
unsigned int det = 0;
unsigned oprec = TYPE_PRECISION (outer);
unsigned iprec = TYPE_PRECISION (inner);
@@ -9797,18 +9797,18 @@
/* Compute 2^^prec - 1. */
if (prec <= HOST_BITS_PER_WIDE_INT)
{
- hi = 0;
- lo = ((~(unsigned HOST_WIDE_INT) 0)
+ high.high = 0;
+ high.low = ((~(unsigned HOST_WIDE_INT) 0)
>> (HOST_BITS_PER_WIDE_INT - prec));
}
else
{
- hi = ((~(unsigned HOST_WIDE_INT) 0)
+ high.high = ((~(unsigned HOST_WIDE_INT) 0)
>> (2 * HOST_BITS_PER_WIDE_INT - prec));
- lo = ~(unsigned HOST_WIDE_INT) 0;
+ high.low = ~(unsigned HOST_WIDE_INT) 0;
}
- return build_int_cst_wide (outer, lo, hi);
+ return double_int_to_tree (outer, high);
}
/* Returns the smallest value obtainable by casting something in INNER type to
diff -ru gcc-4.5.2/gcc/tree-vrp.c gcc-4.5.2-new/gcc/tree-vrp.c
--- gcc-4.5.2/gcc/tree-vrp.c 2010-06-14 11:23:31.000000000 -0400
+++ gcc-4.5.2-new/gcc/tree-vrp.c 2011-11-29 10:20:27.628583820 -0500
@@ -127,10 +127,10 @@
static inline tree
vrp_val_max (const_tree type)
{
- if (!INTEGRAL_TYPE_P (type))
- return NULL_TREE;
+ if (INTEGRAL_TYPE_P (type))
+ return upper_bound_in_type (CONST_CAST_TREE (type), CONST_CAST_TREE (type));
- return TYPE_MAX_VALUE (type);
+ return NULL_TREE;
}
/* Return the minimum value for TYPE. */
@@ -138,10 +138,10 @@
static inline tree
vrp_val_min (const_tree type)
{
- if (!INTEGRAL_TYPE_P (type))
- return NULL_TREE;
+ if (INTEGRAL_TYPE_P (type))
+ return lower_bound_in_type (CONST_CAST_TREE (type), CONST_CAST_TREE (type));
- return TYPE_MIN_VALUE (type);
+ return NULL_TREE;
}
/* Return whether VAL is equal to the maximum value of its type. This
@@ -539,7 +539,7 @@
set_value_range (vr, VR_RANGE, zero,
(overflow_infinity
? positive_overflow_infinity (type)
- : TYPE_MAX_VALUE (type)),
+ : vrp_val_max (type)),
vr->equiv);
}
@@ -1595,7 +1595,7 @@
}
else if (cond_code == LE_EXPR || cond_code == LT_EXPR)
{
- min = TYPE_MIN_VALUE (type);
+ min = vrp_val_min (type);
if (limit_vr == NULL || limit_vr->type == VR_ANTI_RANGE)
max = limit;
@@ -1630,7 +1630,7 @@
}
else if (cond_code == GE_EXPR || cond_code == GT_EXPR)
{
- max = TYPE_MAX_VALUE (type);
+ max = vrp_val_max (type);
if (limit_vr == NULL || limit_vr->type == VR_ANTI_RANGE)
min = limit;
@@ -2047,11 +2047,11 @@
|| code == ROUND_DIV_EXPR)
return (needs_overflow_infinity (TREE_TYPE (res))
? positive_overflow_infinity (TREE_TYPE (res))
- : TYPE_MAX_VALUE (TREE_TYPE (res)));
+ : vrp_val_max (TREE_TYPE (res)));
else
return (needs_overflow_infinity (TREE_TYPE (res))
? negative_overflow_infinity (TREE_TYPE (res))
- : TYPE_MIN_VALUE (TREE_TYPE (res)));
+ : vrp_val_min (TREE_TYPE (res)));
}
return res;
@@ -2750,8 +2750,8 @@
&& TYPE_PRECISION (inner_type) < TYPE_PRECISION (outer_type))
{
vr0.type = VR_RANGE;
- vr0.min = TYPE_MIN_VALUE (inner_type);
- vr0.max = TYPE_MAX_VALUE (inner_type);
+ vr0.min = vrp_val_min (inner_type);
+ vr0.max = vrp_val_max (inner_type);
}
/* If VR0 is a constant range or anti-range and the conversion is
@@ -2836,7 +2836,7 @@
}
}
else
- min = TYPE_MIN_VALUE (type);
+ min = vrp_val_min (type);
if (is_positive_overflow_infinity (vr0.min))
max = negative_overflow_infinity (type);
@@ -2855,7 +2855,7 @@
}
}
else
- max = TYPE_MIN_VALUE (type);
+ max = vrp_val_min (type);
}
else if (code == NEGATE_EXPR
&& TYPE_UNSIGNED (type))
@@ -2897,7 +2897,7 @@
else if (!vrp_val_is_min (vr0.min))
min = fold_unary_to_constant (code, type, vr0.min);
else if (!needs_overflow_infinity (type))
- min = TYPE_MAX_VALUE (type);
+ min = vrp_val_max (type);
else if (supports_overflow_infinity (type))
min = positive_overflow_infinity (type);
else
@@ -2911,7 +2911,7 @@
else if (!vrp_val_is_min (vr0.max))
max = fold_unary_to_constant (code, type, vr0.max);
else if (!needs_overflow_infinity (type))
- max = TYPE_MAX_VALUE (type);
+ max = vrp_val_max (type);
else if (supports_overflow_infinity (type)
/* We shouldn't generate [+INF, +INF] as set_value_range
doesn't like this and ICEs. */
@@ -2941,7 +2941,7 @@
TYPE_MIN_VALUE, remember -TYPE_MIN_VALUE = TYPE_MIN_VALUE. */
if (TYPE_OVERFLOW_WRAPS (type))
{
- tree type_min_value = TYPE_MIN_VALUE (type);
+ tree type_min_value = vrp_val_min (type);
min = (vr0.min != type_min_value
? int_const_binop (PLUS_EXPR, type_min_value,
@@ -2953,7 +2953,7 @@
if (overflow_infinity_range_p (&vr0))
min = negative_overflow_infinity (type);
else
- min = TYPE_MIN_VALUE (type);
+ min = vrp_val_min (type);
}
}
else
@@ -2974,7 +2974,7 @@
}
}
else
- max = TYPE_MAX_VALUE (type);
+ max = vrp_val_max (type);
}
}
@@ -3258,11 +3258,11 @@
if (POINTER_TYPE_P (type) || !TYPE_MIN_VALUE (type))
tmin = lower_bound_in_type (type, type);
else
- tmin = TYPE_MIN_VALUE (type);
+ tmin = vrp_val_min (type);
if (POINTER_TYPE_P (type) || !TYPE_MAX_VALUE (type))
tmax = upper_bound_in_type (type, type);
else
- tmax = TYPE_MAX_VALUE (type);
+ tmax = vrp_val_max (type);
if (vr->type == VR_VARYING || vr->type == VR_UNDEFINED)
{
@@ -4146,8 +4146,8 @@
if ((comp_code == GT_EXPR || comp_code == LT_EXPR)
&& INTEGRAL_TYPE_P (TREE_TYPE (val)))
{
- tree min = TYPE_MIN_VALUE (TREE_TYPE (val));
- tree max = TYPE_MAX_VALUE (TREE_TYPE (val));
+ tree min = vrp_val_min (TREE_TYPE (val));
+ tree max = vrp_val_max (TREE_TYPE (val));
if (comp_code == GT_EXPR
&& (!max
@@ -6426,13 +6426,13 @@
VARYING. Same if the previous max value was invalid for
the type and we'd end up with vr_result.min > vr_result.max. */
if (vrp_val_is_max (vr_result.max)
- || compare_values (TYPE_MIN_VALUE (TREE_TYPE (vr_result.min)),
+ || compare_values (vrp_val_min (TREE_TYPE (vr_result.min)),
vr_result.max) > 0)
goto varying;
if (!needs_overflow_infinity (TREE_TYPE (vr_result.min))
|| !vrp_var_may_overflow (lhs, phi))
- vr_result.min = TYPE_MIN_VALUE (TREE_TYPE (vr_result.min));
+ vr_result.min = vrp_val_min (TREE_TYPE (vr_result.min));
else if (supports_overflow_infinity (TREE_TYPE (vr_result.min)))
vr_result.min =
negative_overflow_infinity (TREE_TYPE (vr_result.min));
@@ -6448,13 +6448,13 @@
VARYING. Same if the previous min value was invalid for
the type and we'd end up with vr_result.max < vr_result.min. */
if (vrp_val_is_min (vr_result.min)
- || compare_values (TYPE_MAX_VALUE (TREE_TYPE (vr_result.max)),
+ || compare_values (vrp_val_max (TREE_TYPE (vr_result.max)),
vr_result.min) < 0)
goto varying;
if (!needs_overflow_infinity (TREE_TYPE (vr_result.max))
|| !vrp_var_may_overflow (lhs, phi))
- vr_result.max = TYPE_MAX_VALUE (TREE_TYPE (vr_result.max));
+ vr_result.max = vrp_val_max (TREE_TYPE (vr_result.max));
else if (supports_overflow_infinity (TREE_TYPE (vr_result.max)))
vr_result.max =
positive_overflow_infinity (TREE_TYPE (vr_result.max));
@@ -6782,7 +6782,7 @@
{
/* This should not be negative infinity; there is no overflow
here. */
- min = TYPE_MIN_VALUE (TREE_TYPE (op0));
+ min = vrp_val_min (TREE_TYPE (op0));
max = op1;
if (cond_code == LT_EXPR && !is_overflow_infinity (max))
@@ -6797,7 +6797,7 @@
{
/* This should not be positive infinity; there is no overflow
here. */
- max = TYPE_MAX_VALUE (TREE_TYPE (op0));
+ max = vrp_val_max (TREE_TYPE (op0));
min = op1;
if (cond_code == GT_EXPR && !is_overflow_infinity (min))

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

@ -0,0 +1,98 @@
diff -ru gcc-4.5.2/libstdc++-v3/include/bits/stl_pair.h gcc-4.5.2-new/libstdc++-v3/include/bits/stl_pair.h
--- gcc-4.5.2/libstdc++-v3/include/bits/stl_pair.h 2010-06-10 06:26:14.000000000 -0400
+++ gcc-4.5.2-new/libstdc++-v3/include/bits/stl_pair.h 2011-11-29 10:25:51.203597393 -0500
@@ -88,6 +88,8 @@
: first(__a), second(__b) { }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ pair(const pair&) = default;
+
// DR 811.
template<class _U1, class = typename
std::enable_if<std::is_convertible<_U1, _T1>::value>::type>
@@ -131,6 +133,15 @@
template<class _U1, class _U2>
pair&
+ operator=(const pair<_U1, _U2>& __p)
+ {
+ first = __p.first;
+ second = __p.second;
+ return *this;
+ }
+
+ template<class _U1, class _U2>
+ pair&
operator=(pair<_U1, _U2>&& __p)
{
first = std::move(__p.first);
diff -ru gcc-4.5.2/libstdc++-v3/include/bits/stl_queue.h gcc-4.5.2-new/libstdc++-v3/include/bits/stl_queue.h
--- gcc-4.5.2/libstdc++-v3/include/bits/stl_queue.h 2010-02-04 13:20:34.000000000 -0500
+++ gcc-4.5.2-new/libstdc++-v3/include/bits/stl_queue.h 2011-11-29 10:26:22.511695475 -0500
@@ -1,6 +1,6 @@
// Queue implementation -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -137,16 +137,6 @@
explicit
queue(_Sequence&& __c = _Sequence())
: c(std::move(__c)) { }
-
- queue(queue&& __q)
- : c(std::move(__q.c)) { }
-
- queue&
- operator=(queue&& __q)
- {
- c = std::move(__q.c);
- return *this;
- }
#endif
/**
@@ -451,17 +441,6 @@
c.insert(c.end(), __first, __last);
std::make_heap(c.begin(), c.end(), comp);
}
-
- priority_queue(priority_queue&& __pq)
- : c(std::move(__pq.c)), comp(std::move(__pq.comp)) { }
-
- priority_queue&
- operator=(priority_queue&& __pq)
- {
- c = std::move(__pq.c);
- comp = std::move(__pq.comp);
- return *this;
- }
#endif
/**
diff -ru gcc-4.5.2/libstdc++-v3/libsupc++/exception_ptr.h gcc-4.5.2-new/libstdc++-v3/libsupc++/exception_ptr.h
--- gcc-4.5.2/libstdc++-v3/libsupc++/exception_ptr.h 2009-11-09 17:09:30.000000000 -0500
+++ gcc-4.5.2-new/libstdc++-v3/libsupc++/exception_ptr.h 2011-11-29 10:26:10.878659023 -0500
@@ -129,7 +129,7 @@
operator==(const exception_ptr&, const exception_ptr&) throw()
__attribute__ ((__pure__));
- const type_info*
+ const class type_info*
__cxa_exception_type() const throw() __attribute__ ((__pure__));
};
diff -ru gcc-4.5.2/libstdc++-v3/libsupc++/nested_exception.h gcc-4.5.2-new/libstdc++-v3/libsupc++/nested_exception.h
--- gcc-4.5.2/libstdc++-v3/libsupc++/nested_exception.h 2010-02-18 12:20:16.000000000 -0500
+++ gcc-4.5.2-new/libstdc++-v3/libsupc++/nested_exception.h 2011-11-29 10:26:10.879659026 -0500
@@ -119,7 +119,7 @@
// with a type that has an accessible nested_exception base.
template<typename _Ex>
inline void
- __throw_with_nested(_Ex&& __ex, const nested_exception* = 0)
+ __throw_with_nested(_Ex&& __ex, const nested_exception*)
{ throw __ex; }
template<typename _Ex>

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

@ -778,8 +778,8 @@ EXPAND_LIBS_GEN = $(PYTHON) $(topsrcdir)/config/pythonpath.py -I$(DEPTH)/config
EXPAND_AR = $(EXPAND_LIBS_EXEC) --extract -- $(AR)
EXPAND_CC = $(EXPAND_LIBS_EXEC) --uselist -- $(CC)
EXPAND_CCC = $(EXPAND_LIBS_EXEC) --uselist -- $(CCC)
EXPAND_LD = $(EXPAND_LIBS_EXEC) --uselist -- $(LD)
EXPAND_MKSHLIB = $(EXPAND_LIBS_EXEC) --uselist -- $(MKSHLIB)
EXPAND_LD = $(EXPAND_LIBS_EXEC) --uselist $(if $(REORDER),--reorder $(REORDER))-- $(LD)
EXPAND_MKSHLIB = $(EXPAND_LIBS_EXEC) --uselist $(if $(REORDER),--reorder $(REORDER))-- $(MKSHLIB)
ifdef STDCXX_COMPAT
CHECK_STDCXX = objdump -p $(1) | grep -e 'GLIBCXX_3\.4\.\(9\|[1-9][0-9]\)' > /dev/null && echo "TEST-UNEXPECTED-FAIL | | We don't want these libstdc++ symbols to be used:" && objdump -T $(1) | grep -e 'GLIBCXX_3\.4\.\(9\|[1-9][0-9]\)' && exit 1 || exit 0

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

@ -48,6 +48,10 @@ of a command line. The kind of list file format used depends on the
EXPAND_LIBS_LIST_STYLE variable: 'list' for MSVC style lists (@file.list)
or 'linkerscript' for GNU ld linker scripts.
See https://bugzilla.mozilla.org/show_bug.cgi?id=584474#c59 for more details.
With the --reorder argument, followed by a file name, it will reorder the
object files from the command line according to the order given in the file.
Implies --extract.
'''
from __future__ import with_statement
import sys
@ -125,6 +129,22 @@ class ExpandArgsMore(ExpandArgs):
newlist = self[0:idx] + [ref] + [item for item in self[idx:] if item not in objs]
self[0:] = newlist
def reorder(self, order_list):
'''Given a list of file names without OBJ_SUFFIX, rearrange self
so that the object file names it contains are ordered according to
that list.
'''
objs = [o for o in self if o.endswith(conf.OBJ_SUFFIX)]
if not objs: return
idx = self.index(objs[0])
# Keep everything before the first object, then the ordered objects,
# then any other objects, then any non-objects after the first object
objnames = dict([(os.path.splitext(os.path.basename(o))[0], o) for o in objs])
self[0:] = self[0:idx] + [objnames[o] for o in order_list if o in objnames] + \
[o for o in objs if os.path.splitext(os.path.basename(o))[0] not in order_list] + \
[x for x in self[idx:] if not x.endswith(conf.OBJ_SUFFIX)]
def main():
parser = OptionParser()
parser.add_option("--extract", action="store_true", dest="extract",
@ -133,12 +153,17 @@ def main():
help="use a list file for objects when executing a command")
parser.add_option("--verbose", action="store_true", dest="verbose",
help="display executed command and temporary files content")
parser.add_option("--reorder", dest="reorder",
help="reorder the objects according to the given list", metavar="FILE")
(options, args) = parser.parse_args()
with ExpandArgsMore(args) as args:
if options.extract:
if options.extract or options.reorder:
args.extract()
if options.reorder:
with open(options.reorder) as file:
args.reorder([l.strip() for l in file.readlines()])
if options.uselist:
args.makelist()

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

@ -267,5 +267,28 @@ class TestExpandArgsMore(TestExpandInit):
# Restore subprocess.call
subprocess.call = subprocess_call
def test_reorder(self):
'''Test object reordering'''
# We don't care about AR_EXTRACT testing, which is done in test_extract
config.AR_EXTRACT = ''
# ExpandArgsMore does the same as ExpandArgs
with ExpandArgsMore(['foo', '-bar'] + self.arg_files + [self.tmpfile('liby', Lib('y'))]) as args:
self.assertRelEqual(args, ['foo', '-bar'] + self.files + self.liby_files + self.libx_files)
# Use an order containing object files from libraries
order_files = [self.libx_files[1], self.libx_files[0], self.liby_files[2], self.files[1]]
order = [os.path.splitext(os.path.basename(f))[0] for f in order_files]
args.reorder(order[:2] + ['unknown'] + order[2:])
# self.files has objects at #1, #2, #4
self.assertRelEqual(args[:3], ['foo', '-bar'] + self.files[:1])
self.assertRelEqual(args[3:7], order_files)
self.assertRelEqual(args[7:9], [self.files[2], self.files[4]])
self.assertRelEqual(args[9:11], self.liby_files[:2])
self.assertRelEqual(args[11:12], [self.libx_files[2]])
self.assertRelEqual(args[12:14], [self.files[3], self.files[5]])
self.assertRelEqual(args[14:], [self.liby_files[3]])
if __name__ == '__main__':
unittest.main(testRunner=MozTestRunner())

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

@ -4909,7 +4909,9 @@ cairo-android)
MOZ_WEBGL=1
MOZ_PDF_PRINTING=1
MOZ_INSTRUMENT_EVENT_LOOP=1
MOZ_OLD_LINKER=1
if test "$MOZ_BUILD_APP" = "mobile/xul"; then
MOZ_OLD_LINKER=1
fi
MOZ_TOUCH=1
;;
@ -7159,6 +7161,9 @@ else
dnl And we need mozglue symbols to be exported.
MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS -rdynamic"
fi
if test "$MOZ_LINKER" = 1; then
MOZ_GLUE_PROGRAM_LDFLAGS="$MOZ_GLUE_PROGRAM_LDFLAGS $ZLIB_LIBS"
fi
fi
if test -z "$MOZ_MEMORY"; then
@ -9048,7 +9053,17 @@ if test -z "$MOZ_NATIVE_NSPR"; then
if test -n "$USE_ARM_KUSER"; then
ac_configure_args="$ac_configure_args --with-arm-kuser"
fi
if test -n "$MOZ_LINKER" -a -z "$MOZ_OLD_LINKER" -a $ac_cv_func_dladdr = no ; then
# dladdr is supported by the new linker, even when the system linker doesn't
# support it. Trick nspr into using dladdr when it's not supported.
_SAVE_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="-include $_topsrcdir/mozglue/linker/dladdr.h $CPPFLAGS"
fi
AC_OUTPUT_SUBDIRS(nsprpub)
if test -n "$MOZ_LINKER" -a -z "$MOZ_OLD_LINKER" -a $ac_cv_func_dladdr = no; then
unset CPPFLAGS
CPPFLAGS="$_SAVE_CFLAGS"
fi
ac_configure_args="$_SUBDIR_CONFIG_ARGS"
fi

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

@ -79,9 +79,14 @@ static fp_except_t oldmask = fpsetmask(~allmask);
#include "nsINode.h"
#include "nsHashtable.h"
#include "nsIDOMNode.h"
#include "nsHtml5Parser.h"
#include "nsHtml5StringParser.h"
#include "nsIParser.h"
#include "nsIDocument.h"
#include "nsIFragmentContentSink.h"
#include "nsContentSink.h"
#include "nsMathUtils.h"
#include "nsThreadUtils.h"
#include "nsIContent.h"
#include "nsCharSeparatedTokenizer.h"
#include "mozilla/AutoRestore.h"
@ -1044,7 +1049,8 @@ public:
* don't set to false when parsing into a target node that has been
* bound to tree.
* @return NS_ERROR_DOM_INVALID_STATE_ERR if a re-entrant attempt to parse
* fragments is made and NS_OK otherwise.
* fragments is made, NS_ERROR_OUT_OF_MEMORY if aSourceBuffer is too
* long and NS_OK otherwise.
*/
static nsresult ParseFragmentHTML(const nsAString& aSourceBuffer,
nsIContent* aTargetNode,
@ -1070,6 +1076,20 @@ public:
bool aPreventScriptExecution,
nsIDOMDocumentFragment** aReturn);
/**
* Parse a string into a document using the HTML parser.
* Script elements are marked unexecutable.
*
* @param aSourceBuffer the string to parse as an HTML document
* @param aTargetDocument the document object to parse into. Must not have
* child nodes.
* @return NS_ERROR_DOM_INVALID_STATE_ERR if a re-entrant attempt to parse
* fragments is made, NS_ERROR_OUT_OF_MEMORY if aSourceBuffer is too
* long and NS_OK otherwise.
*/
static nsresult ParseDocumentHTML(const nsAString& aSourceBuffer,
nsIDocument* aTargetDocument);
/**
* Creates a new XML document, which is marked to be loaded as data.
*
@ -1939,7 +1959,7 @@ private:
static bool sFullScreenKeyInputRestricted;
static PRUint32 sHandlingInputTimeout;
static nsHtml5Parser* sHTMLFragmentParser;
static nsHtml5StringParser* sHTMLFragmentParser;
static nsIParser* sXMLFragmentParser;
static nsIFragmentContentSink* sXMLFragmentSink;

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

@ -49,8 +49,8 @@
#include "nsIDOMHTMLScriptElement.h"
#define NS_ISCRIPTELEMENT_IID \
{ 0x5bb3b905, 0x5988, 0x476f, \
{ 0x95, 0x4f, 0x99, 0x02, 0x59, 0x82, 0x24, 0x67 } }
{ 0x24ab3ff2, 0xd75e, 0x4be4, \
{ 0x8d, 0x50, 0xd6, 0x75, 0x31, 0x29, 0xab, 0x65 } }
/**
* Internal interface implemented by script elements
@ -186,6 +186,28 @@ public:
mCreatorParser = getter_AddRefs(NS_GetWeakReference(aParser));
}
/**
* Unblocks the creator parser
*/
void UnblockParser()
{
nsCOMPtr<nsIParser> parser = do_QueryReferent(mCreatorParser);
if (parser) {
parser->UnblockParser();
}
}
/**
* Attempts to resume parsing asynchronously
*/
void ContinueParserAsync()
{
nsCOMPtr<nsIParser> parser = do_QueryReferent(mCreatorParser);
if (parser) {
parser->ContinueInterruptedParsingAsync();
}
}
/**
* Informs the creator parser that the evaluation of this script is starting
*/

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

@ -103,7 +103,7 @@ public:
NS_IMETHOD WillParse(void) { return NS_OK; }
NS_IMETHOD WillInterrupt(void) { return NS_OK; }
NS_IMETHOD WillResume(void) { return NS_OK; }
NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
NS_IMETHOD SetParser(nsParserBase* aParser) { return NS_OK; }
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);

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

@ -109,68 +109,16 @@ using namespace mozilla;
PRLogModuleInfo* gContentSinkLogModuleInfo;
class nsScriptLoaderObserverProxy : public nsIScriptLoaderObserver
{
public:
nsScriptLoaderObserverProxy(nsIScriptLoaderObserver* aInner)
: mInner(do_GetWeakReference(aInner))
{
}
virtual ~nsScriptLoaderObserverProxy()
{
}
NS_DECL_ISUPPORTS
NS_DECL_NSISCRIPTLOADEROBSERVER
nsWeakPtr mInner;
};
NS_IMPL_ISUPPORTS1(nsScriptLoaderObserverProxy, nsIScriptLoaderObserver)
NS_IMETHODIMP
nsScriptLoaderObserverProxy::ScriptAvailable(nsresult aResult,
nsIScriptElement *aElement,
bool aIsInline,
nsIURI *aURI,
PRInt32 aLineNo)
{
nsCOMPtr<nsIScriptLoaderObserver> inner = do_QueryReferent(mInner);
if (inner) {
return inner->ScriptAvailable(aResult, aElement, aIsInline, aURI,
aLineNo);
}
return NS_OK;
}
NS_IMETHODIMP
nsScriptLoaderObserverProxy::ScriptEvaluated(nsresult aResult,
nsIScriptElement *aElement,
bool aIsInline)
{
nsCOMPtr<nsIScriptLoaderObserver> inner = do_QueryReferent(mInner);
if (inner) {
return inner->ScriptEvaluated(aResult, aElement, aIsInline);
}
return NS_OK;
}
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsContentSink)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsContentSink)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsContentSink)
NS_INTERFACE_MAP_ENTRY(nsICSSLoaderObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIScriptLoaderObserver)
NS_INTERFACE_MAP_ENTRY(nsIDocumentObserver)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIScriptLoaderObserver)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocumentObserver)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_CLASS(nsContentSink)
@ -182,7 +130,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsContentSink)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mParser)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mNodeInfoManager)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mScriptLoader)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mScriptElements)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsContentSink)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDocument)
@ -190,7 +137,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsContentSink)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mNodeInfoManager,
nsNodeInfoManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mScriptLoader)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mScriptElements)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
@ -235,7 +181,6 @@ PRInt32 nsContentSink::sPerfParseTime;
PRInt32 nsContentSink::sInteractiveTime;
PRInt32 nsContentSink::sInitialPerfTime;
PRInt32 nsContentSink::sEnablePerfMode;
bool nsContentSink::sCanInterruptParser;
void
nsContentSink::InitializeStatics()
@ -272,8 +217,6 @@ nsContentSink::InitializeStatics()
"content.sink.initial_perf_time", 2000000);
Preferences::AddIntVarCache(&sEnablePerfMode,
"content.sink.enable_perf_mode", 0);
Preferences::AddBoolVarCache(&sCanInterruptParser,
"content.interrupt.parsing", true);
}
nsresult
@ -295,7 +238,7 @@ nsContentSink::Init(nsIDocument* aDoc,
mDocShell = do_QueryInterface(aContainer);
mScriptLoader = mDocument->ScriptLoader();
if (!mFragmentMode) {
if (!mRunsToCompletion) {
if (mDocShell) {
PRUint32 loadType = 0;
mDocShell->GetLoadType(&loadType);
@ -303,13 +246,6 @@ nsContentSink::Init(nsIDocument* aDoc,
(loadType & nsIDocShell::LOAD_CMD_HISTORY) == 0);
}
// use this to avoid a circular reference sink->document->scriptloader->sink
nsCOMPtr<nsIScriptLoaderObserver> proxy =
new nsScriptLoaderObserverProxy(this);
NS_ENSURE_TRUE(proxy, NS_ERROR_OUT_OF_MEMORY);
mScriptLoader->AddObserver(proxy);
ProcessHTTPHeaders(aChannel);
}
@ -324,10 +260,6 @@ nsContentSink::Init(nsIDocument* aDoc,
FavorPerformanceHint(!mDynamicLowerValue, 0);
}
// prevent DropParserAndPerfHint from unblocking onload in the fragment
// case
mCanInterruptParser = !mFragmentMode && sCanInterruptParser;
return NS_OK;
}
@ -336,7 +268,7 @@ nsContentSink::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
bool aWasAlternate,
nsresult aStatus)
{
NS_ASSERTION(!mFragmentMode, "How come a fragment parser observed sheets?");
NS_ASSERTION(!mRunsToCompletion, "How come a fragment parser observed sheets?");
if (!aWasAlternate) {
NS_ASSERTION(mPendingSheetCount > 0, "How'd that happen?");
--mPendingSheetCount;
@ -366,90 +298,6 @@ nsContentSink::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
return NS_OK;
}
NS_IMETHODIMP
nsContentSink::ScriptAvailable(nsresult aResult,
nsIScriptElement *aElement,
bool aIsInline,
nsIURI *aURI,
PRInt32 aLineNo)
{
PRUint32 count = mScriptElements.Count();
// aElement will not be in mScriptElements if a <script> was added
// using the DOM during loading or if DoneAddingChildren did not return
// NS_ERROR_HTMLPARSER_BLOCK.
NS_ASSERTION(count == 0 ||
mScriptElements.IndexOf(aElement) == PRInt32(count - 1) ||
mScriptElements.IndexOf(aElement) == -1,
"script found at unexpected position");
// Check if this is the element we were waiting for
if (count == 0 || aElement != mScriptElements[count - 1]) {
return NS_OK;
}
NS_ASSERTION(!aElement->GetScriptDeferred(), "defer script was in mScriptElements");
NS_ASSERTION(!aElement->GetScriptAsync(), "async script was in mScriptElements");
if (mParser && !mParser->IsParserEnabled()) {
// make sure to unblock the parser before evaluating the script,
// we must unblock the parser even if loading the script failed or
// if the script was empty, if we don't, the parser will never be
// unblocked.
mParser->UnblockParser();
}
if (NS_SUCCEEDED(aResult)) {
PreEvaluateScript();
} else {
mScriptElements.RemoveObjectAt(count - 1);
if (mParser && aResult != NS_BINDING_ABORTED) {
// Loading external script failed!. So, resume parsing since the parser
// got blocked when loading external script. See
// http://bugzilla.mozilla.org/show_bug.cgi?id=94903.
//
// XXX We don't resume parsing if we get NS_BINDING_ABORTED from the
// script load, assuming that that error code means that the user
// stopped the load through some action (like clicking a link). See
// http://bugzilla.mozilla.org/show_bug.cgi?id=243392.
ContinueInterruptedParsingAsync();
}
}
return NS_OK;
}
NS_IMETHODIMP
nsContentSink::ScriptEvaluated(nsresult aResult,
nsIScriptElement *aElement,
bool aIsInline)
{
mDeflectedCount = sPerfDeflectCount;
// Check if this is the element we were waiting for
PRInt32 count = mScriptElements.Count();
if (count == 0 || aElement != mScriptElements[count - 1]) {
return NS_OK;
}
NS_ASSERTION(!aElement->GetScriptDeferred(), "defer script was in mScriptElements");
NS_ASSERTION(!aElement->GetScriptAsync(), "async script was in mScriptElements");
// Pop the script element stack
mScriptElements.RemoveObjectAt(count - 1);
if (NS_SUCCEEDED(aResult)) {
PostEvaluateScript(aElement);
}
if (mParser && mParser->IsParserEnabled()) {
ContinueInterruptedParsingAsync();
}
return NS_OK;
}
nsresult
nsContentSink::ProcessHTTPHeaders(nsIChannel* aChannel)
{
@ -884,10 +732,10 @@ nsContentSink::ProcessStyleLink(nsIContent* aElement,
// If this is a fragment parser, we don't want to observe.
bool isAlternate;
rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, aAlternate,
mFragmentMode ? nsnull : this, &isAlternate);
mRunsToCompletion ? nsnull : this, &isAlternate);
NS_ENSURE_SUCCESS(rv, rv);
if (!isAlternate && !mFragmentMode) {
if (!isAlternate && !mRunsToCompletion) {
++mPendingSheetCount;
mScriptLoader->AddExecuteBlocker();
}
@ -1499,7 +1347,7 @@ nsContentSink::WillResumeImpl()
nsresult
nsContentSink::DidProcessATokenImpl()
{
if (!mCanInterruptParser || !mParser || !mParser->CanInterrupt()) {
if (mRunsToCompletion || !mParser) {
return NS_OK;
}
@ -1628,7 +1476,7 @@ nsContentSink::DropParserAndPerfHint(void)
// actually broken.
// Drop our reference to the parser to get rid of a circular
// reference.
nsCOMPtr<nsIParser> kungFuDeathGrip(mParser.forget());
nsRefPtr<nsParserBase> kungFuDeathGrip(mParser.forget());
if (mDynamicLowerValue) {
// Reset the performance hint which was set to FALSE
@ -1636,7 +1484,7 @@ nsContentSink::DropParserAndPerfHint(void)
FavorPerformanceHint(true, 0);
}
if (mCanInterruptParser) {
if (!mRunsToCompletion) {
mDocument->UnblockOnload(true);
}
}
@ -1650,7 +1498,7 @@ nsContentSink::IsScriptExecutingImpl()
nsresult
nsContentSink::WillParseImpl(void)
{
if (!mCanInterruptParser) {
if (mRunsToCompletion) {
return NS_OK;
}
@ -1689,7 +1537,7 @@ nsContentSink::WillParseImpl(void)
void
nsContentSink::WillBuildModelImpl()
{
if (mCanInterruptParser) {
if (!mRunsToCompletion) {
mDocument->BlockOnload();
mBeginLoadTime = PR_IntervalToMicroseconds(PR_IntervalNow());
@ -1704,25 +1552,6 @@ nsContentSink::WillBuildModelImpl()
}
}
void
nsContentSink::ContinueInterruptedParsingIfEnabled()
{
// This shouldn't be called in the HTML5 case.
if (mParser && mParser->IsParserEnabled()) {
mParser->ContinueInterruptedParsing();
}
}
// Overridden in the HTML5 case
void
nsContentSink::ContinueInterruptedParsingAsync()
{
nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this,
&nsContentSink::ContinueInterruptedParsingIfEnabled);
NS_DispatchToCurrentThread(ev);
}
/* static */
void
nsContentSink::NotifyDocElementCreated(nsIDocument* aDoc)

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

@ -46,7 +46,6 @@
// Base class for contentsink implementations.
#include "nsICSSLoaderObserver.h"
#include "nsIScriptLoaderObserver.h"
#include "nsWeakReference.h"
#include "nsCOMPtr.h"
#include "nsCOMArray.h"
@ -64,6 +63,7 @@
#include "nsIRequest.h"
#include "nsCycleCollectionParticipant.h"
#include "nsThreadUtils.h"
#include "nsIScriptElement.h"
class nsIDocument;
class nsIURI;
@ -113,16 +113,13 @@ extern PRLogModuleInfo* gContentSinkLogModuleInfo;
#define NS_DELAY_FOR_WINDOW_CREATION 500000
class nsContentSink : public nsICSSLoaderObserver,
public nsIScriptLoaderObserver,
public nsSupportsWeakReference,
public nsStubDocumentObserver,
public nsITimerCallback
{
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsContentSink,
nsIScriptLoaderObserver)
NS_DECL_NSISCRIPTLOADEROBSERVER
nsICSSLoaderObserver)
// nsITimerCallback
NS_DECL_NSITIMERCALLBACK
@ -290,10 +287,6 @@ protected:
return sNotificationInterval;
}
// Overridable hooks into script evaluation
virtual void PreEvaluateScript() {return;}
virtual void PostEvaluateScript(nsIScriptElement *aElement) {return;}
virtual nsresult FlushTags() = 0;
// Later on we might want to make this more involved somehow
@ -302,6 +295,10 @@ protected:
void DoProcessLinkHeader();
void StopDeflecting() {
mDeflectedCount = sPerfDeflectCount;
}
private:
// People shouldn't be allocating this class directly. All subclasses should
// be allocated using a zeroing operator new.
@ -309,19 +306,14 @@ private:
protected:
virtual void ContinueInterruptedParsingAsync();
void ContinueInterruptedParsingIfEnabled();
nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<nsIParser> mParser;
nsRefPtr<nsParserBase> mParser;
nsCOMPtr<nsIURI> mDocumentURI;
nsCOMPtr<nsIDocShell> mDocShell;
nsRefPtr<mozilla::css::Loader> mCSSLoader;
nsRefPtr<nsNodeInfoManager> mNodeInfoManager;
nsRefPtr<nsScriptLoader> mScriptLoader;
nsCOMArray<nsIScriptElement> mScriptElements;
// back off timer notification after count
PRInt32 mBackoffCount;
@ -335,7 +327,6 @@ protected:
// Have we already called BeginUpdate for this set of content changes?
PRUint8 mBeganUpdate : 1;
PRUint8 mLayoutStarted : 1;
PRUint8 mCanInterruptParser : 1;
PRUint8 mDynamicLowerValue : 1;
PRUint8 mParsing : 1;
PRUint8 mDroppedTimer : 1;
@ -347,8 +338,9 @@ protected:
// shouldn't be performing any more content model notifications,
// since we're not longer updating our child counts.
PRUint8 mIsDocumentObserver : 1;
// True if this is a fragment parser
PRUint8 mFragmentMode : 1;
// True if this is parser is a fragment parser or an HTML DOMParser.
// XML DOMParser leaves this to false for now!
PRUint8 mRunsToCompletion : 1;
// True to call prevent script execution in the fragment mode.
PRUint8 mPreventScriptExecution : 1;
@ -406,7 +398,6 @@ protected:
static PRInt32 sInitialPerfTime;
// Should we switch between perf-mode and interactive-mode
static PRInt32 sEnablePerfMode;
static bool sCanInterruptParser;
};
#endif // _nsContentSink_h_

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

@ -279,7 +279,7 @@ bool nsContentUtils::sFullScreenKeyInputRestricted = true;
PRUint32 nsContentUtils::sHandlingInputTimeout = 1000;
nsHtml5Parser* nsContentUtils::sHTMLFragmentParser = nsnull;
nsHtml5StringParser* nsContentUtils::sHTMLFragmentParser = nsnull;
nsIParser* nsContentUtils::sXMLFragmentParser = nsnull;
nsIFragmentContentSink* nsContentUtils::sXMLFragmentSink = nsnull;
bool nsContentUtils::sFragmentParsingActive = false;
@ -3663,18 +3663,37 @@ nsContentUtils::ParseFragmentHTML(const nsAString& aSourceBuffer,
mozilla::AutoRestore<bool> guard(nsContentUtils::sFragmentParsingActive);
nsContentUtils::sFragmentParsingActive = true;
if (!sHTMLFragmentParser) {
sHTMLFragmentParser =
static_cast<nsHtml5Parser*>(nsHtml5Module::NewHtml5Parser().get());
NS_ADDREF(sHTMLFragmentParser = new nsHtml5StringParser());
// Now sHTMLFragmentParser owns the object
}
nsresult rv =
sHTMLFragmentParser->ParseHtml5Fragment(aSourceBuffer,
aTargetNode,
aContextLocalName,
aContextNamespace,
aQuirks,
aPreventScriptExecution);
sHTMLFragmentParser->Reset();
sHTMLFragmentParser->ParseFragment(aSourceBuffer,
aTargetNode,
aContextLocalName,
aContextNamespace,
aQuirks,
aPreventScriptExecution);
return rv;
}
/* static */
nsresult
nsContentUtils::ParseDocumentHTML(const nsAString& aSourceBuffer,
nsIDocument* aTargetDocument)
{
if (nsContentUtils::sFragmentParsingActive) {
NS_NOTREACHED("Re-entrant fragment parsing attempted.");
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
mozilla::AutoRestore<bool> guard(nsContentUtils::sFragmentParsingActive);
nsContentUtils::sFragmentParsingActive = true;
if (!sHTMLFragmentParser) {
NS_ADDREF(sHTMLFragmentParser = new nsHtml5StringParser());
// Now sHTMLFragmentParser owns the object
}
nsresult rv =
sHTMLFragmentParser->ParseDocument(aSourceBuffer,
aTargetDocument);
return rv;
}

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

@ -43,7 +43,6 @@
#include "nsIInputStream.h"
#include "nsNetUtil.h"
#include "nsStringStream.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIScriptSecurityManager.h"
#include "nsIPrincipal.h"
@ -95,13 +94,40 @@ nsDOMParser::ParseFromString(const PRUnichar *str,
NS_ENSURE_ARG(str);
NS_ENSURE_ARG_POINTER(aResult);
nsresult rv;
if (!nsCRT::strcmp(contentType, "text/html")) {
nsCOMPtr<nsIDOMDocument> domDocument;
rv = SetUpDocument(DocumentFlavorHTML, getter_AddRefs(domDocument));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
nsDependentString sourceBuffer(str);
rv = nsContentUtils::ParseDocumentHTML(sourceBuffer, document);
NS_ENSURE_SUCCESS(rv, rv);
// Keep the XULXBL state, base URL and principal setting in sync with the
// XML case
if (nsContentUtils::IsSystemPrincipal(mOriginalPrincipal)) {
document->ForceEnableXULXBL();
}
// Make sure to give this document the right base URI
document->SetBaseURI(mBaseURI);
// And the right principal
document->SetPrincipal(mPrincipal);
domDocument.forget(aResult);
return rv;
}
NS_ConvertUTF16toUTF8 data(str);
// The new stream holds a reference to the buffer
nsCOMPtr<nsIInputStream> stream;
nsresult rv = NS_NewByteInputStream(getter_AddRefs(stream),
data.get(), data.Length(),
NS_ASSIGNMENT_DEPEND);
rv = NS_NewByteInputStream(getter_AddRefs(stream),
data.get(), data.Length(),
NS_ASSIGNMENT_DEPEND);
if (NS_FAILED(rv))
return rv;
@ -152,24 +178,8 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
!svg)
return NS_ERROR_NOT_IMPLEMENTED;
nsCOMPtr<nsIScriptGlobalObject> scriptHandlingObject =
do_QueryReferent(mScriptHandlingObject);
nsresult rv;
if (!mPrincipal) {
NS_ENSURE_TRUE(!mAttemptedInit, NS_ERROR_NOT_INITIALIZED);
AttemptedInitMarker marker(&mAttemptedInit);
nsCOMPtr<nsIPrincipal> prin =
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = Init(prin, nsnull, nsnull, scriptHandlingObject);
NS_ENSURE_SUCCESS(rv, rv);
}
NS_ASSERTION(mPrincipal, "Must have principal by now");
NS_ASSERTION(mDocumentURI, "Must have document URI by now");
// Put the nsCOMPtr out here so we hold a ref to the stream as needed
nsCOMPtr<nsIInputStream> bufferedStream;
if (!NS_InputStreamIsBuffered(stream)) {
@ -180,18 +190,9 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
stream = bufferedStream;
}
// Here we have to cheat a little bit... Setting the base URI won't
// work if the document has a null principal, so use
// mOriginalPrincipal when creating the document, then reset the
// principal.
nsCOMPtr<nsIDOMDocument> domDocument;
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(), nsnull,
mDocumentURI, mBaseURI,
mOriginalPrincipal,
scriptHandlingObject,
svg ? DocumentFlavorSVG :
DocumentFlavorLegacyGuess,
getter_AddRefs(domDocument));
rv = SetUpDocument(svg ? DocumentFlavorSVG : DocumentFlavorLegacyGuess,
getter_AddRefs(domDocument));
NS_ENSURE_SUCCESS(rv, rv);
// Create a fake channel
@ -217,6 +218,9 @@ nsDOMParser::ParseFromStream(nsIInputStream *stream,
nsCOMPtr<nsIDocument> document(do_QueryInterface(domDocument));
if (!document) return NS_ERROR_FAILURE;
// Keep the XULXBL state, base URL and principal setting in sync with the
// HTML case
if (nsContentUtils::IsSystemPrincipal(mOriginalPrincipal)) {
document->ForceEnableXULXBL();
}
@ -481,3 +485,36 @@ nsDOMParser::Init(nsIPrincipal *aPrincipal, nsIURI *aDocumentURI,
return Init(principal, aDocumentURI, aBaseURI,
scriptContext ? scriptContext->GetGlobalObject() : nsnull);
}
nsresult
nsDOMParser::SetUpDocument(DocumentFlavor aFlavor, nsIDOMDocument** aResult)
{
nsCOMPtr<nsIScriptGlobalObject> scriptHandlingObject =
do_QueryReferent(mScriptHandlingObject);
nsresult rv;
if (!mPrincipal) {
NS_ENSURE_TRUE(!mAttemptedInit, NS_ERROR_NOT_INITIALIZED);
AttemptedInitMarker marker(&mAttemptedInit);
nsCOMPtr<nsIPrincipal> prin =
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = Init(prin, nsnull, nsnull, scriptHandlingObject);
NS_ENSURE_SUCCESS(rv, rv);
}
NS_ASSERTION(mPrincipal, "Must have principal by now");
NS_ASSERTION(mDocumentURI, "Must have document URI by now");
// Here we have to cheat a little bit... Setting the base URI won't
// work if the document has a null principal, so use
// mOriginalPrincipal when creating the document, then reset the
// principal.
return nsContentUtils::CreateDocument(EmptyString(), EmptyString(), nsnull,
mDocumentURI, mBaseURI,
mOriginalPrincipal,
scriptHandlingObject,
aFlavor,
aResult);
}

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

@ -43,6 +43,7 @@
#include "nsIURI.h"
#include "nsWeakReference.h"
#include "nsIJSNativeInitializer.h"
#include "nsIDocument.h"
class nsDOMParser : public nsIDOMParser,
public nsIDOMParserJS,
@ -66,6 +67,8 @@ public:
PRUint32 argc, jsval *argv);
private:
nsresult SetUpDocument(DocumentFlavor aFlavor, nsIDOMDocument** aResult);
class AttemptedInitMarker {
public:
AttemptedInitMarker(bool* aAttemptedInit) :

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

@ -104,7 +104,7 @@ public:
NS_IMETHOD WillParse(void) { return NS_OK; }
NS_IMETHOD WillInterrupt(void) { return NS_OK; }
NS_IMETHOD WillResume(void) { return NS_OK; }
NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
NS_IMETHOD SetParser(nsParserBase* aParser) { return NS_OK; }
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsHTMLTag aTag);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);

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

@ -942,8 +942,9 @@ nsScriptLoader::ProcessPendingRequests()
!mParserBlockingRequest->mLoading &&
ReadyToExecuteScripts()) {
request.swap(mParserBlockingRequest);
// nsContentSink::ScriptAvailable unblocks the parser
UnblockParser(request);
ProcessRequest(request);
ContinueParserAsync(request);
}
while (ReadyToExecuteScripts() &&
@ -1169,8 +1170,9 @@ nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader,
FireScriptAvailable(rv, request);
} else if (mParserBlockingRequest == request) {
mParserBlockingRequest = nsnull;
// nsContentSink::ScriptAvailable unblocks the parser
UnblockParser(request);
FireScriptAvailable(rv, request);
ContinueParserAsync(request);
} else {
mPreloads.RemoveElement(request, PreloadRequestComparator());
}
@ -1182,6 +1184,18 @@ nsScriptLoader::OnStreamComplete(nsIStreamLoader* aLoader,
return NS_OK;
}
void
nsScriptLoader::UnblockParser(nsScriptLoadRequest* aParserBlockingRequest)
{
aParserBlockingRequest->mElement->UnblockParser();
}
void
nsScriptLoader::ContinueParserAsync(nsScriptLoadRequest* aParserBlockingRequest)
{
aParserBlockingRequest->mElement->ContinueParserAsync();
}
nsresult
nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
nsIStreamLoader* aLoader,

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

@ -243,6 +243,17 @@ public:
const nsAString &aType);
private:
/**
* Unblocks the creator parser of the parser-blocking scripts.
*/
void UnblockParser(nsScriptLoadRequest* aParserBlockingRequest);
/**
* Asynchronously resumes the creator parser of the parser-blocking scripts.
*/
void ContinueParserAsync(nsScriptLoadRequest* aParserBlockingRequest);
/**
* Helper function to check the content policy for a given request.
*/

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

@ -57,6 +57,7 @@ CPPSRCS = \
nsClientRect.cpp \
nsHTMLDNSPrefetch.cpp \
nsGenericHTMLElement.cpp \
nsGenericHTMLFrameElement.cpp \
nsFormSubmission.cpp \
nsTextEditorState.cpp \
nsHTMLElement.cpp \

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

@ -2552,9 +2552,6 @@ nsGenericHTMLElement::GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu)
//----------------------------------------------------------------------
NS_IMPL_INT_ATTR(nsGenericHTMLFrameElement, TabIndex, tabindex)
NS_IMPL_BOOL_ATTR(nsGenericHTMLFrameElement, MozBrowser, mozbrowser)
nsGenericHTMLFormElement::nsGenericHTMLFormElement(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsGenericHTMLElement(aNodeInfo)
, mForm(nsnull)
@ -2665,24 +2662,6 @@ nsGenericHTMLFormElement::GetDesiredIMEState()
return state;
}
bool
nsGenericHTMLFrameElement::IsHTMLFocusable(bool aWithMouse,
bool *aIsFocusable,
PRInt32 *aTabIndex)
{
if (nsGenericHTMLElement::IsHTMLFocusable(aWithMouse, aIsFocusable, aTabIndex)) {
return true;
}
*aIsFocusable = nsContentUtils::IsSubDocumentTabbable(this);
if (!*aIsFocusable && aTabIndex) {
*aTabIndex = -1;
}
return false;
}
nsresult
nsGenericHTMLFormElement::BindToTree(nsIDocument* aDocument,
nsIContent* aParent,
@ -3208,333 +3187,6 @@ nsGenericHTMLFormElement::FieldSetDisabledChanged(bool aNotify)
//----------------------------------------------------------------------
nsGenericHTMLFrameElement::~nsGenericHTMLFrameElement()
{
if (mFrameLoader) {
mFrameLoader->Destroy();
}
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsGenericHTMLFrameElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGenericHTMLFrameElement,
nsGenericHTMLElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mFrameLoader, nsIFrameLoader)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_TABLE_HEAD(nsGenericHTMLFrameElement)
NS_INTERFACE_TABLE_INHERITED2(nsGenericHTMLFrameElement,
nsIFrameLoaderOwner,
nsIDOMMozBrowserFrameElement)
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsGenericHTMLFrameElement)
NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
nsresult
nsGenericHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
{
NS_PRECONDITION(aContentDocument, "Null out param");
*aContentDocument = nsnull;
nsCOMPtr<nsIDOMWindow> win;
GetContentWindow(getter_AddRefs(win));
if (!win) {
return NS_OK;
}
return win->GetDocument(aContentDocument);
}
nsresult
nsGenericHTMLFrameElement::GetContentWindow(nsIDOMWindow** aContentWindow)
{
NS_PRECONDITION(aContentWindow, "Null out param");
*aContentWindow = nsnull;
nsresult rv = EnsureFrameLoader();
NS_ENSURE_SUCCESS(rv, rv);
if (!mFrameLoader) {
return NS_OK;
}
bool depthTooGreat = false;
mFrameLoader->GetDepthTooGreat(&depthTooGreat);
if (depthTooGreat) {
// Claim to have no contentWindow
return NS_OK;
}
nsCOMPtr<nsIDocShell> doc_shell;
mFrameLoader->GetDocShell(getter_AddRefs(doc_shell));
nsCOMPtr<nsPIDOMWindow> win(do_GetInterface(doc_shell));
if (!win) {
return NS_OK;
}
NS_ASSERTION(win->IsOuterWindow(),
"Uh, this window should always be an outer window!");
return CallQueryInterface(win, aContentWindow);
}
nsresult
nsGenericHTMLFrameElement::EnsureFrameLoader()
{
if (!GetParent() || !IsInDoc() || mFrameLoader) {
// If frame loader is there, we just keep it around, cached
return NS_OK;
}
mFrameLoader = nsFrameLoader::Create(this, mNetworkCreated);
return NS_OK;
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::GetFrameLoader(nsIFrameLoader **aFrameLoader)
{
NS_IF_ADDREF(*aFrameLoader = mFrameLoader);
return NS_OK;
}
NS_IMETHODIMP_(already_AddRefed<nsFrameLoader>)
nsGenericHTMLFrameElement::GetFrameLoader()
{
nsRefPtr<nsFrameLoader> loader = mFrameLoader;
return loader.forget();
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::SwapFrameLoaders(nsIFrameLoaderOwner* aOtherOwner)
{
// We don't support this yet
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsGenericHTMLFrameElement::LoadSrc()
{
nsresult rv = EnsureFrameLoader();
NS_ENSURE_SUCCESS(rv, rv);
if (!mFrameLoader) {
return NS_OK;
}
rv = mFrameLoader->LoadFrame();
#ifdef DEBUG
if (NS_FAILED(rv)) {
NS_WARNING("failed to load URL");
}
#endif
return rv;
}
nsresult
nsGenericHTMLFrameElement::BindToTree(nsIDocument* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
"Missing a script blocker!");
// We're in a document now. Kick off the frame load.
LoadSrc();
}
// We're now in document and scripts may move us, so clear
// the mNetworkCreated flag.
mNetworkCreated = false;
return rv;
}
void
nsGenericHTMLFrameElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
if (mFrameLoader) {
// This iframe is being taken out of the document, destroy the
// iframe's frame loader (doing that will tear down the window in
// this iframe).
// XXXbz we really want to only partially destroy the frame
// loader... we don't want to tear down the docshell. Food for
// later bug.
mFrameLoader->Destroy();
mFrameLoader = nsnull;
}
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
}
nsresult
nsGenericHTMLFrameElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify)
{
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::src) {
// Don't propagate error here. The attribute was successfully set, that's
// what we should reflect.
LoadSrc();
}
return NS_OK;
}
void
nsGenericHTMLFrameElement::DestroyContent()
{
if (mFrameLoader) {
mFrameLoader->Destroy();
mFrameLoader = nsnull;
}
nsGenericHTMLElement::DestroyContent();
}
nsresult
nsGenericHTMLFrameElement::CopyInnerTo(nsGenericElement* aDest) const
{
nsresult rv = nsGenericHTMLElement::CopyInnerTo(aDest);
NS_ENSURE_SUCCESS(rv, rv);
nsIDocument* doc = aDest->OwnerDoc();
if (doc->IsStaticDocument() && mFrameLoader) {
nsGenericHTMLFrameElement* dest =
static_cast<nsGenericHTMLFrameElement*>(aDest);
nsFrameLoader* fl = nsFrameLoader::Create(dest, false);
NS_ENSURE_STATE(fl);
dest->mFrameLoader = fl;
static_cast<nsFrameLoader*>(mFrameLoader.get())->CreateStaticClone(fl);
}
return rv;
}
PRInt64
nsGenericHTMLFrameElement::SizeOf() const
{
PRInt64 size = MemoryReporter::GetBasicSize<nsGenericHTMLFrameElement,
nsGenericHTMLElement>(this);
// TODO: need to implement SizeOf() in nsFrameLoader, bug 672539.
size += mFrameLoader ? sizeof(*mFrameLoader.get()) : 0;
return size;
}
namespace {
// GetContentStateCallbackRunnable is used by MozGetContentState to fire its callback
// asynchronously.
class GetContentStateCallbackRunnable : public nsRunnable
{
public:
GetContentStateCallbackRunnable(nsIDOMMozGetContentStateCallback *aCallback,
nsIDOMEventTarget *aEventTarget,
const nsAString &aResult)
: mCallback(aCallback)
, mEventTarget(aEventTarget)
, mResult(aResult)
{
}
NS_IMETHOD Run()
{
FireCallback();
// Break cycles.
mCallback = NULL;
mEventTarget = NULL;
return NS_OK;
}
private:
void FireCallback()
{
nsCxPusher pusher;
if (!pusher.Push(mEventTarget)) {
return;
}
mCallback->Callback(mResult);
}
nsCOMPtr<nsIDOMMozGetContentStateCallback> mCallback;
nsCOMPtr<nsIDOMEventTarget> mEventTarget;
const nsString mResult;
};
} // anonymous namespace
nsresult
nsGenericHTMLFrameElement::BrowserFrameSecurityCheck()
{
if (!Preferences::GetBool("dom.mozBrowserFramesEnabled")) {
return NS_ERROR_FAILURE;
}
bool browser;
GetMozBrowser(&browser);
if (!browser) {
return NS_ERROR_FAILURE;
}
nsIPrincipal *principal = NodePrincipal();
nsCOMPtr<nsIURI> principalURI;
principal->GetURI(getter_AddRefs(principalURI));
if (!nsContentUtils::URIIsChromeOrInPref(principalURI,
"dom.mozBrowserFramesWhitelist")) {
return NS_ERROR_DOM_SECURITY_ERR;
}
return NS_OK;
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::MozGetContentState(const nsAString &aProperty,
nsIDOMMozGetContentStateCallback *aCallback)
{
nsresult rv = BrowserFrameSecurityCheck();
NS_ENSURE_SUCCESS(rv, rv);
if (!aProperty.EqualsLiteral("location")) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDOMWindow> contentWindow;
GetContentWindow(getter_AddRefs(contentWindow));
NS_ENSURE_TRUE(contentWindow, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMLocation> location;
rv = contentWindow->GetLocation(getter_AddRefs(location));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString href;
rv = location->ToString(href);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDOMEventTarget> eventTarget =
do_QueryInterface(nsContentUtils::GetWindowFromCaller());
NS_ENSURE_TRUE(eventTarget, NS_ERROR_FAILURE);
// Asynchronously fire the callback.
nsRefPtr<GetContentStateCallbackRunnable> runnable =
new GetContentStateCallbackRunnable(aCallback, eventTarget, href);
NS_DispatchToMainThread(runnable);
return NS_OK;
}
//----------------------------------------------------------------------
nsresult
nsGenericHTMLElement::Blur()
{

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

@ -42,12 +42,10 @@
#include "nsIDOMHTMLElement.h"
#include "nsINameSpaceManager.h" // for kNameSpaceID_None
#include "nsIFormControl.h"
#include "nsIDOMHTMLFrameElement.h"
#include "nsFrameLoader.h"
#include "nsGkAtoms.h"
#include "nsContentCreatorFunctions.h"
#include "nsDOMMemoryReporter.h"
#include "nsIDOMMozBrowserFrameElement.h"
class nsIDOMAttr;
class nsIDOMEventListener;
@ -1015,79 +1013,6 @@ PR_STATIC_ASSERT(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + 1 < 32);
//----------------------------------------------------------------------
/**
* A helper class for frame elements
*/
class nsGenericHTMLFrameElement : public nsGenericHTMLElement,
public nsIFrameLoaderOwner,
public nsIDOMMozBrowserFrameElement
{
public:
nsGenericHTMLFrameElement(already_AddRefed<nsINodeInfo> aNodeInfo,
mozilla::dom::FromParser aFromParser)
: nsGenericHTMLElement(aNodeInfo)
{
mNetworkCreated = aFromParser == mozilla::dom::FROM_PARSER_NETWORK;
}
virtual ~nsGenericHTMLFrameElement();
NS_DECL_DOM_MEMORY_REPORTER_SIZEOF
// nsISupports
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
// nsIFrameLoaderOwner
NS_DECL_NSIFRAMELOADEROWNER
// nsIContent
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, PRInt32 *aTabIndex);
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers);
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true);
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, bool aNotify)
{
return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
}
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify);
virtual void DestroyContent();
nsresult CopyInnerTo(nsGenericElement* aDest) const;
// nsIDOMHTMLElement
NS_IMETHOD GetTabIndex(PRInt32 *aTabIndex);
NS_IMETHOD SetTabIndex(PRInt32 aTabIndex);
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsGenericHTMLFrameElement,
nsGenericHTMLElement)
// nsIDOMMozBrowserFrameElement
NS_DECL_NSIDOMMOZBROWSERFRAMEELEMENT
protected:
// This doesn't really ensure a frame loade in all cases, only when
// it makes sense.
nsresult EnsureFrameLoader();
nsresult LoadSrc();
nsresult GetContentDocument(nsIDOMDocument** aContentDocument);
nsresult GetContentWindow(nsIDOMWindow** aContentWindow);
nsresult BrowserFrameSecurityCheck();
nsRefPtr<nsFrameLoader> mFrameLoader;
// True when the element is created by the parser
// using NS_FROM_PARSER_NETWORK flag.
// If the element is modified, it may lose the flag.
bool mNetworkCreated;
};
//----------------------------------------------------------------------
/**
* A macro to implement the getter and setter for a given string
* valued content property. The method uses the generic GetAttr and

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

@ -0,0 +1,446 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsGenericHTMLFrameElement.h"
#include "nsIWebProgress.h"
#include "nsIPrivateDOMEvent.h"
#include "nsIDOMCustomEvent.h"
#include "nsIVariant.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsVariant.h"
#include "nsContentUtils.h"
#include "nsDOMMemoryReporter.h"
#include "nsEventDispatcher.h"
#include "nsContentUtils.h"
#include "nsAsyncDOMEvent.h"
#include "mozilla/Preferences.h"
using namespace mozilla;
using namespace mozilla::dom;
NS_IMPL_CYCLE_COLLECTION_CLASS(nsGenericHTMLFrameElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGenericHTMLFrameElement,
nsGenericHTMLElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mFrameLoader, nsIFrameLoader)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_TABLE_HEAD(nsGenericHTMLFrameElement)
NS_INTERFACE_TABLE_INHERITED3(nsGenericHTMLFrameElement,
nsIFrameLoaderOwner,
nsIDOMMozBrowserFrame,
nsIWebProgressListener)
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsGenericHTMLFrameElement)
NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
NS_IMPL_INT_ATTR(nsGenericHTMLFrameElement, TabIndex, tabindex)
NS_IMPL_BOOL_ATTR(nsGenericHTMLFrameElement, Mozbrowser, mozbrowser)
nsGenericHTMLFrameElement::~nsGenericHTMLFrameElement()
{
if (mFrameLoader) {
mFrameLoader->Destroy();
}
}
nsresult
nsGenericHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
{
NS_PRECONDITION(aContentDocument, "Null out param");
*aContentDocument = nsnull;
nsCOMPtr<nsIDOMWindow> win;
GetContentWindow(getter_AddRefs(win));
if (!win) {
return NS_OK;
}
return win->GetDocument(aContentDocument);
}
nsresult
nsGenericHTMLFrameElement::GetContentWindow(nsIDOMWindow** aContentWindow)
{
NS_PRECONDITION(aContentWindow, "Null out param");
*aContentWindow = nsnull;
nsresult rv = EnsureFrameLoader();
NS_ENSURE_SUCCESS(rv, rv);
if (!mFrameLoader) {
return NS_OK;
}
bool depthTooGreat = false;
mFrameLoader->GetDepthTooGreat(&depthTooGreat);
if (depthTooGreat) {
// Claim to have no contentWindow
return NS_OK;
}
nsCOMPtr<nsIDocShell> doc_shell;
mFrameLoader->GetDocShell(getter_AddRefs(doc_shell));
nsCOMPtr<nsPIDOMWindow> win(do_GetInterface(doc_shell));
if (!win) {
return NS_OK;
}
NS_ASSERTION(win->IsOuterWindow(),
"Uh, this window should always be an outer window!");
return CallQueryInterface(win, aContentWindow);
}
nsresult
nsGenericHTMLFrameElement::EnsureFrameLoader()
{
if (!GetParent() || !IsInDoc() || mFrameLoader) {
// If frame loader is there, we just keep it around, cached
return NS_OK;
}
mFrameLoader = nsFrameLoader::Create(this, mNetworkCreated);
if (!mFrameLoader) {
// Strangely enough, this method doesn't actually ensure that the
// frameloader exists. It's more of a best-effort kind of thing.
return NS_OK;
}
// Register ourselves as a web progress listener on the frameloader's
// docshell.
nsCOMPtr<nsIDocShell> docShell;
mFrameLoader->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIWebProgress> webProgress = do_QueryInterface(docShell);
NS_ENSURE_TRUE(webProgress, NS_OK);
// This adds a weak ref, so we don't have to worry about unregistering.
webProgress->AddProgressListener(this,
nsIWebProgress::NOTIFY_LOCATION |
nsIWebProgress::NOTIFY_STATE_WINDOW);
return NS_OK;
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::GetFrameLoader(nsIFrameLoader **aFrameLoader)
{
NS_IF_ADDREF(*aFrameLoader = mFrameLoader);
return NS_OK;
}
NS_IMETHODIMP_(already_AddRefed<nsFrameLoader>)
nsGenericHTMLFrameElement::GetFrameLoader()
{
nsRefPtr<nsFrameLoader> loader = mFrameLoader;
return loader.forget();
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::SwapFrameLoaders(nsIFrameLoaderOwner* aOtherOwner)
{
// We don't support this yet
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsGenericHTMLFrameElement::LoadSrc()
{
nsresult rv = EnsureFrameLoader();
NS_ENSURE_SUCCESS(rv, rv);
if (!mFrameLoader) {
return NS_OK;
}
rv = mFrameLoader->LoadFrame();
#ifdef DEBUG
if (NS_FAILED(rv)) {
NS_WARNING("failed to load URL");
}
#endif
return rv;
}
nsresult
nsGenericHTMLFrameElement::BindToTree(nsIDocument* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument) {
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
"Missing a script blocker!");
// We're in a document now. Kick off the frame load.
LoadSrc();
}
// We're now in document and scripts may move us, so clear
// the mNetworkCreated flag.
mNetworkCreated = false;
return rv;
}
void
nsGenericHTMLFrameElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
if (mFrameLoader) {
// This iframe is being taken out of the document, destroy the
// iframe's frame loader (doing that will tear down the window in
// this iframe).
// XXXbz we really want to only partially destroy the frame
// loader... we don't want to tear down the docshell. Food for
// later bug.
mFrameLoader->Destroy();
mFrameLoader = nsnull;
}
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
}
nsresult
nsGenericHTMLFrameElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify)
{
nsresult rv = nsGenericHTMLElement::SetAttr(aNameSpaceID, aName, aPrefix,
aValue, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::src) {
// Don't propagate error here. The attribute was successfully set, that's
// what we should reflect.
LoadSrc();
}
return NS_OK;
}
void
nsGenericHTMLFrameElement::DestroyContent()
{
if (mFrameLoader) {
mFrameLoader->Destroy();
mFrameLoader = nsnull;
}
nsGenericHTMLElement::DestroyContent();
}
nsresult
nsGenericHTMLFrameElement::CopyInnerTo(nsGenericElement* aDest) const
{
nsresult rv = nsGenericHTMLElement::CopyInnerTo(aDest);
NS_ENSURE_SUCCESS(rv, rv);
nsIDocument* doc = aDest->OwnerDoc();
if (doc->IsStaticDocument() && mFrameLoader) {
nsGenericHTMLFrameElement* dest =
static_cast<nsGenericHTMLFrameElement*>(aDest);
nsFrameLoader* fl = nsFrameLoader::Create(dest, false);
NS_ENSURE_STATE(fl);
dest->mFrameLoader = fl;
static_cast<nsFrameLoader*>(mFrameLoader.get())->CreateStaticClone(fl);
}
return rv;
}
bool
nsGenericHTMLFrameElement::IsHTMLFocusable(bool aWithMouse,
bool *aIsFocusable,
PRInt32 *aTabIndex)
{
if (nsGenericHTMLElement::IsHTMLFocusable(aWithMouse, aIsFocusable, aTabIndex)) {
return true;
}
*aIsFocusable = nsContentUtils::IsSubDocumentTabbable(this);
if (!*aIsFocusable && aTabIndex) {
*aTabIndex = -1;
}
return false;
}
PRInt64
nsGenericHTMLFrameElement::SizeOf() const
{
PRInt64 size = MemoryReporter::GetBasicSize<nsGenericHTMLFrameElement,
nsGenericHTMLElement>(this);
// TODO: need to implement SizeOf() in nsFrameLoader, bug 672539.
size += mFrameLoader ? sizeof(*mFrameLoader.get()) : 0;
return size;
}
/**
* Return true if this frame element has permission to send mozbrowser
* events, and false otherwise.
*/
bool
nsGenericHTMLFrameElement::BrowserFrameSecurityCheck()
{
// Fail if browser frames are globally disabled.
if (!Preferences::GetBool("dom.mozBrowserFramesEnabled")) {
return false;
}
// Fail if this frame doesn't have the mozbrowser attribute.
bool isBrowser = false;
GetMozbrowser(&isBrowser);
if (!isBrowser) {
return false;
}
// Fail if the node principal isn't trusted.
nsIPrincipal *principal = NodePrincipal();
nsCOMPtr<nsIURI> principalURI;
principal->GetURI(getter_AddRefs(principalURI));
if (!nsContentUtils::URIIsChromeOrInPref(principalURI,
"dom.mozBrowserFramesWhitelist")) {
return false;
}
// Otherwise, succeed.
return true;
}
/**
* Fire a mozbrowser event, if we have permission.
*
* @param aEventName the event name (e.g. "locationchange"). "mozbrowser" is
* added to the beginning of aEventName automatically.
* @param aEventType the event type. Must be either "event" or "customevent".
* @param aValue the value passed along with the event. This value will be
* set as the event's "detail" property. This must be empty if
* aEventType is "event".
*/
nsresult
nsGenericHTMLFrameElement::MaybeFireBrowserEvent(
const nsAString &aEventName,
const nsAString &aEventType,
const nsAString &aValue /* = EmptyString() */)
{
MOZ_ASSERT(aEventType.EqualsLiteral("event") ||
aEventType.EqualsLiteral("customevent"));
MOZ_ASSERT_IF(aEventType.EqualsLiteral("event"),
aValue.IsEmpty());
if (!BrowserFrameSecurityCheck()) {
return NS_OK;
}
nsAutoString eventName;
eventName.AppendLiteral("mozbrowser");
eventName.Append(aEventName);
nsCOMPtr<nsIDOMEvent> domEvent;
nsEventDispatcher::CreateEvent(GetPresContext(), nsnull,
aEventType, getter_AddRefs(domEvent));
nsCOMPtr<nsIPrivateDOMEvent> privateEvent = do_QueryInterface(domEvent);
NS_ENSURE_STATE(privateEvent);
nsresult rv = privateEvent->SetTrusted(true);
NS_ENSURE_SUCCESS(rv, rv);
if (aEventType.EqualsLiteral("customevent")) {
nsCOMPtr<nsIDOMCustomEvent> customEvent = do_QueryInterface(domEvent);
NS_ENSURE_STATE(customEvent);
nsCOMPtr<nsIWritableVariant> value = new nsVariant();
value->SetAsAString(aValue);
rv = customEvent->InitCustomEvent(eventName,
/* bubbles = */ false,
/* cancelable = */ false,
value);
NS_ENSURE_SUCCESS(rv, rv);
}
else {
rv = domEvent->InitEvent(eventName,
/* bubbles = */ false,
/* cancelable = */ false);
NS_ENSURE_SUCCESS(rv, rv);
}
return (new nsAsyncDOMEvent(this, domEvent))->PostDOMEvent();
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI* aURI,
PRUint32 aFlags)
{
nsCAutoString spec;
aURI->GetSpec(spec);
MaybeFireBrowserEvent(NS_LITERAL_STRING("locationchange"),
NS_LITERAL_STRING("customevent"),
NS_ConvertUTF8toUTF16(spec));
return NS_OK;
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::OnStateChange(nsIWebProgress* aProgress,
nsIRequest* aRequest,
PRUint32 aProgressStateFlags,
nsresult aStatus)
{
if (!(aProgressStateFlags & STATE_IS_WINDOW)) {
return NS_OK;
}
nsAutoString status;
if (aProgressStateFlags & STATE_START) {
MaybeFireBrowserEvent(NS_LITERAL_STRING("loadstart"),
NS_LITERAL_STRING("event"));
}
else if (aProgressStateFlags & STATE_STOP) {
MaybeFireBrowserEvent(NS_LITERAL_STRING("loadend"),
NS_LITERAL_STRING("event"));
}
return NS_OK;
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::OnProgressChange(nsIWebProgress* aProgress,
nsIRequest* aRequest,
PRInt32 aCurSelfProgress,
PRInt32 aMaxSelfProgress,
PRInt32 aCurTotalProgress,
PRInt32 aMaxTotalProgress)
{
return NS_OK;
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::OnStatusChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsresult aStatus,
const PRUnichar* aMessage)
{
return NS_OK;
}
NS_IMETHODIMP
nsGenericHTMLFrameElement::OnSecurityChange(nsIWebProgress *aWebProgress,
nsIRequest *aRequest,
PRUint32 state)
{
return NS_OK;
}

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

@ -0,0 +1,80 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsGenericHTMLElement.h"
#include "nsIDOMHTMLFrameElement.h"
#include "nsIDOMMozBrowserFrame.h"
#include "nsIWebProgressListener.h"
/**
* A helper class for frame elements
*/
class nsGenericHTMLFrameElement : public nsGenericHTMLElement,
public nsIFrameLoaderOwner,
public nsIDOMMozBrowserFrame,
public nsIWebProgressListener
{
public:
nsGenericHTMLFrameElement(already_AddRefed<nsINodeInfo> aNodeInfo,
mozilla::dom::FromParser aFromParser)
: nsGenericHTMLElement(aNodeInfo)
{
mNetworkCreated = aFromParser == mozilla::dom::FROM_PARSER_NETWORK;
}
virtual ~nsGenericHTMLFrameElement();
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
NS_DECL_NSIFRAMELOADEROWNER
NS_DECL_NSIDOMMOZBROWSERFRAME
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_DOM_MEMORY_REPORTER_SIZEOF
// nsIContent
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, PRInt32 *aTabIndex);
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers);
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true);
nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
const nsAString& aValue, bool aNotify)
{
return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
}
virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
nsIAtom* aPrefix, const nsAString& aValue,
bool aNotify);
virtual void DestroyContent();
nsresult CopyInnerTo(nsGenericElement* aDest) const;
// nsIDOMHTMLElement
NS_IMETHOD GetTabIndex(PRInt32 *aTabIndex);
NS_IMETHOD SetTabIndex(PRInt32 aTabIndex);
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsGenericHTMLFrameElement,
nsGenericHTMLElement)
protected:
// This doesn't really ensure a frame loade in all cases, only when
// it makes sense.
nsresult EnsureFrameLoader();
nsresult LoadSrc();
nsresult GetContentDocument(nsIDOMDocument** aContentDocument);
nsresult GetContentWindow(nsIDOMWindow** aContentWindow);
bool BrowserFrameSecurityCheck();
nsresult MaybeFireBrowserEvent(const nsAString &aEventName,
const nsAString &aEventType,
const nsAString &aValue = EmptyString());
nsRefPtr<nsFrameLoader> mFrameLoader;
// True when the element is created by the parser
// using NS_FROM_PARSER_NETWORK flag.
// If the element is modified, it may lose the flag.
bool mNetworkCreated;
};

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

@ -38,7 +38,7 @@
#include "mozilla/Util.h"
#include "nsIDOMHTMLFrameElement.h"
#include "nsGenericHTMLElement.h"
#include "nsGenericHTMLFrameElement.h"
#include "nsGkAtoms.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"

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

@ -38,7 +38,7 @@
#include "mozilla/Util.h"
#include "nsIDOMHTMLIFrameElement.h"
#include "nsGenericHTMLElement.h"
#include "nsGenericHTMLFrameElement.h"
#include "nsIDOMDocument.h"
#include "nsIDOMGetSVGDocument.h"
#include "nsIDOMSVGDocument.h"

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

@ -143,7 +143,7 @@ HTML_TAG("figure", "")
HTML_TAG("font", "Font");
HTML_TAG("footer", "")
HTML_TAG("form", "Form", [], [ "nsIWebProgressListener" ]);
HTML_TAG("frame", "Frame", [ "nsIDOMMozBrowserFrameElement" ], [ "nsIFrameLoaderOwner" ]);
HTML_TAG("frame", "Frame", [ "nsIDOMMozBrowserFrame" ], [ "nsIFrameLoaderOwner" ]);
HTML_TAG("frameset", "FrameSet");
HTML_TAG("h1", "Heading");
HTML_TAG("h2", "Heading");
@ -157,7 +157,7 @@ HTML_TAG("hgroup", "")
HTML_TAG("hr", "HR");
HTML_TAG("html", "Html");
HTML_TAG("i", "");
HTML_TAG("iframe", "IFrame", [ "nsIDOMGetSVGDocument", "nsIDOMMozBrowserFrameElement" ],
HTML_TAG("iframe", "IFrame", [ "nsIDOMGetSVGDocument", "nsIDOMMozBrowserFrame" ],
[ "nsIFrameLoaderOwner" ]);
HTML_TAG("image", "Span");
HTML_TAG("img", "Image", [], [ "imgIDecoderObserver",

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

@ -191,7 +191,7 @@ public:
NS_IMETHOD DidBuildModel(bool aTerminated);
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD SetParser(nsParserBase* aParser);
virtual void FlushPendingNotifications(mozFlushType aType);
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
virtual nsISupports *GetTarget();
@ -295,9 +295,6 @@ protected:
void CloseHeadContext();
// nsContentSink overrides
virtual void PreEvaluateScript();
virtual void PostEvaluateScript(nsIScriptElement *aElement);
void UpdateChildCounts();
void NotifyInsert(nsIContent* aContent,
@ -805,11 +802,13 @@ SinkContext::OpenContainer(const nsIParserNode& aNode)
break;
case eHTMLTag_button:
#ifdef MOZ_MEDIA
case eHTMLTag_audio:
case eHTMLTag_video:
#endif
content->DoneCreatingElement();
break;
default:
break;
}
@ -1702,8 +1701,6 @@ HTMLContentSink::DidBuildModel(bool aTerminated)
ScrollToRef();
mDocument->ScriptLoader()->RemoveObserver(this);
// Make sure we no longer respond to document mutations. We've flushed all
// our notifications out, so there's no need to do anything else here.
@ -1721,7 +1718,7 @@ HTMLContentSink::DidBuildModel(bool aTerminated)
}
NS_IMETHODIMP
HTMLContentSink::SetParser(nsIParser* aParser)
HTMLContentSink::SetParser(nsParserBase* aParser)
{
NS_PRECONDITION(aParser, "Should have a parser here!");
mParser = aParser;
@ -2560,78 +2557,8 @@ HTMLContentSink::CloseHeadContext()
nsresult
HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
{
nsresult result = NS_OK;
if (mCurrentContext) {
// Create content object
nsCOMPtr<nsIContent> element;
nsCOMPtr<nsINodeInfo> nodeInfo;
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::link, nsnull,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
result = NS_NewHTMLElement(getter_AddRefs(element), nodeInfo.forget(),
NOT_FROM_PARSER);
NS_ENSURE_SUCCESS(result, result);
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(element));
if (ssle) {
// XXX need prefs. check here.
if (!mInsideNoXXXTag) {
ssle->InitStyleLinkElement(false);
ssle->SetEnableUpdates(false);
} else {
ssle->InitStyleLinkElement(true);
}
}
// Add in the attributes and add the style content object to the
// head container.
result = AddAttributes(aNode, element);
if (NS_FAILED(result)) {
return result;
}
mCurrentContext->AddLeaf(element); // <link>s are leaves
if (ssle) {
ssle->SetEnableUpdates(true);
bool willNotify;
bool isAlternate;
result = ssle->UpdateStyleSheet(mFragmentMode ? nsnull : this,
&willNotify,
&isAlternate);
if (NS_SUCCEEDED(result) && willNotify && !isAlternate && !mFragmentMode) {
++mPendingSheetCount;
mScriptLoader->AddExecuteBlocker();
}
// look for <link rel="next" href="url">
nsAutoString relVal;
element->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
if (!relVal.IsEmpty()) {
PRUint32 linkTypes = nsStyleLinkElement::ParseLinkTypes(relVal);
bool hasPrefetch = linkTypes & PREFETCH;
if (hasPrefetch || (linkTypes & NEXT)) {
nsAutoString hrefVal;
element->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
if (!hrefVal.IsEmpty()) {
PrefetchHref(hrefVal, element, hasPrefetch);
}
}
if (linkTypes & DNS_PREFETCH) {
nsAutoString hrefVal;
element->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
if (!hrefVal.IsEmpty()) {
PrefetchDNS(hrefVal);
}
}
}
}
}
return result;
MOZ_NOT_REACHED("Old HTMLContentSink used for processing links.");
return NS_ERROR_NOT_IMPLEMENTED;
}
#ifdef DEBUG
@ -2716,79 +2643,12 @@ HTMLContentSink::UpdateChildCounts()
mCurrentContext->UpdateChildCounts();
}
void
HTMLContentSink::PreEvaluateScript()
{
// Eagerly append all pending elements (including the current body child)
// to the body (so that they can be seen by scripts) and force reflow.
SINK_TRACE(gSinkLogModuleInfo, SINK_TRACE_CALLS,
("HTMLContentSink::PreEvaluateScript: flushing tags before "
"evaluating script"));
// XXX Should this call FlushTags()?
mCurrentContext->FlushText();
}
void
HTMLContentSink::PostEvaluateScript(nsIScriptElement *aElement)
{
mHTMLDocument->ScriptExecuted(aElement);
}
nsresult
HTMLContentSink::ProcessSCRIPTEndTag(nsGenericHTMLElement *content,
bool aMalformed)
{
// Flush all tags up front so that we are in as stable state as possible
// when calling DoneAddingChildren. This may not be strictly needed since
// any ScriptAvailable calls will cause us to flush anyway. But it gives a
// warm fuzzy feeling to be in a stable state before even attempting to
// run scripts.
// It would however be needed if we properly called BeginUpdate and
// EndUpdate while we were inserting stuff into the DOM.
// XXX Should this call FlushTags()?
mCurrentContext->FlushText();
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(content);
NS_ASSERTION(sele, "Not really closing a script tag?");
if (aMalformed) {
// Make sure to serialize this script correctly, for nice round tripping.
sele->SetIsMalformed();
}
if (mFrameset) {
sele->PreventExecution();
}
// Notify our document that we're loading this script.
mHTMLDocument->ScriptLoading(sele);
// Now tell the script that it's ready to go. This may execute the script
// or return true, or neither if the script doesn't need executing.
bool block = sele->AttemptToExecute();
// If the act of insertion evaluated the script, we're fine.
// Else, block the parser till the script has loaded.
if (block) {
// If this append fails we'll never unblock the parser, but the UI will
// still remain responsive. There are other ways to deal with this, but
// the end result is always that the page gets botched, so there is no
// real point in making it more complicated.
mScriptElements.AppendObject(sele);
} else {
// This may have already happened if the script executed, but in case
// it didn't then remove the element so that it doesn't get stuck forever.
mHTMLDocument->ScriptExecuted(sele);
}
// If the parser got blocked, make sure to return the appropriate rv.
// I'm not sure if this is actually needed or not.
if (mParser && !mParser->IsParserEnabled()) {
block = true;
}
return block ? NS_ERROR_HTMLPARSER_BLOCK : NS_OK;
MOZ_NOT_REACHED("Must not use HTMLContentSink to run scripts.");
return NS_ERROR_NOT_IMPLEMENTED;
}
// 3 ways to load a style sheet: inline, style src=, link tag
@ -2797,29 +2657,8 @@ HTMLContentSink::ProcessSCRIPTEndTag(nsGenericHTMLElement *content,
nsresult
HTMLContentSink::ProcessSTYLEEndTag(nsGenericHTMLElement* content)
{
nsCOMPtr<nsIStyleSheetLinkingElement> ssle = do_QueryInterface(content);
NS_ASSERTION(ssle,
"html:style doesn't implement nsIStyleSheetLinkingElement");
nsresult rv = NS_OK;
if (ssle) {
// Note: if we are inside a noXXX tag, then we init'ed this style element
// with mDontLoadStyle = true, so these two calls will have no effect.
ssle->SetEnableUpdates(true);
bool willNotify;
bool isAlternate;
rv = ssle->UpdateStyleSheet(mFragmentMode ? nsnull : this,
&willNotify,
&isAlternate);
if (NS_SUCCEEDED(rv) && willNotify && !isAlternate && !mFragmentMode) {
++mPendingSheetCount;
mScriptLoader->AddExecuteBlocker();
}
}
return rv;
MOZ_NOT_REACHED("Old HTMLContentSink used for processing style elements.");
return NS_ERROR_NOT_IMPLEMENTED;
}
void

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

@ -906,78 +906,17 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
void
nsHTMLDocument::StopDocumentLoad()
{
if (nsHtml5Module::sEnabled) {
BlockOnload();
if (mWriteState == eDocumentOpened) {
NS_ASSERTION(IsHTML(), "document.open()ed doc is not HTML?");
BlockOnload();
// Marking the document as closed, since pending scripts will be
// stopped by nsDocument::StopDocumentLoad() below
mWriteState = eDocumentClosed;
// Remove the wyciwyg channel request from the document load group
// that we added in Open() if Open() was called on this doc.
RemoveWyciwygChannel();
NS_ASSERTION(!mWyciwygChannel, "nsHTMLDocument::StopDocumentLoad(): "
"nsIWyciwygChannel could not be removed!");
// Remove the wyciwyg channel request from the document load group
// that we added in Open().
NS_ASSERTION(mWyciwygChannel, "nsHTMLDocument::StopDocumentLoad(): "
"Trying to remove nonexistent wyciwyg channel!");
RemoveWyciwygChannel();
NS_ASSERTION(!mWyciwygChannel, "nsHTMLDocument::StopDocumentLoad(): "
"nsIWyciwygChannel could not be removed!");
}
nsDocument::StopDocumentLoad();
UnblockOnload(false);
return;
}
// Code for the old parser:
// If we're writing (i.e., there's been a document.open call), then
// nsDocument::StopDocumentLoad will do the wrong thing and simply terminate
// our parser.
if (mWriteState != eNotWriting) {
Close();
} else {
nsDocument::StopDocumentLoad();
}
}
// static
void
nsHTMLDocument::DocumentWriteTerminationFunc(nsISupports *aRef)
{
nsCOMPtr<nsIArray> arr = do_QueryInterface(aRef);
NS_ASSERTION(arr, "Must have array!");
nsCOMPtr<nsIDocument> doc = do_QueryElementAt(arr, 0);
NS_ASSERTION(doc, "Must have document!");
nsCOMPtr<nsIParser> parser = do_QueryElementAt(arr, 1);
NS_ASSERTION(parser, "Must have parser!");
nsHTMLDocument *htmldoc = static_cast<nsHTMLDocument*>(doc.get());
// Check whether htmldoc still has the same parser. If not, it's
// not for us to mess with it.
if (htmldoc->mParser != parser) {
return;
}
// If the document is in the middle of a document.write() call, this
// most likely means that script on a page document.write()'d out a
// script tag that did location="..." and we're right now finishing
// up executing the script that was written with
// document.write(). Since there's still script on the stack (the
// script that called document.write()) we don't want to release the
// parser now, that would cause the next document.write() call to
// cancel the load that was initiated by the location="..." in the
// script that was written out by document.write().
if (!htmldoc->mWriteLevel && htmldoc->mWriteState != eDocumentOpened) {
// Release the document's parser so that the call to EndLoad()
// doesn't just return early and set the termination function again.
htmldoc->mParser = nsnull;
}
htmldoc->EndLoad();
nsDocument::StopDocumentLoad();
UnblockOnload(false);
return;
}
void
@ -998,65 +937,6 @@ nsHTMLDocument::BeginLoad()
void
nsHTMLDocument::EndLoad()
{
if (mParser && mWriteState != eDocumentClosed) {
nsCOMPtr<nsIJSContextStack> stack =
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
if (stack) {
JSContext *cx = nsnull;
stack->Peek(&cx);
if (cx) {
nsIScriptContext *scx = nsJSUtils::GetDynamicScriptContext(cx);
if (scx) {
// The load of the document was terminated while we're
// called from within JS and we have a parser (i.e. we're in
// the middle of doing document.write()). In stead of
// releasing the parser and ending the document load
// directly, we'll make that happen once the script is done
// executing. This way subsequent document.write() calls
// won't end up creating a new parser and interrupting other
// loads that were started while the script was
// running. I.e. this makes the following case work as
// expected:
//
// document.write("foo");
// location.href = "http://www.mozilla.org";
// document.write("bar");
nsresult rv;
nsCOMPtr<nsIMutableArray> arr =
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = arr->AppendElement(static_cast<nsIDocument*>(this),
false);
if (NS_SUCCEEDED(rv)) {
rv = arr->AppendElement(mParser, false);
if (NS_SUCCEEDED(rv)) {
rv = scx->SetTerminationFunction(DocumentWriteTerminationFunc,
arr);
// If we fail to set the termination function, just go ahead
// and EndLoad now. The slight bugginess involved is better
// than leaking.
if (NS_SUCCEEDED(rv)) {
return;
}
}
}
}
}
}
}
}
// Reset this now, since we're really done "loading" this document.written
// document.
NS_ASSERTION(mWriteState == eNotWriting || mWriteState == ePendingClose ||
mWriteState == eDocumentClosed, "EndLoad called early");
mWriteState = eNotWriting;
bool turnOnEditing =
mParser && (HasFlag(NODE_IS_EDITABLE) || mContentEditableCount > 0);
// Note: nsDocument::EndLoad nulls out mParser.
@ -1673,8 +1553,6 @@ nsHTMLDocument::Open(const nsAString& aContentTypeOrUrl,
// This will be propagated to the parser when someone actually calls write()
SetContentTypeInternal(contentType);
mWriteState = eDocumentOpened;
if (NS_SUCCEEDED(rv)) {
if (loadAsHtml5) {
nsHtml5Module::Initialize(mParser, this, uri, shell, channel);
@ -1686,7 +1564,6 @@ nsHTMLDocument::Open(const nsAString& aContentTypeOrUrl,
if (NS_FAILED(rv)) {
// Don't use a parser without a content sink.
mParser = nsnull;
mWriteState = eNotWriting;
return rv;
}
@ -1746,55 +1623,51 @@ nsHTMLDocument::Close()
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
nsresult rv = NS_OK;
if (mParser && mWriteState == eDocumentOpened) {
mPendingScripts.RemoveElement(GenerateParserKey());
mWriteState = mPendingScripts.IsEmpty() ? eDocumentClosed : ePendingClose;
++mWriteLevel;
rv = mParser->Parse(EmptyString(), mParser->GetRootContextKey(),
GetContentTypeInternal(), true);
--mWriteLevel;
// XXX Make sure that all the document.written content is
// reflowed. We should remove this call once we change
// nsHTMLDocument::OpenCommon() so that it completely destroys the
// earlier document's content and frame hierarchy. Right now, it
// re-uses the earlier document's root content object and
// corresponding frame objects. These re-used frame objects think
// that they have already been reflowed, so they drop initial
// reflows. For certain cases of document.written content, like a
// frameset document, the dropping of the initial reflow means
// that we end up in document.close() without appended any reflow
// commands to the reflow queue and, consequently, without adding
// the dummy layout request to the load group. Since the dummy
// layout request is not added to the load group, the onload
// handler of the frameset fires before the frames get reflowed
// and loaded. That is the long explanation for why we need this
// one line of code here!
// XXXbz as far as I can tell this may not be needed anymore; all
// the testcases in bug 57636 pass without this line... Leaving
// it be for now, though. In any case, there's no reason to do
// this if we have no presshell, since in that case none of the
// above about reusing frames applies.
if (GetShell()) {
FlushPendingNotifications(Flush_Layout);
}
// Remove the wyciwyg channel request from the document load group
// that we added in OpenCommon(). If all other requests between
// document.open() and document.close() have completed, then this
// method should cause the firing of an onload event.
NS_ASSERTION(mWyciwygChannel, "nsHTMLDocument::Close(): Trying to remove "
"nonexistent wyciwyg channel!");
RemoveWyciwygChannel();
NS_ASSERTION(!mWyciwygChannel, "nsHTMLDocument::Close(): "
"nsIWyciwygChannel could not be removed!");
if (!mParser || !mParser->IsScriptCreated()) {
return NS_OK;
}
return NS_OK;
++mWriteLevel;
nsresult rv = mParser->Parse(EmptyString(), nsnull,
GetContentTypeInternal(), true);
--mWriteLevel;
// XXX Make sure that all the document.written content is
// reflowed. We should remove this call once we change
// nsHTMLDocument::OpenCommon() so that it completely destroys the
// earlier document's content and frame hierarchy. Right now, it
// re-uses the earlier document's root content object and
// corresponding frame objects. These re-used frame objects think
// that they have already been reflowed, so they drop initial
// reflows. For certain cases of document.written content, like a
// frameset document, the dropping of the initial reflow means
// that we end up in document.close() without appended any reflow
// commands to the reflow queue and, consequently, without adding
// the dummy layout request to the load group. Since the dummy
// layout request is not added to the load group, the onload
// handler of the frameset fires before the frames get reflowed
// and loaded. That is the long explanation for why we need this
// one line of code here!
// XXXbz as far as I can tell this may not be needed anymore; all
// the testcases in bug 57636 pass without this line... Leaving
// it be for now, though. In any case, there's no reason to do
// this if we have no presshell, since in that case none of the
// above about reusing frames applies.
//
// XXXhsivonen keeping this around for bug 577508 / 253951 still :-(
if (GetShell()) {
FlushPendingNotifications(Flush_Layout);
}
// Removing the wyciwygChannel here is wrong when document.close() is
// called from within the document itself. However, legacy requires the
// channel to be removed here. Otherwise, the load event never fires.
NS_ASSERTION(mWyciwygChannel, "nsHTMLDocument::Close(): Trying to remove "
"nonexistent wyciwyg channel!");
RemoveWyciwygChannel();
NS_ASSERTION(!mWyciwygChannel, "nsHTMLDocument::Close(): "
"nsIWyciwygChannel could not be removed!");
return rv;
}
nsresult
@ -1815,10 +1688,7 @@ nsHTMLDocument::WriteCommon(JSContext *cx,
nsresult rv = NS_OK;
void *key = GenerateParserKey();
if (mWriteState == eDocumentClosed ||
(mWriteState == ePendingClose &&
!mPendingScripts.Contains(key)) ||
(mParser && !mParser->IsInsertionPointDefined())) {
if (mParser && !mParser->IsInsertionPointDefined()) {
if (mExternalScriptsBeingEvaluated) {
// Instead of implying a call to document.open(), ignore the call.
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
@ -1829,7 +1699,6 @@ nsHTMLDocument::WriteCommon(JSContext *cx,
mDocumentURI);
return NS_OK;
}
mWriteState = eDocumentClosed;
mParser->Terminate();
NS_ASSERTION(!mParser, "mParser should have been null'd out");
}
@ -1861,8 +1730,8 @@ nsHTMLDocument::WriteCommon(JSContext *cx,
static NS_NAMED_LITERAL_STRING(new_line, "\n");
// Save the data in cache
if (mWyciwygChannel) {
// Save the data in cache if the write isn't from within the doc
if (mWyciwygChannel && !key) {
if (!aText.IsEmpty()) {
mWyciwygChannel->WriteToCacheEntry(aText);
}
@ -1881,11 +1750,11 @@ nsHTMLDocument::WriteCommon(JSContext *cx,
if (aNewlineTerminate) {
rv = mParser->Parse(aText + new_line,
key, GetContentTypeInternal(),
(mWriteState == eNotWriting || (mWriteLevel > 1)));
false);
} else {
rv = mParser->Parse(aText,
key, GetContentTypeInternal(),
(mWriteState == eNotWriting || (mWriteLevel > 1)));
false);
}
--mWriteLevel;
@ -1939,30 +1808,6 @@ nsHTMLDocument::GetElementsByName(const nsAString& aElementName,
return NS_OK;
}
void
nsHTMLDocument::ScriptLoading(nsIScriptElement *aScript)
{
if (mWriteState == eNotWriting) {
return;
}
mPendingScripts.AppendElement(aScript);
}
void
nsHTMLDocument::ScriptExecuted(nsIScriptElement *aScript)
{
if (mWriteState == eNotWriting) {
return;
}
mPendingScripts.RemoveElement(aScript);
if (mPendingScripts.IsEmpty() && mWriteState == ePendingClose) {
// The last pending script just finished, terminate our parser now.
mWriteState = eDocumentClosed;
}
}
void
nsHTMLDocument::AddedForm()
{
@ -2411,7 +2256,7 @@ nsHTMLDocument::GenerateParserKey(void)
// Make scripts that aren't inserted by the active parser of this document
// participate in the context of the script that document.open()ed
// this document.
return mParser->GetRootContextKey();
return nsnull;
}
}
return script;

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

@ -149,9 +149,6 @@ public:
nsISupports **aResult,
nsWrapperCache **aCache);
virtual void ScriptLoading(nsIScriptElement *aScript);
virtual void ScriptExecuted(nsIScriptElement *aScript);
virtual void AddedForm();
virtual void RemovedForm();
virtual PRInt32 GetNumFormsSynchronous();
@ -275,29 +272,12 @@ protected:
// Override so we can munge the charset on our wyciwyg channel as needed.
virtual void SetDocumentCharacterSet(const nsACString& aCharSetID);
// mWriteState tracks the status of this document if the document is being
// entirely created by script. In the normal load case, mWriteState will be
// eNotWriting. Once document.open has been called (either implicitly or
// explicitly), mWriteState will be eDocumentOpened. When document.close has
// been called, mWriteState will become eDocumentClosed if there have been no
// external script loads in the meantime. If there have been, then mWriteState
// becomes ePendingClose, indicating that we might still be writing, but that
// we shouldn't process any further close() calls.
enum {
eNotWriting,
eDocumentOpened,
ePendingClose,
eDocumentClosed
} mWriteState;
// Tracks if we are currently processing any document.write calls (either
// implicit or explicit). Note that if a write call writes out something which
// would block the parser, then mWriteLevel will be incorrect until the parser
// finishes processing that script.
PRUint32 mWriteLevel;
nsAutoTArray<nsIScriptElement*, 1> mPendingScripts;
// Load flags of the document's channel
PRUint32 mLoadFlags;

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

@ -49,9 +49,8 @@ class nsContentList;
class nsWrapperCache;
#define NS_IHTMLDOCUMENT_IID \
{ 0x51a360fa, 0xd659, 0x4d85, \
{ 0xa5, 0xc5, 0x4a, 0xbb, 0x0d, 0x97, 0x0f, 0x7a } }
{ 0xa921276f, 0x5e70, 0x42e0, \
{ 0xb8, 0x36, 0x7e, 0x6a, 0xb8, 0x30, 0xb3, 0xc0 } }
/**
* HTML document extensions to nsIDocument.
@ -71,18 +70,6 @@ public:
nsISupports **aResult,
nsWrapperCache **aCache) = 0;
/**
* Called from the script loader to notify this document that a new
* script is being loaded.
*/
virtual void ScriptLoading(nsIScriptElement *aScript) = 0;
/**
* Called from the script loader to notify this document that a script
* just finished executing.
*/
virtual void ScriptExecuted(nsIScriptElement *aScript) = 0;
/**
* Called when form->BindToTree() is called so that document knows
* immediately when a form is added

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

@ -207,7 +207,7 @@ nsXMLContentSink::WillBuildModel(nsDTDMode aDTDMode)
// Check for correct load-command for maybe prettyprinting
if (mPrettyPrintXML) {
nsCAutoString command;
mParser->GetCommand(command);
GetParser()->GetCommand(command);
if (!command.EqualsLiteral("view")) {
mPrettyPrintXML = false;
}
@ -327,7 +327,6 @@ nsXMLContentSink::DidBuildModel(bool aTerminated)
}
else {
// Kick off layout for non-XSLT transformed documents.
mDocument->ScriptLoader()->RemoveObserver(this);
// Check if we want to prettyprint
MaybePrettyPrint();
@ -419,8 +418,6 @@ nsXMLContentSink::OnTransformDone(nsresult aResult,
}
}
originalDocument->ScriptLoader()->RemoveObserver(this);
// Notify document observers that all the content has been stuck
// into the document.
// XXX do we need to notify for things like PIs? Or just the
@ -476,7 +473,7 @@ nsXMLContentSink::WillResume(void)
}
NS_IMETHODIMP
nsXMLContentSink::SetParser(nsIParser* aParser)
nsXMLContentSink::SetParser(nsParserBase* aParser)
{
NS_PRECONDITION(aParser, "Should have a parser here!");
mParser = aParser;
@ -505,7 +502,7 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, PRUint32 aAttsCount,
) {
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(content);
sele->SetScriptLineNumber(aLineNumber);
sele->SetCreatorParser(mParser);
sele->SetCreatorParser(GetParser());
mConstrainSize = false;
}
@ -596,21 +593,18 @@ nsXMLContentSink::CloseElement(nsIContent* aContent)
return NS_OK;
}
// Always check the clock in nsContentSink right after a script
StopDeflecting();
// Now tell the script that it's ready to go. This may execute the script
// or return true, or neither if the script doesn't need executing.
bool block = sele->AttemptToExecute();
// If the act of insertion evaluated the script, we're fine.
// Else, block the parser till the script has loaded.
if (block) {
mScriptElements.AppendObject(sele);
}
// If the parser got blocked, make sure to return the appropriate rv.
// I'm not sure if this is actually needed or not.
if (mParser && !mParser->IsParserEnabled()) {
// XXX The HTML sink doesn't call BlockParser here, why do we?
mParser->BlockParser();
GetParser()->BlockParser();
block = true;
}
@ -632,10 +626,10 @@ nsXMLContentSink::CloseElement(nsIContent* aContent)
ssle->SetEnableUpdates(true);
bool willNotify;
bool isAlternate;
rv = ssle->UpdateStyleSheet(mFragmentMode ? nsnull : this,
rv = ssle->UpdateStyleSheet(mRunsToCompletion ? nsnull : this,
&willNotify,
&isAlternate);
if (NS_SUCCEEDED(rv) && willNotify && !isAlternate && !mFragmentMode) {
if (NS_SUCCEEDED(rv) && willNotify && !isAlternate && !mRunsToCompletion) {
++mPendingSheetCount;
mScriptLoader->AddExecuteBlocker();
}
@ -733,7 +727,7 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
nsCAutoString cmd;
if (mParser)
mParser->GetCommand(cmd);
GetParser()->GetCommand(cmd);
if (cmd.EqualsASCII(kLoadAsData))
return NS_OK; // Do not load stylesheets when loading as data
@ -1077,9 +1071,13 @@ nsXMLContentSink::HandleStartElement(const PRUnichar *aName,
if (nodeInfo->NamespaceID() == kNameSpaceID_XHTML) {
if (nodeInfo->NameAtom() == nsGkAtoms::input ||
nodeInfo->NameAtom() == nsGkAtoms::button ||
nodeInfo->NameAtom() == nsGkAtoms::menuitem ||
nodeInfo->NameAtom() == nsGkAtoms::audio ||
nodeInfo->NameAtom() == nsGkAtoms::video) {
nodeInfo->NameAtom() == nsGkAtoms::menuitem
#ifdef MOZ_MEDIA
||
nodeInfo->NameAtom() == nsGkAtoms::audio ||
nodeInfo->NameAtom() == nsGkAtoms::video
#endif
) {
content->DoneCreatingElement();
} else if (nodeInfo->NameAtom() == nsGkAtoms::head && !mCurrentHead) {
mCurrentHead = content;
@ -1324,14 +1322,14 @@ nsXMLContentSink::HandleProcessingInstruction(const PRUnichar *aTarget,
ssle->SetEnableUpdates(true);
bool willNotify;
bool isAlternate;
rv = ssle->UpdateStyleSheet(mFragmentMode ? nsnull : this,
rv = ssle->UpdateStyleSheet(mRunsToCompletion ? nsnull : this,
&willNotify,
&isAlternate);
NS_ENSURE_SUCCESS(rv, rv);
if (willNotify) {
// Successfully started a stylesheet load
if (!isAlternate && !mFragmentMode) {
if (!isAlternate && !mRunsToCompletion) {
++mPendingSheetCount;
mScriptLoader->AddExecuteBlocker();
}
@ -1681,3 +1679,26 @@ nsXMLContentSink::IsMonolithicContainer(nsINodeInfo* aNodeInfo)
(aNodeInfo->NameAtom() == nsGkAtoms::math))
);
}
void
nsXMLContentSink::ContinueInterruptedParsingIfEnabled()
{
if (mParser && mParser->IsParserEnabled()) {
GetParser()->ContinueInterruptedParsing();
}
}
void
nsXMLContentSink::ContinueInterruptedParsingAsync()
{
nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this,
&nsXMLContentSink::ContinueInterruptedParsingIfEnabled);
NS_DispatchToCurrentThread(ev);
}
nsIParser*
nsXMLContentSink::GetParser()
{
return static_cast<nsIParser*>(mParser.get());
}

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

@ -97,11 +97,12 @@ public:
NS_IMETHOD DidBuildModel(bool aTerminated);
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD SetParser(nsParserBase* aParser);
virtual void FlushPendingNotifications(mozFlushType aType);
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
virtual nsISupports *GetTarget();
virtual bool IsScriptExecuting();
virtual void ContinueInterruptedParsingAsync();
// nsITransformObserver
NS_IMETHOD OnDocumentCreated(nsIDocument *aResultDocument);
@ -115,6 +116,11 @@ public:
bool &aIsAlternate);
protected:
nsIParser* GetParser();
void ContinueInterruptedParsingIfEnabled();
// Start layout. If aIgnorePendingSheets is true, this will happen even if
// we still have stylesheet loads pending. Otherwise, we'll wait until the
// stylesheets are all done loading.

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

@ -166,7 +166,7 @@ NS_NewXMLFragmentContentSink(nsIFragmentContentSink** aResult)
nsXMLFragmentContentSink::nsXMLFragmentContentSink()
: mParseError(false)
{
mFragmentMode = true;
mRunsToCompletion = true;
}
nsXMLFragmentContentSink::~nsXMLFragmentContentSink()
@ -211,7 +211,7 @@ nsXMLFragmentContentSink::WillBuildModel(nsDTDMode aDTDMode)
NS_IMETHODIMP
nsXMLFragmentContentSink::DidBuildModel(bool aTerminated)
{
nsCOMPtr<nsIParser> kungFuDeathGrip(mParser);
nsRefPtr<nsParserBase> kungFuDeathGrip(mParser);
// Drop our reference to the parser to get rid of a circular
// reference.

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

@ -115,7 +115,7 @@ public:
NS_IMETHOD DidBuildModel(bool aTerminated);
NS_IMETHOD WillInterrupt(void) { return NS_OK; }
NS_IMETHOD WillResume(void) { return NS_OK; }
NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
NS_IMETHOD SetParser(nsParserBase* aParser) { return NS_OK; }
virtual void FlushPendingNotifications(mozFlushType aType) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; }
virtual nsISupports *GetTarget() { return nsnull; }

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

@ -338,9 +338,13 @@ txMozillaXMLOutput::endElement()
} else if (ns == kNameSpaceID_XHTML &&
(localName == nsGkAtoms::input ||
localName == nsGkAtoms::button ||
localName == nsGkAtoms::menuitem ||
localName == nsGkAtoms::menuitem
#ifdef MOZ_MEDIA
||
localName == nsGkAtoms::audio ||
localName == nsGkAtoms::video )) {
localName == nsGkAtoms::video
#endif
)) {
element->DoneCreatingElement();
}
}

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

@ -300,7 +300,7 @@ XULContentSinkImpl::WillResume(void)
}
NS_IMETHODIMP
XULContentSinkImpl::SetParser(nsIParser* aParser)
XULContentSinkImpl::SetParser(nsParserBase* aParser)
{
NS_IF_RELEASE(mParser);
mParser = aParser;

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

@ -74,7 +74,7 @@ public:
NS_IMETHOD DidBuildModel(bool aTerminated);
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD SetParser(nsParserBase* aParser);
virtual void FlushPendingNotifications(mozFlushType aType) { }
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
virtual nsISupports *GetTarget();
@ -180,7 +180,7 @@ protected:
nsRefPtr<nsXULPrototypeDocument> mPrototype; // [OWNER]
// We use regular pointer b/c of funky exports on nsIParser:
nsIParser* mParser; // [OWNER]
nsParserBase* mParser; // [OWNER]
nsCOMPtr<nsIScriptSecurityManager> mSecMan;
};

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

@ -145,7 +145,6 @@
#include "nsIDOMDOMStringList.h"
#include "nsIDOMDOMTokenList.h"
#include "nsIDOMDOMSettableTokenList.h"
#include "nsIDOMMozBrowserFrameElement.h"
#include "nsDOMStringMap.h"
@ -353,6 +352,7 @@
#include "nsIDOMNSXPathExpression.h"
#include "nsIDOMXPathNSResolver.h"
#include "nsIDOMXPathResult.h"
#include "nsIDOMMozBrowserFrame.h"
#include "nsIDOMGetSVGDocument.h"
#include "nsIDOMSVGAElement.h"
@ -2692,7 +2692,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(HTMLFrameElement, nsIDOMHTMLFrameElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLFrameElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBrowserFrameElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBrowserFrame)
DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
@ -2724,7 +2724,7 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(HTMLIFrameElement, nsIDOMHTMLIFrameElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLIFrameElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMGetSVGDocument)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBrowserFrameElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozBrowserFrame)
DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
DOM_CLASSINFO_MAP_END

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

@ -108,6 +108,7 @@
#include "mozilla/FunctionTimer.h"
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
#include "sampler.h"
@ -146,6 +147,8 @@ static nsITimer *sGCTimer;
static nsITimer *sShrinkGCBuffersTimer;
static nsITimer *sCCTimer;
static PRTime sLastCCEndTime;
static bool sGCHasRun;
// The number of currently pending document loads. This count isn't
@ -3276,8 +3279,15 @@ nsJSContext::CycleCollectNow(nsICycleCollectorListener *aListener)
PokeGC();
}
PRTime now = PR_Now();
if (sLastCCEndTime) {
PRUint32 timeBetween = (PRUint32)(start - sLastCCEndTime) / PR_USEC_PER_SEC;
Telemetry::Accumulate(Telemetry::CYCLE_COLLECTOR_TIME_BETWEEN, timeBetween);
}
sLastCCEndTime = now;
if (sPostGCEventsToConsole) {
PRTime now = PR_Now();
PRTime delta = 0;
if (sFirstCollectionTime) {
delta = now - sFirstCollectionTime;
@ -3615,6 +3625,7 @@ nsJSRuntime::Startup()
// initialize all our statics, so that we can restart XPCOM
sGCTimer = sCCTimer = nsnull;
sGCHasRun = false;
sLastCCEndTime = 0;
sPendingLoadCount = 0;
sLoadingInProgress = false;
sCCollectedWaitingForGC = 0;

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

@ -116,7 +116,7 @@ SDK_XPIDLSRCS = \
nsIDOMHTMLAudioElement.idl \
nsIDOMValidityState.idl \
nsIDOMDOMStringMap.idl \
nsIDOMMozBrowserFrameElement.idl \
nsIDOMMozBrowserFrame.idl \
$(NULL)
XPIDLSRCS = \

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

@ -0,0 +1,38 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
[scriptable, uuid(4CAFE116-581B-4194-B0DE-7F02378FC51D)]
interface nsIDOMMozBrowserFrame : nsISupports
{
/**
* <iframe> and <frame> elements may have the mozbrowser attribute.
*
* The mozbrowser attribute has no effect unless the <iframe> or <frame>
* element is contained in a document privileged to create browser frames.
*
* An <iframe> or <frame> element in a privileged document with the
* mozbrowser attribute emits mozBrowserPropertyChange events when various
* things happen inside the frame.
*
* The mozBrowserPropertyChangeEvent object has two properties:
*
* property: The property which changed
* value: The property's new value
*
* Currently, the |property| field may take on the following values:
*
* 'location': The content window's location changed. |value| gives the new
* URI.
*
* 'loading': The content window started loading a new page (|value| ==
* 'start') or finished loading (|value| == 'stop').
*
*/
attribute boolean mozbrowser;
};

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

@ -920,6 +920,8 @@ DOMStorageImpl::SetDBValue(const nsAString& aKey,
offlineAppPermission = GetQuota(mDomain, &quota, &warnQuota,
CanUseChromePersist());
CacheKeysFromDB();
PRInt32 usage;
rv = gStorageDB->SetKey(this, aKey, aValue, aSecure, quota,
!IS_PERMISSION_ALLOWED(offlineAppPermission),

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

@ -520,8 +520,6 @@ nsDOMStoragePersistentDB::SetKey(DOMStorageImpl* aStorage,
NS_ENSURE_SUCCESS(rv, rv);
}
aStorage->CacheKeysFromDB();
usage += aKey.Length() + aValue.Length();
nsAutoString previousValue;

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

@ -74,7 +74,11 @@ _TEST_FILES = \
test_focusrings.xul \
file_moving_xhr.html \
test_vibrator.html \
test_getContentState.html \
browserFrameHelpers.js \
test_browserFrame1.html \
test_browserFrame2.html \
test_browserFrame3.html \
test_browserFrame4.html \
$(NULL)
_CHROME_FILES = \

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

@ -0,0 +1,62 @@
"use strict";
// Helpers for managing the browser frame preferences.
const browserFrameHelpers = {
'getEnabledPref': function() {
try {
return SpecialPowers.getBoolPref('dom.mozBrowserFramesEnabled');
}
catch(e) {
return undefined;
}
},
'getWhitelistPref': function() {
try {
return SpecialPowers.getCharPref('dom.mozBrowserFramesWhitelist');
}
catch(e) {
return undefined;
}
},
'setEnabledPref': function(enabled) {
if (enabled !== undefined) {
SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', enabled);
}
else {
SpecialPowers.clearUserPref('dom.mozBrowserFramesEnabled');
}
},
'setWhitelistPref': function(whitelist) {
if (whitelist !== undefined) {
SpecialPowers.setCharPref('dom.mozBrowserFramesWhitelist', whitelist);
}
else {
SpecialPowers.clearUserPref('dom.mozBrowserFramesWhitelist');
}
},
'addToWhitelist': function() {
var whitelist = browserFrameHelpers.getWhitelistPref();
whitelist += ', http://' + window.location.host + ', ';
browserFrameHelpers.setWhitelistPref(whitelist);
},
'restoreOriginalPrefs': function() {
browserFrameHelpers.setEnabledPref(browserFrameHelpers.origEnabledPref);
browserFrameHelpers.setWhitelistPref(browserFrameHelpers.origWhitelistPref);
},
'origEnabledPref': null,
'origWhitelistPref': null
};
browserFrameHelpers.origEnabledPref = browserFrameHelpers.getEnabledPref();
browserFrameHelpers.origWhitelistPref = browserFrameHelpers.getWhitelistPref();
addEventListener('unload', function() {
browserFrameHelpers.restoreOriginalPrefs();
});

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

@ -0,0 +1,45 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=710231
-->
<head>
<title>Test for Bug 710231</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=710231">Mozilla Bug 710231</a>
<!--
Test that an iframe without the |mozbrowser| attribute does not emit
mozbrowserX events.
-->
<iframe id='iframe' onload='iframeLoad()'></iframe>
<script type="application/javascript;version=1.7">
"use strict";
SimpleTest.waitForExplicitFinish();
function runTest() {
var iframe = document.getElementById('iframe');
iframe.addEventListener('mozbrowserloadstart', function() {
ok(false, 'Should not send mozbrowserloadstart event.');
});
iframe.src = 'http://example.com';
}
function iframeLoad() {
ok(true, 'Got iframe load event.');
SimpleTest.finish();
}
addEventListener('load', runTest());
</script>
</body>
</html>

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

@ -0,0 +1,48 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=710231
-->
<head>
<title>Test for Bug 710231</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserFrameHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=710231">Mozilla Bug 710231</a>
<!--
Test that an iframe with the |mozbrowser| attribute does not emit
mozbrowserX events when they're globally pref'ed off.
-->
<iframe id='iframe' mozbrowser onload='iframeLoad()'></iframe>
<script type="application/javascript;version=1.7">
"use strict";
SimpleTest.waitForExplicitFinish();
function runTest() {
browserFrameHelpers.setEnabledPref(false);
var iframe = document.getElementById('iframe');
iframe.addEventListener('mozbrowserloadstart', function() {
ok(false, 'Should not send mozbrowserloadstart event.');
});
iframe.src = 'http://example.com';
}
function iframeLoad() {
ok(true, 'Got iframe load event.');
SimpleTest.finish();
}
addEventListener('load', runTest());
</script>
</body>
</html>

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

@ -0,0 +1,49 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=710231
-->
<head>
<title>Test for Bug 710231</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserFrameHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=710231">Mozilla Bug 710231</a>
<!--
Test that an iframe with the |mozbrowser| attribute does not emit
mozbrowserX events when this page is not in the whitelist.
-->
<iframe id='iframe' mozbrowser onload='iframeLoad()'></iframe>
<script type="application/javascript;version=1.7">
"use strict";
SimpleTest.waitForExplicitFinish();
function runTest() {
browserFrameHelpers.setEnabledPref(true);
browserFrameHelpers.setWhitelistPref(' http://foobar.com');
var iframe = document.getElementById('iframe');
iframe.addEventListener('mozbrowserloadstart', function() {
ok(false, 'Should not send mozbrowserloadstart event.');
});
iframe.src = 'http://example.com';
}
function iframeLoad() {
ok(true, 'Got iframe load event.');
SimpleTest.finish();
}
addEventListener('load', runTest());
</script>
</body>
</html>

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

@ -0,0 +1,87 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=710231
-->
<head>
<title>Test for Bug 710231</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserFrameHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=710231">Mozilla Bug 710231</a>
<!--
Test that an iframe with the |mozbrowser| attribute emits
mozbrowserX events when this page is in the whitelist.
-->
<iframe id='iframe' mozbrowser></iframe>
<script type="application/javascript;version=1.7">
"use strict";
SimpleTest.waitForExplicitFinish();
var seenLoadStart = false;
var seenLoad = false;
var seenLoadEnd = false;
var seenLocationChange = false;
function runTest() {
browserFrameHelpers.setEnabledPref(true);
browserFrameHelpers.addToWhitelist();
var iframe = document.getElementById('iframe');
iframe.addEventListener('mozbrowserloadstart', function() {
ok(!seenLoadStart, 'Just one loadstart event.');
seenLoadStart = true;
ok(!seenLoad, 'Got mozbrowserloadstart event before load.');
ok(!seenLoadEnd, 'Got mozbrowserloadstart before loadend.');
ok(!seenLocationChange, 'Got mozbrowserloadstart before locationchange.');
});
iframe.addEventListener('mozbrowserlocationchange', function(e) {
ok(!seenLocationChange, 'Just one locationchange event.');
seenLocationChange = true;
ok(seenLoadStart, 'Location change after load start.');
ok(!seenLoad, 'Location change before load.');
ok(!seenLoadEnd, 'Location change before load end.');
});
iframe.addEventListener('load', function() {
ok(!seenLoad, 'Just one load event.');
seenLoad = true;
ok(seenLoadStart, 'Load after loadstart.');
ok(seenLocationChange, 'Load after locationchange.');
ok(!seenLoadEnd, 'Load before loadend.');
});
iframe.addEventListener('mozbrowserloadend', function() {
ok(!seenLoadEnd, 'Just one load end event.');
seenLoadEnd = true;
ok(seenLoadStart, 'Load end after load start.');
ok(seenLocationChange, 'Load end after location change.');
});
iframe.src = 'http://example.com';
waitForAllCallbacks();
}
function waitForAllCallbacks() {
if (!seenLoadStart || !seenLoad || !seenLoadEnd || !seenLocationChange) {
SimpleTest.executeSoon(waitForAllCallbacks);
return;
}
SimpleTest.finish();
}
addEventListener('load', function() { SimpleTest.executeSoon(runTest); });
</script>
</body>
</html>

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

@ -1,144 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=708963
-->
<head>
<title>Test for Bug 708963</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=708963">Mozilla Bug 708963</a>
<script type="application/javascript;version=1.7">
"use strict";
function getEnabledPref() {
try {
return SpecialPowers.getBoolPref('dom.mozBrowserFramesEnabled');
}
catch(e) {
return undefined;
}
}
function getWhitelistPref() {
try {
return SpecialPowers.getCharPref('dom.mozBrowserFramesWhitelist');
}
catch(e) {
return undefined;
}
}
function setPrefs(enabled, whitelist) {
if (enabled !== undefined) {
SpecialPowers.setBoolPref('dom.mozBrowserFramesEnabled', enabled);
}
else {
SpecialPowers.clearUserPref('dom.mozBrowserFramesEnabled');
}
if (whitelist !== undefined) {
SpecialPowers.setCharPref('dom.mozBrowserFramesWhitelist', whitelist);
}
else {
SpecialPowers.clearUserPref('dom.mozBrowserFramesWhitelist');
}
}
function getPrePath() {
return 'http://' + window.location.host;
}
function checkCannotQueryIframe(id) {
let iframe = document.getElementById(id);
try {
iframe.mozGetContentState('location', function() {
ok(false, 'Got callback, but should have failed.');
});
ok(false, 'Should have thrown exception.');
}
catch(e) {
ok(true, 'Got expected exception.');
}
}
function checkCannotQuery() {
checkCannotQueryIframe('queryable');
checkCannotQueryIframe('not-queryable');
}
let numCallbacksExpected = 0;
let numCallbacksSeen = 0;
function checkCanQuery() {
checkCannotQueryIframe('not-queryable');
let iframe = document.getElementById('queryable');
iframe.mozGetContentState('location', function(href) {
ok(true, 'Got callback, as expected.');
is(href, 'http://example.com/', "Callback value.");
numCallbacksSeen++;
});
numCallbacksExpected++;
}
const oldEnabled = getEnabledPref();
const oldWhitelist = getWhitelistPref();
function runTest() {
setPrefs(false, getPrePath());
checkCannotQuery();
setPrefs(true, '');
checkCannotQuery();
setPrefs(true, getPrePath());
checkCanQuery();
setPrefs(true, 'http://example.com , ' +
getPrePath().toUpperCase() + ', ');
checkCanQuery();
// Spin if we haven't seen all the expected callbacks.
waitForAllExpectedCallbacks();
}
function waitForAllExpectedCallbacks() {
if (numCallbacksSeen < numCallbacksExpected) {
SimpleTest.executeSoon(waitForAllExpectedCallbacks);
return;
}
// Spin the event loop a few times to let any remaining pending callbacks
// fire. (If we get any callbacks here, the test should fail.)
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
SimpleTest.executeSoon(function() {
setPrefs(oldEnabled, oldWhitelist);
SimpleTest.finish();
});
});
});
}
SimpleTest.waitForExplicitFinish();
var numLoaded = 0;
function iframeLoaded() {
numLoaded++;
if (numLoaded == 2) {
runTest();
}
}
</script>
<iframe onload='iframeLoaded()' id='not-queryable' src='http://example.org'></iframe>
<iframe onload='iframeLoaded()' mozbrowser id='queryable' src='http://example.com'></iframe>
</body>
</html>

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

@ -69,12 +69,12 @@
#include "AndroidBridge.h"
#endif
#include <android/log.h>
#endif
#define EGL_LIB "libEGL.so"
#define GLES2_LIB "libGLESv2.so"
#else
#define EGL_LIB "libEGL.so.1"
#define GLES2_LIB "libGLESv2.so.2"
#endif
#define EGL_LIB1 "libEGL.so.1"
#define GLES2_LIB2 "libGLESv2.so.2"
typedef void *EGLNativeDisplayType;
typedef void *EGLNativePixmapType;
@ -386,6 +386,11 @@ public:
if (!mEGLLibrary) {
mEGLLibrary = PR_LoadLibrary(EGL_LIB);
#if defined(XP_UNIX)
if (!mEGLLibrary) {
mEGLLibrary = PR_LoadLibrary(EGL_LIB1);
}
#endif
}
if (!mEGLLibrary) {
@ -750,7 +755,11 @@ public:
bool Init()
{
if (!OpenLibrary(GLES2_LIB)) {
NS_WARNING("Couldn't load EGL LIB.");
#if defined(XP_UNIX)
if (!OpenLibrary(GLES2_LIB2)) {
NS_WARNING("Couldn't load EGL LIB.");
}
#endif
return false;
}

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

@ -796,8 +796,8 @@ CGRGBPixel* Offscreen::getCG(const SkScalerContext_Mac& context, const SkGlyph&
void SkScalerContext_Mac::getVerticalOffset(CGGlyph glyphID, SkIPoint* offset) const {
CGSize vertOffset;
CTFontGetVerticalTranslationsForGlyphs(fCTVerticalFont, &glyphID, &vertOffset, 1);
const SkPoint trans = {SkFloatToScalar(vertOffset.width),
SkFloatToScalar(vertOffset.height)};
const SkPoint trans = {SkScalar(SkFloatToScalar(vertOffset.width)),
SkScalar(SkFloatToScalar(vertOffset.height))};
SkPoint floatOffset;
fVerticalMatrix.mapPoints(&floatOffset, &trans, 1);
if (!isSnowLeopard()) {

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

@ -1016,6 +1016,18 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
// (only used if not rounding)
double hb2appUnits = FixedToFloat(aShapedWord->AppUnitsPerDevUnit());
// Residual from rounding of previous advance, for use in rounding the
// subsequent offset or advance appropriately. 16.16 fixed-point
//
// When rounding, the goal is to make the distance between glyphs and
// their base glyph equal to the integral number of pixels closest to that
// suggested by that shaper.
// i.e. posInfo[n].x_advance - posInfo[n].x_offset + posInfo[n+1].x_offset
//
// The value of the residual is the part of the desired distance that has
// not been included in integer offsets.
hb_position_t x_residual = 0;
// keep track of y-position to set glyph offsets if needed
nscoord yPos = 0;
@ -1116,17 +1128,27 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
continue;
}
// Check if it's a simple one-to-one mapping
hb_position_t x_offset = posInfo[glyphStart].x_offset;
hb_position_t x_advance = posInfo[glyphStart].x_advance;
nscoord advance =
roundX ? appUnitsPerDevUnit * FixedToIntRound(x_advance)
: floor(hb2appUnits * x_advance + 0.5);
nscoord xOffset, advance;
if (roundX) {
xOffset =
appUnitsPerDevUnit * FixedToIntRound(x_offset + x_residual);
// Desired distance from the base glyph to the next reference point.
hb_position_t width = x_advance - x_offset;
int intWidth = FixedToIntRound(width);
x_residual = width - FloatToFixed(intWidth);
advance = appUnitsPerDevUnit * intWidth + xOffset;
} else {
xOffset = floor(hb2appUnits * x_offset + 0.5);
advance = floor(hb2appUnits * x_advance + 0.5);
}
// Check if it's a simple one-to-one mapping
if (glyphsInClump == 1 &&
gfxTextRun::CompressedGlyph::IsSimpleGlyphID(ginfo[glyphStart].codepoint) &&
gfxTextRun::CompressedGlyph::IsSimpleAdvance(advance) &&
aShapedWord->IsClusterStart(baseCharIndex) &&
posInfo[glyphStart].x_offset == 0 &&
xOffset == 0 &&
posInfo[glyphStart].y_offset == 0 && yPos == 0)
{
gfxTextRun::CompressedGlyph g;
@ -1143,20 +1165,14 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
detailedGlyphs.AppendElement();
details->mGlyphID = ginfo[glyphStart].codepoint;
// Rounding offsets independently of advances on the assumption
// that clusters use offsets and rounding of offsets should
// not accumulate, and that advances are typically between
// clusters.
hb_position_t x_offset = posInfo[glyphStart].x_offset;
details->mXOffset =
roundX ? appUnitsPerDevUnit * FixedToIntRound(x_offset)
: floor(hb2appUnits * x_offset + 0.5);
details->mXOffset = xOffset;
details->mAdvance = advance;
hb_position_t y_offset = posInfo[glyphStart].y_offset;
details->mYOffset = yPos -
(roundY ? appUnitsPerDevUnit * FixedToIntRound(y_offset)
: floor(hb2appUnits * y_offset + 0.5));
details->mAdvance = advance;
hb_position_t y_advance = posInfo[glyphStart].y_advance;
if (y_advance != 0) {
yPos -=
@ -1166,10 +1182,25 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
if (++glyphStart >= glyphEnd) {
break;
}
x_offset = posInfo[glyphStart].x_offset;
x_advance = posInfo[glyphStart].x_advance;
advance =
roundX ? appUnitsPerDevUnit * FixedToIntRound(x_advance)
: floor(hb2appUnits * x_advance + 0.5);
if (roundX) {
xOffset = appUnitsPerDevUnit *
FixedToIntRound(x_offset + x_residual);
// Desired distance to the next reference point. The
// residual is considered here, and includes the residual
// from the base glyph offset and subsequent advances, so
// that the distance from the base glyph is optimized
// rather than the distance from combining marks.
x_advance += x_residual;
int intAdvance = FixedToIntRound(x_advance);
x_residual = x_advance - FloatToFixed(intAdvance);
advance = appUnitsPerDevUnit * intAdvance;
} else {
xOffset = floor(hb2appUnits * x_offset + 0.5);
advance = floor(hb2appUnits * x_advance + 0.5);
}
}
gfxTextRun::CompressedGlyph g;

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

@ -62,11 +62,11 @@
// objects that just require generic constructors
namespace mozilla {
namespace imagelib {
namespace image {
NS_GENERIC_FACTORY_CONSTRUCTOR(RasterImage)
}
}
using namespace mozilla::imagelib;
using namespace mozilla::image;
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(imgLoader, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(imgRequestProxy)
@ -136,7 +136,7 @@ static void
imglib_Shutdown()
{
imgLoader::Shutdown();
mozilla::imagelib::DiscardTracker::Shutdown();
mozilla::image::DiscardTracker::Shutdown();
}
static const mozilla::Module kImageModule = {

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

@ -53,7 +53,7 @@
#include "ImageLogging.h"
namespace mozilla {
namespace imagelib {
namespace image {
#ifdef PR_LOGGING
PRLogModuleInfo *gBMPLog = PR_NewLogModule("BMPDecoder");
@ -775,5 +775,5 @@ void nsBMPDecoder::ProcessInfoHeader()
mBIH.important_colors = LITTLE_TO_NATIVE32(mBIH.important_colors);
}
} // namespace imagelib
} // namespace image
} // namespace mozilla

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

@ -48,7 +48,7 @@
#include "BMPFileHeaders.h"
namespace mozilla {
namespace imagelib {
namespace image {
class RasterImage;
@ -163,7 +163,7 @@ inline void Set4BitPixel(PRUint32*& aDecoded, PRUint8 aData,
}
}
} // namespace imagelib
} // namespace image
} // namespace mozilla

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

@ -85,7 +85,7 @@ mailing address.
#include "qcms.h"
namespace mozilla {
namespace imagelib {
namespace image {
/*
* GETN(n, s) requests at least 'n' bytes available from 'q', at start of state 's'
@ -1104,5 +1104,5 @@ nsGIFDecoder2::SpeedHistogram()
}
} // namespace imagelib
} // namespace image
} // namespace mozilla

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

@ -48,7 +48,7 @@
#include "GIF2.h"
namespace mozilla {
namespace imagelib {
namespace image {
class RasterImage;
//////////////////////////////////////////////////////////////////////
@ -102,7 +102,7 @@ private:
gif_struct mGIFStruct;
};
} // namespace imagelib
} // namespace image
} // namespace mozilla
#endif

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

@ -56,7 +56,7 @@
#include "nsISupportsPrimitives.h"
namespace mozilla {
namespace imagelib {
namespace image {
#define ICONCOUNTOFFSET 4
#define DIRENTRYOFFSET 6
@ -611,5 +611,5 @@ nsICODecoder::ProcessDirEntry(IconDirEntry& aTarget)
aTarget.mImageOffset = LITTLE_TO_NATIVE32(aTarget.mImageOffset);
}
} // namespace imagelib
} // namespace image
} // namespace mozilla

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

@ -50,7 +50,7 @@
#include "ICOFileHeaders.h"
namespace mozilla {
namespace imagelib {
namespace image {
class RasterImage;
@ -123,7 +123,7 @@ private:
bool mIsPNG;
};
} // namespace imagelib
} // namespace image
} // namespace mozilla
#endif

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

@ -48,7 +48,7 @@
#include "ImageErrors.h"
namespace mozilla {
namespace imagelib {
namespace image {
nsIconDecoder::nsIconDecoder(RasterImage &aImage, imgIDecoderObserver* aObserver)
: Decoder(aImage, aObserver),
@ -165,5 +165,5 @@ nsIconDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount)
}
}
} // namespace imagelib
} // namespace image
} // namespace mozilla

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

@ -48,7 +48,7 @@
#include "imgIDecoderObserver.h"
namespace mozilla {
namespace imagelib {
namespace image {
class RasterImage;
//////////////////////////////////////////////////////////////////////////////////////////////
@ -94,7 +94,7 @@ enum {
iconStateFinished = 3
};
} // namespace imagelib
} // namespace image
} // namespace mozilla
#endif // nsIconDecoder_h__

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

@ -74,7 +74,7 @@ ycc_rgb_convert_argb (j_decompress_ptr cinfo,
static void cmyk_convert_rgb(JSAMPROW row, JDIMENSION width);
namespace mozilla {
namespace imagelib {
namespace image {
#if defined(PR_LOGGING)
PRLogModuleInfo *gJPEGlog = PR_NewLogModule("JPEGDecoder");
@ -890,7 +890,7 @@ term_source (j_decompress_ptr jd)
decoder->NotifyDone();
}
} // namespace imagelib
} // namespace image
} // namespace mozilla

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

@ -63,7 +63,7 @@ extern "C" {
#include <setjmp.h>
namespace mozilla {
namespace imagelib {
namespace image {
typedef struct {
struct jpeg_error_mgr pub; /* "public" fields for IJG library*/
@ -128,7 +128,7 @@ public:
PRUint32 mCMSMode;
};
} // namespace imagelib
} // namespace image
} // namespace mozilla
#endif // nsJPEGDecoder_h__

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

@ -61,7 +61,7 @@
#include "gfxPlatform.h"
namespace mozilla {
namespace imagelib {
namespace image {
#ifdef PR_LOGGING
static PRLogModuleInfo *gPNGLog = PR_NewLogModule("PNGDecoder");
@ -887,5 +887,5 @@ nsPNGDecoder::SpeedHistogram()
}
} // namespace imagelib
} // namespace image
} // namespace mozilla

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

@ -53,7 +53,7 @@
#include "qcms.h"
namespace mozilla {
namespace imagelib {
namespace image {
class RasterImage;
class nsPNGDecoder : public Decoder
@ -141,7 +141,7 @@ public:
static const PRUint8 pngSignatureBytes[];
};
} // namespace imagelib
} // namespace image
} // namespace mozilla
#endif // nsPNGDecoder_h__

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

@ -545,7 +545,7 @@ nsBMPEncoder::InitInfoHeader(PRUint32 aBPP, PRUint32 aWidth, PRUint32 aHeight)
void
nsBMPEncoder::EncodeFileHeader()
{
mozilla::imagelib::BMPFILEHEADER littleEndianBFH = mBMPFileHeader;
mozilla::image::BMPFILEHEADER littleEndianBFH = mBMPFileHeader;
littleEndianBFH.filesize = NATIVE32_TO_LITTLE(littleEndianBFH.filesize);
littleEndianBFH.reserved = NATIVE32_TO_LITTLE(littleEndianBFH.reserved);
littleEndianBFH.dataoffset= NATIVE32_TO_LITTLE(littleEndianBFH.dataoffset);
@ -572,7 +572,7 @@ nsBMPEncoder::EncodeFileHeader()
void
nsBMPEncoder::EncodeInfoHeader()
{
mozilla::imagelib::BMPINFOHEADER littleEndianmBIH = mBMPInfoHeader;
mozilla::image::BMPINFOHEADER littleEndianmBIH = mBMPInfoHeader;
littleEndianmBIH.width = NATIVE32_TO_LITTLE(littleEndianmBIH.width);
littleEndianmBIH.height = NATIVE32_TO_LITTLE(littleEndianmBIH.height);
littleEndianmBIH.planes = NATIVE16_TO_LITTLE(littleEndianmBIH.planes);

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

@ -98,8 +98,8 @@ protected:
// These headers will always contain endian independent stuff
// They store the BMP headers which will be encoded
mozilla::imagelib::BMPFILEHEADER mBMPFileHeader;
mozilla::imagelib::BMPINFOHEADER mBMPInfoHeader;
mozilla::image::BMPFILEHEADER mBMPFileHeader;
mozilla::image::BMPINFOHEADER mBMPInfoHeader;
// Keeps track of the start of the image buffer
PRUint8* mImageBufferStart;

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

@ -46,7 +46,7 @@
#include "nsStreamUtils.h"
using namespace mozilla;
using namespace mozilla::imagelib;
using namespace mozilla::image;
NS_IMPL_THREADSAFE_ISUPPORTS3(nsICOEncoder, imgIEncoder, nsIInputStream, nsIAsyncInputStream)

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

@ -108,8 +108,8 @@ protected:
// These headers will always contain endian independent stuff.
// Don't trust the width and height of mICODirEntry directly,
// instead use the accessors GetRealWidth() and GetRealHeight().
mozilla::imagelib::IconFileHeader mICOFileHeader;
mozilla::imagelib::IconDirEntry mICODirEntry;
mozilla::image::IconFileHeader mICOFileHeader;
mozilla::image::IconDirEntry mICODirEntry;
// Keeps track of the start of the image buffer
PRUint8* mImageBufferStart;

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

@ -39,7 +39,7 @@
#define MOZILLA_IMAGELIB_BMPHEADERS_H_
namespace mozilla {
namespace imagelib {
namespace image {
struct BMPFILEHEADER {
char signature[2]; // String "BM"
@ -97,7 +97,7 @@ namespace mozilla {
PRUint8 blueRightShift;
};
} // namespace imagelib
} // namespace image
} // namespace mozilla
#define BITFIELD_LENGTH 12 // Length of the bitfields structure in the bmp file

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

@ -42,7 +42,7 @@
#include "nsIScriptError.h"
namespace mozilla {
namespace imagelib {
namespace image {
Decoder::Decoder(RasterImage &aImage, imgIDecoderObserver* aObserver)
: mImage(aImage)
@ -326,5 +326,5 @@ Decoder::PostDecoderError(nsresult aFailureCode)
NS_WARNING("Image decoding error - This is probably a bug!");
}
} // namespace imagelib
} // namespace image
} // namespace mozilla

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

@ -44,7 +44,7 @@
#include "imgIDecoderObserver.h"
namespace mozilla {
namespace imagelib {
namespace image {
class Decoder
{
@ -221,7 +221,7 @@ private:
bool mIsAnimated;
};
} // namespace imagelib
} // namespace image
} // namespace mozilla
#endif // MOZILLA_IMAGELIB_DECODER_H_

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

@ -42,7 +42,7 @@
#include "mozilla/Preferences.h"
namespace mozilla {
namespace imagelib {
namespace image {
static bool sInitialized = false;
static bool sTimerOn = false;
@ -289,5 +289,5 @@ DiscardTracker::TimerCallback(nsITimer *aTimer, void *aClosure)
TimerOff();
}
} // namespace imagelib
} // namespace image
} // namespace mozilla

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

@ -43,7 +43,7 @@
class nsITimer;
namespace mozilla {
namespace imagelib {
namespace image {
class RasterImage;
// Struct to make a RasterImage insertable into the tracker list. This
@ -84,7 +84,7 @@ class DiscardTracker
static void TimerCallback(nsITimer *aTimer, void *aClosure);
};
} // namespace imagelib
} // namespace image
} // namespace mozilla
#endif /* mozilla_imagelib_DiscardTracker_h_ */

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