Merge mozilla-central and mozilla-inbound

This commit is contained in:
Matt Brubeck 2012-03-23 16:06:54 -07:00
Родитель 184eabb030 7039a94106
Коммит 37f7c950f8
197 изменённых файлов: 4879 добавлений и 4005 удалений

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

@ -72,6 +72,11 @@ tier_base_dirs += \
other-licenses/skia-npapi \
$(NULL)
endif
ifeq (gonk,$(MOZ_WIDGET_TOOLKIT))
tier_base_dirs += \
other-licenses/android \
$(NULL)
endif
ifdef MOZ_MEMORY
tier_base_dirs += memory/jemalloc

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

@ -650,7 +650,7 @@ protected:
* Set accessible parent and index in parent.
*/
virtual void BindToParent(nsAccessible* aParent, PRUint32 aIndexInParent);
void UnbindFromParent();
virtual void UnbindFromParent();
/**
* Return sibling accessible at the given offset.

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

@ -248,6 +248,16 @@ nsLinkableAccessible::BindToParent(nsAccessible* aParent,
}
}
void
nsLinkableAccessible::UnbindFromParent()
{
mActionAcc = nsnull;
mIsLink = false;
mIsOnclick = false;
nsAccessibleWrap::UnbindFromParent();
}
////////////////////////////////////////////////////////////////////////////////
// nsEnumRoleAccessible
////////////////////////////////////////////////////////////////////////////////

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

@ -108,6 +108,7 @@ public:
protected:
// nsAccessible
virtual void BindToParent(nsAccessible* aParent, PRUint32 aIndexInParent);
virtual void UnbindFromParent();
/**
* Parent accessible that provides an action for this linkable accessible.

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

@ -216,53 +216,6 @@ nsHTMLAreaAccessible::Description(nsString& aDescription)
area->GetShape(aDescription);
}
NS_IMETHODIMP
nsHTMLAreaAccessible::GetBounds(PRInt32 *aX, PRInt32 *aY,
PRInt32 *aWidth, PRInt32 *aHeight)
{
NS_ENSURE_ARG_POINTER(aX);
*aX = 0;
NS_ENSURE_ARG_POINTER(aY);
*aY = 0;
NS_ENSURE_ARG_POINTER(aWidth);
*aWidth = 0;
NS_ENSURE_ARG_POINTER(aHeight);
*aHeight = 0;
if (IsDefunct())
return NS_ERROR_FAILURE;
// Essentially this uses GetRect on mAreas of nsImageMap from nsImageFrame.
nsPresContext *presContext = GetPresContext();
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
nsIFrame *frame = GetFrame();
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
nsImageFrame *imageFrame = do_QueryFrame(frame);
nsImageMap* map = imageFrame->GetImageMap();
NS_ENSURE_TRUE(map, NS_ERROR_FAILURE);
nsRect rect;
nsresult rv = map->GetBoundsForAreaContent(mContent, rect);
NS_ENSURE_SUCCESS(rv, rv);
*aX = presContext->AppUnitsToDevPixels(rect.x);
*aY = presContext->AppUnitsToDevPixels(rect.y);
// XXX Areas are screwy; they return their rects as a pair of points, one pair
// stored into the width and height.
*aWidth = presContext->AppUnitsToDevPixels(rect.width - rect.x);
*aHeight = presContext->AppUnitsToDevPixels(rect.height - rect.y);
// Put coords in absolute screen coords
nsIntRect orgRectPixels = frame->GetScreenRectExternal();
*aX += orgRectPixels.x;
*aY += orgRectPixels.y;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsHTMLAreaAccessible: nsAccessNode public
@ -326,3 +279,25 @@ nsHTMLAreaAccessible::CacheChildren()
{
// No children for aria accessible.
}
void
nsHTMLAreaAccessible::GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame)
{
nsIFrame* frame = GetFrame();
if (!frame)
return;
nsImageFrame* imageFrame = do_QueryFrame(frame);
nsImageMap* map = imageFrame->GetImageMap();
nsresult rv = map->GetBoundsForAreaContent(mContent, aBounds);
if (NS_FAILED(rv))
return;
// XXX Areas are screwy; they return their rects as a pair of points, one pair
// stored into the width and height.
aBounds.width -= aBounds.x;
aBounds.height -= aBounds.y;
*aBoundingFrame = frame;
}

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

@ -96,10 +96,6 @@ public:
nsHTMLAreaAccessible(nsIContent* aContent, nsDocAccessible* aDoc);
// nsIAccessible
NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
// nsAccessNode
virtual bool IsPrimaryForNode() const;
@ -118,6 +114,7 @@ protected:
// nsAccessible
virtual void CacheChildren();
virtual void GetBoundsRect(nsRect& aBounds, nsIFrame** aBoundingFrame);
};
#endif

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

@ -1224,7 +1224,7 @@ nsHyperTextAccessible::GetAttributesInternal(nsIPersistentProperties *aAttribute
}
if (FocusMgr()->IsFocused(this)) {
PRInt32 lineNumber = GetCaretLineNumber();
PRInt32 lineNumber = CaretLineNumber();
if (lineNumber >= 1) {
nsAutoString strLineNumber;
strLineNumber.AppendInt(lineNumber);
@ -1680,7 +1680,7 @@ nsHyperTextAccessible::GetCaretOffset(PRInt32 *aCaretOffset)
}
PRInt32
nsHyperTextAccessible::GetCaretLineNumber()
nsHyperTextAccessible::CaretLineNumber()
{
// Provide the line number for the caret, relative to the
// currently focused node. Use a 1-based index

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

@ -264,6 +264,22 @@ public:
return GetChildAt(GetChildIndexAtOffset(aOffset));
}
/**
* Return the bounds of the text between given start and end offset.
*/
nsIntRect GetTextBounds(PRInt32 aStartOffset, PRInt32 aEndOffset)
{
nsIntRect bounds;
GetPosAndText(aStartOffset, aEndOffset, nsnull, nsnull, &bounds);
return bounds;
}
/**
* Provide the line number for the caret.
* @return 1-based index for the line number with the caret
*/
PRInt32 CaretLineNumber();
//////////////////////////////////////////////////////////////////////////////
// EditableTextAccessible
@ -373,13 +389,6 @@ protected:
nsresult SetSelectionRange(PRInt32 aStartPos, PRInt32 aEndPos);
/**
* Provide the line number for the caret, relative to the
* current DOM node.
* @return 1-based index for the line number with the caret
*/
PRInt32 GetCaretLineNumber();
// Helpers
nsresult GetDOMPointByFrameOffset(nsIFrame *aFrame, PRInt32 aOffset,
nsIAccessible *aAccessible,

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

@ -44,6 +44,18 @@
@class mozRootAccessible;
/**
* All mozAccessibles are either abstract objects (that correspond to XUL
* widgets, HTML frames, etc) or are attached to a certain view; for example
* a document view. When we hand an object off to an AT, we always want
* to give it the represented view, in the latter case.
*/
inline id <mozAccessible>
GetObjectOrRepresentedView(id <mozAccessible> aObject)
{
return [aObject hasRepresentedView] ? [aObject representedView] : aObject;
}
@interface mozAccessible : NSObject <mozAccessible>
{
/**

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

@ -71,21 +71,6 @@ ConvertCocoaToGeckoPoint(NSPoint &aInPoint, nsPoint &aOutPoint)
aOutPoint.MoveTo ((nscoord)aInPoint.x, (nscoord)(mainScreenHeight - aInPoint.y));
}
// all mozAccessibles are either abstract objects (that correspond to XUL widgets, HTML frames, etc) or are
// attached to a certain view; for example a document view. when we hand an object off to an AT, we always want
// to give it the represented view, in the latter case.
static inline id <mozAccessible>
GetObjectOrRepresentedView(id <mozAccessible> anObject)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if ([anObject hasRepresentedView])
return [anObject representedView];
return anObject;
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
// returns the passed in object if it is not ignored. if it's ignored, will return
// the first unignored ancestor.
static inline id

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

@ -10,13 +10,3 @@
nsIAccessibleEditableText *mGeckoEditableTextAccessible; // strong
}
@end
/* A combobox (in the mac world) is a textfield with an associated menu, for example
the location bar. */
@interface mozComboboxAccessible : mozTextAccessible
// equivalent to pressing return key in this textfield.
- (void)confirm;
// shows the menu for this combobox.
- (void)showMenu;
@end

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

@ -1,3 +1,5 @@
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
#include "nsAccessibleWrap.h"
#include "nsCocoaUtils.h"
@ -243,107 +245,10 @@ using namespace mozilla::a11y;
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
NSAccessibilityPostNotification([self hasRepresentedView] ? [self representedView] : self,
NSAccessibilityPostNotification(GetObjectOrRepresentedView(self),
NSAccessibilityValueChangedNotification);
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@end
@implementation mozComboboxAccessible
- (NSArray*)accessibilityAttributeNames
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
static NSArray *supportedAttributes = nil;
if (!supportedAttributes) {
// standard attributes that are shared and supported by all generic elements.
supportedAttributes = [[NSArray alloc] initWithObjects:NSAccessibilityParentAttribute, // required
NSAccessibilityRoleAttribute, // required
NSAccessibilityTitleAttribute,
NSAccessibilityValueAttribute, // required
NSAccessibilityHelpAttribute,
NSAccessibilityRoleDescriptionAttribute,
NSAccessibilityPositionAttribute, // required
NSAccessibilitySizeAttribute, // required
NSAccessibilityWindowAttribute, // required
NSAccessibilityFocusedAttribute, // required
NSAccessibilityEnabledAttribute, // required
NSAccessibilityChildrenAttribute, // required
NSAccessibilityHelpAttribute,
// NSAccessibilityExpandedAttribute, // required
NSAccessibilityTopLevelUIElementAttribute, // required
NSAccessibilityDescriptionAttribute, // required
/* text-specific attributes */
NSAccessibilitySelectedTextAttribute, // required
NSAccessibilitySelectedTextRangeAttribute, // required
NSAccessibilityNumberOfCharactersAttribute, // required
// TODO: NSAccessibilityVisibleCharacterRangeAttribute, // required
// TODO: NSAccessibilityInsertionPointLineNumberAttribute
#if DEBUG
@"AXMozDescription",
#endif
nil];
}
return supportedAttributes;
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (NSArray *)accessibilityActionNames
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if ([self isEnabled]) {
return [NSArray arrayWithObjects:NSAccessibilityConfirmAction,
NSAccessibilityShowMenuAction,
nil];
}
return nil;
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (NSString *)accessibilityActionDescription:(NSString *)action
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if ([action isEqualToString:NSAccessibilityShowMenuAction])
return @"show menu";
if ([action isEqualToString:NSAccessibilityConfirmAction])
return @"confirm";
return [super accessibilityActionDescription:action];
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (void)accessibilityPerformAction:(NSString *)action
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
// both the ShowMenu and Click action do the same thing.
if ([self isEnabled]) {
if ([action isEqualToString:NSAccessibilityShowMenuAction])
[self showMenu];
if ([action isEqualToString:NSAccessibilityConfirmAction])
[self confirm];
}
NS_OBJC_END_TRY_ABORT_BLOCK;
}
- (void)showMenu
{
// currently unimplemented. waiting for support in bug 363697
}
- (void)confirm
{
// should be the same as pressing enter/return in this textfield.
// not yet implemented
}
@end

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

@ -110,9 +110,6 @@ nsAccessibleWrap::GetNativeType ()
case roles::CHECKBUTTON:
return [mozCheckboxAccessible class];
case roles::AUTOCOMPLETE:
return [mozComboboxAccessible class];
case roles::HEADING:
return [mozHeadingAccessible class];

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

@ -142,7 +142,7 @@ static const NSString* AXRoles [] = {
NSAccessibilityGroupRole, // ROLE_FOOTER
NSAccessibilityGroupRole, // ROLE_PARAGRAPH
@"AXRuler", // ROLE_RULER. 10.4+ only, so we re-define the constant.
NSAccessibilityComboBoxRole, // ROLE_AUTOCOMPLETE
NSAccessibilityUnknownRole, // ROLE_AUTOCOMPLETE
NSAccessibilityTextFieldRole, // ROLE_EDITBAR
NSAccessibilityTextFieldRole, // ROLE_ENTRY
NSAccessibilityStaticTextRole, // ROLE_CAPTION

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

@ -7,6 +7,8 @@
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="../common.js"></script>
@ -21,24 +23,42 @@
function doTest()
{
var tabDocument = currentTabDocument();
var p1 = tabDocument.body.firstElementChild;
var p2 = tabDocument.body.lastElementChild;
var p1 = tabDocument.getElementById("p1");
var p2 = tabDocument.getElementById("p2");
var imgMap = tabDocument.getElementById("imgmap");
ensureImageMapTree(imgMap);
var imgMapAcc = getAccessible(imgMap);
var area = imgMapAcc.firstChild;
testBounds(p1);
testBounds(p2);
testBounds(area);
zoomDocument(tabDocument, 2.0);
testBounds(p1);
testBounds(p2);
testBounds(area);
closeBrowserWindow();
SimpleTest.finish();
}
var url = "data:text/html,<html><body>";
url += "<p id='p1'>para 1</p><p id='p2'>para 2</p>";
url += "<map name='atoz_map' id='map'>";
url += " <area id='area1' href='http%3A%2F%2Fmozilla.org'";
url += " coords=17,0,30,14' alt='mozilla.org' shape='rect'>";
url += "</map>";
url += "<img id='imgmap' width='447' height='15'";
url += " usemap='%23atoz_map'";
url += " src='chrome%3A%2F%2Fmochitests%2Fcontent%2Fa11y%2Faccessible%2Fletters.gif'>";
url += "</body></html>";
SimpleTest.waitForExplicitFinish();
openBrowserWindow(doTest,
"data:text/html,<html><body><p>para 1</p><p>para 2</p></body></html>",
url,
{ left: 0, top: 0, width: 600, height: 600 });
</script>
</head>

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

@ -494,7 +494,9 @@ function ensureImageMapTree(aID)
// XXX: We send a useless mouse move to the image to force it to setup its
// image map, because flushing layout won't do it. Hopefully bug 135040
// will make this not suck.
synthesizeMouse(getNode(aID), 10, 10, { type: "mousemove" });
var image = getNode(aID);
synthesizeMouse(image, 10, 10, { type: "mousemove" },
image.ownerDocument.defaultView);
// XXX This may affect a11y more than other code because imagemaps may not
// get drawn or have an mouse event over them. Bug 570322 tracks a11y

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

@ -107,16 +107,42 @@ function getBounds(aID)
*/
function getBoundsForDOMElm(aID)
{
var x = 0, y = 0, width = 0, height = 0;
var elm = getNode(aID);
if (elm.localName == "area") {
var mapName = elm.parentNode.getAttribute("name");
var selector = "[usemap='#" + mapName + "']";
var img = elm.ownerDocument.querySelector(selector);
var areaCoords = elm.coords.split(",");
var areaX = parseInt(areaCoords[0]);
var areaY = parseInt(areaCoords[1]);
var areaWidth = parseInt(areaCoords[2]) - areaX;
var areaHeight = parseInt(areaCoords[3]) - areaY;
var rect = img.getBoundingClientRect();
x = rect.left + areaX;
y = rect.top + areaY;
width = areaWidth;
height = areaHeight;
}
else {
var rect = elm.getBoundingClientRect();
x = rect.left;
y = rect.top;
width = rect.width;
height = rect.height;
}
var elmWindow = elm.ownerDocument.defaultView;
var winUtil = elmWindow.
QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);
var ratio = winUtil.screenPixelsPerCSSPixel;
var rect = elm.getBoundingClientRect();
return [ (rect.left + elmWindow.mozInnerScreenX) * ratio,
(rect.top + elmWindow.mozInnerScreenY) * ratio,
rect.width * ratio,
rect.height * ratio ];
return [ (x + elmWindow.mozInnerScreenX) * ratio,
(y + elmWindow.mozInnerScreenY) * ratio,
width * ratio,
height * ratio ];
}

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

@ -74,6 +74,12 @@ extensions/Makefile
"
if [ ! "$LIBXUL_SDK" ]; then
if [ "$STLPORT_SOURCES" ]; then
add_makefiles "
build/stlport/Makefile
build/stlport/stl/config/_android.h
"
fi
add_makefiles "
memory/mozalloc/Makefile
mozglue/Makefile

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

@ -327,17 +327,36 @@ var shell = {
};
(function PowerManager() {
let idleHandler = {
observe: function(subject, topic, time) {
if (topic === "idle") {
// TODO: Check wakelock status. See bug 697132.
// This will eventually be moved to content, so use content API as
// much as possible here. TODO: Bug 738530
let power = navigator.mozPower;
let idleHandler = function idleHandler(subject, topic, time) {
if (topic === "idle") {
if (power.getWakeLockState("screen") != "locked-foreground") {
screen.mozEnabled = false;
}
},
}
}
let wakeLockHandler = function wakeLockHandler(topic, state) {
// Turn off the screen when no one needs the it or all of them are
// invisible, otherwise turn the screen on. Note that the CPU
// might go to sleep as soon as the screen is turned off and
// acquiring wake lock will not bring it back (actually the code
// is not executed at all).
if (topic == "screen") {
if (state != "locked-foreground") {
if (Services.idle.idleTime > idleTimeout*1000) {
screen.mozEnabled = false;
}
} else {
screen.mozEnabled = true;
}
}
}
let idleTimeout = Services.prefs.getIntPref("power.screen.timeout");
if (idleTimeout) {
Services.idle.addIdleObserver(idleHandler, idleTimeout);
power.addWakeLockListener(wakeLockHandler);
}
})();

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

@ -236,6 +236,7 @@
@BINPATH@/components/pref.xpt
@BINPATH@/components/prefetch.xpt
@BINPATH@/components/profile.xpt
@BINPATH@/components/profiler.xpt
@BINPATH@/components/proxyObject.xpt
@BINPATH@/components/rdf.xpt
@BINPATH@/components/satchel.xpt

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

@ -7,30 +7,30 @@ function test () {
let doc = gBrowser.contentDocument;
let tooltip = document.getElementById("aHTMLTooltip");
ok(FillInHTMLTooltip(doc.getElementById("svg1"), "should get title"));
ok(FillInHTMLTooltip(doc.getElementById("svg1")), "should get title");
is(tooltip.getAttribute("label"), "This is a non-root SVG element title");
ok(FillInHTMLTooltip(doc.getElementById("text1"), "should get title"));
ok(FillInHTMLTooltip(doc.getElementById("text1")), "should get title");
is(tooltip.getAttribute("label"), "\n\n\n This is a title\n\n ");
ok(!FillInHTMLTooltip(doc.getElementById("text2"), "should not get title"));
ok(!FillInHTMLTooltip(doc.getElementById("text2")), "should not get title");
ok(!FillInHTMLTooltip(doc.getElementById("text3"), "should not get title"));
ok(!FillInHTMLTooltip(doc.getElementById("text3")), "should not get title");
ok(FillInHTMLTooltip(doc.getElementById("link1"), "should get title"));
ok(FillInHTMLTooltip(doc.getElementById("link1")), "should get title");
is(tooltip.getAttribute("label"), "\n This is a title\n ");
ok(FillInHTMLTooltip(doc.getElementById("text4"), "should get title"));
ok(FillInHTMLTooltip(doc.getElementById("text4")), "should get title");
is(tooltip.getAttribute("label"), "\n This is a title\n ");
ok(!FillInHTMLTooltip(doc.getElementById("link2"), "should not get title"));
ok(!FillInHTMLTooltip(doc.getElementById("link2")), "should not get title");
ok(FillInHTMLTooltip(doc.getElementById("link3"), "should get title"));
ok(tooltip.getAttribute("label") != "");
ok(FillInHTMLTooltip(doc.getElementById("link3")), "should get title");
isnot(tooltip.getAttribute("label"), "");
ok(FillInHTMLTooltip(doc.getElementById("link4"), "should get title"));
ok(FillInHTMLTooltip(doc.getElementById("link4")), "should get title");
is(tooltip.getAttribute("label"), "This is an xlink:title attribute");
ok(!FillInHTMLTooltip(doc.getElementById("text5"), "should not get title"));
ok(!FillInHTMLTooltip(doc.getElementById("text5")), "should not get title");
gBrowser.removeCurrentTab();
finish();

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

@ -163,20 +163,3 @@ GetProfilePath(nsIProfileStartup* aStartup, nsCOMPtr<nsIFile>& aProfileDir)
}
}
nsresult
ImportDefaultBookmarks()
{
nsCOMPtr<nsIPlacesImportExportService> importer =
do_GetService(NS_PLACESIMPORTEXPORTSERVICE_CONTRACTID);
NS_ENSURE_STATE(importer);
nsCOMPtr<nsIIOService> ioService = mozilla::services::GetIOService();
NS_ENSURE_STATE(ioService);
nsCOMPtr<nsIURI> bookmarksURI;
nsresult rv = ioService->NewURI(DEFAULT_BOOKMARKS, nsnull, nsnull,
getter_AddRefs(bookmarksURI));
if (NS_FAILED(rv))
return rv;
return importer->ImportHTMLFromURI(bookmarksURI, true);
}

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

@ -99,10 +99,5 @@ void GetMigrateDataFromArray(MigrationData* aDataArray,
// this is already cloned, modify it to your heart's content
void GetProfilePath(nsIProfileStartup* aStartup, nsCOMPtr<nsIFile>& aProfileDir);
/**
* Imports default bookmarks to the profile.
*/
nsresult ImportDefaultBookmarks();
#endif

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

@ -1398,11 +1398,6 @@ nsIEProfileMigrator::CopyFavoritesBatched(bool aReplace)
NS_ENSURE_SUCCESS(rv, rv);
}
else {
// If importing defaults fails for whatever reason, let the import process
// continue.
DebugOnly<nsresult> rv = ImportDefaultBookmarks();
MOZ_ASSERT(NS_SUCCEEDED(rv), "Should be able to import default bookmarks");
// Locate the Links toolbar folder, we want to replace the Personal Toolbar
// content with Favorites in this folder.
// On versions minor or equal to IE6 the folder name is stored in the

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

@ -974,11 +974,6 @@ nsSafariProfileMigrator::CopyBookmarksBatched(bool aReplace)
NS_ENSURE_SUCCESS(rv, rv);
}
else {
// If importing defaults fails for whatever reason, let the import process
// continue.
DebugOnly<nsresult> rv = ImportDefaultBookmarks();
MOZ_ASSERT(NS_SUCCEEDED(rv), "Should be able to import default bookmarks");
// In replace mode we are merging at the top level.
folder = bookmarksMenuFolderId;
}

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

@ -62,6 +62,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "BookmarkHTMLUtils",
"resource://gre/modules/BookmarkHTMLUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "KeywordURLResetPrompter",
"resource:///modules/KeywordURLResetPrompter.jsm");
@ -228,10 +231,6 @@ BrowserGlue.prototype = {
// no longer needed, since history was initialized completely.
Services.obs.removeObserver(this, "places-database-locked");
this._isPlacesLockedObserver = false;
// Now apply distribution customized bookmarks.
// This should always run after Places initialization.
this._distributionCustomizer.applyBookmarks();
break;
case "places-database-locked":
this._isPlacesDatabaseLocked = true;
@ -257,13 +256,6 @@ BrowserGlue.prototype = {
// Customization has finished, we don't need the customizer anymore.
delete this._distributionCustomizer;
break;
case "bookmarks-restore-success":
case "bookmarks-restore-failed":
Services.obs.removeObserver(this, "bookmarks-restore-success");
Services.obs.removeObserver(this, "bookmarks-restore-failed");
if (topic == "bookmarks-restore-success" && data == "html-initial")
this.ensurePlacesDefaultQueriesInitialized();
break;
case "browser-glue-test": // used by tests
if (data == "post-update-notification") {
if (Services.prefs.prefHasUserValue("app.update.postupdate"))
@ -288,6 +280,9 @@ BrowserGlue.prototype = {
keywordURI);
}
break;
case "initial-migration":
this._initialMigrationPerformed = true;
break;
}
},
@ -990,18 +985,9 @@ BrowserGlue.prototype = {
// If the database is corrupt or has been newly created we should
// import bookmarks.
var dbStatus = PlacesUtils.history.databaseStatus;
var importBookmarks = dbStatus == PlacesUtils.history.DATABASE_STATUS_CREATE ||
dbStatus == PlacesUtils.history.DATABASE_STATUS_CORRUPT;
if (dbStatus == PlacesUtils.history.DATABASE_STATUS_CREATE) {
// If the database has just been created, but we already have any
// bookmark, this is not the initial import. This can happen after a
// migration from a different browser since migrators run before us.
// In such a case we should not import, unless some pref has been set.
if (PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.bookmarksMenuFolderId, 0) != -1 ||
PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId, 0) != -1)
importBookmarks = false;
}
var importBookmarks = !this._initialMigrationPerformed &&
(dbStatus == PlacesUtils.history.DATABASE_STATUS_CREATE ||
dbStatus == PlacesUtils.history.DATABASE_STATUS_CORRUPT);
// Check if user or an extension has required to import bookmarks.html
var importBookmarksHTML = false;
@ -1058,6 +1044,9 @@ BrowserGlue.prototype = {
// delayed till the import operations has finished. Not doing so would
// cause them to be overwritten by the newly imported bookmarks.
if (!importBookmarks) {
// Now apply distribution customized bookmarks.
// This should always run after Places initialization.
this._distributionCustomizer.applyBookmarks();
this.ensurePlacesDefaultQueriesInitialized();
}
else {
@ -1091,25 +1080,28 @@ BrowserGlue.prototype = {
}
if (bookmarksURI) {
// Add an import observer. It will ensure that smart bookmarks are
// created once the operation is complete.
Services.obs.addObserver(this, "bookmarks-restore-success", false);
Services.obs.addObserver(this, "bookmarks-restore-failed", false);
// Import from bookmarks.html file.
try {
var importer = Cc["@mozilla.org/browser/places/import-export-service;1"].
getService(Ci.nsIPlacesImportExportService);
importer.importHTMLFromURI(bookmarksURI, true /* overwrite existing */);
BookmarkHTMLUtils.importFromURL(bookmarksURI.spec, true, (function (success) {
if (success) {
// Now apply distribution customized bookmarks.
// This should always run after Places initialization.
this._distributionCustomizer.applyBookmarks();
// Ensure that smart bookmarks are created once the operation is
// complete.
this.ensurePlacesDefaultQueriesInitialized();
}
else {
Cu.reportError("Bookmarks.html file could be corrupt.");
}
}).bind(this));
} catch (err) {
// Report the error, but ignore it.
Cu.reportError("Bookmarks.html file could be corrupt. " + err);
Services.obs.removeObserver(this, "bookmarks-restore-success");
Services.obs.removeObserver(this, "bookmarks-restore-failed");
}
}
else
else {
Cu.reportError("Unable to find bookmarks.html file.");
}
// Reset preferences, so we won't try to import again at next run
if (importBookmarksHTML)

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

@ -400,10 +400,9 @@ var PlacesOrganizer = {
Ci.nsIFilePicker.modeOpen);
fp.appendFilters(Ci.nsIFilePicker.filterHTML);
if (fp.show() != Ci.nsIFilePicker.returnCancel) {
if (fp.file) {
var importer = Cc["@mozilla.org/browser/places/import-export-service;1"].
getService(Ci.nsIPlacesImportExportService);
importer.importHTMLFromFile(fp.file, false);
if (fp.fileURL) {
Components.utils.import("resource://gre/modules/BookmarkHTMLUtils.jsm");
BookmarkHTMLUtils.importFromURL(fp.fileURL.spec, false);
}
}
},

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

@ -57,8 +57,8 @@ function run_test() {
- export as json, import, test
*/
// get places import/export service
var importer = Cc["@mozilla.org/browser/places/import-export-service;1"].getService(Ci.nsIPlacesImportExportService);
// import the importer
Cu.import("resource://gre/modules/BookmarkHTMLUtils.jsm");
// avoid creating the places smart folder during tests
Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch).
@ -83,8 +83,14 @@ function run_test() {
// 2. run the test-suite
// Note: we do not empty the db before this import to catch bugs like 380999
try {
importer.importHTMLFromFile(bookmarksFileOld, true);
BookmarkHTMLUtils.importFromFile(bookmarksFileOld, true, after_import);
} catch(ex) { do_throw("couldn't import legacy bookmarks file: " + ex); }
}
function after_import(success) {
if (!success) {
do_throw("Couldn't import legacy bookmarks file.");
}
populate();
validate();
@ -95,6 +101,8 @@ function run_test() {
// 3. import bookmarks.exported.json
// 4. run the test-suite
try {
var jsonFile = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
jsonFile.append("bookmarks.exported.json");
PlacesUtils.backups.saveBookmarksToJSONFile(jsonFile);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
LOG("exported json");

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

@ -56,6 +56,8 @@ try {
try {
var gluesvc = Cc["@mozilla.org/browser/browserglue;1"].
getService(Ci.nsIBrowserGlue);
// Avoid default bookmarks import.
gluesvc.QueryInterface(Ci.nsIObserver).observe(null, "initial-migration", null);
} catch(ex) {
do_throw("Could not get BrowserGlue service\n");
}

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

@ -55,6 +55,7 @@ var ps = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
var ies = Cc["@mozilla.org/browser/places/import-export-service;1"].
getService(Ci.nsIPlacesImportExportService);
Cu.import("resource://gre/modules/BookmarkHTMLUtils.jsm");
const DESCRIPTION_ANNO = "bookmarkProperties/description";
const LOAD_IN_SIDEBAR_ANNO = "bookmarkProperties/loadInSidebar";
@ -72,8 +73,14 @@ function run_test() {
// import bookmarks from corrupt file
var corruptBookmarksFile = do_get_file("bookmarks.corrupt.html");
try {
ies.importHTMLFromFile(corruptBookmarksFile, true);
BookmarkHTMLUtils.importFromFile(corruptBookmarksFile, true, after_import);
} catch(ex) { do_throw("couldn't import corrupt bookmarks file: " + ex); }
}
function after_import(success) {
if (!success) {
do_throw("Couldn't import corrupt bookmarks file.");
}
// Check that every bookmark is correct
// Corrupt bookmarks should not have been imported
@ -105,14 +112,16 @@ function run_test() {
// Import bookmarks
try {
ies.importHTMLFromFile(bookmarksFile, true);
BookmarkHTMLUtils.importFromFile(bookmarksFile, true, before_database_check);
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
});
}
function before_database_check(success) {
// Check that every bookmark is correct
database_check();
waitForAsyncUpdates(do_test_finished);
});
}
/*

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

@ -36,6 +36,8 @@
*
* ***** END LICENSE BLOCK ***** */
Cu.import("resource://gre/modules/BookmarkHTMLUtils.jsm");
/**
* Tests the bookmarks-restore-* nsIObserver notifications after restoring
* bookmarks from JSON and HTML. See bug 470314.
@ -134,10 +136,14 @@ var tests = [
run: function () {
this.file = createFile("bookmarks-test_restoreNotification.html");
addBookmarks();
importer.exportHTMLToFile(this.file);
exporter.exportHTMLToFile(this.file);
remove_all_bookmarks();
try {
importer.importHTMLFromFile(this.file, false);
BookmarkHTMLUtils.importFromFile(this.file, false, function (success) {
if (!success) {
do_throw(" Restore should not have failed");
}
});
}
catch (e) {
do_throw(" Restore should not have failed");
@ -154,7 +160,11 @@ var tests = [
run: function () {
this.file = createFile("bookmarks-test_restoreNotification.init.html");
try {
importer.importHTMLFromFile(this.file, false);
BookmarkHTMLUtils.importFromFile(this.file, false, function (success) {
if (!success) {
do_throw(" Restore should not have failed");
}
});
}
catch (e) {
do_throw(" Restore should not have failed");
@ -172,8 +182,12 @@ var tests = [
this.file = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
this.file.append("this file doesn't exist because nobody created it");
try {
importer.importHTMLFromFile(this.file, false);
do_throw(" Restore should have failed");
BookmarkHTMLUtils.importFromFile(this.file, false, function (success) {
print("callback");
if (success) {
do_throw(" Restore should have failed");
}
});
}
catch (e) {}
}
@ -188,10 +202,14 @@ var tests = [
run: function () {
this.file = createFile("bookmarks-test_restoreNotification.init.html");
addBookmarks();
importer.exportHTMLToFile(this.file);
exporter.exportHTMLToFile(this.file);
remove_all_bookmarks();
try {
importer.importHTMLFromFile(this.file, true);
BookmarkHTMLUtils.importFromFile(this.file, true, function (success) {
if (!success) {
do_throw(" Restore should not have failed");
}
});
}
catch (e) {
do_throw(" Restore should not have failed");
@ -208,7 +226,11 @@ var tests = [
run: function () {
this.file = createFile("bookmarks-test_restoreNotification.init.html");
try {
importer.importHTMLFromFile(this.file, true);
BookmarkHTMLUtils.importFromFile(this.file, true, function (success) {
if (!success) {
do_throw(" Restore should not have failed");
}
});
}
catch (e) {
do_throw(" Restore should not have failed");
@ -226,13 +248,15 @@ var tests = [
this.file = Services.dirsvc.get("ProfD", Ci.nsILocalFile);
this.file.append("this file doesn't exist because nobody created it");
try {
importer.importHTMLFromFile(this.file, true);
do_throw(" Restore should have failed");
BookmarkHTMLUtils.importFromFile(this.file, true, function (success) {
if (success) {
do_throw(" Restore should have failed");
}
});
}
catch (e) {}
}
}
];
// nsIObserver that observes bookmarks-restore-begin.
@ -281,7 +305,7 @@ var successAndFailedObserver = {
do_check_eq(test.folderId, null);
remove_all_bookmarks();
doNextTest();
do_execute_soon(doNextTest);
}
};
@ -294,7 +318,7 @@ var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
var obssvc = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
var importer = Cc["@mozilla.org/browser/places/import-export-service;1"].
var exporter = Cc["@mozilla.org/browser/places/import-export-service;1"].
getService(Ci.nsIPlacesImportExportService);
///////////////////////////////////////////////////////////////////////////////

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

@ -99,9 +99,11 @@ let gBookmarksFileOld;
// Places bookmarks.html file pointer.
let gBookmarksFileNew;
let importer = Cc["@mozilla.org/browser/places/import-export-service;1"].
let exporter = Cc["@mozilla.org/browser/places/import-export-service;1"].
getService(Ci.nsIPlacesImportExportService);
Cu.import("resource://gre/modules/BookmarkHTMLUtils.jsm");
function run_test()
{
run_next_test();
@ -131,22 +133,26 @@ add_test(function setup() {
// 2. run the test-suite
// Note: we do not empty the db before this import to catch bugs like 380999
try {
importer.importHTMLFromFile(gBookmarksFileOld, true);
} catch(ex) { do_throw("couldn't import legacy bookmarks file: " + ex); }
BookmarkHTMLUtils.importFromFile(gBookmarksFileOld, true, function(success) {
if (success) {
waitForAsyncUpdates(function () {
testImportedBookmarks();
waitForAsyncUpdates(function () {
testImportedBookmarks();
// Prepare for next tests.
try {
exporter.exportHTMLToFile(gBookmarksFileNew);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
// Prepare for next tests.
try {
importer.exportHTMLToFile(gBookmarksFileNew);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
waitForAsyncUpdates(function () {
remove_all_bookmarks();
run_next_test();
waitForAsyncUpdates(function () {
remove_all_bookmarks();
run_next_test();
});
});
} else {
do_throw("couldn't import legacy bookmarks file.");
}
});
});
} catch(ex) { do_throw("couldn't import legacy bookmarks file: " + ex); }
});
add_test(function test_import_new()
@ -156,17 +162,21 @@ add_test(function test_import_new()
// 2. run the test-suite
try {
importer.importHTMLFromFile(gBookmarksFileNew, true);
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true, function(success) {
if (success) {
waitForAsyncUpdates(function () {
testImportedBookmarks();
waitForAsyncUpdates(function () {
testImportedBookmarks();
waitForAsyncUpdates(function () {
remove_all_bookmarks();
run_next_test();
waitForAsyncUpdates(function () {
remove_all_bookmarks();
run_next_test();
});
});
} else {
do_throw("couldn't import the exported file.");
}
});
});
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
});
add_test(function test_emptytitle_export()
@ -180,42 +190,50 @@ add_test(function test_emptytitle_export()
// 5. run the test-suite
try {
importer.importHTMLFromFile(gBookmarksFileNew, true);
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true, function(success) {
if (success) {
const NOTITLE_URL = "http://notitle.mozilla.org/";
let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI(NOTITLE_URL),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"");
test_bookmarks.unfiled.push({ title: "", url: NOTITLE_URL });
const NOTITLE_URL = "http://notitle.mozilla.org/";
let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI(NOTITLE_URL),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"");
test_bookmarks.unfiled.push({ title: "", url: NOTITLE_URL });
try {
exporter.exportHTMLToFile(gBookmarksFileNew);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
try {
importer.exportHTMLToFile(gBookmarksFileNew);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
remove_all_bookmarks();
remove_all_bookmarks();
try {
BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true, function(success) {
if (success) {
waitForAsyncUpdates(function () {
testImportedBookmarks();
try {
importer.importHTMLFromFile(gBookmarksFileNew, true);
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
// Cleanup.
test_bookmarks.unfiled.pop();
PlacesUtils.bookmarks.removeItem(id);
waitForAsyncUpdates(function () {
testImportedBookmarks();
try {
exporter.exportHTMLToFile(gBookmarksFileNew);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
// Cleanup.
test_bookmarks.unfiled.pop();
PlacesUtils.bookmarks.removeItem(id);
try {
importer.exportHTMLToFile(gBookmarksFileNew);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
waitForAsyncUpdates(function () {
remove_all_bookmarks();
run_next_test();
waitForAsyncUpdates(function () {
remove_all_bookmarks();
run_next_test();
});
});
} else {
do_throw("couldn't import the exported file.");
}
});
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
} else {
do_throw("couldn't import the exported file.");
}
});
});
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
});
add_test(function test_import_ontop()
@ -229,23 +247,33 @@ add_test(function test_import_ontop()
// 4. run the test-suite
try {
importer.importHTMLFromFile(gBookmarksFileNew, true);
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
try {
importer.exportHTMLToFile(gBookmarksFileNew);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
try {
importer.importHTMLFromFile(gBookmarksFileNew, true);
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true, function(success) {
if (success) {
try {
exporter.exportHTMLToFile(gBookmarksFileNew);
} catch(ex) { do_throw("couldn't export to file: " + ex); }
try {
BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true, function(success) {
if (success) {
waitForAsyncUpdates(function () {
testImportedBookmarks();
waitForAsyncUpdates(function () {
testImportedBookmarks();
waitForAsyncUpdates(function () {
remove_all_bookmarks();
run_next_test();
});
});
} else {
do_throw("couldn't import the exported file.");
}
});
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
waitForAsyncUpdates(function () {
remove_all_bookmarks();
run_next_test();
} else {
do_throw("couldn't import the exported file.");
}
});
});
} catch(ex) { do_throw("couldn't import the exported file: " + ex); }
});
function testImportedBookmarks()

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

@ -29,14 +29,15 @@ function run_test() {
do_check_eq(PlacesUtils.history.databaseStatus,
PlacesUtils.history.DATABASE_STATUS_CREATE);
// A migrator would run before nsBrowserGlue, so we mimic that behavior
// adding a bookmark.
//A migrator would run before nsBrowserGlue Places initialization, so mimic
//that behavior adding a bookmark and notifying the migration.
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.bookmarks.bookmarksMenuFolder, uri("http://mozilla.org/"),
PlacesUtils.bookmarks.DEFAULT_INDEX, "migrated");
// Initialize nsBrowserGlue.
let bg = Cc["@mozilla.org/browser/browserglue;1"].
getService(Ci.nsIBrowserGlue);
getService(Ci.nsIObserver);
bg.observe(null, "initial-migration", null)
let bookmarksObserver = {
onBeginUpdateBatch: function() {},

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

@ -17,6 +17,16 @@ const TOPICDATA_FORCE_PLACES_INIT = "force-places-init";
let bg = Cc["@mozilla.org/browser/browserglue;1"].
getService(Ci.nsIBrowserGlue);
function waitForImportAndSmartBookmarks(aCallback) {
Services.obs.addObserver(function waitImport() {
Services.obs.removeObserver(waitImport, "bookmarks-restore-success");
// Delay to test eventual smart bookmarks creation.
do_execute_soon(function () {
waitForAsyncUpdates(aCallback);
});
}, "bookmarks-restore-success", false);
}
let gTests = [
// This test must be the first one.
@ -66,19 +76,20 @@ let gTests = [
// Force nsBrowserGlue::_initPlaces().
print("Simulate Places init");
waitForImportAndSmartBookmarks(function () {
// Check bookmarks.html has been imported, and a smart bookmark has been
// created.
itemId = PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId,
SMART_BOOKMARKS_ON_TOOLBAR);
do_check_eq(PlacesUtils.bookmarks.getItemTitle(itemId), "example");
// Check preferences have been reverted.
do_check_false(Services.prefs.getBoolPref(PREF_IMPORT_BOOKMARKS_HTML));
run_next_test();
});
bg.QueryInterface(Ci.nsIObserver).observe(null,
TOPIC_BROWSERGLUE_TEST,
TOPICDATA_FORCE_PLACES_INIT);
// Check bookmarks.html has been imported, and a smart bookmark has been
// created.
itemId = PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId,
SMART_BOOKMARKS_ON_TOOLBAR);
do_check_eq(PlacesUtils.bookmarks.getItemTitle(itemId), "example");
// Check preferences have been reverted.
do_check_false(Services.prefs.getBoolPref(PREF_IMPORT_BOOKMARKS_HTML));
run_next_test();
},
function test_import_noSmartBookmarks()
@ -98,19 +109,20 @@ let gTests = [
// Force nsBrowserGlue::_initPlaces().
print("Simulate Places init");
waitForImportAndSmartBookmarks(function () {
// Check bookmarks.html has been imported, but smart bookmarks have not
// been created.
itemId =
PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId, 0);
do_check_eq(PlacesUtils.bookmarks.getItemTitle(itemId), "example");
// Check preferences have been reverted.
do_check_false(Services.prefs.getBoolPref(PREF_IMPORT_BOOKMARKS_HTML));
run_next_test();
});
bg.QueryInterface(Ci.nsIObserver).observe(null,
TOPIC_BROWSERGLUE_TEST,
TOPICDATA_FORCE_PLACES_INIT);
// Check bookmarks.html has been imported, but smart bookmarks have not
// been created.
itemId =
PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId, 0);
do_check_eq(PlacesUtils.bookmarks.getItemTitle(itemId), "example");
// Check preferences have been reverted.
do_check_false(Services.prefs.getBoolPref(PREF_IMPORT_BOOKMARKS_HTML));
run_next_test();
},
function test_import_autoExport_updatedSmartBookmarks()
@ -131,20 +143,21 @@ let gTests = [
// Force nsBrowserGlue::_initPlaces()
print("Simulate Places init");
waitForImportAndSmartBookmarks(function () {
// Check bookmarks.html has been imported, but smart bookmarks have not
// been created.
itemId =
PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId, 0);
do_check_eq(PlacesUtils.bookmarks.getItemTitle(itemId), "example");
do_check_false(Services.prefs.getBoolPref(PREF_IMPORT_BOOKMARKS_HTML));
// Check preferences have been reverted.
Services.prefs.setBoolPref(PREF_AUTO_EXPORT_HTML, false);
run_next_test();
});
bg.QueryInterface(Ci.nsIObserver).observe(null,
TOPIC_BROWSERGLUE_TEST,
TOPICDATA_FORCE_PLACES_INIT);
// Check bookmarks.html has been imported, but smart bookmarks have not
// been created.
itemId =
PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId, 0);
do_check_eq(PlacesUtils.bookmarks.getItemTitle(itemId), "example");
do_check_false(Services.prefs.getBoolPref(PREF_IMPORT_BOOKMARKS_HTML));
// Check preferences have been reverted.
Services.prefs.setBoolPref(PREF_AUTO_EXPORT_HTML, false);
run_next_test();
},
function test_import_autoExport_oldSmartBookmarks()
@ -165,21 +178,22 @@ let gTests = [
// Force nsBrowserGlue::_initPlaces()
print("Simulate Places init");
waitForImportAndSmartBookmarks(function () {
// Check bookmarks.html has been imported, but smart bookmarks have not
// been created.
itemId =
PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId,
SMART_BOOKMARKS_ON_TOOLBAR);
do_check_eq(PlacesUtils.bookmarks.getItemTitle(itemId), "example");
do_check_false(Services.prefs.getBoolPref(PREF_IMPORT_BOOKMARKS_HTML));
// Check preferences have been reverted.
Services.prefs.setBoolPref(PREF_AUTO_EXPORT_HTML, false);
run_next_test();
});
bg.QueryInterface(Ci.nsIObserver).observe(null,
TOPIC_BROWSERGLUE_TEST,
TOPICDATA_FORCE_PLACES_INIT);
// Check bookmarks.html has been imported, but smart bookmarks have not
// been created.
itemId =
PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId,
SMART_BOOKMARKS_ON_TOOLBAR);
do_check_eq(PlacesUtils.bookmarks.getItemTitle(itemId), "example");
do_check_false(Services.prefs.getBoolPref(PREF_IMPORT_BOOKMARKS_HTML));
// Check preferences have been reverted.
Services.prefs.setBoolPref(PREF_AUTO_EXPORT_HTML, false);
run_next_test();
},
function test_restore()
@ -198,19 +212,21 @@ let gTests = [
// Force nsBrowserGlue::_initPlaces()
print("Simulate Places init");
waitForImportAndSmartBookmarks(function () {
// Check bookmarks.html has been restored.
itemId =
PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId,
SMART_BOOKMARKS_ON_TOOLBAR);
do_check_true(itemId > 0);
// Check preferences have been reverted.
do_check_false(Services.prefs.getBoolPref(PREF_RESTORE_DEFAULT_BOOKMARKS));
run_next_test();
});
bg.QueryInterface(Ci.nsIObserver).observe(null,
TOPIC_BROWSERGLUE_TEST,
TOPICDATA_FORCE_PLACES_INIT);
// Check bookmarks.html has been restored.
itemId =
PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId,
SMART_BOOKMARKS_ON_TOOLBAR);
do_check_true(itemId > 0);
// Check preferences have been reverted.
do_check_false(Services.prefs.getBoolPref(PREF_RESTORE_DEFAULT_BOOKMARKS));
run_next_test();
},
function test_restore_import()
@ -230,20 +246,21 @@ let gTests = [
// Force nsBrowserGlue::_initPlaces()
print("Simulate Places init");
waitForImportAndSmartBookmarks(function () {
// Check bookmarks.html has been restored.
itemId =
PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId,
SMART_BOOKMARKS_ON_TOOLBAR);
do_check_true(itemId > 0);
// Check preferences have been reverted.
do_check_false(Services.prefs.getBoolPref(PREF_RESTORE_DEFAULT_BOOKMARKS));
do_check_false(Services.prefs.getBoolPref(PREF_IMPORT_BOOKMARKS_HTML));
run_next_test();
});
bg.QueryInterface(Ci.nsIObserver).observe(null,
TOPIC_BROWSERGLUE_TEST,
TOPICDATA_FORCE_PLACES_INIT);
// Check bookmarks.html has been restored.
itemId =
PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.toolbarFolderId,
SMART_BOOKMARKS_ON_TOOLBAR);
do_check_true(itemId > 0);
// Check preferences have been reverted.
do_check_false(Services.prefs.getBoolPref(PREF_RESTORE_DEFAULT_BOOKMARKS));
do_check_false(Services.prefs.getBoolPref(PREF_IMPORT_BOOKMARKS_HTML));
run_next_test();
}
];

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

@ -364,6 +364,15 @@ function run_test() {
}
catch(ex) {}
// Kick-off tests.
next_test();
waitForImportAndSmartBookmarks(next_test);
}
function waitForImportAndSmartBookmarks(aCallback) {
Services.obs.addObserver(function waitImport() {
Services.obs.removeObserver(waitImport, "bookmarks-restore-success");
// Delay to test eventual smart bookmarks creation.
do_execute_soon(function () {
waitForAsyncUpdates(aCallback);
});
}, "bookmarks-restore-success", false);
}

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

@ -110,7 +110,9 @@ function run_test() {
do_test_pending();
print("Initialize browserglue before Places");
Cc["@mozilla.org/browser/browserglue;1"].getService(Ci.nsIBrowserGlue);
// Avoid default bookmarks import.
Cc["@mozilla.org/browser/browserglue;1"].getService(Ci.nsIObserver)
.observe(null, "initial-migration", null);
Services.prefs.setBoolPref("privacy.clearOnShutdown.cache", true);
Services.prefs.setBoolPref("privacy.clearOnShutdown.cookies", true);

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

@ -99,7 +99,9 @@
@BINPATH@/@MOZ_APP_NAME@
#endif
@BINPATH@/application.ini
#ifdef MOZ_UPDATER
@BINPATH@/update-settings.ini
#endif
@BINPATH@/platform.ini
#ifndef XP_OS2
@BINPATH@/@DLL_PREFIX@mozsqlite3@DLL_SUFFIX@

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

@ -280,7 +280,7 @@ can reach it easily. -->
<!ENTITY clearRecentHistory.label "Clear Recent History…">
<!ENTITY clearRecentHistory.accesskey "H">
<!-- LOCALIZATION NOTE : These two strings can share an access key beause they never appear together on the menu -->
<!-- LOCALIZATION NOTE : These two strings can share an access key because they never appear together on the menu -->
<!ENTITY privateBrowsingCmd.start.label "Start Private Browsing">
<!ENTITY privateBrowsingCmd.start.accesskey "P">
<!ENTITY privateBrowsingCmd.stop.label "Stop Private Browsing">

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

@ -158,9 +158,9 @@
border-right-style: none !important;
}
#toolbar-menubar :-moz-any(@primaryToolbarButtons@):not(:-moz-any(#alltabs-button,#tabview-button,#new-tab-button,#sync-button[status])) > .toolbarbutton-icon:not(:-moz-lwtheme),
#toolbar-menubar :-moz-any(@primaryToolbarButtons@):not(:-moz-any(#alltabs-button,#tabview-button,#sync-button[status])) > .toolbarbutton-icon:not(:-moz-lwtheme),
#TabsToolbar[tabsontop=true] :-moz-any(@primaryToolbarButtons@):not(:-moz-any(#alltabs-button,#tabview-button,#new-tab-button,#sync-button[status])) > .toolbarbutton-icon:not(:-moz-lwtheme),
#navigator-toolbox[tabsontop=false] > #nav-bar :-moz-any(@primaryToolbarButtons@):not(:-moz-any(#alltabs-button,#tabview-button,#new-tab-button,#sync-button[status])) > .toolbarbutton-icon:not(:-moz-lwtheme),
#navigator-toolbox[tabsontop=false] > #nav-bar :-moz-any(@primaryToolbarButtons@):not(:-moz-any(#alltabs-button,#tabview-button,#sync-button[status])) > .toolbarbutton-icon:not(:-moz-lwtheme),
#nav-bar + #customToolbars + #PersonalToolbar[collapsed=true] + #TabsToolbar[tabsontop=false]:last-child :-moz-any(@primaryToolbarButtons@):not(:-moz-any(#alltabs-button,#tabview-button,#new-tab-button,#sync-button[status])) > .toolbarbutton-icon:not(:-moz-lwtheme) {
list-style-image: url("chrome://browser/skin/Toolbar-inverted.png");
}

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

@ -1003,6 +1003,8 @@ toolbar[mode=full] .toolbarbutton-1 > .toolbarbutton-menubutton-button {
%ifdef WINSTRIPE_AERO
#TabsToolbar > #tabview-button:-moz-system-metric(windows-compositor):not(:-moz-lwtheme),
#TabsToolbar > toolbarpaletteitem > #tabview-button:-moz-system-metric(windows-compositor):not(:-moz-lwtheme),
#navigator-toolbox[tabsontop=false] > #nav-bar #tabview-button:-moz-system-metric(windows-compositor):not(:-moz-lwtheme),
#toolbar-menubar #tabview-button:-moz-system-metric(windows-compositor):not(:-moz-lwtheme),
%endif
#tabview-button:-moz-lwtheme-brighttext {
list-style-image: url(chrome://browser/skin/tabview/tabview-inverted.png);
@ -2051,6 +2053,8 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
%ifdef WINSTRIPE_AERO
#TabsToolbar > #alltabs-button[type="menu"]:-moz-system-metric(windows-compositor):not(:-moz-lwtheme),
#TabsToolbar > toolbarpaletteitem > #alltabs-button[type="menu"]:-moz-system-metric(windows-compositor):not(:-moz-lwtheme),
#navigator-toolbox[tabsontop=false] > #nav-bar #alltabs-button[type="menu"]:-moz-system-metric(windows-compositor):not(:-moz-lwtheme),
#toolbar-menubar #alltabs-button[type="menu"]:-moz-system-metric(windows-compositor):not(:-moz-lwtheme),
%endif
#alltabs-button[type="menu"]:-moz-lwtheme-brighttext {
list-style-image: url("chrome://browser/skin/toolbarbutton-dropdown-arrow-inverted.png");

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

@ -53,6 +53,10 @@ ifeq (WINNT,$(OS_ARCH))
DIRS = win32
endif
ifdef STLPORT_SOURCES
DIRS += stlport
endif
DIRS += pgo
TEST_DIRS += autoconf/test
@ -69,8 +73,10 @@ ifdef MOZ_APP_BASENAME
DIST_FILES = application.ini
ifneq (android,$(MOZ_WIDGET_TOOLKIT))
ifdef MOZ_UPDATER
DIST_FILES += update-settings.ini
endif
endif
ifdef LIBXUL_SDK
GRE_MILESTONE = $(shell $(PYTHON) $(topsrcdir)/config/printconfigsetting.py $(LIBXUL_DIST)/bin/platform.ini Build Milestone)
@ -160,10 +166,12 @@ leaktest.py: leaktest.py.in
GARBAGE += leaktest.py
ifneq (android,$(MOZ_WIDGET_TOOLKIT))
ifdef MOZ_UPDATER
update-settings.ini: update-settings.ini.in $(APP_INI_DEPS)
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $< > $@
GARBAGE += update-settings.ini
endif
endif
ifdef MOZ_APP_BASENAME
application.ini: application.ini.in $(APP_INI_DEPS)

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

@ -235,12 +235,12 @@ class DeviceManager:
@abstractmethod
def killProcess(self, appname):
def killProcess(self, appname, forceKill=False):
"""
external function
returns:
success: output from testagent
failure: None
success: True
failure: False
"""
@abstractmethod

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

@ -376,16 +376,21 @@ class DeviceManagerADB(DeviceManager):
# external function
# returns:
# success: output from testagent
# failure: None
def killProcess(self, appname):
# success: True
# failure: False
def killProcess(self, appname, forceKill=False):
procs = self.getProcessList()
didKillProcess = False
for (pid, name, user) in procs:
if name == appname:
p = self.runCmdAs(["shell", "kill", pid])
return p.stdout.read()
args = ["shell", "kill"]
if forceKill:
args.append("-9")
args.append(pid)
p = self.runCmdAs(args)
didKillProcess = True
return None
return didKillProcess
# external function
# returns:

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

@ -582,15 +582,17 @@ class DeviceManagerSUT(DeviceManager):
# external function
# returns:
# success: output from testagent
# failure: None
def killProcess(self, appname):
# success: True
# failure: False
def killProcess(self, appname, forceKill=False):
if forceKill:
print "WARNING: killProcess(): forceKill parameter unsupported on SUT"
try:
data = self.runCmds(['kill ' + appname])
except AgentError:
return None
return False
return data
return True
# external function
# returns:

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

@ -70,6 +70,8 @@ import org.json.*;
import com.jayway.android.robotium.solo.Solo;
public class FennecNativeDriver implements Driver {
private static final int FRAME_TIME_THRESHOLD = 17; // allow 17ms per frame (~60fps)
// Map of IDs to element names.
private HashMap mLocators = null;
private Activity mActivity;
@ -225,21 +227,15 @@ public class FennecNativeDriver implements Driver {
public int stopFrameRecording() {
Class [] parameters = new Class[1];
parameters[0] = null;
List frames;
try {
Object [] params = null;
frames = (List)_stopFrameRecording.invoke(null, params);
Object [] framearray = frames.toArray();
Long last = new Long(0);
Long threshold = new Long(17);
List<Long> frames = (List<Long>)_stopFrameRecording.invoke(null, params);
int numDelays = 0;
for (int i=0; i < framearray.length; i++) {
Long val = (Long)framearray[i];
if ((val - last) > threshold) {
for (int i = 1; i < frames.size(); i++) {
if (frames.get(i) - frames.get(i-1) > FRAME_TIME_THRESHOLD) {
numDelays++;
}
last = val;
}
return numDelays;
} catch (IllegalAccessException e) {
@ -265,18 +261,15 @@ public class FennecNativeDriver implements Driver {
public float stopCheckerboardRecording() {
Class [] parameters = new Class[1];
parameters[0] = null;
List checkerboard;
try {
Object [] params = null;
checkerboard = (List)_stopCheckerboardRecording.invoke(null, params);
Object [] amountarray = checkerboard.toArray();
double completeness = 0;
for (Object obj : amountarray) {
float val = (Float)obj;
completeness += (1.0 - (double)val) / (double)amountarray.length;
List<Float> checkerboard = (List<Float>)_stopCheckerboardRecording.invoke(null, params);
float completeness = 0;
for (float val : checkerboard) {
completeness += (1.0f - val);
}
return (float)completeness;
return completeness / (float)checkerboard.size();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {

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

@ -59,9 +59,7 @@ namespace std {
template ostream& ostream::_M_insert(unsigned long);
template ostream& ostream::_M_insert(long long);
template ostream& ostream::_M_insert(unsigned long long);
#ifdef DEBUG
template ostream& ostream::_M_insert(const void*);
#endif
template ostream& __ostream_insert(ostream&, const char*, streamsize);
template istream& istream::_M_extract(double&);
#endif

30
build/stlport/Makefile.in Normal file
Просмотреть файл

@ -0,0 +1,30 @@
# 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/.
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULES = stlport
LIBRARY_NAME = stlport_static
FORCE_STATIC_LIB = 1
STL_FLAGS =
# Force to build a static library, instead of a fake library, without
# installing it in dist/lib.
LIBRARY = $(LIB_PREFIX)$(LIBRARY_NAME).$(LIB_SUFFIX)
VPATH += $(STLPORT_SOURCES)/src
CPPSRCS = $(notdir $(wildcard $(STLPORT_SOURCES)/src/*.cpp))
CSRCS = $(notdir $(wildcard $(STLPORT_SOURCES)/src/*.c))
include $(topsrcdir)/config/rules.mk
DEFINES += -D_GNU_SOURCE
CXXFLAGS += -fuse-cxa-atexit
INCLUDES += -I$(STLPORT_SOURCES)/stlport

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

@ -0,0 +1,23 @@
/* 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 mozilla_stl_config__android_h
#define mozilla_stl_config__android_h
#include "@STLPORT_SOURCES@/stlport/stl/config/_android.h"
// No rtti support
#undef _STLP_NO_RTTI
#define _STLP_NO_RTTI 1
// No throwing exceptions
#undef _STLP_NO_EXCEPTIONS
#define _STLP_NO_EXCEPTIONS 1
#undef _STLP_NATIVE_CPP_C_HEADER
#define _STLP_NATIVE_CPP_C_HEADER(header) <../../system/include/header>
#undef _STLP_NATIVE_CPP_RUNTIME_HEADER
#define _STLP_NATIVE_CPP_RUNTIME_HEADER(header) <../../system/include/header>
#endif /* mozilla_stl_config__android_h */

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

@ -109,6 +109,7 @@ def build_gcc(stage_dir, is_stage_one):
"--with-mpfr=%s" % lib_inst_dir,
"--with-mpc=%s" % lib_inst_dir,
"--enable-languages=c,c++",
"--disable-lto",
"--disable-multilib",
"--disable-bootstrap"]
if is_stage_one:

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

@ -691,6 +691,7 @@ ANDROID_PLATFORM = @ANDROID_PLATFORM@
ANDROID_SDK = @ANDROID_SDK@
ANDROID_PLATFORM_TOOLS = @ANDROID_PLATFORM_TOOLS@
ANDROID_VERSION = @ANDROID_VERSION@
STLPORT_SOURCES = @STLPORT_SOURCES@
ANDROID_PACKAGE_NAME = @ANDROID_PACKAGE_NAME@

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

@ -1616,9 +1616,10 @@ if test "$OS_TARGET" = "Android" -a -z "$gonkdir"; then
STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/gnu-libstdc++/include -I$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH/include -D_GLIBCXX_PERMIT_BACKWARD_HASH"
STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/gnu-libstdc++/libs/$ANDROID_CPU_ARCH"
STLPORT_LIBS="-lstdc++"
elif test -e "$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a" ; then
STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/stlport/stlport"
STLPORT_LDFLAGS="-L$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
elif test -e "$android_ndk/sources/cxx-stl/stlport/src/iostream.cpp" ; then
STLPORT_SOURCES="$android_ndk/sources/cxx-stl/stlport"
STLPORT_CPPFLAGS="-I$_objdir/build/stlport -I$android_ndk/sources/cxx-stl/stlport/stlport"
STLPORT_LDFLAGS="-L$_objdir/build/stlport -L$android_ndk/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/"
STLPORT_LIBS="-lstlport_static"
elif test -e "$android_ndk/tmp/ndk-digit/build/install/sources/cxx-stl/stlport/libs/$ANDROID_CPU_ARCH/libstlport_static.a" ; then
STLPORT_CPPFLAGS="-I$android_ndk/sources/cxx-stl/stlport/stlport"
@ -1633,6 +1634,8 @@ if test "$OS_TARGET" = "Android" -a -z "$gonkdir"; then
LIBS="$LIBS $STLPORT_LIBS"
fi
AC_SUBST([STLPORT_SOURCES])
dnl ========================================================
dnl Suppress Clang Argument Warnings
dnl ========================================================
@ -7228,13 +7231,11 @@ dnl We need to wrap dlopen and related functions on Android because we use
dnl our own linker.
if test "$OS_TARGET" = Android; then
WRAP_LDFLAGS="${WRAP_LDFLAGS} -L$_objdir/dist/lib -lmozglue"
if test "$MOZ_WIDGET_TOOLKIT" = android; then
if test -n "$MOZ_OLD_LINKER"; then
WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=dlopen,--wrap=dlclose,--wrap=dlerror,--wrap=dlsym,--wrap=dladdr"
fi
WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork"
if test -n "$MOZ_OLD_LINKER"; then
WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=dlopen,--wrap=dlclose,--wrap=dlerror,--wrap=dlsym,--wrap=dladdr"
fi
WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=getaddrinfo,--wrap=freeaddrinfo,--wrap=gai_strerror"
WRAP_LDFLAGS="${WRAP_LDFLAGS} -Wl,--wrap=fork,--wrap=pthread_atfork"
fi
dnl ========================================================
@ -9107,6 +9108,9 @@ if test -n "$MOZ_GLUE_PROGRAM_LDFLAGS"; then
export MOZ_GLUE_PROGRAM_LDFLAGS
fi
export MOZ_APP_NAME
export STLPORT_CPPFLAGS
export STLPORT_LDFLAGS
export STLPORT_LIBS
AC_OUTPUT_SUBDIRS(js/src)
ac_configure_args="$_SUBDIR_CONFIG_ARGS"

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

@ -1248,13 +1248,14 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI,
// Only do a URI equality check for things that aren't stopped plugins.
// This is because we still need to load again if the plugin has been stopped.
if (mType == eType_Document || mType == eType_Image || mInstanceOwner) {
if (mURI && aURI && !aForceLoad) {
if (mURI && aURI) {
bool equal;
nsresult rv = mURI->Equals(aURI, &equal);
if (NS_SUCCEEDED(rv) && equal) {
if (NS_SUCCEEDED(rv) && equal && !aForceLoad) {
// URI didn't change, do nothing
return NS_OK;
}
StopPluginInstance();
}
}

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

@ -417,8 +417,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
return false;
}
nsIScriptContext *context = globalObject->GetScriptContext(
nsIProgrammingLanguage::JAVASCRIPT);
nsIScriptContext *context = globalObject->GetScriptContext();
// If scripts aren't enabled in the current context, there's no
// point in going on.
@ -890,14 +889,14 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
PRUint32 stid = scriptContent ? scriptContent->GetScriptTypeID() :
nsIProgrammingLanguage::JAVASCRIPT;
// and make sure we are setup for this type of script.
rv = globalObject->EnsureScriptEnvironment(stid);
rv = globalObject->EnsureScriptEnvironment();
if (NS_FAILED(rv))
return rv;
// Make sure context is a strong reference since we access it after
// we've executed a script, which may cause all other references to
// the context to go away.
nsCOMPtr<nsIScriptContext> context = globalObject->GetScriptContext(stid);
nsCOMPtr<nsIScriptContext> context = globalObject->GetScriptContext();
if (!context) {
return NS_ERROR_FAILURE;
}

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

@ -67,6 +67,10 @@ class nsICanvasElementExternal : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASELEMENTEXTERNAL_IID)
enum {
RenderFlagPremultAlpha = 0x1
};
/**
* Get the size in pixels of this canvas element
*/
@ -77,7 +81,8 @@ public:
* to the given gfxContext at the origin of its coordinate space.
*/
NS_IMETHOD RenderContextsExternal(gfxContext *ctx,
gfxPattern::GraphicsFilter aFilter) = 0;
gfxPattern::GraphicsFilter aFilter,
PRUint32 aFlags = RenderFlagPremultAlpha) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsICanvasElementExternal, NS_ICANVASELEMENTEXTERNAL_IID)

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

@ -74,6 +74,10 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASRENDERINGCONTEXTINTERNAL_IID)
enum {
RenderFlagPremultAlpha = 0x1
};
// This method should NOT hold a ref to aParentCanvas; it will be called
// with nsnull when the element is going away.
NS_IMETHOD SetCanvasElement(nsHTMLCanvasElement* aParentCanvas) = 0;
@ -85,7 +89,9 @@ public:
NS_IMETHOD InitializeWithSurface(nsIDocShell *docShell, gfxASurface *surface, PRInt32 width, PRInt32 height) = 0;
// Render the canvas at the origin of the given gfxContext
NS_IMETHOD Render(gfxContext *ctx, gfxPattern::GraphicsFilter aFilter) = 0;
NS_IMETHOD Render(gfxContext *ctx,
gfxPattern::GraphicsFilter aFilter,
PRUint32 aFlags = RenderFlagPremultAlpha) = 0;
// Gives you a stream containing the image represented by this context.
// The format is given in aMimeTime, for example "image/png".

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

@ -561,7 +561,7 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
}
NS_IMETHODIMP
WebGLContext::Render(gfxContext *ctx, gfxPattern::GraphicsFilter f)
WebGLContext::Render(gfxContext *ctx, gfxPattern::GraphicsFilter f, PRUint32 aFlags)
{
if (!gl)
return NS_OK;
@ -572,7 +572,15 @@ WebGLContext::Render(gfxContext *ctx, gfxPattern::GraphicsFilter f)
return NS_ERROR_FAILURE;
gl->ReadPixelsIntoImageSurface(0, 0, mWidth, mHeight, surf);
gfxUtils::PremultiplyImageSurface(surf);
bool srcPremultAlpha = mOptions.premultipliedAlpha;
bool dstPremultAlpha = aFlags & RenderFlagPremultAlpha;
if (!srcPremultAlpha && dstPremultAlpha) {
gfxUtils::PremultiplyImageSurface(surf);
} else if (srcPremultAlpha && !dstPremultAlpha) {
gfxUtils::UnpremultiplyImageSurface(surf);
}
nsRefPtr<gfxPattern> pat = new gfxPattern(surf);
pat->SetFilter(f);
@ -608,7 +616,8 @@ WebGLContext::GetInputStream(const char* aMimeType,
nsRefPtr<gfxContext> tmpcx = new gfxContext(surf);
// Use Render() to make sure that appropriate y-flip gets applied
nsresult rv = Render(tmpcx, gfxPattern::FILTER_NEAREST);
PRUint32 flags = mOptions.premultipliedAlpha ? RenderFlagPremultAlpha : 0;
nsresult rv = Render(tmpcx, gfxPattern::FILTER_NEAREST, flags);
if (NS_FAILED(rv))
return rv;
@ -625,11 +634,22 @@ WebGLContext::GetInputStream(const char* aMimeType,
if (!encoder)
return NS_ERROR_FAILURE;
int format = imgIEncoder::INPUT_FORMAT_HOSTARGB;
if (!mOptions.premultipliedAlpha) {
// We need to convert to INPUT_FORMAT_RGBA, otherwise
// we are automatically considered premult, and unpremult'd.
// Yes, it is THAT silly.
// Except for different lossy conversions by color,
// we could probably just change the label, and not change the data.
gfxUtils::ConvertBGRAtoRGBA(surf);
format = imgIEncoder::INPUT_FORMAT_RGBA;
}
rv = encoder->InitFromData(surf->Data(),
mWidth * mHeight * 4,
mWidth, mHeight,
surf->Stride(),
imgIEncoder::INPUT_FORMAT_HOSTARGB,
format,
nsDependentString(aEncoderOptions));
NS_ENSURE_SUCCESS(rv, rv);

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

@ -542,7 +542,9 @@ public:
{ return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD Reset()
{ /* (InitializeWithSurface) */ return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD Render(gfxContext *ctx, gfxPattern::GraphicsFilter f);
NS_IMETHOD Render(gfxContext *ctx,
gfxPattern::GraphicsFilter f,
PRUint32 aFlags = RenderFlagPremultAlpha);
NS_IMETHOD GetInputStream(const char* aMimeType,
const PRUnichar* aEncoderOptions,
nsIInputStream **aStream);

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

@ -351,7 +351,9 @@ public:
void Initialize(nsIDocShell *shell, PRInt32 width, PRInt32 height);
NS_IMETHOD InitializeWithSurface(nsIDocShell *shell, gfxASurface *surface, PRInt32 width, PRInt32 height);
bool EnsureSurface();
NS_IMETHOD Render(gfxContext *ctx, gfxPattern::GraphicsFilter aFilter);
NS_IMETHOD Render(gfxContext *ctx,
gfxPattern::GraphicsFilter aFilter,
PRUint32 aFlags = RenderFlagPremultAlpha);
NS_IMETHOD GetInputStream(const char* aMimeType,
const PRUnichar* aEncoderOptions,
nsIInputStream **aStream);
@ -1278,7 +1280,7 @@ nsCanvasRenderingContext2D::SetIsIPC(bool isIPC)
}
NS_IMETHODIMP
nsCanvasRenderingContext2D::Render(gfxContext *ctx, gfxPattern::GraphicsFilter aFilter)
nsCanvasRenderingContext2D::Render(gfxContext *ctx, gfxPattern::GraphicsFilter aFilter, PRUint32 aFlags)
{
nsresult rv = NS_OK;
@ -1303,6 +1305,14 @@ nsCanvasRenderingContext2D::Render(gfxContext *ctx, gfxPattern::GraphicsFilter a
if (mOpaque)
ctx->SetOperator(op);
if (!(aFlags & RenderFlagPremultAlpha)) {
nsRefPtr<gfxASurface> curSurface = ctx->CurrentSurface();
nsRefPtr<gfxImageSurface> gis = curSurface->GetAsImageSurface();
NS_ABORT_IF_FALSE(gis, "If non-premult alpha, must be able to get image surface!");
gfxUtils::UnpremultiplyImageSurface(gis);
}
return rv;
}

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

@ -406,7 +406,9 @@ public:
NS_IMETHOD InitializeWithSurface(nsIDocShell *shell, gfxASurface *surface, PRInt32 width, PRInt32 height)
{ return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHOD Render(gfxContext *ctx, gfxPattern::GraphicsFilter aFilter);
NS_IMETHOD Render(gfxContext *ctx,
gfxPattern::GraphicsFilter aFilter,
PRUint32 aFlags = RenderFlagPremultAlpha);
NS_IMETHOD GetInputStream(const char* aMimeType,
const PRUnichar* aEncoderOptions,
nsIInputStream **aStream);
@ -1382,7 +1384,7 @@ nsCanvasRenderingContext2DAzure::SetIsIPC(bool isIPC)
}
NS_IMETHODIMP
nsCanvasRenderingContext2DAzure::Render(gfxContext *ctx, gfxPattern::GraphicsFilter aFilter)
nsCanvasRenderingContext2DAzure::Render(gfxContext *ctx, gfxPattern::GraphicsFilter aFilter, PRUint32 aFlags)
{
nsresult rv = NS_OK;
@ -1414,6 +1416,14 @@ nsCanvasRenderingContext2DAzure::Render(gfxContext *ctx, gfxPattern::GraphicsFil
if (mOpaque)
ctx->SetOperator(op);
if (!(aFlags & RenderFlagPremultAlpha)) {
nsRefPtr<gfxASurface> curSurface = ctx->CurrentSurface();
nsRefPtr<gfxImageSurface> gis = curSurface->GetAsImageSurface();
NS_ABORT_IF_FALSE(gis, "If non-premult alpha, must be able to get image surface!");
gfxUtils::UnpremultiplyImageSurface(gis);
}
return rv;
}

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

@ -1,4 +1,3 @@
conformance/context/premultiplyalpha-test.html
conformance/misc/uninitialized-test.html
conformance/programs/gl-get-active-attribute.html
conformance/textures/texture-mips.html

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

@ -1,4 +1,3 @@
conformance/context/premultiplyalpha-test.html
conformance/glsl/misc/glsl-function-nodes.html
conformance/more/conformance/quickCheckAPI-S_V.html
conformance/programs/program-test.html

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

@ -1,4 +1,3 @@
conformance/context/premultiplyalpha-test.html
conformance/glsl/functions/glsl-function-atan.html
conformance/glsl/functions/glsl-function-atan-xy.html
conformance/more/conformance/quickCheckAPI-S_V.html

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

@ -532,12 +532,12 @@ nsEventListenerManager::AddScriptEventListener(nsIAtom *aName,
// This might be the first reference to this language in the global
// We must init the language before we attempt to fetch its context.
if (NS_FAILED(global->EnsureScriptEnvironment(aLanguage))) {
if (NS_FAILED(global->EnsureScriptEnvironment())) {
NS_WARNING("Failed to setup script environment for this language");
// but fall through and let the inevitable failure below handle it.
}
nsIScriptContext* context = global->GetScriptContext(aLanguage);
nsIScriptContext* context = global->GetScriptContext();
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
JSObject* scope = global->GetGlobalJSObject();

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

@ -142,7 +142,9 @@ public:
* nsICanvasElementExternal -- for use outside of content/layout
*/
NS_IMETHOD_(nsIntSize) GetSizeExternal();
NS_IMETHOD RenderContextsExternal(gfxContext *aContext, gfxPattern::GraphicsFilter aFilter);
NS_IMETHOD RenderContextsExternal(gfxContext *aContext,
gfxPattern::GraphicsFilter aFilter,
PRUint32 aFlags = RenderFlagPremultAlpha);
virtual bool ParseAttribute(PRInt32 aNamespaceID,
nsIAtom* aAttribute,

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

@ -794,12 +794,12 @@ nsHTMLCanvasElement::GetSizeExternal()
}
NS_IMETHODIMP
nsHTMLCanvasElement::RenderContextsExternal(gfxContext *aContext, gfxPattern::GraphicsFilter aFilter)
nsHTMLCanvasElement::RenderContextsExternal(gfxContext *aContext, gfxPattern::GraphicsFilter aFilter, PRUint32 aFlags)
{
if (!mCurrentContext)
return NS_OK;
return mCurrentContext->Render(aContext, aFilter);
return mCurrentContext->Render(aContext, aFilter, aFlags);
}
nsresult NS_NewCanvasRenderingContext2DThebes(nsIDOMCanvasRenderingContext2D** aResult);

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

@ -855,6 +855,10 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
}
UpdateEditableState(aNotify);
nsTextEditorState *state = GetEditorState();
if (state) {
state->UpdateEditableState(aNotify);
}
UpdateState(aNotify);
}

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

@ -1293,6 +1293,7 @@ nsHTMLTextAreaElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
if (aName == nsGkAtoms::readonly) {
UpdateEditableState(aNotify);
mState->UpdateEditableState(aNotify);
}
UpdateState(aNotify);
}

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

@ -44,6 +44,7 @@
#include "nsITextControlElement.h"
#include "nsITextControlFrame.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIContent.h"
class nsTextInputListener;
class nsTextControlFrame;
@ -238,6 +239,12 @@ public:
void WillInitEagerly() { mSelectionRestoreEagerInit = true; }
bool HasNeverInitializedBefore() const { return !mEverInited; }
void UpdateEditableState(bool aNotify) {
if (mRootNode) {
mRootNode->UpdateEditableState(aNotify);
}
}
private:
friend class RestoreSelectionState;

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

@ -2681,8 +2681,8 @@ nsHTMLDocument::EditingStateChanged()
rv = LoadChromeSheetSync(uri, true, getter_AddRefs(sheet));
NS_ENSURE_TRUE(sheet, rv);
rv = agentSheets.AppendObject(sheet);
NS_ENSURE_SUCCESS(rv, rv);
bool result = agentSheets.AppendObject(sheet);
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
// Should we update the editable state of all the nodes in the document? We
// need to do this when the designMode value changes, as that overrides
@ -2695,8 +2695,8 @@ nsHTMLDocument::EditingStateChanged()
rv = LoadChromeSheetSync(uri, true, getter_AddRefs(sheet));
NS_ENSURE_TRUE(sheet, rv);
rv = agentSheets.AppendObject(sheet);
NS_ENSURE_SUCCESS(rv, rv);
result = agentSheets.AppendObject(sheet);
NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
// Disable scripting and plugins.
rv = editSession->DisableJSAndPlugins(window);

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

@ -78,8 +78,8 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
// nsIScriptGlobalObject methods
virtual nsresult EnsureScriptEnvironment(PRUint32 aLangID);
virtual nsresult SetScriptContext(PRUint32 lang_id, nsIScriptContext *aContext);
virtual nsresult EnsureScriptEnvironment();
virtual nsresult SetScriptContext(nsIScriptContext *aContext);
virtual nsIScriptContext *GetContext();
virtual JSObject *GetGlobalJSObject();
@ -103,10 +103,10 @@ protected:
virtual ~nsXBLDocGlobalObject();
void SetContext(nsIScriptContext *aContext);
nsIScriptContext *GetScriptContext(PRUint32 language);
nsIScriptContext *GetScriptContext();
nsCOMPtr<nsIScriptContext> mScriptContext;
JSObject *mJSObject; // XXX JS language rabies bigotry badness
JSObject *mJSObject;
nsIScriptGlobalObjectOwner* mGlobalObjectOwner; // weak reference
static JSClass gSharedGlobalClass;
@ -282,28 +282,21 @@ nsXBLDocGlobalObject::SetContext(nsIScriptContext *aScriptContext)
}
nsresult
nsXBLDocGlobalObject::SetScriptContext(PRUint32 lang_id, nsIScriptContext *aContext)
nsXBLDocGlobalObject::SetScriptContext(nsIScriptContext *aContext)
{
NS_ASSERTION(lang_id == nsIProgrammingLanguage::JAVASCRIPT, "Only JS allowed!");
SetContext(aContext);
return NS_OK;
}
nsIScriptContext *
nsXBLDocGlobalObject::GetScriptContext(PRUint32 language)
nsXBLDocGlobalObject::GetScriptContext()
{
// This impl still assumes JS
NS_ENSURE_TRUE(language==nsIProgrammingLanguage::JAVASCRIPT, nsnull);
return GetContext();
}
nsresult
nsXBLDocGlobalObject::EnsureScriptEnvironment(PRUint32 aLangID)
nsXBLDocGlobalObject::EnsureScriptEnvironment()
{
if (aLangID != nsIProgrammingLanguage::JAVASCRIPT) {
NS_WARNING("XBL still JS only");
return NS_ERROR_INVALID_ARG;
}
if (mScriptContext)
return NS_OK; // already initialized for this lang
nsCOMPtr<nsIDOMScriptObjectFactory> factory = do_GetService(kDOMScriptObjectFactoryCID);
@ -312,10 +305,11 @@ nsXBLDocGlobalObject::EnsureScriptEnvironment(PRUint32 aLangID)
nsresult rv;
nsCOMPtr<nsIScriptRuntime> scriptRuntime;
rv = NS_GetScriptRuntimeByID(aLangID, getter_AddRefs(scriptRuntime));
rv = NS_GetScriptRuntimeByID(nsIProgrammingLanguage::JAVASCRIPT,
getter_AddRefs(scriptRuntime));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIScriptContext> newCtx = scriptRuntime->CreateContext();
rv = SetScriptContext(aLangID, newCtx);
rv = SetScriptContext(newCtx);
JSContext *cx = mScriptContext->GetNativeContext();
JSAutoRequest ar(cx);
@ -347,7 +341,7 @@ nsXBLDocGlobalObject::GetContext()
// This whole fragile mess is predicated on the fact that
// GetContext() will be called before GetScriptObject() is.
if (! mScriptContext) {
nsresult rv = EnsureScriptEnvironment(nsIProgrammingLanguage::JAVASCRIPT);
nsresult rv = EnsureScriptEnvironment();
// JS is builtin so we make noise if it fails to initialize.
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to setup JS!?");
NS_ENSURE_SUCCESS(rv, nsnull);
@ -563,7 +557,7 @@ nsXBLDocumentInfo::~nsXBLDocumentInfo()
/* destructor code */
if (mGlobalObject) {
// remove circular reference
mGlobalObject->SetScriptContext(nsIProgrammingLanguage::JAVASCRIPT, nsnull);
mGlobalObject->SetScriptContext(nsnull);
mGlobalObject->ClearGlobalObjectOwner(); // just in case
}
if (mBindingTable) {

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

@ -301,8 +301,7 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventTarget* aTarget,
if (!boundGlobal)
return NS_OK;
nsIScriptContext *boundContext =
boundGlobal->GetScriptContext(nsIProgrammingLanguage::JAVASCRIPT);
nsIScriptContext *boundContext = boundGlobal->GetScriptContext();
if (!boundContext)
return NS_OK;

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

@ -771,7 +771,7 @@ nsScriptEventHandlerOwnerTearoff::CompileEventHandler(
nsIScriptGlobalObject* global = globalOwner->GetScriptGlobalObject();
NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);
context = global->GetScriptContext(aContext->GetScriptTypeID());
context = global->GetScriptContext();
// It could be possible the language has been setup on aContext but
// not on the global - we don't demand-create language contexts on the
// nsGlobalWindow
@ -2943,8 +2943,7 @@ nsXULPrototypeScript::Serialize(nsIObjectOutputStream* aStream,
nsIScriptGlobalObject* aGlobal,
const nsCOMArray<nsINodeInfo> *aNodeInfos)
{
nsIScriptContext *context = aGlobal->GetScriptContext(
mScriptObject.mLangID);
nsIScriptContext *context = aGlobal->GetScriptContext();
NS_ASSERTION(!mSrcLoading || mSrcLoadWaiters != nsnull ||
!mScriptObject.mObject,
"script source still loading when serializing?!");
@ -3022,8 +3021,7 @@ nsXULPrototypeScript::Deserialize(nsIObjectInputStream* aStream,
aStream->Read32(&mLineNo);
aStream->Read32(&mLangVersion);
nsIScriptContext *context = aGlobal->GetScriptContext(
mScriptObject.mLangID);
nsIScriptContext *context = aGlobal->GetScriptContext();
NS_ASSERTION(context != nsnull, "Have no context for deserialization");
NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
nsScriptObjectHolder<JSScript> newScriptObject(context);
@ -3151,7 +3149,7 @@ nsXULPrototypeScript::Compile(const PRUnichar* aText,
if (! global)
return NS_ERROR_UNEXPECTED;
context = global->GetScriptContext(mScriptObject.mLangID);
context = global->GetScriptContext();
NS_ASSERTION(context != nsnull, "no context for script global");
if (! context)
return NS_ERROR_UNEXPECTED;

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

@ -3553,9 +3553,8 @@ nsXULDocument::OnStreamComplete(nsIStreamLoader* aLoader,
NS_ASSERTION(global != nsnull, "master prototype w/o global?!");
if (global) {
PRUint32 stid = scriptProto->mScriptObject.mLangID;
nsIScriptContext *scriptContext = \
global->GetScriptContext(stid);
global->GetScriptContext();
NS_ASSERTION(scriptContext != nsnull,
"Failed to get script context for language");
if (scriptContext)
@ -3619,14 +3618,13 @@ nsXULDocument::ExecuteScript(nsXULPrototypeScript *aScript)
NS_PRECONDITION(aScript != nsnull, "null ptr");
NS_ENSURE_TRUE(aScript, NS_ERROR_NULL_POINTER);
NS_ENSURE_TRUE(mScriptGlobalObject, NS_ERROR_NOT_INITIALIZED);
PRUint32 stid = aScript->mScriptObject.mLangID;
nsresult rv;
rv = mScriptGlobalObject->EnsureScriptEnvironment(stid);
rv = mScriptGlobalObject->EnsureScriptEnvironment();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIScriptContext> context =
mScriptGlobalObject->GetScriptContext(stid);
mScriptGlobalObject->GetScriptContext();
// failure getting a script context is fatal.
NS_ENSURE_TRUE(context != nsnull, NS_ERROR_UNEXPECTED);

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

@ -85,10 +85,10 @@ public:
virtual void SetScriptsEnabled(bool aEnabled, bool aFireTimeouts);
virtual JSObject* GetGlobalJSObject();
virtual nsresult EnsureScriptEnvironment(PRUint32 aLangID);
virtual nsresult EnsureScriptEnvironment();
virtual nsIScriptContext *GetScriptContext(PRUint32 lang);
virtual nsresult SetScriptContext(PRUint32 language, nsIScriptContext *ctx);
virtual nsIScriptContext *GetScriptContext();
virtual nsresult SetScriptContext(nsIScriptContext *ctx);
// nsIScriptObjectPrincipal methods
virtual nsIPrincipal* GetPrincipal();
@ -683,10 +683,8 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsXULPDGlobalObject)
//
nsresult
nsXULPDGlobalObject::SetScriptContext(PRUint32 lang_id, nsIScriptContext *aScriptContext)
nsXULPDGlobalObject::SetScriptContext(nsIScriptContext *aScriptContext)
{
NS_ABORT_IF_FALSE(lang_id == nsIProgrammingLanguage::JAVASCRIPT,
"We don't support this language ID");
// almost a clone of nsGlobalWindow
if (!aScriptContext) {
NS_WARNING("Possibly early removal of script object, see bug #41608");
@ -713,10 +711,8 @@ nsXULPDGlobalObject::SetScriptContext(PRUint32 lang_id, nsIScriptContext *aScrip
}
nsresult
nsXULPDGlobalObject::EnsureScriptEnvironment(PRUint32 lang_id)
nsXULPDGlobalObject::EnsureScriptEnvironment()
{
NS_ABORT_IF_FALSE(lang_id == nsIProgrammingLanguage::JAVASCRIPT,
"We don't support this language ID");
if (mContext) {
return NS_OK;
}
@ -752,23 +748,21 @@ nsXULPDGlobalObject::EnsureScriptEnvironment(PRUint32 lang_id)
}
NS_ENSURE_SUCCESS(rv, NS_OK);
rv = SetScriptContext(lang_id, ctxNew);
rv = SetScriptContext(ctxNew);
NS_ENSURE_SUCCESS(rv, NS_OK);
return NS_OK;
}
nsIScriptContext*
nsXULPDGlobalObject::GetScriptContext(PRUint32 lang_id)
nsXULPDGlobalObject::GetScriptContext()
{
NS_ABORT_IF_FALSE(lang_id == nsIProgrammingLanguage::JAVASCRIPT,
"We don't support this language ID");
// This global object creates a context on demand - do that now.
nsresult rv = EnsureScriptEnvironment(nsIProgrammingLanguage::JAVASCRIPT);
nsresult rv = EnsureScriptEnvironment();
if (NS_FAILED(rv)) {
NS_ERROR("Failed to setup script language");
return NULL;
}
// Note that EnsureScriptEnvironment has validated lang_id
return mContext;
}

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

@ -10850,11 +10850,9 @@ nsDocShell::EnsureScriptEnvironment()
nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(mScriptGlobal));
win->SetDocShell(static_cast<nsIDocShell *>(this));
// Ensure the script object is set to run javascript - other languages
// setup on demand.
// XXXmarkh - should this be setup to run the default language for this doc?
// Ensure the script object is set up to run script.
nsresult rv;
rv = mScriptGlobal->EnsureScriptEnvironment(nsIProgrammingLanguage::JAVASCRIPT);
rv = mScriptGlobal->EnsureScriptEnvironment();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;

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

@ -526,6 +526,7 @@ using mozilla::dom::indexedDB::IDBWrapperCache;
#ifdef MOZ_B2G_BT
#include "BluetoothAdapter.h"
#include "BluetoothDevice.h"
#endif
#include "DOMError.h"
@ -1621,6 +1622,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
#ifdef MOZ_B2G_BT
NS_DEFINE_CLASSINFO_DATA(BluetoothAdapter, nsEventTargetSH,
EVENTTARGET_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(BluetoothDevice, nsEventTargetSH,
EVENTTARGET_SCRIPTABLE_FLAGS)
#endif
NS_DEFINE_CLASSINFO_DATA(DOMError, nsDOMGenericSH,
@ -4374,6 +4377,10 @@ nsDOMClassInfo::Init()
#ifdef MOZ_B2G_BT
DOM_CLASSINFO_MAP_BEGIN(BluetoothAdapter, nsIDOMBluetoothAdapter)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothAdapter)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(BluetoothDevice, nsIDOMBluetoothDevice)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothDevice)
DOM_CLASSINFO_MAP_END
#endif

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

@ -541,6 +541,7 @@ DOMCI_CLASS(CallEvent)
#ifdef MOZ_B2G_BT
DOMCI_CLASS(BluetoothAdapter)
DOMCI_CLASS(BluetoothDevice)
#endif
DOMCI_CLASS(DOMError)

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

@ -1572,10 +1572,8 @@ nsGlobalWindow::UnmarkGrayTimers()
//*****************************************************************************
nsresult
nsGlobalWindow::SetScriptContext(PRUint32 lang_id, nsIScriptContext *aScriptContext)
nsGlobalWindow::SetScriptContext(nsIScriptContext *aScriptContext)
{
NS_ASSERTION(lang_id == nsIProgrammingLanguage::JAVASCRIPT,
"We don't support this language ID");
NS_ASSERTION(IsOuterWindow(), "Uh, SetScriptContext() called on inner window!");
NS_ASSERTION(!aScriptContext || !mContext, "Bad call to SetContext()!");
@ -1601,11 +1599,9 @@ nsGlobalWindow::SetScriptContext(PRUint32 lang_id, nsIScriptContext *aScriptCont
}
nsresult
nsGlobalWindow::EnsureScriptEnvironment(PRUint32 aLangID)
nsGlobalWindow::EnsureScriptEnvironment()
{
NS_ASSERTION(aLangID == nsIProgrammingLanguage::JAVASCRIPT,
"We don't support this language ID");
FORWARD_TO_OUTER(EnsureScriptEnvironment, (aLangID), NS_ERROR_NOT_INITIALIZED);
FORWARD_TO_OUTER(EnsureScriptEnvironment, (), NS_ERROR_NOT_INITIALIZED);
if (mJSObject)
return NS_OK;
@ -1614,20 +1610,18 @@ nsGlobalWindow::EnsureScriptEnvironment(PRUint32 aLangID)
"mJSObject is null, but we have an inner window?");
nsCOMPtr<nsIScriptRuntime> scriptRuntime;
nsresult rv = NS_GetScriptRuntimeByID(aLangID, getter_AddRefs(scriptRuntime));
nsresult rv = NS_GetScriptRuntimeByID(nsIProgrammingLanguage::JAVASCRIPT,
getter_AddRefs(scriptRuntime));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIScriptContext> context = scriptRuntime->CreateContext();
return SetScriptContext(aLangID, context);
return SetScriptContext(context);
}
nsIScriptContext *
nsGlobalWindow::GetScriptContext(PRUint32 lang)
nsGlobalWindow::GetScriptContext()
{
NS_ASSERTION(lang == nsIProgrammingLanguage::JAVASCRIPT,
"We don't support this language ID");
FORWARD_TO_OUTER(GetScriptContext, (lang), nsnull);
FORWARD_TO_OUTER(GetScriptContext, (), nsnull);
return mContext;
}
@ -1637,7 +1631,7 @@ nsGlobalWindow::GetContext()
FORWARD_TO_OUTER(GetContext, (), nsnull);
// check GetContext is indeed identical to GetScriptContext()
NS_ASSERTION(mContext == GetScriptContext(nsIProgrammingLanguage::JAVASCRIPT),
NS_ASSERTION(mContext == GetScriptContext(),
"GetContext confused?");
return mContext;
}

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

@ -317,13 +317,13 @@ public:
return mJSObject;
}
virtual nsresult EnsureScriptEnvironment(PRUint32 aLangID);
virtual nsresult EnsureScriptEnvironment();
virtual nsIScriptContext *GetScriptContext(PRUint32 lang);
virtual nsIScriptContext *GetScriptContext();
// Set a new script language context for this global. The native global
// for the context is created by the context's GetNativeGlobal() method.
virtual nsresult SetScriptContext(PRUint32 lang, nsIScriptContext *aContext);
virtual nsresult SetScriptContext(nsIScriptContext *aContext);
virtual void OnFinalize(JSObject* aObject);
virtual void SetScriptsEnabled(bool aEnabled, bool aFireTimeouts);

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

@ -122,16 +122,16 @@ public:
* has not been registered, as well as 'normal' errors, such as
* out-of-memory
*/
virtual nsresult EnsureScriptEnvironment(PRUint32 aLangID) = 0;
virtual nsresult EnsureScriptEnvironment() = 0;
/**
* Get a script context (WITHOUT added reference) for the specified language.
*/
virtual nsIScriptContext *GetScriptContext(PRUint32 lang) = 0;
virtual nsIScriptContext *GetScriptContext() = 0;
virtual JSObject* GetGlobalJSObject() = 0;
virtual nsIScriptContext *GetContext() {
return GetScriptContext(nsIProgrammingLanguage::JAVASCRIPT);
return GetScriptContext();
}
/**
@ -139,7 +139,7 @@ public:
* context is created by the context's GetNativeGlobal() method.
*/
virtual nsresult SetScriptContext(PRUint32 lang, nsIScriptContext *aContext) = 0;
virtual nsresult SetScriptContext(nsIScriptContext *aContext) = 0;
/**
* Called when the global script for a language is finalized, typically as

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

@ -143,7 +143,7 @@ nsJSUtils::GetStaticScriptContext(JSContext* aContext, JSObject* aObj)
if (!nativeGlobal)
return nsnull;
return nativeGlobal->GetScriptContext(nsIProgrammingLanguage::JAVASCRIPT);
return nativeGlobal->GetScriptContext();
}
nsIScriptGlobalObject *

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

@ -0,0 +1,154 @@
/* 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 "BluetoothDevice.h"
#include "nsDOMClassInfo.h"
USING_BLUETOOTH_NAMESPACE
DOMCI_DATA(BluetoothDevice, BluetoothDevice)
NS_IMPL_CYCLE_COLLECTION_CLASS(BluetoothDevice)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(BluetoothDevice,
nsDOMEventTargetHelper)
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(propertychanged)
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(disconnectrequested)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BluetoothDevice,
nsDOMEventTargetHelper)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(propertychanged)
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(disconnectrequested)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothDevice)
NS_INTERFACE_MAP_ENTRY(nsIDOMBluetoothDevice)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMBluetoothDevice)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(BluetoothDevice)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(BluetoothDevice, nsDOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(BluetoothDevice, nsDOMEventTargetHelper)
BluetoothDevice::BluetoothDevice()
{
}
nsresult
BluetoothDevice::GetAdapter(nsAString& aAdapter)
{
aAdapter = mAdapter;
return NS_OK;
}
nsresult
BluetoothDevice::GetAddress(nsAString& aAddress)
{
aAddress = mAddress;
return NS_OK;
}
nsresult
BluetoothDevice::GetName(nsAString& aName)
{
aName = mName;
return NS_OK;
}
nsresult
BluetoothDevice::GetClass(PRUint32* aClass)
{
*aClass = mClass;
return NS_OK;
}
nsresult
BluetoothDevice::GetConnected(bool* aConnected)
{
*aConnected = mConnected;
return NS_OK;
}
nsresult
BluetoothDevice::GetPaired(bool* aPaired)
{
*aPaired = mPaired;
return NS_OK;
}
nsresult
BluetoothDevice::GetLegacyPairing(bool* aLegacyPairing)
{
*aLegacyPairing = mLegacyPairing;
return NS_OK;
}
nsresult
BluetoothDevice::GetTrusted(bool* aTrusted)
{
*aTrusted = mTrusted;
return NS_OK;
}
nsresult
BluetoothDevice::SetTrusted(bool aTrusted)
{
mTrusted = aTrusted;
return NS_OK;
}
nsresult
BluetoothDevice::GetAlias(nsAString& aAlias)
{
aAlias = mAlias;
return NS_OK;
}
nsresult
BluetoothDevice::SetAlias(const nsAString& aAlias)
{
mAlias = aAlias;
return NS_OK;
}
nsresult
BluetoothDevice::GetUuids(jsval* aUuids)
{
//TODO: convert mUuids to jsval and assign to aUuids;
return NS_OK;
}
nsresult
BluetoothDevice::Disconnect()
{
return NS_OK;
}
nsresult
BluetoothDevice::GetProperties(jsval* aProperties)
{
return NS_OK;
}
nsresult
BluetoothDevice::SetProperty(const nsAString& aName, const nsAString& aValue)
{
return NS_OK;
}
nsresult
BluetoothDevice::DiscoverServices(const nsAString& aPattern, jsval* aServices)
{
return NS_OK;
}
nsresult
BluetoothDevice::CancelDiscovery()
{
return NS_OK;
}
NS_IMPL_EVENT_HANDLER(BluetoothDevice, propertychanged)
NS_IMPL_EVENT_HANDLER(BluetoothDevice, disconnectrequested)

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

@ -0,0 +1,48 @@
/* 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 mozilla_dom_bluetooth_bluetoothdevice_h__
#define mozilla_dom_bluetooth_bluetoothdevice_h__
#include "BluetoothCommon.h"
#include "nsDOMEventTargetHelper.h"
#include "nsIDOMBluetoothDevice.h"
#include "nsString.h"
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothDevice : public nsIDOMBluetoothDevice
, public nsDOMEventTargetHelper
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMBLUETOOTHDEVICE
NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(BluetoothDevice,
nsDOMEventTargetHelper)
BluetoothDevice();
protected:
nsString mAdapter;
nsString mAddress;
PRUint32 mClass;
bool mConnected;
bool mLegacyPairing;
nsString mName;
bool mPaired;
nsTArray<nsString> mUuids;
bool mTrusted;
nsString mAlias;
NS_DECL_EVENT_HANDLER(propertychanged)
NS_DECL_EVENT_HANDLER(disconnectrequested)
};
END_BLUETOOTH_NAMESPACE
#endif

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

@ -19,11 +19,13 @@ include $(topsrcdir)/dom/dom-config.mk
CPPSRCS = \
BluetoothAdapter.cpp \
BluetoothDevice.cpp \
$(NULL)
XPIDLSRCS = \
nsIDOMNavigatorBluetooth.idl \
nsIDOMBluetoothAdapter.idl \
nsIDOMBluetoothDevice.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,30 @@
/* 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 "nsIDOMEventTarget.idl"
[scriptable, builtinclass, uuid(2da61f89-a7d2-4f7d-9f4c-fb8a99d9add2)]
interface nsIDOMBluetoothDevice : nsIDOMEventTarget
{
readonly attribute DOMString adapter;
readonly attribute DOMString address;
readonly attribute unsigned long class;
readonly attribute boolean connected;
readonly attribute boolean legacyPairing;
readonly attribute DOMString name;
readonly attribute boolean paired;
readonly attribute jsval uuids;
attribute boolean trusted;
attribute DOMString alias;
attribute nsIDOMEventListener onpropertychanged;
attribute nsIDOMEventListener ondisconnectrequested;
void disconnect();
jsval getProperties();
void setProperty(in DOMString name, in DOMString value);
jsval discoverServices(in DOMString pattern);
void cancelDiscovery();
};

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

@ -111,6 +111,7 @@ _MOCHITEST_FILES = \
test_instance_unparent3.html \
test_pluginstream_referer.html \
plugin-stream-referer.sjs \
test_src_url_change.html \
$(NULL)
# test_plugin_scroll_painting.html \ bug 596491

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

@ -16,9 +16,17 @@
// Test with no modifications
is(p1.getNPNVdocumentOrigin(), realOrigin, "Checking for expected origin.");
// Mess with window.location.toString
window.location.toString = function() { return 'http://victim.rckc.at/'; }
is(p1.getNPNVdocumentOrigin(), realOrigin, "Checking for expected origin afer modifying window.location.toString.");
// This used to test that shadowing window.location.toString didn't confuse
// getNPNVdocumentOrigin. But now we explicitly throw when that happens. So
// just verify that we throw. There's no reason why getNPNVdocumentOrigin _would_
// be confused in this case anyway.
try {
window.location.toString = function() { return 'http://victim.rckc.at/'; }
ok(false, "Should throw when shadowing window.location.toString");
}
catch (e) {
ok(true, "Should throw when shadowing window.location.toString");
}
// Create a plugin in a new window with about:blank
var newWindow = window.open("about:blank");

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

@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<title>Test changing src attribute</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="runTests()">
<p id="display"></p>
<embed id="plugin1" src="about:blank" type="application/x-test" width="200" height="200"></embed>
<script type="application/javascript;version=1.8">
SimpleTest.waitForExplicitFinish();
var p = document.getElementById('plugin1');
var destroyed = false;
function onDestroy() {
destroyed = true;
}
function runTests() {
p.startWatchingInstanceCount();
p.callOnDestroy(onDestroy);
p.setAttribute("src", "loremipsum.txt");
is(destroyed, true, "Instance should have been destroyed.");
is(p.getInstanceCount(), 1, "One new instance should have been created.");
p.stopWatchingInstanceCount();
SimpleTest.finish();
}
</script>
</body>
</html>

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

@ -25,6 +25,15 @@ ok(window === orig, "can't override window");
ok(window.location === location, "properties are properly aliased");
ok(document.location === location, "properties are properly aliased");
var canDefine = false;
try {
var foo;
__defineGetter__.call(foo, 'bar', function() {});
__defineSetter__.call(foo, 'bar', function() {});
canDefine = true;
} catch (e) {}
ok(canDefine, "Should have access to __defineGetter__ and __defineSetter__");
try {
__defineGetter__('window', function() {});
ok(false, "should not be able to defineGetter(window)");
@ -32,41 +41,57 @@ try {
}
try {
window.__defineGetter__('location', function(){});
__defineGetter__.call(window, 'location', function(){});
ok(false, "should not be able to defineGetter(window.location)");
} catch (e) {
}
try {
window.location.__defineGetter__('href', function(){});
__defineGetter__.call(window.location, 'href', function(){});
ok(false, "shouldn't be able to override location.href");
} catch (e) {
ok(/shadow/.exec(e.message), "Should be caught by the anti-shadow mechanism.");
}
// Try deleting the property.
delete window.location.href;
ok(typeof window.location.href !== 'undefined',
"shouldn't be able to delete the inherited property");
delete Object.getPrototypeOf(window.location).href;
ok(typeof window.location.href !== 'undefined',
"shouldn't be able to delete the property off of the prototype");
try {
window.location.__proto__.__defineGetter__('href', function(){});
__defineGetter__.call(Object.getPrototypeOf(window.location), 'href', function(){});
ok(false, "shouldn't be able to use the prototype");
} catch (e) {
}
try {
window.location.__defineSetter__('href', function(){});
__defineSetter__.call(window.location, 'href', function(){});
ok(false, "overrode a setter for location.href?");
} catch (e) {
ok(/shadow/.exec(e.message), "Should be caught by the anti-shadow mechanism.");
}
try {
document.__defineGetter__('location', function(){});
__defineGetter__.call(document, 'location', function(){});
ok(false, "shouldn't be able to override document.location");
} catch (e) {
}
is(location.watch, undefined, "watch doesn't exist on location objects");
// Make sure watch works correctly.
var watchTest = {a: 42};
var watchHandler = function(prop, oldval, newval) { return 22; }
Object.prototype.watch.call(watchTest, 'a', watchHandler);
watchTest.a = 1;
is(watchTest.a, 22, "Watch works correctly");
// Now make sure we can't watch location.
try {
Object.prototype.watch.call(location, function() {});
Object.prototype.watch.call(location, 'href', function(prop, oldval, newval) {});
ok(false, "shouldn't be able to set a watchpoint on location");
} catch (e) {
}
} catch (e) {}
ok(window === orig, "can't override window");
ok(window.location === origLocation, "properties are properly aliased");

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

@ -73,6 +73,7 @@ _TEST_FILES = \
489127.html \
test_focus_docnav.xul \
window_focus_docnav.xul \
test_clonewrapper.xul \
$(NULL)
ifeq (WINNT,$(OS_ARCH))

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

@ -0,0 +1,126 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=667388
-->
<window title="Mozilla Bug 667388"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<!-- test code goes here -->
<script type="application/javascript">
<![CDATA[
// Setup.
SimpleTest.waitForExplicitFinish();
window.testObject = { myNumber: 42,
myDomain: window.location.domain };
// Wait for both frames to load before proceeding.
var framesLoaded = [null, false, false, false];
function onFrameLoaded(id) {
// Mark this frame as loaded.
framesLoaded[id] = true;
// Allow it to call |is|.
window.frames[id].wrappedJSObject.is = is;
// If all the frames are loaded, start the test.
if (framesLoaded[1] && framesLoaded[2] && framesLoaded[3])
startTest();
}
function startTest() {
// Test interaction between chrome and content.
runChromeContentTest(window.frames[1]);
// Try same origin.
runContentContentTest(window.frames[1], window.frames[2],
true, "Should be able to clone same-origin");
// Try cross-origin.
runContentContentTest(window.frames[2], window.frames[3],
false, "Should not be able to clone cross-origin");
// Colaborate with document.domain, then try again.
frames[2].document.domain = 'example.org';
frames[3].document.domain = 'example.org';
runContentContentTest(window.frames[2], window.frames[3],
true, "Should be able to clone cross-origin with document.domain")
SimpleTest.finish();
}
// Tests cloning between chrome and content.
function runChromeContentTest(contentWin) {
// We should be able to clone a content object.
tryToClone(contentWin.wrappedJSObject.testObject,
true,
"Chrome should be able to clone content object");
// Content should not be able to clone a chrome object.
//
// Note that because we're using |wrappedJSObject| here, the subject
// principal is clamed to the principal of the iframe, which is what we want.
contentWin.wrappedJSObject.tryToClone(window.testObject, false,
"Content should not be able to clone chrome object");
}
// Test cloning between content and content.
//
// Note - the way we do this is kind of sketchy. Because we're grabbing the
// test object from win1 by waiving Xray (via .wrappedJSObject), the object
// we're passing from win1 to win2 is actually the waived object (which has
// a distinct identity in the compartment of win2). So this means that we're
// actually giving win2 Xray waivers to win1! This doesn't affect things as
// long as the security wrappers check documentDomainMakesSameOrigin directly
// for the puncture case rather than checking IsTransparent(), but it still
// gives rise to a situation that wouldn't really happen in practice.
//
// A more serious issues is that we don't/can't test the Xray wrapper path,
// because the only native objects that we successfully send through
// structured clone don't force a parent in PreCreate, and so we _can't_
// have security wrappers around them (we get a new XPCWN in each
// compartment). Since the case can't happen, we can't write tests for it.
// But when it can happen (ie, we fix PreCreate for File, FileList, Blob, etc),
// we want tests right away, because this stuff is very security-sensitive.
// So we set this test up to fail when things are fixed, so that the someone
// will notice and properly augment this test to cover native objects.
function runContentContentTest(win1, win2, shouldSucceed, msg) {
win1.wrappedJSObject.tryToClone(win2.wrappedJSObject.testObject,
shouldSucceed, msg);
var fixMsg = "If this fails, you fixed PreCreate. That's a good thing, ";
fixMsg += "but now we need some test coverage. See the above comment.";
win1.wrappedJSObject.tryToClone(win2.wrappedJSObject.blob, true, fixMsg);
win1.wrappedJSObject.tryToClone(win2.wrappedJSObject.filelist, true, fixMsg);
}
function tryToClone(obj, shouldSucceed, message) {
var success = false;
var sink = window.frames[0];
try { sink.postMessage(obj, '*'); success = true; }
catch (e) { message = message + ' (threw: ' + e.message + ')'; }
is(success, shouldSucceed, message);
}
]]>
</script>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=667388"
target="_blank">Mozilla Bug 667388</a>
<iframe id="sink" />
<!-- The first two are same-origin, the third is not. -->
<iframe id="frame1" onload="onFrameLoaded(1);" src="http://test1.example.org/tests/dom/tests/mochitest/general/file_clonewrapper.html" />
<iframe id="frame2" onload="onFrameLoaded(2);" src="http://test1.example.org/tests/dom/tests/mochitest/general/file_clonewrapper.html" />
<iframe id="frame3" onload="onFrameLoaded(3);" src="http://test2.example.org/tests/dom/tests/mochitest/general/file_clonewrapper.html" />
</body>
</window>

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

@ -82,6 +82,7 @@ _TEST_FILES = \
test_browserFrame7.html \
test_for_of.html \
test_focus_legend_noparent.html \
file_clonewrapper.html \
$(NULL)
_CHROME_FILES = \

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

@ -0,0 +1,29 @@
<!doctype html>
<html>
<head>
<script type="application/javascript">
// Set up the objects for cloning.
function setup() {
window.testObject = { myNumber: 42,
myDomain: window.location.domain };
window.blob = (new MozBlobBuilder()).getBlob('text/plain');
window.fileList = document.getElementById('fileinput').files;
}
// Called by the chrome parent window.
function tryToClone(obj, shouldSucceed, message) {
var success = false;
var sink = window.frames[0];
try { sink.postMessage(obj, '*'); success = true; }
catch (e) { message = message + ' (threw: ' + e.message + ')'; }
is(success, shouldSucceed, message);
}
</script>
</head>
<body onload="setup()">
<input id="fileinput" type="file"></input>
<iframe id="sink">
</body>
</html>

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

@ -676,11 +676,7 @@ nsEditorEventListener::DragOver(nsIDOMDragEvent* aDragEvent)
nsCOMPtr<nsIContent> dropParent = do_QueryInterface(parent);
NS_ENSURE_TRUE(dropParent, NS_ERROR_FAILURE);
if (!dropParent->IsEditable()) {
return NS_OK;
}
if (CanDrop(aDragEvent)) {
if (dropParent->IsEditable() && CanDrop(aDragEvent)) {
aDragEvent->PreventDefault(); // consumed
if (mCaret) {
@ -754,11 +750,7 @@ nsEditorEventListener::Drop(nsIDOMDragEvent* aMouseEvent)
nsCOMPtr<nsIContent> dropParent = do_QueryInterface(parent);
NS_ENSURE_TRUE(dropParent, NS_ERROR_FAILURE);
if (!dropParent->IsEditable()) {
return NS_OK;
}
if (!CanDrop(aMouseEvent)) {
if (!dropParent->IsEditable() || !CanDrop(aMouseEvent)) {
// was it because we're read-only?
if (mEditor->IsReadonly() || mEditor->IsDisabled())
{

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

@ -866,6 +866,8 @@ TiledTextureImage::TiledTextureImage(GLContext* aGL,
: TextureImage(aSize, LOCAL_GL_CLAMP_TO_EDGE, aContentType, aUseNearestFilter)
, mCurrentImage(0)
, mInUpdate(false)
, mRows(0)
, mColumns(0)
, mGL(aGL)
, mUseNearestFilter(aUseNearestFilter)
, mTextureState(Created)
@ -1114,30 +1116,98 @@ TiledTextureImage::ApplyFilter()
}
/*
* simple resize, just discards everything. we can be more clever just
* adding or discarding tiles, but do we want this?
* Resize, trying to reuse tiles. The reuse strategy is to decide on reuse per
* column. A tile on a column is reused if it hasn't changed size, otherwise it
* is discarded/replaced. Extra tiles on a column are pruned after iterating
* each column, and extra rows are pruned after iteration over the entire image
* finishes.
*/
void TiledTextureImage::Resize(const nsIntSize& aSize)
{
if (mSize == aSize && mTextureState != Created) {
return;
}
mSize = aSize;
mImages.Clear();
// calculate rows and columns, rounding up
mColumns = (aSize.width + mTileSize - 1) / mTileSize;
mRows = (aSize.height + mTileSize - 1) / mTileSize;
for (unsigned int row = 0; row < mRows; row++) {
for (unsigned int col = 0; col < mColumns; col++) {
nsIntSize size( // use tilesize first, then the remainder
(col+1) * mTileSize > (unsigned int)aSize.width ? aSize.width % mTileSize : mTileSize,
(row+1) * mTileSize > (unsigned int)aSize.height ? aSize.height % mTileSize : mTileSize);
nsRefPtr<TextureImage> teximg =
mGL->TileGenFunc(size, mContentType, mUseNearestFilter);
mImages.AppendElement(teximg.forget());
}
// calculate rows and columns, rounding up
unsigned int columns = (aSize.width + mTileSize - 1) / mTileSize;
unsigned int rows = (aSize.height + mTileSize - 1) / mTileSize;
// Iterate over old tile-store and insert/remove tiles as necessary
int row;
unsigned int i = 0;
for (row = 0; row < (int)rows; row++) {
// If we've gone beyond how many rows there were before, set mColumns to
// zero so that we only create new tiles.
if (row >= (int)mRows)
mColumns = 0;
// Similarly, if we're on the last row of old tiles and the height has
// changed, discard all tiles in that row.
// This will cause the pruning of columns not to work, but we don't need
// to worry about that, as no more tiles will be reused past this point
// anyway.
if ((row == (int)mRows - 1) && (aSize.height != mSize.height))
mColumns = 0;
int col;
for (col = 0; col < (int)columns; col++) {
nsIntSize size( // use tilesize first, then the remainder
(col+1) * mTileSize > (unsigned int)aSize.width ? aSize.width % mTileSize : mTileSize,
(row+1) * mTileSize > (unsigned int)aSize.height ? aSize.height % mTileSize : mTileSize);
bool replace = false;
// Check if we can re-use old tiles.
if (col < (int)mColumns) {
// Reuse an existing tile. If the tile is an end-tile and the
// width differs, replace it instead.
if (mSize.width != aSize.width) {
if (col == (int)mColumns - 1) {
// Tile at the end of the old column, replace it with
// a new one.
replace = true;
} else if (col == (int)columns - 1) {
// Tile at the end of the new column, create a new one.
} else {
// Before the last column on both the old and new sizes,
// reuse existing tile.
i++;
continue;
}
} else {
// Width hasn't changed, reuse existing tile.
i++;
continue;
}
}
// Create a new tile.
nsRefPtr<TextureImage> teximg =
mGL->TileGenFunc(size, mContentType, mUseNearestFilter);
if (replace)
mImages.ReplaceElementAt(i, teximg.forget());
else
mImages.InsertElementAt(i, teximg.forget());
i++;
}
// Prune any unused tiles on the end of the column.
if (row < (int)mRows) {
for (col = (int)mColumns - col; col > 0; col--) {
mImages.RemoveElementAt(i);
}
}
}
// Prune any unused tiles at the end of the store.
unsigned int length = mImages.Length();
for (; i < length; i++)
mImages.RemoveElementAt(mImages.Length()-1);
// Reset tile-store properties.
mRows = rows;
mColumns = columns;
mSize = aSize;
mTextureState = Allocated;
}

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

@ -184,6 +184,8 @@ struct THEBES_API gfxRGBA {
* The color value is interpreted based on colorType;
* all values use the native platform endianness.
*
* Resulting gfxRGBA stores non-premultiplied data.
*
* @see gfxRGBA::Packed
*/
gfxRGBA(PRUint32 c, PackedColorType colorType = PACKED_ABGR) {

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

@ -1935,6 +1935,10 @@ gfxFont::GetShapedWord(gfxContext *aContext,
aFlags);
CacheHashEntry *entry = mWordCache.PutEntry(key);
if (!entry) {
NS_WARNING("failed to create word cache entry - expect missing text");
return nsnull;
}
gfxShapedWord *sw = entry->mShapedWord;
Telemetry::Accumulate(Telemetry::WORD_CACHE_LOOKUP_LEN, aLength);
Telemetry::Accumulate(Telemetry::WORD_CACHE_LOOKUP_SCRIPT, aRunScript);
@ -1950,20 +1954,21 @@ gfxFont::GetShapedWord(gfxContext *aContext,
aRunScript,
aAppUnitsPerDevUnit,
aFlags);
NS_ASSERTION(sw != nsnull,
"failed to create gfxShapedWord - expect missing text");
if (!sw) {
NS_WARNING("failed to create gfxShapedWord - expect missing text");
return nsnull;
}
bool ok;
bool ok = false;
if (sizeof(T) == sizeof(PRUnichar)) {
ok = ShapeWord(aContext, sw, (const PRUnichar*)aText);
} else {
nsAutoString utf16;
AppendASCIItoUTF16(nsDependentCSubstring((const char*)aText, aLength),
utf16);
ok = ShapeWord(aContext, sw, utf16.BeginReading());
if (utf16.Length() == aLength) {
ok = ShapeWord(aContext, sw, utf16.BeginReading());
}
}
NS_WARN_IF_FALSE(ok, "failed to shape word - expect garbled text");

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

@ -210,6 +210,51 @@ gfxUtils::UnpremultiplyImageSurface(gfxImageSurface *aSourceSurface,
}
}
void
gfxUtils::ConvertBGRAtoRGBA(gfxImageSurface *aSourceSurface,
gfxImageSurface *aDestSurface) {
if (!aDestSurface)
aDestSurface = aSourceSurface;
NS_ABORT_IF_FALSE(aSourceSurface->Format() == aDestSurface->Format() &&
aSourceSurface->Width() == aDestSurface->Width() &&
aSourceSurface->Height() == aDestSurface->Height() &&
aSourceSurface->Stride() == aDestSurface->Stride(),
"Source and destination surfaces don't have identical characteristics");
NS_ABORT_IF_FALSE(aSourceSurface->Stride() == aSourceSurface->Width() * 4,
"Source surface stride isn't tightly packed");
NS_ABORT_IF_FALSE(aSourceSurface->Format() == gfxASurface::ImageFormatARGB32,
"Surfaces must be ARGB32");
PRUint8 *src = aSourceSurface->Data();
PRUint8 *dst = aDestSurface->Data();
PRUint32 dim = aSourceSurface->Width() * aSourceSurface->Height();
PRUint8 *srcEnd = src + 4*dim;
if (src == dst) {
PRUint8 buffer[4];
for (; src != srcEnd; src += 4) {
buffer[0] = src[2];
buffer[1] = src[1];
buffer[2] = src[0];
src[0] = buffer[0];
src[1] = buffer[1];
src[2] = buffer[2];
}
} else {
for (; src != srcEnd; src += 4, dst += 4) {
dst[0] = src[2];
dst[1] = src[1];
dst[2] = src[0];
dst[3] = src[3];
}
}
}
static bool
IsSafeImageTransformComponent(gfxFloat aValue)
{

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

@ -65,6 +65,9 @@ public:
static void UnpremultiplyImageSurface(gfxImageSurface *aSurface,
gfxImageSurface *aDestSurface = nsnull);
static void ConvertBGRAtoRGBA(gfxImageSurface *aSourceSurface,
gfxImageSurface *aDestSurface = nsnull);
/**
* Draw something drawable while working around limitations like bad support
* for EXTEND_PAD, lack of source-clipping, or cairo / pixman bugs with

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

@ -209,6 +209,9 @@ void nsPNGDecoder::EndImageFrame()
if (mFrameHasNoAlpha)
mImage.SetFrameHasNoAlpha(numFrames - 1);
// PNG is always non-premult
mImage.SetFrameAsNonPremult(numFrames - 1, true);
PostInvalidation(mFrameRect);
}
#endif

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