merge mozilla-inbound to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book 2015-02-16 15:59:56 +01:00
commit 08fafcb3e2
460 changed files with 20931 additions and 18048 deletions

View File

@ -970,31 +970,31 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
}
if (!newAcc && isHTML) { // HTML accessibles
if (roleMapEntry) {
// Create pure ARIA grid/treegrid related accessibles if they weren't used
// on accessible HTML table elements.
if ((roleMapEntry->accTypes & eTableCell)) {
if (aContext->IsTableRow() &&
(frame->AccessibleType() != eHTMLTableCellType ||
aContext->GetContent() != content->GetParent())) {
newAcc = new ARIAGridCellAccessibleWrap(content, document);
bool isARIATableOrCell = roleMapEntry &&
(roleMapEntry->accTypes & (eTableCell | eTable));
if (!isARIATableOrCell ||
frame->AccessibleType() == eHTMLTableCellType ||
frame->AccessibleType() == eHTMLTableType) {
// Prefer to use markup (mostly tag name, perhaps attributes) to decide if
// and what kind of accessible to create,
newAcc = CreateHTMLAccessibleByMarkup(frame, content, aContext);
if (!newAcc) // try by frame accessible type.
newAcc = CreateAccessibleByFrameType(frame, content, aContext);
}
} else if ((roleMapEntry->IsOfType(eTable)) &&
frame->AccessibleType() != eHTMLTableType) {
// In case of ARIA grids use grid-specific classes if it's not native table
// based.
if (isARIATableOrCell && (!newAcc || newAcc->IsGenericHyperText())) {
if ((roleMapEntry->accTypes & eTableCell)) {
if (aContext->IsTableRow())
newAcc = new ARIAGridCellAccessibleWrap(content, document);
} else if (roleMapEntry->IsOfType(eTable)) {
newAcc = new ARIAGridAccessibleWrap(content, document);
}
}
if (!newAcc) {
// Prefer to use markup (mostly tag name, perhaps attributes) to decide if
// and what kind of accessible to create.
newAcc = CreateHTMLAccessibleByMarkup(frame, content, aContext);
// Try using frame to do it.
if (!newAcc)
newAcc = CreateAccessibleByFrameType(frame, content, aContext);
// If table has strong ARIA role then all table descendants shouldn't
// expose their native roles.
if (!roleMapEntry && newAcc && aContext->HasStrongARIARole()) {
@ -1017,7 +1017,6 @@ nsAccessibilityService::GetOrCreateAccessible(nsINode* aNode,
}
}
}
}
// Accessible XBL types and deck stuff are used in XUL only currently.
if (!newAcc && content->IsXUL()) {

View File

@ -604,5 +604,12 @@ ARIAGridCellAccessible::NativeAttributes()
stringIdx.AppendInt(rowIdx * colCount + colIdx);
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::tableCellIndex, stringIdx);
#ifdef DEBUG
nsAutoString unused;
attributes->SetStringProperty(NS_LITERAL_CSTRING("cppclass"),
NS_LITERAL_STRING("ARIAGridCellAccessible"),
unused);
#endif
return attributes.forget();
}

View File

@ -579,6 +579,7 @@ public:
bool IsDoc() const { return HasGenericType(eDocument); }
DocAccessible* AsDoc();
bool IsGenericHyperText() const { return mType == eHyperTextType; }
bool IsHyperText() const { return HasGenericType(eHyperText); }
HyperTextAccessible* AsHyperText();

View File

@ -50,6 +50,7 @@ HyperTextAccessible::
HyperTextAccessible(nsIContent* aNode, DocAccessible* aDoc) :
AccessibleWrap(aNode, aDoc)
{
mType = eHyperTextType;
mGenericTypes |= eHyperText;
}

View File

@ -48,6 +48,7 @@ HTMLTableCellAccessible::
HTMLTableCellAccessible(nsIContent* aContent, DocAccessible* aDoc) :
HyperTextAccessibleWrap(aContent, aDoc)
{
mType = eHTMLTableCellType;
mGenericTypes |= eTableCell;
}
@ -129,6 +130,13 @@ HTMLTableCellAccessible::NativeAttributes()
if (!axisText.IsEmpty())
nsAccUtils::SetAccAttr(attributes, nsGkAtoms::axis, axisText);
#ifdef DEBUG
nsAutoString unused;
attributes->SetStringProperty(NS_LITERAL_CSTRING("cppclass"),
NS_LITERAL_STRING("HTMLTableCellAccessible"),
unused);
#endif
return attributes.forget();
}

View File

@ -62,13 +62,13 @@
headerInfoMap = [
{
// not focusable cell (nsARIAGridCellAccessible is used)
// not focusable cell (ARIAGridCellAccessible is used)
cell: "table2_dc_1",
rowHeaderCells: [],
columnHeaderCells: [ "table2_ch_1" ]
},
{
// focusable cell (nsARIAGridCellAccessible is used)
// focusable cell (ARIAGridCellAccessible is used)
cell: "table2_dc_2",
rowHeaderCells: [],
columnHeaderCells: [ "table2_ch_2" ]
@ -77,6 +77,27 @@
testHeaderCells(headerInfoMap);
//////////////////////////////////////////////////////////////////////////
// column and row headers from markup for one more crazy grid.
headerInfoMap = [
{
// ARIAGridCellAccessible is used
cell: "t3_dc_1",
rowHeaderCells: [ "t3_rh_1" ],
columnHeaderCells: [ ]
},
{
// ARIAGridCellAccessible is used (inside rowgroup)
cell: "t3_dc_2",
rowHeaderCells: [ "t3_rh_2" ],
columnHeaderCells: [ ]
}
];
testHeaderCells(headerInfoMap);
SimpleTest.finish();
}
@ -135,5 +156,30 @@
</div>
</div>
<div role="grid">
<table role="presentation">
<tbody role="presentation">
<tr role="row">
<th id="t3_rh_1" role="rowheader">Row 1</th>
<td id="t3_dc_1" role="gridcell" tabindex="-1">
Apple Inc.
</td>
</tr>
</tbody>
</table>
<div role="rowgroup" tabindex="0">
<table role="presentation">
<tbody role="presentation">
<tr role="row">
<th id="t3_rh_2" role="rowheader">Row 2</th>
<td id="t3_dc_2" role="gridcell" tabindex="-1">
Apple-Shmapple Inc.
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

View File

@ -1,4 +1,3 @@
browser.jar:
# The file that holds the default permissions (which is loaded by nsPermissionManager) for the browser.
default_permissions (default_permissions)
% resource app %
defaults/permissions (permissions)

View File

@ -410,6 +410,9 @@ pref("browser.search.hiddenOneOffs", "");
pref("browser.sessionhistory.max_entries", 50);
// Built-in default permissions.
pref("permissions.manager.defaultsUrl", "resource://app/defaults/permissions");
// handle links targeting new windows
// 1=current window/tab, 2=new window, 3=new tab in most recent window
pref("browser.link.open_newwindow", 3);

View File

@ -13,9 +13,12 @@
* from the source profile.
*/
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource:///modules/MigrationUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/MigrationUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesBackups",
"resource://gre/modules/PlacesBackups.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SessionMigration",
@ -34,6 +37,34 @@ function FirefoxProfileMigrator() {
FirefoxProfileMigrator.prototype = Object.create(MigratorPrototype);
FirefoxProfileMigrator.prototype._getAllProfiles = function () {
let allProfiles = new Map();
let profiles =
Components.classes["@mozilla.org/toolkit/profile-service;1"]
.getService(Components.interfaces.nsIToolkitProfileService)
.profiles;
while (profiles.hasMoreElements()) {
let profile = profiles.getNext().QueryInterface(Ci.nsIToolkitProfile);
let rootDir = profile.rootDir;
if (rootDir.exists() && rootDir.isReadable() &&
!rootDir.equals(MigrationUtils.profileStartup.directory)) {
allProfiles.set(profile.name, rootDir);
}
}
return allProfiles;
};
function sorter(a, b) {
return a.id.toLocaleLowerCase().localeCompare(b.id.toLocaleLowerCase());
}
Object.defineProperty(FirefoxProfileMigrator.prototype, "sourceProfiles", {
get: function() {
return [{id: x, name: x} for (x of this._getAllProfiles().keys())].sort(sorter);
}
});
FirefoxProfileMigrator.prototype._getFileObject = function(dir, fileName) {
let file = dir.clone();
file.append(fileName);
@ -42,19 +73,13 @@ FirefoxProfileMigrator.prototype._getFileObject = function(dir, fileName) {
// they are not expected to work alone. Return null to avoid trying to
// copy non-existing files.
return file.exists() ? file : null;
}
};
FirefoxProfileMigrator.prototype.getResources = function() {
// Only allow migrating from the default (selected) profile since this will
// be the only one returned by the toolkit profile service after bug 214675.
let sourceProfile =
FirefoxProfileMigrator.prototype.getResources = function(aProfile) {
let sourceProfileDir = aProfile ? this._getAllProfiles().get(aProfile.id) :
Components.classes["@mozilla.org/toolkit/profile-service;1"]
.getService(Components.interfaces.nsIToolkitProfileService)
.selectedProfile;
if (!sourceProfile)
return null;
let sourceProfileDir = sourceProfile.rootDir;
.selectedProfile.rootDir;
if (!sourceProfileDir || !sourceProfileDir.exists() ||
!sourceProfileDir.isReadable())
return null;
@ -67,10 +92,10 @@ FirefoxProfileMigrator.prototype.getResources = function() {
if (sourceProfileDir.equals(currentProfileDir))
return null;
return this._getResourcesInternal(sourceProfileDir, currentProfileDir);
}
return this._getResourcesInternal(sourceProfileDir, currentProfileDir, aProfile);
};
FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileDir, currentProfileDir) {
FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileDir, currentProfileDir, aProfile) {
let getFileResource = function(aMigrationType, aFileNames) {
let files = [];
for (let fileName of aFileNames) {
@ -107,7 +132,7 @@ FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileD
let sessionFile = this._getFileObject(sourceProfileDir, "sessionstore.js");
let session;
if (sessionFile) {
session = {
session = aProfile ? getFileResource(types.SESSION, ["sessionstore.js"]) : {
type: types.SESSION,
migrate: function(aCallback) {
sessionCheckpoints.copyTo(currentProfileDir, "sessionCheckpoints.json");
@ -217,7 +242,7 @@ FirefoxProfileMigrator.prototype._getResourcesInternal = function(sourceProfileD
return [r for each (r in [places, cookies, passwords, formData,
dictionary, bookmarksBackups, session,
times, healthReporter]) if (r)];
}
};
Object.defineProperty(FirefoxProfileMigrator.prototype, "startupOnlyMigrator", {
get: function() true

View File

@ -45,13 +45,10 @@ function getMigrationBundle() {
* but it will soon be exposed properly.
*/
function getMigratorKeyForDefaultBrowser() {
// Don't map Firefox to the Firefox migrator, because we don't
// expect it to ever show up as an option in the wizard.
// We may want to revise this if/when we use separate profiles
// for each Firefox-update channel.
const APP_DESC_TO_KEY = {
"Internet Explorer": "ie",
"Safari": "safari",
"Firefox": "firefox",
"Google Chrome": "chrome", // Windows, Linux
"Chrome": "chrome", // OS X
};
@ -485,11 +482,11 @@ this.MigrationUtils = Object.freeze({
get migrators() {
let migratorKeysOrdered = [
#ifdef XP_WIN
"ie", "chrome", "safari"
"firefox", "ie", "chrome", "safari"
#elifdef XP_MACOSX
"safari", "chrome"
"firefox", "safari", "chrome"
#elifdef XP_UNIX
"chrome"
"firefox", "chrome"
#endif
];

View File

@ -125,7 +125,10 @@ var MigrationWizard = {
// check for more than one source profile
var sourceProfiles = this._migrator.sourceProfiles;
if (sourceProfiles && sourceProfiles.length > 1) {
if (this._skipImportSourcePage) {
this._wiz.currentPage.next = "homePageImport";
}
else if (sourceProfiles && sourceProfiles.length > 1) {
this._wiz.currentPage.next = "selectProfile";
}
else {

View File

@ -32,6 +32,7 @@
<description id="importBookmarks" control="importSourceGroup" hidden="true">&importFromBookmarks.label;</description>
<radiogroup id="importSourceGroup" align="start">
<radio id="firefox" label="&importFromFirefox.label;" accesskey="&importFromFirefox.accesskey;"/>
#ifdef XP_WIN
<radio id="ie" label="&importFromIE.label;" accesskey="&importFromIE.accesskey;"/>
<radio id="chrome" label="&importFromChrome.label;" accesskey="&importFromChrome.accesskey;"/>
@ -42,7 +43,6 @@
#elifdef XP_UNIX
<radio id="chrome" label="&importFromChrome.label;" accesskey="&importFromChrome.accesskey;"/>
#endif
<radio id="firefox" label="&importFromFirefox.label;" accesskey="&importFromFirefox.accesskey;"/>
<radio id="nothing" label="&importFromNothing.label;" accesskey="&importFromNothing.accesskey;" hidden="true"/>
</radiogroup>
<label id="noSources" hidden="true">&noMigrationSources.label;</label>

View File

@ -57,18 +57,21 @@ NSS_VERSION=3
dnl Set the minimum version of toolkit libs used by mozilla
dnl ========================================================
GLIB_VERSION=1.2.0
GLIB_VERSION=2.22
# 2_26 is the earliest version we can set GLIB_VERSION_MIN_REQUIRED.
# The macro won't be used when compiling with earlier versions anyway.
GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26
GIO_VERSION=2.22
PERL_VERSION=5.006
CAIRO_VERSION=1.10
PANGO_VERSION=1.22.0
GTK2_VERSION=2.18.0
GTK3_VERSION=3.0.0
GTK3_VERSION=3.4.0
WINDRES_VERSION=2.14.90
W32API_VERSION=3.14
GNOMEVFS_VERSION=2.0
GNOMEUI_VERSION=2.2.0
GCONF_VERSION=1.2.1
GIO_VERSION=2.20
STARTUP_NOTIFICATION_VERSION=0.8
DBUS_VERSION=0.60
SQLITE_VERSION=3.8.8.2
@ -4407,13 +4410,19 @@ if test "$COMPILE_ENVIRONMENT"; then
dnl of a make reference because of how TK_LIBS is mangled in toolkit/library/moz.build
dnl for GTK+3 builds.
TK_LIBS=$MOZ_GTK3_LIBS
GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32
fi
if test "$MOZ_ENABLE_GTK2"; then
GLIB_VERSION_MAX_ALLOWED=$GLIB_VERSION_MIN_REQUIRED
fi
if test "$MOZ_ENABLE_GTK"; then
if test "$MOZ_X11"; then
GDK_PACKAGES=gdk-x11-2.0
fi
AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED)
AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED)
PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 >= $GLIB_VERSION gobject-2.0 $GDK_PACKAGES)
MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS"
fi
@ -5610,7 +5619,7 @@ MOZ_ARG_ENABLE_BOOL(alsa,
if test -n "$MOZ_ALSA"; then
PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
[echo "$MOZ_ALSA_PKG_ERRORS"
AC_MSG_ERROR([Need alsa for Ogg, Wave or WebM decoding on Linux. Disable with --disable-ogg --disable-wave --disable-webm. (On Ubuntu, you might try installing the package libasound2-dev.)])])
AC_MSG_ERROR([Need alsa for audio output on Linux. (On Ubuntu, you might try installing the package libasound2-dev.)])])
fi
AC_SUBST(MOZ_ALSA)

View File

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=4 sw=4 et tw=80:
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -65,7 +65,8 @@ public:
*/
NS_IMETHOD UnregisterVisitedCallback(nsIURI* aURI, dom::Link* aLink) = 0;
enum VisitFlags {
enum VisitFlags
{
/**
* Indicates whether the URI was loaded in a top-level window.
*/
@ -101,11 +102,9 @@ public:
* @param aFlags
* The VisitFlags describing this visit.
*/
NS_IMETHOD VisitURI(
nsIURI *aURI,
NS_IMETHOD VisitURI(nsIURI* aURI,
nsIURI* aLastVisitedURI,
uint32_t aFlags
) = 0;
uint32_t aFlags) = 0;
/**
* Set the title of the URI.

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -31,8 +31,9 @@ namespace mozilla {
* to separate the safebrowsing cookie.
*/
class LoadContext MOZ_FINAL : public nsILoadContext,
public nsIInterfaceRequestor
class LoadContext MOZ_FINAL
: public nsILoadContext
, public nsIInterfaceRequestor
{
public:
NS_DECL_ISUPPORTS

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -93,12 +93,12 @@ LoadInfo::TriggeringPrincipal()
}
NS_IMETHODIMP
LoadInfo::GetLoadingDocument(nsIDOMDocument** outLoadingDocument)
LoadInfo::GetLoadingDocument(nsIDOMDocument** aResult)
{
nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext);
if (node) {
nsCOMPtr<nsIDOMDocument> context = do_QueryInterface(node->OwnerDoc());
context.forget(outLoadingDocument);
context.forget(aResult);
}
return NS_OK;
}
@ -111,16 +111,17 @@ LoadInfo::LoadingNode()
}
NS_IMETHODIMP
LoadInfo::GetSecurityFlags(nsSecurityFlags* outSecurityFlags)
LoadInfo::GetSecurityFlags(nsSecurityFlags* aResult)
{
*outSecurityFlags = mSecurityFlags;
*aResult = mSecurityFlags;
return NS_OK;
}
NS_IMETHODIMP
LoadInfo::GetForceInheritPrincipal(bool* aInheritPrincipal)
{
*aInheritPrincipal = (mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
*aInheritPrincipal =
(mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
return NS_OK;
}
@ -132,9 +133,9 @@ LoadInfo::GetLoadingSandboxed(bool* aLoadingSandboxed)
}
NS_IMETHODIMP
LoadInfo::GetContentPolicyType(nsContentPolicyType* outContentPolicyType)
LoadInfo::GetContentPolicyType(nsContentPolicyType* aResult)
{
*outContentPolicyType = mContentPolicyType;
*aResult = mContentPolicyType;
return NS_OK;
}
@ -153,9 +154,9 @@ LoadInfo::BaseURI()
}
NS_IMETHODIMP
LoadInfo::GetInnerWindowID(uint32_t* outInnerWindowID)
LoadInfo::GetInnerWindowID(uint32_t* aResult)
{
*outInnerWindowID = mInnerWindowID;
*aResult = mInnerWindowID;
return NS_OK;
}

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -34,7 +34,8 @@ SerializedLoadContext::SerializedLoadContext(nsIChannel* aChannel)
bool isOverriden = false;
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(aChannel);
if (pbChannel &&
NS_SUCCEEDED(pbChannel->IsPrivateModeOverriden(&isPrivate, &isOverriden)) &&
NS_SUCCEEDED(pbChannel->IsPrivateModeOverriden(&isPrivate,
&isOverriden)) &&
isOverriden) {
mUsePrivateBrowsing = isPrivate;
mIsPrivateBitValid = true;

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -37,15 +37,8 @@ public:
void Init(nsILoadContext* aLoadContext);
bool IsNotNull() const
{
return mIsNotNull;
}
bool IsPrivateBitValid() const
{
return mIsPrivateBitValid;
}
bool IsNotNull() const { return mIsNotNull; }
bool IsPrivateBitValid() const { return mIsPrivateBitValid; }
// used to indicate if child-side LoadContext * was null.
bool mIsNotNull;

View File

@ -1,7 +1,6 @@
/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=2 sw=2 tw=80 et:
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

View File

@ -1,7 +1,6 @@
/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=2 sw=2 tw=80 et:
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -34,9 +33,9 @@ public:
// Check whether two markers should be considered the same,
// for the purpose of pairing start and end markers. Normally
// this definition suffices.
virtual bool Equals(const TimelineMarker* other)
virtual bool Equals(const TimelineMarker* aOther)
{
return strcmp(mName, other->mName) == 0;
return strcmp(mName, aOther->mName) == 0;
}
// Add details specific to this marker type to aMarker. The
@ -44,34 +43,18 @@ public:
// called on both the starting and ending markers of a pair.
// Ordinarily the ending marker doesn't need to do anything
// here.
virtual void AddDetails(mozilla::dom::ProfileTimelineMarker& aMarker)
{
}
virtual void AddDetails(mozilla::dom::ProfileTimelineMarker& aMarker) {}
virtual void AddLayerRectangles(mozilla::dom::Sequence<mozilla::dom::ProfileTimelineLayerRect>&)
virtual void AddLayerRectangles(
mozilla::dom::Sequence<mozilla::dom::ProfileTimelineLayerRect>&)
{
MOZ_ASSERT_UNREACHABLE("can only be called on layer markers");
}
const char* GetName() const
{
return mName;
}
TracingMetadata GetMetaData() const
{
return mMetaData;
}
DOMHighResTimeStamp GetTime() const
{
return mTime;
}
const nsString& GetCause() const
{
return mCause;
}
const char* GetName() const { return mName; }
TracingMetadata GetMetaData() const { return mMetaData; }
DOMHighResTimeStamp GetTime() const { return mTime; }
const nsString& GetCause() const { return mCause; }
JSObject* GetStack()
{
@ -82,7 +65,6 @@ public:
}
protected:
void CaptureStack()
{
JSContext* ctx = nsContentUtils::GetCurrentJSContext();
@ -97,7 +79,6 @@ protected:
}
private:
const char* mName;
TracingMetadata mMetaData;
DOMHighResTimeStamp mTime;

View File

@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:set ts=4 sw=4 sts=4 et cindent: */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -12,7 +12,8 @@
NS_IMPL_ISUPPORTS(nsAboutRedirector, nsIAboutModule)
struct RedirEntry {
struct RedirEntry
{
const char* id;
const char* url;
uint32_t flags;
@ -29,61 +30,93 @@ struct RedirEntry {
URI. Perhaps we should separate the two concepts out...
*/
static RedirEntry kRedirMap[] = {
{ "", "chrome://global/content/about.xhtml",
nsIAboutModule::ALLOW_SCRIPT },
{
"", "chrome://global/content/about.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{ "about", "chrome://global/content/aboutAbout.xhtml", 0 },
{ "credits", "http://www.mozilla.org/credits/",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
{ "mozilla", "chrome://global/content/mozilla.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
{
"credits", "http://www.mozilla.org/credits/",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
},
{
"mozilla", "chrome://global/content/mozilla.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
},
{ "plugins", "chrome://global/content/plugins.html", 0 },
{ "config", "chrome://global/content/config.xul", 0 },
#ifdef MOZ_CRASHREPORTER
{ "crashes", "chrome://global/content/crashes.xhtml", 0 },
#endif
{ "logo", "chrome://branding/content/about.png",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT},
{ "buildconfig", "chrome://global/content/buildconfig.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
{ "license", "chrome://global/content/license.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT },
{ "neterror", "chrome://global/content/netError.xhtml",
{
"logo", "chrome://branding/content/about.png",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
},
{
"buildconfig", "chrome://global/content/buildconfig.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
},
{
"license", "chrome://global/content/license.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
},
{
"neterror", "chrome://global/content/netError.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::URI_CAN_LOAD_IN_CHILD |
nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
{ "memory", "chrome://global/content/aboutMemory.xhtml",
nsIAboutModule::ALLOW_SCRIPT },
{ "compartments", "chrome://global/content/aboutCompartments.xhtml",
nsIAboutModule::ALLOW_SCRIPT },
{ "addons", "chrome://mozapps/content/extensions/extensions.xul",
nsIAboutModule::ALLOW_SCRIPT },
{ "newaddon", "chrome://mozapps/content/extensions/newaddon.xul",
nsIAboutModule::HIDE_FROM_ABOUTABOUT
},
{
"memory", "chrome://global/content/aboutMemory.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"compartments", "chrome://global/content/aboutCompartments.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"addons", "chrome://mozapps/content/extensions/extensions.xul",
nsIAboutModule::ALLOW_SCRIPT
},
{
"newaddon", "chrome://mozapps/content/extensions/newaddon.xul",
nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT },
{ "support", "chrome://global/content/aboutSupport.xhtml",
nsIAboutModule::ALLOW_SCRIPT },
{ "telemetry", "chrome://global/content/aboutTelemetry.xhtml",
nsIAboutModule::ALLOW_SCRIPT },
{ "networking", "chrome://global/content/aboutNetworking.xhtml",
nsIAboutModule::ALLOW_SCRIPT },
{ "webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.xhtml",
nsIAboutModule::ALLOW_SCRIPT },
nsIAboutModule::HIDE_FROM_ABOUTABOUT
},
{
"support", "chrome://global/content/aboutSupport.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"telemetry", "chrome://global/content/aboutTelemetry.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"networking", "chrome://global/content/aboutNetworking.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
// about:srcdoc is unresolvable by specification. It is included here
// because the security manager would disallow srcdoc iframes otherwise.
{ "srcdoc", "about:blank",
{
"srcdoc", "about:blank",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT }
nsIAboutModule::HIDE_FROM_ABOUTABOUT
}
};
static const int kRedirTotal = mozilla::ArrayLength(kRedirMap);
NS_IMETHODIMP
nsAboutRedirector::NewChannel(nsIURI* aURI,
nsILoadInfo* aLoadInfo,
nsIChannel** result)
nsIChannel** aResult)
{
NS_ENSURE_ARG_POINTER(aURI);
NS_ASSERTION(result, "must not be null");
NS_ASSERTION(aResult, "must not be null");
nsAutoCString path;
nsresult rv = NS_GetAboutModuleName(aURI, path);
@ -92,11 +125,8 @@ nsAboutRedirector::NewChannel(nsIURI* aURI,
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
NS_ENSURE_SUCCESS(rv, rv);
for (int i=0; i<kRedirTotal; i++)
{
if (!strcmp(path.get(), kRedirMap[i].id))
{
for (int i = 0; i < kRedirTotal; i++) {
if (!strcmp(path.get(), kRedirMap[i].id)) {
nsCOMPtr<nsIChannel> tempChannel;
nsCOMPtr<nsIURI> tempURI;
rv = NS_NewURI(getter_AddRefs(tempURI), kRedirMap[i].url);
@ -109,17 +139,16 @@ nsAboutRedirector::NewChannel(nsIURI* aURI,
rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
tempURI,
aLoadInfo);
} else {
rv = ioService->NewChannelFromURI(tempURI, getter_AddRefs(tempChannel));
}
else {
rv = ioService->NewChannelFromURI(tempURI,
getter_AddRefs(tempChannel));
}
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
return rv;
}
tempChannel->SetOriginalURI(aURI);
NS_ADDREF(*result = tempChannel);
NS_ADDREF(*aResult = tempChannel);
return rv;
}
}
@ -129,7 +158,7 @@ nsAboutRedirector::NewChannel(nsIURI* aURI,
}
NS_IMETHODIMP
nsAboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result)
nsAboutRedirector::GetURIFlags(nsIURI* aURI, uint32_t* aResult)
{
NS_ENSURE_ARG_POINTER(aURI);
@ -137,11 +166,9 @@ nsAboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result)
nsresult rv = NS_GetAboutModuleName(aURI, name);
NS_ENSURE_SUCCESS(rv, rv);
for (int i=0; i < kRedirTotal; i++)
{
if (name.EqualsASCII(kRedirMap[i].id))
{
*result = kRedirMap[i].flags;
for (int i = 0; i < kRedirTotal; i++) {
if (name.EqualsASCII(kRedirMap[i].id)) {
*aResult = kRedirMap[i].flags;
return NS_OK;
}
}
@ -151,9 +178,9 @@ nsAboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result)
}
NS_IMETHODIMP
nsAboutRedirector::GetIndexedDBOriginPostfix(nsIURI *aURI, nsAString &result)
nsAboutRedirector::GetIndexedDBOriginPostfix(nsIURI* aURI, nsAString& aResult)
{
SetDOMStringToNull(result);
SetDOMStringToNull(aResult);
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -161,8 +188,6 @@ nsresult
nsAboutRedirector::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
nsAboutRedirector* about = new nsAboutRedirector();
if (about == nullptr)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(about);
nsresult rv = about->QueryInterface(aIID, aResult);
NS_RELEASE(about);

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -17,8 +18,7 @@ public:
nsAboutRedirector() {}
static nsresult
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
protected:
virtual ~nsAboutRedirector() {}

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -48,7 +49,6 @@ nsDSURIContentListener::Init()
return rv;
}
//*****************************************************************************
// nsDSURIContentListener::nsISupports
//*****************************************************************************
@ -79,8 +79,9 @@ nsDSURIContentListener::OnStartURIOpen(nsIURI* aURI, bool* aAbortOpen)
nsCOMPtr<nsIURIContentListener> parentListener;
GetParentContentListener(getter_AddRefs(parentListener));
if (parentListener)
if (parentListener) {
return parentListener->OnStartURIOpen(aURI, aAbortOpen);
}
return NS_OK;
}
@ -88,7 +89,7 @@ nsDSURIContentListener::OnStartURIOpen(nsIURI* aURI, bool* aAbortOpen)
NS_IMETHODIMP
nsDSURIContentListener::DoContent(const char* aContentType,
bool aIsContentPreferred,
nsIRequest* request,
nsIRequest* aRequest,
nsIStreamListener** aContentHandler,
bool* aAbortProcess)
{
@ -99,7 +100,7 @@ nsDSURIContentListener::DoContent(const char* aContentType,
// Check whether X-Frame-Options permits us to load this content in an
// iframe and abort the load (unless we've disabled x-frame-options
// checking).
if (!CheckFrameOptions(request)) {
if (!CheckFrameOptions(aRequest)) {
*aAbortProcess = true;
return NS_OK;
}
@ -108,13 +109,13 @@ nsDSURIContentListener::DoContent(const char* aContentType,
// determine if the channel has just been retargeted to us...
nsLoadFlags loadFlags = 0;
nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(request);
nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(aRequest);
if (aOpenedChannel)
if (aOpenedChannel) {
aOpenedChannel->GetLoadFlags(&loadFlags);
}
if(loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI)
{
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
// XXX: Why does this not stop the content too?
mDocShell->Stop(nsIWebNavigation::STOP_NETWORK);
@ -125,20 +126,19 @@ nsDSURIContentListener::DoContent(const char* aContentType,
// create new viewer since the one we already have is capable of
// rendering multipart jpeg correctly (see bug 625012)
nsCOMPtr<nsIChannel> baseChannel;
if (nsCOMPtr<nsIMultiPartChannel> mpchan = do_QueryInterface(request)) {
if (nsCOMPtr<nsIMultiPartChannel> mpchan = do_QueryInterface(aRequest)) {
mpchan->GetBaseChannel(getter_AddRefs(baseChannel));
}
bool reuseCV = baseChannel
&& baseChannel == mExistingJPEGRequest
&& nsDependentCString(aContentType).EqualsLiteral("image/jpeg");
bool reuseCV = baseChannel && baseChannel == mExistingJPEGRequest &&
nsDependentCString(aContentType).EqualsLiteral("image/jpeg");
if (mExistingJPEGStreamListener && reuseCV) {
nsRefPtr<nsIStreamListener> copy(mExistingJPEGStreamListener);
copy.forget(aContentHandler);
rv = NS_OK;
} else {
rv = mDocShell->CreateContentViewer(aContentType, request, aContentHandler);
rv = mDocShell->CreateContentViewer(aContentType, aRequest, aContentHandler);
if (NS_SUCCEEDED(rv) && reuseCV) {
mExistingJPEGStreamListener = *aContentHandler;
} else {
@ -147,9 +147,8 @@ nsDSURIContentListener::DoContent(const char* aContentType,
mExistingJPEGRequest = baseChannel;
}
if (rv == NS_ERROR_REMOTE_XUL) {
request->Cancel(rv);
aRequest->Cancel(rv);
*aAbortProcess = true;
return NS_OK;
}
@ -161,8 +160,8 @@ nsDSURIContentListener::DoContent(const char* aContentType,
}
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
nsCOMPtr<nsIDOMWindow> domWindow = mDocShell ? mDocShell->GetWindow()
: nullptr;
nsCOMPtr<nsIDOMWindow> domWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
domWindow->Focus();
}
@ -199,10 +198,7 @@ nsDSURIContentListener::IsPreferred(const char* aContentType,
// and someone didn't EXPLICITLY set a nsIURIContentListener at the top
// of our docshell chain, then we'll now always attempt to process the
// content ourselves...
return CanHandleContent(aContentType,
true,
aDesiredContentType,
aCanHandle);
return CanHandleContent(aContentType, true, aDesiredContentType, aCanHandle);
}
NS_IMETHODIMP
@ -249,17 +245,15 @@ nsDSURIContentListener::SetLoadCookie(nsISupports * aLoadCookie)
}
NS_IMETHODIMP
nsDSURIContentListener::GetParentContentListener(nsIURIContentListener**
aParentListener)
{
if (mWeakParentContentListener)
nsDSURIContentListener::GetParentContentListener(
nsIURIContentListener** aParentListener)
{
if (mWeakParentContentListener) {
nsCOMPtr<nsIURIContentListener> tempListener =
do_QueryReferent(mWeakParentContentListener);
*aParentListener = tempListener;
NS_IF_ADDREF(*aParentListener);
}
else {
} else {
*aParentListener = mParentContentListener;
NS_IF_ADDREF(*aParentListener);
}
@ -267,43 +261,42 @@ nsDSURIContentListener::GetParentContentListener(nsIURIContentListener**
}
NS_IMETHODIMP
nsDSURIContentListener::SetParentContentListener(nsIURIContentListener*
aParentListener)
{
if (aParentListener)
nsDSURIContentListener::SetParentContentListener(
nsIURIContentListener* aParentListener)
{
if (aParentListener) {
// Store the parent listener as a weak ref. Parents not supporting
// nsISupportsWeakReference assert but may still be used.
mParentContentListener = nullptr;
mWeakParentContentListener = do_GetWeakReference(aParentListener);
if (!mWeakParentContentListener)
{
if (!mWeakParentContentListener) {
mParentContentListener = aParentListener;
}
}
else
{
} else {
mWeakParentContentListener = nullptr;
mParentContentListener = nullptr;
}
return NS_OK;
}
bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChannel,
const nsAString& policy) {
bool
nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
const nsAString& aPolicy)
{
static const char allowFrom[] = "allow-from";
const uint32_t allowFromLen = ArrayLength(allowFrom) - 1;
bool isAllowFrom =
StringHead(policy, allowFromLen).LowerCaseEqualsLiteral(allowFrom);
StringHead(aPolicy, allowFromLen).LowerCaseEqualsLiteral(allowFrom);
// return early if header does not have one of the values with meaning
if (!policy.LowerCaseEqualsLiteral("deny") &&
!policy.LowerCaseEqualsLiteral("sameorigin") &&
!isAllowFrom)
if (!aPolicy.LowerCaseEqualsLiteral("deny") &&
!aPolicy.LowerCaseEqualsLiteral("sameorigin") &&
!isAllowFrom) {
return true;
}
nsCOMPtr<nsIURI> uri;
httpChannel->GetURI(getter_AddRefs(uri));
aHttpChannel->GetURI(getter_AddRefs(uri));
// XXXkhuey when does this happen? Is returning true safe here?
if (!mDocShell) {
@ -316,8 +309,9 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// the document must never be framed.
nsCOMPtr<nsIDOMWindow> thisWindow = mDocShell->GetWindow();
// If we don't have DOMWindow there is no risk of clickjacking
if (!thisWindow)
if (!thisWindow) {
return true;
}
// GetScriptableTop, not GetTop, because we want this to respect
// <iframe mozbrowser> boundaries.
@ -325,17 +319,18 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
thisWindow->GetScriptableTop(getter_AddRefs(topWindow));
// if the document is in the top window, it's not in a frame.
if (thisWindow == topWindow)
if (thisWindow == topWindow) {
return true;
}
// Find the top docshell in our parent chain that doesn't have the system
// principal and use it for the principal comparison. Finding the top
// content-type docshell doesn't work because some chrome documents are
// loaded in content docshells (see bug 593387).
nsCOMPtr<nsIDocShellTreeItem> thisDocShellItem(do_QueryInterface(
static_cast<nsIDocShell*> (mDocShell)));
nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem,
curDocShellItem = thisDocShellItem;
nsCOMPtr<nsIDocShellTreeItem> thisDocShellItem(
do_QueryInterface(static_cast<nsIDocShell*>(mDocShell)));
nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
nsCOMPtr<nsIDocShellTreeItem> curDocShellItem = thisDocShellItem;
nsCOMPtr<nsIDocument> topDoc;
nsresult rv;
nsCOMPtr<nsIScriptSecurityManager> ssm =
@ -347,9 +342,9 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// Traverse up the parent chain and stop when we see a docshell whose
// parent has a system principal, or a docshell corresponding to
// <iframe mozbrowser>.
while (NS_SUCCEEDED(curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem))) &&
while (NS_SUCCEEDED(
curDocShellItem->GetParent(getter_AddRefs(parentDocShellItem))) &&
parentDocShellItem) {
nsCOMPtr<nsIDocShell> curDocShell = do_QueryInterface(curDocShellItem);
if (curDocShell && curDocShell->GetIsBrowserOrApp()) {
break;
@ -358,13 +353,13 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
bool system = false;
topDoc = parentDocShellItem->GetDocument();
if (topDoc) {
if (NS_SUCCEEDED(ssm->IsSystemPrincipal(topDoc->NodePrincipal(),
&system)) && system) {
if (NS_SUCCEEDED(
ssm->IsSystemPrincipal(topDoc->NodePrincipal(), &system)) &&
system) {
// Found a system-principled doc: last docshell was top.
break;
}
}
else {
} else {
return false;
}
curDocShellItem = parentDocShellItem;
@ -372,13 +367,14 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// If this document has the top non-SystemPrincipal docshell it is not being
// framed or it is being framed by a chrome document, which we allow.
if (curDocShellItem == thisDocShellItem)
if (curDocShellItem == thisDocShellItem) {
return true;
}
// If the value of the header is DENY, and the previous condition is
// not met (current docshell is not the top docshell), prohibit the
// load.
if (policy.LowerCaseEqualsLiteral("deny")) {
if (aPolicy.LowerCaseEqualsLiteral("deny")) {
ReportXFOViolation(curDocShellItem, uri, eDENY);
return false;
}
@ -389,7 +385,7 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// If the X-Frame-Options value is SAMEORIGIN, then the top frame in the
// parent chain must be from the same origin as this document.
if (policy.LowerCaseEqualsLiteral("sameorigin")) {
if (aPolicy.LowerCaseEqualsLiteral("sameorigin")) {
rv = ssm->CheckSameOriginURI(uri, topUri, true);
if (NS_FAILED(rv)) {
ReportXFOViolation(curDocShellItem, uri, eSAMEORIGIN);
@ -400,16 +396,16 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// If the X-Frame-Options value is "allow-from [uri]", then the top
// frame in the parent chain must be from that origin
if (isAllowFrom) {
if (policy.Length() == allowFromLen ||
(policy[allowFromLen] != ' ' &&
policy[allowFromLen] != '\t')) {
if (aPolicy.Length() == allowFromLen ||
(aPolicy[allowFromLen] != ' ' &&
aPolicy[allowFromLen] != '\t')) {
ReportXFOViolation(curDocShellItem, uri, eALLOWFROM);
return false;
}
rv = NS_NewURI(getter_AddRefs(uri),
Substring(policy, allowFromLen));
if (NS_FAILED(rv))
rv = NS_NewURI(getter_AddRefs(uri), Substring(aPolicy, allowFromLen));
if (NS_FAILED(rv)) {
return false;
}
rv = ssm->CheckSameOriginURI(uri, topUri, true);
if (NS_FAILED(rv)) {
@ -424,10 +420,11 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
// Check if X-Frame-Options permits this document to be loaded as a subdocument.
// This will iterate through and check any number of X-Frame-Options policies
// in the request (comma-separated in a header, multiple headers, etc).
bool nsDSURIContentListener::CheckFrameOptions(nsIRequest *request)
bool
nsDSURIContentListener::CheckFrameOptions(nsIRequest* aRequest)
{
nsresult rv;
nsCOMPtr<nsIChannel> chan = do_QueryInterface(request);
nsCOMPtr<nsIChannel> chan = do_QueryInterface(aRequest);
if (!chan) {
return true;
}
@ -436,9 +433,10 @@ bool nsDSURIContentListener::CheckFrameOptions(nsIRequest *request)
if (!httpChannel) {
// check if it is hiding in a multipart channel
rv = mDocShell->GetHttpChannel(chan, getter_AddRefs(httpChannel));
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
return false;
}
}
if (!httpChannel) {
return true;
@ -450,8 +448,9 @@ bool nsDSURIContentListener::CheckFrameOptions(nsIRequest *request)
NS_ConvertUTF8toUTF16 xfoHeaderValue(xfoHeaderCValue);
// if no header value, there's nothing to do.
if (xfoHeaderValue.IsEmpty())
if (xfoHeaderValue.IsEmpty()) {
return true;
}
// iterate through all the header values (usually there's only one, but can
// be many. If any want to deny the load, deny the load.
@ -483,42 +482,49 @@ nsDSURIContentListener::ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem
MOZ_ASSERT(aTopDocShellItem, "Need a top docshell");
nsCOMPtr<nsPIDOMWindow> topOuterWindow = aTopDocShellItem->GetWindow();
if (!topOuterWindow)
if (!topOuterWindow) {
return;
}
NS_ASSERTION(topOuterWindow->IsOuterWindow(), "Huh?");
nsPIDOMWindow* topInnerWindow = topOuterWindow->GetCurrentInnerWindow();
if (!topInnerWindow)
if (!topInnerWindow) {
return;
}
nsCOMPtr<nsIURI> topURI;
nsCOMPtr<nsIDocument> document = aTopDocShellItem->GetDocument();
nsresult rv = document->NodePrincipal()->GetURI(getter_AddRefs(topURI));
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
return;
}
if (!topURI)
if (!topURI) {
return;
}
nsCString topURIString;
nsCString thisURIString;
rv = topURI->GetSpec(topURIString);
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
return;
}
rv = aThisURI->GetSpec(thisURIString);
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
return;
}
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
nsCOMPtr<nsIScriptError> errorObject =
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
if (!consoleService || !errorObject)
if (!consoleService || !errorObject) {
return;
}
nsString msg = NS_LITERAL_STRING("Load denied by X-Frame-Options: ");
msg.Append(NS_ConvertUTF8toUTF16(thisURIString));
@ -541,8 +547,9 @@ nsDSURIContentListener::ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem
nsIScriptError::errorFlag,
"X-Frame-Options",
topInnerWindow->WindowID());
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
return;
}
consoleService->LogMessage(errorObject);
}

View File

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -16,12 +16,12 @@ class nsIWebNavigationInfo;
class nsIHttpChannel;
class nsAString;
class nsDSURIContentListener MOZ_FINAL :
public nsIURIContentListener,
public nsSupportsWeakReference
class nsDSURIContentListener MOZ_FINAL
: public nsIURIContentListener
, public nsSupportsWeakReference
{
friend class nsDocShell;
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIURICONTENTLISTENER
@ -32,7 +32,8 @@ protected:
explicit nsDSURIContentListener(nsDocShell* aDocShell);
virtual ~nsDSURIContentListener();
void DropDocShellreference() {
void DropDocShellReference()
{
mDocShell = nullptr;
mExistingJPEGRequest = nullptr;
mExistingJPEGStreamListener = nullptr;
@ -40,11 +41,12 @@ protected:
// Determine if X-Frame-Options allows content to be framed
// as a subdocument
bool CheckFrameOptions(nsIRequest* request);
bool CheckOneFrameOptionsPolicy(nsIHttpChannel* httpChannel,
const nsAString& policy);
bool CheckFrameOptions(nsIRequest* aRequest);
bool CheckOneFrameOptionsPolicy(nsIHttpChannel* aHttpChannel,
const nsAString& aPolicy);
enum XFOHeader {
enum XFOHeader
{
eDENY,
eSAMEORIGIN,
eALLOWFROM
@ -53,6 +55,7 @@ protected:
void ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem,
nsIURI* aThisURI,
XFOHeader aHeader);
protected:
nsDocShell* mDocShell;
// Hack to handle multipart images without creating a new viewer

View File

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -39,13 +39,10 @@ static bool sFixupKeywords = true;
nsDefaultURIFixup::nsDefaultURIFixup()
{
/* member initializers and constructor code */
}
nsDefaultURIFixup::~nsDefaultURIFixup()
{
/* destructor code */
}
/* nsIURI createExposableURI (in nsIURI aURI); */
@ -62,8 +59,7 @@ nsDefaultURIFixup::CreateExposableURI(nsIURI *aURI, nsIURI **aReturn)
aURI->GetUserPass(userPass);
// most of the time we can just AddRef and return
if (!isWyciwyg && userPass.IsEmpty())
{
if (!isWyciwyg && userPass.IsEmpty()) {
*aReturn = aURI;
NS_ADDREF(*aReturn);
return NS_OK;
@ -71,28 +67,26 @@ nsDefaultURIFixup::CreateExposableURI(nsIURI *aURI, nsIURI **aReturn)
// Rats, we have to massage the URI
nsCOMPtr<nsIURI> uri;
if (isWyciwyg)
{
if (isWyciwyg) {
nsAutoCString path;
nsresult rv = aURI->GetPath(path);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t pathLength = path.Length();
if (pathLength <= 2)
{
if (pathLength <= 2) {
return NS_ERROR_FAILURE;
}
// Path is of the form "//123/http://foo/bar", with a variable number of digits.
// To figure out where the "real" URL starts, search path for a '/', starting at
// the third character.
// Path is of the form "//123/http://foo/bar", with a variable number of
// digits. To figure out where the "real" URL starts, search path for a '/',
// starting at the third character.
int32_t slashIndex = path.FindChar('/', 2);
if (slashIndex == kNotFound)
{
if (slashIndex == kNotFound) {
return NS_ERROR_FAILURE;
}
// Get the charset of the original URI so we can pass it to our fixed up URI.
// Get the charset of the original URI so we can pass it to our fixed up
// URI.
nsAutoCString charset;
aURI->GetOriginCharset(charset);
@ -100,17 +94,14 @@ nsDefaultURIFixup::CreateExposableURI(nsIURI *aURI, nsIURI **aReturn)
Substring(path, slashIndex + 1, pathLength - slashIndex - 1),
charset.get());
NS_ENSURE_SUCCESS(rv, rv);
}
else
{
} else {
// clone the URI so zapping user:pass doesn't change the original
nsresult rv = aURI->Clone(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
}
// hide user:pass unless overridden by pref
if (Preferences::GetBool("browser.fixup.hide_user_pass", true))
{
if (Preferences::GetBool("browser.fixup.hide_user_pass", true)) {
uri->SetUserPass(EmptyCString());
}
@ -122,7 +113,8 @@ nsDefaultURIFixup::CreateExposableURI(nsIURI *aURI, nsIURI **aReturn)
/* nsIURI createFixupURI (in nsAUTF8String aURIText, in unsigned long aFixupFlags); */
NS_IMETHODIMP
nsDefaultURIFixup::CreateFixupURI(const nsACString& aStringURI, uint32_t aFixupFlags,
nsDefaultURIFixup::CreateFixupURI(const nsACString& aStringURI,
uint32_t aFixupFlags,
nsIInputStream** aPostData, nsIURI** aURI)
{
nsCOMPtr<nsIURIFixupInfo> fixupInfo;
@ -135,8 +127,10 @@ nsDefaultURIFixup::CreateFixupURI(const nsACString& aStringURI, uint32_t aFixupF
}
NS_IMETHODIMP
nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixupFlags,
nsIInputStream **aPostData, nsIURIFixupInfo **aInfo)
nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI,
uint32_t aFixupFlags,
nsIInputStream** aPostData,
nsIURIFixupInfo** aInfo)
{
NS_ENSURE_ARG(!aStringURI.IsEmpty());
@ -154,7 +148,8 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
nsRefPtr<nsDefaultURIFixupInfo> info = new nsDefaultURIFixupInfo(uriString);
NS_ADDREF(*aInfo = info);
nsCOMPtr<nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIIOService> ioService =
do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString scheme;
ioService->ExtractScheme(aStringURI, scheme);
@ -163,8 +158,7 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
// after it. The easiest way to do that is to call this method again with the
// "view-source:" lopped off and then prepend it again afterwards.
if (scheme.LowerCaseEqualsLiteral("view-source"))
{
if (scheme.LowerCaseEqualsLiteral("view-source")) {
nsCOMPtr<nsIURIFixupInfo> uriInfo;
uint32_t newFixupFlags = aFixupFlags & ~FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP;
@ -173,25 +167,25 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
uriString.Length() -
(sizeof("view-source:") - 1)),
newFixupFlags, aPostData, getter_AddRefs(uriInfo));
if (NS_FAILED(rv))
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
nsAutoCString spec;
nsCOMPtr<nsIURI> uri;
uriInfo->GetPreferredURI(getter_AddRefs(uri));
if (!uri)
if (!uri) {
return NS_ERROR_FAILURE;
}
uri->GetSpec(spec);
uriString.AssignLiteral("view-source:");
uriString.Append(spec);
}
else {
} else {
// Check for if it is a file URL
nsCOMPtr<nsIURI> uri;
FileURIFixup(uriString, getter_AddRefs(uri));
// NB: FileURIFixup only returns a URI if it had to fix the protocol to
// do so, so passing in file:///foo/bar will not hit this path:
if (uri)
{
if (uri) {
uri.swap(info->mFixedURI);
info->mPreferredURI = info->mFixedURI;
info->mFixupChangedProtocol = true;
@ -199,8 +193,8 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
}
#if defined(XP_WIN)
// Not a file URL, so translate '\' to '/' for convenience in the common protocols
// e.g. catch
// Not a file URL, so translate '\' to '/' for convenience in the common
// protocols. E.g. catch
//
// http:\\broken.com\address
// http:\\broken.com/blah
@ -215,8 +209,7 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
if (scheme.IsEmpty() ||
scheme.LowerCaseEqualsLiteral("http") ||
scheme.LowerCaseEqualsLiteral("https") ||
scheme.LowerCaseEqualsLiteral("ftp"))
{
scheme.LowerCaseEqualsLiteral("ftp")) {
// Walk the string replacing backslashes with forward slashes until
// the end is reached, or a question mark, or a hash, or a forward
// slash. The forward slash test is to stop before trampling over
@ -227,10 +220,12 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
uriString.BeginWriting(start);
uriString.EndWriting(end);
while (start != end) {
if (*start == '?' || *start == '#' || *start == '/')
if (*start == '?' || *start == '#' || *start == '/') {
break;
if (*start == '\\')
}
if (*start == '\\') {
*start = '/';
}
++start;
}
}
@ -248,7 +243,8 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
rv = Preferences::AddBoolVarCache(&sDNSFirstForSingleWords,
"browser.fixup.dns_first_for_single_words",
sDNSFirstForSingleWords);
MOZ_ASSERT(NS_SUCCEEDED(rv), "Failed to observe \"browser.fixup.dns_first_for_single_words\"");
MOZ_ASSERT(NS_SUCCEEDED(rv),
"Failed to observe \"browser.fixup.dns_first_for_single_words\"");
rv = Preferences::AddBoolVarCache(&sFixupKeywords, "keyword.enabled",
sFixupKeywords);
@ -258,7 +254,6 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
// Fix up common scheme typos.
if (sFixTypos && (aFixupFlags & FIXUP_FLAG_FIX_SCHEME_TYPOS)) {
// Fast-path for common cases.
if (scheme.IsEmpty() ||
scheme.LowerCaseEqualsLiteral("http") ||
@ -321,7 +316,8 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID);
if (extProtService) {
bool handlerExists = false;
rv = extProtService->ExternalProtocolHandlerExists(scheme.get(), &handlerExists);
rv = extProtService->ExternalProtocolHandlerExists(scheme.get(),
&handlerExists);
if (NS_FAILED(rv)) {
return rv;
}
@ -337,8 +333,9 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
if (info->mFixedURI) {
if (!info->mPreferredURI) {
if (aFixupFlags & FIXUP_FLAGS_MAKE_ALTERNATE_URI)
if (aFixupFlags & FIXUP_FLAGS_MAKE_ALTERNATE_URI) {
info->mFixupCreatedAlternateURI = MakeAlternateURI(info->mFixedURI);
}
info->mPreferredURI = info->mFixedURI;
}
return NS_OK;
@ -354,8 +351,7 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
// ://totallybroken.url.com
// //shorthand.url.com
//
if (StringBeginsWith(uriString, NS_LITERAL_CSTRING("://")))
{
if (StringBeginsWith(uriString, NS_LITERAL_CSTRING("://"))) {
uriString = StringTail(uriString, uriString.Length() - 3);
inputHadDuffProtocol = true;
} else if (StringBeginsWith(uriString, NS_LITERAL_CSTRING("//"))) {
@ -392,14 +388,13 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
// be whitelisted?
if (info->mFixedURI) {
if (aFixupFlags & FIXUP_FLAG_REQUIRE_WHITELISTED_HOST) {
nsAutoCString asciiHost;
if (NS_SUCCEEDED(info->mFixedURI->GetAsciiHost(asciiHost)) &&
!asciiHost.IsEmpty()) {
uint32_t dotLoc = uint32_t(asciiHost.FindChar('.'));
if ((dotLoc == uint32_t(kNotFound) || dotLoc == asciiHost.Length() - 1)) {
if ((dotLoc == uint32_t(kNotFound) ||
dotLoc == asciiHost.Length() - 1)) {
if (IsDomainWhitelisted(asciiHost, dotLoc)) {
info->mPreferredURI = info->mFixedURI;
}
@ -423,7 +418,8 @@ nsDefaultURIFixup::GetFixupURIInfo(const nsACString& aStringURI, uint32_t aFixup
return rv;
}
NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
NS_IMETHODIMP
nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
nsIInputStream** aPostData,
nsIURIFixupInfo** aInfo)
{
@ -451,7 +447,8 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
ipc::OptionalInputStreamParams postData;
ipc::OptionalURIParams uri;
nsAutoString providerName;
if (!contentChild->SendKeywordToURI(keyword, &providerName, &postData, &uri)) {
if (!contentChild->SendKeywordToURI(keyword, &providerName, &postData,
&uri)) {
return NS_ERROR_FAILURE;
}
@ -473,7 +470,8 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
#ifdef MOZ_TOOLKIT_SEARCH
// Try falling back to the search service's default search engine
nsCOMPtr<nsIBrowserSearchService> searchSvc = do_GetService("@mozilla.org/browser/search-service;1");
nsCOMPtr<nsIBrowserSearchService> searchSvc =
do_GetService("@mozilla.org/browser/search-service;1");
if (searchSvc) {
nsCOMPtr<nsISearchEngine> defaultEngine;
searchSvc->GetDefaultEngine(getter_AddRefs(defaultEngine));
@ -482,9 +480,11 @@ NS_IMETHODIMP nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
nsAutoString responseType;
// We allow default search plugins to specify alternate
// parameters that are specific to keyword searches.
NS_NAMED_LITERAL_STRING(mozKeywordSearch, "application/x-moz-keywordsearch");
NS_NAMED_LITERAL_STRING(mozKeywordSearch,
"application/x-moz-keywordsearch");
bool supportsResponseType = false;
defaultEngine->SupportsResponseType(mozKeywordSearch, &supportsResponseType);
defaultEngine->SupportsResponseType(mozKeywordSearch,
&supportsResponseType);
if (supportsResponseType) {
responseType.Assign(mozKeywordSearch);
}
@ -527,7 +527,8 @@ nsDefaultURIFixup::TryKeywordFixupForURIInfo(const nsACString & aURIString,
nsIInputStream** aPostData)
{
nsCOMPtr<nsIURIFixupInfo> keywordInfo;
nsresult rv = KeywordToURI(aURIString, aPostData, getter_AddRefs(keywordInfo));
nsresult rv = KeywordToURI(aURIString, aPostData,
getter_AddRefs(keywordInfo));
if (NS_SUCCEEDED(rv)) {
keywordInfo->GetKeywordProviderName(aFixupInfo->mKeywordProviderName);
keywordInfo->GetKeywordAsSent(aFixupInfo->mKeywordAsSent);
@ -536,14 +537,13 @@ nsDefaultURIFixup::TryKeywordFixupForURIInfo(const nsACString & aURIString,
return rv;
}
bool nsDefaultURIFixup::MakeAlternateURI(nsIURI *aURI)
{
if (!Preferences::GetRootBranch())
bool
nsDefaultURIFixup::MakeAlternateURI(nsIURI* aURI)
{
if (!Preferences::GetRootBranch()) {
return false;
}
if (!Preferences::GetBool("browser.fixup.alternate.enabled", true))
{
if (!Preferences::GetBool("browser.fixup.alternate.enabled", true)) {
return false;
}
@ -572,56 +572,46 @@ bool nsDefaultURIFixup::MakeAlternateURI(nsIURI *aURI)
oldHost.BeginReading(iter);
oldHost.EndReading(iterEnd);
while (iter != iterEnd) {
if (*iter == '.')
if (*iter == '.') {
numDots++;
}
++iter;
}
// Get the prefix and suffix to stick onto the new hostname. By default these
// are www. & .com but they could be any other value, e.g. www. & .org
nsAutoCString prefix("www.");
nsAdoptingCString prefPrefix =
Preferences::GetCString("browser.fixup.alternate.prefix");
if (prefPrefix)
{
if (prefPrefix) {
prefix.Assign(prefPrefix);
}
nsAutoCString suffix(".com");
nsAdoptingCString prefSuffix =
Preferences::GetCString("browser.fixup.alternate.suffix");
if (prefSuffix)
{
if (prefSuffix) {
suffix.Assign(prefSuffix);
}
if (numDots == 0)
{
if (numDots == 0) {
newHost.Assign(prefix);
newHost.Append(oldHost);
newHost.Append(suffix);
}
else if (numDots == 1)
{
} else if (numDots == 1) {
if (!prefix.IsEmpty() &&
oldHost.EqualsIgnoreCase(prefix.get(), prefix.Length())) {
newHost.Assign(oldHost);
newHost.Append(suffix);
}
else if (!suffix.IsEmpty()) {
} else if (!suffix.IsEmpty()) {
newHost.Assign(prefix);
newHost.Append(oldHost);
}
else
{
} else {
// Do nothing
return false;
}
}
else
{
} else {
// Do nothing
return false;
}
@ -639,7 +629,8 @@ bool nsDefaultURIFixup::MakeAlternateURI(nsIURI *aURI)
* Check if the host name starts with ftp\d*\. and it's not directly followed
* by the tld.
*/
bool nsDefaultURIFixup::IsLikelyFTP(const nsCString &aHostSpec)
bool
nsDefaultURIFixup::IsLikelyFTP(const nsCString& aHostSpec)
{
bool likelyFTP = false;
if (aHostSpec.EqualsIgnoreCase("ftp", 3)) {
@ -649,13 +640,11 @@ bool nsDefaultURIFixup::IsLikelyFTP(const nsCString &aHostSpec)
aHostSpec.EndReading(end);
iter.advance(3); // move past the "ftp" part
while (iter != end)
{
while (iter != end) {
if (*iter == '.') {
// now make sure the name has at least one more dot in it
++iter;
while (iter != end)
{
while (iter != end) {
if (*iter == '.') {
likelyFTP = true;
break;
@ -663,8 +652,7 @@ bool nsDefaultURIFixup::IsLikelyFTP(const nsCString &aHostSpec)
++iter;
}
break;
}
else if (!nsCRT::IsAsciiDigit(*iter)) {
} else if (!nsCRT::IsAsciiDigit(*iter)) {
break;
}
++iter;
@ -673,45 +661,43 @@ bool nsDefaultURIFixup::IsLikelyFTP(const nsCString &aHostSpec)
return likelyFTP;
}
nsresult nsDefaultURIFixup::FileURIFixup(const nsACString& aStringURI,
nsIURI** aURI)
nsresult
nsDefaultURIFixup::FileURIFixup(const nsACString& aStringURI, nsIURI** aURI)
{
nsAutoCString uriSpecOut;
nsresult rv = ConvertFileToStringURI(aStringURI, uriSpecOut);
if (NS_SUCCEEDED(rv))
{
if (NS_SUCCEEDED(rv)) {
// if this is file url, uriSpecOut is already in FS charset
if(NS_SUCCEEDED(NS_NewURI(aURI, uriSpecOut.get(), nullptr)))
if (NS_SUCCEEDED(NS_NewURI(aURI, uriSpecOut.get(), nullptr))) {
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
nsresult nsDefaultURIFixup::ConvertFileToStringURI(const nsACString& aIn,
nsCString& aOut)
nsresult
nsDefaultURIFixup::ConvertFileToStringURI(const nsACString& aIn,
nsCString& aResult)
{
bool attemptFixup = false;
#if defined(XP_WIN)
// Check for \ in the url-string or just a drive (PC)
if (kNotFound != aIn.FindChar('\\') ||
(aIn.Length() == 2 && (aIn.Last() == ':' || aIn.Last() == '|')))
{
(aIn.Length() == 2 && (aIn.Last() == ':' || aIn.Last() == '|'))) {
attemptFixup = true;
}
#elif defined(XP_UNIX)
// Check if it starts with / (UNIX)
if(aIn.First() == '/')
{
if (aIn.First() == '/') {
attemptFixup = true;
}
#else
// Do nothing (All others for now)
#endif
if (attemptFixup)
{
if (attemptFixup) {
// Test if this is a valid path by trying to create a local file
// object. The URL of that is returned if successful.
@ -726,8 +712,8 @@ nsresult nsDefaultURIFixup::ConvertFileToStringURI(const nsACString& aIn,
// in order to really fix the problem, we need to change the
// nsICmdLineService interface to use wstring to pass paramenters
// instead of string since path name and other argument could be
// in non ascii.(see bug 87127) Since it is too risky to make interface change right
// now, we decide not to do so now.
// in non ascii.(see bug 87127) Since it is too risky to make interface
// change right now, we decide not to do so now.
// Therefore, the aIn we receive here maybe already in damage form
// (e.g. treat every bytes as ISO-8859-1 and cast up to char16_t
// while the real data could be in file system charset )
@ -750,16 +736,15 @@ nsresult nsDefaultURIFixup::ConvertFileToStringURI(const nsACString& aIn,
NS_ConvertUTF8toUTF16 in(aIn);
if (PossiblyByteExpandedFileName(in)) {
// removes high byte
rv = NS_NewNativeLocalFile(NS_LossyConvertUTF16toASCII(in), false, getter_AddRefs(filePath));
}
else {
rv = NS_NewNativeLocalFile(NS_LossyConvertUTF16toASCII(in), false,
getter_AddRefs(filePath));
} else {
// input is unicode
rv = NS_NewLocalFile(in, false, getter_AddRefs(filePath));
}
if (NS_SUCCEEDED(rv))
{
NS_GetURLSpecFromFile(filePath, aOut);
if (NS_SUCCEEDED(rv)) {
NS_GetURLSpecFromFile(filePath, aResult);
return NS_OK;
}
}
@ -767,7 +752,6 @@ nsresult nsDefaultURIFixup::ConvertFileToStringURI(const nsACString& aIn,
return NS_ERROR_FAILURE;
}
nsresult
nsDefaultURIFixup::FixupURIProtocol(const nsACString& aURIString,
nsDefaultURIFixupInfo* aFixupInfo,
@ -791,26 +775,28 @@ nsDefaultURIFixup::FixupURIProtocol(const nsACString & aURIString,
(firstDelim != -1 && schemeDelim > firstDelim)) {
// find host name
int32_t hostPos = uriString.FindCharInSet("/:?#");
if (hostPos == -1)
if (hostPos == -1) {
hostPos = uriString.Length();
}
// extract host name
nsAutoCString hostSpec;
uriString.Left(hostSpec, hostPos);
// insert url spec corresponding to host name
if (IsLikelyFTP(hostSpec))
if (IsLikelyFTP(hostSpec)) {
uriString.InsertLiteral("ftp://", 0);
else
} else {
uriString.InsertLiteral("http://", 0);
}
aFixupInfo->mFixupChangedProtocol = true;
} // end if checkprotocol
return NS_NewURI(aURI, uriString, nullptr);
}
bool nsDefaultURIFixup::PossiblyHostPortUrl(const nsACString &aUrl)
bool
nsDefaultURIFixup::PossiblyHostPortUrl(const nsACString& aUrl)
{
// Oh dear, the protocol is invalid. Test if the protocol might
// actually be a url without a protocol:
@ -844,36 +830,30 @@ bool nsDefaultURIFixup::PossiblyHostPortUrl(const nsACString &aUrl)
aUrl.EndReading(iterEnd);
nsACString::const_iterator iter = iterBegin;
while (iter != iterEnd)
{
while (iter != iterEnd) {
uint32_t chunkSize = 0;
// Parse a chunk of the address
while (iter != iterEnd &&
(*iter == '-' ||
nsCRT::IsAsciiAlpha(*iter) ||
nsCRT::IsAsciiDigit(*iter)))
{
nsCRT::IsAsciiDigit(*iter))) {
++chunkSize;
++iter;
}
if (chunkSize == 0 || iter == iterEnd)
{
if (chunkSize == 0 || iter == iterEnd) {
return false;
}
if (*iter == ':')
{
if (*iter == ':') {
// Go onto checking the for the digits
break;
}
if (*iter != '.')
{
if (*iter != '.') {
// Whatever it is, it ain't a hostname!
return false;
}
++iter;
}
if (iter == iterEnd)
{
if (iter == iterEnd) {
// No point continuing since there is no colon
return false;
}
@ -883,25 +863,18 @@ bool nsDefaultURIFixup::PossiblyHostPortUrl(const nsACString &aUrl)
// next forward slash (or end of string)
uint32_t digitCount = 0;
while (iter != iterEnd && digitCount <= 5)
{
if (nsCRT::IsAsciiDigit(*iter))
{
while (iter != iterEnd && digitCount <= 5) {
if (nsCRT::IsAsciiDigit(*iter)) {
digitCount++;
}
else if (*iter == '/')
{
} else if (*iter == '/') {
break;
}
else
{
} else {
// Whatever it is, it ain't a port!
return false;
}
++iter;
}
if (digitCount == 0 || digitCount > 5)
{
if (digitCount == 0 || digitCount > 5) {
// No digits or more digits than a port would have.
return false;
}
@ -910,7 +883,8 @@ bool nsDefaultURIFixup::PossiblyHostPortUrl(const nsACString &aUrl)
return true;
}
bool nsDefaultURIFixup::PossiblyByteExpandedFileName(const nsAString& aIn)
bool
nsDefaultURIFixup::PossiblyByteExpandedFileName(const nsAString& aIn)
{
// XXXXX HACK XXXXX : please don't copy this code.
// There are cases where aIn contains the locale byte chars padded to short
@ -922,10 +896,10 @@ bool nsDefaultURIFixup::PossiblyByteExpandedFileName(const nsAString& aIn)
nsReadingIterator<char16_t> iterEnd;
aIn.BeginReading(iter);
aIn.EndReading(iterEnd);
while (iter != iterEnd)
{
if (*iter >= 0x0080 && *iter <= 0x00FF)
while (iter != iterEnd) {
if (*iter >= 0x0080 && *iter <= 0x00FF) {
return true;
}
++iter;
}
return false;
@ -1010,7 +984,8 @@ nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
firstSpaceLoc = pos;
} else if (*iter == '?' && firstQMarkLoc == uint32_t(kNotFound)) {
firstQMarkLoc = pos;
} else if ((*iter == '\'' || *iter == '"') && firstQuoteLoc == uint32_t(kNotFound)) {
} else if ((*iter == '\'' || *iter == '"') &&
firstQuoteLoc == uint32_t(kNotFound)) {
firstQuoteLoc = pos;
} else if (*iter == '[') {
lastLSBracketLoc = pos;
@ -1035,11 +1010,13 @@ nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
nsAutoCString asciiHost;
nsAutoCString host;
bool isValidAsciiHost = aFixupInfo->mFixedURI &&
bool isValidAsciiHost =
aFixupInfo->mFixedURI &&
NS_SUCCEEDED(aFixupInfo->mFixedURI->GetAsciiHost(asciiHost)) &&
!asciiHost.IsEmpty();
bool isValidHost = aFixupInfo->mFixedURI &&
bool isValidHost =
aFixupInfo->mFixedURI &&
NS_SUCCEEDED(aFixupInfo->mFixedURI->GetHost(host)) &&
!host.IsEmpty();
@ -1073,44 +1050,52 @@ nsDefaultURIFixup::KeywordURIFixup(const nsACString & aURIString,
nsresult rv = NS_OK;
// We do keyword lookups if a space or quote preceded the dot, colon
// or question mark (or if the latter is not found, or if the input starts with a question mark)
// or question mark (or if the latter is not found, or if the input starts
// with a question mark)
if (((firstSpaceLoc < firstDotLoc || firstQuoteLoc < firstDotLoc) &&
(firstSpaceLoc < firstColonLoc || firstQuoteLoc < firstColonLoc) &&
(firstSpaceLoc < firstQMarkLoc || firstQuoteLoc < firstQMarkLoc)) || firstQMarkLoc == 0) {
rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo, aPostData);
(firstSpaceLoc < firstQMarkLoc || firstQuoteLoc < firstQMarkLoc)) ||
firstQMarkLoc == 0) {
rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo,
aPostData);
// ... or when the host is the same as asciiHost and there are no
// characters from [a-z][A-Z]
} else if (isValidAsciiHost && isValidHost && !hasAsciiAlpha &&
host.EqualsIgnoreCase(asciiHost.get())) {
if (!sDNSFirstForSingleWords) {
rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo, aPostData);
rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo,
aPostData);
}
}
// ... or if there is no question mark or colon, and there is either no
// dot, or exactly 1 and it is the first or last character of the input:
else if ((firstDotLoc == uint32_t(kNotFound) ||
(foundDots == 1 && (firstDotLoc == 0 || firstDotLoc == aURIString.Length() - 1))) &&
firstColonLoc == uint32_t(kNotFound) && firstQMarkLoc == uint32_t(kNotFound)) {
(foundDots == 1 && (firstDotLoc == 0 ||
firstDotLoc == aURIString.Length() - 1))) &&
firstColonLoc == uint32_t(kNotFound) &&
firstQMarkLoc == uint32_t(kNotFound)) {
if (isValidAsciiHost && IsDomainWhitelisted(asciiHost, firstDotLoc)) {
return NS_OK;
}
// ... unless there are no dots, and a slash, and alpha characters, and this is a valid host:
if (firstDotLoc == uint32_t(kNotFound) && lastSlashLoc != uint32_t(kNotFound) &&
// ... unless there are no dots, and a slash, and alpha characters, and
// this is a valid host:
if (firstDotLoc == uint32_t(kNotFound) &&
lastSlashLoc != uint32_t(kNotFound) &&
hasAsciiAlpha && isValidAsciiHost) {
return NS_OK;
}
// If we get here, we don't have a valid URI, or we did but the
// host is not whitelisted, so we do a keyword search *anyway*:
rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo, aPostData);
rv = TryKeywordFixupForURIInfo(aFixupInfo->mOriginalInput, aFixupInfo,
aPostData);
}
return rv;
}
bool nsDefaultURIFixup::IsDomainWhitelisted(const nsAutoCString aAsciiHost,
bool
nsDefaultURIFixup::IsDomainWhitelisted(const nsAutoCString aAsciiHost,
const uint32_t aDotLoc)
{
if (sDNSFirstForSingleWords) {
@ -1132,29 +1117,16 @@ bool nsDefaultURIFixup::IsDomainWhitelisted(const nsAutoCString aAsciiHost,
return Preferences::GetBool(pref.get(), false);
}
nsresult NS_NewURIFixup(nsIURIFixup **aURIFixup)
{
nsDefaultURIFixup *fixup = new nsDefaultURIFixup;
if (fixup == nullptr)
{
return NS_ERROR_OUT_OF_MEMORY;
}
return fixup->QueryInterface(NS_GET_IID(nsIURIFixup), (void **) aURIFixup);
}
/* Implementation of nsIURIFixupInfo */
NS_IMPL_ISUPPORTS(nsDefaultURIFixupInfo, nsIURIFixupInfo)
nsDefaultURIFixupInfo::nsDefaultURIFixupInfo(const nsACString& aOriginalInput):
mFixupChangedProtocol(false),
mFixupCreatedAlternateURI(false)
nsDefaultURIFixupInfo::nsDefaultURIFixupInfo(const nsACString& aOriginalInput)
: mFixupChangedProtocol(false)
, mFixupCreatedAlternateURI(false)
{
mOriginalInput = aOriginalInput;
}
nsDefaultURIFixupInfo::~nsDefaultURIFixupInfo()
{
}
@ -1191,36 +1163,36 @@ nsDefaultURIFixupInfo::GetFixedURI(nsIURI** aFixedURI)
}
NS_IMETHODIMP
nsDefaultURIFixupInfo::GetKeywordProviderName(nsAString& aOut)
nsDefaultURIFixupInfo::GetKeywordProviderName(nsAString& aResult)
{
aOut = mKeywordProviderName;
aResult = mKeywordProviderName;
return NS_OK;
}
NS_IMETHODIMP
nsDefaultURIFixupInfo::GetKeywordAsSent(nsAString& aOut)
nsDefaultURIFixupInfo::GetKeywordAsSent(nsAString& aResult)
{
aOut = mKeywordAsSent;
aResult = mKeywordAsSent;
return NS_OK;
}
NS_IMETHODIMP
nsDefaultURIFixupInfo::GetFixupChangedProtocol(bool* aOut)
nsDefaultURIFixupInfo::GetFixupChangedProtocol(bool* aResult)
{
*aOut = mFixupChangedProtocol;
*aResult = mFixupChangedProtocol;
return NS_OK;
}
NS_IMETHODIMP
nsDefaultURIFixupInfo::GetFixupCreatedAlternateURI(bool* aOut)
nsDefaultURIFixupInfo::GetFixupCreatedAlternateURI(bool* aResult)
{
*aOut = mFixupCreatedAlternateURI;
*aResult = mFixupCreatedAlternateURI;
return NS_OK;
}
NS_IMETHODIMP
nsDefaultURIFixupInfo::GetOriginalInput(nsACString& aInput)
nsDefaultURIFixupInfo::GetOriginalInput(nsACString& aResult)
{
aInput = mOriginalInput;
aResult = mOriginalInput;
return NS_OK;
}

View File

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -26,7 +26,7 @@ protected:
private:
/* additional members */
nsresult FileURIFixup(const nsACString& aStringURI, nsIURI** aURI);
nsresult ConvertFileToStringURI(const nsACString& aIn, nsCString& aOut);
nsresult ConvertFileToStringURI(const nsACString& aIn, nsCString& aResult);
nsresult FixupURIProtocol(const nsACString& aIn,
nsDefaultURIFixupInfo* aFixupInfo,
nsIURI** aURI);

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=4 sw=4 et tw=80:
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -94,7 +93,8 @@ class ProfilerMarkerTracing;
/* load types were moved to nsDocShellLoadTypes.h */
/* internally used ViewMode types */
enum ViewMode {
enum ViewMode
{
viewNormal = 0x0,
viewSource = 0x1
};
@ -123,34 +123,36 @@ protected:
virtual ~nsRefreshTimer();
};
typedef enum {
enum eCharsetReloadState
{
eCharsetReloadInit,
eCharsetReloadRequested,
eCharsetReloadStopOrigional
} eCharsetReloadState;
};
//*****************************************************************************
//*** nsDocShell
//*****************************************************************************
class nsDocShell MOZ_FINAL : public nsDocLoader,
public nsIDocShell,
public nsIWebNavigation,
public nsIBaseWindow,
public nsIScrollable,
public nsITextScroll,
public nsIDocCharset,
public nsIContentViewerContainer,
public nsIRefreshURI,
public nsIWebProgressListener,
public nsIWebPageDescriptor,
public nsIAuthPromptProvider,
public nsILoadContext,
public nsIWebShellServices,
public nsILinkHandler,
public nsIClipboardCommands,
public nsIDOMStorageManager,
public mozilla::SupportsWeakPtr<nsDocShell>
class nsDocShell MOZ_FINAL
: public nsDocLoader
, public nsIDocShell
, public nsIWebNavigation
, public nsIBaseWindow
, public nsIScrollable
, public nsITextScroll
, public nsIDocCharset
, public nsIContentViewerContainer
, public nsIRefreshURI
, public nsIWebProgressListener
, public nsIWebPageDescriptor
, public nsIAuthPromptProvider
, public nsILoadContext
, public nsIWebShellServices
, public nsILinkHandler
, public nsIClipboardCommands
, public nsIDOMStorageManager
, public mozilla::SupportsWeakPtr<nsDocShell>
{
friend class nsDSURIContentListener;
@ -214,7 +216,8 @@ public:
NS_IMETHOD OnLeaveLink() MOZ_OVERRIDE;
nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType);
uint32_t ConvertDocShellLoadInfoToLoadType(nsDocShellInfoLoadType aDocShellLoadType);
uint32_t ConvertDocShellLoadInfoToLoadType(
nsDocShellInfoLoadType aDocShellLoadType);
// Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods
// are shared with nsIDocShell (appID, etc.) and can't be declared twice.
@ -271,6 +274,7 @@ public:
// Global counter for how many docShells are currently recording profile
// timeline markers
static unsigned long gProfileTimelineRecordingsCount;
protected:
// Object Management
virtual ~nsDocShell();
@ -284,10 +288,12 @@ protected:
nsIURI* aBaseURI,
bool aTryToSaveOldPresentation = true);
nsresult CreateContentViewer(const char* aContentType,
nsIRequest * request, nsIStreamListener ** aContentHandler);
nsIRequest* aRequest,
nsIStreamListener** aContentHandler);
nsresult NewContentViewerObj(const char* aContentType,
nsIRequest * request, nsILoadGroup * aLoadGroup,
nsIStreamListener ** aContentHandler, nsIContentViewer ** aViewer);
nsIRequest* aRequest, nsILoadGroup* aLoadGroup,
nsIStreamListener** aContentHandler,
nsIContentViewer** aViewer);
nsresult SetupNewViewer(nsIContentViewer* aNewViewer);
void SetupReferrerFromChannel(nsIChannel* aChannel);
@ -316,14 +322,14 @@ protected:
const nsAString& aFileName,
nsIInputStream* aPostData,
nsIInputStream* aHeadersData,
bool firstParty,
bool aFirstParty,
nsIDocShell** aDocShell,
nsIRequest** aRequest,
bool aIsNewWindowTarget,
bool aBypassClassifier,
bool aForceAllowCookies,
const nsAString& aSrcdoc,
nsIURI * baseURI,
nsIURI* aBaseURI,
nsContentPolicyType aContentPolicyType);
nsresult AddHeadersToChannel(nsIInputStream* aHeadersData,
nsIChannel* aChannel);
@ -331,7 +337,7 @@ protected:
nsIURILoader* aURILoader,
bool aBypassClassifier);
nsresult ScrollToAnchor(nsACString & curHash, nsACString & newHash,
nsresult ScrollToAnchor(nsACString& aCurHash, nsACString& aNewHash,
uint32_t aLoadType);
// Returns true if would have called FireOnLocationChange,
@ -359,7 +365,7 @@ protected:
bool aCloneSHChildren);
void SetReferrerURI(nsIURI* aURI);
void SetReferrerPolicy(uint32_t referrerPolicy);
void SetReferrerPolicy(uint32_t aReferrerPolicy);
// Session History
bool ShouldAddToSessionHistory(nsIURI* aURI);
@ -377,7 +383,7 @@ protected:
bool aCloneChildren);
nsresult AddChildSHEntryInternal(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
int32_t aChildOffset, uint32_t loadType,
int32_t aChildOffset, uint32_t aLoadType,
bool aCloneChildren);
nsresult LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType);
@ -399,8 +405,7 @@ protected:
nsISHEntry** aDestEntry);
// Child-walking callback for CloneAndReplace
static nsresult CloneAndReplaceChild(nsISHEntry *aEntry,
nsDocShell *aShell,
static nsresult CloneAndReplaceChild(nsISHEntry* aEntry, nsDocShell* aShell,
int32_t aChildIndex, void* aData);
nsresult GetRootSessionHistory(nsISHistory** aReturn);
@ -423,8 +428,7 @@ protected:
void SetHistoryEntry(nsCOMPtr<nsISHEntry>* aPtr, nsISHEntry* aEntry);
// Child-walking callback for SetHistoryEntry
static nsresult SetChildHistoryEntry(nsISHEntry *aEntry,
nsDocShell *aShell,
static nsresult SetChildHistoryEntry(nsISHEntry* aEntry, nsDocShell* aShell,
int32_t aEntryIndex, void* aData);
// Callback prototype for WalkHistoryEntries.
@ -550,11 +554,10 @@ protected:
nsresult SetBaseUrlForWyciwyg(nsIContentViewer* aContentViewer);
static inline uint32_t
PRTimeToSeconds(PRTime t_usec)
static inline uint32_t PRTimeToSeconds(PRTime aTimeUsec)
{
PRTime usec_per_sec = PR_USEC_PER_SEC;
return uint32_t(t_usec /= usec_per_sec);
PRTime usecPerSec = PR_USEC_PER_SEC;
return uint32_t(aTimeUsec /= usecPerSec);
}
inline bool UseErrorPages()
@ -575,7 +578,7 @@ protected:
// Sets the current document's current state object to the given SHEntry's
// state object. The current state object is eventually given to the page
// in the PopState event.
nsresult SetDocCurrentStateObj(nsISHEntry *shEntry);
nsresult SetDocCurrentStateObj(nsISHEntry* aShEntry);
nsresult CheckLoadingPermissions();
@ -648,8 +651,8 @@ protected:
nsresult BeginRestoreChildren();
// Method to get our current position and size without flushing
void DoGetPositionAndSize(int32_t * x, int32_t * y, int32_t * cx,
int32_t * cy);
void DoGetPositionAndSize(int32_t* aX, int32_t* aY, int32_t* aWidth,
int32_t* aHeight);
// Call this when a URI load is handed to us (via OnLinkClick or
// InternalLoad). This makes sure that we're not inside unload, or that if
@ -662,8 +665,8 @@ protected:
nsIDOMStorageManager* TopSessionStorageManager();
// helpers for executing commands
nsresult GetControllerForCommand(const char *inCommand,
nsIController** outController);
nsresult GetControllerForCommand(const char* aCommand,
nsIController** aResult);
nsresult EnsureCommandHandler();
nsIChannel* GetCurrentDocChannel();
@ -678,9 +681,11 @@ protected:
bool DoAppRedirectIfNeeded(nsIURI* aURI,
nsIDocShellLoadInfo* aLoadInfo,
bool aFirstParty);
protected:
nsresult GetCurScrollPos(int32_t scrollOrientation, int32_t * curPos);
nsresult SetCurScrollPosEx(int32_t curHorizontalPos, int32_t curVerticalPos);
nsresult GetCurScrollPos(int32_t aScrollOrientation, int32_t* aCurPos);
nsresult SetCurScrollPosEx(int32_t aCurHorizontalPos,
int32_t aCurVerticalPos);
// Override the parent setter from nsDocLoader
virtual nsresult SetDocLoaderParent(nsDocLoader* aLoader) MOZ_OVERRIDE;
@ -695,22 +700,24 @@ protected:
public:
// Event type dispatched by RestorePresentation
class RestorePresentationEvent : public nsRunnable {
class RestorePresentationEvent : public nsRunnable
{
public:
NS_DECL_NSIRUNNABLE
explicit RestorePresentationEvent(nsDocShell *ds) : mDocShell(ds) {}
explicit RestorePresentationEvent(nsDocShell* aDs) : mDocShell(aDs) {}
void Revoke() { mDocShell = nullptr; }
private:
nsRefPtr<nsDocShell> mDocShell;
};
protected:
protected:
bool JustStartedNetworkLoad();
nsresult CreatePrincipalFromReferrer(nsIURI* aReferrer,
nsIPrincipal** outPrincipal);
nsIPrincipal** aResult);
enum FrameType {
enum FrameType
{
eFrameTypeRegular,
eFrameTypeBrowser,
eFrameTypeApp
@ -852,7 +859,8 @@ protected:
// parent across the content boundary has allowfullscreen=true in all its
// containing iframes. mFullscreenAllowed defaults to CHECK_ATTRIBUTES and
// is set otherwise when docshells which are content boundaries are created.
enum FullscreenAllowedState {
enum FullscreenAllowedState
{
CHECK_ATTRIBUTES,
PARENT_ALLOWS,
PARENT_PROHIBITS
@ -953,6 +961,7 @@ protected:
nsString mPaymentRequestId;
nsString GetInheritedPaymentRequestId();
private:
nsCString mForcedCharset;
nsCString mParentCharset;
@ -981,10 +990,11 @@ private:
nsresult DoFindItemWithName(const char16_t* aName,
nsISupports* aRequestor,
nsIDocShellTreeItem* aOriginalRequestor,
nsIDocShellTreeItem** _retval);
nsIDocShellTreeItem** aResult);
// Notify consumers of a search being loaded through the observer service:
void MaybeNotifyKeywordSearchLoading(const nsString &aProvider, const nsString &aKeyword);
void MaybeNotifyKeywordSearchLoading(const nsString& aProvider,
const nsString& aKeyword);
#ifdef DEBUG
// We're counting the number of |nsDocShells| to help find leaks
@ -992,9 +1002,10 @@ private:
#endif /* DEBUG */
public:
class InterfaceRequestorProxy : public nsIInterfaceRequestor {
class InterfaceRequestorProxy : public nsIInterfaceRequestor
{
public:
explicit InterfaceRequestorProxy(nsIInterfaceRequestor* p);
explicit InterfaceRequestorProxy(nsIInterfaceRequestor* aRequestor);
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIINTERFACEREQUESTOR

View File

@ -1,10 +1,9 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "nsDocShellEditorData.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsComponentManagerUtils.h"
@ -14,14 +13,8 @@
#include "nsIEditingSession.h"
#include "nsIDocShell.h"
/*---------------------------------------------------------------------------
nsDocShellEditorData
----------------------------------------------------------------------------*/
nsDocShellEditorData::nsDocShellEditorData(nsIDocShell* inOwningDocShell)
: mDocShell(inOwningDocShell)
nsDocShellEditorData::nsDocShellEditorData(nsIDocShell* aOwningDocShell)
: mDocShell(aOwningDocShell)
, mMakeEditable(false)
, mIsDetached(false)
, mDetachedMakeEditable(false)
@ -30,12 +23,6 @@ nsDocShellEditorData::nsDocShellEditorData(nsIDocShell* inOwningDocShell)
NS_ASSERTION(mDocShell, "Where is my docShell?");
}
/*---------------------------------------------------------------------------
~nsDocShellEditorData
----------------------------------------------------------------------------*/
nsDocShellEditorData::~nsDocShellEditorData()
{
TearDownEditor();
@ -52,133 +39,94 @@ nsDocShellEditorData::TearDownEditor()
mIsDetached = false;
}
/*---------------------------------------------------------------------------
MakeEditable
----------------------------------------------------------------------------*/
nsresult
nsDocShellEditorData::MakeEditable(bool inWaitForUriLoad)
nsDocShellEditorData::MakeEditable(bool aInWaitForUriLoad)
{
if (mMakeEditable)
if (mMakeEditable) {
return NS_OK;
}
// if we are already editable, and are getting turned off,
// nuke the editor.
if (mEditor)
{
if (mEditor) {
NS_WARNING("Destroying existing editor on frame");
mEditor->PreDestroy(false);
mEditor = nullptr;
}
if (inWaitForUriLoad)
if (aInWaitForUriLoad) {
mMakeEditable = true;
}
return NS_OK;
}
/*---------------------------------------------------------------------------
GetEditable
----------------------------------------------------------------------------*/
bool
nsDocShellEditorData::GetEditable()
{
return mMakeEditable || (mEditor != nullptr);
}
/*---------------------------------------------------------------------------
CreateEditor
----------------------------------------------------------------------------*/
nsresult
nsDocShellEditorData::CreateEditor()
{
nsCOMPtr<nsIEditingSession> editingSession;
nsresult rv = GetEditingSession(getter_AddRefs(editingSession));
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIDOMWindow> domWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
rv = editingSession->SetupEditorOnWindow(domWindow);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv)) {
return rv;
}
return NS_OK;
}
/*---------------------------------------------------------------------------
GetEditingSession
----------------------------------------------------------------------------*/
nsresult
nsDocShellEditorData::GetEditingSession(nsIEditingSession **outEditingSession)
nsDocShellEditorData::GetEditingSession(nsIEditingSession** aResult)
{
nsresult rv = EnsureEditingSession();
NS_ENSURE_SUCCESS(rv, rv);
NS_ADDREF(*outEditingSession = mEditingSession);
NS_ADDREF(*aResult = mEditingSession);
return NS_OK;
}
/*---------------------------------------------------------------------------
GetEditor
----------------------------------------------------------------------------*/
nsresult
nsDocShellEditorData::GetEditor(nsIEditor **outEditor)
nsDocShellEditorData::GetEditor(nsIEditor** aResult)
{
NS_ENSURE_ARG_POINTER(outEditor);
NS_IF_ADDREF(*outEditor = mEditor);
NS_ENSURE_ARG_POINTER(aResult);
NS_IF_ADDREF(*aResult = mEditor);
return NS_OK;
}
/*---------------------------------------------------------------------------
SetEditor
----------------------------------------------------------------------------*/
nsresult
nsDocShellEditorData::SetEditor(nsIEditor *inEditor)
nsDocShellEditorData::SetEditor(nsIEditor* aEditor)
{
// destroy any editor that we have. Checks for equality are
// necessary to ensure that assigment into the nsCOMPtr does
// not temporarily reduce the refCount of the editor to zero
if (mEditor.get() != inEditor)
{
if (mEditor)
{
if (mEditor.get() != aEditor) {
if (mEditor) {
mEditor->PreDestroy(false);
mEditor = nullptr;
}
mEditor = inEditor; // owning addref
if (!mEditor)
mEditor = aEditor; // owning addref
if (!mEditor) {
mMakeEditable = false;
}
}
return NS_OK;
}
/*---------------------------------------------------------------------------
EnsureEditingSession
This creates the editing session on the content docShell that owns
'this'.
----------------------------------------------------------------------------*/
// This creates the editing session on the content docShell that owns 'this'.
nsresult
nsDocShellEditorData::EnsureEditingSession()
{
@ -187,8 +135,7 @@ nsDocShellEditorData::EnsureEditingSession()
nsresult rv = NS_OK;
if (!mEditingSession)
{
if (!mEditingSession) {
mEditingSession =
do_CreateInstance("@mozilla.org/editor/editingsession;1", &rv);
}
@ -214,8 +161,9 @@ nsDocShellEditorData::DetachFromWindow()
nsCOMPtr<nsIDOMDocument> domDoc;
domWindow->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
if (htmlDoc)
if (htmlDoc) {
mDetachedEditingState = htmlDoc->GetEditingState();
}
mDocShell = nullptr;
@ -238,8 +186,9 @@ nsDocShellEditorData::ReattachToWindow(nsIDocShell* aDocShell)
nsCOMPtr<nsIDOMDocument> domDoc;
domWindow->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
if (htmlDoc)
if (htmlDoc) {
htmlDoc->SetEditingState(mDetachedEditingState);
}
return NS_OK;
}

View File

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef nsDocShellEditorData_h__
@ -19,23 +19,21 @@ class nsIEditor;
class nsDocShellEditorData
{
public:
explicit nsDocShellEditorData(nsIDocShell* inOwningDocShell);
explicit nsDocShellEditorData(nsIDocShell* aOwningDocShell);
~nsDocShellEditorData();
nsresult MakeEditable(bool inWaitForUriLoad);
nsresult MakeEditable(bool aWaitForUriLoad);
bool GetEditable();
nsresult CreateEditor();
nsresult GetEditingSession(nsIEditingSession **outEditingSession);
nsresult GetEditor(nsIEditor **outEditor);
nsresult SetEditor(nsIEditor *inEditor);
nsresult GetEditingSession(nsIEditingSession** aResult);
nsresult GetEditor(nsIEditor** aResult);
nsresult SetEditor(nsIEditor* aEditor);
void TearDownEditor();
nsresult DetachFromWindow();
nsresult ReattachToWindow(nsIDocShell* aDocShell);
bool WaitingForLoad() const { return mMakeEditable; }
protected:
nsresult EnsureEditingSession();
// The doc shell that owns us. Weak ref, since it always outlives us.
@ -63,5 +61,4 @@ protected:
};
#endif // nsDocShellEditorData_h__

View File

@ -1,20 +1,19 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "nsDocShellEnumerator.h"
#include "nsIDocShellTreeItem.h"
nsDocShellEnumerator::nsDocShellEnumerator(int32_t inEnumerationDirection)
nsDocShellEnumerator::nsDocShellEnumerator(int32_t aEnumerationDirection)
: mRootItem(nullptr)
, mCurIndex(0)
, mDocShellType(nsIDocShellTreeItem::typeAll)
, mArrayValid(false)
, mEnumerationDirection(inEnumerationDirection)
, mEnumerationDirection(aEnumerationDirection)
{
}
@ -24,15 +23,17 @@ nsDocShellEnumerator::~nsDocShellEnumerator()
NS_IMPL_ISUPPORTS(nsDocShellEnumerator, nsISimpleEnumerator)
/* nsISupports getNext (); */
NS_IMETHODIMP nsDocShellEnumerator::GetNext(nsISupports **outCurItem)
NS_IMETHODIMP
nsDocShellEnumerator::GetNext(nsISupports** aResult)
{
NS_ENSURE_ARG_POINTER(outCurItem);
*outCurItem = nullptr;
NS_ENSURE_ARG_POINTER(aResult);
*aResult = nullptr;
nsresult rv = EnsureDocShellArray();
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv)) {
return rv;
}
if (mCurIndex >= mItemArray.Length()) {
return NS_ERROR_FAILURE;
@ -40,24 +41,29 @@ NS_IMETHODIMP nsDocShellEnumerator::GetNext(nsISupports **outCurItem)
// post-increment is important here
nsCOMPtr<nsISupports> item = do_QueryReferent(mItemArray[mCurIndex++], &rv);
item.forget(outCurItem);
item.forget(aResult);
return rv;
}
/* boolean hasMoreElements (); */
NS_IMETHODIMP nsDocShellEnumerator::HasMoreElements(bool *outHasMore)
NS_IMETHODIMP
nsDocShellEnumerator::HasMoreElements(bool* aResult)
{
NS_ENSURE_ARG_POINTER(outHasMore);
*outHasMore = false;
NS_ENSURE_ARG_POINTER(aResult);
*aResult = false;
nsresult rv = EnsureDocShellArray();
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv)) {
return rv;
}
*outHasMore = (mCurIndex < mItemArray.Length());
*aResult = (mCurIndex < mItemArray.Length());
return NS_OK;
}
nsresult nsDocShellEnumerator::GetEnumerationRootItem(nsIDocShellTreeItem * *aEnumerationRootItem)
nsresult
nsDocShellEnumerator::GetEnumerationRootItem(
nsIDocShellTreeItem** aEnumerationRootItem)
{
NS_ENSURE_ARG_POINTER(aEnumerationRootItem);
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
@ -65,37 +71,42 @@ nsresult nsDocShellEnumerator::GetEnumerationRootItem(nsIDocShellTreeItem * *aEn
return NS_OK;
}
nsresult nsDocShellEnumerator::SetEnumerationRootItem(nsIDocShellTreeItem * aEnumerationRootItem)
nsresult
nsDocShellEnumerator::SetEnumerationRootItem(
nsIDocShellTreeItem* aEnumerationRootItem)
{
mRootItem = do_GetWeakReference(aEnumerationRootItem);
ClearState();
return NS_OK;
}
nsresult nsDocShellEnumerator::GetEnumDocShellType(int32_t *aEnumerationItemType)
nsresult
nsDocShellEnumerator::GetEnumDocShellType(int32_t* aEnumerationItemType)
{
NS_ENSURE_ARG_POINTER(aEnumerationItemType);
*aEnumerationItemType = mDocShellType;
return NS_OK;
}
nsresult nsDocShellEnumerator::SetEnumDocShellType(int32_t aEnumerationItemType)
nsresult
nsDocShellEnumerator::SetEnumDocShellType(int32_t aEnumerationItemType)
{
mDocShellType = aEnumerationItemType;
ClearState();
return NS_OK;
}
nsresult nsDocShellEnumerator::First()
nsresult
nsDocShellEnumerator::First()
{
mCurIndex = 0;
return EnsureDocShellArray();
}
nsresult nsDocShellEnumerator::EnsureDocShellArray()
{
if (!mArrayValid)
nsresult
nsDocShellEnumerator::EnsureDocShellArray()
{
if (!mArrayValid) {
mArrayValid = true;
return BuildDocShellArray(mItemArray);
}
@ -103,7 +114,8 @@ nsresult nsDocShellEnumerator::EnsureDocShellArray()
return NS_OK;
}
nsresult nsDocShellEnumerator::ClearState()
nsresult
nsDocShellEnumerator::ClearState()
{
mItemArray.Clear();
mArrayValid = false;
@ -111,67 +123,85 @@ nsresult nsDocShellEnumerator::ClearState()
return NS_OK;
}
nsresult nsDocShellEnumerator::BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray)
nsresult
nsDocShellEnumerator::BuildDocShellArray(nsTArray<nsWeakPtr>& aItemArray)
{
NS_ENSURE_TRUE(mRootItem, NS_ERROR_NOT_INITIALIZED);
inItemArray.Clear();
aItemArray.Clear();
nsCOMPtr<nsIDocShellTreeItem> item = do_QueryReferent(mRootItem);
return BuildArrayRecursive(item, inItemArray);
return BuildArrayRecursive(item, aItemArray);
}
nsresult nsDocShellForwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray)
nsresult
nsDocShellForwardsEnumerator::BuildArrayRecursive(
nsIDocShellTreeItem* aItem,
nsTArray<nsWeakPtr>& aItemArray)
{
nsresult rv;
// add this item to the array
if (mDocShellType == nsIDocShellTreeItem::typeAll ||
inItem->ItemType() == mDocShellType) {
if (!inItemArray.AppendElement(do_GetWeakReference(inItem)))
aItem->ItemType() == mDocShellType) {
if (!aItemArray.AppendElement(do_GetWeakReference(aItem))) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
int32_t numChildren;
rv = inItem->GetChildCount(&numChildren);
if (NS_FAILED(rv)) return rv;
rv = aItem->GetChildCount(&numChildren);
if (NS_FAILED(rv)) {
return rv;
}
for (int32_t i = 0; i < numChildren; ++i)
{
for (int32_t i = 0; i < numChildren; ++i) {
nsCOMPtr<nsIDocShellTreeItem> curChild;
rv = inItem->GetChildAt(i, getter_AddRefs(curChild));
if (NS_FAILED(rv)) return rv;
rv = aItem->GetChildAt(i, getter_AddRefs(curChild));
if (NS_FAILED(rv)) {
return rv;
}
rv = BuildArrayRecursive(curChild, inItemArray);
if (NS_FAILED(rv)) return rv;
rv = BuildArrayRecursive(curChild, aItemArray);
if (NS_FAILED(rv)) {
return rv;
}
}
return NS_OK;
}
nsresult nsDocShellBackwardsEnumerator::BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray)
nsresult
nsDocShellBackwardsEnumerator::BuildArrayRecursive(
nsIDocShellTreeItem* aItem,
nsTArray<nsWeakPtr>& aItemArray)
{
nsresult rv;
int32_t numChildren;
rv = inItem->GetChildCount(&numChildren);
if (NS_FAILED(rv)) return rv;
rv = aItem->GetChildCount(&numChildren);
if (NS_FAILED(rv)) {
return rv;
}
for (int32_t i = numChildren - 1; i >= 0; --i)
{
for (int32_t i = numChildren - 1; i >= 0; --i) {
nsCOMPtr<nsIDocShellTreeItem> curChild;
rv = inItem->GetChildAt(i, getter_AddRefs(curChild));
if (NS_FAILED(rv)) return rv;
rv = aItem->GetChildAt(i, getter_AddRefs(curChild));
if (NS_FAILED(rv)) {
return rv;
}
rv = BuildArrayRecursive(curChild, inItemArray);
if (NS_FAILED(rv)) return rv;
rv = BuildArrayRecursive(curChild, aItemArray);
if (NS_FAILED(rv)) {
return rv;
}
}
// add this item to the array
if (mDocShellType == nsIDocShellTreeItem::typeAll ||
inItem->ItemType() == mDocShellType) {
if (!inItemArray.AppendElement(do_GetWeakReference(inItem)))
aItem->ItemType() == mDocShellType) {
if (!aItemArray.AppendElement(do_GetWeakReference(aItem))) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
return NS_OK;
}

View File

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -32,8 +32,8 @@ class nsIDocShellTreeItem;
class nsDocShellEnumerator : public nsISimpleEnumerator
{
protected:
enum {
enum
{
enumerateForwards,
enumerateBackwards
};
@ -41,8 +41,7 @@ protected:
virtual ~nsDocShellEnumerator();
public:
explicit nsDocShellEnumerator(int32_t inEnumerationDirection);
explicit nsDocShellEnumerator(int32_t aEnumerationDirection);
// nsISupports
NS_DECL_ISUPPORTS
@ -51,7 +50,6 @@ public:
NS_DECL_NSISIMPLEENUMERATOR
public:
nsresult GetEnumerationRootItem(nsIDocShellTreeItem** aEnumerationRootItem);
nsresult SetEnumerationRootItem(nsIDocShellTreeItem* aEnumerationRootItem);
@ -61,15 +59,14 @@ public:
nsresult First();
protected:
nsresult EnsureDocShellArray();
nsresult ClearState();
nsresult BuildDocShellArray(nsTArray<nsWeakPtr>& inItemArray);
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray) = 0;
nsresult BuildDocShellArray(nsTArray<nsWeakPtr>& aItemArray);
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
nsTArray<nsWeakPtr>& aItemArray) = 0;
protected:
nsWeakPtr mRootItem; // weak ref!
nsTArray<nsWeakPtr> mItemArray; // flattened list of items with matching type
@ -81,33 +78,31 @@ protected:
const int8_t mEnumerationDirection;
};
class nsDocShellForwardsEnumerator : public nsDocShellEnumerator
{
public:
nsDocShellForwardsEnumerator()
: nsDocShellEnumerator(enumerateForwards)
{
}
protected:
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray);
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
nsTArray<nsWeakPtr>& aItemArray);
};
class nsDocShellBackwardsEnumerator : public nsDocShellEnumerator
{
public:
nsDocShellBackwardsEnumerator()
: nsDocShellEnumerator(enumerateBackwards)
{
}
protected:
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* inItem, nsTArray<nsWeakPtr>& inItemArray);
protected:
virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
nsTArray<nsWeakPtr>& aItemArray);
};
#endif // nsDocShellEnumerator_h___

View File

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -17,12 +17,12 @@
//*****************************************************************************
nsDocShellLoadInfo::nsDocShellLoadInfo()
: mInheritOwner(false),
mOwnerIsExplicit(false),
mSendReferrer(true),
mReferrerPolicy(mozilla::net::RP_Default),
mLoadType(nsIDocShellLoadInfo::loadNormal),
mIsSrcdocLoad(false)
: mInheritOwner(false)
, mOwnerIsExplicit(false)
, mSendReferrer(true)
, mReferrerPolicy(mozilla::net::RP_Default)
, mLoadType(nsIDocShellLoadInfo::loadNormal)
, mIsSrcdocLoad(false)
{
}
@ -46,7 +46,8 @@ NS_INTERFACE_MAP_END
// nsDocShellLoadInfo::nsIDocShellLoadInfo
//*****************************************************************************
NS_IMETHODIMP nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
NS_IMETHODIMP
nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
{
NS_ENSURE_ARG_POINTER(aReferrer);
@ -55,13 +56,15 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetReferrer(nsIURI* aReferrer)
NS_IMETHODIMP
nsDocShellLoadInfo::SetReferrer(nsIURI* aReferrer)
{
mReferrer = aReferrer;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetOwner(nsISupports** aOwner)
NS_IMETHODIMP
nsDocShellLoadInfo::GetOwner(nsISupports** aOwner)
{
NS_ENSURE_ARG_POINTER(aOwner);
@ -70,13 +73,15 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetOwner(nsISupports** aOwner)
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetOwner(nsISupports* aOwner)
NS_IMETHODIMP
nsDocShellLoadInfo::SetOwner(nsISupports* aOwner)
{
mOwner = aOwner;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetInheritOwner(bool* aInheritOwner)
NS_IMETHODIMP
nsDocShellLoadInfo::GetInheritOwner(bool* aInheritOwner)
{
NS_ENSURE_ARG_POINTER(aInheritOwner);
@ -84,25 +89,29 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetInheritOwner(bool* aInheritOwner)
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetInheritOwner(bool aInheritOwner)
NS_IMETHODIMP
nsDocShellLoadInfo::SetInheritOwner(bool aInheritOwner)
{
mInheritOwner = aInheritOwner;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetOwnerIsExplicit(bool* aOwnerIsExplicit)
NS_IMETHODIMP
nsDocShellLoadInfo::GetOwnerIsExplicit(bool* aOwnerIsExplicit)
{
*aOwnerIsExplicit = mOwnerIsExplicit;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetOwnerIsExplicit(bool aOwnerIsExplicit)
NS_IMETHODIMP
nsDocShellLoadInfo::SetOwnerIsExplicit(bool aOwnerIsExplicit)
{
mOwnerIsExplicit = aOwnerIsExplicit;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType * aLoadType)
NS_IMETHODIMP
nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType* aLoadType)
{
NS_ENSURE_ARG_POINTER(aLoadType);
@ -110,13 +119,15 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetLoadType(nsDocShellInfoLoadType * aLoadType
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetLoadType(nsDocShellInfoLoadType aLoadType)
NS_IMETHODIMP
nsDocShellLoadInfo::SetLoadType(nsDocShellInfoLoadType aLoadType)
{
mLoadType = aLoadType;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetSHEntry(nsISHEntry** aSHEntry)
NS_IMETHODIMP
nsDocShellLoadInfo::GetSHEntry(nsISHEntry** aSHEntry)
{
NS_ENSURE_ARG_POINTER(aSHEntry);
@ -125,13 +136,15 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetSHEntry(nsISHEntry** aSHEntry)
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetSHEntry(nsISHEntry* aSHEntry)
NS_IMETHODIMP
nsDocShellLoadInfo::SetSHEntry(nsISHEntry* aSHEntry)
{
mSHEntry = aSHEntry;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetTarget(char16_t** aTarget)
NS_IMETHODIMP
nsDocShellLoadInfo::GetTarget(char16_t** aTarget)
{
NS_ENSURE_ARG_POINTER(aTarget);
@ -140,13 +153,13 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetTarget(char16_t** aTarget)
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetTarget(const char16_t* aTarget)
NS_IMETHODIMP
nsDocShellLoadInfo::SetTarget(const char16_t* aTarget)
{
mTarget.Assign(aTarget);
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetPostDataStream(nsIInputStream** aResult)
{
@ -158,7 +171,6 @@ nsDocShellLoadInfo::GetPostDataStream(nsIInputStream **aResult)
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::SetPostDataStream(nsIInputStream* aStream)
{
@ -167,20 +179,23 @@ nsDocShellLoadInfo::SetPostDataStream(nsIInputStream *aStream)
}
/* attribute nsIInputStream headersStream; */
NS_IMETHODIMP nsDocShellLoadInfo::GetHeadersStream(nsIInputStream * *aHeadersStream)
NS_IMETHODIMP
nsDocShellLoadInfo::GetHeadersStream(nsIInputStream** aHeadersStream)
{
NS_ENSURE_ARG_POINTER(aHeadersStream);
*aHeadersStream = mHeadersStream;
NS_IF_ADDREF(*aHeadersStream);
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetHeadersStream(nsIInputStream * aHeadersStream)
NS_IMETHODIMP
nsDocShellLoadInfo::SetHeadersStream(nsIInputStream* aHeadersStream)
{
mHeadersStream = aHeadersStream;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetSendReferrer(bool* aSendReferrer)
NS_IMETHODIMP
nsDocShellLoadInfo::GetSendReferrer(bool* aSendReferrer)
{
NS_ENSURE_ARG_POINTER(aSendReferrer);
@ -188,44 +203,53 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetSendReferrer(bool* aSendReferrer)
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetSendReferrer(bool aSendReferrer)
NS_IMETHODIMP
nsDocShellLoadInfo::SetSendReferrer(bool aSendReferrer)
{
mSendReferrer = aSendReferrer;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetReferrerPolicy(nsDocShellInfoReferrerPolicy* aReferrerPolicy)
NS_IMETHODIMP
nsDocShellLoadInfo::GetReferrerPolicy(
nsDocShellInfoReferrerPolicy* aReferrerPolicy)
{
*aReferrerPolicy = mReferrerPolicy;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetReferrerPolicy(nsDocShellInfoReferrerPolicy aReferrerPolicy)
NS_IMETHODIMP
nsDocShellLoadInfo::SetReferrerPolicy(
nsDocShellInfoReferrerPolicy aReferrerPolicy)
{
mReferrerPolicy = aReferrerPolicy;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetIsSrcdocLoad(bool* aIsSrcdocLoad)
NS_IMETHODIMP
nsDocShellLoadInfo::GetIsSrcdocLoad(bool* aIsSrcdocLoad)
{
*aIsSrcdocLoad = mIsSrcdocLoad;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetSrcdocData(nsAString &aSrcdocData)
NS_IMETHODIMP
nsDocShellLoadInfo::GetSrcdocData(nsAString& aSrcdocData)
{
aSrcdocData = mSrcdocData;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetSrcdocData(const nsAString &aSrcdocData)
NS_IMETHODIMP
nsDocShellLoadInfo::SetSrcdocData(const nsAString& aSrcdocData)
{
mSrcdocData = aSrcdocData;
mIsSrcdocLoad = true;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetSourceDocShell(nsIDocShell** aSourceDocShell)
NS_IMETHODIMP
nsDocShellLoadInfo::GetSourceDocShell(nsIDocShell** aSourceDocShell)
{
MOZ_ASSERT(aSourceDocShell);
nsCOMPtr<nsIDocShell> result = mSourceDocShell;
@ -233,13 +257,15 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetSourceDocShell(nsIDocShell** aSourceDocShel
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetSourceDocShell(nsIDocShell* aSourceDocShell)
NS_IMETHODIMP
nsDocShellLoadInfo::SetSourceDocShell(nsIDocShell* aSourceDocShell)
{
mSourceDocShell = aSourceDocShell;
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::GetBaseURI(nsIURI** aBaseURI)
NS_IMETHODIMP
nsDocShellLoadInfo::GetBaseURI(nsIURI** aBaseURI)
{
NS_ENSURE_ARG_POINTER(aBaseURI);
@ -248,16 +274,9 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetBaseURI(nsIURI** aBaseURI)
return NS_OK;
}
NS_IMETHODIMP nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI)
NS_IMETHODIMP
nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI)
{
mBaseURI = aBaseURI;
return NS_OK;
}
//*****************************************************************************
// nsDocShellLoadInfo: Helpers
//*****************************************************************************
//*****************************************************************************
// nsDocShellLoadInfo: Accessors
//*****************************************************************************

View File

@ -1,13 +1,12 @@
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef nsDocShellLoadInfo_h__
#define nsDocShellLoadInfo_h__
// Helper Classes
#include "nsCOMPtr.h"
#include "nsString.h"

View File

@ -1,7 +1,6 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=4 sw=4 et tw=80:
*
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -32,15 +31,14 @@
LOAD_FLAGS_ALLOW_POPUPS | \
0xffff0000)
/* load types are legal combinations of load commands and flags
*
* NOTE:
* Remember to update the IsValidLoadType function below if you change this
* enum to ensure bad flag combinations will be rejected.
*/
enum LoadType {
enum LoadType
{
LOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_NONE),
LOAD_NORMAL_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
LOAD_NORMAL_EXTERNAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL),
@ -71,10 +69,10 @@ enum LoadType {
// NOTE: Adding a new value? Remember to update IsValidLoadType!
};
static inline bool IsValidLoadType(uint32_t aLoadType)
{
switch (aLoadType)
static inline bool
IsValidLoadType(uint32_t aLoadType)
{
switch (aLoadType) {
case LOAD_NORMAL:
case LOAD_NORMAL_REPLACE:
case LOAD_NORMAL_EXTERNAL:

View File

@ -1,3 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -11,7 +13,6 @@ nsTransferableHookData::nsTransferableHookData()
{
}
nsTransferableHookData::~nsTransferableHookData()
{
}
@ -29,11 +30,11 @@ nsTransferableHookData::AddClipboardDragDropHooks(
NS_ENSURE_ARG(aOverrides);
// don't let a hook be added more than once
if (mHookList.IndexOfObject(aOverrides) == -1)
{
if (!mHookList.AppendObject(aOverrides))
if (mHookList.IndexOfObject(aOverrides) == -1) {
if (!mHookList.AppendObject(aOverrides)) {
return NS_ERROR_FAILURE;
}
}
return NS_OK;
}
@ -43,8 +44,9 @@ nsTransferableHookData::RemoveClipboardDragDropHooks(
nsIClipboardDragDropHooks* aOverrides)
{
NS_ENSURE_ARG(aOverrides);
if (!mHookList.RemoveObject(aOverrides))
if (!mHookList.RemoveObject(aOverrides)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}

View File

@ -1,3 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

View File

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=2 sts=2
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -29,8 +29,9 @@ nsDownloadHistory::AddDownload(nsIURI *aSource,
nsCOMPtr<nsIGlobalHistory2> history =
do_GetService("@mozilla.org/browser/global-history;2");
if (!history)
if (!history) {
return NS_ERROR_NOT_AVAILABLE;
}
bool visited;
nsresult rv = history->IsVisited(aSource, &visited);
@ -42,9 +43,10 @@ nsDownloadHistory::AddDownload(nsIURI *aSource,
if (!visited) {
nsCOMPtr<nsIObserverService> os =
do_GetService("@mozilla.org/observer-service;1");
if (os)
if (os) {
os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
}
}
return NS_OK;
}

View File

@ -1,6 +1,6 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=2 sts=2
* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -22,7 +23,8 @@ class nsString;
/**
* Interface used for handling clicks on links
*/
class nsILinkHandler : public nsISupports {
class nsILinkHandler : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILINKHANDLER_IID)

View File

@ -1,7 +1,8 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
* 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/. */
#ifndef nsIScrollObserver_h___
#define nsIScrollObserver_h___
@ -27,13 +28,13 @@ public:
* Called when an async panning/zooming transform has started being applied
* and passed the scroll offset
*/
virtual void AsyncPanZoomStarted(const mozilla::CSSIntPoint scrollPos){};
virtual void AsyncPanZoomStarted(const mozilla::CSSIntPoint aScrollPos) {};
/**
* Called when an async panning/zooming transform is no longer applied
* and passed the scroll offset
*/
virtual void AsyncPanZoomStopped(const mozilla::CSSIntPoint scrollPos){};
virtual void AsyncPanZoomStopped(const mozilla::CSSIntPoint aScrollPos) {};
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollObserver, NS_ISCROLLOBSERVER_IID)

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -16,7 +17,8 @@
//----------------------------------------------------------------------
class nsIWebShellServices : public nsISupports {
class nsIWebShellServices : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWEB_SHELL_SERVICES_IID)
@ -29,7 +31,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIWebShellServices, NS_IWEB_SHELL_SERVICES_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIWEBSHELLSERVICES \
NS_IMETHOD ReloadDocument(const char *aCharset=nullptr, int32_t aSource=kCharsetUninitialized) MOZ_OVERRIDE; \
NS_IMETHOD StopDocumentLoad(void) MOZ_OVERRIDE; \
NS_IMETHOD ReloadDocument(const char* aCharset = nullptr, \
int32_t aSource = kCharsetUninitialized) MOZ_OVERRIDE; \
NS_IMETHOD StopDocumentLoad(void) MOZ_OVERRIDE;
#endif /* nsIWebShellServices_h___ */

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
@ -55,7 +56,8 @@ nsWebNavigationInfo::IsTypeSupported(const nsACString& aType,
// there's no need to try and find a plugin to handle it.
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aWebNav));
bool allowed;
if (docShell && NS_SUCCEEDED(docShell->GetAllowPlugins(&allowed)) && !allowed) {
if (docShell &&
NS_SUCCEEDED(docShell->GetAllowPlugins(&allowed)) && !allowed) {
return NS_OK;
}
@ -84,7 +86,6 @@ nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
{
NS_PRECONDITION(aIsSupported, "Null out param?");
nsContentUtils::ContentViewerType vtype = nsContentUtils::TYPE_UNSUPPORTED;
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory =
@ -109,8 +110,7 @@ nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
// contractid.
if (imgLoader::SupportImageWithMimeType(aType.get())) {
*aIsSupported = nsIWebNavigationInfo::IMAGE;
}
else {
} else {
*aIsSupported = nsIWebNavigationInfo::OTHER;
}
break;

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */

View File

@ -692,6 +692,7 @@ DOMException::Constructor(GlobalObject& /* unused */,
if (name.EqualsASCII(sDOMErrorMsgMap[idx].mName)) {
exceptionResult = sDOMErrorMsgMap[idx].mNSResult;
exceptionCode = sDOMErrorMsgMap[idx].mCode;
break;
}
}
}
@ -739,11 +740,10 @@ DOMException::Sanitize(JSContext* aCx,
// Now it's possible that the stack on retval still starts with
// stuff aCx is not supposed to touch; it depends on what's on the
// stack right this second. Walk past all of that.
while (retval->mLocation && !retval->mLocation->CallerSubsumes(aCx)) {
nsCOMPtr<nsIStackFrame> caller;
retval->mLocation->GetCaller(getter_AddRefs(caller));
retval->mLocation.swap(caller);
}
nsCOMPtr<nsIStackFrame> stack;
nsresult rv = retval->mLocation->GetSanitized(aCx, getter_AddRefs(stack));
NS_ENSURE_SUCCESS(rv, false);
retval->mLocation.swap(stack);
}
return ToJSValue(aCx, retval, aSanitizedValue);

View File

@ -2609,6 +2609,10 @@ Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem,
}
if (!Preferences::GetBool("media.eme.enabled", false)) {
// EME disabled by user, send notification to chrome so UI can
// inform user.
MediaKeySystemAccess::NotifyObservers(aKeySystem,
MediaKeySystemStatus::Api_disabled);
p->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return p.forget();
}
@ -2619,7 +2623,14 @@ Navigator::RequestMediaKeySystemAccess(const nsAString& aKeySystem,
return p.forget();
}
if (!MediaKeySystemAccess::IsKeySystemSupported(aKeySystem)) {
MediaKeySystemStatus status = MediaKeySystemAccess::GetKeySystemStatus(aKeySystem);
if (status != MediaKeySystemStatus::Available) {
if (status != MediaKeySystemStatus::Error) {
// Failed due to user disabling something, send a notification to
// chrome, so we can show some UI to explain how the user can rectify
// the situation.
MediaKeySystemAccess::NotifyObservers(aKeySystem, status);
}
p->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return p.forget();
}

View File

@ -2930,9 +2930,22 @@ nsContentUtils::IsInPrivateBrowsing(nsIDocument* aDoc)
return isPrivate;
}
bool
nsContentUtils::DocumentInactiveForImageLoads(nsIDocument* aDocument)
{
if (aDocument && !IsChromeDoc(aDocument) && !aDocument->IsResourceDoc()) {
nsCOMPtr<nsPIDOMWindow> win =
do_QueryInterface(aDocument->GetScopeObject());
return !win || !win->GetDocShell();
}
return false;
}
imgLoader*
nsContentUtils::GetImgLoaderForDocument(nsIDocument* aDoc)
{
NS_ENSURE_TRUE(!DocumentInactiveForImageLoads(aDoc), nullptr);
if (!aDoc) {
return imgLoader::Singleton();
}
@ -2942,8 +2955,11 @@ nsContentUtils::GetImgLoaderForDocument(nsIDocument* aDoc)
// static
imgLoader*
nsContentUtils::GetImgLoaderForChannel(nsIChannel* aChannel)
nsContentUtils::GetImgLoaderForChannel(nsIChannel* aChannel,
nsIDocument* aContext)
{
NS_ENSURE_TRUE(!DocumentInactiveForImageLoads(aContext), nullptr);
if (!aChannel)
return imgLoader::Singleton();
nsCOMPtr<nsILoadContext> context;
@ -2983,7 +2999,7 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
imgLoader* imgLoader = GetImgLoaderForDocument(aLoadingDocument);
if (!imgLoader) {
// nothing we can do here
return NS_OK;
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsILoadGroup> loadGroup = aLoadingDocument->GetDocumentLoadGroup();

View File

@ -613,6 +613,11 @@ public:
int16_t* aImageBlockingStatus = nullptr,
uint32_t aContentPolicyType = nsIContentPolicy::TYPE_IMAGE);
/**
* Returns true if objects in aDocument shouldn't initiate image loads.
*/
static bool DocumentInactiveForImageLoads(nsIDocument* aDocument);
/**
* Method to start an image load. This does not do any security checks.
* This method will attempt to make aURI immutable; a caller that wants to
@ -646,7 +651,8 @@ public:
* Null document/channel arguments return the public image loader.
*/
static imgLoader* GetImgLoaderForDocument(nsIDocument* aDoc);
static imgLoader* GetImgLoaderForChannel(nsIChannel* aChannel);
static imgLoader* GetImgLoaderForChannel(nsIChannel* aChannel,
nsIDocument* aContext);
/**
* Returns whether the given URI is in the image cache.

View File

@ -894,31 +894,6 @@ nsDOMClassInfo::PreCreate(nsISupports *nativeObj, JSContext *cx,
return NS_OK;
}
NS_IMETHODIMP
nsDOMClassInfo::Create(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, JSObject *obj)
{
NS_WARNING("nsDOMClassInfo::Create Don't call me!");
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
nsDOMClassInfo::PostCreate(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, JSObject *obj)
{
NS_WARNING("nsDOMClassInfo::PostCreate Don't call me!");
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
nsDOMClassInfo::PostTransplant(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, JSObject *obj)
{
MOZ_CRASH("nsDOMClassInfo::PostTransplant Don't call me!");
}
NS_IMETHODIMP
nsDOMClassInfo::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp,
@ -929,15 +904,6 @@ nsDOMClassInfo::AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
nsDOMClassInfo::DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, bool *_retval)
{
NS_WARNING("nsDOMClassInfo::DelProperty Don't call me!");
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
nsDOMClassInfo::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsid id, jsval *vp,
@ -1011,16 +977,6 @@ nsDOMClassInfo::Resolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
NS_IMETHODIMP
nsDOMClassInfo::Convert(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, uint32_t type, jsval *vp,
bool *_retval)
{
NS_WARNING("nsDOMClassInfo::Convert Don't call me!");
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP
nsDOMClassInfo::Finalize(nsIXPConnectWrappedNative *wrapper, JSFreeOp *fop,
JSObject *obj)
@ -2035,7 +1991,8 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
if (aWin->GetDoc()) {
aWin->GetDoc()->WarnOnceAbout(nsIDocument::eWindow_Controllers);
}
JS::Rooted<JSObject*> shim(cx, JS_NewObject(cx, &ControllersShimClass, obj));
MOZ_ASSERT(JS_IsGlobalObject(obj));
JS::Rooted<JSObject*> shim(cx, JS_NewObject(cx, &ControllersShimClass));
if (NS_WARN_IF(!shim)) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -1322,7 +1322,7 @@ nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX,
if (!widget)
return NS_ERROR_FAILURE;
return widget->SynthesizeNativeMouseEvent(nsIntPoint(aScreenX, aScreenY),
return widget->SynthesizeNativeMouseEvent(LayoutDeviceIntPoint(aScreenX, aScreenY),
aNativeMessage, aModifierFlags);
}
@ -1345,7 +1345,7 @@ nsDOMWindowUtils::SendNativeMouseScrollEvent(int32_t aScreenX,
return NS_ERROR_FAILURE;
}
return widget->SynthesizeNativeMouseScrollEvent(nsIntPoint(aScreenX,
return widget->SynthesizeNativeMouseScrollEvent(LayoutDeviceIntPoint(aScreenX,
aScreenY),
aNativeMessage,
aDeltaX, aDeltaY, aDeltaZ,

View File

@ -95,7 +95,7 @@ nsImageLoadingContent::nsImageLoadingContent()
mFrameCreateCalled(false),
mVisibleCount(0)
{
if (!nsContentUtils::GetImgLoaderForChannel(nullptr)) {
if (!nsContentUtils::GetImgLoaderForChannel(nullptr, nullptr)) {
mLoadingEnabled = false;
}
}
@ -347,7 +347,7 @@ nsImageLoadingContent::GetLoadingEnabled(bool *aLoadingEnabled)
NS_IMETHODIMP
nsImageLoadingContent::SetLoadingEnabled(bool aLoadingEnabled)
{
if (nsContentUtils::GetImgLoaderForChannel(nullptr)) {
if (nsContentUtils::GetImgLoaderForChannel(nullptr, nullptr)) {
mLoadingEnabled = aLoadingEnabled;
}
return NS_OK;
@ -629,7 +629,9 @@ already_AddRefed<nsIStreamListener>
nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
ErrorResult& aError)
{
if (!nsContentUtils::GetImgLoaderForChannel(aChannel)) {
imgLoader* loader =
nsContentUtils::GetImgLoaderForChannel(aChannel, GetOurOwnerDoc());
if (!loader) {
aError.Throw(NS_ERROR_NULL_POINTER);
return nullptr;
}
@ -650,7 +652,7 @@ nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
// Do the load.
nsCOMPtr<nsIStreamListener> listener;
nsRefPtr<imgRequestProxy>& req = PrepareNextRequest(eImageLoadType_Normal);
nsresult rv = nsContentUtils::GetImgLoaderForChannel(aChannel)->
nsresult rv = loader->
LoadImageWithChannel(aChannel, this, doc,
getter_AddRefs(listener),
getter_AddRefs(req));
@ -1190,6 +1192,11 @@ nsImageLoadingContent::StringToURI(const nsAString& aSpec,
nsresult
nsImageLoadingContent::FireEvent(const nsAString& aEventType)
{
if (nsContentUtils::DocumentInactiveForImageLoads(GetOurOwnerDoc())) {
// Don't bother to fire any events, especially error events.
return NS_OK;
}
// We have to fire the event asynchronously so that we won't go into infinite
// loops in cases when onLoad handlers reset the src and the new src is in
// cache.

View File

@ -23,6 +23,7 @@
#endif
#include "nsBindingManager.h"
#include "nsGenericHTMLElement.h"
#include "mozilla/Assertions.h"
#include "mozilla/dom/HTMLImageElement.h"
#include "mozilla/dom/HTMLMediaElement.h"
#include "nsWrapperCacheInlines.h"
@ -466,17 +467,9 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
if (aReparentScope) {
JS::Rooted<JSObject*> wrapper(cx);
if ((wrapper = aNode->GetWrapper())) {
if (IsDOMObject(wrapper)) {
MOZ_ASSERT(IsDOMObject(wrapper));
JSAutoCompartment ac(cx, wrapper);
rv = ReparentWrapper(cx, wrapper);
} else {
nsIXPConnect *xpc = nsContentUtils::XPConnect();
if (xpc) {
rv = xpc->ReparentWrappedNativeIfFound(cx, wrapper, aReparentScope, aNode);
} else {
rv = NS_ERROR_FAILURE;
}
}
if (NS_FAILED(rv)) {
aNode->mNodeInfo.swap(nodeInfo);

View File

@ -775,3 +775,5 @@ skip-if = true # bug 1107443 - code for newly-added test was disabled
[test_performance_user_timing.html]
[test_bug1126851.html]
skip-if = buildapp == 'mulet' || buildapp == 'b2g'
[test_bug1118689.html]
skip-if = buildapp == 'mulet' || buildapp == 'b2g'

View File

@ -0,0 +1,57 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1118689
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1118689</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/** Test for Bug 1118689 **/
SimpleTest.requestFlakyTimeout("Just need some random timeout.");
function test1() {
// test 1, check that error handling in data documents is still the same
// as it has been for ages.
var d = document.implementation.createHTMLDocument();
d.body.innerHTML = "<img onerror='ok(false, \"EventHandler shouldn't be called in data document\")'>";
d.body.firstChild.addEventListener("error",
function() {
ok(true, "EventListener should be called in data document");
test2();
});
d.body.firstChild.addEventListener("load",
function() {
ok(false, "Images in data document shouldn't be loaded");
});
d.body.firstChild.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP";
}
function test2() {
// test 2, check that load event doesn't keep up being dispatched if
// window has been closed.
var win = window.open('data:text/html,<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP" onload="this.src = this.src">',
"", "height=100,width=100");
setTimeout(function() {
win.close();
SimpleTest.finish();
}, 2500);
}
SimpleTest.waitForExplicitFinish();
</script>
</head>
<body onload="test1();">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1118689">Mozilla Bug 1118689</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>

View File

@ -394,6 +394,7 @@ class CGDOMJSClass(CGThing):
{
nullptr, /* lookupProperty */
nullptr, /* defineProperty */
nullptr, /* hasProperty */
nullptr, /* getProperty */
nullptr, /* setProperty */
nullptr, /* getOwnPropertyDescriptor */
@ -2095,8 +2096,8 @@ def methodLength(method):
def isMaybeExposedIn(member, descriptor):
# All we can say for sure is that if this is a worker descriptor
# and member is only exposed in windows, then it's not exposed.
return not descriptor.workers or member.exposureSet != set(["Window"])
# and member is not exposed in any worker, then it's not exposed.
return not descriptor.workers or member.isExposedInAnyWorker()
def clearableCachedAttrs(descriptor):
return (m for m in descriptor.interface.members if

View File

@ -112,9 +112,8 @@ DOMProxyHandler::EnsureExpandoObject(JSContext* cx, JS::Handle<JSObject*> obj)
expandoAndGeneration = nullptr;
}
JS::Rooted<JSObject*> parent(cx, js::GetObjectParent(obj));
JS::Rooted<JSObject*> expando(cx,
JS_NewObjectWithGivenProto(cx, nullptr, JS::NullPtr(), parent));
JS_NewObjectWithGivenProto(cx, nullptr, JS::NullPtr()));
if (!expando) {
return nullptr;
}

View File

@ -6,6 +6,7 @@
#include "mozilla/dom/Exceptions.h"
#include "js/GCAPI.h"
#include "js/TypeDecls.h"
#include "jsapi.h"
#include "jsprf.h"
#include "mozilla/CycleCollectedJSRuntime.h"
@ -299,6 +300,8 @@ public:
NS_IMETHOD GetCaller(nsIStackFrame** aCaller) MOZ_OVERRIDE;
NS_IMETHOD GetFormattedStack(nsAString& aStack) MOZ_OVERRIDE;
virtual bool CallerSubsumes(JSContext* aCx) MOZ_OVERRIDE;
NS_IMETHOD GetSanitized(JSContext* aCx,
nsIStackFrame** aSanitized) MOZ_OVERRIDE;
protected:
virtual bool IsJSFrame() const MOZ_OVERRIDE {
@ -390,15 +393,22 @@ NS_IMETHODIMP JSStackFrame::GetFilename(nsAString& aFilename)
JS::Rooted<JSObject*> stack(cx, mStack);
JS::ExposeObjectToActiveJS(mStack);
JSAutoCompartment ac(cx, stack);
JS::Rooted<JS::Value> filenameVal(cx);
if (!JS_GetProperty(cx, stack, "source", &filenameVal) ||
!filenameVal.isString()) {
if (!JS_GetProperty(cx, stack, "source", &filenameVal)) {
return NS_ERROR_UNEXPECTED;
}
if (filenameVal.isNull()) {
filenameVal = JS_GetEmptyStringValue(cx);
}
MOZ_ASSERT(filenameVal.isString());
nsAutoJSString str;
if (!str.init(cx, filenameVal.toString())) {
return NS_ERROR_OUT_OF_MEMORY;
}
mFilename = str;
mFilenameInitialized = true;
}
@ -471,11 +481,15 @@ JSStackFrame::GetLineno(int32_t* aLineNo)
JS::ExposeObjectToActiveJS(mStack);
JSAutoCompartment ac(cx, stack);
JS::Rooted<JS::Value> lineVal(cx);
if (!JS_GetProperty(cx, stack, "line", &lineVal) ||
!lineVal.isNumber()) {
if (!JS_GetProperty(cx, stack, "line", &lineVal)) {
return NS_ERROR_UNEXPECTED;
}
if (lineVal.isNumber()) {
mLineno = lineVal.toNumber();
} else {
MOZ_ASSERT(lineVal.isNull());
mLineno = 0;
}
mLinenoInitialized = true;
}
@ -500,11 +514,15 @@ JSStackFrame::GetColNo(int32_t* aColNo)
JS::ExposeObjectToActiveJS(mStack);
JSAutoCompartment ac(cx, stack);
JS::Rooted<JS::Value> colVal(cx);
if (!JS_GetProperty(cx, stack, "column", &colVal) ||
!colVal.isNumber()) {
if (!JS_GetProperty(cx, stack, "column", &colVal)) {
return NS_ERROR_UNEXPECTED;
}
if (colVal.isNumber()) {
mColNo = colVal.toNumber();
} else {
MOZ_ASSERT(colVal.isNull());
mColNo = 0;
}
mColNoInitialized = true;
}
@ -524,6 +542,35 @@ NS_IMETHODIMP StackFrame::GetSourceLine(nsACString& aSourceLine)
return NS_OK;
}
/* [noscript] readonly attribute nsIStackFrame sanitized */
NS_IMETHODIMP StackFrame::GetSanitized(JSContext*, nsIStackFrame** aSanitized)
{
NS_ADDREF(*aSanitized = this);
return NS_OK;
}
/* [noscript] readonly attribute nsIStackFrame sanitized */
NS_IMETHODIMP JSStackFrame::GetSanitized(JSContext* aCx, nsIStackFrame** aSanitized)
{
// NB: Do _not_ enter the compartment of the SavedFrame object here, because
// we are checking against the caller's compartment's principals in
// GetFirstSubsumedSavedFrame.
JS::RootedObject savedFrame(aCx, mStack);
JS::ExposeObjectToActiveJS(mStack);
savedFrame = js::GetFirstSubsumedSavedFrame(aCx, savedFrame);
nsCOMPtr<nsIStackFrame> stackFrame;
if (savedFrame) {
stackFrame = new JSStackFrame(savedFrame);
} else {
stackFrame = new StackFrame();
}
stackFrame.forget(aSanitized);
return NS_OK;
}
/* readonly attribute nsIStackFrame caller; */
NS_IMETHODIMP JSStackFrame::GetCaller(nsIStackFrame** aCaller)
{

View File

@ -456,8 +456,12 @@ class IDLExposureMixins():
self._exposureGlobalNames = set()
self.exposureSet = set()
self._location = location
self._globalScope = None
def finish(self, scope):
assert scope.parentScope is None
self._globalScope = scope
# Verify that our [Exposed] value, if any, makes sense.
for globalName in self._exposureGlobalNames:
if globalName not in scope.globalNames:
@ -492,8 +496,8 @@ class IDLExposureMixins():
return len(workerScopes.difference(self.exposureSet)) > 0
def getWorkerExposureSet(self):
# Subclasses that might be exposed in workers should override as needed
return set()
workerScopes = self._globalScope.globalNameMapping["Worker"]
return workerScopes.intersection(self.exposureSet)
class IDLExternalInterface(IDLObjectWithIdentifier, IDLExposureMixins):
@ -801,9 +805,13 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
ctor = self.ctor()
if ctor is not None:
assert len(ctor._exposureGlobalNames) == 0
ctor._exposureGlobalNames.update(self._exposureGlobalNames)
ctor.finish(scope)
for ctor in self.namedConstructors:
assert len(ctor._exposureGlobalNames) == 0
ctor._exposureGlobalNames.update(self._exposureGlobalNames)
ctor.finish(scope)
# Make a copy of our member list, so things that implement us
@ -1110,10 +1118,6 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
len(set(m.identifier.name for m in self.members if
m.isMethod() and not m.isStatic())) == 1)
def getWorkerExposureSet(self):
workerScopes = self.parentScope.globalNameMapping["Worker"]
return workerScopes.intersection(self.exposureSet)
def inheritanceDepth(self):
depth = 0
parent = self.parent
@ -3056,7 +3060,7 @@ class IDLUndefinedValue(IDLObject):
def _getDependentObjects(self):
return set()
class IDLInterfaceMember(IDLObjectWithIdentifier):
class IDLInterfaceMember(IDLObjectWithIdentifier, IDLExposureMixins):
Tags = enum(
'Const',
@ -3074,13 +3078,9 @@ class IDLInterfaceMember(IDLObjectWithIdentifier):
def __init__(self, location, identifier, tag):
IDLObjectWithIdentifier.__init__(self, location, None, identifier)
IDLExposureMixins.__init__(self, location)
self.tag = tag
self._extendedAttrDict = {}
# _exposureGlobalNames are the global names listed in our [Exposed]
# extended attribute. exposureSet is the exposure set as defined in the
# Web IDL spec: it contains interface names.
self._exposureGlobalNames = set()
self.exposureSet = set()
def isMethod(self):
return self.tag == IDLInterfaceMember.Tags.Method
@ -3104,26 +3104,24 @@ class IDLInterfaceMember(IDLObjectWithIdentifier):
return self._extendedAttrDict.get(name, None)
def finish(self, scope):
for globalName in self._exposureGlobalNames:
if globalName not in scope.globalNames:
raise WebIDLError("Unknown [Exposed] value %s" % globalName,
[self.location])
globalNameSetToExposureSet(scope, self._exposureGlobalNames,
self.exposureSet)
self._scope = scope
# We better be exposed _somewhere_.
if (len(self._exposureGlobalNames) == 0):
print self.identifier.name
assert len(self._exposureGlobalNames) != 0
IDLExposureMixins.finish(self, scope)
def validate(self):
if (self.getExtendedAttribute("Pref") and
self.exposureSet != set([self._scope.primaryGlobalName])):
self.exposureSet != set([self._globalScope.primaryGlobalName])):
raise WebIDLError("[Pref] used on an interface member that is not "
"%s-only" % self._scope.primaryGlobalName,
"%s-only" % self._globalScope.primaryGlobalName,
[self.location])
if (self.getExtendedAttribute("CheckPermissions") and
self.exposureSet != set([self._scope.primaryGlobalName])):
self.exposureSet != set([self._globalScope.primaryGlobalName])):
raise WebIDLError("[CheckPermissions] used on an interface member "
"that is not %s-only" %
self._scope.primaryGlobalName,
self._globalScope.primaryGlobalName,
[self.location])
if self.isAttr() or self.isMethod():

View File

@ -113,7 +113,8 @@ BrowserElementChild.prototype = {
.addProgressListener(this._progressListener,
Ci.nsIWebProgress.NOTIFY_LOCATION |
Ci.nsIWebProgress.NOTIFY_SECURITY |
Ci.nsIWebProgress.NOTIFY_STATE_WINDOW);
Ci.nsIWebProgress.NOTIFY_STATE_WINDOW |
Ci.nsIWebProgress.NOTIFY_PROGRESS);
docShell.QueryInterface(Ci.nsIWebNavigation)
.sessionHistory = Cc["@mozilla.org/browser/shistory;1"]
@ -1371,8 +1372,12 @@ BrowserElementChild.prototype = {
},
onStatusChange: function(webProgress, request, status, message) {},
onProgressChange: function(webProgress, request, curSelfProgress,
maxSelfProgress, curTotalProgress, maxTotalProgress) {},
maxSelfProgress, curTotalProgress, maxTotalProgress) {
sendAsyncMsg('loadprogresschanged', { curTotalProgress: curTotalProgress,
maxTotalProgress: maxTotalProgress });
},
},
// Expose the message manager for WebApps and others.

View File

@ -181,6 +181,7 @@ BrowserElementParent.prototype = {
"hello": this._recvHello,
"loadstart": this._fireProfiledEventFromMsg,
"loadend": this._fireProfiledEventFromMsg,
"loadprogresschanged": this._fireEventFromMsg,
"close": this._fireEventFromMsg,
"error": this._fireEventFromMsg,
"firstpaint": this._fireProfiledEventFromMsg,

View File

@ -13,7 +13,8 @@ function runTest() {
// Load emptypage1 into the iframe, wait for that to finish loading, then
// call runTest2.
//
// This should trigger loadstart, locationchange, and loadend events.
// This should trigger loadstart, locationchange, loadprogresschanged and
// loadend events.
var seenLoadEnd = false;
var seenLoadStart = false;
@ -74,6 +75,7 @@ function runTest2() {
var seenLoadStart = false;
var seenLoadEnd = false;
var seenLocationChange = false;
var seenLoadProgressChanged = false;
// Add this event listener to the document; the events should bubble.
document.addEventListener('mozbrowserloadstart', function(e) {
@ -103,6 +105,14 @@ function runTest2() {
is(e.detail.backgroundColor, 'transparent', 'Expected background color reported')
});
iframe.addEventListener('mozbrowserloadprogresschanged', function(e) {
ok(e.isTrusted, 'Event should be trusted.');
seenLoadProgressChanged = true;
ok(seenLoadStart, 'Load end after load start.');
ok(seenLocationChange, 'Load end after location change.');
ok(!seenLoadEnd, 'Load end after load progress.');
});
iframe.src = browserElementTestHelpers.emptyPage2;
function waitForAllCallbacks() {

View File

@ -505,7 +505,7 @@ IsFeatureInBlacklist(const nsCOMPtr<nsIGfxInfo>& gfxInfo, int32_t feature)
static already_AddRefed<GLContext>
CreateHeadlessNativeGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
WebGLContext* webgl)
bool requireCompatProfile, WebGLContext* webgl)
{
if (!forceEnabled &&
IsFeatureInBlacklist(gfxInfo, nsIGfxInfo::FEATURE_WEBGL_OPENGL))
@ -515,7 +515,7 @@ CreateHeadlessNativeGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
return nullptr;
}
nsRefPtr<GLContext> gl = gl::GLContextProvider::CreateHeadless();
nsRefPtr<GLContext> gl = gl::GLContextProvider::CreateHeadless(requireCompatProfile);
if (!gl) {
webgl->GenerateWarning("Error during native OpenGL init.");
return nullptr;
@ -530,7 +530,7 @@ CreateHeadlessNativeGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
// Eventually, we want to be able to pick ANGLE-EGL or native EGL.
static already_AddRefed<GLContext>
CreateHeadlessANGLE(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
WebGLContext* webgl)
bool requireCompatProfile, WebGLContext* webgl)
{
nsRefPtr<GLContext> gl;
@ -543,7 +543,7 @@ CreateHeadlessANGLE(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
return nullptr;
}
gl = gl::GLContextProviderEGL::CreateHeadless();
gl = gl::GLContextProviderEGL::CreateHeadless(requireCompatProfile);
if (!gl) {
webgl->GenerateWarning("Error during ANGLE OpenGL init.");
return nullptr;
@ -555,13 +555,13 @@ CreateHeadlessANGLE(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
}
static already_AddRefed<GLContext>
CreateHeadlessEGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
CreateHeadlessEGL(bool forceEnabled, bool requireCompatProfile,
WebGLContext* webgl)
{
nsRefPtr<GLContext> gl;
#ifdef ANDROID
gl = gl::GLContextProviderEGL::CreateHeadless();
gl = gl::GLContextProviderEGL::CreateHeadless(requireCompatProfile);
if (!gl) {
webgl->GenerateWarning("Error during EGL OpenGL init.");
return nullptr;
@ -583,16 +583,22 @@ CreateHeadlessGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo>& gfxInfo,
if (PR_GetEnv("MOZ_WEBGL_FORCE_OPENGL"))
disableANGLE = true;
bool requireCompatProfile = webgl->IsWebGL2() ? false : true;
nsRefPtr<GLContext> gl;
if (preferEGL)
gl = CreateHeadlessEGL(forceEnabled, gfxInfo, webgl);
gl = CreateHeadlessEGL(forceEnabled, requireCompatProfile, webgl);
if (!gl && !disableANGLE)
gl = CreateHeadlessANGLE(forceEnabled, gfxInfo, webgl);
if (!gl && !disableANGLE) {
gl = CreateHeadlessANGLE(forceEnabled, gfxInfo, requireCompatProfile,
webgl);
}
if (!gl)
gl = CreateHeadlessNativeGL(forceEnabled, gfxInfo, webgl);
if (!gl) {
gl = CreateHeadlessNativeGL(forceEnabled, gfxInfo,
requireCompatProfile, webgl);
}
return gl.forget();
}

View File

@ -1209,9 +1209,10 @@ protected:
// -------------------------------------------------------------------------
// WebGL 2 specifics (implemented in WebGL2Context.cpp)
public:
virtual bool IsWebGL2() const = 0;
protected:
bool InitWebGL2();
// -------------------------------------------------------------------------

View File

@ -2106,7 +2106,6 @@ WebGLContext::ReadPixels(GLint x, GLint y, GLsizei width,
// if we're reading alpha, we may need to do fixup. Note that we don't allow
// GL_ALPHA to readpixels currently, but we had the code written for it already.
const bool formatHasAlpha = format == LOCAL_GL_ALPHA ||
format == LOCAL_GL_RGBA;
if (!formatHasAlpha)

View File

@ -1117,11 +1117,12 @@ WebGLContext::AssertCachedState()
AssertUintParamCorrect(gl, LOCAL_GL_STENCIL_CLEAR_VALUE, mStencilClearValue);
GLint stencilBits = 0;
gl->fGetIntegerv(LOCAL_GL_STENCIL_BITS, &stencilBits);
if (GetStencilBits(&stencilBits)) {
const GLuint stencilRefMask = (1 << stencilBits) - 1;
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_REF, stencilRefMask, mStencilRefFront);
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_BACK_REF, stencilRefMask, mStencilRefBack);
}
// GLES 3.0.4, $4.1.4, p177:
// [...] the front and back stencil mask are both set to the value `2^s - 1`, where

View File

@ -1779,8 +1779,8 @@ WebGLContext::InitAndValidateGL()
MakeContextCurrent();
// on desktop OpenGL, we always keep vertex attrib 0 array enabled
if (!gl->IsGLES())
// For OpenGL compat. profiles, we always keep vertex attrib 0 array enabled.
if (gl->IsCompatibilityProfile())
gl->fEnableVertexAttribArray(0);
if (MinCapabilityMode())
@ -1889,7 +1889,7 @@ WebGLContext::InitAndValidateGL()
// Always 1 for GLES2
mMaxFramebufferColorAttachments = 1;
if (!gl->IsGLES()) {
if (gl->IsCompatibilityProfile()) {
// gl_PointSize is always available in ES2 GLSL, but has to be
// specifically enabled on desktop GLSL.
gl->fEnable(LOCAL_GL_VERTEX_PROGRAM_POINT_SIZE);

View File

@ -4,9 +4,16 @@
# 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/.
TEST_DIRS += ['test']
TEST_DIRS += ['compiledtest']
MOCHITEST_MANIFESTS += [
'test/crossorigin/mochitest.ini',
'test/mochitest-subsuite-webgl.ini',
'test/mochitest.ini',
]
MOCHITEST_CHROME_MANIFESTS += ['test/chrome/chrome.ini']
EXPORTS += [
'nsICanvasRenderingContextInternal.h',
]

View File

@ -1,13 +0,0 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
MOCHITEST_MANIFESTS += [
'crossorigin/mochitest.ini',
'mochitest-subsuite-webgl.ini',
'mochitest.ini',
]
MOCHITEST_CHROME_MANIFESTS += ['chrome/chrome.ini']

View File

@ -1,9 +0,0 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
MOCHITEST_MANIFESTS += [
'_webgl_conformance.ini',
]

View File

@ -1,9 +0,0 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
MOCHITEST_MANIFESTS += [
'webgl_mochitest.ini',
]

View File

@ -877,7 +877,7 @@ Event::Shutdown()
}
}
nsIntPoint
LayoutDeviceIntPoint
Event::GetScreenCoords(nsPresContext* aPresContext,
WidgetEvent* aEvent,
LayoutDeviceIntPoint aPoint)
@ -894,18 +894,18 @@ Event::GetScreenCoords(nsPresContext* aPresContext,
aEvent->mClass != eTouchEventClass &&
aEvent->mClass != eDragEventClass &&
aEvent->mClass != eSimpleGestureEventClass)) {
return nsIntPoint(0, 0);
return LayoutDeviceIntPoint(0, 0);
}
WidgetGUIEvent* guiEvent = aEvent->AsGUIEvent();
if (!guiEvent->widget) {
return LayoutDeviceIntPoint::ToUntyped(aPoint);
return aPoint;
}
LayoutDeviceIntPoint offset = aPoint + guiEvent->widget->WidgetToScreenOffset();
nscoord factor =
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
return LayoutDeviceIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
}

View File

@ -146,7 +146,7 @@ public:
WidgetEvent* aEvent,
LayoutDeviceIntPoint aPoint,
CSSIntPoint aDefaultPoint);
static nsIntPoint GetScreenCoords(nsPresContext* aPresContext,
static LayoutDeviceIntPoint GetScreenCoords(nsPresContext* aPresContext,
WidgetEvent* aEvent,
LayoutDeviceIntPoint aPoint);

View File

@ -265,7 +265,7 @@ EventStateManager* EventStateManager::sActiveESM = nullptr;
nsIDocument* EventStateManager::sMouseOverDocument = nullptr;
nsWeakFrame EventStateManager::sLastDragOverFrame = nullptr;
LayoutDeviceIntPoint EventStateManager::sLastRefPoint = kInvalidRefPoint;
nsIntPoint EventStateManager::sLastScreenPoint = nsIntPoint(0, 0);
LayoutDeviceIntPoint EventStateManager::sLastScreenPoint = LayoutDeviceIntPoint(0, 0);
LayoutDeviceIntPoint EventStateManager::sSynthCenteringPoint = kInvalidRefPoint;
CSSIntPoint EventStateManager::sLastClientPoint = CSSIntPoint(0, 0);
bool EventStateManager::sIsPointerLocked = false;
@ -4031,8 +4031,7 @@ EventStateManager::GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent)
// in the other branch here.
sSynthCenteringPoint = center;
aMouseEvent->widget->SynthesizeNativeMouseMove(
LayoutDeviceIntPoint::ToUntyped(center +
aMouseEvent->widget->WidgetToScreenOffset()));
center + aMouseEvent->widget->WidgetToScreenOffset());
} else if (aMouseEvent->refPoint == sSynthCenteringPoint) {
// This is the "synthetic native" event we dispatched to re-center the
// pointer. Cancel it so we don't expose the centering move to content.
@ -4167,8 +4166,7 @@ EventStateManager::SetPointerLock(nsIWidget* aWidget,
sLastRefPoint = GetWindowInnerRectCenter(aElement->OwnerDoc()->GetWindow(),
aWidget,
mPresContext);
aWidget->SynthesizeNativeMouseMove(
LayoutDeviceIntPoint::ToUntyped(sLastRefPoint + aWidget->WidgetToScreenOffset()));
aWidget->SynthesizeNativeMouseMove(sLastRefPoint + aWidget->WidgetToScreenOffset());
// Retarget all events to this element via capture.
nsIPresShell::SetCapturingContent(aElement, CAPTURE_POINTERLOCK);
@ -4183,8 +4181,7 @@ EventStateManager::SetPointerLock(nsIWidget* aWidget,
// pre-pointerlock position, so that the synthetic mouse event reports
// no movement.
sLastRefPoint = mPreLockPoint;
aWidget->SynthesizeNativeMouseMove(
LayoutDeviceIntPoint::ToUntyped(mPreLockPoint + aWidget->WidgetToScreenOffset()));
aWidget->SynthesizeNativeMouseMove(mPreLockPoint + aWidget->WidgetToScreenOffset());
// Don't retarget events to this element any more.
nsIPresShell::SetCapturingContent(nullptr, CAPTURE_POINTERLOCK);

View File

@ -233,7 +233,7 @@ public:
// locked. This is used by dom::Event::GetScreenCoords() to make mouse
// events' screen coord appear frozen at the last mouse position while
// the pointer is locked.
static nsIntPoint sLastScreenPoint;
static LayoutDeviceIntPoint sLastScreenPoint;
// Holds the point in client coords of the last mouse event. Used by
// dom::Event::GetClientCoords() to make mouse events' client coords appear

View File

@ -31,7 +31,7 @@ Touch::Touch(EventTarget* aTarget,
mTarget = aTarget;
mIdentifier = aIdentifier;
mPagePoint = CSSIntPoint(aPageX, aPageY);
mScreenPoint = nsIntPoint(aScreenX, aScreenY);
mScreenPoint = LayoutDeviceIntPoint(aScreenX, aScreenY);
mClientPoint = CSSIntPoint(aClientX, aClientY);
mRefPoint = LayoutDeviceIntPoint(0, 0);
mPointsInitialized = true;
@ -53,7 +53,7 @@ Touch::Touch(int32_t aIdentifier,
{
mIdentifier = aIdentifier;
mPagePoint = CSSIntPoint(0, 0);
mScreenPoint = nsIntPoint(0, 0);
mScreenPoint = LayoutDeviceIntPoint(0, 0);
mClientPoint = CSSIntPoint(0, 0);
mRefPoint = aPoint;
mPointsInitialized = false;

View File

@ -79,7 +79,7 @@ public:
int32_t mIdentifier;
CSSIntPoint mPagePoint;
CSSIntPoint mClientPoint;
nsIntPoint mScreenPoint;
LayoutDeviceIntPoint mScreenPoint;
nsIntPoint mRadius;
float mRotationAngle;
float mForce;

View File

@ -358,11 +358,11 @@ UIEvent::DuplicatePrivateData()
mPagePoint =
Event::GetPageCoords(mPresContext, mEvent, mEvent->refPoint, mClientPoint);
// GetScreenPoint converts mEvent->refPoint to right coordinates.
nsIntPoint screenPoint =
LayoutDeviceIntPoint screenPoint =
Event::GetScreenCoords(mPresContext, mEvent, mEvent->refPoint);
nsresult rv = Event::DuplicatePrivateData();
if (NS_SUCCEEDED(rv)) {
mEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(screenPoint);
mEvent->refPoint = screenPoint;
}
return rv;
}

View File

@ -39,7 +39,7 @@ public:
NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) MOZ_OVERRIDE;
NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, void** aIter) MOZ_OVERRIDE;
static nsIntPoint CalculateScreenPoint(nsPresContext* aPresContext,
static LayoutDeviceIntPoint CalculateScreenPoint(nsPresContext* aPresContext,
WidgetEvent* aEvent)
{
if (!aEvent ||
@ -49,18 +49,18 @@ public:
aEvent->mClass != eDragEventClass &&
aEvent->mClass != ePointerEventClass &&
aEvent->mClass != eSimpleGestureEventClass)) {
return nsIntPoint(0, 0);
return LayoutDeviceIntPoint(0, 0);
}
WidgetGUIEvent* event = aEvent->AsGUIEvent();
if (!event->widget) {
return LayoutDeviceIntPoint::ToUntyped(aEvent->refPoint);
return aEvent->refPoint;
}
LayoutDeviceIntPoint offset = aEvent->refPoint + event->widget->WidgetToScreenOffset();
nscoord factor =
aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
return LayoutDeviceIntPoint(nsPresContext::AppUnitsToIntCSSPixels(offset.x * factor),
nsPresContext::AppUnitsToIntCSSPixels(offset.y * factor));
}

View File

@ -629,8 +629,8 @@ HTMLImageElement::UnbindFromTree(bool aDeep, bool aNullParent)
}
}
if (aNullParent &&
nsINode::GetParentNode()->Tag() == nsGkAtoms::picture &&
if (aNullParent && GetParent() &&
GetParent()->IsHTML(nsGkAtoms::picture) &&
HTMLPictureElement::IsPictureEnabled()) {
// Being removed from picture re-triggers selection, even if we
// weren't using a <source> peer

View File

@ -864,6 +864,7 @@ void HTMLMediaElement::SelectResource()
"Should think we're not loading from source children by default");
mLoadingSrc = uri;
UpdatePreloadAction();
if (mPreloadAction == HTMLMediaElement::PRELOAD_NONE) {
// preload:none media, suspend the load here before we make any
// network requests.
@ -1078,7 +1079,10 @@ void HTMLMediaElement::UpdatePreloadAction()
// Find the appropriate preload action by looking at the attribute.
const nsAttrValue* val = mAttrsAndChildren.GetAttr(nsGkAtoms::preload,
kNameSpaceID_None);
uint32_t preloadDefault =
// MSE doesn't work if preload is none, so it ignores the pref when src is
// from MSE.
uint32_t preloadDefault = (mLoadingSrc && IsMediaSourceURI(mLoadingSrc)) ?
HTMLMediaElement::PRELOAD_ATTR_METADATA :
Preferences::GetInt("media.preload.default",
HTMLMediaElement::PRELOAD_ATTR_METADATA);
uint32_t preloadAuto =

View File

@ -1664,12 +1664,6 @@ nsHTMLDocument::Open(JSContext* cx,
}
}
}
nsIXPConnect *xpc = nsContentUtils::XPConnect();
rv = xpc->RescueOrphansInScope(cx, oldScope->GetGlobalJSObject());
if (rv.Failed()) {
return nullptr;
}
}
}

View File

@ -517,7 +517,12 @@ child:
int32_t aModifiers,
bool aIgnoreRootScrollFrame);
RealMouseEvent(WidgetMouseEvent event);
/**
* When two consecutive mouse move events would be added to the message queue,
* they are 'compressed' by dumping the oldest one.
*/
RealMouseMoveEvent(WidgetMouseEvent event) compress;
RealMouseButtonEvent(WidgetMouseEvent event);
RealKeyEvent(WidgetKeyboardEvent event, MaybeNativeKeyBinding keyBinding);
MouseWheelEvent(WidgetWheelEvent event, ScrollableLayerGuid aGuid, uint64_t aInputBlockId);
RealTouchEvent(WidgetTouchEvent aEvent, ScrollableLayerGuid aGuid, uint64_t aInputBlockId);

View File

@ -2159,7 +2159,13 @@ TabChild::RecvMouseEvent(const nsString& aType,
}
bool
TabChild::RecvRealMouseEvent(const WidgetMouseEvent& event)
TabChild::RecvRealMouseMoveEvent(const WidgetMouseEvent& event)
{
return RecvRealMouseButtonEvent(event);
}
bool
TabChild::RecvRealMouseButtonEvent(const WidgetMouseEvent& event)
{
WidgetMouseEvent localEvent(event);
localEvent.widget = mWidget;

View File

@ -354,7 +354,8 @@ public:
const int32_t& aClickCount,
const int32_t& aModifiers,
const bool& aIgnoreRootScrollFrame) MOZ_OVERRIDE;
virtual bool RecvRealMouseEvent(const mozilla::WidgetMouseEvent& event) MOZ_OVERRIDE;
virtual bool RecvRealMouseMoveEvent(const mozilla::WidgetMouseEvent& event) MOZ_OVERRIDE;
virtual bool RecvRealMouseButtonEvent(const mozilla::WidgetMouseEvent& event) MOZ_OVERRIDE;
virtual bool RecvRealKeyEvent(const mozilla::WidgetKeyboardEvent& event,
const MaybeNativeKeyBinding& aBindings) MOZ_OVERRIDE;
virtual bool RecvMouseWheelEvent(const mozilla::WidgetWheelEvent& event,

View File

@ -929,7 +929,7 @@ TabParent::UpdateDimensions(const nsIntRect& rect, const nsIntSize& size)
mDimensions = size;
mOrientation = orientation;
nsIntPoint chromeOffset = -GetChildProcessOffset();
nsIntPoint chromeOffset = LayoutDevicePixel::ToUntyped(-GetChildProcessOffset());
unused << SendUpdateDimensions(mRect, mDimensions, mOrientation, chromeOffset);
}
}
@ -1219,7 +1219,10 @@ bool TabParent::SendRealMouseEvent(WidgetMouseEvent& event)
if (!MapEventCoordinatesForChildProcess(&event)) {
return false;
}
return PBrowserParent::SendRealMouseEvent(event);
if (event.message == NS_MOUSE_MOVE) {
return SendRealMouseMoveEvent(event);
}
return SendRealMouseButtonEvent(event);
}
CSSPoint TabParent::AdjustTapToChildWidget(const CSSPoint& aPoint)
@ -1824,13 +1827,13 @@ TabParent::RecvEnableDisableCommands(const nsString& aAction,
return true;
}
nsIntPoint
LayoutDeviceIntPoint
TabParent::GetChildProcessOffset()
{
// The "toplevel widget" in child processes is always at position
// 0,0. Map the event coordinates to match that.
nsIntPoint offset(0, 0);
LayoutDeviceIntPoint offset(0, 0);
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
if (!frameLoader) {
return offset;
@ -1849,8 +1852,8 @@ TabParent::GetChildProcessOffset()
LayoutDeviceIntPoint(0, 0),
targetFrame);
return LayoutDeviceIntPoint::ToUntyped(LayoutDeviceIntPoint::FromAppUnitsToNearest(
pt, targetFrame->PresContext()->AppUnitsPerDevPixel()));
return LayoutDeviceIntPoint::FromAppUnitsToNearest(
pt, targetFrame->PresContext()->AppUnitsPerDevPixel());
}
bool
@ -1987,8 +1990,7 @@ TabParent::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent)
aEvent.mReply.mRect.Union(mIMECompositionRects[i]);
}
aEvent.mReply.mOffset = aEvent.mInput.mOffset;
aEvent.mReply.mRect =
aEvent.mReply.mRect - LayoutDevicePixel::FromUntyped(GetChildProcessOffset());
aEvent.mReply.mRect = aEvent.mReply.mRect - GetChildProcessOffset();
aEvent.mReply.mWritingMode = mWritingMode;
aEvent.mSucceeded = true;
}
@ -2000,15 +2002,13 @@ TabParent::HandleQueryContentEvent(WidgetQueryContentEvent& aEvent)
}
aEvent.mReply.mOffset = mIMECaretOffset;
aEvent.mReply.mRect =
mIMECaretRect - LayoutDevicePixel::FromUntyped(GetChildProcessOffset());
aEvent.mReply.mRect = mIMECaretRect - GetChildProcessOffset();
aEvent.mSucceeded = true;
}
break;
case NS_QUERY_EDITOR_RECT:
{
aEvent.mReply.mRect =
mIMEEditorRect - LayoutDevicePixel::FromUntyped(GetChildProcessOffset());
aEvent.mReply.mRect = mIMEEditorRect - GetChildProcessOffset();
aEvent.mSucceeded = true;
}
break;

View File

@ -354,7 +354,7 @@ public:
return mTabId;
}
nsIntPoint GetChildProcessOffset();
LayoutDeviceIntPoint GetChildProcessOffset();
/**
* Native widget remoting protocol for use with windowed plugins with e10s.

View File

@ -86,6 +86,7 @@ MediaDecoderReader::MediaDecoderReader(AbstractMediaDecoder* aDecoder)
MediaDecoderReader::~MediaDecoderReader()
{
MOZ_ASSERT(mShutdown);
MOZ_ASSERT(!mDecoder);
ResetDecode();
MOZ_COUNT_DTOR(MediaDecoderReader);
}
@ -317,6 +318,8 @@ MediaDecoderReader::Shutdown()
p = ShutdownPromise::CreateAndResolve(true, __func__);
}
mDecoder = nullptr;
return p;
}

View File

@ -61,6 +61,8 @@ public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReader)
// The caller must ensure that Shutdown() is called before aDecoder is
// destroyed.
explicit MediaDecoderReader(AbstractMediaDecoder* aDecoder);
// Initializes the reader, returns NS_OK on success, or NS_ERROR_FAILURE
@ -251,10 +253,6 @@ public:
return mTaskQueue;
}
void ClearDecoder() {
mDecoder = nullptr;
}
// Returns true if the reader implements RequestAudioData()
// and RequestVideoData() asynchronously, rather than using the
// implementation in this class to adapt the old synchronous to

View File

@ -1419,7 +1419,7 @@ void MediaDecoderStateMachine::SetDuration(int64_t aDuration)
"Should be on main or decode thread.");
AssertCurrentThreadInMonitor();
if (aDuration == -1) {
if (aDuration < 0) {
mDurationSet = false;
return;
}
@ -2114,6 +2114,13 @@ bool MediaDecoderStateMachine::HasLowUndecodedData(int64_t aUsecs)
NS_ASSERTION(mState > DECODER_STATE_DECODING_FIRSTFRAME,
"Must have loaded first frame for GetBuffered() to work");
// If we don't have a duration, GetBuffered is probably not going to produce
// a useful buffered range. Return false here so that we don't get stuck in
// buffering mode for live streams.
if (GetDuration() < 0) {
return false;
}
nsRefPtr<dom::TimeRanges> buffered = new dom::TimeRanges();
nsresult rv = mReader->GetBuffered(buffered.get());
NS_ENSURE_SUCCESS(rv, false);

View File

@ -4,9 +4,10 @@
* 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 "nsPIDOMWindow.h"
#include "mozilla/dom/MediaKeyStatusMap.h"
#include "nsPIDOMWindow.h"
#include "mozilla/dom/UnionTypes.h"
#include "mozilla/dom/ToJSValue.h"
namespace mozilla {
namespace dom {

View File

@ -17,11 +17,12 @@
#include "mozilla/CDMCaps.h"
class nsPIDOMWindow;
class ArrayBufferViewOrArrayBuffer;
namespace mozilla {
namespace dom {
class ArrayBufferViewOrArrayBuffer;
class MediaKeyStatusMap MOZ_FINAL : public nsISupports,
public nsWrapperCache
{

View File

@ -18,6 +18,8 @@
#include "nsServiceManagerUtils.h"
#include "mozIGeckoMediaPluginService.h"
#include "VideoUtils.h"
#include "mozilla/Services.h"
#include "nsIObserverService.h"
namespace mozilla {
namespace dom {
@ -90,35 +92,48 @@ HaveGMPFor(mozIGeckoMediaPluginService* aGMPService,
}
/* static */
bool
MediaKeySystemAccess::IsKeySystemSupported(const nsAString& aKeySystem)
MediaKeySystemStatus
MediaKeySystemAccess::GetKeySystemStatus(const nsAString& aKeySystem)
{
MOZ_ASSERT(Preferences::GetBool("media.eme.enabled", false));
nsCOMPtr<mozIGeckoMediaPluginService> mps =
do_GetService("@mozilla.org/gecko-media-plugin-service;1");
if (NS_WARN_IF(!mps)) {
return false;
return MediaKeySystemStatus::Error;
}
if (aKeySystem.EqualsLiteral("org.w3.clearkey") &&
HaveGMPFor(mps,
if (aKeySystem.EqualsLiteral("org.w3.clearkey")) {
if (!Preferences::GetBool("media.eme.clearkey.enabled", true)) {
return MediaKeySystemStatus::Cdm_disabled;
}
if (!HaveGMPFor(mps,
NS_LITERAL_CSTRING("org.w3.clearkey"),
NS_LITERAL_CSTRING(GMP_API_DECRYPTOR))) {
return true;
return MediaKeySystemStatus::Cdm_not_installed;
}
return MediaKeySystemStatus::Available;
}
#ifdef XP_WIN
if ((aKeySystem.EqualsLiteral("com.adobe.access") ||
aKeySystem.EqualsLiteral("com.adobe.primetime")) &&
Preferences::GetBool("media.eme.adobe-access.enabled", false) &&
IsVistaOrLater() && // Win Vista and later only.
HaveGMPFor(mps,
aKeySystem.EqualsLiteral("com.adobe.primetime"))) {
// Win Vista and later only.
if (!IsVistaOrLater()) {
return MediaKeySystemStatus::Cdm_not_supported;
}
if (!Preferences::GetBool("media.eme.adobe-access.enabled", false)) {
return MediaKeySystemStatus::Cdm_disabled;
}
if (!HaveGMPFor(mps,
NS_ConvertUTF16toUTF8(aKeySystem),
NS_LITERAL_CSTRING(GMP_API_DECRYPTOR))) {
return true;
return MediaKeySystemStatus::Cdm_not_installed;
}
return MediaKeySystemStatus::Available;
}
#endif
return false;
return MediaKeySystemStatus::Cdm_not_supported;
}
static bool
@ -209,5 +224,21 @@ MediaKeySystemAccess::IsSupported(const nsAString& aKeySystem,
return false;
}
/* static */
void
MediaKeySystemAccess::NotifyObservers(const nsAString& aKeySystem,
MediaKeySystemStatus aStatus)
{
RequestMediaKeySystemAccessNotification data;
data.mKeySystem = aKeySystem;
data.mStatus = aStatus;
nsAutoString json;
data.ToJSON(json);
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (obs) {
obs->NotifyObservers(nullptr, "mediakeys-request", json.get());
}
}
} // namespace dom
} // namespace mozilla

View File

@ -14,6 +14,8 @@
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/MediaKeySystemAccessBinding.h"
#include "mozilla/dom/MediaKeysRequestStatusBinding.h"
#include "js/TypeDecls.h"
namespace mozilla {
@ -42,11 +44,14 @@ public:
already_AddRefed<Promise> CreateMediaKeys(ErrorResult& aRv);
static bool IsKeySystemSupported(const nsAString& aKeySystem);
static MediaKeySystemStatus GetKeySystemStatus(const nsAString& aKeySystem);
static bool IsSupported(const nsAString& aKeySystem,
const Sequence<MediaKeySystemOptions>& aOptions);
static void NotifyObservers(const nsAString& aKeySystem,
MediaKeySystemStatus aStatus);
private:
nsCOMPtr<nsPIDOMWindow> mParent;
const nsString mKeySystem;

View File

@ -27,6 +27,7 @@
#include "nsContentCID.h"
#include "nsServiceManagerUtils.h"
#include "mozIGeckoMediaPluginService.h"
#include "mozilla/dom/MediaKeySystemAccess.h"
namespace mozilla {
@ -365,6 +366,9 @@ MediaKeys::OnCDMCreated(PromiseId aId, const nsACString& aNodeId)
if (mCreatePromiseId == aId) {
Release();
}
MediaKeySystemAccess::NotifyObservers(mKeySystem,
MediaKeySystemStatus::Cdm_created);
}
already_AddRefed<MediaKeySession>

View File

@ -87,7 +87,9 @@ AVCCMediaDataDecoder::Init()
nsresult
AVCCMediaDataDecoder::Input(mp4_demuxer::MP4Sample* aSample)
{
mp4_demuxer::AnnexB::ConvertSampleToAVCC(aSample);
if (!mp4_demuxer::AnnexB::ConvertSampleToAVCC(aSample)) {
return NS_ERROR_FAILURE;
}
if (!mDecoder) {
// It is not possible to create an AVCC H264 decoder without SPS.
// As such, creation will fail if the extra_data just extracted doesn't

View File

@ -405,14 +405,12 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
if (mDemuxer->Crypto().valid) {
#ifdef MOZ_EME
if (!sIsEMEEnabled) {
// TODO: Need to signal DRM/EME required somehow...
return NS_ERROR_FAILURE;
}
// We have encrypted audio or video. We'll need a CDM to decrypt and
// possibly decode this. Wait until we've received a CDM from the
// JavaScript player app.
// JavaScript player app. Note: we still go through the motions here
// even if EME is disabled, so that if script tries and fails to create
// a CDM, we can detect that and notify chrome and show some UI explaining
// that we failed due to EME being disabled.
nsRefPtr<CDMProxy> proxy;
nsTArray<uint8_t> initData;
ExtractCryptoInitData(initData);

View File

@ -66,7 +66,10 @@ public:
}
virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) MOZ_OVERRIDE {
mp4_demuxer::AnnexB::ConvertSampleToAnnexB(aSample);
if (!mp4_demuxer::AnnexB::ConvertSampleToAnnexB(aSample)) {
return NS_ERROR_OUT_OF_MEMORY;
}
return MediaCodecDataDecoder::Input(aSample);
}
@ -179,7 +182,7 @@ protected:
return true;
}
mGLContext = GLContextProvider::CreateHeadless();
mGLContext = GLContextProvider::CreateHeadless(false);
return mGLContext;
}

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