Merge m-i to m-c, a=merge

This commit is contained in:
Phil Ringnalda 2015-05-23 13:31:21 -07:00
commit 6cdd54a926
337 changed files with 6767 additions and 2918 deletions

View File

@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.
Bug 1163201 needs clobber.
Bug 1166031 - NSS update hit needs-clobber bustage.

View File

@ -31,12 +31,15 @@ GetNativeFromGeckoAccessible(mozilla::a11y::Accessible* aAccessible)
return native;
}
// This is OR'd with the Accessible owner to indicate the wrap-ee is a proxy.
static const uintptr_t IS_PROXY = 1;
@interface mozAccessible : NSObject <mozAccessible>
{
/**
* Weak reference; it owns us.
*/
mozilla::a11y::AccessibleWrap* mGeckoAccessible;
uintptr_t mGeckoAccessible;
/**
* Strong ref to array of children
@ -54,6 +57,9 @@ GetNativeFromGeckoAccessible(mozilla::a11y::Accessible* aAccessible)
mozilla::a11y::role mRole;
}
// return the Accessible for this mozAccessible.
- (mozilla::a11y::AccessibleWrap*) getGeckoAccessible;
// inits with the gecko owner.
- (id)initWithAccessible:(mozilla::a11y::AccessibleWrap*)geckoParent;

View File

@ -65,7 +65,7 @@ GetClosestInterestingAccessible(id anObject)
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if ((self = [super init])) {
mGeckoAccessible = geckoAccessible;
mGeckoAccessible = reinterpret_cast<uintptr_t>(geckoAccessible);
mRole = geckoAccessible->Role();
}
@ -83,6 +83,15 @@ GetClosestInterestingAccessible(id anObject)
NS_OBJC_END_TRY_ABORT_BLOCK;
}
- (mozilla::a11y::AccessibleWrap*)getGeckoAccessible
{
// Check if mGeckoAccessible points at a proxy
if (mGeckoAccessible & IS_PROXY)
return nil;
return reinterpret_cast<AccessibleWrap*>(mGeckoAccessible);
}
#pragma mark -
@ -92,8 +101,10 @@ GetClosestInterestingAccessible(id anObject)
// unknown (either unimplemented, or irrelevant) elements are marked as ignored
// as well as expired elements.
return !mGeckoAccessible || ([[self role] isEqualToString:NSAccessibilityUnknownRole] &&
!(mGeckoAccessible->InteractiveState() & states::FOCUSABLE));
AccessibleWrap* accWrap = [self getGeckoAccessible];
return !accWrap || ([[self role] isEqualToString:NSAccessibilityUnknownRole] &&
!(accWrap->InteractiveState() & states::FOCUSABLE));
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
}
@ -103,7 +114,7 @@ GetClosestInterestingAccessible(id anObject)
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
// if we're expired, we don't support any attributes.
if (!mGeckoAccessible)
if (![self getGeckoAccessible])
return [NSArray array];
static NSArray *generalAttributes = nil;
@ -141,7 +152,7 @@ GetClosestInterestingAccessible(id anObject)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if (!mGeckoAccessible)
if (![self getGeckoAccessible])
return nil;
#if DEBUG
@ -183,7 +194,8 @@ GetClosestInterestingAccessible(id anObject)
if ([attribute isEqualToString:NSAccessibilityTitleAttribute])
return [self title];
if ([attribute isEqualToString:NSAccessibilityTitleUIElementAttribute]) {
Relation rel = mGeckoAccessible->RelationByType(RelationType::LABELLED_BY);
Relation rel =
[self getGeckoAccessible]->RelationByType(RelationType::LABELLED_BY);
Accessible* tempAcc = rel.Next();
return tempAcc ? GetNativeFromGeckoAccessible(tempAcc) : nil;
}
@ -227,7 +239,8 @@ GetClosestInterestingAccessible(id anObject)
- (id)accessibilityHitTest:(NSPoint)point
{
if (!mGeckoAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (!accWrap)
return nil;
// Convert the given screen-global point in the cocoa coordinate system (with
@ -239,8 +252,9 @@ GetClosestInterestingAccessible(id anObject)
nsIntPoint geckoPoint = nsCocoaUtils::
CocoaPointsToDevPixels(tmpPoint, nsCocoaUtils::GetBackingScaleFactor(mainView));
Accessible* child = mGeckoAccessible->ChildAtPoint(geckoPoint.x, geckoPoint.y,
Accessible::eDeepestChild);
Accessible* child =
accWrap->ChildAtPoint(geckoPoint.x, geckoPoint.y,
Accessible::eDeepestChild);
if (child) {
mozAccessible* nativeChild = GetNativeFromGeckoAccessible(child);
@ -270,10 +284,11 @@ GetClosestInterestingAccessible(id anObject)
- (id)accessibilityFocusedUIElement
{
if (!mGeckoAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (!accWrap)
return nil;
Accessible* focusedGeckoChild = mGeckoAccessible->FocusedChild();
Accessible* focusedGeckoChild = accWrap->FocusedChild();
if (focusedGeckoChild) {
mozAccessible *focusedChild = GetNativeFromGeckoAccessible(focusedGeckoChild);
if (focusedChild)
@ -290,7 +305,8 @@ GetClosestInterestingAccessible(id anObject)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
Accessible* accessibleParent = mGeckoAccessible->GetUnignoredParent();
AccessibleWrap* accWrap = [self getGeckoAccessible];
Accessible* accessibleParent = accWrap->GetUnignoredParent();
if (accessibleParent) {
id nativeParent = GetNativeFromGeckoAccessible(accessibleParent);
if (nativeParent)
@ -303,7 +319,7 @@ GetClosestInterestingAccessible(id anObject)
//
// get the native root accessible, and tell it to return its first parent unignored accessible.
id nativeParent =
GetNativeFromGeckoAccessible(mGeckoAccessible->RootAccessible());
GetNativeFromGeckoAccessible(accWrap->RootAccessible());
NSAssert1 (nativeParent, @"!!! we can't find a parent for %@", self);
return GetClosestInterestingAccessible(nativeParent);
@ -332,14 +348,15 @@ GetClosestInterestingAccessible(id anObject)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if (mChildren || !mGeckoAccessible->AreChildrenCached())
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (mChildren || !accWrap->AreChildrenCached())
return mChildren;
mChildren = [[NSMutableArray alloc] init];
// get the array of children.
nsAutoTArray<Accessible*, 10> childrenArray;
mGeckoAccessible->GetUnignoredChildren(&childrenArray);
accWrap->GetUnignoredChildren(&childrenArray);
// now iterate through the children array, and get each native accessible.
uint32_t totalCount = childrenArray.Length();
@ -370,10 +387,11 @@ GetClosestInterestingAccessible(id anObject)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if (!mGeckoAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (!accWrap)
return nil;
nsIntRect rect = mGeckoAccessible->Bounds();
nsIntRect rect = accWrap->Bounds();
NSScreen* mainView = [[NSScreen screens] objectAtIndex:0];
CGFloat scaleFactor = nsCocoaUtils::GetBackingScaleFactor(mainView);
@ -389,10 +407,11 @@ GetClosestInterestingAccessible(id anObject)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if (!mGeckoAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (!accWrap)
return nil;
nsIntRect rect = mGeckoAccessible->Bounds();
nsIntRect rect = accWrap->Bounds();
CGFloat scaleFactor =
nsCocoaUtils::GetBackingScaleFactor([[NSScreen screens] objectAtIndex:0]);
return [NSValue valueWithSize:NSMakeSize(static_cast<CGFloat>(rect.width) / scaleFactor,
@ -403,11 +422,12 @@ GetClosestInterestingAccessible(id anObject)
- (NSString*)role
{
if (!mGeckoAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (!accWrap)
return nil;
#ifdef DEBUG_A11Y
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(mGeckoAccessible),
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(accWrap),
"Does not support Text when it should");
#endif
@ -427,10 +447,11 @@ GetClosestInterestingAccessible(id anObject)
- (NSString*)subrole
{
if (!mGeckoAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (!accWrap)
return nil;
nsIAtom* landmark = mGeckoAccessible->LandmarkRole();
nsIAtom* landmark = accWrap->LandmarkRole();
if (landmark) {
if (landmark == nsGkAtoms::application)
return @"AXLandmarkApplication";
@ -457,7 +478,7 @@ GetClosestInterestingAccessible(id anObject)
return @"AXContentList"; // 10.6+ NSAccessibilityContentListSubrole;
case roles::ENTRY:
if (mGeckoAccessible->IsSearchbox())
if (accWrap->IsSearchbox())
return @"AXSearchField";
break;
@ -528,7 +549,7 @@ struct RoleDescrComparator
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
nsAutoString title;
mGeckoAccessible->Name(title);
[self getGeckoAccessible]->Name(title);
return nsCocoaUtils::ToNSString(title);
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
@ -539,7 +560,7 @@ struct RoleDescrComparator
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
nsAutoString value;
mGeckoAccessible->Value(value);
[self getGeckoAccessible]->Value(value);
return nsCocoaUtils::ToNSString(value);
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
@ -567,11 +588,12 @@ struct RoleDescrComparator
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if (mGeckoAccessible->IsDefunct())
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (accWrap->IsDefunct())
return nil;
nsAutoString desc;
mGeckoAccessible->Description(desc);
accWrap->Description(desc);
return nsCocoaUtils::ToNSString(desc);
@ -583,7 +605,7 @@ struct RoleDescrComparator
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
nsAutoString helpText;
mGeckoAccessible->Help(helpText);
[self getGeckoAccessible]->Help(helpText);
return nsCocoaUtils::ToNSString(helpText);
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
@ -601,26 +623,29 @@ struct RoleDescrComparator
- (BOOL)isFocused
{
return FocusMgr()->IsFocused(mGeckoAccessible);
return FocusMgr()->IsFocused([self getGeckoAccessible]);
}
- (BOOL)canBeFocused
{
return mGeckoAccessible && (mGeckoAccessible->InteractiveState() & states::FOCUSABLE);
AccessibleWrap* accWrap = [self getGeckoAccessible];
return accWrap && (accWrap->InteractiveState() & states::FOCUSABLE);
}
- (BOOL)focus
{
if (!mGeckoAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (!accWrap)
return NO;
mGeckoAccessible->TakeFocus();
accWrap->TakeFocus();
return YES;
}
- (BOOL)isEnabled
{
return mGeckoAccessible && ((mGeckoAccessible->InteractiveState() & states::UNAVAILABLE) == 0);
AccessibleWrap* accWrap = [self getGeckoAccessible];
return accWrap && ((accWrap->InteractiveState() & states::UNAVAILABLE) == 0);
}
// The root accessible calls this when the focused node was
@ -643,7 +668,7 @@ struct RoleDescrComparator
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
AccessibleWrap* accWrap = static_cast<AccessibleWrap*>(mGeckoAccessible);
AccessibleWrap* accWrap = [self getGeckoAccessible];
// Get a pointer to the native window (NSWindow) we reside in.
NSWindow *nativeWindow = nil;
@ -685,14 +710,14 @@ struct RoleDescrComparator
[self invalidateChildren];
mGeckoAccessible = nullptr;
mGeckoAccessible = 0;
NS_OBJC_END_TRY_ABORT_BLOCK;
}
- (BOOL)isExpired
{
return !mGeckoAccessible;
return ![self getGeckoAccessible];
}
#pragma mark -

View File

@ -73,7 +73,7 @@ enum CheckboxValue {
- (BOOL)accessibilityIsIgnored
{
return !mGeckoAccessible;
return ![self getGeckoAccessible];
}
- (NSArray*)accessibilityActionNames
@ -118,12 +118,13 @@ enum CheckboxValue {
{
// both buttons and checkboxes have only one action. we should really stop using arbitrary
// arrays with actions, and define constants for these actions.
mGeckoAccessible->DoAction(0);
[self getGeckoAccessible]->DoAction(0);
}
- (BOOL)isTab
{
return (mGeckoAccessible && (mGeckoAccessible->Role() == roles::PAGETAB));
AccessibleWrap* accWrap = [self getGeckoAccessible];
return (accWrap && (accWrap->Role() == roles::PAGETAB));
}
@end
@ -148,7 +149,7 @@ enum CheckboxValue {
- (int)isChecked
{
uint64_t state = mGeckoAccessible->NativeState();
uint64_t state = [self getGeckoAccessible]->NativeState();
// check if we're checked or in a mixed state
if (state & states::CHECKED) {
@ -292,10 +293,10 @@ enum CheckboxValue {
*/
- (id)value
{
if (!mGeckoAccessible)
if (![self getGeckoAccessible])
return nil;
Accessible* accessible = mGeckoAccessible->GetSelectedItem(0);
Accessible* accessible = [self getGeckoAccessible]->GetSelectedItem(0);
if (!accessible)
return nil;
@ -339,29 +340,29 @@ enum CheckboxValue {
- (NSUInteger)accessibilityArrayAttributeCount:(NSString*)attribute
{
if (!mGeckoAccessible)
if (![self getGeckoAccessible])
return 0;
// By default this calls -[[mozAccessible children] count].
// Since we don't cache mChildren. This is faster.
if ([attribute isEqualToString:NSAccessibilityChildrenAttribute])
return mGeckoAccessible->ChildCount() ? 1 : 0;
return [self getGeckoAccessible]->ChildCount() ? 1 : 0;
return [super accessibilityArrayAttributeCount:attribute];
}
- (NSArray*)children
{
if (!mGeckoAccessible)
if (![self getGeckoAccessible])
return nil;
nsDeckFrame* deckFrame = do_QueryFrame(mGeckoAccessible->GetFrame());
nsDeckFrame* deckFrame = do_QueryFrame([self getGeckoAccessible]->GetFrame());
nsIFrame* selectedFrame = deckFrame ? deckFrame->GetSelectedBox() : nullptr;
Accessible* selectedAcc = nullptr;
if (selectedFrame) {
nsINode* node = selectedFrame->GetContent();
selectedAcc = mGeckoAccessible->Document()->GetAccessible(node);
selectedAcc = [self getGeckoAccessible]->Document()->GetAccessible(node);
}
if (selectedAcc) {

View File

@ -33,7 +33,7 @@ getNativeViewFromRootAccessible(Accessible* aAccessible)
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
// if we're expired, we don't support any attributes.
if (!mGeckoAccessible)
if (![self getGeckoAccessible])
return [NSArray array];
// standard attributes that are shared and supported by root accessible (AXMain) elements.
@ -95,7 +95,7 @@ getNativeViewFromRootAccessible(Accessible* aAccessible)
if (mParallelView)
return (id)mParallelView;
mParallelView = getNativeViewFromRootAccessible (mGeckoAccessible);
mParallelView = getNativeViewFromRootAccessible ([self getGeckoAccessible]);
NSAssert(mParallelView, @"can't return root accessible's native parallel view.");
return mParallelView;

View File

@ -20,17 +20,19 @@
mozilla::ErrorResult rv;
// XXX use the flattening API when there are available
// see bug 768298
mGeckoAccessible->GetContent()->GetTextContent(title, rv);
[self getGeckoAccessible]->GetContent()->GetTextContent(title, rv);
return nsCocoaUtils::ToNSString(title);
}
- (id)value
{
if (!mGeckoAccessible || !mGeckoAccessible->IsHyperText())
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (!accWrap || !accWrap->IsHyperText())
return nil;
uint32_t level = mGeckoAccessible->AsHyperText()->GetLevelInternal();
uint32_t level = accWrap->AsHyperText()->GetLevelInternal();
return [NSNumber numberWithInt:level];
}
@ -45,7 +47,7 @@
- (NSArray*)accessibilityAttributeNames
{
// if we're expired, we don't support any attributes.
if (!mGeckoAccessible)
if (![self getGeckoAccessible])
return [NSArray array];
static NSMutableArray* attributes = nil;
@ -69,7 +71,7 @@
- (NSArray*)accessibilityActionNames
{
// if we're expired, we don't support any attributes.
if (!mGeckoAccessible)
if (![self getGeckoAccessible])
return [NSArray array];
static NSArray* actionNames = nil;
@ -84,11 +86,13 @@
- (void)accessibilityPerformAction:(NSString*)action
{
if (!mGeckoAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (!accWrap)
return;
if ([action isEqualToString:NSAccessibilityPressAction])
mGeckoAccessible->DoAction(0);
accWrap->DoAction(0);
else
[super accessibilityPerformAction:action];
}
@ -105,11 +109,11 @@
- (NSURL*)url
{
if (!mGeckoAccessible || mGeckoAccessible->IsDefunct())
if (![self getGeckoAccessible] || [self getGeckoAccessible]->IsDefunct())
return nil;
nsAutoString value;
mGeckoAccessible->Value(value);
[self getGeckoAccessible]->Value(value);
NSString* urlString = value.IsEmpty() ? nil : nsCocoaUtils::ToNSString(value);
if (!urlString)

View File

@ -8,9 +8,6 @@
@interface mozTextAccessible : mozAccessible
{
// both of these are the same old mGeckoAccessible, but already
// QI'd for us, to the right type, for convenience.
mozilla::a11y::HyperTextAccessible* mGeckoTextAccessible; // strong
}
@end

View File

@ -53,21 +53,9 @@ ToNSString(id aValue)
@implementation mozTextAccessible
- (id)initWithAccessible:(AccessibleWrap*)accessible
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if ((self = [super initWithAccessible:accessible])) {
mGeckoTextAccessible = accessible->AsHyperText();
}
return self;
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (BOOL)accessibilityIsIgnored
{
return !mGeckoAccessible;
return ![self getGeckoAccessible];
}
- (NSArray*)accessibilityAttributeNames
@ -126,11 +114,13 @@ ToNSString(id aValue)
return [self text];
}
AccessibleWrap* accWrap = [self getGeckoAccessible];
if ([attribute isEqualToString:@"AXRequired"])
return [NSNumber numberWithBool:!!(mGeckoAccessible->State() & states::REQUIRED)];
return [NSNumber numberWithBool:!!(accWrap->State() & states::REQUIRED)];
if ([attribute isEqualToString:@"AXInvalid"])
return [NSNumber numberWithBool:!!(mGeckoAccessible->State() & states::INVALID)];
return [NSNumber numberWithBool:!!(accWrap->State() & states::INVALID)];
if ([attribute isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute])
return [self visibleCharacterRange];
@ -166,7 +156,9 @@ ToNSString(id aValue)
- (id)accessibilityAttributeValue:(NSString*)attribute forParameter:(id)parameter
{
if (!mGeckoTextAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
if (!textAcc)
return nil;
if ([attribute isEqualToString:NSAccessibilityStringForRangeParameterizedAttribute]) {
@ -214,7 +206,7 @@ ToNSString(id aValue)
int32_t start = range.location;
int32_t end = start + range.length;
nsIntRect bounds = mGeckoTextAccessible->TextBounds(start, end);
nsIntRect bounds = textAcc->TextBounds(start, end);
return [NSValue valueWithRect:nsCocoaUtils::GeckoRectToCocoaRect(bounds)];
}
@ -247,7 +239,9 @@ ToNSString(id aValue)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
if (!mGeckoTextAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
if (!textAcc)
return;
if ([attribute isEqualToString:NSAccessibilityValueAttribute]) {
@ -262,12 +256,12 @@ ToNSString(id aValue)
return;
int32_t start = 0, end = 0;
mGeckoTextAccessible->SelectionBoundsAt(0, &start, &end);
mGeckoTextAccessible->DeleteText(start, end - start);
textAcc->SelectionBoundsAt(0, &start, &end);
textAcc->DeleteText(start, end - start);
nsString text;
nsCocoaUtils::GetStringForNSString(stringValue, text);
mGeckoTextAccessible->InsertText(text, start);
textAcc->InsertText(text, start);
}
if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) {
@ -275,8 +269,8 @@ ToNSString(id aValue)
if (!ToNSRange(value, &range))
return;
mGeckoTextAccessible->SetSelectionBoundsAt(0, range.location,
range.location + range.length);
textAcc->SetSelectionBoundsAt(0, range.location,
range.location + range.length);
return;
}
@ -285,8 +279,8 @@ ToNSString(id aValue)
if (!ToNSRange(value, &range))
return;
mGeckoTextAccessible->ScrollSubstringTo(range.location, range.location + range.length,
nsIAccessibleScrollType::SCROLL_TYPE_TOP_EDGE);
textAcc->ScrollSubstringTo(range.location, range.location + range.length,
nsIAccessibleScrollType::SCROLL_TYPE_TOP_EDGE);
return;
}
@ -303,16 +297,6 @@ ToNSString(id aValue)
return nil;
}
- (void)expire
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
mGeckoTextAccessible = nullptr;
[super expire];
NS_OBJC_END_TRY_ABORT_BLOCK;
}
#pragma mark -
- (BOOL)isReadOnly
@ -322,8 +306,10 @@ ToNSString(id aValue)
if ([[self role] isEqualToString:NSAccessibilityStaticTextRole])
return YES;
if (mGeckoTextAccessible)
return (mGeckoAccessible->State() & states::READONLY) == 0;
AccessibleWrap* accWrap = [self getGeckoAccessible];
HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
if (textAcc)
return (accWrap->State() & states::READONLY) == 0;
return NO;
@ -332,8 +318,10 @@ ToNSString(id aValue)
- (NSNumber*)caretLineNumber
{
int32_t lineNumber = mGeckoTextAccessible ?
mGeckoTextAccessible->CaretLineNumber() - 1 : -1;
AccessibleWrap* accWrap = [self getGeckoAccessible];
HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
int32_t lineNumber = textAcc ?
textAcc->CaretLineNumber() - 1 : -1;
return (lineNumber >= 0) ? [NSNumber numberWithInt:lineNumber] : nil;
}
@ -342,10 +330,12 @@ ToNSString(id aValue)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
if (mGeckoTextAccessible) {
AccessibleWrap* accWrap = [self getGeckoAccessible];
HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
if (textAcc) {
nsString text;
nsCocoaUtils::GetStringForNSString(aNewString, text);
mGeckoTextAccessible->ReplaceText(text);
textAcc->ReplaceText(text);
}
NS_OBJC_END_TRY_ABORT_BLOCK;
@ -353,7 +343,9 @@ ToNSString(id aValue)
- (NSString*)text
{
if (!mGeckoAccessible || !mGeckoTextAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
if (!accWrap || !textAcc)
return nil;
// A password text field returns an empty value
@ -361,9 +353,7 @@ ToNSString(id aValue)
return @"";
nsAutoString text;
mGeckoTextAccessible->TextSubstring(0,
nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT,
text);
textAcc->TextSubstring(0, nsIAccessibleText::TEXT_OFFSET_END_OF_TEXT, text);
return nsCocoaUtils::ToNSString(text);
}
@ -371,10 +361,12 @@ ToNSString(id aValue)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
if (!mGeckoAccessible || !mGeckoTextAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
if (!accWrap || !textAcc)
return 0;
return mGeckoTextAccessible ? mGeckoTextAccessible->CharacterCount() : 0;
return textAcc ? textAcc->CharacterCount() : 0;
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(0);
}
@ -383,9 +375,11 @@ ToNSString(id aValue)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
if (mGeckoTextAccessible) {
AccessibleWrap* accWrap = [self getGeckoAccessible];
HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
if (textAcc) {
int32_t start = 0, end = 0;
mGeckoTextAccessible->SelectionBoundsAt(0, &start, &end);
textAcc->SelectionBoundsAt(0, &start, &end);
return (end - start);
}
return 0;
@ -397,12 +391,14 @@ ToNSString(id aValue)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if (mGeckoTextAccessible) {
AccessibleWrap* accWrap = [self getGeckoAccessible];
HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
if (textAcc) {
int32_t start = 0, end = 0;
mGeckoTextAccessible->SelectionBoundsAt(0, &start, &end);
textAcc->SelectionBoundsAt(0, &start, &end);
if (start != end) {
nsAutoString selText;
mGeckoTextAccessible->TextSubstring(start, end, selText);
textAcc->TextSubstring(start, end, selText);
return nsCocoaUtils::ToNSString(selText);
}
}
@ -415,17 +411,19 @@ ToNSString(id aValue)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
if (mGeckoTextAccessible) {
AccessibleWrap* accWrap = [self getGeckoAccessible];
HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
if (textAcc) {
int32_t start = 0;
int32_t end = 0;
int32_t count = mGeckoTextAccessible->SelectionCount();
int32_t count = textAcc->SelectionCount();
if (count) {
mGeckoTextAccessible->SelectionBoundsAt(0, &start, &end);
textAcc->SelectionBoundsAt(0, &start, &end);
return [NSValue valueWithRange:NSMakeRange(start, end - start)];
}
start = mGeckoTextAccessible->CaretOffset();
start = textAcc->CaretOffset();
return [NSValue valueWithRange:NSMakeRange(start != -1 ? start : 0, 0)];
}
return [NSValue valueWithRange:NSMakeRange(0, 0)];
@ -437,9 +435,11 @@ ToNSString(id aValue)
{
// XXX this won't work with Textarea and such as we actually don't give
// the visible character range.
AccessibleWrap* accWrap = [self getGeckoAccessible];
HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
return [NSValue valueWithRange:
NSMakeRange(0, mGeckoTextAccessible ?
mGeckoTextAccessible->CharacterCount() : 0)];
NSMakeRange(0, textAcc ?
textAcc->CharacterCount() : 0)];
}
- (void)valueDidChange
@ -460,11 +460,16 @@ ToNSString(id aValue)
- (NSString*)stringFromRange:(NSRange*)range
{
NS_PRECONDITION(mGeckoTextAccessible && range, "no Gecko text accessible or range");
NS_PRECONDITION(range, "no range");
AccessibleWrap* accWrap = [self getGeckoAccessible];
HyperTextAccessible* textAcc = accWrap? accWrap->AsHyperText() : nullptr;
if (!textAcc)
return nil;
nsAutoString text;
mGeckoTextAccessible->TextSubstring(range->location,
range->location + range->length, text);
textAcc->TextSubstring(range->location,
range->location + range->length, text);
return nsCocoaUtils::ToNSString(text);
}
@ -496,18 +501,20 @@ ToNSString(id aValue)
- (NSString*)text
{
if (!mGeckoAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (!accWrap)
return nil;
return nsCocoaUtils::ToNSString(mGeckoAccessible->AsTextLeaf()->Text());
return nsCocoaUtils::ToNSString(accWrap->AsTextLeaf()->Text());
}
- (long)textLength
{
if (!mGeckoAccessible)
AccessibleWrap* accWrap = [self getGeckoAccessible];
if (!accWrap)
return 0;
return mGeckoAccessible->AsTextLeaf()->Text().Length();
return accWrap->AsTextLeaf()->Text().Length();
}
@end

View File

@ -35,19 +35,14 @@ function readURI(uri, options) {
options = options || {};
let charset = options.charset || 'UTF-8';
let channel = NetUtil.newChannel2(uri,
charset,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let channel = NetUtil.newChannel({
uri: NetUtil.newURI(uri, charset),
loadUsingSystemPrincipal: true});
let { promise, resolve, reject } = defer();
try {
NetUtil.asyncFetch2(channel, function (stream, result) {
NetUtil.asyncFetch(channel, function (stream, result) {
if (components.isSuccessCode(result)) {
let count = stream.available();
let data = NetUtil.readInputStreamToString(stream, count, { charset : charset });
@ -83,14 +78,9 @@ exports.readURI = readURI;
function readURISync(uri, charset) {
charset = typeof charset === "string" ? charset : "UTF-8";
let channel = NetUtil.newChannel2(uri,
charset,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let channel = NetUtil.newChannel({
uri: NetUtil.newURI(uri, charset),
loadUsingSystemPrincipal: true});
let stream = channel.open();
let count = stream.available();

View File

@ -152,20 +152,28 @@ function URL(url, base) {
Object.defineProperties(this, {
toString: {
value() new String(uri.spec).toString(),
value() {
return new String(uri.spec).toString();
},
enumerable: false
},
valueOf: {
value() new String(uri.spec).valueOf(),
value() {
return new String(uri.spec).valueOf();
},
enumerable: false
},
toSource: {
value() new String(uri.spec).toSource(),
value() {
return new String(uri.spec).toSource();
},
enumerable: false
},
// makes more sense to flatten to string, easier to travel across JSON
toJSON: {
value() new String(uri.spec).toString(),
value() {
return new String(uri.spec).toString();
},
enumerable: false
}
});

View File

@ -178,14 +178,10 @@ function readURI(uri) {
uri = proto.resolveURI(nsURI);
}
let stream = NetUtil.newChannel2(uri,
'UTF-8',
null,
null, // aLoadingNode
systemPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER).open();
let stream = NetUtil.newChannel({
uri: NetUtil.newURI(uri, 'UTF-8'),
loadUsingSystemPrincipal: true}
).open();
let count = stream.available();
let data = NetUtil.readInputStreamToString(stream, count, {
charset: 'UTF-8'

View File

@ -88,7 +88,6 @@ pref("network.http.max-persistent-connections-per-proxy", 20);
pref("network.cookie.cookieBehavior", 0);
// spdy
pref("network.http.spdy.enabled.http2draft", true);
pref("network.http.spdy.push-allowance", 32768);
// See bug 545869 for details on why these are set the way they are

View File

@ -1779,19 +1779,11 @@ pref("geo.wifi.uri", "https://location.services.mozilla.com/v1/geolocate?key=%MO
#endif
#ifdef XP_MACOSX
#ifdef RELEASE_BUILD
pref("geo.provider.use_corelocation", false);
#else
pref("geo.provider.use_corelocation", true);
#endif
#endif
#ifdef XP_WIN
#ifdef RELEASE_BUILD
pref("geo.provider.ms-windows-location", false);
#else
pref("geo.provider.ms-windows-location", true);
#endif
#endif
// Necko IPC security checks only needed for app isolation for cookies/cache/etc:

View File

@ -1033,6 +1033,9 @@ chatbox:-moz-full-screen-ancestor > .chat-titlebar {
/* Combobox dropdown renderer */
#ContentSelectDropdown > menupopup {
max-height: 350px;
/* The menupopup itself should always be rendered LTR to ensure the scrollbar aligns with
* the dropdown arrow on the dropdown widget. If a menuitem is RTL, its style will be set accordingly */
direction: ltr;
}
.contentSelectDropdown-optgroup {

View File

@ -1433,13 +1433,13 @@ nsContextMenu.prototype = {
var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
getService(Ci.nsIClipboardHelper);
clipboard.copyString(addresses, document);
clipboard.copyString(addresses);
},
copyLink: function() {
var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
getService(Ci.nsIClipboardHelper);
clipboard.copyString(this.linkURL, document);
clipboard.copyString(this.linkURL);
},
///////////////
@ -1691,7 +1691,7 @@ nsContextMenu.prototype = {
copyMediaLocation : function () {
var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
getService(Ci.nsIClipboardHelper);
clipboard.copyString(this.mediaURL, document);
clipboard.copyString(this.mediaURL);
},
drmLearnMore: function(aEvent) {

View File

@ -1253,7 +1253,7 @@ function doCopy()
elem.removeAttribute("copybuffer");
}
}
gClipboardHelper.copyString(text.join("\n"), document);
gClipboardHelper.copyString(text.join("\n"));
}
}

View File

@ -5,14 +5,7 @@ Cu.import("resource://gre/modules/NetUtil.jsm");
function test() {
var file = new File([new Blob(['test'], {type: 'text/plain'})], "test-name");
var url = URL.createObjectURL(file);
var channel = NetUtil.newChannel2(url,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var channel = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
is(channel.contentDispositionFilename, 'test-name', "filename matches");
}

View File

@ -32,7 +32,7 @@ function test() {
// Put a multi-line string in the clipboard.
// Setting the clipboard value is an async OS operation, so we need to poll
// the clipboard for valid data before going on.
waitForClipboard(kTestString, function() { cbHelper.copyString(kTestString, document); },
waitForClipboard(kTestString, function() { cbHelper.copyString(kTestString); },
next_test, finish);
}

View File

@ -14,7 +14,7 @@ add_task(function* () {
SimpleTest.waitForClipboard(url, () => {
Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper)
.copyString(url, document);
.copyString(url);
}, resolve, () => {
ok(false, "Clipboard copy failed");
reject();

View File

@ -596,7 +596,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(Ci.nsIClipboardHelper)
.copyString(val, document);
.copyString(val);
},
supportsCommand: function(aCommand) {
switch (aCommand) {
@ -969,7 +969,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(Ci.nsIClipboardHelper)
.copyStringToClipboard(val, Ci.nsIClipboard.kSelectionClipboard, document);
.copyStringToClipboard(val, Ci.nsIClipboard.kSelectionClipboard);
]]></handler>
</handlers>

View File

@ -1208,7 +1208,7 @@ DownloadsPlacesView.prototype = {
Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(Ci.nsIClipboardHelper)
.copyString(urls.join("\n"), document);
.copyString(urls.join("\n"));
},
_getURLFromClipboardData() {

View File

@ -1262,7 +1262,7 @@ DownloadsViewItemController.prototype = {
downloadsCmd_copyLocation() {
let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(Ci.nsIClipboardHelper);
clipboard.copyString(this.download.source.url, document);
clipboard.copyString(this.download.source.url);
},
downloadsCmd_doDefault() {

View File

@ -374,7 +374,9 @@ let gEditItemOverlay = {
XPCOMUtils.generateQI([Components.interfaces.nsIDOMEventListener,
Components.interfaces.nsINavBookmarkObserver]),
_element(aID) document.getElementById("editBMPanel_" + aID),
_element(aID) {
return document.getElementById("editBMPanel_" + aID);
},
uninitPanel(aHideCollapsibleElements) {
if (aHideCollapsibleElements) {

View File

@ -444,7 +444,10 @@ var gMainPane = {
* downloads are automatically saved, updating preferences and UI in
* response to the choice, if one is made.
*/
chooseFolder() this.chooseFolderTask().catch(Components.utils.reportError),
chooseFolder()
{
return this.chooseFolderTask().catch(Components.utils.reportError);
},
chooseFolderTask: Task.async(function* ()
{
let bundlePreferences = document.getElementById("bundlePreferences");

View File

@ -308,7 +308,10 @@ var gMainPane = {
* downloads are automatically saved, updating preferences and UI in
* response to the choice, if one is made.
*/
chooseFolder() this.chooseFolderTask().catch(Components.utils.reportError),
chooseFolder()
{
return this.chooseFolderTask().catch(Components.utils.reportError);
},
chooseFolderTask: Task.async(function* ()
{
let bundlePreferences = document.getElementById("bundlePreferences");

View File

@ -359,17 +359,13 @@ let SnapshotsListView = Heritage.extend(WidgetMethods, {
return;
}
let channel = NetUtil.newChannel2(fp.file,
null,
null,
window.document,
null, // aLoadingPrincipal
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let channel = NetUtil.newChannel({
uri: NetUtil.newURI(fp.file),
loadingNode: window.document,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER});
channel.contentType = "text/plain";
NetUtil.asyncFetch2(channel, (inputStream, status) => {
NetUtil.asyncFetch(channel, (inputStream, status) => {
if (!Components.isSuccessCode(status)) {
console.error("Could not import recorded animation frame snapshot file.");
return;

View File

@ -910,7 +910,7 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
if (!selected) {
return;
}
clipboardHelper.copyString(selected.source.url, document);
clipboardHelper.copyString(selected.source.url);
},
/**

View File

@ -2214,7 +2214,7 @@ MarkupElementContainer.prototype = Heritage.extend(MarkupContainer.prototype, {
// the tooltip, because we want the full-size image
this.node.getImageData().then(data => {
data.data.string().then(str => {
clipboardHelper.copyString(str, this.markup.doc);
clipboardHelper.copyString(str);
});
});
},

View File

@ -563,7 +563,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
*/
copyUrl: function() {
let selected = this.selectedItem.attachment;
clipboardHelper.copyString(selected.url, document);
clipboardHelper.copyString(selected.url);
},
/**
@ -573,7 +573,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
let selected = this.selectedItem.attachment;
let params = nsIURL(selected.url).query.split("&");
let string = params.join(Services.appinfo.OS === "WINNT" ? "\r\n" : "\n");
clipboardHelper.copyString(string, document);
clipboardHelper.copyString(string);
},
/**
@ -650,7 +650,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
}
}
clipboardHelper.copyString(string, document);
clipboardHelper.copyString(string);
}),
/**
@ -681,7 +681,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
data.postDataText = yield gNetwork.getString(postData);
}
clipboardHelper.copyString(Curl.generateCommand(data), document);
clipboardHelper.copyString(Curl.generateCommand(data));
});
},
@ -694,7 +694,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
if (Services.appinfo.OS !== "WINNT") {
rawHeaders = rawHeaders.replace(/\r/g, "");
}
clipboardHelper.copyString(rawHeaders, document);
clipboardHelper.copyString(rawHeaders);
},
/**
@ -706,7 +706,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
if (Services.appinfo.OS !== "WINNT") {
rawHeaders = rawHeaders.replace(/\r/g, "");
}
clipboardHelper.copyString(rawHeaders, document);
clipboardHelper.copyString(rawHeaders);
},
/**
@ -718,7 +718,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
gNetwork.getString(text).then(aString => {
let data = "data:" + mimeType + ";" + encoding + "," + aString;
clipboardHelper.copyString(data, document);
clipboardHelper.copyString(data);
});
},
@ -730,7 +730,7 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
let text = selected.responseContent.content.text;
gNetwork.getString(text).then(aString => {
clipboardHelper.copyString(aString, document);
clipboardHelper.copyString(aString);
});
},

View File

@ -76,14 +76,9 @@ let PerformanceIO = {
loadRecordingFromFile: function(file) {
let deferred = promise.defer();
let channel = NetUtil.newChannel2(file,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let channel = NetUtil.newChannel({
uri: NetUtil.newURI(file),
loadUsingSystemPrincipal: true});
channel.contentType = "text/plain";

View File

@ -260,7 +260,10 @@ function* getFileData(file) {
}
let def = promise.defer();
NetUtil.asyncFetch2(file, function(inputStream, status) {
NetUtil.asyncFetch({
uri: NetUtil.newURI(file),
loadUsingSystemPrincipal: true
}, function(inputStream, status) {
if (!Components.isSuccessCode(status)) {
info("ERROR READING TEMP FILE", status);
}
@ -275,12 +278,7 @@ function* getFileData(file) {
var data = NetUtil.readInputStreamToString(inputStream, inputStream.available());
def.resolve(data);
},
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
});
return def.promise;
}

View File

@ -1137,19 +1137,15 @@ var Scratchpad = {
importFromFile: function SP_importFromFile(aFile, aSilentError, aCallback)
{
// Prevent file type detection.
let channel = NetUtil.newChannel2(aFile,
null,
null,
window.document,
null, // aLoadingPrincipal
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let channel = NetUtil.newChannel({
uri: NetUtil.newURI(aFile),
loadingNode: window.document,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER});
channel.contentType = "application/javascript";
this.notificationBox.removeAllNotifications(false);
NetUtil.asyncFetch2(channel, (aInputStream, aStatus) => {
NetUtil.asyncFetch(channel, (aInputStream, aStatus) => {
let content = null;
if (Components.isSuccessCode(aStatus)) {

View File

@ -214,17 +214,12 @@ function writeFile(file, content, callback)
function readFile(file, callback)
{
let channel = NetUtil.newChannel2(file,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let channel = NetUtil.newChannel({
uri: NetUtil.newURI(file),
loadUsingSystemPrincipal: true});
channel.contentType = "application/javascript";
NetUtil.asyncFetch2(channel, function(inputStream, status) {
NetUtil.asyncFetch(channel, function(inputStream, status) {
ok(Components.isSuccessCode(status),
"file was read successfully");

View File

@ -91,18 +91,13 @@ function fileExported(aStatus)
gFileContent = oldContent;
let channel = NetUtil.newChannel2(gFile,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let channel = NetUtil.newChannel({
uri: NetUtil.newURI(gFile),
loadUsingSystemPrincipal: true});
channel.contentType = "application/javascript";
// Read back the temporary file.
NetUtil.asyncFetch2(channel, fileRead);
NetUtil.asyncFetch(channel, fileRead);
}
function fileExported2()

View File

@ -25,14 +25,10 @@ const cachedThemes = {};
* Returns a string of the file found at URI
*/
function readURI (uri) {
let stream = NetUtil.newChannel2(uri,
"UTF-8",
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER).open();
let stream = NetUtil.newChannel({
uri: NetUtil.newURI(uri, "UTF-8"),
loadUsingSystemPrincipal: true}
).open();
let count = stream.available();
let data = NetUtil.readInputStreamToString(stream, count, { charset: "UTF-8" });

View File

@ -364,7 +364,11 @@ StyleEditorUI.prototype = {
// nothing selected
return;
}
NetUtil.asyncFetch2(file, (stream, status) => {
NetUtil.asyncFetch({
uri: NetUtil.newURI(file),
loadingNode: this._window.document,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER
}, (stream, status) => {
if (!Components.isSuccessCode(status)) {
this.emit("error", { key: LOAD_ERROR });
return;
@ -375,12 +379,7 @@ StyleEditorUI.prototype = {
this._debuggee.addStyleSheet(source).then((styleSheet) => {
this._onStyleSheetCreated(styleSheet, file);
});
},
this._window.document,
null, // aLoadingPrincipal
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
});
};
showFilePicker(file, false, parentWindow, onFileSelected);

View File

@ -816,7 +816,7 @@ CssHtmlTree.prototype = {
},
_onCopyColor: function() {
clipboardHelper.copyString(this._colorToCopy, this.styleDocument);
clipboardHelper.copyString(this._colorToCopy);
},
/**
@ -854,7 +854,7 @@ CssHtmlTree.prototype = {
result = textArray[0];
}
clipboardHelper.copyString(result, this.styleDocument);
clipboardHelper.copyString(result);
if (event) {
event.preventDefault();

View File

@ -1511,7 +1511,7 @@ CssRuleView.prototype = {
text = text.replace(rx, "");
}
clipboardHelper.copyString(text, this.doc);
clipboardHelper.copyString(text);
event.preventDefault();
} catch(e) {
console.error(e);
@ -1522,7 +1522,7 @@ CssRuleView.prototype = {
* Copy the most recently selected color value to clipboard.
*/
_onCopyColor: function() {
clipboardHelper.copyString(this._colorToCopy, this.styleDocument);
clipboardHelper.copyString(this._colorToCopy);
},
/**

View File

@ -39,7 +39,7 @@ function consoleOpened(HUD) {
waitForClipboard(
stringToCopy,
function() {
clipboardHelper.copyString(stringToCopy, document);
clipboardHelper.copyString(stringToCopy);
},
onClipboardCopy,
finishTest);

View File

@ -2874,7 +2874,7 @@ WebConsoleFrame.prototype = {
}
}
clipboardHelper.copyString(strings.join("\n"), this.document);
clipboardHelper.copyString(strings.join("\n"));
},
/**

View File

@ -157,18 +157,15 @@ function makeContentReadable(obj, window) {
}
function createNewChannel(uri, node, principal) {
return NetUtil.newChannel2(uri,
null,
null,
node, // aLoadingNode
principal, // aLoadingPrincipal
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
return NetUtil.newChannel({
uri: uri,
loadingNode: node,
loadingPrincipal: principal,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER});
}
function asyncFetchChannel(channel, callback) {
return NetUtil.asyncFetch2(channel, callback);
return NetUtil.asyncFetch(channel, callback);
}
// PDF data storage

View File

@ -86,7 +86,7 @@ function _imageFromURI(doc, uri, privateMode, callback) {
} catch (e) {
// Ignore channels which do not support nsIPrivateBrowsingChannel
}
NetUtil.asyncFetch2(channel, function(inputStream, resultCode) {
NetUtil.asyncFetch(channel, function(inputStream, resultCode) {
if (!Components.isSuccessCode(resultCode))
return;
try {

View File

@ -696,17 +696,13 @@ this.AppsUtils = {
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
file.initWithPath(aPath);
let channel = NetUtil.newChannel2(file,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let channel = NetUtil.newChannel({
uri: NetUtil.newURI(file),
loadUsingSystemPrincipal: true});
channel.contentType = "application/json";
NetUtil.asyncFetch2(channel, function(aStream, aResult) {
NetUtil.asyncFetch(channel, function(aStream, aResult) {
if (!Components.isSuccessCode(aResult)) {
deferred.resolve(null);

View File

@ -91,16 +91,12 @@ function storeCache(applicationCache, url, file, itemType, metadata) {
function readFile(aFile, aPrincipal, aCallback) {
let channel = NetUtil.newChannel2(aFile,
null,
null,
null, // aLoadingNode
aPrincipal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let channel = NetUtil.newChannel({
uri: NetUtil.newURI(aFile),
loadingPrincipal: aPrincipal,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER});
channel.contentType = "plain/text";
NetUtil.asyncFetch2(channel, function(aStream, aResult) {
NetUtil.asyncFetch(channel, function(aStream, aResult) {
if (!Components.isSuccessCode(aResult)) {
Cu.reportError("OfflineCacheInstaller: Could not read file " + aFile.path);
if (aCallback)

View File

@ -203,15 +203,11 @@ this.TrustedHostedAppsUtils = {
let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(
aApp.origin, aApp.localId, false);
let mRequestChannel = NetUtil.newChannel2(aApp.manifestURL,
null,
null,
null, // aLoadingNode
principal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER)
.QueryInterface(Ci.nsIHttpChannel);
let mRequestChannel = NetUtil.newChannel({
uri: aApp.manifestURL,
loadingPrincipal: principal,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER}
).QueryInterface(Ci.nsIHttpChannel);
mRequestChannel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
mRequestChannel.notificationCallbacks =
AppsUtils.createLoadContext(aAppId, false);
@ -232,15 +228,11 @@ this.TrustedHostedAppsUtils = {
return;
}
let sRequestChannel = NetUtil.newChannel2(signatureURL,
null,
null,
null, // aLoadingNode
principal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER)
.QueryInterface(Ci.nsIHttpChannel);
let sRequestChannel = NetUtil.newChannel({
uri: signatureURL,
loadingPrincipal: principal,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER}
).QueryInterface(Ci.nsIHttpChannel);
sRequestChannel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
sRequestChannel.notificationCallbacks =
AppsUtils.createLoadContext(aAppId, false);
@ -256,11 +248,11 @@ this.TrustedHostedAppsUtils = {
Promise.all([
new Promise((resolve, reject) => {
NetUtil.asyncFetch2(mRequestChannel,
NetUtil.asyncFetch(mRequestChannel,
getAsyncFetchCallback(resolve, reject));
}),
new Promise((resolve, reject) => {
NetUtil.asyncFetch2(sRequestChannel,
NetUtil.asyncFetch(sRequestChannel,
getAsyncFetchCallback(resolve, reject));
})
]).then(([aManifestStream, aSignatureStream]) => {

View File

@ -3527,25 +3527,17 @@ this.DOMApplicationRegistry = {
appURI, aNewApp.localId, false);
if (aIsLocalFileInstall) {
requestChannel = NetUtil.newChannel2(aFullPackagePath,
null,
null,
null, // aLoadingNode
principal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER)
.QueryInterface(Ci.nsIFileChannel);
requestChannel = NetUtil.newChannel({
uri: aFullPackagePath,
loadingPrincipal: principal,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER}
).QueryInterface(Ci.nsIFileChannel);
} else {
requestChannel = NetUtil.newChannel2(aFullPackagePath,
null,
null,
null, // aLoadingNode
principal,
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER)
.QueryInterface(Ci.nsIHttpChannel);
requestChannel = NetUtil.newChannel({
uri: aFullPackagePath,
loadingPrincipal: principal,
contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER}
).QueryInterface(Ci.nsIHttpChannel);
requestChannel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
}
@ -3640,7 +3632,10 @@ this.DOMApplicationRegistry = {
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
file.initWithPath(aFilePath);
NetUtil.asyncFetch2(file, function(inputStream, status) {
NetUtil.asyncFetch({
uri: NetUtil.newURI(file),
loadUsingSystemPrincipal: true
}, function(inputStream, status) {
if (!Components.isSuccessCode(status)) {
debug("Error reading " + aFilePath + ": " + e);
deferred.reject();
@ -3667,12 +3662,7 @@ this.DOMApplicationRegistry = {
debug("File hash computed: " + hash);
deferred.resolve(hash);
},
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
});
return deferred.promise;
},

View File

@ -1850,6 +1850,10 @@ public:
MOZ_ASSERT_UNREACHABLE("There are no storages");
}
virtual void
PerformIdleMaintenance() override
{ }
virtual void
ShutdownWorkThreads() override
{ }

View File

@ -1157,7 +1157,7 @@ void
FragmentOrElement::GetTextContentInternal(nsAString& aTextContent,
ErrorResult& aError)
{
if(!nsContentUtils::GetNodeTextContent(this, true, aTextContent)) {
if(!nsContentUtils::GetNodeTextContent(this, true, aTextContent, fallible)) {
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
}
}

8
dom/base/Makefile.in Normal file
View File

@ -0,0 +1,8 @@
# 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/.
INSTALL_TARGETS += usecounterlist
usecounterlist_FILES := UseCounterList.h
usecounterlist_DEST = $(DIST)/include/mozilla/dom
usecounterlist_TARGET := export

27
dom/base/UseCounter.h Normal file
View File

@ -0,0 +1,27 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 UseCounter_h_
#define UseCounter_h_
namespace mozilla {
enum UseCounter {
eUseCounter_UNKNOWN = -1,
#define USE_COUNTER_DOM_METHOD(interface_, name_) \
eUseCounter_##interface_##_##name_,
#define USE_COUNTER_DOM_ATTRIBUTE(interface_, name_) \
eUseCounter_##interface_##_##name_,
#define USE_COUNTER_CSS_PROPERTY(name_, id_) \
eUseCounter_property_##id_,
#include "mozilla/dom/UseCounterList.h"
#undef USE_COUNTER_DOM_METHOD
#undef USE_COUNTER_DOM_ATTRIBUTE
#undef USE_COUNTER_CSS_PROPERTY
eUseCounter_Count
};
}
#endif

33
dom/base/UseCounters.conf Normal file
View File

@ -0,0 +1,33 @@
// 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/.
// This file defines a list of use counters, which are things that can
// record usage of Web platform features and then report this information
// through Telemetry.
//
// The format of this file is very strict. Each line can be:
//
// (a) a blank line
//
// (b) a comment, which is a line that begins with "//"
//
// (c) an #if/ifdef/else/endif preprocessor directive
//
// (d) one of three possible use counter declarations:
//
// method <IDL interface name>.<IDL operation name>
// attribute <IDL interface name>.<IDL attribute name>
// property <CSS property name>
//
// To actually cause use counters to be incremented, DOM methods
// and attributes must have a [UseCounter] extended attribute in
// the Web IDL file, and CSS properties must be declared with
// the CSS_PROPERTY_HAS_USE_COUNTER flag in nsCSSPropList.h.
//
// You might reasonably ask why we have this file and we require
// annotating things with [UseCounter] in the relevant WebIDL file as
// well. Generating things from bindings codegen and ensuring all the
// dependencies were correct would have been rather difficult, and
// annotating the WebIDL files does nothing for identifying CSS
// property usage, which we would also like to track.

79
dom/base/gen-usecounters.py Executable file
View File

@ -0,0 +1,79 @@
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import print_function
import json
import os
import sys
sys.path.append(os.path.dirname(__file__))
import usecounters
AUTOGENERATED_WARNING_COMMENT = "/* THIS FILE IS AUTOGENERATED BY gen-usercounters.py - DO NOT EDIT */"
def generate_list(f, counters):
def print_optional_macro_declare(name):
print('''
#ifndef %(name)s
#define %(name)s(interface_, name_) // nothing
#define DEFINED_%(name)s
#endif
''' % { 'name': name }, file=f)
def print_optional_macro_undeclare(name):
print('''
#ifdef DEFINED_%(name)s
#undef DEFINED_%(name)s
#undef %(name)s
#endif
''' % { 'name': name }, file=f)
print(AUTOGENERATED_WARNING_COMMENT, file=f)
print_optional_macro_declare('USE_COUNTER_DOM_METHOD')
print_optional_macro_declare('USE_COUNTER_DOM_ATTRIBUTE')
print_optional_macro_declare('USE_COUNTER_CSS_PROPERTY')
for counter in counters:
if counter['type'] == 'method':
print('USE_COUNTER_DOM_METHOD(%s, %s)' % (counter['interface_name'], counter['method_name']), file=f)
elif counter['type'] == 'attribute':
print('USE_COUNTER_DOM_ATTRIBUTE(%s, %s)' % (counter['interface_name'], counter['attribute_name']), file=f)
elif counter['type'] == 'property':
prop = counter['property_name']
print('USE_COUNTER_CSS_PROPERTY(%s, %s)' % (prop, prop.replace('-', '_')), file=f)
print_optional_macro_undeclare('USE_COUNTER_DOM_METHOD')
print_optional_macro_undeclare('USE_COUNTER_DOM_ATTRIBUTE')
print_optional_macro_undeclare('USE_COUNTER_CSS_PROPERTY')
def generate_property_map(f, counters):
print(AUTOGENERATED_WARNING_COMMENT, file=f)
print('''
enum {
// XXX is this the right define?
#define CSS_PROP_LIST_INCLUDE_LOGICAL
#define CSS_PROP(name_, id_, method_, flags_, pref_, parsevariant_, \\
kwtable_, stylestruct_, stylestructoffset_, animtype_) \\
USE_COUNTER_FOR_CSS_PROPERTY_##id_ = eUseCounter_UNKNOWN,
#include "nsCSSPropList.h"
#undef CSS_PROP
#undef CSS_PROP_LIST_INCLUDE_LOGICAL
};
''', file=f)
for counter in counters:
if counter['type'] == 'property':
prop = counter['property_name'].replace('-', '_')
print('#define USE_COUNTER_FOR_CSS_PROPERTY_%s eUseCounter_property_%s' % (prop, prop), file=f)
def use_counter_list(output_header, conf_filename):
counters = usecounters.read_conf(conf_filename)
generate_list(output_header, counters)
def property_map(output_map, conf_filename):
counters = usecounters.read_conf(conf_filename)
generate_property_map(output_map, counters)

View File

@ -144,6 +144,7 @@ EXPORTS.mozilla += [
'CORSMode.h',
'FeedWriterEnabled.h',
'TextInputProcessor.h',
'UseCounter.h',
]
EXPORTS.mozilla.dom += [
@ -467,3 +468,16 @@ if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/android', 'xulrunner']:
if CONFIG['MOZ_X11']:
CXXFLAGS += CONFIG['TK_CFLAGS']
GENERATED_FILES += [
'PropertyUseCounterMap.inc',
'UseCounterList.h',
]
countermap = GENERATED_FILES['PropertyUseCounterMap.inc']
countermap.script = 'gen-usecounters.py:property_map'
countermap.inputs = ['UseCounters.conf']
counterlist = GENERATED_FILES['UseCounterList.h']
counterlist.script = 'gen-usecounters.py:use_counter_list'
counterlist.inputs = ['UseCounters.conf']

View File

@ -7057,10 +7057,19 @@ nsContentUtils::DOMWindowDumpEnabled()
}
bool
nsContentUtils::GetNodeTextContent(nsINode* aNode, bool aDeep, nsAString& aResult)
nsContentUtils::GetNodeTextContent(nsINode* aNode, bool aDeep, nsAString& aResult,
const fallible_t& aFallible)
{
aResult.Truncate();
return AppendNodeTextContent(aNode, aDeep, aResult, fallible);
return AppendNodeTextContent(aNode, aDeep, aResult, aFallible);
}
void
nsContentUtils::GetNodeTextContent(nsINode* aNode, bool aDeep, nsAString& aResult)
{
if (!GetNodeTextContent(aNode, aDeep, aResult, fallible)) {
NS_ABORT_OOM(0); // Unfortunately we don't know the allocation size
}
}
void

View File

@ -1279,6 +1279,9 @@ public:
*/
MOZ_WARN_UNUSED_RESULT
static bool GetNodeTextContent(nsINode* aNode, bool aDeep,
nsAString& aResult, const mozilla::fallible_t&);
static void GetNodeTextContent(nsINode* aNode, bool aDeep,
nsAString& aResult);
/**

View File

@ -7086,8 +7086,7 @@ nsDocument::GetTitleFromElement(uint32_t aNamespace, nsAString& aTitle)
nsIContent* title = GetTitleContent(aNamespace);
if (!title)
return;
if(!nsContentUtils::GetNodeTextContent(title, false, aTitle))
NS_RUNTIMEABORT("OOM");
nsContentUtils::GetNodeTextContent(title, false, aTitle);
}
NS_IMETHODIMP

View File

@ -404,7 +404,7 @@ nsStyleLinkElement::DoUpdateStyleSheet(nsIDocument* aOldDocument,
nsresult rv = NS_OK;
if (isInline) {
nsAutoString text;
if (!nsContentUtils::GetNodeTextContent(thisContent, false, text)) {
if (!nsContentUtils::GetNodeTextContent(thisContent, false, text, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -1396,9 +1396,8 @@ nsTreeSanitizer::SanitizeChildren(nsINode* aRoot)
NS_ASSERTION(ns == kNameSpaceID_XHTML || ns == kNameSpaceID_SVG,
"Should have only HTML or SVG here!");
nsAutoString styleText;
if (!nsContentUtils::GetNodeTextContent(node, false, styleText)) {
NS_RUNTIMEABORT("OOM");
}
nsContentUtils::GetNodeTextContent(node, false, styleText);
nsAutoString sanitizedStyle;
nsCOMPtr<nsIURI> baseURI = node->GetBaseURI();
if (SanitizeStyleSheet(styleText,

View File

@ -71,14 +71,9 @@ function makeTest(id, expectedJSON, useReportOnlyPolicy, callback) {
var selfuri = NetUtil.newURI(REPORT_SERVER_URI +
":" + REPORT_SERVER_PORT +
"/foo/self");
var selfchan = NetUtil.newChannel2(selfuri,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
var selfchan = NetUtil.newChannel({
uri: selfuri,
loadUsingSystemPrincipal: true});
dump("Created test " + id + " : " + policy + "\n\n");

View File

@ -41,44 +41,16 @@ function run_test() {
let spec2 = "http://bar.com/bar.html";
let uri1 = NetUtil.newURI(spec1);
let uri2 = NetUtil.newURI(spec2);
let channel1 = NetUtil.newChannel2(uri1,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let channel2 = NetUtil.newChannel2(uri2,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let channel1 = NetUtil.newChannel({uri: uri1, loadUsingSystemPrincipal: true});
let channel2 = NetUtil.newChannel({uri: uri2, loadUsingSystemPrincipal: true});
// Create some file:// URIs.
let filespec1 = "file://foo.txt";
let filespec2 = "file://bar.txt";
let fileuri1 = NetUtil.newURI(filespec1);
let fileuri2 = NetUtil.newURI(filespec2);
let filechannel1 = NetUtil.newChannel2(fileuri1,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let filechannel2 = NetUtil.newChannel2(fileuri2,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let filechannel1 = NetUtil.newChannel({uri: fileuri1, loadUsingSystemPrincipal: true});
let filechannel2 = NetUtil.newChannel({uri: fileuri2, loadUsingSystemPrincipal: true});
// Test isThirdPartyURI.
do_check_false(util.isThirdPartyURI(uri1, uri1));

78
dom/base/usecounters.py Normal file
View File

@ -0,0 +1,78 @@
# 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/.
import buildconfig
import collections
import re
import StringIO
import sys
from mozbuild.preprocessor import preprocess
def read_conf(conf_filename):
# Invoking the preprocessor ourselves is easier than writing build rules
# to do it for us.
processed = StringIO.StringIO()
preprocess(includes=[conf_filename],
defines=buildconfig.defines,
output=processed)
# Can't read/write from a single StringIO, so make a new one for reading.
stream = StringIO.StringIO(processed.getvalue())
def parse_counters(stream):
for line_num, line in enumerate(stream):
line = line.rstrip('\n')
if not line or line.startswith('//'):
# empty line or comment
continue
m = re.match(r'method ([A-Za-z0-9]+)\.([A-Za-z0-9]+)$', line)
if m:
interface_name, method_name = m.groups()
yield { 'type': 'method',
'interface_name': interface_name,
'method_name': method_name }
continue
m = re.match(r'attribute ([A-Za-z0-9]+)\.([A-Za-z0-9]+)$', line)
if m:
interface_name, attribute_name = m.groups()
yield { 'type': 'attribute',
'interface_name': interface_name,
'attribute_name': attribute_name }
continue
m = re.match(r'property ([a-z0-9-]+)$', line)
if m:
property_name = m.group(1)
yield { 'type': 'property',
'property_name': property_name }
continue
raise ValueError('error parsing %s at line %d' % (conf_filename, line_num))
return parse_counters(stream)
def generate_histograms(filename):
# The mapping for use counters to telemetry histograms depends on the
# ordering of items in the dictionary.
items = collections.OrderedDict()
for counter in read_conf(filename):
def append_counter(name, desc):
items[name] = { 'expires_in_version': 'never',
'kind' : 'boolean',
'description': desc }
def append_counters(name, desc):
append_counter('USE_COUNTER_%s_DOCUMENT' % name, 'Whether a document %s' % desc)
append_counter('USE_COUNTER_%s_PAGE' % name, 'Whether a page %s' % desc)
if counter['type'] == 'method':
method = '%s.%s' % (counter['interface_name'], counter['method_name'])
append_counters(method.replace('.', '_').upper(), 'called %s' % method)
elif counter['type'] == 'attribute':
attr = '%s.%s' % (counter['interface_name'], counter['attribute_name'])
append_counters(attr.replace('.', '_').upper(), 'got or set %s' % attr)
elif counter['type'] == 'property':
prop = counter['property_name']
append_counters('PROPERTY_%s' % prop.replace('-', '_').upper(), "used the '%s' property" % prop)
return items

View File

@ -2411,7 +2411,7 @@ IsInCertifiedApp(JSContext* aCx, JSObject* aObj)
#ifdef DEBUG
void
VerifyTraceProtoAndIfaceCacheCalled(JS::CallbackTracer *trc, void **thingp,
JSGCTraceKind kind)
JS::TraceKind kind)
{
// We don't do anything here, we only want to verify that
// TraceProtoAndIfaceCache was called.

View File

@ -528,7 +528,7 @@ AllocateProtoAndIfaceCache(JSObject* obj, ProtoAndIfaceCache::Kind aKind)
#ifdef DEBUG
void
VerifyTraceProtoAndIfaceCacheCalled(JS::CallbackTracer *trc, void **thingp,
JSGCTraceKind kind);
JS::TraceKind kind);
struct VerifyTraceProtoAndIfaceCacheCalledTracer : public JS::CallbackTracer
{

View File

@ -226,6 +226,9 @@ public:
}
}
virtual void
PerformIdleMaintenance() override
{ }
virtual void
ShutdownWorkThreads() override

View File

@ -124,14 +124,10 @@ ContactDB.prototype = {
}
}
let chan = jsm.NetUtil.newChannel2(contactsFile,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let chan = jsm.NetUtil.newChannel({
uri: NetUtil.newURI(contactsFile),
loadUsingSystemPrincipal: true});
let stream = chan.open();
// Obtain a converter to read from a UTF-8 encoded input stream.
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]

View File

@ -659,19 +659,20 @@ tv = {
}
},
// RFC 2409 <http://tools.ietf.org/html/rfc2409#section-6.1>
// RFC 2409 <http://tools.ietf.org/html/rfc2409#section-6.2>
dh: {
prime: util.hex2abv(
"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74" +
"020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f1437" +
"4fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"
"4fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7ed" +
"ee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"
),
prime2: util.hex2abv(
"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74" +
"020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f1437" +
"4fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7ed" +
"ee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"
"8b79f180cbd3f282de92e8b8f2d092674ffda61f01ed961f8ef04a1b7a3709ff" +
"748c2abf6226cf0c4538e48838193da456e92ee530ef7aa703e741585e475b26" +
"cd64fa97819181cef27de2449cd385c49c9b030f89873b5b7eaf063a788f00db" +
"3cb670c73846bc4f76af062d672bde8f29806b81548411ab48b99aebfd9c2d09"
),
},

View File

@ -344,7 +344,7 @@ IMPL_URI_PART(Hash)
NS_IMETHODIMP
HTMLAnchorElement::GetText(nsAString& aText)
{
if(!nsContentUtils::GetNodeTextContent(this, true, aText)) {
if(!nsContentUtils::GetNodeTextContent(this, true, aText, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;

View File

@ -49,7 +49,7 @@ HTMLElement::GetInnerHTML(nsAString& aInnerHTML)
*/
if (mNodeInfo->Equals(nsGkAtoms::xmp) ||
mNodeInfo->Equals(nsGkAtoms::plaintext)) {
if (!nsContentUtils::GetNodeTextContent(this, false, aInnerHTML)) {
if (!nsContentUtils::GetNodeTextContent(this, false, aInnerHTML, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;

View File

@ -372,9 +372,7 @@ void
HTMLMenuItemElement::GetText(nsAString& aText)
{
nsAutoString text;
if (!nsContentUtils::GetNodeTextContent(this, false, text)) {
NS_RUNTIMEABORT("OOM");
}
nsContentUtils::GetNodeTextContent(this, false, text);
text.CompressWhitespace(true, true);
aText = text;

View File

@ -147,9 +147,7 @@ HTMLOutputElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
void
HTMLOutputElement::GetValue(nsAString& aValue)
{
if (!nsContentUtils::GetNodeTextContent(this, true, aValue)) {
NS_RUNTIMEABORT("OOM");
}
nsContentUtils::GetNodeTextContent(this, true, aValue);
}
void
@ -180,9 +178,7 @@ HTMLOutputElement::HtmlFor()
void HTMLOutputElement::DescendantsChanged()
{
if (mIsDoneAddingChildren && mValueModeFlag == eModeDefault) {
if (!nsContentUtils::GetNodeTextContent(this, true, mDefaultValue)) {
NS_RUNTIMEABORT("OOM");
}
nsContentUtils::GetNodeTextContent(this, true, mDefaultValue);
}
}

View File

@ -110,7 +110,7 @@ HTMLScriptElement::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) c
NS_IMETHODIMP
HTMLScriptElement::GetText(nsAString& aValue)
{
if (!nsContentUtils::GetNodeTextContent(this, false, aValue)) {
if (!nsContentUtils::GetNodeTextContent(this, false, aValue, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
@ -222,7 +222,7 @@ HTMLScriptElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
NS_IMETHODIMP
HTMLScriptElement::GetInnerHTML(nsAString& aInnerHTML)
{
if (!nsContentUtils::GetNodeTextContent(this, false, aInnerHTML)) {
if (!nsContentUtils::GetNodeTextContent(this, false, aInnerHTML, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;

View File

@ -214,7 +214,7 @@ HTMLStyleElement::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute,
NS_IMETHODIMP
HTMLStyleElement::GetInnerHTML(nsAString& aInnerHTML)
{
if (!nsContentUtils::GetNodeTextContent(this, false, aInnerHTML)) {
if (!nsContentUtils::GetNodeTextContent(this, false, aInnerHTML, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;

View File

@ -362,7 +362,7 @@ HTMLTextAreaElement::SetValueChanged(bool aValueChanged)
NS_IMETHODIMP
HTMLTextAreaElement::GetDefaultValue(nsAString& aDefaultValue)
{
if (!nsContentUtils::GetNodeTextContent(this, false, aDefaultValue)) {
if (!nsContentUtils::GetNodeTextContent(this, false, aDefaultValue, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;

View File

@ -42,7 +42,7 @@ HTMLTitleElement::WrapNode(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
void
HTMLTitleElement::GetText(DOMString& aText, ErrorResult& aError)
{
if (!nsContentUtils::GetNodeTextContent(this, false, aText)) {
if (!nsContentUtils::GetNodeTextContent(this, false, aText, fallible)) {
aError = NS_ERROR_OUT_OF_MEMORY;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -96,4 +96,5 @@ LOCAL_INCLUDES += [
'/dom/workers',
'/ipc/glue',
'/xpcom/build',
'/xpcom/threads',
]

View File

@ -0,0 +1,136 @@
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
var testGenerator = testSteps();
function testSteps()
{
let uri = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService).
newURI("https://www.example.com", null, null);
let principal = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager).
getNoAppCodebasePrincipal(uri);
info("Setting permissions");
let permMgr =
Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager);
permMgr.add(uri, "indexedDB", Ci.nsIPermissionManager.ALLOW_ACTION);
info("Setting idle preferences to prevent real 'idle-daily' notification");
let prefs =
Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
prefs.setIntPref("idle.lastDailyNotification", (Date.now() / 1000) - 10);
info("Activating real idle service");
do_get_idle();
info("Creating databases");
let quotaManager =
Cc["@mozilla.org/dom/quota/manager;1"].getService(Ci.nsIQuotaManager);
let dbCount = 0;
for (let persistence of ["persistent", "temporary", "default"]) {
for (let i = 1; i <= 5; i++) {
let dbName = "foo-" + i;
let dbPersistence = persistence;
let req = indexedDB.openForPrincipal(principal,
dbName,
{ version: 1,
storage: dbPersistence });
req.onerror = event => {
if (dbPersistence != "persistent") {
errorHandler(event);
return;
}
// Explicit persistence is currently blocked on mobile.
info("Failed to create persistent database '" + dbPersistence + "/" +
dbName + "', hopefully this is on mobile!");
event.preventDefault();
if (!(--dbCount)) {
continueToNextStep();
}
};
req.onupgradeneeded = event => {
let db = event.target.result;
let objectStore = db.createObjectStore("foo");
// Add lots of data...
for (let j = 0; j < 100; j++) {
objectStore.add("abcdefghijklmnopqrstuvwxyz0123456789", j);
}
// And then clear it so that maintenance has some space to reclaim.
objectStore.clear();
};
req.onsuccess = event => {
let db = event.target.result;
ok(db, "Created database '" + dbPersistence + "/" + dbName + "'");
db.close();
if (!(--dbCount)) {
continueToNextStep();
}
};
dbCount++;
}
}
yield undefined;
info("Getting usage before maintenance");
let usageBeforeMaintenance;
quotaManager.getUsageForURI(uri, (url, usage) => {
ok(usage > 0, "Usage is non-zero");
usageBeforeMaintenance = usage;
continueToNextStep();
});
yield undefined;
info("Sending fake 'idle-daily' notification to QuotaManager");
let observer = quotaManager.QueryInterface(Ci.nsIObserver);
observer.observe(null, "idle-daily", "");
info("Waiting for maintenance to start");
// This time is totally arbitrary. Most likely directory scanning will have
// completed, QuotaManager locks will be acquired, and maintenance tasks will
// be scheduled before this time has elapsed, so we will be testing the
// maintenance code. However, if something is slow then this will test
// shutting down in the middle of maintenance.
setTimeout(continueToNextStep, 10000);
yield undefined;
info("Getting usage after maintenance");
let usageAfterMaintenance;
quotaManager.getUsageForURI(uri, (url, usage) => {
ok(usage > 0, "Usage is non-zero");
usageAfterMaintenance = usage;
continueToNextStep();
});
yield undefined;
info("Usage before: " + usageBeforeMaintenance + ". " +
"Usage after: " + usageAfterMaintenance);
ok(usageAfterMaintenance <= usageBeforeMaintenance,
"Maintenance decreased file sizes or left them the same");
finishTest();
yield undefined;
}

View File

@ -26,6 +26,7 @@ support-files =
[test_defaultStorageUpgrade.js]
[test_globalObjects_ipc.js]
skip-if = toolkit == 'android'
[test_idle_maintenance.js]
[test_invalidate.js]
# disabled for the moment.
skip-if = true

View File

@ -337,11 +337,26 @@ TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize)
FrameMetrics metrics(mLastRootMetrics);
metrics.SetViewport(CSSRect(CSSPoint(), viewport));
// Calculate the composition bounds based on mInnerSize, excluding the sizes
// of the scrollbars if they are not overlay scrollbars.
ScreenSize compositionSize(mInnerSize);
nsCOMPtr<nsIPresShell> shell = GetPresShell();
if (shell) {
nsMargin scrollbarsAppUnits =
nsLayoutUtils::ScrollbarAreaToExcludeFromCompositionBoundsFor(shell->GetRootScrollFrame());
// Scrollbars are not subject to scaling, so CSS pixels = screen pixels for them.
ScreenMargin scrollbars = CSSMargin::FromAppUnits(scrollbarsAppUnits)
* CSSToScreenScale(1.0f);
compositionSize.width -= scrollbars.LeftRight();
compositionSize.height -= scrollbars.TopBottom();
}
metrics.SetCompositionBounds(ParentLayerRect(
ParentLayerPoint(),
ParentLayerSize(ViewAs<ParentLayerPixel>(mInnerSize, PixelCastJustification::ScreenIsParentLayerForRoot))));
ParentLayerSize(ViewAs<ParentLayerPixel>(compositionSize, PixelCastJustification::ScreenIsParentLayerForRoot))));
metrics.SetRootCompositionSize(
ScreenSize(mInnerSize) * ScreenToLayoutDeviceScale(1.0f) / metrics.GetDevPixelsPerCSSPixel());
ScreenSize(compositionSize) * ScreenToLayoutDeviceScale(1.0f) / metrics.GetDevPixelsPerCSSPixel());
// This change to the zoom accounts for all types of changes I can conceive:
// 1. screen size changes, CSS viewport does not (pages with no meta viewport
@ -362,7 +377,6 @@ TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize)
// Changing the zoom when we're not doing a first paint will get ignored
// by AsyncPanZoomController and causes a blurry flash.
nsCOMPtr<nsIPresShell> shell = GetPresShell();
bool isFirstPaint = true;
if (shell) {
isFirstPaint = shell->GetIsFirstPaint();

View File

@ -1713,8 +1713,11 @@ void MediaDecoderStateMachine::NotifyDataArrived(const char* aBuffer,
//
// Make sure to only do this if we have a start time, otherwise the reader
// doesn't know how to compute GetBuffered.
if (!mDecoder->IsInfinite() || mStartTime == -1) {
return;
}
media::TimeIntervals buffered{mDecoder->GetBuffered()};
if (mDecoder->IsInfinite() && (mStartTime != -1) && !buffered.IsInvalid()) {
if (!buffered.IsInvalid()) {
bool exists;
media::TimeUnit end{buffered.GetEnd(&exists)};
if (exists) {

View File

@ -695,6 +695,9 @@ RTCPeerConnection.prototype = {
case "pranswer":
throw new this._win.DOMException("pranswer not yet implemented",
"NotSupportedError");
case "rollback":
type = Ci.IPeerConnection.kActionRollback;
break;
default:
throw new this._win.DOMException(
"Invalid type " + desc.type + " provided to setLocalDescription",
@ -768,6 +771,9 @@ RTCPeerConnection.prototype = {
case "pranswer":
throw new this._win.DOMException("pranswer not yet implemented",
"NotSupportedError");
case "rollback":
type = Ci.IPeerConnection.kActionRollback;
break;
default:
throw new this._win.DOMException(
"Invalid type " + desc.type + " provided to setRemoteDescription",

View File

@ -28,7 +28,7 @@ interface IPeerConnectionObserver : nsISupports
{
};
[scriptable, uuid(c9c31639-1a49-4533-8429-f6a348c4d8c3)]
[scriptable, uuid(14afc8e7-e421-4d0c-99a5-69308d871481)]
interface IPeerConnection : nsISupports
{
const unsigned long kHintAudio = 0x00000001;
@ -38,6 +38,7 @@ interface IPeerConnection : nsISupports
const long kActionOffer = 0;
const long kActionAnswer = 1;
const long kActionPRAnswer = 2;
const long kActionRollback = 3;
const long kIceGathering = 0;
const long kIceWaiting = 1;

View File

@ -380,8 +380,8 @@ CommandChain.prototype = {
/**
* Inserts the new commands after the specified command.
*/
insertAfter: function(functionOrName, commands) {
this._insertHelper(functionOrName, commands, 1);
insertAfter: function(functionOrName, commands, all, start) {
this._insertHelper(functionOrName, commands, 1, all, start);
},
/**
@ -431,8 +431,8 @@ CommandChain.prototype = {
/**
* Removes all commands after the specified one, returns what was removed.
*/
removeAfter: function(functionOrName) {
var index = this.indexOf(functionOrName);
removeAfter: function(functionOrName, start) {
var index = this.indexOf(functionOrName, start);
if (index >= 0) {
return this.commands.splice(index + 1);
}
@ -461,8 +461,8 @@ CommandChain.prototype = {
/**
* Replaces all commands after the specified one, returns what was removed.
*/
replaceAfter: function(functionOrName, commands) {
var oldCommands = this.removeAfter(functionOrName);
replaceAfter: function(functionOrName, commands, start) {
var oldCommands = this.removeAfter(functionOrName, start);
this.append(commands);
return oldCommands;
},

View File

@ -196,6 +196,14 @@ skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
[test_peerConnection_webAudio.html]
tags = webaudio webrtc
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
[test_peerConnection_localRollback.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
[test_peerConnection_localReofferRollback.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
[test_peerConnection_remoteRollback.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
[test_peerConnection_remoteReofferRollback.html]
skip-if = toolkit == 'gonk' || buildapp == 'mulet' # b2g (Bug 1059867)
# Bug 950317: Hack for making a cleanup hook after finishing all WebRTC cases
[test_zmedia_cleanup.html]

View File

@ -774,7 +774,6 @@ function PeerConnectionWrapper(label, configuration, h264) {
this._local_ice_candidates = [];
this._remote_ice_candidates = [];
this.holdIceCandidates = new Promise(r => this.releaseIceCandidates = r);
this.localRequiresTrickleIce = false;
this.remoteRequiresTrickleIce = false;
this.localMediaElements = [];
@ -1085,7 +1084,12 @@ PeerConnectionWrapper.prototype = {
this.observedNegotiationNeeded = undefined;
return this._pc.setRemoteDescription(desc).then(() => {
info(this + ": Successfully set remote description");
this.releaseIceCandidates();
if (desc.type == "rollback") {
this.holdIceCandidates = new Promise(r => this.releaseIceCandidates = r);
} else {
this.releaseIceCandidates();
}
});
},
@ -1318,6 +1322,7 @@ PeerConnectionWrapper.prototype = {
var resolveEndOfTrickle;
this.endOfTrickleIce = new Promise(r => resolveEndOfTrickle = r);
this.holdIceCandidates = new Promise(r => this.releaseIceCandidates = r);
this.endOfTrickleIce.then(() => {
this._pc.onicecandidate = () =>

View File

@ -0,0 +1,57 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "952145",
title: "Rollback local reoffer"
});
var test;
runNetworkTest(function (options) {
test = new PeerConnectionTest(options);
addRenegotiation(test.chain, [
function PC_LOCAL_ADD_SECOND_STREAM(test) {
test.setMediaConstraints([{audio: true}, {audio: true}],
[{audio: true}]);
return test.pcLocal.getAllUserMedia([{audio: true}]);
},
function PC_REMOTE_SETUP_ICE_HANDLER(test) {
test.pcRemote.setupIceCandidateHandler(test);
if (test.steeplechase) {
test.pcRemote.endOfTrickleIce.then(() => {
send_message({"type": "end_of_trickle_ice"});
});
}
},
function PC_REMOTE_CREATE_AND_SET_OFFER(test) {
return test.createOffer(test.pcRemote).then(offer => {
return test.setLocalDescription(test.pcRemote, offer, HAVE_LOCAL_OFFER);
});
},
function PC_REMOTE_ROLLBACK(test) {
return test.setLocalDescription(
test.pcRemote,
new mozRTCSessionDescription({ type: "rollback", sdp: ""}),
STABLE);
},
// Rolling back should shut down gathering
function PC_REMOTE_WAIT_FOR_END_OF_TRICKLE(test) {
return test.pcRemote.endOfTrickleIce;
},
]);
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.run();
});
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,51 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "952145",
title: "Rollback local offer"
});
var test;
runNetworkTest(function (options) {
test = new PeerConnectionTest(options);
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.chain.insertBefore('PC_LOCAL_CREATE_OFFER', [
function PC_REMOTE_CREATE_AND_SET_OFFER(test) {
return test.createOffer(test.pcRemote).then(offer => {
return test.setLocalDescription(test.pcRemote, offer, HAVE_LOCAL_OFFER);
});
},
function PC_REMOTE_ROLLBACK(test) {
return test.setLocalDescription(
test.pcRemote,
new mozRTCSessionDescription({ type: "rollback", sdp: ""}),
STABLE);
},
// Rolling back should shut down gathering
function PC_REMOTE_WAIT_FOR_END_OF_TRICKLE(test) {
return test.pcRemote.endOfTrickleIce;
},
function PC_REMOTE_SETUP_ICE_HANDLER(test) {
test.pcRemote.setupIceCandidateHandler(test);
if (test.steeplechase) {
test.pcRemote.endOfTrickleIce.then(() => {
send_message({"type": "end_of_trickle_ice"});
});
}
},
]);
test.run();
});
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "952145",
title: "Rollback remote reoffer"
});
var test;
runNetworkTest(function (options) {
test = new PeerConnectionTest(options);
addRenegotiation(test.chain,
[
function PC_LOCAL_ADD_SECOND_STREAM(test) {
test.setMediaConstraints([{audio: true}, {audio: true}],
[{audio: true}]);
return test.pcLocal.getAllUserMedia([{audio: true}]);
},
]
);
test.chain.replaceAfter('PC_REMOTE_SET_REMOTE_DESCRIPTION',
[
function PC_LOCAL_SETUP_ICE_HANDLER(test) {
test.pcLocal.setupIceCandidateHandler(test);
if (test.steeplechase) {
test.pcLocal.endOfTrickleIce.then(() => {
send_message({"type": "end_of_trickle_ice"});
});
}
},
function PC_REMOTE_ROLLBACK(test) {
return test.setRemoteDescription(
test.pcRemote,
new mozRTCSessionDescription({ type: "rollback" }),
STABLE);
},
function PC_LOCAL_ROLLBACK(test) {
return test.setLocalDescription(
test.pcLocal,
new mozRTCSessionDescription({ type: "rollback", sdp: ""}),
STABLE);
},
// Rolling back should shut down gathering
function PC_LOCAL_WAIT_FOR_END_OF_TRICKLE(test) {
return test.pcLocal.endOfTrickleIce;
},
],
1 // Second PC_REMOTE_SET_REMOTE_DESCRIPTION
);
test.chain.append(commandsPeerConnectionOfferAnswer);
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.run();
});
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,46 @@
<!DOCTYPE HTML>
<html>
<head>
<script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
createHTML({
bug: "952145",
title: "Rollback remote offer"
});
var test;
runNetworkTest(function (options) {
test = new PeerConnectionTest(options);
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.chain.removeAfter('PC_REMOTE_SET_REMOTE_DESCRIPTION');
test.chain.append([
function PC_REMOTE_ROLLBACK(test) {
return test.setRemoteDescription(
test.pcRemote,
new mozRTCSessionDescription({ type: "rollback" }),
STABLE);
},
function PC_LOCAL_ROLLBACK(test) {
return test.setLocalDescription(
test.pcLocal,
new mozRTCSessionDescription({ type: "rollback", sdp: ""}),
STABLE);
},
// Rolling back should shut down gathering
function PC_LOCAL_WAIT_FOR_END_OF_TRICKLE(test) {
return test.pcLocal.endOfTrickleIce;
},
]);
test.chain.append(commandsPeerConnectionOfferAnswer);
test.run();
});
</script>
</pre>
</body>
</html>

View File

@ -115,6 +115,9 @@ public:
WaitForStoragesToComplete(nsTArray<nsIOfflineStorage*>& aStorages,
nsIRunnable* aCallback) = 0;
virtual void
PerformIdleMaintenance() = 0;
virtual void
ShutdownWorkThreads() = 0;

View File

@ -10,6 +10,7 @@
#include "nsIBinaryInputStream.h"
#include "nsIBinaryOutputStream.h"
#include "nsIFile.h"
#include "nsIIdleService.h"
#include "nsIObserverService.h"
#include "nsIOfflineStorage.h"
#include "nsIPermissionManager.h"
@ -1078,7 +1079,7 @@ nsresult
GetDirectoryMetadataInputStream(nsIFile* aDirectory,
nsIBinaryInputStream** aStream)
{
AssertIsOnIOThread();
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aDirectory);
MOZ_ASSERT(aStream);
@ -1108,51 +1109,6 @@ GetDirectoryMetadataInputStream(nsIFile* aDirectory,
return NS_OK;
}
nsresult
GetDirectoryMetadata(nsIFile* aDirectory,
int64_t* aTimestamp,
nsACString& aGroup,
nsACString& aOrigin,
bool* aIsApp)
{
AssertIsOnIOThread();
MOZ_ASSERT(aDirectory);
MOZ_ASSERT(aTimestamp);
nsCOMPtr<nsIBinaryInputStream> binaryStream;
nsresult rv =
GetDirectoryMetadataInputStream(aDirectory, getter_AddRefs(binaryStream));
NS_ENSURE_SUCCESS(rv, rv);
uint64_t timestamp;
rv = binaryStream->Read64(&timestamp);
NS_ENSURE_SUCCESS(rv, rv);
nsCString group;
rv = binaryStream->ReadCString(group);
NS_ENSURE_SUCCESS(rv, rv);
nsCString origin;
rv = binaryStream->ReadCString(origin);
NS_ENSURE_SUCCESS(rv, rv);
bool isApp;
if (aIsApp) {
rv = binaryStream->ReadBoolean(&isApp);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
*aTimestamp = timestamp;
aGroup = group;
aOrigin = origin;
if (aIsApp) {
*aIsApp = isApp;
}
return NS_OK;
}
nsresult
GetDirectoryMetadataWithRestore(nsIFile* aDirectory,
bool aPersistent,
@ -1161,22 +1117,22 @@ GetDirectoryMetadataWithRestore(nsIFile* aDirectory,
nsACString& aOrigin,
bool* aIsApp)
{
nsresult rv = GetDirectoryMetadata(aDirectory,
aTimestamp,
aGroup,
aOrigin,
aIsApp);
nsresult rv = QuotaManager::GetDirectoryMetadata(aDirectory,
aTimestamp,
aGroup,
aOrigin,
aIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) {
rv = RestoreDirectoryMetadata(aDirectory, aPersistent);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = GetDirectoryMetadata(aDirectory,
aTimestamp,
aGroup,
aOrigin,
aIsApp);
rv = QuotaManager::GetDirectoryMetadata(aDirectory,
aTimestamp,
aGroup,
aOrigin,
aIsApp);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -1482,10 +1438,8 @@ QuotaManager::Init()
NS_ASSERTION(mClients.Capacity() == Client::TYPE_MAX,
"Should be using an auto array with correct capacity!");
nsRefPtr<Client> idbClient = indexedDB::CreateQuotaClient();
// Register clients.
mClients.AppendElement(idbClient);
mClients.AppendElement(indexedDB::CreateQuotaClient());
mClients.AppendElement(asmjscache::CreateClient());
mClients.AppendElement(cache::CreateQuotaClient());
@ -2776,6 +2730,52 @@ QuotaManager::ChromeOrigin(nsACString& aOrigin)
aOrigin.AssignLiteral(kChromeOrigin);
}
// static
nsresult
QuotaManager::GetDirectoryMetadata(nsIFile* aDirectory,
int64_t* aTimestamp,
nsACString& aGroup,
nsACString& aOrigin,
bool* aIsApp)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(aDirectory);
MOZ_ASSERT(aTimestamp);
nsCOMPtr<nsIBinaryInputStream> binaryStream;
nsresult rv =
GetDirectoryMetadataInputStream(aDirectory, getter_AddRefs(binaryStream));
NS_ENSURE_SUCCESS(rv, rv);
uint64_t timestamp;
rv = binaryStream->Read64(&timestamp);
NS_ENSURE_SUCCESS(rv, rv);
nsCString group;
rv = binaryStream->ReadCString(group);
NS_ENSURE_SUCCESS(rv, rv);
nsCString origin;
rv = binaryStream->ReadCString(origin);
NS_ENSURE_SUCCESS(rv, rv);
bool isApp;
if (aIsApp) {
rv = binaryStream->ReadBoolean(&isApp);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
*aTimestamp = timestamp;
aGroup = group;
aOrigin = origin;
if (aIsApp) {
*aIsApp = isApp;
}
return NS_OK;
}
NS_IMPL_ISUPPORTS(QuotaManager, nsIQuotaManager, nsIObserver)
NS_IMETHODIMP
@ -3061,6 +3061,13 @@ QuotaManager::Observe(nsISupports* aSubject,
return NS_OK;
}
if (!strcmp(aTopic, OBSERVER_TOPIC_IDLE_DAILY)) {
for (auto& client : mClients) {
client->PerformIdleMaintenance();
}
return NS_OK;
}
NS_NOTREACHED("Unknown topic!");
return NS_ERROR_UNEXPECTED;
}

View File

@ -313,6 +313,13 @@ public:
EmptyCString(), _retval);
}
static nsresult
GetDirectoryMetadata(nsIFile* aDirectory,
int64_t* aTimestamp,
nsACString& aGroup,
nsACString& aOrigin,
bool* aIsApp);
private:
QuotaManager();

View File

@ -80,14 +80,9 @@ SettingsDB.prototype = {
}
}
let chan = NetUtil.newChannel2(settingsFile,
null,
null,
null, // aLoadingNode
Services.scriptSecurityManager.getSystemPrincipal(),
null, // aTriggeringPrincipal
Ci.nsILoadInfo.SEC_NORMAL,
Ci.nsIContentPolicy.TYPE_OTHER);
let chan = NetUtil.newChannel({
uri: NetUtil.newURI(settingsFile),
loadUsingSystemPrincipal: true});
let stream = chan.open();
// Obtain a converter to read from a UTF-8 encoded input stream.
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]

View File

@ -784,22 +784,23 @@ nsSMILAnimationFunction::GetValues(const nsISMILAttr& aSMILAttr,
return NS_ERROR_FAILURE;
}
// AppendElement() below must succeed, because SetCapacity() succeeded.
if (!to.IsNull()) {
if (!from.IsNull()) {
result.AppendElement(from);
result.AppendElement(to);
MOZ_ALWAYS_TRUE(result.AppendElement(from));
MOZ_ALWAYS_TRUE(result.AppendElement(to));
} else {
result.AppendElement(to);
MOZ_ALWAYS_TRUE(result.AppendElement(to));
}
} else if (!by.IsNull()) {
nsSMILValue effectiveFrom(by.mType);
if (!from.IsNull())
effectiveFrom = from;
// Set values to 'from; from + by'
result.AppendElement(effectiveFrom);
MOZ_ALWAYS_TRUE(result.AppendElement(effectiveFrom));
nsSMILValue effectiveTo(effectiveFrom);
if (!effectiveTo.IsNull() && NS_SUCCEEDED(effectiveTo.Add(by))) {
result.AppendElement(effectiveTo);
MOZ_ALWAYS_TRUE(result.AppendElement(effectiveTo));
} else {
// Using by-animation with non-additive type or bad base-value
return NS_ERROR_FAILURE;

View File

@ -266,7 +266,7 @@ DOMSVGLengthList::InsertItemBefore(DOMSVGLength& newItem,
MaybeInsertNullInAnimValListAt(index);
InternalList().InsertItem(index, domItem->ToSVGLength());
mItems.InsertElementAt(index, domItem.get());
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(index, domItem.get()));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad
@ -380,7 +380,7 @@ DOMSVGLengthList::MaybeInsertNullInAnimValListAt(uint32_t aIndex)
MOZ_ASSERT(animVal->mItems.Length() == mItems.Length(),
"animVal list not in sync!");
animVal->mItems.InsertElementAt(aIndex, static_cast<DOMSVGLength*>(nullptr));
MOZ_ALWAYS_TRUE(animVal->mItems.InsertElementAt(aIndex, nullptr));
UpdateListIndicesFromIndex(animVal->mItems, aIndex + 1);
}

View File

@ -250,7 +250,7 @@ DOMSVGNumberList::InsertItemBefore(DOMSVGNumber& aItem,
MaybeInsertNullInAnimValListAt(index);
InternalList().InsertItem(index, domItem->ToSVGNumber());
mItems.InsertElementAt(index, domItem);
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(index, domItem));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad
@ -359,7 +359,7 @@ DOMSVGNumberList::MaybeInsertNullInAnimValListAt(uint32_t aIndex)
MOZ_ASSERT(animVal->mItems.Length() == mItems.Length(),
"animVal list not in sync!");
animVal->mItems.InsertElementAt(aIndex, static_cast<DOMSVGNumber*>(nullptr));
MOZ_ALWAYS_TRUE(animVal->mItems.InsertElementAt(aIndex, nullptr));
UpdateListIndicesFromIndex(animVal->mItems, aIndex + 1);
}

View File

@ -384,8 +384,12 @@ DOMSVGPathSegList::InsertItemBefore(DOMSVGPathSeg& aNewItem,
float segAsRaw[1 + NS_SVG_PATH_SEG_MAX_ARGS];
domItem->ToSVGPathSegEncodedData(segAsRaw);
InternalList().mData.InsertElementsAt(internalIndex, segAsRaw, 1 + argCount);
mItems.InsertElementAt(aIndex, ItemProxy(domItem.get(), internalIndex));
MOZ_ALWAYS_TRUE(InternalList().mData.InsertElementsAt(internalIndex,
segAsRaw,
1 + argCount));
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(aIndex,
ItemProxy(domItem.get(),
internalIndex)));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad
@ -537,7 +541,9 @@ DOMSVGPathSegList::
MOZ_ASSERT(animVal->mItems.Length() == mItems.Length(),
"animVal list not in sync!");
animVal->mItems.InsertElementAt(aIndex, ItemProxy(nullptr, aInternalIndex));
MOZ_ALWAYS_TRUE(animVal->mItems.InsertElementAt(aIndex,
ItemProxy(nullptr,
aInternalIndex)));
animVal->UpdateListIndicesFromIndex(aIndex + 1, 1 + aArgCountForItem);
}

View File

@ -317,7 +317,7 @@ DOMSVGPointList::InsertItemBefore(nsISVGPoint& aNewItem, uint32_t aIndex,
MaybeInsertNullInAnimValListAt(aIndex);
InternalList().InsertItem(aIndex, domItem->ToSVGPoint());
mItems.InsertElementAt(aIndex, domItem);
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(aIndex, domItem));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad
@ -433,7 +433,7 @@ DOMSVGPointList::MaybeInsertNullInAnimValListAt(uint32_t aIndex)
MOZ_ASSERT(animVal->mItems.Length() == mItems.Length(),
"animVal list not in sync!");
animVal->mItems.InsertElementAt(aIndex, static_cast<nsISVGPoint*>(nullptr));
MOZ_ALWAYS_TRUE(animVal->mItems.InsertElementAt(aIndex, nullptr));
UpdateListIndicesFromIndex(animVal->mItems, aIndex + 1);
}

View File

@ -258,7 +258,7 @@ DOMSVGTransformList::InsertItemBefore(SVGTransform& newItem,
MaybeInsertNullInAnimValListAt(index);
InternalList().InsertItem(index, domItem->ToSVGTransform());
mItems.InsertElementAt(index, domItem.get());
MOZ_ALWAYS_TRUE(mItems.InsertElementAt(index, domItem.get()));
// This MUST come after the insertion into InternalList(), or else under the
// insertion into InternalList() the values read from domItem would be bad
@ -406,8 +406,7 @@ DOMSVGTransformList::MaybeInsertNullInAnimValListAt(uint32_t aIndex)
MOZ_ASSERT(animVal->mItems.Length() == mItems.Length(),
"animVal list not in sync!");
animVal->mItems.InsertElementAt(aIndex,
static_cast<SVGTransform*>(nullptr));
MOZ_ALWAYS_TRUE(animVal->mItems.InsertElementAt(aIndex, nullptr));
UpdateListIndicesFromIndex(animVal->mItems, aIndex + 1);
}

View File

@ -307,8 +307,7 @@ SVGMotionSMILType::Add(nsSMILValue& aDest, const nsSMILValue& aValueToAdd,
// Replace destination's current value -- a point-on-a-path -- with the
// translation that results from our addition.
dstArr.Clear();
dstArr.AppendElement(MotionSegment(newX, newY, rotateAngle));
dstArr.ReplaceElementAt(0, MotionSegment(newX, newY, rotateAngle));
return NS_OK;
}
@ -441,8 +440,9 @@ SVGMotionSMILType::Interpolate(const nsSMILValue& aStartVal,
// Construct the intermediate result segment, and put it in our outparam.
// AppendElement has guaranteed success here, since Init() allocates 1 slot.
resultArr.AppendElement(MotionSegment(path, resultDist,
rotateType, rotateAngle));
MOZ_ALWAYS_TRUE(resultArr.AppendElement(MotionSegment(path, resultDist,
rotateType,
rotateAngle)));
return NS_OK;
}
@ -484,7 +484,8 @@ SVGMotionSMILType::ConstructSMILValue(Path* aPath,
MotionSegmentArray& arr = ExtractMotionSegmentArray(smilVal);
// AppendElement has guaranteed success here, since Init() allocates 1 slot.
arr.AppendElement(MotionSegment(aPath, aDist, aRotateType, aRotateAngle));
MOZ_ALWAYS_TRUE(arr.AppendElement(MotionSegment(aPath, aDist,
aRotateType, aRotateAngle)));
return smilVal;
}

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