From 479716c93080f20274cc935524cb5a8ffaf077fb Mon Sep 17 00:00:00 2001 From: Corey Ford Date: Tue, 30 Jul 2013 21:01:06 -0700 Subject: [PATCH 01/40] Bug 894716 - Parameterize nsLayoutUtils::GetNearestScrollableFrame. r=dbaron --- layout/base/nsLayoutUtils.cpp | 8 +++++--- layout/base/nsLayoutUtils.h | 11 +++++++++-- layout/generic/nsFrame.cpp | 30 ++++++++++++------------------ 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 62d7785f1bb0..d31ae80dc0ae 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1165,14 +1165,16 @@ nsLayoutUtils::GetNearestScrollableFrameForDirection(nsIFrame* aFrame, // static nsIScrollableFrame* -nsLayoutUtils::GetNearestScrollableFrame(nsIFrame* aFrame) +nsLayoutUtils::GetNearestScrollableFrame(nsIFrame* aFrame, uint32_t aFlags) { NS_ASSERTION(aFrame, "GetNearestScrollableFrame expects a non-null frame"); - for (nsIFrame* f = aFrame; f; f = nsLayoutUtils::GetCrossDocParentFrame(f)) { + for (nsIFrame* f = aFrame; f; f = (aFlags & SCROLLABLE_SAME_DOC) ? + f->GetParent() : nsLayoutUtils::GetCrossDocParentFrame(f)) { nsIScrollableFrame* scrollableFrame = do_QueryFrame(f); if (scrollableFrame) { nsPresContext::ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles(); - if (ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN || + if ((aFlags & SCROLLABLE_INCLUDE_HIDDEN) || + ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN || ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) return scrollableFrame; } diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 313738005098..7da8306f94af 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -378,16 +378,23 @@ public: static nsIScrollableFrame* GetNearestScrollableFrameForDirection(nsIFrame* aFrame, Direction aDirection); + enum { + SCROLLABLE_SAME_DOC = 0x01, + SCROLLABLE_INCLUDE_HIDDEN = 0x02 + }; /** * GetNearestScrollableFrame locates the first ancestor of aFrame * (or aFrame itself) that is scrollable with overflow:scroll or * overflow:auto in some direction. - * The search extends across document boundaries. * * @param aFrame the frame to start with + * @param aFlags if SCROLLABLE_SAME_DOC is set, do not search across + * document boundaries. If SCROLLABLE_INCLUDE_HIDDEN is set, include + * frames scrollable with overflow:hidden. * @return the nearest scrollable frame or nullptr if not found */ - static nsIScrollableFrame* GetNearestScrollableFrame(nsIFrame* aFrame); + static nsIScrollableFrame* GetNearestScrollableFrame(nsIFrame* aFrame, + uint32_t aFlags = 0); /** * GetScrolledRect returns the range of allowable scroll offsets diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index acdcba7c86c0..ca3982356ef0 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -2554,15 +2554,14 @@ nsFrame::HandlePress(nsPresContext* aPresContext, // frame, or something else is already capturing the mouse, there's no // reason to capture. if (!nsIPresShell::GetCapturingContent()) { - nsIFrame* checkFrame = this; - nsIScrollableFrame *scrollFrame = nullptr; - while (checkFrame) { - scrollFrame = do_QueryFrame(checkFrame); - if (scrollFrame) { - nsIPresShell::SetCapturingContent(checkFrame->GetContent(), CAPTURE_IGNOREALLOWED); - break; - } - checkFrame = checkFrame->GetParent(); + nsIScrollableFrame* scrollFrame = + nsLayoutUtils::GetNearestScrollableFrame(this, + nsLayoutUtils::SCROLLABLE_SAME_DOC | + nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN); + if (scrollFrame) { + nsIFrame* capturingFrame = do_QueryFrame(scrollFrame); + nsIPresShell::SetCapturingContent(capturingFrame->GetContent(), + CAPTURE_IGNOREALLOWED); } } @@ -2925,15 +2924,10 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsPresContext* aPresContext, } // get the nearest scrollframe - nsIFrame* checkFrame = this; - nsIScrollableFrame *scrollFrame = nullptr; - while (checkFrame) { - scrollFrame = do_QueryFrame(checkFrame); - if (scrollFrame) { - break; - } - checkFrame = checkFrame->GetParent(); - } + nsIScrollableFrame* scrollFrame = + nsLayoutUtils::GetNearestScrollableFrame(this, + nsLayoutUtils::SCROLLABLE_SAME_DOC | + nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN); if (scrollFrame) { nsIFrame* capturingFrame = scrollFrame->GetScrolledFrame(); From 42290cd6596e7bd1041ae65ad464afe34f6e2b69 Mon Sep 17 00:00:00 2001 From: Masatoshi Kimura Date: Wed, 31 Jul 2013 09:25:31 -0400 Subject: [PATCH 02/40] Bug 898136 - Remove nsIDOMGlobalObjectConstructor. r=mrbkap --- dom/base/nsDOMClassInfo.cpp | 63 ++----------------- dom/interfaces/base/moz.build | 1 - .../base/nsIDOMGlobalObjectConstructor.idl | 19 ------ 3 files changed, 4 insertions(+), 79 deletions(-) delete mode 100644 dom/interfaces/base/nsIDOMGlobalObjectConstructor.idl diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 39288e49e587..13104f7b49f0 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -256,7 +256,6 @@ using mozilla::dom::workers::ResolveWorkerClasses; #include "DOMCameraCapabilities.h" #include "nsIOpenWindowEventDetail.h" #include "nsIAsyncScrollEventDetail.h" -#include "nsIDOMGlobalObjectConstructor.h" #include "nsIDOMCanvasRenderingContext2D.h" #include "LockedFile.h" #include "nsDebug.h" @@ -2729,8 +2728,7 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner, } nsCOMPtr initializer(do_QueryInterface(native)); - nsCOMPtr constructor(do_QueryInterface(native)); - if (initializer || constructor) { + if (initializer) { // Initialize object using the current inner window, but only if // the caller can access it. nsCOMPtr owner = do_QueryReferent(aWeakOwner); @@ -2743,62 +2741,9 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner, return NS_ERROR_DOM_SECURITY_ERR; } - if (initializer) { - rv = initializer->Initialize(currentInner, cx, obj, args); - if (NS_FAILED(rv)) { - return rv; - } - } else { - nsCOMPtr wrappedJS = do_QueryInterface(native); - - JS::Rooted thisObject(cx, wrappedJS->GetJSObject()); - if (!thisObject) { - return NS_ERROR_UNEXPECTED; - } - - nsCxPusher pusher; - pusher.Push(cx); - - JSAutoCompartment ac(cx, thisObject); - - JS::Rooted funval(cx); - if (!JS_GetProperty(cx, thisObject, "constructor", &funval) || - !funval.isObject()) { - return NS_ERROR_UNEXPECTED; - } - - // Check if the object is even callable. - NS_ENSURE_STATE(JS_ObjectIsCallable(cx, &funval.toObject())); - { - // wrap parameters in the target compartment - // we also pass in the calling window as the first argument - unsigned argc = args.length() + 1; - nsAutoArrayPtr argv(new JS::Value[argc]); - JS::AutoArrayRooter rooter(cx, 0, argv); - - nsCOMPtr holder; - nsCOMPtr currentWin(do_GetInterface(currentInner)); - rv = WrapNative(cx, obj, currentWin, &NS_GET_IID(nsIDOMWindow), - true, &argv[0], getter_AddRefs(holder)); - if (!JS_WrapValue(cx, &argv[0])) - return NS_ERROR_FAILURE; - rooter.changeLength(1); - - for (size_t i = 1; i < argc; ++i) { - argv[i] = args[i - 1]; - if (!JS_WrapValue(cx, &argv[i])) - return NS_ERROR_FAILURE; - rooter.changeLength(i + 1); - } - - JS::Rooted frval(cx); - bool ret = JS_CallFunctionValue(cx, thisObject, funval, argc, argv, - frval.address()); - - if (!ret) { - return NS_ERROR_FAILURE; - } - } + rv = initializer->Initialize(currentInner, cx, obj, args); + if (NS_FAILED(rv)) { + return rv; } } diff --git a/dom/interfaces/base/moz.build b/dom/interfaces/base/moz.build index f168c5e32178..c4c8cd1fd0bc 100644 --- a/dom/interfaces/base/moz.build +++ b/dom/interfaces/base/moz.build @@ -16,7 +16,6 @@ XPIDL_SOURCES += [ 'nsIDOMClientRect.idl', 'nsIDOMClientRectList.idl', 'nsIDOMConstructor.idl', - 'nsIDOMGlobalObjectConstructor.idl', 'nsIDOMGlobalPropertyInitializer.idl', 'nsIDOMHistory.idl', 'nsIDOMJSWindow.idl', diff --git a/dom/interfaces/base/nsIDOMGlobalObjectConstructor.idl b/dom/interfaces/base/nsIDOMGlobalObjectConstructor.idl deleted file mode 100644 index 6d49efdcb765..000000000000 --- a/dom/interfaces/base/nsIDOMGlobalObjectConstructor.idl +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- Mode: IDL; 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/. */ - -#include "domstubs.idl" - -[scriptable, uuid(cb439c73-0129-4289-a349-c5216e6b912a)] -interface nsIDOMGlobalObjectConstructor : nsISupports -{ - /* - * JS use only - * - * The constructor() method will be called with any parameters passed - * to the object constructor. - * If the JS implementation returns a value, it will be ignored. - */ - void constructor(); -}; From e854bc2ed36c3176c35281ed53d87e1d081d92ab Mon Sep 17 00:00:00 2001 From: Dirk Schulze Date: Wed, 31 Jul 2013 09:26:45 -0400 Subject: [PATCH 03/40] Bug 898361 - [CSS Filters] Implement parsing for drop-shadow. r=heycam --- layout/style/nsCSSKeywordList.h | 1 + layout/style/nsCSSParser.cpp | 42 ++++++++++++++++++- layout/style/nsComputedDOMStyle.cpp | 33 ++++++++++----- layout/style/nsComputedDOMStyle.h | 2 +- layout/style/nsRuleNode.cpp | 57 ++++++++++++++++---------- layout/style/nsRuleNode.h | 7 +++- layout/style/nsStyleStruct.cpp | 56 ++++++++++++++++++++++--- layout/style/nsStyleStruct.h | 57 ++++++++++++++++++++++---- layout/style/test/property_database.js | 34 +++++++++++++++ 9 files changed, 240 insertions(+), 49 deletions(-) diff --git a/layout/style/nsCSSKeywordList.h b/layout/style/nsCSSKeywordList.h index ee53ad464ea9..38dd3bdc5fea 100644 --- a/layout/style/nsCSSKeywordList.h +++ b/layout/style/nsCSSKeywordList.h @@ -242,6 +242,7 @@ CSS_KEY(disc, disc) CSS_KEY(discretionary-ligatures, discretionary_ligatures) CSS_KEY(dotted, dotted) CSS_KEY(double, double) +CSS_KEY(drop-shadow, drop_shadow) CSS_KEY(e-resize, e_resize) CSS_KEY(each-box, each_box) CSS_KEY(ease, ease) diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index f9aaad7fd88b..e319805bd3da 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -607,6 +607,7 @@ protected: /* Functions for filter parsing */ bool ParseFilter(); bool ParseSingleFilter(nsCSSValue* aValue); + bool ParseDropShadow(nsCSSValue* aValue); /* Find and return the namespace ID associated with aPrefix. If aPrefix has not been declared in an @namespace rule, returns @@ -10051,6 +10052,32 @@ bool CSSParserImpl::ParseTransformOrigin(bool aPerspective) return true; } +/** + * Reads a drop-shadow value. At the moment the Filter Effects specification + * just expects one shadow item. Should this ever change to a list of shadow + * items, use ParseShadowList instead. + */ +bool +CSSParserImpl::ParseDropShadow(nsCSSValue* aValue) +{ + // Use nsCSSValueList to reuse the shadow resolving code in + // nsRuleNode and nsComputedDOMStyle. + nsCSSValue shadow; + nsCSSValueList* cur = shadow.SetListValue(); + if (!ParseShadowItem(cur->mValue, false)) + return false; + + if (!ExpectSymbol(')', true)) + return false; + + nsCSSValue::Array* dropShadow = aValue->InitFunction(eCSSKeyword_drop_shadow, 1); + + // Copy things over. + dropShadow->Item(1) = shadow; + + return true; +} + /** * Reads a single url or filter function from the tokenizer stream, reporting an * error if something goes wrong. @@ -10078,11 +10105,24 @@ CSSParserImpl::ParseSingleFilter(nsCSSValue* aValue) return false; } + nsCSSKeyword functionName = nsCSSKeywords::LookupKeyword(mToken.mIdent); + // Parse drop-shadow independently of the other filter functions + // because of its more complex characteristics. + if (functionName == eCSSKeyword_drop_shadow) { + if (ParseDropShadow(aValue)) { + return true; + } else { + // Unrecognized filter function. + REPORT_UNEXPECTED_TOKEN(PEExpectedNoneOrURLOrFilterFunction); + SkipUntil(')'); + return false; + } + } + // Set up the parsing rules based on the filter function. int32_t variantMask = VARIANT_PN; bool rejectNegativeArgument = true; bool clampArgumentToOne = false; - nsCSSKeyword functionName = nsCSSKeywords::LookupKeyword(mToken.mIdent); switch (functionName) { case eCSSKeyword_blur: variantMask = VARIANT_LCALC | VARIANT_NONNEGATIVE_DIMENSION; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 01c7cbcebd82..05b3fa0a34b9 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -4498,9 +4498,9 @@ nsComputedDOMStyle::SetCssTextToCoord(nsAString& aCssText, } static void -GetFilterFunctionName(nsAString& aString, nsStyleFilter::Type mType) +GetFilterFunctionName(nsAString& aString, nsStyleFilter::Type aType) { - switch (mType) { + switch (aType) { case nsStyleFilter::Type::eBlur: aString.AssignLiteral("blur("); break; @@ -4510,6 +4510,9 @@ GetFilterFunctionName(nsAString& aString, nsStyleFilter::Type mType) case nsStyleFilter::Type::eContrast: aString.AssignLiteral("contrast("); break; + case nsStyleFilter::Type::eDropShadow: + aString.AssignLiteral("drop-shadow("); + break; case nsStyleFilter::Type::eGrayscale: aString.AssignLiteral("grayscale("); break; @@ -4533,25 +4536,34 @@ GetFilterFunctionName(nsAString& aString, nsStyleFilter::Type mType) } } -nsROCSSPrimitiveValue* +CSSValue* nsComputedDOMStyle::CreatePrimitiveValueForStyleFilter( const nsStyleFilter& aStyleFilter) { nsROCSSPrimitiveValue* value = new nsROCSSPrimitiveValue; - // Handle url(). - if (nsStyleFilter::Type::eURL == aStyleFilter.mType) { - value->SetURI(aStyleFilter.mURL); + if (nsStyleFilter::Type::eURL == aStyleFilter.GetType()) { + value->SetURI(aStyleFilter.GetURL()); return value; } // Filter function name and opening parenthesis. nsAutoString filterFunctionString; - GetFilterFunctionName(filterFunctionString, aStyleFilter.mType); + GetFilterFunctionName(filterFunctionString, aStyleFilter.GetType()); - // Filter function argument. nsAutoString argumentString; - SetCssTextToCoord(argumentString, aStyleFilter.mFilterParameter); + if (nsStyleFilter::Type::eDropShadow == aStyleFilter.GetType()) { + // Handle drop-shadow() + nsRefPtr shadowValue = + GetCSSShadowArray(aStyleFilter.GetDropShadow(), + StyleColor()->mColor, + false); + ErrorResult dummy; + shadowValue->GetCssText(argumentString, dummy); + } else { + // Filter function argument. + SetCssTextToCoord(argumentString, aStyleFilter.GetFilterParameter()); + } filterFunctionString.Append(argumentString); // Filter function closing parenthesis. @@ -4574,8 +4586,7 @@ nsComputedDOMStyle::DoGetFilter() nsDOMCSSValueList* valueList = GetROCSSValueList(false); for(uint32_t i = 0; i < filters.Length(); i++) { - nsROCSSPrimitiveValue* value = - CreatePrimitiveValueForStyleFilter(filters[i]); + CSSValue* value = CreatePrimitiveValueForStyleFilter(filters[i]); valueList->AppendCSSValue(value); } return valueList; diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index c75265eda958..dc671b30a294 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -494,7 +494,7 @@ private: /* Helper functions for computing the filter property style. */ void SetCssTextToCoord(nsAString& aCssText, const nsStyleCoord& aCoord); - nsROCSSPrimitiveValue* CreatePrimitiveValueForStyleFilter( + mozilla::dom::CSSValue* CreatePrimitiveValueForStyleFilter( const nsStyleFilter& aStyleFilter); struct ComputedStyleMapEntry diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 3c8bd1eda265..cab366d6809b 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -3752,7 +3752,7 @@ already_AddRefed nsRuleNode::GetShadowData(const nsCSSValueList* aList, nsStyleContext* aContext, bool aIsBoxShadow, - bool& canStoreInRuleTree) + bool& aCanStoreInRuleTree) { uint32_t arrayLength = ListLength(aList); @@ -3775,13 +3775,13 @@ nsRuleNode::GetShadowData(const nsCSSValueList* aList, // OK to pass bad aParentCoord since we're not passing SETCOORD_INHERIT unitOK = SetCoord(arr->Item(0), tempCoord, nsStyleCoord(), SETCOORD_LENGTH | SETCOORD_CALC_LENGTH_ONLY, - aContext, mPresContext, canStoreInRuleTree); + aContext, mPresContext, aCanStoreInRuleTree); NS_ASSERTION(unitOK, "unexpected unit"); item->mXOffset = tempCoord.GetCoordValue(); unitOK = SetCoord(arr->Item(1), tempCoord, nsStyleCoord(), SETCOORD_LENGTH | SETCOORD_CALC_LENGTH_ONLY, - aContext, mPresContext, canStoreInRuleTree); + aContext, mPresContext, aCanStoreInRuleTree); NS_ASSERTION(unitOK, "unexpected unit"); item->mYOffset = tempCoord.GetCoordValue(); @@ -3790,7 +3790,7 @@ nsRuleNode::GetShadowData(const nsCSSValueList* aList, unitOK = SetCoord(arr->Item(2), tempCoord, nsStyleCoord(), SETCOORD_LENGTH | SETCOORD_CALC_LENGTH_ONLY | SETCOORD_CALC_CLAMP_NONNEGATIVE, - aContext, mPresContext, canStoreInRuleTree); + aContext, mPresContext, aCanStoreInRuleTree); NS_ASSERTION(unitOK, "unexpected unit"); item->mRadius = tempCoord.GetCoordValue(); } else { @@ -3801,7 +3801,7 @@ nsRuleNode::GetShadowData(const nsCSSValueList* aList, if (aIsBoxShadow && arr->Item(3).GetUnit() != eCSSUnit_Null) { unitOK = SetCoord(arr->Item(3), tempCoord, nsStyleCoord(), SETCOORD_LENGTH | SETCOORD_CALC_LENGTH_ONLY, - aContext, mPresContext, canStoreInRuleTree); + aContext, mPresContext, aCanStoreInRuleTree); NS_ASSERTION(unitOK, "unexpected unit"); item->mSpread = tempCoord.GetCoordValue(); } else { @@ -3812,7 +3812,7 @@ nsRuleNode::GetShadowData(const nsCSSValueList* aList, item->mHasColor = true; // 2nd argument can be bogus since inherit is not a valid color unitOK = SetColor(arr->Item(4), 0, mPresContext, aContext, item->mColor, - canStoreInRuleTree); + aCanStoreInRuleTree); NS_ASSERTION(unitOK, "unexpected unit"); } @@ -7722,15 +7722,17 @@ nsRuleNode::ComputeSVGData(void* aStartStruct, } static nsStyleFilter::Type -StyleFilterTypeForFunctionName(nsCSSKeyword functionName) +StyleFilterTypeForFunctionName(nsCSSKeyword aFunctionName) { - switch (functionName) { + switch (aFunctionName) { case eCSSKeyword_blur: return nsStyleFilter::Type::eBlur; case eCSSKeyword_brightness: return nsStyleFilter::Type::eBrightness; case eCSSKeyword_contrast: return nsStyleFilter::Type::eContrast; + case eCSSKeyword_drop_shadow: + return nsStyleFilter::Type::eDropShadow; case eCSSKeyword_grayscale: return nsStyleFilter::Type::eGrayscale; case eCSSKeyword_hue_rotate: @@ -7749,17 +7751,16 @@ StyleFilterTypeForFunctionName(nsCSSKeyword functionName) } } -static void -SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter, - const nsCSSValue& aValue, - nsStyleContext* aStyleContext, - nsPresContext* aPresContext, - bool& aCanStoreInRuleTree) +void +nsRuleNode::SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter, + const nsCSSValue& aValue, + nsStyleContext* aStyleContext, + nsPresContext* aPresContext, + bool& aCanStoreInRuleTree) { nsCSSUnit unit = aValue.GetUnit(); if (unit == eCSSUnit_URL) { - aStyleFilter->mType = nsStyleFilter::Type::eURL; - aStyleFilter->mURL = aValue.GetURLValue(); + aStyleFilter->SetURL(aValue.GetURLValue()); return; } @@ -7768,24 +7769,36 @@ SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter, nsCSSValue::Array* filterFunction = aValue.GetArrayValue(); nsCSSKeyword functionName = (nsCSSKeyword)filterFunction->Item(0).GetIntValue(); - aStyleFilter->mType = StyleFilterTypeForFunctionName(functionName); + + nsStyleFilter::Type type = StyleFilterTypeForFunctionName(functionName); + if (type == nsStyleFilter::Type::eDropShadow) { + nsRefPtr shadowArray = GetShadowData( + filterFunction->Item(1).GetListValue(), + aStyleContext, + false, + aCanStoreInRuleTree); + aStyleFilter->SetDropShadow(shadowArray); + return; + } int32_t mask = SETCOORD_PERCENT | SETCOORD_FACTOR; - if (aStyleFilter->mType == nsStyleFilter::Type::eBlur) { + if (type == nsStyleFilter::Type::eBlur) { mask = SETCOORD_LENGTH | SETCOORD_STORE_CALC; - } else if (aStyleFilter->mType == nsStyleFilter::Type::eHueRotate) { + } else if (type == nsStyleFilter::Type::eHueRotate) { mask = SETCOORD_ANGLE; } NS_ABORT_IF_FALSE(filterFunction->Count() == 2, - "all filter functions except drop-shadow should have " + "all filter functions should have " "exactly one argument"); nsCSSValue& arg = filterFunction->Item(1); - DebugOnly success = SetCoord(arg, aStyleFilter->mFilterParameter, + nsStyleCoord filterParameter; + DebugOnly success = SetCoord(arg, filterParameter, nsStyleCoord(), mask, aStyleContext, aPresContext, aCanStoreInRuleTree); + aStyleFilter->SetFilterParameter(filterParameter, type); NS_ABORT_IF_FALSE(success, "unexpected unit"); } @@ -7884,7 +7897,7 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct, nsStyleFilter styleFilter; SetStyleFilterToCSSValue(&styleFilter, cur->mValue, aContext, mPresContext, canStoreInRuleTree); - NS_ABORT_IF_FALSE(styleFilter.mType != nsStyleFilter::Type::eNull, + NS_ABORT_IF_FALSE(styleFilter.GetType() != nsStyleFilter::Type::eNull, "filter should be set"); svgReset->mFilters.AppendElement(styleFilter); cur = cur->mNext; diff --git a/layout/style/nsRuleNode.h b/layout/style/nsRuleNode.h index 227eece07d94..7b2f9af59131 100644 --- a/layout/style/nsRuleNode.h +++ b/layout/style/nsRuleNode.h @@ -627,7 +627,12 @@ protected: GetShadowData(const nsCSSValueList* aList, nsStyleContext* aContext, bool aIsBoxShadow, - bool& inherited); + bool& aCanStoreInRuleTree); + void SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter, + const nsCSSValue& aValue, + nsStyleContext* aStyleContext, + nsPresContext* aPresContext, + bool& aCanStoreInRuleTree); private: nsRuleNode(nsPresContext* aPresContext, nsRuleNode* aParent, diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 2c7a1be52619..60aef799b5f9 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -1011,19 +1011,20 @@ nsStyleFilter::nsStyleFilter() } nsStyleFilter::nsStyleFilter(const nsStyleFilter& aSource) - : mType(aSource.mType) { MOZ_COUNT_CTOR(nsStyleFilter); - - if (mType == eURL) { - mURL = aSource.mURL; - } else if (mType != eNull) { - mFilterParameter = aSource.mFilterParameter; + if (aSource.mType == eURL) { + SetURL(aSource.mURL); + } else if (aSource.mType == eDropShadow) { + SetDropShadow(aSource.mDropShadow); + } else if (aSource.mType != eNull) { + SetFilterParameter(aSource.mFilterParameter, aSource.mType); } } nsStyleFilter::~nsStyleFilter() { + ReleaseRef(); MOZ_COUNT_DTOR(nsStyleFilter); } @@ -1036,6 +1037,8 @@ nsStyleFilter::operator==(const nsStyleFilter& aOther) const if (mType == eURL) { return EqualURIs(mURL, aOther.mURL); + } else if (mType == eDropShadow) { + return *mDropShadow == *aOther.mDropShadow; } else if (mType != eNull) { return mFilterParameter == aOther.mFilterParameter; } @@ -1043,6 +1046,47 @@ nsStyleFilter::operator==(const nsStyleFilter& aOther) const return true; } +void +nsStyleFilter::ReleaseRef() +{ + if (mType == eDropShadow) { + NS_ASSERTION(mDropShadow, "expected pointer"); + mDropShadow->Release(); + } else if (mType == eURL) { + NS_ASSERTION(mURL, "expected pointer"); + mURL->Release(); + } +} + +void +nsStyleFilter::SetFilterParameter(const nsStyleCoord& aFilterParameter, + Type aType) +{ + ReleaseRef(); + mFilterParameter = aFilterParameter; + mType = aType; +} + +void +nsStyleFilter::SetURL(nsIURI* aURL) +{ + NS_ASSERTION(aURL, "expected pointer"); + ReleaseRef(); + mURL = aURL; + mURL->AddRef(); + mType = eURL; +} + +void +nsStyleFilter::SetDropShadow(nsCSSShadowArray* aDropShadow) +{ + NS_ASSERTION(aDropShadow, "expected pointer"); + ReleaseRef(); + mDropShadow = aDropShadow; + mDropShadow->AddRef(); + mType = eDropShadow; +} + // -------------------- // nsStyleSVGReset // diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 473711e09993..9675adfcae81 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -655,7 +655,7 @@ struct nsCSSShadowItem { MOZ_COUNT_DTOR(nsCSSShadowItem); } - bool operator==(const nsCSSShadowItem& aOther) { + bool operator==(const nsCSSShadowItem& aOther) const { return (mXOffset == aOther.mXOffset && mYOffset == aOther.mYOffset && mRadius == aOther.mRadius && @@ -664,7 +664,7 @@ struct nsCSSShadowItem { mInset == aOther.mInset && (!mHasColor || mColor == aOther.mColor)); } - bool operator!=(const nsCSSShadowItem& aOther) { + bool operator!=(const nsCSSShadowItem& aOther) const { return !(*this == aOther); } }; @@ -716,6 +716,18 @@ class nsCSSShadowArray { return false; } + bool operator==(const nsCSSShadowArray& aOther) const { + if (mLength != aOther.Length()) + return false; + + for (uint32_t i = 0; i < mLength; ++i) { + if (ShadowAt(i) != aOther.ShadowAt(i)) + return false; + } + + return true; + } + NS_INLINE_DECL_REFCOUNTING(nsCSSShadowArray) private: @@ -2281,18 +2293,49 @@ struct nsStyleFilter { eBlur, eBrightness, eContrast, + eDropShadow, + eGrayscale, eHueRotate, eInvert, eOpacity, - eGrayscale, eSaturate, eSepia, }; + Type GetType() const { + return mType; + } + + const nsStyleCoord& GetFilterParameter() const { + NS_ASSERTION(mType != eDropShadow && + mType != eURL && + mType != eNull, "wrong filter type"); + return mFilterParameter; + } + void SetFilterParameter(const nsStyleCoord& aFilterParameter, + Type aType); + + nsIURI* GetURL() const { + NS_ASSERTION(mType == eURL, "wrong filter type"); + return mURL; + } + void SetURL(nsIURI* aURL); + + nsCSSShadowArray* GetDropShadow() const { + NS_ASSERTION(mType == eDropShadow, "wrong filter type"); + return mDropShadow; + } + void SetDropShadow(nsCSSShadowArray* aDropShadow); + +private: + void ReleaseRef(); + Type mType; - nsIURI* mURL; nsStyleCoord mFilterParameter; // coord, percent, factor, angle - // FIXME: Add a nsCSSShadowItem when we implement drop shadow. + union { + nsIURI* mURL; + nsCSSShadowArray* mDropShadow; + }; }; struct nsStyleSVGReset { @@ -2318,8 +2361,8 @@ struct nsStyleSVGReset { // filter functions. nsIURI* SingleFilter() const { return (mFilters.Length() == 1 && - mFilters[0].mType == nsStyleFilter::Type::eURL) ? - mFilters[0].mURL : nullptr; + mFilters[0].GetType() == nsStyleFilter::Type::eURL) ? + mFilters[0].GetURL() : nullptr; } nsCOMPtr mClipPath; // [reset] diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index f317ff4d3285..922f42be92bd 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -4458,6 +4458,24 @@ if (SpecialPowers.getBoolPref("layout.css.filters.enabled")) { "contrast(350%)", "contrast(4.567)", + "drop-shadow(2px 2px)", + "drop-shadow(2px 2px 1px)", + "drop-shadow(2px 2px green))", + "drop-shadow(2px 2px 1px green)", + "drop-shadow(green 2px 2px)", + "drop-shadow(green 2px 2px 1px)", + "drop-shadow(currentColor 3px 3px)", + "drop-shadow(2px 2px calc(-5px))", /* clamped */ + "drop-shadow(calc(3em - 2px) 2px green)", + "drop-shadow(green calc(3em - 2px) 2px)", + "drop-shadow(2px calc(2px + 0.2em))", + "drop-shadow(blue 2px calc(2px + 0.2em))", + "drop-shadow(2px calc(2px + 0.2em) blue)", + "drop-shadow(calc(-2px) calc(-2px))", + "drop-shadow(-2px -2px)", + "drop-shadow(calc(2px) calc(2px))", + "drop-shadow(calc(2px) calc(2px) calc(2px))", + "grayscale(0)", "grayscale(50%)", "grayscale(1)", @@ -4556,6 +4574,22 @@ if (SpecialPowers.getBoolPref("layout.css.filters.enabled")) { "contrast(10px)", "contrast(-1)", + "drop-shadow()", + "drop-shadow(3% 3%)", + "drop-shadow(2px 2px -5px)", + "drop-shadow(2px 2px 2px 2px)", + "drop-shadow(2px 2px, none)", + "drop-shadow(none, 2px 2px)", + "drop-shadow(inherit, 2px 2px)", + "drop-shadow(2px 2px, inherit)", + "drop-shadow(2 2px)", + "drop-shadow(2px 2)", + "drop-shadow(2px 2px 2)", + "drop-shadow(2px 2px 2px 2)", + "drop-shadow(calc(2px) calc(2px) calc(2px) calc(2px))", + "drop-shadow(green 2px 2px, blue 1px 3px 4px)", + "drop-shadow(blue 2px 2px, currentColor 1px 2px)", + "grayscale()", "grayscale(0.5 0.5)", "grayscale(0.5,)", From 0a304aba4a7aa2c53fc91c70f4df284d6ed180c4 Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Wed, 31 Jul 2013 10:47:39 -0400 Subject: [PATCH 04/40] Bug 889512 - no focus event for google's moving textbox, r=tbsaunde --- accessible/src/generic/DocAccessible.cpp | 34 +++++++++++++++--------- accessible/src/generic/DocAccessible.h | 7 ++++- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/accessible/src/generic/DocAccessible.cpp b/accessible/src/generic/DocAccessible.cpp index afbb27d21cc0..d358e86daf0e 100644 --- a/accessible/src/generic/DocAccessible.cpp +++ b/accessible/src/generic/DocAccessible.cpp @@ -1830,10 +1830,16 @@ DocAccessible::UpdateTreeInternal(Accessible* aChild, bool aIsInsert, { uint32_t updateFlags = eAccessible; + // If a focused node has been shown then it could mean its frame was recreated + // while the node stays focused and we need to fire focus event on + // the accessible we just created. If the queue contains a focus event for + // this node already then it will be suppressed by this one. + Accessible* focusedAcc = nullptr; + nsINode* node = aChild->GetNode(); if (aIsInsert) { // Create accessible tree for shown accessible. - CacheChildrenInSubtree(aChild); + CacheChildrenInSubtree(aChild, &focusedAcc); } else { // Fire menupopup end event before hide event if a menu goes away. @@ -1870,16 +1876,6 @@ DocAccessible::UpdateTreeInternal(Accessible* aChild, bool aIsInsert, updateFlags = eAlertAccessible; FireDelayedEvent(nsIAccessibleEvent::EVENT_ALERT, aChild); } - - // If focused node has been shown then it means its frame was recreated - // while it's focused. Fire focus event on new focused accessible. If - // the queue contains focus event for this node then it's suppressed by - // this one. - // XXX: do we really want to send focus to focused DOM node not taking into - // account active item? - if (FocusMgr()->IsFocused(aChild)) - FocusMgr()->DispatchFocusEvent(this, aChild); - } else { // Update the tree for content removal. // The accessible parent may differ from container accessible if @@ -1893,12 +1889,24 @@ DocAccessible::UpdateTreeInternal(Accessible* aChild, bool aIsInsert, UncacheChildrenInSubtree(aChild); } + // XXX: do we really want to send focus to focused DOM node not taking into + // account active item? + if (focusedAcc) + FocusMgr()->DispatchFocusEvent(this, focusedAcc); + return updateFlags; } void -DocAccessible::CacheChildrenInSubtree(Accessible* aRoot) +DocAccessible::CacheChildrenInSubtree(Accessible* aRoot, + Accessible** aFocusedAcc) { + // If the accessible is focused then report a focus event after all related + // mutation events. + if (aFocusedAcc && !*aFocusedAcc && + FocusMgr()->HasDOMFocus(aRoot->GetContent())) + *aFocusedAcc = aRoot; + aRoot->EnsureChildren(); // Make sure we create accessible tree defined in DOM only, i.e. if accessible @@ -1910,7 +1918,7 @@ DocAccessible::CacheChildrenInSubtree(Accessible* aRoot) NS_ASSERTION(child, "Illicit tree change while tree is created!"); // Don't cross document boundaries. if (child && child->IsContent()) - CacheChildrenInSubtree(child); + CacheChildrenInSubtree(child, aFocusedAcc); } // Fire document load complete on ARIA documents. diff --git a/accessible/src/generic/DocAccessible.h b/accessible/src/generic/DocAccessible.h index a4443b21ea1b..73446d2f5388 100644 --- a/accessible/src/generic/DocAccessible.h +++ b/accessible/src/generic/DocAccessible.h @@ -449,8 +449,13 @@ protected: /** * Create accessible tree. + * + * @param aRoot [in] a root of subtree to create + * @param aFocusedAcc [in, optional] a focused accessible under created + * subtree if any */ - void CacheChildrenInSubtree(Accessible* aRoot); + void CacheChildrenInSubtree(Accessible* aRoot, + Accessible** aFocusedAcc = nullptr); /** * Remove accessibles in subtree from node to accessible map. From 5d03ad2e852be2eb4b206ad46a747ef5f4992d81 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Wed, 31 Jul 2013 16:00:27 +0100 Subject: [PATCH 05/40] Backed out changeset e27bd873b413 (bug 898361) for crashes on a CLOSED TREE --- layout/style/nsCSSKeywordList.h | 1 - layout/style/nsCSSParser.cpp | 42 +------------------ layout/style/nsComputedDOMStyle.cpp | 33 +++++---------- layout/style/nsComputedDOMStyle.h | 2 +- layout/style/nsRuleNode.cpp | 57 ++++++++++---------------- layout/style/nsRuleNode.h | 7 +--- layout/style/nsStyleStruct.cpp | 56 +++---------------------- layout/style/nsStyleStruct.h | 57 ++++---------------------- layout/style/test/property_database.js | 34 --------------- 9 files changed, 49 insertions(+), 240 deletions(-) diff --git a/layout/style/nsCSSKeywordList.h b/layout/style/nsCSSKeywordList.h index 38dd3bdc5fea..ee53ad464ea9 100644 --- a/layout/style/nsCSSKeywordList.h +++ b/layout/style/nsCSSKeywordList.h @@ -242,7 +242,6 @@ CSS_KEY(disc, disc) CSS_KEY(discretionary-ligatures, discretionary_ligatures) CSS_KEY(dotted, dotted) CSS_KEY(double, double) -CSS_KEY(drop-shadow, drop_shadow) CSS_KEY(e-resize, e_resize) CSS_KEY(each-box, each_box) CSS_KEY(ease, ease) diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index e319805bd3da..f9aaad7fd88b 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -607,7 +607,6 @@ protected: /* Functions for filter parsing */ bool ParseFilter(); bool ParseSingleFilter(nsCSSValue* aValue); - bool ParseDropShadow(nsCSSValue* aValue); /* Find and return the namespace ID associated with aPrefix. If aPrefix has not been declared in an @namespace rule, returns @@ -10052,32 +10051,6 @@ bool CSSParserImpl::ParseTransformOrigin(bool aPerspective) return true; } -/** - * Reads a drop-shadow value. At the moment the Filter Effects specification - * just expects one shadow item. Should this ever change to a list of shadow - * items, use ParseShadowList instead. - */ -bool -CSSParserImpl::ParseDropShadow(nsCSSValue* aValue) -{ - // Use nsCSSValueList to reuse the shadow resolving code in - // nsRuleNode and nsComputedDOMStyle. - nsCSSValue shadow; - nsCSSValueList* cur = shadow.SetListValue(); - if (!ParseShadowItem(cur->mValue, false)) - return false; - - if (!ExpectSymbol(')', true)) - return false; - - nsCSSValue::Array* dropShadow = aValue->InitFunction(eCSSKeyword_drop_shadow, 1); - - // Copy things over. - dropShadow->Item(1) = shadow; - - return true; -} - /** * Reads a single url or filter function from the tokenizer stream, reporting an * error if something goes wrong. @@ -10105,24 +10078,11 @@ CSSParserImpl::ParseSingleFilter(nsCSSValue* aValue) return false; } - nsCSSKeyword functionName = nsCSSKeywords::LookupKeyword(mToken.mIdent); - // Parse drop-shadow independently of the other filter functions - // because of its more complex characteristics. - if (functionName == eCSSKeyword_drop_shadow) { - if (ParseDropShadow(aValue)) { - return true; - } else { - // Unrecognized filter function. - REPORT_UNEXPECTED_TOKEN(PEExpectedNoneOrURLOrFilterFunction); - SkipUntil(')'); - return false; - } - } - // Set up the parsing rules based on the filter function. int32_t variantMask = VARIANT_PN; bool rejectNegativeArgument = true; bool clampArgumentToOne = false; + nsCSSKeyword functionName = nsCSSKeywords::LookupKeyword(mToken.mIdent); switch (functionName) { case eCSSKeyword_blur: variantMask = VARIANT_LCALC | VARIANT_NONNEGATIVE_DIMENSION; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 05b3fa0a34b9..01c7cbcebd82 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -4498,9 +4498,9 @@ nsComputedDOMStyle::SetCssTextToCoord(nsAString& aCssText, } static void -GetFilterFunctionName(nsAString& aString, nsStyleFilter::Type aType) +GetFilterFunctionName(nsAString& aString, nsStyleFilter::Type mType) { - switch (aType) { + switch (mType) { case nsStyleFilter::Type::eBlur: aString.AssignLiteral("blur("); break; @@ -4510,9 +4510,6 @@ GetFilterFunctionName(nsAString& aString, nsStyleFilter::Type aType) case nsStyleFilter::Type::eContrast: aString.AssignLiteral("contrast("); break; - case nsStyleFilter::Type::eDropShadow: - aString.AssignLiteral("drop-shadow("); - break; case nsStyleFilter::Type::eGrayscale: aString.AssignLiteral("grayscale("); break; @@ -4536,34 +4533,25 @@ GetFilterFunctionName(nsAString& aString, nsStyleFilter::Type aType) } } -CSSValue* +nsROCSSPrimitiveValue* nsComputedDOMStyle::CreatePrimitiveValueForStyleFilter( const nsStyleFilter& aStyleFilter) { nsROCSSPrimitiveValue* value = new nsROCSSPrimitiveValue; + // Handle url(). - if (nsStyleFilter::Type::eURL == aStyleFilter.GetType()) { - value->SetURI(aStyleFilter.GetURL()); + if (nsStyleFilter::Type::eURL == aStyleFilter.mType) { + value->SetURI(aStyleFilter.mURL); return value; } // Filter function name and opening parenthesis. nsAutoString filterFunctionString; - GetFilterFunctionName(filterFunctionString, aStyleFilter.GetType()); + GetFilterFunctionName(filterFunctionString, aStyleFilter.mType); + // Filter function argument. nsAutoString argumentString; - if (nsStyleFilter::Type::eDropShadow == aStyleFilter.GetType()) { - // Handle drop-shadow() - nsRefPtr shadowValue = - GetCSSShadowArray(aStyleFilter.GetDropShadow(), - StyleColor()->mColor, - false); - ErrorResult dummy; - shadowValue->GetCssText(argumentString, dummy); - } else { - // Filter function argument. - SetCssTextToCoord(argumentString, aStyleFilter.GetFilterParameter()); - } + SetCssTextToCoord(argumentString, aStyleFilter.mFilterParameter); filterFunctionString.Append(argumentString); // Filter function closing parenthesis. @@ -4586,7 +4574,8 @@ nsComputedDOMStyle::DoGetFilter() nsDOMCSSValueList* valueList = GetROCSSValueList(false); for(uint32_t i = 0; i < filters.Length(); i++) { - CSSValue* value = CreatePrimitiveValueForStyleFilter(filters[i]); + nsROCSSPrimitiveValue* value = + CreatePrimitiveValueForStyleFilter(filters[i]); valueList->AppendCSSValue(value); } return valueList; diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index dc671b30a294..c75265eda958 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -494,7 +494,7 @@ private: /* Helper functions for computing the filter property style. */ void SetCssTextToCoord(nsAString& aCssText, const nsStyleCoord& aCoord); - mozilla::dom::CSSValue* CreatePrimitiveValueForStyleFilter( + nsROCSSPrimitiveValue* CreatePrimitiveValueForStyleFilter( const nsStyleFilter& aStyleFilter); struct ComputedStyleMapEntry diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index cab366d6809b..3c8bd1eda265 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -3752,7 +3752,7 @@ already_AddRefed nsRuleNode::GetShadowData(const nsCSSValueList* aList, nsStyleContext* aContext, bool aIsBoxShadow, - bool& aCanStoreInRuleTree) + bool& canStoreInRuleTree) { uint32_t arrayLength = ListLength(aList); @@ -3775,13 +3775,13 @@ nsRuleNode::GetShadowData(const nsCSSValueList* aList, // OK to pass bad aParentCoord since we're not passing SETCOORD_INHERIT unitOK = SetCoord(arr->Item(0), tempCoord, nsStyleCoord(), SETCOORD_LENGTH | SETCOORD_CALC_LENGTH_ONLY, - aContext, mPresContext, aCanStoreInRuleTree); + aContext, mPresContext, canStoreInRuleTree); NS_ASSERTION(unitOK, "unexpected unit"); item->mXOffset = tempCoord.GetCoordValue(); unitOK = SetCoord(arr->Item(1), tempCoord, nsStyleCoord(), SETCOORD_LENGTH | SETCOORD_CALC_LENGTH_ONLY, - aContext, mPresContext, aCanStoreInRuleTree); + aContext, mPresContext, canStoreInRuleTree); NS_ASSERTION(unitOK, "unexpected unit"); item->mYOffset = tempCoord.GetCoordValue(); @@ -3790,7 +3790,7 @@ nsRuleNode::GetShadowData(const nsCSSValueList* aList, unitOK = SetCoord(arr->Item(2), tempCoord, nsStyleCoord(), SETCOORD_LENGTH | SETCOORD_CALC_LENGTH_ONLY | SETCOORD_CALC_CLAMP_NONNEGATIVE, - aContext, mPresContext, aCanStoreInRuleTree); + aContext, mPresContext, canStoreInRuleTree); NS_ASSERTION(unitOK, "unexpected unit"); item->mRadius = tempCoord.GetCoordValue(); } else { @@ -3801,7 +3801,7 @@ nsRuleNode::GetShadowData(const nsCSSValueList* aList, if (aIsBoxShadow && arr->Item(3).GetUnit() != eCSSUnit_Null) { unitOK = SetCoord(arr->Item(3), tempCoord, nsStyleCoord(), SETCOORD_LENGTH | SETCOORD_CALC_LENGTH_ONLY, - aContext, mPresContext, aCanStoreInRuleTree); + aContext, mPresContext, canStoreInRuleTree); NS_ASSERTION(unitOK, "unexpected unit"); item->mSpread = tempCoord.GetCoordValue(); } else { @@ -3812,7 +3812,7 @@ nsRuleNode::GetShadowData(const nsCSSValueList* aList, item->mHasColor = true; // 2nd argument can be bogus since inherit is not a valid color unitOK = SetColor(arr->Item(4), 0, mPresContext, aContext, item->mColor, - aCanStoreInRuleTree); + canStoreInRuleTree); NS_ASSERTION(unitOK, "unexpected unit"); } @@ -7722,17 +7722,15 @@ nsRuleNode::ComputeSVGData(void* aStartStruct, } static nsStyleFilter::Type -StyleFilterTypeForFunctionName(nsCSSKeyword aFunctionName) +StyleFilterTypeForFunctionName(nsCSSKeyword functionName) { - switch (aFunctionName) { + switch (functionName) { case eCSSKeyword_blur: return nsStyleFilter::Type::eBlur; case eCSSKeyword_brightness: return nsStyleFilter::Type::eBrightness; case eCSSKeyword_contrast: return nsStyleFilter::Type::eContrast; - case eCSSKeyword_drop_shadow: - return nsStyleFilter::Type::eDropShadow; case eCSSKeyword_grayscale: return nsStyleFilter::Type::eGrayscale; case eCSSKeyword_hue_rotate: @@ -7751,16 +7749,17 @@ StyleFilterTypeForFunctionName(nsCSSKeyword aFunctionName) } } -void -nsRuleNode::SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter, - const nsCSSValue& aValue, - nsStyleContext* aStyleContext, - nsPresContext* aPresContext, - bool& aCanStoreInRuleTree) +static void +SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter, + const nsCSSValue& aValue, + nsStyleContext* aStyleContext, + nsPresContext* aPresContext, + bool& aCanStoreInRuleTree) { nsCSSUnit unit = aValue.GetUnit(); if (unit == eCSSUnit_URL) { - aStyleFilter->SetURL(aValue.GetURLValue()); + aStyleFilter->mType = nsStyleFilter::Type::eURL; + aStyleFilter->mURL = aValue.GetURLValue(); return; } @@ -7769,36 +7768,24 @@ nsRuleNode::SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter, nsCSSValue::Array* filterFunction = aValue.GetArrayValue(); nsCSSKeyword functionName = (nsCSSKeyword)filterFunction->Item(0).GetIntValue(); - - nsStyleFilter::Type type = StyleFilterTypeForFunctionName(functionName); - if (type == nsStyleFilter::Type::eDropShadow) { - nsRefPtr shadowArray = GetShadowData( - filterFunction->Item(1).GetListValue(), - aStyleContext, - false, - aCanStoreInRuleTree); - aStyleFilter->SetDropShadow(shadowArray); - return; - } + aStyleFilter->mType = StyleFilterTypeForFunctionName(functionName); int32_t mask = SETCOORD_PERCENT | SETCOORD_FACTOR; - if (type == nsStyleFilter::Type::eBlur) { + if (aStyleFilter->mType == nsStyleFilter::Type::eBlur) { mask = SETCOORD_LENGTH | SETCOORD_STORE_CALC; - } else if (type == nsStyleFilter::Type::eHueRotate) { + } else if (aStyleFilter->mType == nsStyleFilter::Type::eHueRotate) { mask = SETCOORD_ANGLE; } NS_ABORT_IF_FALSE(filterFunction->Count() == 2, - "all filter functions should have " + "all filter functions except drop-shadow should have " "exactly one argument"); nsCSSValue& arg = filterFunction->Item(1); - nsStyleCoord filterParameter; - DebugOnly success = SetCoord(arg, filterParameter, + DebugOnly success = SetCoord(arg, aStyleFilter->mFilterParameter, nsStyleCoord(), mask, aStyleContext, aPresContext, aCanStoreInRuleTree); - aStyleFilter->SetFilterParameter(filterParameter, type); NS_ABORT_IF_FALSE(success, "unexpected unit"); } @@ -7897,7 +7884,7 @@ nsRuleNode::ComputeSVGResetData(void* aStartStruct, nsStyleFilter styleFilter; SetStyleFilterToCSSValue(&styleFilter, cur->mValue, aContext, mPresContext, canStoreInRuleTree); - NS_ABORT_IF_FALSE(styleFilter.GetType() != nsStyleFilter::Type::eNull, + NS_ABORT_IF_FALSE(styleFilter.mType != nsStyleFilter::Type::eNull, "filter should be set"); svgReset->mFilters.AppendElement(styleFilter); cur = cur->mNext; diff --git a/layout/style/nsRuleNode.h b/layout/style/nsRuleNode.h index 7b2f9af59131..227eece07d94 100644 --- a/layout/style/nsRuleNode.h +++ b/layout/style/nsRuleNode.h @@ -627,12 +627,7 @@ protected: GetShadowData(const nsCSSValueList* aList, nsStyleContext* aContext, bool aIsBoxShadow, - bool& aCanStoreInRuleTree); - void SetStyleFilterToCSSValue(nsStyleFilter* aStyleFilter, - const nsCSSValue& aValue, - nsStyleContext* aStyleContext, - nsPresContext* aPresContext, - bool& aCanStoreInRuleTree); + bool& inherited); private: nsRuleNode(nsPresContext* aPresContext, nsRuleNode* aParent, diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 60aef799b5f9..2c7a1be52619 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -1011,20 +1011,19 @@ nsStyleFilter::nsStyleFilter() } nsStyleFilter::nsStyleFilter(const nsStyleFilter& aSource) + : mType(aSource.mType) { MOZ_COUNT_CTOR(nsStyleFilter); - if (aSource.mType == eURL) { - SetURL(aSource.mURL); - } else if (aSource.mType == eDropShadow) { - SetDropShadow(aSource.mDropShadow); - } else if (aSource.mType != eNull) { - SetFilterParameter(aSource.mFilterParameter, aSource.mType); + + if (mType == eURL) { + mURL = aSource.mURL; + } else if (mType != eNull) { + mFilterParameter = aSource.mFilterParameter; } } nsStyleFilter::~nsStyleFilter() { - ReleaseRef(); MOZ_COUNT_DTOR(nsStyleFilter); } @@ -1037,8 +1036,6 @@ nsStyleFilter::operator==(const nsStyleFilter& aOther) const if (mType == eURL) { return EqualURIs(mURL, aOther.mURL); - } else if (mType == eDropShadow) { - return *mDropShadow == *aOther.mDropShadow; } else if (mType != eNull) { return mFilterParameter == aOther.mFilterParameter; } @@ -1046,47 +1043,6 @@ nsStyleFilter::operator==(const nsStyleFilter& aOther) const return true; } -void -nsStyleFilter::ReleaseRef() -{ - if (mType == eDropShadow) { - NS_ASSERTION(mDropShadow, "expected pointer"); - mDropShadow->Release(); - } else if (mType == eURL) { - NS_ASSERTION(mURL, "expected pointer"); - mURL->Release(); - } -} - -void -nsStyleFilter::SetFilterParameter(const nsStyleCoord& aFilterParameter, - Type aType) -{ - ReleaseRef(); - mFilterParameter = aFilterParameter; - mType = aType; -} - -void -nsStyleFilter::SetURL(nsIURI* aURL) -{ - NS_ASSERTION(aURL, "expected pointer"); - ReleaseRef(); - mURL = aURL; - mURL->AddRef(); - mType = eURL; -} - -void -nsStyleFilter::SetDropShadow(nsCSSShadowArray* aDropShadow) -{ - NS_ASSERTION(aDropShadow, "expected pointer"); - ReleaseRef(); - mDropShadow = aDropShadow; - mDropShadow->AddRef(); - mType = eDropShadow; -} - // -------------------- // nsStyleSVGReset // diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 9675adfcae81..473711e09993 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -655,7 +655,7 @@ struct nsCSSShadowItem { MOZ_COUNT_DTOR(nsCSSShadowItem); } - bool operator==(const nsCSSShadowItem& aOther) const { + bool operator==(const nsCSSShadowItem& aOther) { return (mXOffset == aOther.mXOffset && mYOffset == aOther.mYOffset && mRadius == aOther.mRadius && @@ -664,7 +664,7 @@ struct nsCSSShadowItem { mInset == aOther.mInset && (!mHasColor || mColor == aOther.mColor)); } - bool operator!=(const nsCSSShadowItem& aOther) const { + bool operator!=(const nsCSSShadowItem& aOther) { return !(*this == aOther); } }; @@ -716,18 +716,6 @@ class nsCSSShadowArray { return false; } - bool operator==(const nsCSSShadowArray& aOther) const { - if (mLength != aOther.Length()) - return false; - - for (uint32_t i = 0; i < mLength; ++i) { - if (ShadowAt(i) != aOther.ShadowAt(i)) - return false; - } - - return true; - } - NS_INLINE_DECL_REFCOUNTING(nsCSSShadowArray) private: @@ -2293,49 +2281,18 @@ struct nsStyleFilter { eBlur, eBrightness, eContrast, - eDropShadow, - eGrayscale, eHueRotate, eInvert, eOpacity, + eGrayscale, eSaturate, eSepia, }; - Type GetType() const { - return mType; - } - - const nsStyleCoord& GetFilterParameter() const { - NS_ASSERTION(mType != eDropShadow && - mType != eURL && - mType != eNull, "wrong filter type"); - return mFilterParameter; - } - void SetFilterParameter(const nsStyleCoord& aFilterParameter, - Type aType); - - nsIURI* GetURL() const { - NS_ASSERTION(mType == eURL, "wrong filter type"); - return mURL; - } - void SetURL(nsIURI* aURL); - - nsCSSShadowArray* GetDropShadow() const { - NS_ASSERTION(mType == eDropShadow, "wrong filter type"); - return mDropShadow; - } - void SetDropShadow(nsCSSShadowArray* aDropShadow); - -private: - void ReleaseRef(); - Type mType; + nsIURI* mURL; nsStyleCoord mFilterParameter; // coord, percent, factor, angle - union { - nsIURI* mURL; - nsCSSShadowArray* mDropShadow; - }; + // FIXME: Add a nsCSSShadowItem when we implement drop shadow. }; struct nsStyleSVGReset { @@ -2361,8 +2318,8 @@ struct nsStyleSVGReset { // filter functions. nsIURI* SingleFilter() const { return (mFilters.Length() == 1 && - mFilters[0].GetType() == nsStyleFilter::Type::eURL) ? - mFilters[0].GetURL() : nullptr; + mFilters[0].mType == nsStyleFilter::Type::eURL) ? + mFilters[0].mURL : nullptr; } nsCOMPtr mClipPath; // [reset] diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 922f42be92bd..f317ff4d3285 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -4458,24 +4458,6 @@ if (SpecialPowers.getBoolPref("layout.css.filters.enabled")) { "contrast(350%)", "contrast(4.567)", - "drop-shadow(2px 2px)", - "drop-shadow(2px 2px 1px)", - "drop-shadow(2px 2px green))", - "drop-shadow(2px 2px 1px green)", - "drop-shadow(green 2px 2px)", - "drop-shadow(green 2px 2px 1px)", - "drop-shadow(currentColor 3px 3px)", - "drop-shadow(2px 2px calc(-5px))", /* clamped */ - "drop-shadow(calc(3em - 2px) 2px green)", - "drop-shadow(green calc(3em - 2px) 2px)", - "drop-shadow(2px calc(2px + 0.2em))", - "drop-shadow(blue 2px calc(2px + 0.2em))", - "drop-shadow(2px calc(2px + 0.2em) blue)", - "drop-shadow(calc(-2px) calc(-2px))", - "drop-shadow(-2px -2px)", - "drop-shadow(calc(2px) calc(2px))", - "drop-shadow(calc(2px) calc(2px) calc(2px))", - "grayscale(0)", "grayscale(50%)", "grayscale(1)", @@ -4574,22 +4556,6 @@ if (SpecialPowers.getBoolPref("layout.css.filters.enabled")) { "contrast(10px)", "contrast(-1)", - "drop-shadow()", - "drop-shadow(3% 3%)", - "drop-shadow(2px 2px -5px)", - "drop-shadow(2px 2px 2px 2px)", - "drop-shadow(2px 2px, none)", - "drop-shadow(none, 2px 2px)", - "drop-shadow(inherit, 2px 2px)", - "drop-shadow(2px 2px, inherit)", - "drop-shadow(2 2px)", - "drop-shadow(2px 2)", - "drop-shadow(2px 2px 2)", - "drop-shadow(2px 2px 2px 2)", - "drop-shadow(calc(2px) calc(2px) calc(2px) calc(2px))", - "drop-shadow(green 2px 2px, blue 1px 3px 4px)", - "drop-shadow(blue 2px 2px, currentColor 1px 2px)", - "grayscale()", "grayscale(0.5 0.5)", "grayscale(0.5,)", From 0bacd98783ac45a580e28bb6c8a896fc23f997f5 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 31 Jul 2013 11:43:28 -0400 Subject: [PATCH 06/40] Bug 784739 - Switch from NULL to nullptr in parser/; r=ehsan --- parser/htmlparser/src/nsHTMLTokenizer.cpp | 2 +- parser/htmlparser/src/nsParser.h | 4 ++-- parser/htmlparser/src/nsParserModule.cpp | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/parser/htmlparser/src/nsHTMLTokenizer.cpp b/parser/htmlparser/src/nsHTMLTokenizer.cpp index ce35ac56e086..555ddf37c9d8 100644 --- a/parser/htmlparser/src/nsHTMLTokenizer.cpp +++ b/parser/htmlparser/src/nsHTMLTokenizer.cpp @@ -166,7 +166,7 @@ nsHTMLTokenizer::PeekToken() * This method provides access to the topmost token in the tokenDeque. * The token is really removed from the list; if the list is empty we return 0. * - * @return Pointer to token or NULL + * @return Pointer to token or nullptr */ CToken* nsHTMLTokenizer::PopToken() diff --git a/parser/htmlparser/src/nsParser.h b/parser/htmlparser/src/nsParser.h index 901c0add4dd9..59d415f6c6e4 100644 --- a/parser/htmlparser/src/nsParser.h +++ b/parser/htmlparser/src/nsParser.h @@ -98,7 +98,7 @@ class nsParser : public nsIParser, * Select given content sink into parser for parser output * @update gess5/11/98 * @param aSink is the new sink to be used by parser - * @return old sink, or NULL + * @return old sink, or nullptr */ NS_IMETHOD_(void) SetContentSink(nsIContentSink* aSink); @@ -106,7 +106,7 @@ class nsParser : public nsIParser, * retrive the sink set into the parser * @update gess5/11/98 * @param aSink is the new sink to be used by parser - * @return old sink, or NULL + * @return old sink, or nullptr */ NS_IMETHOD_(nsIContentSink*) GetContentSink(void); diff --git a/parser/htmlparser/src/nsParserModule.cpp b/parser/htmlparser/src/nsParserModule.cpp index 1eae263bc0ee..4b5bcf9a1a1e 100644 --- a/parser/htmlparser/src/nsParserModule.cpp +++ b/parser/htmlparser/src/nsParserModule.cpp @@ -48,21 +48,21 @@ NS_DEFINE_NAMED_CID(NS_SAXXMLREADER_CID); static const mozilla::Module::CIDEntry kParserCIDs[] = { #if defined(DEBUG) - { &kNS_EXPAT_DRIVER_CID, false, NULL, nsExpatDriverConstructor }, + { &kNS_EXPAT_DRIVER_CID, false, nullptr, nsExpatDriverConstructor }, #endif - { &kNS_PARSER_CID, false, NULL, nsParserConstructor }, - { &kNS_CNAVDTD_CID, false, NULL, CNavDTDConstructor }, - { &kNS_PARSERSERVICE_CID, false, NULL, nsParserServiceConstructor }, - { &kNS_SAXATTRIBUTES_CID, false, NULL, nsSAXAttributesConstructor }, - { &kNS_SAXXMLREADER_CID, false, NULL, nsSAXXMLReaderConstructor }, - { NULL } + { &kNS_PARSER_CID, false, nullptr, nsParserConstructor }, + { &kNS_CNAVDTD_CID, false, nullptr, CNavDTDConstructor }, + { &kNS_PARSERSERVICE_CID, false, nullptr, nsParserServiceConstructor }, + { &kNS_SAXATTRIBUTES_CID, false, nullptr, nsSAXAttributesConstructor }, + { &kNS_SAXXMLREADER_CID, false, nullptr, nsSAXXMLReaderConstructor }, + { nullptr } }; static const mozilla::Module::ContractIDEntry kParserContracts[] = { { NS_PARSERSERVICE_CONTRACTID, &kNS_PARSERSERVICE_CID }, { NS_SAXATTRIBUTES_CONTRACTID, &kNS_SAXATTRIBUTES_CID }, { NS_SAXXMLREADER_CONTRACTID, &kNS_SAXXMLREADER_CID }, - { NULL } + { nullptr } }; static nsresult @@ -102,8 +102,8 @@ static mozilla::Module kParserModule = { mozilla::Module::kVersion, kParserCIDs, kParserContracts, - NULL, - NULL, + nullptr, + nullptr, Initialize, Shutdown }; From 064266ee0ceaac9a9c7fd095cbeabc7f16b39357 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 31 Jul 2013 11:43:38 -0400 Subject: [PATCH 07/40] Bug 784739 - Switch from NULL to nullptr in profile/; r=ehsan --- profile/dirserviceprovider/src/nsProfileLock.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/profile/dirserviceprovider/src/nsProfileLock.cpp b/profile/dirserviceprovider/src/nsProfileLock.cpp index e875908afdc0..2de04b4188eb 100644 --- a/profile/dirserviceprovider/src/nsProfileLock.cpp +++ b/profile/dirserviceprovider/src/nsProfileLock.cpp @@ -166,7 +166,7 @@ void nsProfileLock::FatalSignalHandler(int signo if (oldact->sa_handler == SIG_DFL) { // Make sure the default sig handler is executed // We need it to get Mozilla to dump core. - sigaction(signo,oldact,NULL); + sigaction(signo,oldact, nullptr); // Now that we've restored the default handler, unmask the // signal and invoke it. @@ -175,7 +175,7 @@ void nsProfileLock::FatalSignalHandler(int signo sigemptyset(&unblock_sigs); sigaddset(&unblock_sigs, signo); - sigprocmask(SIG_UNBLOCK, &unblock_sigs, NULL); + sigprocmask(SIG_UNBLOCK, &unblock_sigs, nullptr); raise(signo); } @@ -391,7 +391,7 @@ nsresult nsProfileLock::LockWithSymlink(nsIFile *aLockFile, bool aHaveFcntlLock) #define CATCH_SIGNAL(signame) \ PR_BEGIN_MACRO \ - if (sigaction(signame, NULL, &oldact) == 0 && \ + if (sigaction(signame, nullptr, &oldact) == 0 && \ oldact.sa_handler != SIG_IGN) \ { \ sigaction(signame, &act, &signame##_oldact); \ @@ -505,11 +505,11 @@ nsresult nsProfileLock::Lock(nsIFile* aProfileDir, if (ioBytes == sizeof(LockProcessInfo)) { #ifdef __LP64__ - processInfo.processAppRef = NULL; + processInfo.processAppRef = nullptr; #else - processInfo.processAppSpec = NULL; + processInfo.processAppSpec = nullptr; #endif - processInfo.processName = NULL; + processInfo.processName = nullptr; processInfo.processInfoLength = sizeof(ProcessInfoRec); if (::GetProcessInformation(&lockProcessInfo.psn, &processInfo) == noErr && processInfo.processLaunchDate == lockProcessInfo.launchDate) From d467009d81b6327ff709b8b3b7544a6d4b25ea77 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 31 Jul 2013 11:44:03 -0400 Subject: [PATCH 08/40] Bug 784739 - Switch from NULL to nullptr in rdf/; r=ehsan --- rdf/build/nsRDFModule.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/rdf/build/nsRDFModule.cpp b/rdf/build/nsRDFModule.cpp index 18b2c54e0568..ec0fcff27db1 100644 --- a/rdf/build/nsRDFModule.cpp +++ b/rdf/build/nsRDFModule.cpp @@ -113,20 +113,20 @@ NS_DEFINE_NAMED_CID(NS_LOCALSTORE_CID); static const mozilla::Module::CIDEntry kRDFCIDs[] = { - { &kNS_RDFCOMPOSITEDATASOURCE_CID, false, NULL, CreateNewRDFCompositeDataSource }, - { &kNS_RDFFILESYSTEMDATASOURCE_CID, false, NULL, FileSystemDataSource::Create }, - { &kNS_RDFINMEMORYDATASOURCE_CID, false, NULL, NS_NewRDFInMemoryDataSource }, - { &kNS_RDFXMLDATASOURCE_CID, false, NULL, CreateNewRDFXMLDataSource }, - { &kNS_RDFDEFAULTRESOURCE_CID, false, NULL, CreateNewRDFDefaultResource }, - { &kNS_RDFCONTENTSINK_CID, false, NULL, CreateNewRDFContentSink }, - { &kNS_RDFCONTAINER_CID, false, NULL, CreateNewRDFContainer }, - { &kNS_RDFCONTAINERUTILS_CID, false, NULL, CreateNewRDFContainerUtils }, - { &kNS_RDFSERVICE_CID, false, NULL, RDFServiceImpl::CreateSingleton }, - { &kNS_RDFXMLPARSER_CID, false, NULL, nsRDFXMLParser::Create }, - { &kNS_RDFXMLSERIALIZER_CID, false, NULL, nsRDFXMLSerializer::Create }, - { &kNS_RDFNTRIPLES_SERIALIZER_CID, false, NULL, CreateNewTriplesSerializer }, - { &kNS_LOCALSTORE_CID, false, NULL, NS_NewLocalStore }, - { NULL } + { &kNS_RDFCOMPOSITEDATASOURCE_CID, false, nullptr, CreateNewRDFCompositeDataSource }, + { &kNS_RDFFILESYSTEMDATASOURCE_CID, false, nullptr, FileSystemDataSource::Create }, + { &kNS_RDFINMEMORYDATASOURCE_CID, false, nullptr, NS_NewRDFInMemoryDataSource }, + { &kNS_RDFXMLDATASOURCE_CID, false, nullptr, CreateNewRDFXMLDataSource }, + { &kNS_RDFDEFAULTRESOURCE_CID, false, nullptr, CreateNewRDFDefaultResource }, + { &kNS_RDFCONTENTSINK_CID, false, nullptr, CreateNewRDFContentSink }, + { &kNS_RDFCONTAINER_CID, false, nullptr, CreateNewRDFContainer }, + { &kNS_RDFCONTAINERUTILS_CID, false, nullptr, CreateNewRDFContainerUtils }, + { &kNS_RDFSERVICE_CID, false, nullptr, RDFServiceImpl::CreateSingleton }, + { &kNS_RDFXMLPARSER_CID, false, nullptr, nsRDFXMLParser::Create }, + { &kNS_RDFXMLSERIALIZER_CID, false, nullptr, nsRDFXMLSerializer::Create }, + { &kNS_RDFNTRIPLES_SERIALIZER_CID, false, nullptr, CreateNewTriplesSerializer }, + { &kNS_LOCALSTORE_CID, false, nullptr, NS_NewLocalStore }, + { nullptr } }; static const mozilla::Module::ContractIDEntry kRDFContracts[] = { @@ -143,7 +143,7 @@ static const mozilla::Module::ContractIDEntry kRDFContracts[] = { { NS_RDF_CONTRACTID "/xml-serializer;1", &kNS_RDFXMLSERIALIZER_CID }, { NS_RDF_SERIALIZER "ntriples", &kNS_RDFNTRIPLES_SERIALIZER_CID }, { NS_LOCALSTORE_CONTRACTID, &kNS_LOCALSTORE_CID }, - { NULL } + { nullptr } }; static nsresult @@ -170,8 +170,8 @@ static const mozilla::Module kRDFModule = { mozilla::Module::kVersion, kRDFCIDs, kRDFContracts, - NULL, - NULL, + nullptr, + nullptr, StartupRDFModule, ShutdownRDFModule }; From 138cf9ba66ea2109eff8daac992b2ac1812e7ac3 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 31 Jul 2013 11:44:18 -0400 Subject: [PATCH 09/40] Bug 784739 - Switch from NULL to nullptr in services/; r=ehsan --- services/crypto/component/nsSyncJPAKE.cpp | 47 ++++++++++++----------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/services/crypto/component/nsSyncJPAKE.cpp b/services/crypto/component/nsSyncJPAKE.cpp index c07339e542d1..5c3a3b1265ca 100644 --- a/services/crypto/component/nsSyncJPAKE.cpp +++ b/services/crypto/component/nsSyncJPAKE.cpp @@ -133,7 +133,7 @@ NS_IMETHODIMP nsSyncJPAKE::Round1(const nsACString & aSignerID, nsACString & aR2) { NS_ENSURE_STATE(round == JPAKENotStarted); - NS_ENSURE_STATE(key == NULL); + NS_ENSURE_STATE(key == nullptr); static CK_MECHANISM_TYPE mechanisms[] = { CKM_NSS_JPAKE_ROUND1_SHA256, @@ -142,8 +142,9 @@ NS_IMETHODIMP nsSyncJPAKE::Round1(const nsACString & aSignerID, }; PK11SlotInfo * slot = PK11_GetBestSlotMultiple(mechanisms, - NUM_ELEM(mechanisms), NULL); - NS_ENSURE_STATE(slot != NULL); + NUM_ELEM(mechanisms), + nullptr); + NS_ENSURE_STATE(slot != nullptr); CK_BYTE pBuf[(NUM_ELEM(p) - 1) / 2]; CK_BYTE qBuf[(NUM_ELEM(q) - 1) / 2]; @@ -178,8 +179,8 @@ NS_IMETHODIMP nsSyncJPAKE::Round1(const nsACString & aSignerID, key = PK11_KeyGenWithTemplate(slot, CKM_NSS_JPAKE_ROUND1_SHA256, CKM_NSS_JPAKE_ROUND1_SHA256, ¶msItem, keyTemplate, - NUM_ELEM(keyTemplate), NULL); - nsresult rv = key != NULL + NUM_ELEM(keyTemplate), nullptr); + nsresult rv = key != nullptr ? NS_OK : mapErrno(); if (rv == NS_OK) { @@ -208,7 +209,7 @@ NS_IMETHODIMP nsSyncJPAKE::Round2(const nsACString & aPeerID, nsACString & aRA) { NS_ENSURE_STATE(round == JPAKEBeforeRound2); - NS_ENSURE_STATE(key != NULL); + NS_ENSURE_STATE(key != nullptr); NS_ENSURE_ARG(!aPeerID.IsEmpty()); /* PIN cannot be equal to zero when converted to a bignum. NSS 3.12.9 J-PAKE @@ -274,7 +275,7 @@ NS_IMETHODIMP nsSyncJPAKE::Round2(const nsACString & aPeerID, keyTemplate, NUM_ELEM(keyTemplate), false); - if (newKey != NULL) { + if (newKey != nullptr) { if (toHexString(rp.A.pGX, rp.A.ulGXLen, aA) && toHexString(rp.A.pGV, rp.A.ulGVLen, aGVA) && toHexString(rp.A.pR, rp.A.ulRLen, aRA)) { @@ -298,7 +299,7 @@ setBase64(const unsigned char * data, unsigned len, nsACString & out) nsresult rv = NS_OK; const char * base64 = BTOA_DataToAscii(data, len); - if (base64 != NULL) { + if (base64 != nullptr) { size_t len = PORT_Strlen(base64); if (out.SetCapacity(len, fallible_t())) { out.SetLength(0); @@ -319,7 +320,7 @@ base64KeyValue(PK11SymKey * key, nsACString & keyString) nsresult rv = NS_OK; if (PK11_ExtractKeyValue(key) == SECSuccess) { const SECItem * value = PK11_GetKeyData(key); - rv = value != NULL && value->data != NULL && value->len > 0 + rv = value != nullptr && value->data != nullptr && value->len > 0 ? setBase64(value->data, value->len, keyString) : NS_ERROR_UNEXPECTED; } else { @@ -339,7 +340,7 @@ extractBase64KeyValue(PK11SymKey * keyBlock, CK_ULONG bitPosition, PK11SymKey * key = PK11_Derive(keyBlock, CKM_EXTRACT_KEY_FROM_KEY, ¶msItem, destMech, CKA_SIGN, keySize); - if (key == NULL) + if (key == nullptr) return mapErrno(); nsresult rv = base64KeyValue(key, keyString); PK11_FreeSymKey(key); @@ -360,7 +361,7 @@ NS_IMETHODIMP nsSyncJPAKE::Final(const nsACString & aB, CK_EXTRACT_PARAMS hmacBitPosition = aesBitPosition + (AES256_KEY_SIZE * 8); NS_ENSURE_STATE(round == JPAKEAfterRound2); - NS_ENSURE_STATE(key != NULL); + NS_ENSURE_STATE(key != nullptr); CK_BYTE gxBBuf[NUM_ELEM(p)/2], gvBBuf[NUM_ELEM(p)/2], rBBuf [NUM_ELEM(p)/2]; nsresult rv = fromHexString(aB, gxBBuf, sizeof gxBBuf); @@ -379,15 +380,15 @@ NS_IMETHODIMP nsSyncJPAKE::Final(const nsACString & aB, PK11SymKey * keyMaterial = PK11_Derive(key, CKM_NSS_JPAKE_FINAL_SHA256, ¶msItem, CKM_NSS_HKDF_SHA256, CKA_DERIVE, 0); - PK11SymKey * keyBlock = NULL; + PK11SymKey * keyBlock = nullptr; - if (keyMaterial == NULL) + if (keyMaterial == nullptr) rv = mapErrno(); if (rv == NS_OK) { CK_NSS_HKDFParams hkdfParams; hkdfParams.bExtract = CK_TRUE; - hkdfParams.pSalt = NULL; + hkdfParams.pSalt = nullptr; hkdfParams.ulSaltLen = 0; hkdfParams.bExpand = CK_TRUE; hkdfParams.pInfo = (CK_BYTE *) aHKDFInfo.Data(); @@ -397,7 +398,7 @@ NS_IMETHODIMP nsSyncJPAKE::Final(const nsACString & aB, keyBlock = PK11_Derive(keyMaterial, CKM_NSS_HKDF_SHA256, ¶msItem, CKM_EXTRACT_KEY_FROM_KEY, CKA_DERIVE, AES256_KEY_SIZE + HMAC_SHA256_KEY_SIZE); - if (keyBlock == NULL) + if (keyBlock == nullptr) rv = mapErrno(); } @@ -414,12 +415,12 @@ NS_IMETHODIMP nsSyncJPAKE::Final(const nsACString & aB, SECStatus srv = PK11_ExtractKeyValue(keyMaterial); NS_ENSURE_TRUE(srv == SECSuccess, NS_ERROR_UNEXPECTED); // XXX leaks SECItem * keyMaterialBytes = PK11_GetKeyData(keyMaterial); - NS_ENSURE_TRUE(keyMaterialBytes != NULL, NS_ERROR_UNEXPECTED); + NS_ENSURE_TRUE(keyMaterialBytes != nullptr, NS_ERROR_UNEXPECTED); } - if (keyBlock != NULL) + if (keyBlock != nullptr) PK11_FreeSymKey(keyBlock); - if (keyMaterial != NULL) + if (keyMaterial != nullptr) PK11_FreeSymKey(keyMaterial); return rv; @@ -428,22 +429,22 @@ NS_IMETHODIMP nsSyncJPAKE::Final(const nsACString & aB, NS_GENERIC_FACTORY_CONSTRUCTOR(nsSyncJPAKE) NS_DEFINE_NAMED_CID(NS_SYNCJPAKE_CID); -nsSyncJPAKE::nsSyncJPAKE() : round(JPAKENotStarted), key(NULL) { } +nsSyncJPAKE::nsSyncJPAKE() : round(JPAKENotStarted), key(nullptr) { } nsSyncJPAKE::~nsSyncJPAKE() { - if (key != NULL) + if (key != nullptr) PK11_FreeSymKey(key); } static const mozilla::Module::CIDEntry kServicesCryptoCIDs[] = { - { &kNS_SYNCJPAKE_CID, false, NULL, nsSyncJPAKEConstructor }, - { NULL } + { &kNS_SYNCJPAKE_CID, false, nullptr, nsSyncJPAKEConstructor }, + { nullptr } }; static const mozilla::Module::ContractIDEntry kServicesCryptoContracts[] = { { NS_SYNCJPAKE_CONTRACTID, &kNS_SYNCJPAKE_CID }, - { NULL } + { nullptr } }; static const mozilla::Module kServicesCryptoModule = { From c742394e7573766bf54b3b75f61e0fbc16fd99c0 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 31 Jul 2013 11:44:31 -0400 Subject: [PATCH 10/40] Bug 784739 - Switch from NULL to nullptr in gfx/thebes/; r=ehsan --- gfx/thebes/gfxASurface.cpp | 4 +- gfx/thebes/gfxAndroidPlatform.cpp | 4 +- gfx/thebes/gfxBlur.h | 11 ++-- gfx/thebes/gfxContext.cpp | 59 +++++++++--------- gfx/thebes/gfxContext.h | 4 +- gfx/thebes/gfxCoreTextShaper.cpp | 28 ++++----- gfx/thebes/gfxCoreTextShaper.h | 2 +- gfx/thebes/gfxD2DSurface.cpp | 2 +- gfx/thebes/gfxDWriteCommon.cpp | 4 +- gfx/thebes/gfxDWriteFontList.cpp | 20 +++--- gfx/thebes/gfxDWriteFontList.h | 2 +- gfx/thebes/gfxDWriteFonts.cpp | 2 +- gfx/thebes/gfxDWriteShaper.cpp | 16 ++--- gfx/thebes/gfxDWriteTextAnalysis.cpp | 10 +-- gfx/thebes/gfxFT2FontBase.cpp | 2 +- gfx/thebes/gfxFT2FontList.cpp | 18 +++--- gfx/thebes/gfxFT2FontList.h | 2 +- gfx/thebes/gfxFT2Fonts.cpp | 2 +- gfx/thebes/gfxFT2Utils.cpp | 6 +- gfx/thebes/gfxFont.cpp | 8 +-- gfx/thebes/gfxFont.h | 12 ++-- gfx/thebes/gfxFontconfigUtils.cpp | 49 +++++++-------- gfx/thebes/gfxFontconfigUtils.h | 8 +-- gfx/thebes/gfxGDIFont.cpp | 4 +- gfx/thebes/gfxGDIFontList.cpp | 9 +-- gfx/thebes/gfxGDIFontList.h | 8 +-- gfx/thebes/gfxGDIShaper.cpp | 2 +- gfx/thebes/gfxGdkNativeRenderer.cpp | 2 +- gfx/thebes/gfxImageSurface.cpp | 2 +- gfx/thebes/gfxMacFont.cpp | 4 +- gfx/thebes/gfxOS2Fonts.cpp | 6 +- gfx/thebes/gfxOS2Surface.cpp | 2 +- gfx/thebes/gfxPangoFonts.cpp | 84 ++++++++++++++------------ gfx/thebes/gfxPangoFonts.h | 11 ++-- gfx/thebes/gfxPattern.cpp | 24 ++++---- gfx/thebes/gfxPattern.h | 2 +- gfx/thebes/gfxPlatform.cpp | 10 +-- gfx/thebes/gfxPlatform.h | 2 +- gfx/thebes/gfxPlatformGtk.cpp | 56 ++++++++--------- gfx/thebes/gfxPlatformMac.cpp | 4 +- gfx/thebes/gfxQtNativeRenderer.cpp | 2 +- gfx/thebes/gfxQtPlatform.cpp | 42 ++++++------- gfx/thebes/gfxQuartzImageSurface.cpp | 2 +- gfx/thebes/gfxQuartzSurface.cpp | 2 +- gfx/thebes/gfxUniscribeShaper.cpp | 4 +- gfx/thebes/gfxUniscribeShaper.h | 2 +- gfx/thebes/gfxUserFontSet.cpp | 2 +- gfx/thebes/gfxUtils.cpp | 2 +- gfx/thebes/gfxWindowsNativeDrawing.cpp | 4 +- gfx/thebes/gfxWindowsPlatform.cpp | 27 +++++---- gfx/thebes/gfxWindowsPlatform.h | 6 +- gfx/thebes/gfxWindowsSurface.cpp | 2 +- gfx/thebes/gfxWindowsSurface.h | 2 +- gfx/thebes/gfxXlibNativeRenderer.cpp | 10 +-- gfx/thebes/gfxXlibSurface.cpp | 8 +-- gfx/thebes/nsSurfaceTexture.cpp | 20 +++--- 56 files changed, 330 insertions(+), 314 deletions(-) diff --git a/gfx/thebes/gfxASurface.cpp b/gfx/thebes/gfxASurface.cpp index 15b327b259fe..37fa78aba4f8 100644 --- a/gfx/thebes/gfxASurface.cpp +++ b/gfx/thebes/gfxASurface.cpp @@ -113,7 +113,7 @@ gfxASurface* gfxASurface::GetSurfaceWrapper(cairo_surface_t *csurf) { if (!csurf) - return NULL; + return nullptr; return (gfxASurface*) cairo_surface_get_user_data(csurf, &gfxasurface_pointer_key); } @@ -281,7 +281,7 @@ void * gfxASurface::GetData(const cairo_user_data_key_t *key) { if (!mSurfaceValid) - return NULL; + return nullptr; return cairo_surface_get_user_data(mSurface, key); } diff --git a/gfx/thebes/gfxAndroidPlatform.cpp b/gfx/thebes/gfxAndroidPlatform.cpp index de25e84f11c0..628c6093b0b1 100644 --- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -27,7 +27,7 @@ using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::gfx; -static FT_Library gPlatformFTLibrary = NULL; +static FT_Library gPlatformFTLibrary = nullptr; static int64_t sFreetypeMemoryUsed; static FT_MemoryRec_ sFreetypeMemoryRecord; @@ -114,7 +114,7 @@ gfxAndroidPlatform::~gfxAndroidPlatform() cairo_debug_reset_static_data(); FT_Done_Library(gPlatformFTLibrary); - gPlatformFTLibrary = NULL; + gPlatformFTLibrary = nullptr; } already_AddRefed diff --git a/gfx/thebes/gfxBlur.h b/gfx/thebes/gfxBlur.h index 152495dff6cf..70e3250c1fbd 100644 --- a/gfx/thebes/gfxBlur.h +++ b/gfx/thebes/gfxBlur.h @@ -52,12 +52,13 @@ public: * this value. This parameter should nearly always be computed using * CalculateBlurRadius, below. * - * @param aDirtyRect A pointer to a dirty rect, measured in device units, if available. - * This will be used for optimizing the blur operation. It is safe to pass NULL here. + * @param aDirtyRect A pointer to a dirty rect, measured in device units, + * if available. This will be used for optimizing the blur operation. It + * is safe to pass nullptr here. * - * @param aSkipRect A pointer to a rect, measured in device units, that represents an area - * where blurring is unnecessary and shouldn't be done for speed reasons. It is safe to - * pass NULL here. + * @param aSkipRect A pointer to a rect, measured in device units, that + * represents an area where blurring is unnecessary and shouldn't be done + * for speed reasons. It is safe to pass nullptr here. */ gfxContext* Init(const gfxRect& aRect, const gfxIntSize& aSpreadRadius, diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index a2f6da06bfa2..e2e5e7eeb9b0 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -36,7 +36,7 @@ using namespace mozilla::gfx; class GeneralPattern { public: - GeneralPattern(gfxContext *aContext) : mContext(aContext), mPattern(NULL) {} + GeneralPattern(gfxContext *aContext) : mContext(aContext), mPattern(nullptr) {} ~GeneralPattern() { if (mPattern) { mPattern->~Pattern(); } } operator mozilla::gfx::Pattern&() @@ -76,7 +76,7 @@ private: }; gfxContext::gfxContext(gfxASurface *surface) - : mRefCairo(NULL) + : mRefCairo(nullptr) , mSurface(surface) { MOZ_COUNT_CTOR(gfxContext); @@ -97,9 +97,9 @@ gfxContext::gfxContext(gfxASurface *surface) gfxContext::gfxContext(DrawTarget *aTarget) : mPathIsRect(false) , mTransformChanged(false) - , mCairo(NULL) - , mRefCairo(NULL) - , mSurface(NULL) + , mCairo(nullptr) + , mRefCairo(nullptr) + , mSurface(nullptr) , mFlags(0) , mDT(aTarget) , mOriginalDT(aTarget) @@ -224,8 +224,8 @@ gfxContext::NewPath() if (mCairo) { cairo_new_path(mCairo); } else { - mPath = NULL; - mPathBuilder = NULL; + mPath = nullptr; + mPathBuilder = nullptr; mPathIsRect = false; mTransformChanged = false; } @@ -934,7 +934,8 @@ gfxContext::SetDash(gfxFloat *dashes, int ndash, gfxFloat offset) } state.strokeOptions.mDashLength = ndash; state.strokeOptions.mDashOffset = Float(offset); - state.strokeOptions.mDashPattern = ndash ? state.dashPattern.Elements() : NULL; + state.strokeOptions.mDashPattern = ndash ? state.dashPattern.Elements() + : nullptr; } } @@ -974,7 +975,7 @@ gfxContext::CurrentDashOffset() const return 0.0; } gfxFloat offset; - cairo_get_dash(mCairo, NULL, &offset); + cairo_get_dash(mCairo, nullptr, &offset); return offset; } else { return CurrentState().strokeOptions.mDashOffset; @@ -1122,7 +1123,7 @@ gfxContext::Clip(const gfxRect& rect) cairo_rectangle(mCairo, rect.X(), rect.Y(), rect.Width(), rect.Height()); cairo_clip(mCairo); } else { - AzureState::PushedClip clip = { NULL, ToRect(rect), mTransform }; + AzureState::PushedClip clip = { nullptr, ToRect(rect), mTransform }; CurrentState().pushedClips.AppendElement(clip); mDT->PushClipRect(ToRect(rect)); NewPath(); @@ -1138,7 +1139,7 @@ gfxContext::Clip() if (mPathIsRect) { MOZ_ASSERT(!mTransformChanged); - AzureState::PushedClip clip = { NULL, mRect, mTransform }; + AzureState::PushedClip clip = { nullptr, mRect, mTransform }; CurrentState().pushedClips.AppendElement(clip); mDT->PushClipRect(mRect); } else { @@ -1279,9 +1280,9 @@ gfxContext::SetColor(const gfxRGBA& c) else cairo_set_source_rgba(mCairo, c.r, c.g, c.b, c.a); } else { - CurrentState().pattern = NULL; - CurrentState().sourceSurfCairo = NULL; - CurrentState().sourceSurface = NULL; + CurrentState().pattern = nullptr; + CurrentState().sourceSurfCairo = nullptr; + CurrentState().sourceSurface = nullptr; if (gfxPlatform::GetCMSMode() == eCMSMode_All) { @@ -1305,9 +1306,9 @@ gfxContext::SetDeviceColor(const gfxRGBA& c) if (mCairo) { cairo_set_source_rgba(mCairo, c.r, c.g, c.b, c.a); } else { - CurrentState().pattern = NULL; - CurrentState().sourceSurfCairo = NULL; - CurrentState().sourceSurface = NULL; + CurrentState().pattern = nullptr; + CurrentState().sourceSurfCairo = nullptr; + CurrentState().sourceSurface = nullptr; CurrentState().color = ToColor(c); } } @@ -1343,7 +1344,7 @@ gfxContext::SetSource(gfxASurface *surface, const gfxPoint& offset) cairo_set_source_surface(mCairo, surface->CairoSurface(), offset.x, offset.y); } else { CurrentState().surfTransform = Matrix(1.0f, 0, 0, 1.0f, Float(offset.x), Float(offset.y)); - CurrentState().pattern = NULL; + CurrentState().pattern = nullptr; CurrentState().patternTransformChanged = false; // Keep the underlying cairo surface around while we keep the // sourceSurface. @@ -1359,8 +1360,8 @@ gfxContext::SetPattern(gfxPattern *pattern) if (mCairo) { cairo_set_source(mCairo, pattern->CairoPattern()); } else { - CurrentState().sourceSurfCairo = NULL; - CurrentState().sourceSurface = NULL; + CurrentState().sourceSurfCairo = nullptr; + CurrentState().sourceSurface = nullptr; CurrentState().patternTransformChanged = false; CurrentState().pattern = pattern; } @@ -1621,9 +1622,9 @@ gfxContext::PopGroupToSource() RefPtr src = mDT->Snapshot(); Point deviceOffset = CurrentState().deviceOffset; Restore(); - CurrentState().sourceSurfCairo = NULL; + CurrentState().sourceSurfCairo = nullptr; CurrentState().sourceSurface = src; - CurrentState().pattern = NULL; + CurrentState().pattern = nullptr; CurrentState().patternTransformChanged = false; Matrix mat = mTransform; @@ -1952,7 +1953,7 @@ gfxContext::EnsurePath() { if (mPathBuilder) { mPath = mPathBuilder->Finish(); - mPathBuilder = NULL; + mPathBuilder = nullptr; } if (mPath) { @@ -1962,7 +1963,7 @@ gfxContext::EnsurePath() mat = mPathTransform * mat; mPathBuilder = mPath->TransformedCopyToBuilder(mat, CurrentState().fillRule); mPath = mPathBuilder->Finish(); - mPathBuilder = NULL; + mPathBuilder = nullptr; mTransformChanged = false; } @@ -1974,13 +1975,13 @@ gfxContext::EnsurePath() mPathBuilder = mPath->CopyToBuilder(CurrentState().fillRule); mPath = mPathBuilder->Finish(); - mPathBuilder = NULL; + mPathBuilder = nullptr; return; } EnsurePathBuilder(); mPath = mPathBuilder->Finish(); - mPathBuilder = NULL; + mPathBuilder = nullptr; } void @@ -1993,7 +1994,7 @@ gfxContext::EnsurePathBuilder() if (mPath) { if (!mTransformChanged) { mPathBuilder = mPath->CopyToBuilder(CurrentState().fillRule); - mPath = NULL; + mPath = nullptr; } else { Matrix invTransform = mTransform; invTransform.Invert(); @@ -2019,8 +2020,8 @@ gfxContext::EnsurePathBuilder() if (mTransformChanged) { // This could be an else if since this should never happen when - // mPathBuilder is NULL and mPath is NULL. But this way we can assert - // if all the state is as expected. + // mPathBuilder is nullptr and mPath is nullptr. But this way we can + // assert if all the state is as expected. MOZ_ASSERT(oldPath); MOZ_ASSERT(!mPathIsRect); diff --git a/gfx/thebes/gfxContext.h b/gfx/thebes/gfxContext.h index 10ecb648016a..8f4714a5d950 100644 --- a/gfx/thebes/gfxContext.h +++ b/gfx/thebes/gfxContext.h @@ -67,7 +67,7 @@ public: */ already_AddRefed CurrentSurface(gfxFloat *dx, gfxFloat *dy); already_AddRefed CurrentSurface() { - return CurrentSurface(NULL, NULL); + return CurrentSurface(nullptr, nullptr); } /** @@ -453,7 +453,7 @@ public: void SetDash(gfxLineType ltype); void SetDash(gfxFloat *dashes, int ndash, gfxFloat offset); // Return true if dashing is set, false if it's not enabled or the - // context is in an error state. |offset| can be NULL to mean + // context is in an error state. |offset| can be nullptr to mean // "don't care". bool CurrentDash(FallibleTArray& dashes, gfxFloat* offset) const; // Returns 0.0 if dashing isn't enabled. diff --git a/gfx/thebes/gfxCoreTextShaper.cpp b/gfx/thebes/gfxCoreTextShaper.cpp index 62b5b788c1fb..e1949291e02f 100644 --- a/gfx/thebes/gfxCoreTextShaper.cpp +++ b/gfx/thebes/gfxCoreTextShaper.cpp @@ -32,8 +32,8 @@ using namespace mozilla; // standard font descriptors that we construct the first time they're needed -CTFontDescriptorRef gfxCoreTextShaper::sDefaultFeaturesDescriptor = NULL; -CTFontDescriptorRef gfxCoreTextShaper::sDisableLigaturesDescriptor = NULL; +CTFontDescriptorRef gfxCoreTextShaper::sDefaultFeaturesDescriptor = nullptr; +CTFontDescriptorRef gfxCoreTextShaper::sDisableLigaturesDescriptor = nullptr; gfxCoreTextShaper::gfxCoreTextShaper(gfxMacFont *aFont) : gfxFontShaper(aFont) @@ -41,7 +41,7 @@ gfxCoreTextShaper::gfxCoreTextShaper(gfxMacFont *aFont) // Create our CTFontRef mCTFont = ::CTFontCreateWithGraphicsFont(aFont->GetCGFontRef(), aFont->GetAdjustedSize(), - NULL, + nullptr, GetDefaultFeaturesDescriptor()); // Set up the default attribute dictionary that we will need each time we create a CFAttributedString @@ -214,9 +214,9 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedText *aShapedText, nsAutoArrayPtr glyphsArray; nsAutoArrayPtr positionsArray; nsAutoArrayPtr glyphToCharArray; - const CGGlyph* glyphs = NULL; - const CGPoint* positions = NULL; - const CFIndex* glyphToChar = NULL; + const CGGlyph* glyphs = nullptr; + const CGPoint* positions = nullptr; + const CFIndex* glyphToChar = nullptr; // Testing indicates that CTRunGetGlyphsPtr (almost?) always succeeds, // and so allocating a new array and copying data with CTRunGetGlyphs @@ -260,7 +260,7 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedText *aShapedText, } double runWidth = ::CTRunGetTypographicBounds(aCTRun, ::CFRangeMake(0, 0), - NULL, NULL, NULL); + nullptr, nullptr, nullptr); nsAutoTArray detailedGlyphs; gfxShapedText::CompressedGlyph g; @@ -513,7 +513,7 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedText *aShapedText, void gfxCoreTextShaper::CreateDefaultFeaturesDescriptor() { - if (sDefaultFeaturesDescriptor != NULL) { + if (sDefaultFeaturesDescriptor != nullptr) { return; } @@ -586,7 +586,7 @@ gfxCoreTextShaper::CreateDefaultFeaturesDescriptor() CTFontRef gfxCoreTextShaper::CreateCTFontWithDisabledLigatures(CGFloat aSize) { - if (sDisableLigaturesDescriptor == NULL) { + if (sDisableLigaturesDescriptor == nullptr) { // initialize cached descriptor to turn off the Common Ligatures feature SInt16 val = kLigaturesType; CFNumberRef ligaturesType = @@ -636,19 +636,19 @@ gfxCoreTextShaper::CreateCTFontWithDisabledLigatures(CGFloat aSize) } gfxMacFont *f = static_cast(mFont); - return ::CTFontCreateWithGraphicsFont(f->GetCGFontRef(), aSize, NULL, + return ::CTFontCreateWithGraphicsFont(f->GetCGFontRef(), aSize, nullptr, sDisableLigaturesDescriptor); } void gfxCoreTextShaper::Shutdown() // [static] { - if (sDisableLigaturesDescriptor != NULL) { + if (sDisableLigaturesDescriptor != nullptr) { ::CFRelease(sDisableLigaturesDescriptor); - sDisableLigaturesDescriptor = NULL; + sDisableLigaturesDescriptor = nullptr; } - if (sDefaultFeaturesDescriptor != NULL) { + if (sDefaultFeaturesDescriptor != nullptr) { ::CFRelease(sDefaultFeaturesDescriptor); - sDefaultFeaturesDescriptor = NULL; + sDefaultFeaturesDescriptor = nullptr; } } diff --git a/gfx/thebes/gfxCoreTextShaper.h b/gfx/thebes/gfxCoreTextShaper.h index aa22dcb6da42..5928da69112e 100644 --- a/gfx/thebes/gfxCoreTextShaper.h +++ b/gfx/thebes/gfxCoreTextShaper.h @@ -47,7 +47,7 @@ protected: static void CreateDefaultFeaturesDescriptor(); static CTFontDescriptorRef GetDefaultFeaturesDescriptor() { - if (sDefaultFeaturesDescriptor == NULL) { + if (sDefaultFeaturesDescriptor == nullptr) { CreateDefaultFeaturesDescriptor(); } return sDefaultFeaturesDescriptor; diff --git a/gfx/thebes/gfxD2DSurface.cpp b/gfx/thebes/gfxD2DSurface.cpp index 941ff7a5959f..475dd42144a0 100644 --- a/gfx/thebes/gfxD2DSurface.cpp +++ b/gfx/thebes/gfxD2DSurface.cpp @@ -83,7 +83,7 @@ void gfxD2DSurface::ReleaseDC(const nsIntRect *aUpdatedRect) { if (!aUpdatedRect) { - return cairo_d2d_release_dc(CairoSurface(), NULL); + return cairo_d2d_release_dc(CairoSurface(), nullptr); } cairo_rectangle_int_t rect; diff --git a/gfx/thebes/gfxDWriteCommon.cpp b/gfx/thebes/gfxDWriteCommon.cpp index 844397f39368..e91388f326b9 100644 --- a/gfx/thebes/gfxDWriteCommon.cpp +++ b/gfx/thebes/gfxDWriteCommon.cpp @@ -5,7 +5,7 @@ #include "gfxDWriteCommon.h" -IDWriteFontFileLoader* gfxDWriteFontFileLoader::mInstance = NULL; +IDWriteFontFileLoader* gfxDWriteFontFileLoader::mInstance = nullptr; HRESULT STDMETHODCALLTYPE gfxDWriteFontFileLoader::CreateStreamFromKey(const void *fontFileReferenceKey, @@ -61,7 +61,7 @@ gfxDWriteFontFileStream::ReadFileFragment(const void **fragmentStart, } // We should be alive for the duration of this. *fragmentStart = &mData[fileOffset]; - *fragmentContext = NULL; + *fragmentContext = nullptr; return S_OK; } diff --git a/gfx/thebes/gfxDWriteFontList.cpp b/gfx/thebes/gfxDWriteFontList.cpp index f8e3b728e42e..cfb5a599ebc6 100644 --- a/gfx/thebes/gfxDWriteFontList.cpp +++ b/gfx/thebes/gfxDWriteFontList.cpp @@ -290,7 +290,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag, uint32_t tableSize = ::GetFontData(dc.GetDC(), NativeEndian::swapToBigEndian(aTableTag), 0, - NULL, 0); + nullptr, 0); if (tableSize != GDI_ERROR) { if (aBuffer.SetLength(tableSize)) { ::GetFontData(dc.GetDC(), @@ -312,7 +312,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag, uint8_t *tableData; uint32_t len; - void *tableContext = NULL; + void *tableContext = nullptr; BOOL exists; HRESULT hr = fontFace->TryGetFontTable(NativeEndian::swapToBigEndian(aTableTag), @@ -481,7 +481,7 @@ gfxDWriteFontEntry::CreateFontFace(IDWriteFontFace **aFontFace, // has the Bold simulation - unfortunately, DWrite doesn't provide // a simple API for this UINT32 numberOfFiles = 0; - if (FAILED(mFontFace->GetFiles(&numberOfFiles, NULL))) { + if (FAILED(mFontFace->GetFiles(&numberOfFiles, nullptr))) { return NS_ERROR_FAILURE; } nsAutoTArray files; @@ -753,8 +753,8 @@ gfxDWriteFontList::InitFontList() if (LOG_FONTINIT_ENABLED()) { GetTimeFormat(LOCALE_INVARIANT, TIME_FORCE24HOURFORMAT, - NULL, NULL, nowTime, 256); - GetDateFormat(LOCALE_INVARIANT, 0, NULL, NULL, nowDate, 256); + nullptr, nullptr, nowTime, 256); + GetDateFormat(LOCALE_INVARIANT, 0, nullptr, nullptr, nowDate, 256); } upTime = (double) GetTickCount(); QueryPerformanceFrequency(&frequency); @@ -821,8 +821,8 @@ gfxDWriteFontList::DelayedInitFontList() if (LOG_FONTINIT_ENABLED()) { GetTimeFormat(LOCALE_INVARIANT, TIME_FORCE24HOURFORMAT, - NULL, NULL, nowTime, 256); - GetDateFormat(LOCALE_INVARIANT, 0, NULL, NULL, nowDate, 256); + nullptr, nullptr, nowTime, 256); + GetDateFormat(LOCALE_INVARIANT, 0, nullptr, nullptr, nowDate, 256); } upTime = (double) GetTickCount(); @@ -1094,7 +1094,7 @@ gfxDWriteFontList::GetFontSubstitutes() lenAlias = ArrayLength(aliasName); actualName[0] = 0; lenActual = sizeof(actualName); - rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, NULL, &valueType, + rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, nullptr, &valueType, (LPBYTE)actualName, &lenActual); if (rv != ERROR_SUCCESS || valueType != REG_SZ || lenAlias == 0) { @@ -1371,7 +1371,7 @@ gfxDWriteFontList::GlobalFontFallback(const uint32_t aCh, // initialize text format if (!mFallbackFormat) { - hr = dwFactory->CreateTextFormat(L"Arial", NULL, + hr = dwFactory->CreateTextFormat(L"Arial", nullptr, DWRITE_FONT_WEIGHT_REGULAR, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, @@ -1409,7 +1409,7 @@ gfxDWriteFontList::GlobalFontFallback(const uint32_t aCh, // call the draw method to invoke the DirectWrite layout functions // which determine the fallback font - hr = fallbackLayout->Draw(NULL, mFallbackRenderer, 50.0f, 50.0f); + hr = fallbackLayout->Draw(nullptr, mFallbackRenderer, 50.0f, 50.0f); if (FAILED(hr)) { return nullptr; } diff --git a/gfx/thebes/gfxDWriteFontList.h b/gfx/thebes/gfxDWriteFontList.h index 1a1c17372307..07eb67b247d2 100644 --- a/gfx/thebes/gfxDWriteFontList.h +++ b/gfx/thebes/gfxDWriteFontList.h @@ -313,7 +313,7 @@ public: } else if (__uuidof(IUnknown) == riid) { *ppvObject = this; } else { - *ppvObject = NULL; + *ppvObject = nullptr; return E_FAIL; } diff --git a/gfx/thebes/gfxDWriteFonts.cpp b/gfx/thebes/gfxDWriteFonts.cpp index 094a98aa71ec..0bf9617380aa 100644 --- a/gfx/thebes/gfxDWriteFonts.cpp +++ b/gfx/thebes/gfxDWriteFonts.cpp @@ -491,7 +491,7 @@ gfxDWriteFont::SetupCairoFont(gfxContext *aContext) bool gfxDWriteFont::IsValid() { - return mFontFace != NULL; + return mFontFace != nullptr; } IDWriteFontFace* diff --git a/gfx/thebes/gfxDWriteShaper.cpp b/gfx/thebes/gfxDWriteShaper.cpp index 0934516a4897..39c58916f13d 100644 --- a/gfx/thebes/gfxDWriteShaper.cpp +++ b/gfx/thebes/gfxDWriteShaper.cpp @@ -45,7 +45,7 @@ gfxDWriteShaper::ShapeText(gfxContext *aContext, */ UINT32 length = aLength; - TextAnalysis analysis(aText, length, NULL, readingDirection); + TextAnalysis analysis(aText, length, nullptr, readingDirection); TextAnalysis::Run *runHead; hr = analysis.GenerateResults(analyzer, &runHead); @@ -83,7 +83,7 @@ trymoreglyphs: hr = analyzer->GetGlyphs(aText, length, font->GetFontFace(), FALSE, readingDirection == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT, - &runHead->mScript, NULL, NULL, NULL, NULL, 0, + &runHead->mScript, nullptr, nullptr, nullptr, nullptr, 0, maxGlyphs, clusters.Elements(), textProperties.Elements(), indices.Elements(), glyphProperties.Elements(), &actualGlyphs); @@ -122,9 +122,9 @@ trymoreglyphs: FALSE, FALSE, &runHead->mScript, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, 0, advances.Elements(), glyphOffsets.Elements()); @@ -141,9 +141,9 @@ trymoreglyphs: FALSE, FALSE, &runHead->mScript, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, 0, advances.Elements(), glyphOffsets.Elements()); diff --git a/gfx/thebes/gfxDWriteTextAnalysis.cpp b/gfx/thebes/gfxDWriteTextAnalysis.cpp index 95e1d2cde34b..fc97f05939de 100644 --- a/gfx/thebes/gfxDWriteTextAnalysis.cpp +++ b/gfx/thebes/gfxDWriteTextAnalysis.cpp @@ -13,7 +13,7 @@ TextAnalysis::TextAnalysis(const wchar_t* text, , mTextLength(textLength) , mLocaleName(localeName) , mReadingDirection(readingDirection) - , mCurrentRun(NULL) + , mCurrentRun(nullptr) { } @@ -42,7 +42,7 @@ TextAnalysis::GenerateResults(IDWriteTextAnalyzer* textAnalyzer, mRunHead.mTextLength = mTextLength; mRunHead.mBidiLevel = (mReadingDirection == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT); - mRunHead.nextRun = NULL; + mRunHead.nextRun = nullptr; mCurrentRun = &mRunHead; // Call each of the analyzers in sequence, recording their results. @@ -67,7 +67,7 @@ TextAnalysis::GetTextAtPosition(UINT32 textPosition, { if (textPosition >= mTextLength) { // No text at this position, valid query though. - *textString = NULL; + *textString = nullptr; *textLength = 0; } else { *textString = mText + textPosition; @@ -85,7 +85,7 @@ TextAnalysis::GetTextBeforePosition(UINT32 textPosition, if (textPosition == 0 || textPosition > mTextLength) { // Either there is no text before here (== 0), or this // is an invalid position. The query is considered valid thouh. - *textString = NULL; + *textString = nullptr; *textLength = 0; } else { *textString = mText; @@ -122,7 +122,7 @@ TextAnalysis::GetNumberSubstitution(UINT32 textPosition, OUT IDWriteNumberSubstitution** numberSubstitution) { // We do not support number substitution. - *numberSubstitution = NULL; + *numberSubstitution = nullptr; *textLength = mTextLength - textPosition; return S_OK; diff --git a/gfx/thebes/gfxFT2FontBase.cpp b/gfx/thebes/gfxFT2FontBase.cpp index 1b91810936f6..42c94490c562 100644 --- a/gfx/thebes/gfxFT2FontBase.cpp +++ b/gfx/thebes/gfxFT2FontBase.cpp @@ -91,7 +91,7 @@ gfxFT2FontBase::GetGlyph(uint32_t aCharCode) void gfxFT2FontBase::GetGlyphExtents(uint32_t aGlyph, cairo_text_extents_t* aExtents) { - NS_PRECONDITION(aExtents != NULL, "aExtents must not be NULL"); + NS_PRECONDITION(aExtents != nullptr, "aExtents must not be NULL"); cairo_glyph_t glyphs[1]; glyphs[0].index = aGlyph; diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index b2ad898c386a..3b26886f6a51 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -600,7 +600,7 @@ public: MoveEntry, PL_DHashClearEntryStub, PL_DHashFinalizeStub, - NULL + nullptr }; if (!PL_DHashTableInit(&mMap, &mOps, nullptr, @@ -659,12 +659,12 @@ public: if (!(end = strchr(beginning, ';'))) { break; } - uint32_t timestamp = strtoul(beginning, NULL, 10); + uint32_t timestamp = strtoul(beginning, nullptr, 10); beginning = end + 1; if (!(end = strchr(beginning, ';'))) { break; } - uint32_t filesize = strtoul(beginning, NULL, 10); + uint32_t filesize = strtoul(beginning, nullptr, 10); FNCMapEntry* mapEntry = static_cast @@ -829,7 +829,7 @@ gfxFT2FontList::AppendFacesFromCachedFaceList(const nsCString& aFileName, if (!(end = strchr(beginning, ','))) { break; } - uint32_t index = strtoul(beginning, NULL, 10); + uint32_t index = strtoul(beginning, nullptr, 10); beginning = end + 1; if (!(end = strchr(beginning, ','))) { break; @@ -839,12 +839,12 @@ gfxFT2FontList::AppendFacesFromCachedFaceList(const nsCString& aFileName, if (!(end = strchr(beginning, ','))) { break; } - uint32_t weight = strtoul(beginning, NULL, 10); + uint32_t weight = strtoul(beginning, nullptr, 10); beginning = end + 1; if (!(end = strchr(beginning, ','))) { break; } - int32_t stretch = strtol(beginning, NULL, 10); + int32_t stretch = strtol(beginning, nullptr, 10); FontListEntry fle(familyName, faceName, aFileName, weight, stretch, italic, index); @@ -1157,7 +1157,7 @@ gfxFT2FontList::FindFonts() FindExInfoStandard, &results, FindExSearchNameMatch, - NULL, + nullptr, 0); bool moreFiles = handle != INVALID_HANDLE_VALUE; while (moreFiles) { @@ -1276,8 +1276,8 @@ gfxFT2FontList::FindFontsInDir(const nsCString& aDir, FontNameCache *aFNC) return; } - struct dirent *ent = NULL; - while ((ent = readdir(d)) != NULL) { + struct dirent *ent = nullptr; + while ((ent = readdir(d)) != nullptr) { int namelen = strlen(ent->d_name); if (namelen <= 4) { // cannot be a usable font filename diff --git a/gfx/thebes/gfxFT2FontList.h b/gfx/thebes/gfxFT2FontList.h index decf489c2eb8..1b37ec1083c1 100644 --- a/gfx/thebes/gfxFT2FontList.h +++ b/gfx/thebes/gfxFT2FontList.h @@ -55,7 +55,7 @@ public: // Create a font entry for a given freetype face; if it is an installed font, // also record the filename and index. - // aFontData (if non-NULL) is NS_Malloc'ed data that aFace depends on, + // aFontData (if non-nullptr) is NS_Malloc'ed data that aFace depends on, // to be freed after the face is destroyed static FT2FontEntry* CreateFontEntry(FT_Face aFace, diff --git a/gfx/thebes/gfxFT2Fonts.cpp b/gfx/thebes/gfxFT2Fonts.cpp index cf84193ae067..fa9768ed1bc8 100644 --- a/gfx/thebes/gfxFT2Fonts.cpp +++ b/gfx/thebes/gfxFT2Fonts.cpp @@ -286,7 +286,7 @@ void gfxFT2FontGroup::GetCJKPrefFonts(nsTArray >& aFontEn case 950: GetPrefFonts(nsGkAtoms::zh_tw, aFontEntryList); break; } #else - const char *ctype = setlocale(LC_CTYPE, NULL); + const char *ctype = setlocale(LC_CTYPE, nullptr); if (ctype) { if (!PL_strncasecmp(ctype, "ja", 2)) { GetPrefFonts(nsGkAtoms::Japanese, aFontEntryList); diff --git a/gfx/thebes/gfxFT2Utils.cpp b/gfx/thebes/gfxFT2Utils.cpp index 25efc2795483..acc058e73353 100644 --- a/gfx/thebes/gfxFT2Utils.cpp +++ b/gfx/thebes/gfxFT2Utils.cpp @@ -47,8 +47,8 @@ void gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics, uint32_t* aSpaceGlyph) { - NS_PRECONDITION(aMetrics != NULL, "aMetrics must not be NULL"); - NS_PRECONDITION(aSpaceGlyph != NULL, "aSpaceGlyph must not be NULL"); + NS_PRECONDITION(aMetrics != nullptr, "aMetrics must not be NULL"); + NS_PRECONDITION(aSpaceGlyph != nullptr, "aSpaceGlyph must not be NULL"); if (MOZ_UNLIKELY(!mFace)) { // No face. This unfortunate situation might happen if the font @@ -323,7 +323,7 @@ gfxFT2LockedFace::GetUVSGlyph(uint32_t aCharCode, uint32_t aVariantSelector) uint32_t gfxFT2LockedFace::GetCharExtents(char aChar, cairo_text_extents_t* aExtents) { - NS_PRECONDITION(aExtents != NULL, "aExtents must not be NULL"); + NS_PRECONDITION(aExtents != nullptr, "aExtents must not be NULL"); if (!mFace) return 0; diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 8790586e693e..a7b074777361 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -706,7 +706,7 @@ gfxFontFamily::FindFontForStyle(const gfxFontStyle& aFontStyle, // Most families are "simple", having just Regular/Bold/Italic/BoldItalic, // or some subset of these. In this case, we have exactly 4 entries in mAvailableFonts, - // stored in the above order; note that some of the entries may be NULL. + // stored in the above order; note that some of the entries may be nullptr. // We can then pick the required entry based on whether the request is for // bold or non-bold, italic or non-italic, without running the more complex // matching algorithm used for larger families with many weights and/or widths. @@ -885,7 +885,7 @@ gfxFontFamily::FindWeightsForStyle(gfxFontEntry* aFontsForWeights[], uint32_t count = mAvailableFonts.Length(); for (uint32_t i = 0; i < count; i++) { // this is not called for "simple" families, and therefore it does not - // need to check the mAvailableFonts entries for NULL + // need to check the mAvailableFonts entries for nullptr. gfxFontEntry *fe = mAvailableFonts[i]; uint32_t distance = StyleDistance(fe, anItalic, aStretch); if (distance <= bestMatchDistance) { @@ -2526,8 +2526,8 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd, Matrix mat, matInv; Matrix oldMat = dt->GetTransform(); - // This is NULL when we have inverse-transformed glyphs and we need to - // transform the Brush inside flush. + // This is nullptr when we have inverse-transformed glyphs and we need + // to transform the Brush inside flush. Matrix *passedInvMatrix = nullptr; RefPtr renderingOptions = diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index 93ebad8ec07c..332b962261ff 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -350,12 +350,12 @@ public: // Subclasses should override this if they can provide more efficient // access than copying table data into our own buffers. // - // Get blob that encapsulates a specific font table, or NULL if + // Get blob that encapsulates a specific font table, or nullptr if // the table doesn't exist in the font. // // Caller is responsible to call hb_blob_destroy() on the returned blob - // (if non-NULL) when no longer required. For transient access to a table, - // use of AutoTable (below) is generally preferred. + // (if non-nullptr) when no longer required. For transient access to a + // table, use of AutoTable (below) is generally preferred. virtual hb_blob_t *GetFontTable(uint32_t aTag); // Stack-based utility to return a specified table, automatically releasing @@ -395,8 +395,8 @@ public: // reference is owned by the caller. Removing the last reference // unregisters the table from the font entry. // - // Pass NULL for aBuffer to indicate that the table is not present and - // NULL will be returned. Also returns NULL on OOM. + // Pass nullptr for aBuffer to indicate that the table is not present and + // nullptr will be returned. Also returns nullptr on OOM. hb_blob_t *ShareFontTableAndGetBlob(uint32_t aTag, FallibleTArray* aTable); @@ -1548,7 +1548,7 @@ public: * @param aDrawMode specifies whether the fill or stroke of the glyph should be * drawn, or if it should be drawn into the current path * @param aObjectPaint information about how to construct the fill and - * stroke pattern. Can be NULL if we are not stroking the text, which + * stroke pattern. Can be nullptr if we are not stroking the text, which * indicates that the current source from aContext should be used for filling * * Callers guarantee: diff --git a/gfx/thebes/gfxFontconfigUtils.cpp b/gfx/thebes/gfxFontconfigUtils.cpp index 7888308e339f..7c98c59d7d6b 100644 --- a/gfx/thebes/gfxFontconfigUtils.cpp +++ b/gfx/thebes/gfxFontconfigUtils.cpp @@ -308,7 +308,7 @@ gfxFontconfigUtils::NewPattern(const nsTArray& aFamilies, } gfxFontconfigUtils::gfxFontconfigUtils() - : mLastConfig(NULL) + : mLastConfig(nullptr) { mFontsByFamily.Init(50); mFontsByFullname.Init(50); @@ -477,7 +477,7 @@ gfxFontconfigUtils::GetSampleLangForGroup(nsIAtom *aLangGroup, } } } - const char *ctype = setlocale(LC_CTYPE, NULL); + const char *ctype = setlocale(LC_CTYPE, nullptr); if (ctype && TryLangForGroup(nsDependentCString(ctype), aLangGroup, aFcLang)) return; @@ -494,9 +494,9 @@ nsresult gfxFontconfigUtils::GetFontListInternal(nsTArray& aListOfFonts, nsIAtom *aLangGroup) { - FcPattern *pat = NULL; - FcObjectSet *os = NULL; - FcFontSet *fs = NULL; + FcPattern *pat = nullptr; + FcObjectSet *os = nullptr; + FcFontSet *fs = nullptr; nsresult rv = NS_ERROR_FAILURE; aListOfFonts.Clear(); @@ -505,7 +505,7 @@ gfxFontconfigUtils::GetFontListInternal(nsTArray& aListOfFonts, if (!pat) goto end; - os = FcObjectSetBuild(FC_FAMILY, NULL); + os = FcObjectSetBuild(FC_FAMILY, nullptr); if (!os) goto end; @@ -514,7 +514,7 @@ gfxFontconfigUtils::GetFontListInternal(nsTArray& aListOfFonts, AddLangGroup(pat, aLangGroup); } - fs = FcFontList(NULL, pat, os); + fs = FcFontList(nullptr, pat, os); if (!fs) goto end; @@ -564,8 +564,8 @@ gfxFontconfigUtils::UpdateFontListInternal(bool aForce) // This checks periodically according to fontconfig's configured // interval. FcInitBringUptoDate(); - } else if (!FcConfigUptoDate(NULL)) { // check now with aForce - mLastConfig = NULL; + } else if (!FcConfigUptoDate(nullptr)) { // check now with aForce + mLastConfig = nullptr; FcInitReinitialize(); } @@ -669,11 +669,11 @@ gfxFontconfigUtils::GetStandardFamilyName(const nsAString& aFontName, nsAString& if (!IsExistingFamily(fontname)) return NS_OK; - FcPattern *pat = NULL; - FcObjectSet *os = NULL; - FcFontSet *givenFS = NULL; + FcPattern *pat = nullptr; + FcObjectSet *os = nullptr; + FcFontSet *givenFS = nullptr; nsTArray candidates; - FcFontSet *candidateFS = NULL; + FcFontSet *candidateFS = nullptr; rv = NS_ERROR_FAILURE; pat = FcPatternCreate(); @@ -682,11 +682,11 @@ gfxFontconfigUtils::GetStandardFamilyName(const nsAString& aFontName, nsAString& FcPatternAddString(pat, FC_FAMILY, (FcChar8 *)fontname.get()); - os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, NULL); + os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, nullptr); if (!os) goto end; - givenFS = FcFontList(NULL, pat, os); + givenFS = FcFontList(nullptr, pat, os); if (!givenFS) goto end; @@ -718,7 +718,7 @@ gfxFontconfigUtils::GetStandardFamilyName(const nsAString& aFontName, nsAString& FcPatternDel(pat, FC_FAMILY); FcPatternAddString(pat, FC_FAMILY, (FcChar8 *)candidates[j].get()); - candidateFS = FcFontList(NULL, pat, os); + candidateFS = FcFontList(nullptr, pat, os); if (!candidateFS) goto end; @@ -834,7 +834,8 @@ bool gfxFontconfigUtils::FontsByFullnameEntry::KeyEquals(KeyTypePointer aKey) const { const FcChar8 *key = mKey; - // If mKey is NULL, key comes from the style and family of the first font. + // If mKey is nullptr, key comes from the style and family of the first + // font. nsAutoCString fullname; if (!key) { NS_ASSERTION(mFonts.Length(), "No font in FontsByFullnameEntry!"); @@ -850,7 +851,7 @@ void gfxFontconfigUtils::AddFullnameEntries() { // This FcFontSet is owned by fontconfig - FcFontSet *fontSet = FcConfigGetFonts(NULL, FcSetSystem); + FcFontSet *fontSet = FcConfigGetFonts(nullptr, FcSetSystem); // Record the existing font families for (int f = 0; f < fontSet->nfont; ++f) { @@ -866,8 +867,8 @@ gfxFontconfigUtils::AddFullnameEntries() // will always succeed, and so the entry will always have a // font from which to obtain the key. bool added = entry->AddFont(font); - // The key may be NULL either if this is the first font, or if - // the first font does not have a fullname property, and so + // The key may be nullptr either if this is the first font, or + // if the first font does not have a fullname property, and so // the key is obtained from the font. Set the key in both // cases. The check that AddFont succeeded is required for // the second case. @@ -890,8 +891,8 @@ gfxFontconfigUtils::AddFullnameEntries() if (entry) { entry->AddFont(font); // Either entry->mKey has been set for a previous font or it - // remains NULL to indicate that the key is obtained from the - // first font. + // remains nullptr to indicate that the key is obtained from + // the first font. } } } @@ -1008,7 +1009,7 @@ gfxFontconfigUtils::GetLangSupportEntry(const FcChar8 *aLang, bool aWithFonts) } // This FcFontSet is owned by fontconfig - FcFontSet *fontSet = FcConfigGetFonts(NULL, FcSetSystem); + FcFontSet *fontSet = FcConfigGetFonts(nullptr, FcSetSystem); nsAutoTArray fonts; @@ -1046,7 +1047,7 @@ gfxFontconfigUtils::GetLangSupportEntry(const FcChar8 *aLang, bool aWithFonts) // entry->mSupport needs to be recalculated, but this is an // indication that the set of installed fonts has changed, so // update all caches. - mLastConfig = NULL; // invalidates caches + mLastConfig = nullptr; // invalidates caches UpdateFontListInternal(true); return GetLangSupportEntry(aLang, aWithFonts); } diff --git a/gfx/thebes/gfxFontconfigUtils.h b/gfx/thebes/gfxFontconfigUtils.h index b8af966952d2..c04801774b44 100644 --- a/gfx/thebes/gfxFontconfigUtils.h +++ b/gfx/thebes/gfxFontconfigUtils.h @@ -181,11 +181,11 @@ public: class DepFcStrEntry : public FcStrEntryBase { public: // When constructing a new entry in the hashtable, the key is left - // NULL. The caller of PutEntry() must fill in mKey when NULL. This - // provides a mechanism for the caller of PutEntry() to determine + // nullptr. The caller of PutEntry() must fill in mKey when nullptr. + // This provides a mechanism for the caller of PutEntry() to determine // whether the entry has been initialized. DepFcStrEntry(KeyTypePointer aName) - : mKey(NULL) { } + : mKey(nullptr) { } DepFcStrEntry(const DepFcStrEntry& toCopy) : mKey(toCopy.mKey) { } @@ -253,7 +253,7 @@ protected: class FontsByFullnameEntry : public DepFcStrEntry { public: // When constructing a new entry in the hashtable, the key is left - // NULL. The caller of PutEntry() is must fill in mKey when adding + // nullptr. The caller of PutEntry() is must fill in mKey when adding // the first font if the key is not derived from the family and style. // If the key is derived from family and style, a font must be added. FontsByFullnameEntry(KeyTypePointer aName) diff --git a/gfx/thebes/gfxGDIFont.cpp b/gfx/thebes/gfxGDIFont.cpp index 9a2428285bea..29bfc15ab639 100644 --- a/gfx/thebes/gfxGDIFont.cpp +++ b/gfx/thebes/gfxGDIFont.cpp @@ -40,7 +40,7 @@ gfxGDIFont::gfxGDIFont(GDIFontEntry *aFontEntry, bool aNeedsBold, AntialiasOption anAAOption) : gfxFont(aFontEntry, aFontStyle, anAAOption), - mFont(NULL), + mFont(nullptr), mFontFace(nullptr), mMetrics(nullptr), mSpaceGlyph(0), @@ -543,7 +543,7 @@ gfxGDIFont::GetGlyphWidth(gfxContext *aCtx, uint16_t aGID) AutoSelectFont fs(dc, GetHFONT()); int devWidth; - if (GetCharWidthI(dc, aGID, 1, NULL, &devWidth)) { + if (GetCharWidthI(dc, aGID, 1, nullptr, &devWidth)) { // ensure width is positive, 16.16 fixed-point value width = (devWidth & 0x7fff) << 16; mGlyphWidths.Put(aGID, width); diff --git a/gfx/thebes/gfxGDIFontList.cpp b/gfx/thebes/gfxGDIFontList.cpp index 3d3046aed94f..e6d2e18dd2f2 100644 --- a/gfx/thebes/gfxGDIFontList.cpp +++ b/gfx/thebes/gfxGDIFontList.cpp @@ -243,7 +243,8 @@ GDIFontEntry::CopyFontTable(uint32_t aTableTag, if (font.IsValid()) { uint32_t tableSize = ::GetFontData(dc.GetDC(), - NativeEndian::swapToBigEndian(aTableTag), 0, NULL, 0); + NativeEndian::swapToBigEndian(aTableTag), + 0, nullptr, 0); if (tableSize != GDI_ERROR) { if (aBuffer.SetLength(tableSize)) { ::GetFontData(dc.GetDC(), @@ -343,14 +344,14 @@ GDIFontEntry::TestCharacterMap(uint32_t aCh) } else { // ScriptGetCMap works better than GetGlyphIndicesW // for things like bitmap/vector fonts - SCRIPT_CACHE sc = NULL; + SCRIPT_CACHE sc = nullptr; HRESULT rv = ScriptGetCMap(dc, &sc, str, 1, 0, glyph); if (rv == S_OK) hasGlyph = true; } SelectObject(dc, oldFont); - ReleaseDC(NULL, dc); + ReleaseDC(nullptr, dc); if (hasGlyph) { mCharacterMap->set(aCh); @@ -599,7 +600,7 @@ gfxGDIFontList::GetFontSubstitutes() lenAlias = ArrayLength(aliasName); actualName[0] = 0; lenActual = sizeof(actualName); - rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, NULL, &valueType, + rv = RegEnumValueW(hKey, i, aliasName, &lenAlias, nullptr, &valueType, (LPBYTE)actualName, &lenActual); if (rv != ERROR_SUCCESS || valueType != REG_SZ || lenAlias == 0) { diff --git a/gfx/thebes/gfxGDIFontList.h b/gfx/thebes/gfxGDIFontList.h index 9fa0b03cf489..2cb63ce518b7 100644 --- a/gfx/thebes/gfxGDIFontList.h +++ b/gfx/thebes/gfxGDIFontList.h @@ -17,11 +17,11 @@ class AutoDC // get the global device context, and auto-release it on destructio { public: AutoDC() { - mDC = ::GetDC(NULL); + mDC = ::GetDC(nullptr); } ~AutoDC() { - ::ReleaseDC(NULL, mDC); + ::ReleaseDC(nullptr, mDC); } HDC GetDC() { @@ -44,7 +44,7 @@ public: mDC = aDC; mOldFont = (HFONT)::SelectObject(aDC, mFont); } else { - mOldFont = NULL; + mOldFont = nullptr; } } @@ -66,7 +66,7 @@ public: } bool IsValid() const { - return mFont != NULL; + return mFont != nullptr; } HFONT GetFont() const { diff --git a/gfx/thebes/gfxGDIShaper.cpp b/gfx/thebes/gfxGDIShaper.cpp index 7959822bdf90..9b69ac6c05e0 100644 --- a/gfx/thebes/gfxGDIShaper.cpp +++ b/gfx/thebes/gfxGDIShaper.cpp @@ -52,7 +52,7 @@ gfxGDIShaper::ShapeText(gfxContext *aContext, glyphs, length, INT_MAX, - NULL, + nullptr, partialWidthArray.Elements(), &size); if (!success) { diff --git a/gfx/thebes/gfxGdkNativeRenderer.cpp b/gfx/thebes/gfxGdkNativeRenderer.cpp index 054f746c93b7..48833a37c690 100644 --- a/gfx/thebes/gfxGdkNativeRenderer.cpp +++ b/gfx/thebes/gfxGdkNativeRenderer.cpp @@ -44,7 +44,7 @@ gfxGdkNativeRenderer::DrawWithXlib(gfxXlibSurface* surface, } return DrawWithGDK(drawable, offset.x, offset.y, - numClipRects ? &clipRect : NULL, numClipRects); + numClipRects ? &clipRect : nullptr, numClipRects); } void diff --git a/gfx/thebes/gfxImageSurface.cpp b/gfx/thebes/gfxImageSurface.cpp index d2e45b162176..c402fdc3f05f 100644 --- a/gfx/thebes/gfxImageSurface.cpp +++ b/gfx/thebes/gfxImageSurface.cpp @@ -46,7 +46,7 @@ void gfxImageSurface::MakeInvalid() { mSize = gfxIntSize(-1, -1); - mData = NULL; + mData = nullptr; mStride = 0; } diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index 0698b0554bf5..46ce79eee564 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -60,7 +60,7 @@ gfxMacFont::gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyl // synthetic oblique by skewing via the font matrix bool needsOblique = - (mFontEntry != NULL) && + (mFontEntry != nullptr) && (!mFontEntry->IsItalic() && (mStyle.style & (NS_FONT_STYLE_ITALIC | NS_FONT_STYLE_OBLIQUE))); @@ -369,7 +369,7 @@ gfxMacFont::InitMetricsFromPlatform() { CTFontRef ctFont = ::CTFontCreateWithGraphicsFont(mCGFont, mAdjustedSize, - NULL, NULL); + nullptr, nullptr); if (!ctFont) { return; } diff --git a/gfx/thebes/gfxOS2Fonts.cpp b/gfx/thebes/gfxOS2Fonts.cpp index 39b0f1e00530..d82a4aa3ff7f 100644 --- a/gfx/thebes/gfxOS2Fonts.cpp +++ b/gfx/thebes/gfxOS2Fonts.cpp @@ -356,7 +356,7 @@ cairo_font_face_t *gfxOS2Font::CairoFontFace() // finally find a matching font FcResult fcRes; - FcPattern *fcMatch = FcFontMatch(NULL, fcPattern, &fcRes); + FcPattern *fcMatch = FcFontMatch(nullptr, fcPattern, &fcRes); // Most code that depends on FcFontMatch() assumes it won't fail, // then crashes when it does. For now, at least, substitute the @@ -370,7 +370,7 @@ cairo_font_face_t *gfxOS2Font::CairoFontFace() //#endif // FcPatternAddString() will free the existing FC_FAMILY string FcPatternAddString(fcPattern, FC_FAMILY, (FcChar8*)"SERIF"); - fcMatch = FcFontMatch(NULL, fcPattern, &fcRes); + fcMatch = FcFontMatch(nullptr, fcPattern, &fcRes); //#ifdef DEBUG printf("Attempt to substitute default SERIF font %s\n", fcMatch ? "succeeded" : "failed"); @@ -449,7 +449,7 @@ bool gfxOS2Font::SetupCairoFont(gfxContext *aContext) #endif // gfxPangoFont checks the CTM but Windows doesn't so leave away here, too - // this implicitely ensures that mScaledFont is created if NULL + // this implicitely ensures that mScaledFont is created if nullptr cairo_scaled_font_t *scaledFont = CairoScaledFont(); if (!scaledFont || cairo_scaled_font_status(scaledFont) != CAIRO_STATUS_SUCCESS) { // Don't cairo_set_scaled_font as that would propagate the error to diff --git a/gfx/thebes/gfxOS2Surface.cpp b/gfx/thebes/gfxOS2Surface.cpp index 18098617f88a..0259479db1d3 100644 --- a/gfx/thebes/gfxOS2Surface.cpp +++ b/gfx/thebes/gfxOS2Surface.cpp @@ -149,7 +149,7 @@ gfxOS2Surface::~gfxOS2Surface() } } else { if (mBitmap) { - GpiSetBitmap(mPS, NULL); + GpiSetBitmap(mPS, nullptr); GpiDeleteBitmap(mBitmap); } if (mPS) { diff --git a/gfx/thebes/gfxPangoFonts.cpp b/gfx/thebes/gfxPangoFonts.cpp index 4e9f6fcb259d..851b38f08f7f 100644 --- a/gfx/thebes/gfxPangoFonts.cpp +++ b/gfx/thebes/gfxPangoFonts.cpp @@ -79,7 +79,7 @@ FindFunctionSymbol(const char *name) static bool HasChar(FcPattern *aFont, FcChar32 wc) { - FcCharSet *charset = NULL; + FcCharSet *charset = nullptr; FcPatternGetCharSet(aFont, FC_CHARSET, 0, &charset); return charset && FcCharSetHasChar(charset, wc); @@ -187,7 +187,7 @@ public: mFTFace(nullptr), mFTFaceInitialized(false) { cairo_font_face_reference(mFontFace); - cairo_font_face_set_user_data(mFontFace, &sFontEntryKey, this, NULL); + cairo_font_face_set_user_data(mFontFace, &sFontEntryKey, this, nullptr); mPatterns.AppendElement(); // mPatterns is an nsAutoTArray with 1 space always available, so the // AppendElement always succeeds. @@ -202,7 +202,10 @@ public: ~gfxSystemFcFontEntry() { - cairo_font_face_set_user_data(mFontFace, &sFontEntryKey, NULL, NULL); + cairo_font_face_set_user_data(mFontFace, + &sFontEntryKey, + nullptr, + nullptr); cairo_font_face_destroy(mFontFace); } @@ -448,7 +451,7 @@ public: const uint8_t *aData, FT_Face aFace) : gfxUserFcFontEntry(aProxyEntry), mFontData(aData), mFace(aFace) { - NS_PRECONDITION(aFace != NULL, "aFace is NULL!"); + NS_PRECONDITION(aFace != nullptr, "aFace is NULL!"); InitPattern(); } @@ -536,16 +539,20 @@ gfxDownloadedFcFontEntry::InitPattern() // available only from fontconfig-2.4.2 (December 2006). (CentOS 5.0 has // fontconfig-2.4.1.) if (sQueryFacePtr) { - // The "file" argument cannot be NULL (in fontconfig-2.6.0 at least). - // The dummy file passed here is removed below. + // The "file" argument cannot be nullptr (in fontconfig-2.6.0 at + // least). The dummy file passed here is removed below. // - // When fontconfig scans the system fonts, FcConfigGetBlanks(NULL) is - // passed as the "blanks" argument, which provides that unexpectedly - // blank glyphs are elided. Here, however, we pass NULL for "blanks", - // effectively assuming that, if the font has a blank glyph, then the - // author intends any associated character to be rendered blank. + // When fontconfig scans the system fonts, FcConfigGetBlanks(nullptr) + // is passed as the "blanks" argument, which provides that unexpectedly + // blank glyphs are elided. Here, however, we pass nullptr for + // "blanks", effectively assuming that, if the font has a blank glyph, + // then the author intends any associated character to be rendered + // blank. pattern = - (*sQueryFacePtr)(mFace, gfxFontconfigUtils::ToFcChar8(""), 0, NULL); + (*sQueryFacePtr)(mFace, + gfxFontconfigUtils::ToFcChar8(""), + 0, + nullptr); if (!pattern) // Either OOM, or fontconfig chose to skip this font because it // has "no encoded characters", which I think means "BDF and PCF @@ -561,7 +568,7 @@ gfxDownloadedFcFontEntry::InitPattern() // Do the minimum necessary to construct a pattern for sorting. // FC_CHARSET is vital to determine which characters are supported. - nsAutoRef charset(FcFreeTypeCharSet(mFace, NULL)); + nsAutoRef charset(FcFreeTypeCharSet(mFace, nullptr)); // If there are no characters then assume we don't know how to read // this font. if (!charset || FcCharSetCount(charset) == 0) @@ -708,7 +715,7 @@ public: // GetFontPatternAt sets up mFonts FcPattern *fontPattern = GetFontPatternAt(i); if (!fontPattern) - return NULL; + return nullptr; mFonts[i].mFont = gfxFcFont::GetOrMakeFont(mSortPattern, fontPattern, @@ -769,7 +776,7 @@ private: // considered for mFonts. int mFcFontsTrimmed; // True iff fallback fonts are either stored in mFcFontSet or have been - // trimmed and added to mFonts (so that mFcFontSet is NULL). + // trimmed and added to mFonts (so that mFcFontSet is nullptr). bool mHaveFallbackFonts; // True iff there was a user font set with pending downloads, // so the set may be updated when downloads complete @@ -1056,7 +1063,7 @@ gfxFcFontSet::SortPreferredFonts(bool &aWaitForUserFont) } } - FcPattern *truncateMarker = NULL; + FcPattern *truncateMarker = nullptr; for (uint32_t r = 0; r < requiredLangs.Length(); ++r) { const nsTArray< nsCountedRef >& langFonts = utils->GetFontsForLang(requiredLangs[r].mLang); @@ -1103,16 +1110,16 @@ gfxFcFontSet::SortPreferredFonts(bool &aWaitForUserFont) FcFontSet *sets[1] = { fontSet }; FcResult result; #ifdef SOLARIS - // Get around a crash of FcFontSetSort when FcConfig is NULL + // Get around a crash of FcFontSetSort when FcConfig is nullptr // Solaris's FcFontSetSort needs an FcConfig (bug 474758) fontSet.own(FcFontSetSort(FcConfigGetCurrent(), sets, 1, mSortPattern, - FcFalse, NULL, &result)); + FcFalse, nullptr, &result)); #else - fontSet.own(FcFontSetSort(NULL, sets, 1, mSortPattern, - FcFalse, NULL, &result)); + fontSet.own(FcFontSetSort(nullptr, sets, 1, mSortPattern, + FcFalse, nullptr, &result)); #endif - if (truncateMarker != NULL && fontSet) { + if (truncateMarker != nullptr && fontSet) { nsAutoRef truncatedSet(FcFontSetCreate()); for (int f = 0; f < fontSet->nfont; ++f) { @@ -1143,8 +1150,8 @@ gfxFcFontSet::SortFallbackFonts() // GetFontPatternAt() will trim lazily if and as needed, which will also // remove duplicates of preferred fonts. FcResult result; - return nsReturnRef(FcFontSort(NULL, mSortPattern, - FcFalse, NULL, &result)); + return nsReturnRef(FcFontSort(nullptr, mSortPattern, + FcFalse, nullptr, &result)); } // GetFontAt relies on this setting up all patterns up to |i|. @@ -1159,7 +1166,7 @@ gfxFcFontSet::GetFontPatternAt(uint32_t i) mFcFontSet = SortFallbackFonts(); mHaveFallbackFonts = true; mFcFontsTrimmed = 0; - // Loop to test that mFcFontSet is non-NULL. + // Loop to test that mFcFontSet is non-nullptr. } while (mFcFontsTrimmed < mFcFontSet->nfont) { @@ -1178,7 +1185,7 @@ gfxFcFontSet::GetFontPatternAt(uint32_t i) } if (supportedChars) { - FcCharSet *newChars = NULL; + FcCharSet *newChars = nullptr; FcPatternGetCharSet(font, FC_CHARSET, 0, &newChars); if (newChars) { if (FcCharSetIsSubset(newChars, supportedChars)) @@ -1214,7 +1221,7 @@ static void PrepareSortPattern(FcPattern *aPattern, double aFallbackSize, double aSizeAdjustFactor, bool aIsPrinterFont) { - FcConfigSubstitute(NULL, aPattern, FcMatchPattern); + FcConfigSubstitute(nullptr, aPattern, FcMatchPattern); // This gets cairo_font_options_t for the Screen. We should have // different font options for printing (no hinting) but we are not told @@ -1553,7 +1560,7 @@ gfxPangoFontGroup::FindFontForChar(uint32_t aCh, uint32_t aPrevCh, gfxFcFontSet *fontSet = GetBaseFontSet(); uint32_t nextFont = 0; - FcPattern *basePattern = NULL; + FcPattern *basePattern = nullptr; if (!mStyle.systemFont && mPangoLanguage) { basePattern = fontSet->GetFontPatternAt(0); if (HasChar(basePattern, aCh)) { @@ -1617,12 +1624,15 @@ gfxFcFont::gfxFcFont(cairo_scaled_font_t *aCairoFont, const gfxFontStyle *aFontStyle) : gfxFT2FontBase(aCairoFont, aFontEntry, aFontStyle) { - cairo_scaled_font_set_user_data(mScaledFont, &sGfxFontKey, this, NULL); + cairo_scaled_font_set_user_data(mScaledFont, &sGfxFontKey, this, nullptr); } gfxFcFont::~gfxFcFont() { - cairo_scaled_font_set_user_data(mScaledFont, &sGfxFontKey, NULL, NULL); + cairo_scaled_font_set_user_data(mScaledFont, + &sGfxFontKey, + nullptr, + nullptr); } bool @@ -1669,7 +1679,7 @@ gfxPangoFontGroup::Shutdown() { // Resetting gFTLibrary in case this is wanted again after a // cairo_debug_reset_static_data. - gFTLibrary = NULL; + gFTLibrary = nullptr; } /* static */ gfxFontEntry * @@ -1704,7 +1714,7 @@ gfxPangoFontGroup::NewFontEntry(const gfxProxyFontEntry &aProxyEntry, NS_ConvertUTF16toUTF8 fullname(aFullname); FcPatternAddString(pattern, FC_FULLNAME, gfxFontconfigUtils::ToFcChar8(fullname)); - FcConfigSubstitute(NULL, pattern, FcMatchPattern); + FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcChar8 *name; for (int v = 0; @@ -1739,11 +1749,11 @@ gfxPangoFontGroup::GetFTLibrary() gfxFcFont *font = fontGroup->GetBaseFont(); if (!font) - return NULL; + return nullptr; gfxFT2LockedFace face(font); if (!face.get()) - return NULL; + return nullptr; gFTLibrary = face.get()->glyph->library; } @@ -1759,7 +1769,7 @@ gfxPangoFontGroup::NewFontEntry(const gfxProxyFontEntry &aProxyEntry, // new fontEntry, which will release it when no longer needed. // Using face_index = 0 for the first face in the font, as we have no - // other information. FT_New_Memory_Face checks for a NULL FT_Library. + // other information. FT_New_Memory_Face checks for a nullptr FT_Library. FT_Face face; FT_Error error = FT_New_Memory_Face(GetFTLibrary(), aFontData, aLength, 0, &face); @@ -1803,7 +1813,7 @@ gfxFcFont::GetOrMakeFont(FcPattern *aRequestedPattern, FcPattern *aFontPattern, const gfxFontStyle *aFontStyle) { nsAutoRef renderPattern - (FcFontRenderPrepare(NULL, aRequestedPattern, aFontPattern)); + (FcFontRenderPrepare(nullptr, aRequestedPattern, aFontPattern)); cairo_font_face_t *face = cairo_ft_font_face_create_for_pattern(renderPattern); @@ -2125,14 +2135,14 @@ PangoLanguage * GuessPangoLanguage(nsIAtom *aLanguage) { if (!aLanguage) - return NULL; + return nullptr; // Pango and fontconfig won't understand mozilla's internal langGroups, so // find a real language. nsAutoCString lang; gfxFontconfigUtils::GetSampleLangForGroup(aLanguage, &lang); if (lang.IsEmpty()) - return NULL; + return nullptr; return pango_language_from_string(lang.get()); } diff --git a/gfx/thebes/gfxPangoFonts.h b/gfx/thebes/gfxPangoFonts.h index d57d00022932..0b8073ce6765 100644 --- a/gfx/thebes/gfxPangoFonts.h +++ b/gfx/thebes/gfxPangoFonts.h @@ -52,9 +52,10 @@ public: private: // @param aLang [in] language to use for pref fonts and system default font - // selection, or NULL for the language guessed from the gfxFontStyle. + // selection, or nullptr for the language guessed from the + // gfxFontStyle. // The FontGroup holds a reference to this set. - gfxFcFontSet *GetFontSet(PangoLanguage *aLang = NULL); + gfxFcFontSet *GetFontSet(PangoLanguage *aLang = nullptr); class FontSetByLangEntry { public: @@ -73,11 +74,11 @@ private: nsIAtom *aLanguage); // @param aLang [in] language to use for pref fonts and system font - // resolution, or NULL to guess a language from the gfxFontStyle. - // @param aMatchPattern [out] if non-NULL, will return the pattern used. + // resolution, or nullptr to guess a language from the gfxFontStyle. + // @param aMatchPattern [out] if non-nullptr, will return the pattern used. already_AddRefed MakeFontSet(PangoLanguage *aLang, gfxFloat aSizeAdjustFactor, - nsAutoRef *aMatchPattern = NULL); + nsAutoRef *aMatchPattern = nullptr); gfxFcFontSet *GetBaseFontSet(); gfxFcFont *GetBaseFont(); diff --git a/gfx/thebes/gfxPattern.cpp b/gfx/thebes/gfxPattern.cpp index 14accb96ccd5..7c3e5100e904 100644 --- a/gfx/thebes/gfxPattern.cpp +++ b/gfx/thebes/gfxPattern.cpp @@ -15,27 +15,27 @@ using namespace mozilla::gfx; gfxPattern::gfxPattern(cairo_pattern_t *aPattern) - : mGfxPattern(NULL) + : mGfxPattern(nullptr) { mPattern = cairo_pattern_reference(aPattern); } gfxPattern::gfxPattern(const gfxRGBA& aColor) - : mGfxPattern(NULL) + : mGfxPattern(nullptr) { mPattern = cairo_pattern_create_rgba(aColor.r, aColor.g, aColor.b, aColor.a); } // from another surface gfxPattern::gfxPattern(gfxASurface *surface) - : mGfxPattern(NULL) + : mGfxPattern(nullptr) { mPattern = cairo_pattern_create_for_surface(surface->CairoSurface()); } // linear gfxPattern::gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1) - : mGfxPattern(NULL) + : mGfxPattern(nullptr) { mPattern = cairo_pattern_create_linear(x0, y0, x1, y1); } @@ -43,7 +43,7 @@ gfxPattern::gfxPattern(gfxFloat x0, gfxFloat y0, gfxFloat x1, gfxFloat y1) // radial gfxPattern::gfxPattern(gfxFloat cx0, gfxFloat cy0, gfxFloat radius0, gfxFloat cx1, gfxFloat cy1, gfxFloat radius1) - : mGfxPattern(NULL) + : mGfxPattern(nullptr) { mPattern = cairo_pattern_create_radial(cx0, cy0, radius0, cx1, cy1, radius1); @@ -51,8 +51,8 @@ gfxPattern::gfxPattern(gfxFloat cx0, gfxFloat cy0, gfxFloat radius0, // Azure gfxPattern::gfxPattern(SourceSurface *aSurface, const Matrix &aTransform) - : mPattern(NULL) - , mGfxPattern(NULL) + : mPattern(nullptr) + , mGfxPattern(nullptr) , mSourceSurface(aSurface) , mTransform(aTransform) , mExtend(EXTEND_NONE) @@ -78,7 +78,7 @@ void gfxPattern::AddColorStop(gfxFloat offset, const gfxRGBA& c) { if (mPattern) { - mStops = NULL; + mStops = nullptr; if (gfxPlatform::GetCMSMode() == eCMSMode_All) { gfxRGBA cms; qcms_transform *transform = gfxPlatform::GetCMSRGBTransform(); @@ -177,7 +177,7 @@ gfxPattern::GetPattern(DrawTarget *aTarget, Matrix *aPatternTransform) cairo_pattern_get_matrix(mPattern, &mat); gfxMatrix matrix(*reinterpret_cast(&mat)); - cairo_surface_t *surf = NULL; + cairo_surface_t *surf = nullptr; cairo_pattern_get_surface(mPattern, &surf); if (!mSourceSurface) { @@ -293,10 +293,10 @@ void gfxPattern::SetExtend(GraphicsExtend extend) { if (mPattern) { - mStops = NULL; + mStops = nullptr; if (extend == EXTEND_PAD_EDGE) { if (cairo_pattern_get_type(mPattern) == CAIRO_PATTERN_TYPE_SURFACE) { - cairo_surface_t *surf = NULL; + cairo_surface_t *surf = nullptr; cairo_pattern_get_surface (mPattern, &surf); if (surf) { @@ -335,7 +335,7 @@ gfxPattern::IsOpaque() switch (cairo_pattern_get_type(mPattern)) { case CAIRO_PATTERN_TYPE_SURFACE: { - cairo_surface_t *surf = NULL; + cairo_surface_t *surf = nullptr; cairo_pattern_get_surface(mPattern, &surf); if (cairo_surface_get_content(surf) == CAIRO_CONTENT_COLOR) { diff --git a/gfx/thebes/gfxPattern.h b/gfx/thebes/gfxPattern.h index 736f4751f2f1..5996e1bd81b6 100644 --- a/gfx/thebes/gfxPattern.h +++ b/gfx/thebes/gfxPattern.h @@ -45,7 +45,7 @@ public: /* Get an Azure Pattern for the current Cairo pattern. aPattern transform * specifies the transform that was set on the DrawTarget when the pattern - * was set. When this is NULL it is assumed the transform is identical + * was set. When this is nullptr it is assumed the transform is identical * to the current transform. */ mozilla::gfx::Pattern *GetPattern(mozilla::gfx::DrawTarget *aTarget, diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 3224e8221427..b98e30777044 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -556,7 +556,7 @@ RefPtr gfxPlatform::CreateDrawTargetForSurface(gfxASurface *aSurface, const IntSize& aSize) { RefPtr drawTarget = Factory::CreateDrawTargetForCairoSurface(aSurface->CairoSurface(), aSize); - aSurface->SetData(&kDrawTarget, drawTarget, NULL); + aSurface->SetData(&kDrawTarget, drawTarget, nullptr); return drawTarget; } @@ -604,13 +604,13 @@ void SourceSnapshotDetached(cairo_surface_t *nullSurf) gfxImageSurface* origSurf = static_cast(cairo_surface_get_user_data(nullSurf, &kSourceSurface)); - origSurf->SetData(&kSourceSurface, NULL, NULL); + origSurf->SetData(&kSourceSurface, nullptr, nullptr); } #else void SourceSnapshotDetached(void *nullSurf) { gfxImageSurface* origSurf = static_cast(nullSurf); - origSurf->SetData(&kSourceSurface, NULL, NULL); + origSurf->SetData(&kSourceSurface, nullptr, nullptr); } #endif @@ -738,7 +738,7 @@ gfxPlatform::GetSourceSurfaceForSurface(DrawTarget *aTarget, gfxASurface *aSurfa cairo_surface_set_user_data(nullSurf, &kSourceSurface, imgSurface, - NULL); + nullptr); cairo_surface_attach_snapshot(imgSurface->CairoSurface(), nullSurf, SourceSnapshotDetached); cairo_surface_destroy(nullSurf); #else @@ -849,7 +849,7 @@ gfxPlatform::CreateDrawTargetForBackend(BackendType aBackend, const IntSize& aSi nsRefPtr surf = CreateOffscreenSurface(ThebesIntSize(aSize), ContentForFormat(aFormat)); if (!surf || surf->CairoStatus()) { - return NULL; + return nullptr; } return CreateDrawTargetForSurface(surf, aSize); diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index a44e0033dee4..b3a4c4d0a46a 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -493,7 +493,7 @@ public: /** * Convert a pixel using a cms transform in an endian-aware manner. * - * Sets 'out' to 'in' if transform is NULL. + * Sets 'out' to 'in' if transform is nullptr. */ static void TransformPixel(const gfxRGBA& in, gfxRGBA& out, qcms_transform *transform); diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index d2e3db2223f6..09da1f803c18 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -59,11 +59,11 @@ gfxFontconfigUtils *gfxPlatformGtk::sFontconfigUtils = nullptr; #ifndef MOZ_PANGO typedef nsDataHashtable > FontTable; typedef nsDataHashtable > > PrefFontTable; -static FontTable *gPlatformFonts = NULL; -static FontTable *gPlatformFontAliases = NULL; -static PrefFontTable *gPrefFonts = NULL; -static gfxSparseBitSet *gCodepointsWithNoFonts = NULL; -static FT_Library gPlatformFTLibrary = NULL; +static FontTable *gPlatformFonts = nullptr; +static FontTable *gPlatformFontAliases = nullptr; +static PrefFontTable *gPrefFonts = nullptr; +static gfxSparseBitSet *gCodepointsWithNoFonts = nullptr; +static FT_Library gPlatformFTLibrary = nullptr; #endif static cairo_user_data_key_t cairo_gdk_drawable_key; @@ -105,13 +105,13 @@ gfxPlatformGtk::~gfxPlatformGtk() gfxPangoFontGroup::Shutdown(); #else delete gPlatformFonts; - gPlatformFonts = NULL; + gPlatformFonts = nullptr; delete gPlatformFontAliases; - gPlatformFontAliases = NULL; + gPlatformFontAliases = nullptr; delete gPrefFonts; - gPrefFonts = NULL; + gPrefFonts = nullptr; delete gCodepointsWithNoFonts; - gCodepointsWithNoFonts = NULL; + gCodepointsWithNoFonts = nullptr; #ifdef NS_FREE_PERMANENT_DATA // do cairo cleanup *before* closing down the FTLibrary, @@ -120,7 +120,7 @@ gfxPlatformGtk::~gfxPlatformGtk() cairo_debug_reset_static_data(); FT_Done_FreeType(gPlatformFTLibrary); - gPlatformFTLibrary = NULL; + gPlatformFTLibrary = nullptr; #endif #endif @@ -283,15 +283,15 @@ gfxPlatformGtk::GetFontList(nsIAtom *aLangGroup, nsresult gfxPlatformGtk::UpdateFontList() { - FcPattern *pat = NULL; - FcObjectSet *os = NULL; - FcFontSet *fs = NULL; + FcPattern *pat = nullptr; + FcObjectSet *os = nullptr; + FcFontSet *fs = nullptr; int32_t result = -1; pat = FcPatternCreate(); - os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, FC_WEIGHT, FC_SLANT, FC_WIDTH, NULL); + os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, FC_WEIGHT, FC_SLANT, FC_WIDTH, nullptr); - fs = FcFontList(NULL, pat, os); + fs = FcFontList(nullptr, pat, os); for (int i = 0; i < fs->nfont; i++) { @@ -376,8 +376,8 @@ gfxPlatformGtk::ResolveFontName(const nsAString& aFontName, FcPattern *npat = FcPatternCreate(); FcPatternAddString(npat, FC_FAMILY, (FcChar8*)utf8Name.get()); - FcObjectSet *nos = FcObjectSetBuild(FC_FAMILY, NULL); - FcFontSet *nfs = FcFontList(NULL, npat, nos); + FcObjectSet *nos = FcObjectSetBuild(FC_FAMILY, nullptr); + FcFontSet *nfs = FcFontList(nullptr, npat, nos); for (int k = 0; k < nfs->nfont; k++) { FcChar8 *str; @@ -401,15 +401,15 @@ gfxPlatformGtk::ResolveFontName(const nsAString& aFontName, npat = FcPatternCreate(); FcPatternAddString(npat, FC_FAMILY, (FcChar8*)utf8Name.get()); FcPatternDel(npat, FC_LANG); - FcConfigSubstitute(NULL, npat, FcMatchPattern); + FcConfigSubstitute(nullptr, npat, FcMatchPattern); FcDefaultSubstitute(npat); - nos = FcObjectSetBuild(FC_FAMILY, NULL); - nfs = FcFontList(NULL, npat, nos); + nos = FcObjectSetBuild(FC_FAMILY, nullptr); + nfs = FcFontList(nullptr, npat, nos); FcResult fresult; - FcPattern *match = FcFontMatch(NULL, npat, &fresult); + FcPattern *match = FcFontMatch(nullptr, npat, &fresult); if (match) FcFontSetAdd(nfs, match); @@ -521,9 +521,9 @@ gfxPlatformGtk::GetPlatformCMSOutputProfile() Display *dpy = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); // In xpcshell tests, we never initialize X and hence don't have a Display. // In this case, there's no output colour management to be done, so we just - // return NULL. + // return nullptr. if (!dpy) { - return NULL; + return nullptr; } Window root = gdk_x11_get_default_root_xwindow(); @@ -541,7 +541,7 @@ gfxPlatformGtk::GetPlatformCMSOutputProfile() False, AnyPropertyType, &retAtom, &retFormat, &retLength, &retAfter, &retProperty)) { - qcms_profile* profile = NULL; + qcms_profile* profile = nullptr; if (retLength > 0) profile = qcms_profile_from_memory(retProperty, retLength); @@ -739,7 +739,7 @@ GdkDrawable * gfxPlatformGtk::GetGdkDrawable(gfxASurface *target) { if (target->CairoStatus()) - return NULL; + return nullptr; GdkDrawable *result; @@ -750,7 +750,7 @@ gfxPlatformGtk::GetGdkDrawable(gfxASurface *target) #ifdef MOZ_X11 if (target->GetType() != gfxASurface::SurfaceTypeXlib) - return NULL; + return nullptr; gfxXlibSurface *xs = static_cast(target); @@ -762,7 +762,7 @@ gfxPlatformGtk::GetGdkDrawable(gfxASurface *target) } #endif - return NULL; + return nullptr; } #endif @@ -777,6 +777,6 @@ gfxPlatformGtk::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont) return Factory::CreateScaledFontForNativeFont(nativeFont, aFont->GetAdjustedSize()); } - return NULL; + return nullptr; } diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index b4db5bad8249..926cb219e7c4 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -42,7 +42,7 @@ DisableFontActivation() { // get the main bundle identifier CFBundleRef mainBundle = ::CFBundleGetMainBundle(); - CFStringRef mainBundleID = NULL; + CFStringRef mainBundleID = nullptr; if (mainBundle) { mainBundleID = ::CFBundleGetIdentifier(mainBundle); @@ -470,7 +470,7 @@ gfxPlatformMac::GetPlatformCMSOutputProfile() return nullptr; // get the size of location - err = NCMGetProfileLocation(cmProfile, NULL, &locationSize); + err = NCMGetProfileLocation(cmProfile, nullptr, &locationSize); if (err != noErr) return nullptr; diff --git a/gfx/thebes/gfxQtNativeRenderer.cpp b/gfx/thebes/gfxQtNativeRenderer.cpp index c08f388be0e1..bfc32abcd8a0 100644 --- a/gfx/thebes/gfxQtNativeRenderer.cpp +++ b/gfx/thebes/gfxQtNativeRenderer.cpp @@ -38,7 +38,7 @@ gfxQtNativeRenderer::Draw(gfxContext* ctx, nsIntSize size, tempCtx->Paint(); } - nsresult rv = DrawWithXlib(xsurf.get(), nsIntPoint(0, 0), NULL, 0); + nsresult rv = DrawWithXlib(xsurf.get(), nsIntPoint(0, 0), nullptr, 0); if (NS_FAILED(rv)) return rv; diff --git a/gfx/thebes/gfxQtPlatform.cpp b/gfx/thebes/gfxQtPlatform.cpp index bb9941f03a93..331f8e09ca4d 100644 --- a/gfx/thebes/gfxQtPlatform.cpp +++ b/gfx/thebes/gfxQtPlatform.cpp @@ -78,11 +78,11 @@ static gfxImageFormat sOffscreenFormat = gfxASurface::ImageFormatRGB24; #ifndef MOZ_PANGO typedef nsDataHashtable > FontTable; typedef nsDataHashtable > > PrefFontTable; -static FontTable *gPlatformFonts = NULL; -static FontTable *gPlatformFontAliases = NULL; -static PrefFontTable *gPrefFonts = NULL; -static gfxSparseBitSet *gCodepointsWithNoFonts = NULL; -static FT_Library gPlatformFTLibrary = NULL; +static FontTable *gPlatformFonts = nullptr; +static FontTable *gPlatformFontAliases = nullptr; +static PrefFontTable *gPrefFonts = nullptr; +static gfxSparseBitSet *gCodepointsWithNoFonts = nullptr; +static FT_Library gPlatformFTLibrary = nullptr; #endif gfxQtPlatform::gfxQtPlatform() @@ -152,18 +152,18 @@ gfxQtPlatform::~gfxQtPlatform() gfxPangoFontGroup::Shutdown(); #else delete gPlatformFonts; - gPlatformFonts = NULL; + gPlatformFonts = nullptr; delete gPlatformFontAliases; - gPlatformFontAliases = NULL; + gPlatformFontAliases = nullptr; delete gPrefFonts; - gPrefFonts = NULL; + gPrefFonts = nullptr; delete gCodepointsWithNoFonts; - gCodepointsWithNoFonts = NULL; + gCodepointsWithNoFonts = nullptr; cairo_debug_reset_static_data(); FT_Done_FreeType(gPlatformFTLibrary); - gPlatformFTLibrary = NULL; + gPlatformFTLibrary = nullptr; #endif #if 0 @@ -260,14 +260,14 @@ nsresult gfxQtPlatform::UpdateFontList() { #ifndef MOZ_PANGO - FcPattern *pat = NULL; - FcObjectSet *os = NULL; - FcFontSet *fs = NULL; + FcPattern *pat = nullptr; + FcObjectSet *os = nullptr; + FcFontSet *fs = nullptr; pat = FcPatternCreate(); - os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, FC_WEIGHT, FC_SLANT, FC_WIDTH, NULL); + os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_INDEX, FC_WEIGHT, FC_SLANT, FC_WIDTH, nullptr); - fs = FcFontList(NULL, pat, os); + fs = FcFontList(nullptr, pat, os); for (int i = 0; i < fs->nfont; i++) { @@ -383,8 +383,8 @@ gfxQtPlatform::ResolveFontName(const nsAString& aFontName, FcPattern *npat = FcPatternCreate(); FcPatternAddString(npat, FC_FAMILY, (FcChar8*)utf8Name.get()); - FcObjectSet *nos = FcObjectSetBuild(FC_FAMILY, NULL); - FcFontSet *nfs = FcFontList(NULL, npat, nos); + FcObjectSet *nos = FcObjectSetBuild(FC_FAMILY, nullptr); + FcFontSet *nfs = FcFontList(nullptr, npat, nos); for (int k = 0; k < nfs->nfont; k++) { FcChar8 *str; @@ -407,15 +407,15 @@ gfxQtPlatform::ResolveFontName(const nsAString& aFontName, npat = FcPatternCreate(); FcPatternAddString(npat, FC_FAMILY, (FcChar8*)utf8Name.get()); FcPatternDel(npat, FC_LANG); - FcConfigSubstitute(NULL, npat, FcMatchPattern); + FcConfigSubstitute(nullptr, npat, FcMatchPattern); FcDefaultSubstitute(npat); - nos = FcObjectSetBuild(FC_FAMILY, NULL); - nfs = FcFontList(NULL, npat, nos); + nos = FcObjectSetBuild(FC_FAMILY, nullptr); + nfs = FcFontList(nullptr, npat, nos); FcResult fresult; - FcPattern *match = FcFontMatch(NULL, npat, &fresult); + FcPattern *match = FcFontMatch(nullptr, npat, &fresult); if (match) FcFontSetAdd(nfs, match); diff --git a/gfx/thebes/gfxQuartzImageSurface.cpp b/gfx/thebes/gfxQuartzImageSurface.cpp index 51bb0218e932..791c00bffe42 100644 --- a/gfx/thebes/gfxQuartzImageSurface.cpp +++ b/gfx/thebes/gfxQuartzImageSurface.cpp @@ -10,7 +10,7 @@ gfxQuartzImageSurface::gfxQuartzImageSurface(gfxImageSurface *imageSurface) { - if (imageSurface->CairoSurface() == NULL) + if (imageSurface->CairoSurface() == nullptr) return; cairo_surface_t *surf = cairo_quartz_image_surface_create (imageSurface->CairoSurface()); diff --git a/gfx/thebes/gfxQuartzSurface.cpp b/gfx/thebes/gfxQuartzSurface.cpp index f50fa0c1e9bf..7af4dd01b3ee 100644 --- a/gfx/thebes/gfxQuartzSurface.cpp +++ b/gfx/thebes/gfxQuartzSurface.cpp @@ -16,7 +16,7 @@ gfxQuartzSurface::MakeInvalid() gfxQuartzSurface::gfxQuartzSurface(const gfxSize& desiredSize, gfxImageFormat format, bool aForPrinting) - : mCGContext(NULL), mSize(desiredSize), mForPrinting(aForPrinting) + : mCGContext(nullptr), mSize(desiredSize), mForPrinting(aForPrinting) { gfxIntSize size((unsigned int) floor(desiredSize.width), (unsigned int) floor(desiredSize.height)); diff --git a/gfx/thebes/gfxUniscribeShaper.cpp b/gfx/thebes/gfxUniscribeShaper.cpp index 65d066823e88..20d7d5723c5f 100644 --- a/gfx/thebes/gfxUniscribeShaper.cpp +++ b/gfx/thebes/gfxUniscribeShaper.cpp @@ -184,7 +184,7 @@ public: rv = ScriptPlace(placeDC, mShaper->ScriptCache(), mGlyphs.Elements(), mNumGlyphs, mAttr.Elements(), &sa, - mAdvances.Elements(), mOffsets.Elements(), NULL); + mAdvances.Elements(), mOffsets.Elements(), nullptr); if (rv == E_PENDING) { SelectFont(); @@ -208,7 +208,7 @@ public: memset(sfp, 0, sizeof(SCRIPT_FONTPROPERTIES)); sfp->cBytes = sizeof(SCRIPT_FONTPROPERTIES); - rv = ScriptGetFontProperties(NULL, mShaper->ScriptCache(), + rv = ScriptGetFontProperties(nullptr, mShaper->ScriptCache(), sfp); if (rv == E_PENDING) { SelectFont(); diff --git a/gfx/thebes/gfxUniscribeShaper.h b/gfx/thebes/gfxUniscribeShaper.h index c90518b6f6cd..ccf28c367521 100644 --- a/gfx/thebes/gfxUniscribeShaper.h +++ b/gfx/thebes/gfxUniscribeShaper.h @@ -19,7 +19,7 @@ class gfxUniscribeShaper : public gfxFontShaper public: gfxUniscribeShaper(gfxGDIFont *aFont) : gfxFontShaper(aFont) - , mScriptCache(NULL) + , mScriptCache(nullptr) { MOZ_COUNT_CTOR(gfxUniscribeShaper); } diff --git a/gfx/thebes/gfxUserFontSet.cpp b/gfx/thebes/gfxUserFontSet.cpp index e6674677fc5b..8bea36a7bcbe 100644 --- a/gfx/thebes/gfxUserFontSet.cpp +++ b/gfx/thebes/gfxUserFontSet.cpp @@ -297,7 +297,7 @@ gfxUserFontSet::OTSMessage(void *aUserData, const char *format, ...) #endif // Call the OTS library to sanitize an sfnt before attempting to use it. -// Returns a newly-allocated block, or NULL in case of fatal errors. +// Returns a newly-allocated block, or nullptr in case of fatal errors. const uint8_t* gfxUserFontSet::SanitizeOpenTypeData(gfxMixedFontFamily *aFamily, gfxProxyFontEntry *aProxy, diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index f1b7d2f27021..7633765fc663 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -862,5 +862,5 @@ gfxUtils::CopyAsDataURL(DrawTarget* aDT) bool gfxUtils::sDumpPaintList = getenv("MOZ_DUMP_PAINT_LIST") != 0; bool gfxUtils::sDumpPainting = getenv("MOZ_DUMP_PAINT") != 0; bool gfxUtils::sDumpPaintingToFile = getenv("MOZ_DUMP_PAINT_TO_FILE") != 0; -FILE *gfxUtils::sDumpPaintFile = NULL; +FILE *gfxUtils::sDumpPaintFile = nullptr; #endif diff --git a/gfx/thebes/gfxWindowsNativeDrawing.cpp b/gfx/thebes/gfxWindowsNativeDrawing.cpp index 199e19322468..5c62a0a218e1 100644 --- a/gfx/thebes/gfxWindowsNativeDrawing.cpp +++ b/gfx/thebes/gfxWindowsNativeDrawing.cpp @@ -146,7 +146,7 @@ gfxWindowsNativeDrawing::BeginNativeDrawing() SetViewportOrgEx(mDC, mOrigViewportOrigin.x + (int)mDeviceOffset.x, mOrigViewportOrigin.y + (int)mDeviceOffset.y, - NULL); + nullptr); return mDC; } else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_BLACK || @@ -227,7 +227,7 @@ gfxWindowsNativeDrawing::EndNativeDrawing() { if (mRenderState == RENDER_STATE_NATIVE_DRAWING) { // we drew directly to the HDC in the context; undo our changes - SetViewportOrgEx(mDC, mOrigViewportOrigin.x, mOrigViewportOrigin.y, NULL); + SetViewportOrgEx(mDC, mOrigViewportOrigin.x, mOrigViewportOrigin.y, nullptr); if (mTransformType != TRANSLATION_ONLY) SetWorldTransform(mDC, &mOldWorldTransform); diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 3be242a3483d..ffe48f4e56f7 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -362,9 +362,9 @@ gfxWindowsPlatform::gfxWindowsPlatform() /* * Initialize COM */ - CoInitialize(NULL); + CoInitialize(nullptr); - mScreenDC = GetDC(NULL); + mScreenDC = GetDC(nullptr); #ifdef CAIRO_HAS_D2D_SURFACE NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(D2DCache)); @@ -384,7 +384,7 @@ gfxWindowsPlatform::~gfxWindowsPlatform() { NS_UnregisterMemoryMultiReporter(mGPUAdapterMultiReporter); - ::ReleaseDC(NULL, mScreenDC); + ::ReleaseDC(nullptr, mScreenDC); // not calling FT_Done_FreeType because cairo may still hold references to // these FT_Faces. See bug 458169. #ifdef CAIRO_HAS_D2D_SURFACE @@ -521,7 +521,7 @@ gfxWindowsPlatform::CreateDevice(nsRefPtr &adapter1, nsRefPtr device; HRESULT hr = - createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, NULL, + createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr, D3D10_CREATE_DEVICE_BGRA_SUPPORT | D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS, static_cast(kSupportedFeatureLevels[featureLevelIndex]), @@ -752,7 +752,7 @@ gfxWindowsPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget) if (aTarget->GetType() == BACKEND_DIRECT2D) { if (!GetD2DDevice()) { // We no longer have a D2D device, can't do this. - return NULL; + return nullptr; } RefPtr texture = @@ -768,7 +768,7 @@ gfxWindowsPlatform::GetThebesSurfaceForDrawTarget(DrawTarget *aTarget) new gfxD2DSurface(texture, ContentForFormat(aTarget->GetFormat())); // shouldn't this hold a reference? - surf->SetData(&kDrawTarget, aTarget, NULL); + surf->SetData(&kDrawTarget, aTarget, nullptr); return surf.forget(); } #endif @@ -1172,7 +1172,7 @@ gfxWindowsPlatform::GetDLLVersion(const PRUnichar *aDLLPath, nsAString& aVersion DWORD versInfoSize, vers[4] = {0}; // version info not available case aVersion.Assign(NS_LITERAL_STRING("0.0.0.0")); - versInfoSize = GetFileVersionInfoSizeW(aDLLPath, NULL); + versInfoSize = GetFileVersionInfoSizeW(aDLLPath, nullptr); nsAutoTArray versionInfo; if (versInfoSize == 0 || @@ -1231,7 +1231,8 @@ gfxWindowsPlatform::GetCleartypeParams(nsTArray& aParams // enumerate over subkeys for (i = 0, rv = ERROR_SUCCESS; rv != ERROR_NO_MORE_ITEMS; i++) { size = ArrayLength(displayName); - rv = RegEnumKeyExW(hKey, i, displayName, &size, NULL, NULL, NULL, NULL); + rv = RegEnumKeyExW(hKey, i, displayName, &size, + nullptr, nullptr, nullptr, nullptr); if (rv != ERROR_SUCCESS) { continue; } @@ -1251,7 +1252,7 @@ gfxWindowsPlatform::GetCleartypeParams(nsTArray& aParams if (subrv == ERROR_SUCCESS) { size = sizeof(value); - subrv = RegQueryValueExW(subKey, L"GammaLevel", NULL, &type, + subrv = RegQueryValueExW(subKey, L"GammaLevel", nullptr, &type, (LPBYTE)&value, &size); if (subrv == ERROR_SUCCESS && type == REG_DWORD) { foundData = true; @@ -1259,7 +1260,7 @@ gfxWindowsPlatform::GetCleartypeParams(nsTArray& aParams } size = sizeof(value); - subrv = RegQueryValueExW(subKey, L"PixelStructure", NULL, &type, + subrv = RegQueryValueExW(subKey, L"PixelStructure", nullptr, &type, (LPBYTE)&value, &size); if (subrv == ERROR_SUCCESS && type == REG_DWORD) { foundData = true; @@ -1275,7 +1276,7 @@ gfxWindowsPlatform::GetCleartypeParams(nsTArray& aParams if (subrv == ERROR_SUCCESS) { size = sizeof(value); - subrv = RegQueryValueExW(subKey, L"ClearTypeLevel", NULL, &type, + subrv = RegQueryValueExW(subKey, L"ClearTypeLevel", nullptr, &type, (LPBYTE)&value, &size); if (subrv == ERROR_SUCCESS && type == REG_DWORD) { foundData = true; @@ -1284,7 +1285,7 @@ gfxWindowsPlatform::GetCleartypeParams(nsTArray& aParams size = sizeof(value); subrv = RegQueryValueExW(subKey, L"EnhancedContrastLevel", - NULL, &type, (LPBYTE)&value, &size); + nullptr, &type, (LPBYTE)&value, &size); if (subrv == ERROR_SUCCESS && type == REG_DWORD) { foundData = true; ctinfo.enhancedContrast = value; @@ -1478,7 +1479,7 @@ gfxWindowsPlatform::GetD3D11Device() return nullptr; } - HRESULT hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, + HRESULT hr = d3d11CreateDevice(adapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr, D3D11_CREATE_DEVICE_BGRA_SUPPORT, featureLevels.Elements(), featureLevels.Length(), D3D11_SDK_VERSION, byRef(mD3D11Device), nullptr, nullptr); diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 8443d2478a25..3d8ab0e28347 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -52,7 +52,7 @@ class nsIMemoryMultiReporter; // used by both GDI and Uniscribe font shapers struct DCFromContext { DCFromContext(gfxContext *aContext) { - dc = NULL; + dc = nullptr; nsRefPtr aSurface = aContext->CurrentSurface(); NS_ASSERTION(aSurface, "DCFromContext: null surface"); if (aSurface && @@ -67,7 +67,7 @@ struct DCFromContext { cairo_win32_scaled_font_select_font(scaled, dc); } if (!dc) { - dc = GetDC(NULL); + dc = GetDC(nullptr); SetGraphicsMode(dc, GM_ADVANCED); needsRelease = true; } @@ -75,7 +75,7 @@ struct DCFromContext { ~DCFromContext() { if (needsRelease) { - ReleaseDC(NULL, dc); + ReleaseDC(nullptr, dc); } else { RestoreDC(dc, -1); } diff --git a/gfx/thebes/gfxWindowsSurface.cpp b/gfx/thebes/gfxWindowsSurface.cpp index 43942d4a0889..0fe3ee969f88 100644 --- a/gfx/thebes/gfxWindowsSurface.cpp +++ b/gfx/thebes/gfxWindowsSurface.cpp @@ -224,7 +224,7 @@ gfxWindowsSurface::BeginPrinting(const nsAString& aTitle, docinfo.cbSize = sizeof(docinfo); docinfo.lpszDocName = titleStr.Length() > 0 ? titleStr.get() : L"Mozilla Document"; docinfo.lpszOutput = docName.Length() > 0 ? docName.get() : nullptr; - docinfo.lpszDatatype = NULL; + docinfo.lpszDatatype = nullptr; docinfo.fwType = 0; ::StartDocW(mDC, &docinfo); diff --git a/gfx/thebes/gfxWindowsSurface.h b/gfx/thebes/gfxWindowsSurface.h index cb783b765ef5..1e8cc92627f9 100644 --- a/gfx/thebes/gfxWindowsSurface.h +++ b/gfx/thebes/gfxWindowsSurface.h @@ -31,7 +31,7 @@ public: gfxWindowsSurface(const gfxIntSize& size, gfxImageFormat imageFormat = ImageFormatRGB24); - // Create a DDB surface; dc may be NULL to use the screen DC + // Create a DDB surface; dc may be nullptr to use the screen DC gfxWindowsSurface(HDC dc, const gfxIntSize& size, gfxImageFormat imageFormat = ImageFormatRGB24); diff --git a/gfx/thebes/gfxXlibNativeRenderer.cpp b/gfx/thebes/gfxXlibNativeRenderer.cpp index 84a566d2f89e..d71b435e068a 100644 --- a/gfx/thebes/gfxXlibNativeRenderer.cpp +++ b/gfx/thebes/gfxXlibNativeRenderer.cpp @@ -320,8 +320,8 @@ CreateTempXlibSurface (gfxASurface *destination, nsIntSize size, // Analyse the pixel formats either to check whether we can // doCopyBackground or to see if we can find a better visual for // opaque drawing. - Visual *target_visual = NULL; - XRenderPictFormat *target_format = NULL; + Visual *target_visual = nullptr; + XRenderPictFormat *target_format = nullptr; switch (target_type) { case CAIRO_SURFACE_TYPE_XLIB: target_visual = cairo_xlib_surface_get_visual (target); @@ -419,7 +419,7 @@ gfxXlibNativeRenderer::DrawOntoTempSurface(gfxXlibSurface *tempXlibSurface, tempXlibSurface->Flush(); /* no clipping is needed because the callback can't draw outside the native surface anyway */ - nsresult rv = DrawWithXlib(tempXlibSurface, offset, NULL, 0); + nsresult rv = DrawWithXlib(tempXlibSurface, offset, nullptr, 0); tempXlibSurface->MarkDirty(); return NS_SUCCEEDED(rv); } @@ -445,7 +445,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size, DrawOutput* result) { if (result) { - result->mSurface = NULL; + result->mSurface = nullptr; result->mUniformAlpha = false; result->mUniformColor = false; } @@ -520,7 +520,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size, if (drawingRect.Size() != size || method == eCopyBackground) { // Only drawing a portion, or copying background, // so won't return a result. - result = NULL; + result = nullptr; } nsRefPtr tmpCtx; diff --git a/gfx/thebes/gfxXlibSurface.cpp b/gfx/thebes/gfxXlibSurface.cpp index 712d76d71c6a..6e0f1133e6dd 100644 --- a/gfx/thebes/gfxXlibSurface.cpp +++ b/gfx/thebes/gfxXlibSurface.cpp @@ -458,7 +458,7 @@ gfxXlibSurface::FindVisual(Screen *screen, gfxImageFormat format) case ImageFormatA8: case ImageFormatA1: default: - return NULL; + return nullptr; } for (int d = 0; d < screen->ndepths; d++) { @@ -477,7 +477,7 @@ gfxXlibSurface::FindVisual(Screen *screen, gfxImageFormat format) } } - return NULL; + return nullptr; } /* static */ @@ -495,7 +495,7 @@ gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format) // and find xrender format by visual Visual *visual = FindVisual(DefaultScreenOfDisplay(dpy), format); if (!visual) - return NULL; + return nullptr; return XRenderFindVisualFormat(dpy, visual); } case ImageFormatA8: @@ -506,7 +506,7 @@ gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format) break; } - return (XRenderPictFormat*)NULL; + return nullptr; } Screen* diff --git a/gfx/thebes/nsSurfaceTexture.cpp b/gfx/thebes/nsSurfaceTexture.cpp index a263f9752e34..f48cdab4696d 100644 --- a/gfx/thebes/nsSurfaceTexture.cpp +++ b/gfx/thebes/nsSurfaceTexture.cpp @@ -52,11 +52,11 @@ public: jobject CreateSurfaceTexture(GLuint aTexture) { if (!EnsureInitialized()) - return NULL; + return nullptr; JNIEnv* env = GetJNIForThread(); if (!env) - return NULL; + return nullptr; AutoLocalJNIFrame jniFrame(env); @@ -93,7 +93,7 @@ public: jfloatArray jarray = env->NewFloatArray(16); env->CallVoidMethod(aSurfaceTexture, jSurfaceTexture_getTransformMatrix, jarray); - jfloat* array = env->GetFloatArrayElements(jarray, NULL); + jfloat* array = env->GetFloatArrayElements(jarray, nullptr); aMatrix._11 = array[0]; aMatrix._12 = array[1]; @@ -136,13 +136,13 @@ nsSurfaceTexture::Create(GLuint aTexture) // Right now we only support creating this on the main thread because // of the JNIEnv assumptions in JNIHelper and elsewhere if (!NS_IsMainThread()) - return NULL; + return nullptr; nsSurfaceTexture* st = new nsSurfaceTexture(); if (!st->Init(aTexture)) { LOG("Failed to initialize nsSurfaceTexture"); delete st; - st = NULL; + st = nullptr; } return st; @@ -155,7 +155,7 @@ nsSurfaceTexture::Find(int id) it = sInstances.find(id); if (it == sInstances.end()) - return NULL; + return nullptr; return it->second; } @@ -189,7 +189,7 @@ nsSurfaceTexture::Init(GLuint aTexture) } nsSurfaceTexture::nsSurfaceTexture() - : mSurfaceTexture(NULL), mNativeWindow(NULL) + : mSurfaceTexture(nullptr), mNativeWindow(nullptr) { } @@ -197,11 +197,11 @@ nsSurfaceTexture::~nsSurfaceTexture() { sInstances.erase(mID); - mFrameAvailableCallback = NULL; + mFrameAvailableCallback = nullptr; if (mNativeWindow) { AndroidBridge::Bridge()->ReleaseNativeWindowForSurfaceTexture(mSurfaceTexture); - mNativeWindow = NULL; + mNativeWindow = nullptr; } JNIEnv* env = GetJNIForThread(); @@ -212,7 +212,7 @@ nsSurfaceTexture::~nsSurfaceTexture() AndroidBridge::Bridge()->UnregisterSurfaceTextureFrameListener(mSurfaceTexture); env->DeleteGlobalRef(mSurfaceTexture); - mSurfaceTexture = NULL; + mSurfaceTexture = nullptr; } } From d93bd417977ac68f7f23277b9a456de23c064b18 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 31 Jul 2013 11:44:43 -0400 Subject: [PATCH 11/40] Bug 784739 - Switch from NULL to nullptr in startupcache/; r=ehsan --- startupcache/StartupCache.cpp | 12 ++++++------ startupcache/StartupCacheModule.cpp | 14 +++++++------- startupcache/test/TestStartupCache.cpp | 18 +++++++++--------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/startupcache/StartupCache.cpp b/startupcache/StartupCache.cpp index da91e74b2e4e..2f86b37f391b 100644 --- a/startupcache/StartupCache.cpp +++ b/startupcache/StartupCache.cpp @@ -126,7 +126,7 @@ bool StartupCache::gIgnoreDiskCache; enum StartupCache::TelemetrifyAge StartupCache::gPostFlushAgeAction = StartupCache::IGNORE_AGE; StartupCache::StartupCache() - : mArchive(NULL), mStartupWriteInitiated(false), mWriteThread(NULL), + : mArchive(nullptr), mStartupWriteInitiated(false), mWriteThread(nullptr), mMappingMemoryReporter(nullptr), mDataMemoryReporter(nullptr) { } StartupCache::~StartupCache() @@ -254,7 +254,7 @@ StartupCache::LoadArchive(enum TelemetrifyAge flag) return NS_ERROR_FAILURE; bool exists; - mArchive = NULL; + mArchive = nullptr; nsresult rv = mFile->Exists(&exists); if (NS_FAILED(rv) || !exists) return NS_ERROR_FILE_NOT_FOUND; @@ -481,7 +481,7 @@ StartupCache::WriteToDisk() mTable.Enumerate(CacheCloseHelper, &holder); // Close the archive so Windows doesn't choke. - mArchive = NULL; + mArchive = nullptr; zipW->Close(); // We succesfully wrote the archive to disk; mark the disk file as trusted @@ -498,7 +498,7 @@ StartupCache::InvalidateCache() { WaitOnWriteThread(); mTable.Clear(); - mArchive = NULL; + mArchive = nullptr; nsresult rv = mFile->Remove(false); if (NS_FAILED(rv) && rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST && rv != NS_ERROR_FILE_NOT_FOUND) { @@ -531,7 +531,7 @@ StartupCache::WaitOnWriteThread() return; PR_JoinThread(mWriteThread); - mWriteThread = NULL; + mWriteThread = nullptr; } void @@ -551,7 +551,7 @@ StartupCache::WriteTimeout(nsITimer *aTimer, void *aClosure) { gStartupCache->mWriteThread = PR_CreateThread(PR_USER_THREAD, StartupCache::ThreadedWrite, - NULL, + nullptr, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, diff --git a/startupcache/StartupCacheModule.cpp b/startupcache/StartupCacheModule.cpp index 5ec4c584224a..aa9f08e33029 100644 --- a/startupcache/StartupCacheModule.cpp +++ b/startupcache/StartupCacheModule.cpp @@ -23,23 +23,23 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(StartupCacheWrapper, NS_DEFINE_NAMED_CID(NS_STARTUPCACHE_CID); static const mozilla::Module::CIDEntry kStartupCacheCIDs[] = { - { &kNS_STARTUPCACHE_CID, false, NULL, StartupCacheWrapperConstructor }, - { NULL } + { &kNS_STARTUPCACHE_CID, false, nullptr, StartupCacheWrapperConstructor }, + { nullptr } }; static const mozilla::Module::ContractIDEntry kStartupCacheContracts[] = { { "@mozilla.org/startupcache/cache;1", &kNS_STARTUPCACHE_CID }, - { NULL } + { nullptr } }; static const mozilla::Module kStartupCacheModule = { mozilla::Module::kVersion, kStartupCacheCIDs, kStartupCacheContracts, - NULL, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr, + nullptr }; NSMODULE_DEFN(StartupCacheModule) = &kStartupCacheModule; diff --git a/startupcache/test/TestStartupCache.cpp b/startupcache/test/TestStartupCache.cpp index 417ccce9cdb1..d4deb6e10e60 100644 --- a/startupcache/test/TestStartupCache.cpp +++ b/startupcache/test/TestStartupCache.cpp @@ -91,7 +91,7 @@ TestStartupWriteRead() { const char* buf = "Market opportunities for BeardBook"; const char* id = "id"; - char* outbufPtr = NULL; + char* outbufPtr = nullptr; nsAutoArrayPtr outbuf; uint32_t len; @@ -120,7 +120,7 @@ TestWriteInvalidateRead() { nsresult rv; const char* buf = "BeardBook competitive analysis"; const char* id = "id"; - char* outbuf = NULL; + char* outbuf = nullptr; uint32_t len; nsCOMPtr sc = do_GetService("@mozilla.org/startupcache/cache;1", &rv); @@ -196,7 +196,7 @@ TestWriteObject() { return rv; } - char* bufPtr = NULL; + char* bufPtr = nullptr; nsAutoArrayPtr buf; uint32_t len; NewBufferFromStorageStream(storageStream, &bufPtr, &len); @@ -210,7 +210,7 @@ TestWriteObject() { return rv; } - char* buf2Ptr = NULL; + char* buf2Ptr = nullptr; nsAutoArrayPtr buf2; uint32_t len2; nsCOMPtr objectInput; @@ -315,7 +315,7 @@ TestIgnoreDiskCache(nsIFile* profileDir) { const char* buf = "Get a Beardbook app for your smartphone"; const char* id = "id"; - char* outbuf = NULL; + char* outbuf = nullptr; uint32_t len; rv = sc->PutBuffer(id, buf, strlen(buf) + 1); @@ -361,7 +361,7 @@ TestEarlyShutdown() { const char* buf = "Find your soul beardmate on BeardBook"; const char* id = "id"; uint32_t len; - char* outbuf = NULL; + char* outbuf = nullptr; sc->ResetStartupWriteTimer(); rv = sc->PutBuffer(id, buf, strlen(buf) + 1); @@ -413,13 +413,13 @@ GetHistogramCounts(const char *testmsg, const nsACString &histogram_id, passed(testmsg); Rooted snapshot_val(cx); - JSFunction *snapshot_fn = NULL; + JSFunction *snapshot_fn = nullptr; Rooted ss(cx); return (JS_GetProperty(cx, JSVAL_TO_OBJECT(h), "snapshot", &snapshot_val) && (snapshot_fn = JS_ValueToFunction(cx, snapshot_val)) && JS::Call(cx, JSVAL_TO_OBJECT(h), - snapshot_fn, 0, NULL, &ss) + snapshot_fn, 0, nullptr, &ss) && JS_GetProperty(cx, JSVAL_TO_OBJECT(ss), "counts", counts)); } @@ -522,7 +522,7 @@ int main(int argc, char** argv) }; JSObject *glob = nullptr; if (use_js) - glob = JS_NewGlobalObject(cx, &global_class, NULL); + glob = JS_NewGlobalObject(cx, &global_class, nullptr); if (!glob) use_js = false; mozilla::Maybe ac; From 521d66d83e9aeff471df3c3abf92f99436d72a2b Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Wed, 31 Jul 2013 11:44:58 -0400 Subject: [PATCH 12/40] Bug 784739 - Switch from NULL to nullptr in storage/; r=ehsan --- rdf/base/src/nsInMemoryDataSource.cpp | 4 +- storage/build/mozStorageModule.cpp | 10 ++-- storage/public/StatementCache.h | 2 +- storage/src/SQLiteMutex.h | 2 +- storage/src/StorageBaseStatementInternal.cpp | 2 +- storage/src/TelemetryVFS.cpp | 14 +++--- storage/src/Variant.h | 4 +- storage/src/mozStorageConnection.cpp | 48 ++++++++++--------- storage/src/mozStorageConnection.h | 2 +- storage/src/mozStorageSQLFunctions.cpp | 4 +- storage/src/mozStorageService.cpp | 6 +-- storage/src/mozStorageStatement.cpp | 8 ++-- storage/src/mozStorageStatementData.h | 4 +- storage/src/mozStorageStatementRow.cpp | 2 +- storage/src/variantToSQLiteT_impl.h | 2 +- ...st_asyncStatementExecution_transaction.cpp | 2 +- storage/test/test_true_async.cpp | 4 +- 17 files changed, 62 insertions(+), 58 deletions(-) diff --git a/rdf/base/src/nsInMemoryDataSource.cpp b/rdf/base/src/nsInMemoryDataSource.cpp index 81f774d4b068..cbf88dae2a40 100644 --- a/rdf/base/src/nsInMemoryDataSource.cpp +++ b/rdf/base/src/nsInMemoryDataSource.cpp @@ -197,7 +197,7 @@ Assertion::~Assertion() { if (mHashEntry && u.hash.mPropertyHash) { PL_DHashTableEnumerate(u.hash.mPropertyHash, DeletePropertyHashEntry, - NULL); + nullptr); PL_DHashTableDestroy(u.hash.mPropertyHash); u.hash.mPropertyHash = nullptr; } @@ -814,7 +814,7 @@ InMemoryDataSource::~InMemoryDataSource() // associated with this data source. We only need to do this // for the forward arcs, because the reverse arcs table // indexes the exact same set of resources. - PL_DHashTableEnumerate(&mForwardArcs, DeleteForwardArcsEntry, NULL); + PL_DHashTableEnumerate(&mForwardArcs, DeleteForwardArcsEntry, nullptr); PL_DHashTableFinish(&mForwardArcs); } if (mReverseArcs.ops) diff --git a/storage/build/mozStorageModule.cpp b/storage/build/mozStorageModule.cpp index 357486f40da4..ba77e4c62a7e 100644 --- a/storage/build/mozStorageModule.cpp +++ b/storage/build/mozStorageModule.cpp @@ -27,20 +27,20 @@ NS_DEFINE_NAMED_CID(MOZ_STORAGE_SERVICE_CID); NS_DEFINE_NAMED_CID(VACUUMMANAGER_CID); static const mozilla::Module::CIDEntry kStorageCIDs[] = { - { &kMOZ_STORAGE_SERVICE_CID, false, NULL, mozilla::storage::ServiceConstructor }, - { &kVACUUMMANAGER_CID, false, NULL, mozilla::storage::VacuumManagerConstructor }, - { NULL } + { &kMOZ_STORAGE_SERVICE_CID, false, nullptr, mozilla::storage::ServiceConstructor }, + { &kVACUUMMANAGER_CID, false, nullptr, mozilla::storage::VacuumManagerConstructor }, + { nullptr } }; static const mozilla::Module::ContractIDEntry kStorageContracts[] = { { MOZ_STORAGE_SERVICE_CONTRACTID, &kMOZ_STORAGE_SERVICE_CID }, { VACUUMMANAGER_CONTRACTID, &kVACUUMMANAGER_CID }, - { NULL } + { nullptr } }; static const mozilla::Module::CategoryEntry kStorageCategories[] = { { "idle-daily", "MozStorage Vacuum Manager", VACUUMMANAGER_CONTRACTID }, - { NULL } + { nullptr } }; static const mozilla::Module kStorageModule = { diff --git a/storage/public/StatementCache.h b/storage/public/StatementCache.h index c8b5faf19a12..75c7453c18a3 100644 --- a/storage/public/StatementCache.h +++ b/storage/public/StatementCache.h @@ -80,7 +80,7 @@ public: void FinalizeStatements() { - (void)mCachedStatements.Enumerate(FinalizeCachedStatements, NULL); + (void)mCachedStatements.Enumerate(FinalizeCachedStatements, nullptr); // Clear the cache at this time too! (void)mCachedStatements.Clear(); diff --git a/storage/src/SQLiteMutex.h b/storage/src/SQLiteMutex.h index e6ea0ab07e83..295577b4673b 100644 --- a/storage/src/SQLiteMutex.h +++ b/storage/src/SQLiteMutex.h @@ -31,7 +31,7 @@ public: */ SQLiteMutex(const char *aName) : BlockingResourceBase(aName, eMutex) - , mMutex(NULL) + , mMutex(nullptr) { } diff --git a/storage/src/StorageBaseStatementInternal.cpp b/storage/src/StorageBaseStatementInternal.cpp index 7160757c04e3..5355bf8ca262 100644 --- a/storage/src/StorageBaseStatementInternal.cpp +++ b/storage/src/StorageBaseStatementInternal.cpp @@ -109,7 +109,7 @@ private: //// StorageBaseStatementInternal StorageBaseStatementInternal::StorageBaseStatementInternal() -: mAsyncStatement(NULL) +: mAsyncStatement(nullptr) { } diff --git a/storage/src/TelemetryVFS.cpp b/storage/src/TelemetryVFS.cpp index b31bd396e4fa..351676f35895 100644 --- a/storage/src/TelemetryVFS.cpp +++ b/storage/src/TelemetryVFS.cpp @@ -51,7 +51,7 @@ Histograms gHistograms[] = { SQLITE_TELEMETRY("places.sqlite", PLACES), SQLITE_TELEMETRY("cookies.sqlite", COOKIES), SQLITE_TELEMETRY("webappsstore.sqlite", WEBAPPS), - SQLITE_TELEMETRY(NULL, OTHER) + SQLITE_TELEMETRY(nullptr, OTHER) }; #undef SQLITE_TELEMETRY @@ -123,7 +123,7 @@ xClose(sqlite3_file *pFile) rc = p->pReal->pMethods->xClose(p->pReal); if( rc==SQLITE_OK ){ delete p->base.pMethods; - p->base.pMethods = NULL; + p->base.pMethods = nullptr; p->quotaObject = nullptr; } return rc; @@ -330,7 +330,7 @@ xOpen(sqlite3_vfs* vfs, const char *zName, sqlite3_file* pFile, sqlite3_vfs *orig_vfs = static_cast(vfs->pAppData); int rc; telemetry_file *p = (telemetry_file *)pFile; - Histograms *h = NULL; + Histograms *h = nullptr; // check if the filename is one we are probing for for(size_t i = 0;i < sizeof(gHistograms)/sizeof(gHistograms[0]);i++) { h = &gHistograms[i]; @@ -389,9 +389,9 @@ xOpen(sqlite3_vfs* vfs, const char *zName, sqlite3_file* pFile, pNew->xShmBarrier = pSub->xShmBarrier ? xShmBarrier : 0; pNew->xShmUnmap = pSub->xShmUnmap ? xShmUnmap : 0; // Methods added in version 3. - // SQLite 3.7.17 calls these methods without checking for NULL first, + // SQLite 3.7.17 calls these methods without checking for nullptr first, // so we always define them. Verify that we're not going to call - // NULL pointers, though. + // nullptrs, though. MOZ_ASSERT(pSub->xFetch); pNew->xFetch = xFetch; MOZ_ASSERT(pSub->xUnfetch); @@ -530,11 +530,11 @@ sqlite3_vfs* ConstructTelemetryVFS() expected_vfs = (vfs != nullptr); } else { - vfs = sqlite3_vfs_find(NULL); + vfs = sqlite3_vfs_find(nullptr); expected_vfs = vfs->zName && !strcmp(vfs->zName, EXPECTED_VFS); } if (!expected_vfs) { - return NULL; + return nullptr; } sqlite3_vfs *tvfs = new ::sqlite3_vfs; diff --git a/storage/src/Variant.h b/storage/src/Variant.h index c9f85abf53e4..4db8afd2b781 100644 --- a/storage/src/Variant.h +++ b/storage/src/Variant.h @@ -22,7 +22,7 @@ * nsString -> TEXT (use TextVariant) * nsCString -> TEXT (use UTF8TextVariant) * uint8_t[] -> BLOB (use BlobVariant) - * nullptr -> NULL (use NullVariant) + * nullptr -> NULL (use NullVariant) */ namespace mozilla { @@ -278,7 +278,7 @@ struct variant_blob_traits }; /** - * NULL type + * nullptr type */ class NullVariant : public Variant_base diff --git a/storage/src/mozStorageConnection.cpp b/storage/src/mozStorageConnection.cpp index 431539827d28..120475871306 100644 --- a/storage/src/mozStorageConnection.cpp +++ b/storage/src/mozStorageConnection.cpp @@ -560,7 +560,7 @@ Connection::initialize() PROFILER_LABEL("storage", "Connection::initialize"); // in memory database requested, sqlite uses a magic file name - int srv = ::sqlite3_open_v2(":memory:", &mDBConn, mFlags, NULL); + int srv = ::sqlite3_open_v2(":memory:", &mDBConn, mFlags, nullptr); if (srv != SQLITE_OK) { mDBConn = nullptr; return convertResultCode(srv); @@ -583,7 +583,7 @@ Connection::initialize(nsIFile *aDatabaseFile) NS_ENSURE_SUCCESS(rv, rv); int srv = ::sqlite3_open_v2(NS_ConvertUTF16toUTF8(path).get(), &mDBConn, - mFlags, NULL); + mFlags, nullptr); if (srv != SQLITE_OK) { mDBConn = nullptr; return convertResultCode(srv); @@ -612,7 +612,7 @@ Connection::initialize(nsIFileURL *aFileURL) rv = aFileURL->GetSpec(spec); NS_ENSURE_SUCCESS(rv, rv); - int srv = ::sqlite3_open_v2(spec.get(), &mDBConn, mFlags, NULL); + int srv = ::sqlite3_open_v2(spec.get(), &mDBConn, mFlags, nullptr); if (srv != SQLITE_OK) { mDBConn = nullptr; return convertResultCode(srv); @@ -837,7 +837,7 @@ Connection::internalClose() #ifdef DEBUG // Notify about any non-finalized statements. - sqlite3_stmt *stmt = NULL; + sqlite3_stmt *stmt = nullptr; while ((stmt = ::sqlite3_next_stmt(mDBConn, stmt))) { char *msg = ::PR_smprintf("SQL statement '%s' was not finalized", ::sqlite3_sql(stmt)); @@ -850,7 +850,7 @@ Connection::internalClose() NS_ASSERTION(srv == SQLITE_OK, "sqlite3_close failed. There are probably outstanding statements that are listed above!"); - mDBConn = NULL; + mDBConn = nullptr; return convertResultCode(srv); } @@ -926,8 +926,11 @@ Connection::prepareStatement(const nsCString &aSQL, (void)::sqlite3_extended_result_codes(mDBConn, 1); int srv; - while((srv = ::sqlite3_prepare_v2(mDBConn, aSQL.get(), -1, _stmt, NULL)) == - SQLITE_LOCKED_SHAREDCACHE) { + while((srv = ::sqlite3_prepare_v2(mDBConn, + aSQL.get(), + -1, + _stmt, + nullptr)) == SQLITE_LOCKED_SHAREDCACHE) { if (!checkedMainThread) { checkedMainThread = true; if (::NS_IsMainThread()) { @@ -960,10 +963,10 @@ Connection::prepareStatement(const nsCString &aSQL, (void)::sqlite3_extended_result_codes(mDBConn, 0); // Drop off the extended result bits of the result code. int rc = srv & 0xFF; - // sqlite will return OK on a comment only string and set _stmt to NULL. + // sqlite will return OK on a comment only string and set _stmt to nullptr. // The callers of this function are used to only checking the return value, // so it is safer to return an error code. - if (rc == SQLITE_OK && *_stmt == NULL) { + if (rc == SQLITE_OK && *_stmt == nullptr) { return SQLITE_MISUSE; } @@ -978,7 +981,7 @@ Connection::executeSql(const char *aSqlString) return SQLITE_MISUSE; TimeStamp startTime = TimeStamp::Now(); - int srv = ::sqlite3_exec(mDBConn, aSqlString, NULL, NULL, NULL); + int srv = ::sqlite3_exec(mDBConn, aSqlString, nullptr, nullptr, nullptr); // Report very slow SQL statements to Telemetry TimeDuration duration = TimeStamp::Now() - startTime; @@ -1466,7 +1469,7 @@ Connection::CreateFunction(const nsACString &aFunctionName, // Check to see if this function is already defined. We only check the name // because a function can be defined with the same body but different names. SQLiteMutexAutoLock lockedScope(sharedDBMutex); - NS_ENSURE_FALSE(mFunctions.Get(aFunctionName, NULL), NS_ERROR_FAILURE); + NS_ENSURE_FALSE(mFunctions.Get(aFunctionName, nullptr), NS_ERROR_FAILURE); int srv = ::sqlite3_create_function(mDBConn, nsPromiseFlatCString(aFunctionName).get(), @@ -1474,8 +1477,8 @@ Connection::CreateFunction(const nsACString &aFunctionName, SQLITE_ANY, aFunction, basicFunctionHelper, - NULL, - NULL); + nullptr, + nullptr); if (srv != SQLITE_OK) return convertResultCode(srv); @@ -1496,7 +1499,7 @@ Connection::CreateAggregateFunction(const nsACString &aFunctionName, // Check to see if this function name is already defined. SQLiteMutexAutoLock lockedScope(sharedDBMutex); - NS_ENSURE_FALSE(mFunctions.Get(aFunctionName, NULL), NS_ERROR_FAILURE); + NS_ENSURE_FALSE(mFunctions.Get(aFunctionName, nullptr), NS_ERROR_FAILURE); // Because aggregate functions depend on state across calls, you cannot have // the same instance use the same name. We want to enumerate all functions @@ -1508,7 +1511,7 @@ Connection::CreateAggregateFunction(const nsACString &aFunctionName, aNumArguments, SQLITE_ANY, aFunction, - NULL, + nullptr, aggregateFunctionStepHelper, aggregateFunctionFinalHelper); if (srv != SQLITE_OK) @@ -1528,16 +1531,16 @@ Connection::RemoveFunction(const nsACString &aFunctionName) if (!mDBConn) return NS_ERROR_NOT_INITIALIZED; SQLiteMutexAutoLock lockedScope(sharedDBMutex); - NS_ENSURE_TRUE(mFunctions.Get(aFunctionName, NULL), NS_ERROR_FAILURE); + NS_ENSURE_TRUE(mFunctions.Get(aFunctionName, nullptr), NS_ERROR_FAILURE); int srv = ::sqlite3_create_function(mDBConn, nsPromiseFlatCString(aFunctionName).get(), 0, SQLITE_ANY, - NULL, - NULL, - NULL, - NULL); + nullptr, + nullptr, + nullptr, + nullptr); if (srv != SQLITE_OK) return convertResultCode(srv); @@ -1577,7 +1580,7 @@ Connection::RemoveProgressHandler(mozIStorageProgressHandler **_oldHandler) NS_IF_ADDREF(*_oldHandler = mProgressHandler); mProgressHandler = nullptr; - ::sqlite3_progress_handler(mDBConn, 0, NULL, NULL); + ::sqlite3_progress_handler(mDBConn, 0, nullptr, nullptr); return NS_OK; } @@ -1598,7 +1601,8 @@ Connection::SetGrowthIncrement(int32_t aChunkSize, const nsACString &aDatabaseNa } (void)::sqlite3_file_control(mDBConn, - aDatabaseName.Length() ? nsPromiseFlatCString(aDatabaseName).get() : NULL, + aDatabaseName.Length() ? nsPromiseFlatCString(aDatabaseName).get() + : nullptr, SQLITE_FCNTL_CHUNK_SIZE, &aChunkSize); #endif diff --git a/storage/src/mozStorageConnection.h b/storage/src/mozStorageConnection.h index a291e2541a7e..c3c86843cb92 100644 --- a/storage/src/mozStorageConnection.h +++ b/storage/src/mozStorageConnection.h @@ -183,7 +183,7 @@ private: * Sets the database into a closed state so no further actions can be * performed. * - * @note mDBConn is set to NULL in this method. + * @note mDBConn is set to nullptr in this method. */ nsresult setClosedState(); diff --git a/storage/src/mozStorageSQLFunctions.cpp b/storage/src/mozStorageSQLFunctions.cpp index 9badb5a18946..fbdc676bb4af 100644 --- a/storage/src/mozStorageSQLFunctions.cpp +++ b/storage/src/mozStorageSQLFunctions.cpp @@ -144,7 +144,7 @@ public: /** * Return the pointer to the allocated array. - * @note If the array allocation failed, get() will return NULL! + * @note If the array allocation failed, get() will return nullptr! * * @return the pointer to the allocated array */ @@ -346,7 +346,7 @@ registerFunctions(sqlite3 *aDB) for (size_t i = 0; SQLITE_OK == rv && i < ArrayLength(functions); ++i) { struct Functions *p = &functions[i]; rv = ::sqlite3_create_function(aDB, p->zName, p->nArg, p->enc, p->pContext, - p->xFunc, NULL, NULL); + p->xFunc, nullptr, nullptr); } return rv; diff --git a/storage/src/mozStorageService.cpp b/storage/src/mozStorageService.cpp index 45c35a05f49b..a2285049ae4d 100644 --- a/storage/src/mozStorageService.cpp +++ b/storage/src/mozStorageService.cpp @@ -482,7 +482,7 @@ const sqlite3_mem_methods memMethods = { &sqliteMemRoundup, &sqliteMemInit, &sqliteMemShutdown, - NULL + nullptr }; } // anonymous namespace @@ -628,7 +628,7 @@ Service::OpenSpecialDatabase(const char *aStorageKey, nsCOMPtr storageFile; if (::strcmp(aStorageKey, "memory") == 0) { - // just fall through with NULL storageFile, this will cause the storage + // just fall through with nullptr storageFile, this will cause the storage // connection to use a memory DB. } else { @@ -764,7 +764,7 @@ Service::OpenAsyncDatabase(nsIVariant *aDatabaseStore, return NS_ERROR_INVALID_ARG; } - // Just fall through with NULL storageFile, this will cause the storage + // Just fall through with nullptr storageFile, this will cause the storage // connection to use a memory DB. } diff --git a/storage/src/mozStorageStatement.cpp b/storage/src/mozStorageStatement.cpp index 9d0f74f6323e..aa152ff9b67a 100644 --- a/storage/src/mozStorageStatement.cpp +++ b/storage/src/mozStorageStatement.cpp @@ -124,7 +124,7 @@ static StatementClassInfo sStatementClassInfo; Statement::Statement() : StorageBaseStatementInternal() -, mDBStatement(NULL) +, mDBStatement(nullptr) , mColumnNames() , mExecuting(false) { @@ -280,7 +280,7 @@ int Statement::getAsyncStatement(sqlite3_stmt **_stmt) { // If we have no statement, we shouldn't be calling this method! - NS_ASSERTION(mDBStatement != NULL, "We have no statement to clone!"); + NS_ASSERTION(mDBStatement != nullptr, "We have no statement to clone!"); // If we do not yet have a cached async statement, clone our statement now. if (!mAsyncStatement) { @@ -363,7 +363,7 @@ Statement::internalFinalize(bool aDestructing) #endif int srv = ::sqlite3_finalize(mDBStatement); - mDBStatement = NULL; + mDBStatement = nullptr; if (mAsyncStatement) { // If the destructor called us, there are no pending async statements (they @@ -419,7 +419,7 @@ Statement::GetParameterName(uint32_t aParamIndex, const char *name = ::sqlite3_bind_parameter_name(mDBStatement, aParamIndex + 1); - if (name == NULL) { + if (name == nullptr) { // this thing had no name, so fake one nsAutoCString name(":"); name.AppendInt(aParamIndex); diff --git a/storage/src/mozStorageStatementData.h b/storage/src/mozStorageStatementData.h index 2eed63450d2c..bb4763b1f245 100644 --- a/storage/src/mozStorageStatementData.h +++ b/storage/src/mozStorageStatementData.h @@ -85,7 +85,7 @@ public: nsCOMPtr asyncThread = mStatementOwner->getOwner()->getAsyncExecutionTarget(); // It's possible that we are shutting down the async thread, and this - // method would return NULL as a result. + // method would return nullptr as a result. if (asyncThread) { bool onAsyncThread; NS_ASSERTION(NS_SUCCEEDED(asyncThread->IsOnCurrentThread(&onAsyncThread)) && onAsyncThread, @@ -99,7 +99,7 @@ public: if (mStatement) { (void)::sqlite3_reset(mStatement); (void)::sqlite3_clear_bindings(mStatement); - mStatement = NULL; + mStatement = nullptr; } } diff --git a/storage/src/mozStorageStatementRow.cpp b/storage/src/mozStorageStatementRow.cpp index f407d610173b..ed0126b880db 100644 --- a/storage/src/mozStorageStatementRow.cpp +++ b/storage/src/mozStorageStatementRow.cpp @@ -137,7 +137,7 @@ StatementRow::NewResolve(nsIXPConnectWrappedNative *aWrapper, // It's highly likely that the name doesn't exist, so let the JS engine // check the prototype chain and throw if that doesn't have the property // either. - *_objp = NULL; + *_objp = nullptr; return NS_OK; } diff --git a/storage/src/variantToSQLiteT_impl.h b/storage/src/variantToSQLiteT_impl.h index 30301337f813..30d58f012322 100644 --- a/storage/src/variantToSQLiteT_impl.h +++ b/storage/src/variantToSQLiteT_impl.h @@ -17,7 +17,7 @@ int variantToSQLiteT(T aObj, nsIVariant *aValue) { - // Allow to return NULL not wrapped to nsIVariant for speed. + // Allow to return nullptr not wrapped to nsIVariant for speed. if (!aValue) return sqlite3_T_null(aObj); diff --git a/storage/test/test_asyncStatementExecution_transaction.cpp b/storage/test/test_asyncStatementExecution_transaction.cpp index 3492590e8e8f..fb0c948aaef0 100644 --- a/storage/test/test_asyncStatementExecution_transaction.cpp +++ b/storage/test/test_asyncStatementExecution_transaction.cpp @@ -60,7 +60,7 @@ check_transaction(mozIStorageConnection *aDB, asyncSpin->SpinUntilCompleted(); // -- uninstall the transaction commit hook. - ::sqlite3_commit_hook(*static_cast(aDB), NULL, NULL); + ::sqlite3_commit_hook(*static_cast(aDB), nullptr, nullptr); // -- check transaction do_check_eq(aTransactionExpected, !!commit); diff --git a/storage/test/test_true_async.cpp b/storage/test/test_true_async.cpp index 616da68db418..34ec873f2d1f 100644 --- a/storage/test/test_true_async.cpp +++ b/storage/test/test_true_async.cpp @@ -31,7 +31,7 @@ sqlite3_mutex_methods orig_mutex_methods; sqlite3_mutex_methods wrapped_mutex_methods; bool mutex_used_on_watched_thread = false; -PRThread *watched_thread = NULL; +PRThread *watched_thread = nullptr; /** * Ugly hack to let us figure out what a connection's async thread is. If we * were MOZILLA_INTERNAL_API and linked as such we could just include @@ -41,7 +41,7 @@ PRThread *watched_thread = NULL; * When the thread a mutex is invoked on isn't watched_thread we save it to this * variable. */ -PRThread *last_non_watched_thread = NULL; +PRThread *last_non_watched_thread = nullptr; /** * Set a flag if the mutex is used on the thread we are watching, but always From 47b26323bdddc88ff21bab0ea8c1d42a6d28c283 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Wed, 31 Jul 2013 11:35:25 -0400 Subject: [PATCH 13/40] Bug 803669 - convert nsScannerBufferList to use mozilla::LinkedList; r=mrbkap --- parser/htmlparser/public/nsScannerString.h | 29 +++++++------ parser/htmlparser/src/nsScannerString.cpp | 49 ++++++++-------------- 2 files changed, 32 insertions(+), 46 deletions(-) diff --git a/parser/htmlparser/public/nsScannerString.h b/parser/htmlparser/public/nsScannerString.h index ae611691544a..b9ebb1f40fc8 100644 --- a/parser/htmlparser/public/nsScannerString.h +++ b/parser/htmlparser/public/nsScannerString.h @@ -9,7 +9,7 @@ #include "nsString.h" #include "nsUnicharUtils.h" // for nsCaseInsensitiveStringComparator -#include "prclist.h" +#include "mozilla/LinkedList.h" #include @@ -61,7 +61,7 @@ class nsScannerBufferList * of the data segment is determined by increment the |this| pointer * by 1 unit. */ - class Buffer : public PRCList + class Buffer : public mozilla::LinkedListElement { public: @@ -76,11 +76,11 @@ class nsScannerBufferList const PRUnichar* DataEnd() const { return mDataEnd; } PRUnichar* DataEnd() { return mDataEnd; } - const Buffer* Next() const { return static_cast(next); } - Buffer* Next() { return static_cast(next); } + const Buffer* Next() const { return getNext(); } + Buffer* Next() { return getNext(); } - const Buffer* Prev() const { return static_cast(prev); } - Buffer* Prev() { return static_cast(prev); } + const Buffer* Prev() const { return getPrevious(); } + Buffer* Prev() { return getPrevious(); } uint32_t DataLength() const { return mDataEnd - DataStart(); } void SetDataLength(uint32_t len) { mDataEnd = DataStart() + len; } @@ -127,23 +127,22 @@ class nsScannerBufferList nsScannerBufferList( Buffer* buf ) : mRefCnt(0) { - PR_INIT_CLIST(&mBuffers); - PR_APPEND_LINK(buf, &mBuffers); + mBuffers.insertBack(buf); } void AddRef() { ++mRefCnt; } void Release() { if (--mRefCnt == 0) delete this; } - void Append( Buffer* buf ) { PR_APPEND_LINK(buf, &mBuffers); } - void InsertAfter( Buffer* buf, Buffer* prev ) { PR_INSERT_AFTER(buf, prev); } + void Append( Buffer* buf ) { mBuffers.insertBack(buf); } + void InsertAfter( Buffer* buf, Buffer* prev ) { prev->setNext(buf); } void SplitBuffer( const Position& ); void DiscardUnreferencedPrefix( Buffer* ); - Buffer* Head() { return static_cast(PR_LIST_HEAD(&mBuffers)); } - const Buffer* Head() const { return static_cast(PR_LIST_HEAD(&mBuffers)); } + Buffer* Head() { return mBuffers.getFirst(); } + const Buffer* Head() const { return mBuffers.getFirst(); } - Buffer* Tail() { return static_cast(PR_LIST_TAIL(&mBuffers)); } - const Buffer* Tail() const { return static_cast(PR_LIST_TAIL(&mBuffers)); } + Buffer* Tail() { return mBuffers.getLast(); } + const Buffer* Tail() const { return mBuffers.getLast(); } private: @@ -153,7 +152,7 @@ class nsScannerBufferList void ReleaseAll(); int32_t mRefCnt; - PRCList mBuffers; + mozilla::LinkedList mBuffers; }; diff --git a/parser/htmlparser/src/nsScannerString.cpp b/parser/htmlparser/src/nsScannerString.cpp index 7cb5c7b04c26..23ab9170f3da 100644 --- a/parser/htmlparser/src/nsScannerString.cpp +++ b/parser/htmlparser/src/nsScannerString.cpp @@ -19,25 +19,13 @@ nsScannerBufferList::Buffer* nsScannerBufferList::AllocBufferFromString( const nsAString& aString ) { uint32_t len = aString.Length(); + Buffer* buf = AllocBuffer(len); - if (len > MAX_CAPACITY) - return nullptr; - - Buffer* buf = (Buffer*) malloc(sizeof(Buffer) + (len + 1) * sizeof(PRUnichar)); if (buf) { - // leave PRCList members of Buffer uninitialized - - buf->mUsageCount = 0; - buf->mDataEnd = buf->DataStart() + len; - nsAString::const_iterator source; aString.BeginReading(source); nsCharTraits::copy(buf->DataStart(), source.get(), len); - - // XXX null terminate. this shouldn't be required, but we do it because - // nsScanner erroneously thinks it can dereference DataEnd :-( - *buf->mDataEnd = PRUnichar(0); } return buf; } @@ -48,30 +36,29 @@ nsScannerBufferList::AllocBuffer( uint32_t capacity ) if (capacity > MAX_CAPACITY) return nullptr; - Buffer* buf = (Buffer*) malloc(sizeof(Buffer) + (capacity + 1) * sizeof(PRUnichar)); - if (buf) - { - // leave PRCList members of Buffer uninitialized + void* ptr = malloc(sizeof(Buffer) + (capacity + 1) * sizeof(PRUnichar)); + if (!ptr) + return nullptr; - buf->mUsageCount = 0; - buf->mDataEnd = buf->DataStart() + capacity; + Buffer* buf = new (ptr) Buffer(); - // XXX null terminate. this shouldn't be required, but we do it because - // nsScanner erroneously thinks it can dereference DataEnd :-( - *buf->mDataEnd = PRUnichar(0); - } + buf->mUsageCount = 0; + buf->mDataEnd = buf->DataStart() + capacity; + + // XXX null terminate. this shouldn't be required, but we do it because + // nsScanner erroneously thinks it can dereference DataEnd :-( + *buf->mDataEnd = PRUnichar(0); return buf; } void nsScannerBufferList::ReleaseAll() { - while (!PR_CLIST_IS_EMPTY(&mBuffers)) + while (!mBuffers.isEmpty()) { - PRCList* node = PR_LIST_HEAD(&mBuffers); - PR_REMOVE_LINK(node); + Buffer* node = mBuffers.popFirst(); //printf(">>> freeing buffer @%p\n", node); - free(static_cast(node)); + free(node); } } @@ -106,10 +93,10 @@ nsScannerBufferList::DiscardUnreferencedPrefix( Buffer* aBuf ) { if (aBuf == Head()) { - while (!PR_CLIST_IS_EMPTY(&mBuffers) && !Head()->IsInUse()) + while (!mBuffers.isEmpty() && !Head()->IsInUse()) { Buffer* buffer = Head(); - PR_REMOVE_LINK(buffer); + buffer->remove(); free(buffer); } } @@ -276,7 +263,7 @@ nsScannerSubstring::GetNextFragment( nsScannerFragment& frag ) const if (frag.mBuffer == mEnd.mBuffer) return false; - frag.mBuffer = static_cast(PR_NEXT_LINK(frag.mBuffer)); + frag.mBuffer = frag.mBuffer->getNext(); if (frag.mBuffer == mStart.mBuffer) frag.mFragmentStart = mStart.mPosition; @@ -298,7 +285,7 @@ nsScannerSubstring::GetPrevFragment( nsScannerFragment& frag ) const if (frag.mBuffer == mStart.mBuffer) return false; - frag.mBuffer = static_cast(PR_PREV_LINK(frag.mBuffer)); + frag.mBuffer = frag.mBuffer->getPrevious(); if (frag.mBuffer == mStart.mBuffer) frag.mFragmentStart = mStart.mPosition; From 37ded34aa51efab8071e51f5d9afd5e040393b25 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Wed, 31 Jul 2013 17:48:36 +0200 Subject: [PATCH 14/40] Bug 888597 - Move IDBObjectStore to WebIDL, r=janv --- addon-sdk/source/lib/sdk/indexed-db.js | 1 - addon-sdk/source/test/test-indexed-db.js | 4 +- dom/base/nsDOMClassInfo.cpp | 7 - dom/base/nsDOMClassInfoClasses.h | 1 - dom/bindings/Bindings.conf | 11 +- dom/indexedDB/IDBCursor.cpp | 48 +- dom/indexedDB/IDBCursor.h | 14 +- dom/indexedDB/IDBDatabase.cpp | 2 +- dom/indexedDB/IDBIndex.cpp | 7 +- dom/indexedDB/IDBObjectStore.cpp | 747 ++++++++---------- dom/indexedDB/IDBObjectStore.h | 161 +++- dom/indexedDB/IDBTransaction.cpp | 2 +- dom/indexedDB/IDBTransaction.h | 2 +- dom/indexedDB/KeyPath.cpp | 35 + dom/indexedDB/KeyPath.h | 8 + dom/indexedDB/ipc/IndexedDBParent.cpp | 68 +- dom/indexedDB/moz.build | 1 - dom/indexedDB/nsIIDBDatabase.idl | 3 +- dom/indexedDB/nsIIDBIndex.idl | 4 +- dom/indexedDB/nsIIDBObjectStore.idl | 99 --- dom/indexedDB/test/unit/head.js | 1 - .../test/unit/test_complex_keyPaths.js | 2 - ...e_inline_autoincrement_key_added_on_put.js | 1 - .../unit/test_objectStore_remove_values.js | 1 - .../test/unit/test_open_objectStore.js | 1 - dom/indexedDB/test/unit/test_remove_index.js | 2 - .../test/unit/test_remove_objectStore.js | 2 - dom/webidl/IDBCursor.webidl | 15 + dom/webidl/IDBIndex.webidl | 14 + dom/webidl/IDBObjectStore.webidl | 65 ++ dom/webidl/IDBTransaction.webidl | 2 - dom/webidl/WebIDL.mk | 3 + js/xpconnect/src/dictionary_helper_gen.conf | 1 - js/xpconnect/src/dom_quickstubs.qsconf | 1 - js/xpconnect/src/nsXPConnect.cpp | 4 +- 35 files changed, 708 insertions(+), 632 deletions(-) delete mode 100644 dom/indexedDB/nsIIDBObjectStore.idl create mode 100644 dom/webidl/IDBCursor.webidl create mode 100644 dom/webidl/IDBIndex.webidl create mode 100644 dom/webidl/IDBObjectStore.webidl diff --git a/addon-sdk/source/lib/sdk/indexed-db.js b/addon-sdk/source/lib/sdk/indexed-db.js index 2a1f59a350ec..b260f32a0dea 100644 --- a/addon-sdk/source/lib/sdk/indexed-db.js +++ b/addon-sdk/source/lib/sdk/indexed-db.js @@ -57,5 +57,4 @@ exports.IDBCursor = Ci.nsIIDBCursor; exports.IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest; exports.IDBDatabase = Ci.nsIIDBDatabase; exports.IDBIndex = Ci.nsIIDBIndex; -exports.IDBObjectStore = Ci.nsIIDBObjectStore; exports.IDBRequest = Ci.nsIIDBRequest; diff --git a/addon-sdk/source/test/test-indexed-db.js b/addon-sdk/source/test/test-indexed-db.js index 05e146b226e3..1174b9544ae5 100644 --- a/addon-sdk/source/test/test-indexed-db.js +++ b/addon-sdk/source/test/test-indexed-db.js @@ -9,7 +9,7 @@ if (xulApp.versionInRange(xulApp.platformVersion, "16.0a1", "*")) { new function tests() { const { indexedDB, IDBKeyRange, DOMException, IDBCursor, - IDBOpenDBRequest, IDBDatabase, IDBIndex, IDBObjectStore, IDBRequest + IDBOpenDBRequest, IDBDatabase, IDBIndex, IDBRequest } = require("sdk/indexed-db"); exports["test indexedDB is frozen"] = function(assert){ @@ -24,7 +24,7 @@ exports["test indexedDB is frozen"] = function(assert){ exports["test db variables"] = function(assert) { [ indexedDB, IDBKeyRange, DOMException, IDBCursor, IDBOpenDBRequest, IDBOpenDBRequest, IDBDatabase, IDBIndex, - IDBObjectStore, IDBRequest + IDBRequest ].forEach(function(value) { assert.notEqual(typeof(value), "undefined", "variable is defined"); }); diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 13104f7b49f0..f42b2246af91 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -204,7 +204,6 @@ #include "mozilla/dom/indexedDB/IDBWrapperCache.h" #include "mozilla/dom/indexedDB/IDBRequest.h" #include "mozilla/dom/indexedDB/IDBDatabase.h" -#include "mozilla/dom/indexedDB/IDBObjectStore.h" #include "mozilla/dom/indexedDB/IDBCursor.h" #include "mozilla/dom/indexedDB/IDBKeyRange.h" #include "mozilla/dom/indexedDB/IDBIndex.h" @@ -638,8 +637,6 @@ static nsDOMClassInfoData sClassInfoData[] = { IDBEVENTTARGET_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(IDBDatabase, IDBEventTargetSH, IDBEVENTTARGET_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(IDBObjectStore, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(IDBCursor, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(IDBCursorWithValue, nsDOMGenericSH, @@ -1546,10 +1543,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(IDBObjectStore, nsIIDBObjectStore) - DOM_CLASSINFO_MAP_ENTRY(nsIIDBObjectStore) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(IDBCursor, nsIIDBCursor) DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor) DOM_CLASSINFO_MAP_END diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 338b03184b14..a27bf43bff05 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -121,7 +121,6 @@ DOMCI_CLASS(ChromeMessageSender) DOMCI_CLASS(IDBRequest) DOMCI_CLASS(IDBDatabase) -DOMCI_CLASS(IDBObjectStore) DOMCI_CLASS(IDBCursor) DOMCI_CLASS(IDBCursorWithValue) DOMCI_CLASS(IDBKeyRange) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index aa1dcd79f53a..838a9f1caa20 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -546,6 +546,14 @@ DOMInterfaces = { 'nativeType': 'mozilla::dom::indexedDB::IDBFileHandle', }, +'IDBObjectStore': { + 'nativeType': 'mozilla::dom::indexedDB::IDBObjectStore', + 'implicitJSContext': [ 'createIndex' ], + 'binaryNames': { + 'mozGetAll': 'getAll' + } +}, + 'IDBTransaction': { 'nativeType': 'mozilla::dom::indexedDB::IDBTransaction', }, @@ -1660,8 +1668,9 @@ addExternalIface('FileCallback', nativeType='nsIFileCallback', headerFile='nsIDOMHTMLCanvasElement.h') addExternalIface('HitRegionOptions', nativeType='nsISupports') addExternalIface('IDBDatabase', nativeType='nsIIDBDatabase') -addExternalIface('IDBObjectStore', nativeType='nsIIDBObjectStore') +addExternalIface('IDBIndex', nativeType='nsIIDBIndex') addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest') +addExternalIface('IDBRequest', nativeType='nsIIDBRequest') addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver') addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True) addExternalIface('LockedFile') diff --git a/dom/indexedDB/IDBCursor.cpp b/dom/indexedDB/IDBCursor.cpp index 6ec5adf8f603..055e4834cd7f 100644 --- a/dom/indexedDB/IDBCursor.cpp +++ b/dom/indexedDB/IDBCursor.cpp @@ -295,6 +295,28 @@ IDBCursor::ParseDirection(const nsAString& aDirection, Direction* aResult) return NS_OK; } +// static +IDBCursor::Direction +IDBCursor::ConvertDirection(mozilla::dom::IDBCursorDirection aDirection) +{ + switch (aDirection) { + case mozilla::dom::IDBCursorDirection::Next: + return NEXT; + + case mozilla::dom::IDBCursorDirection::Nextunique: + return NEXT_UNIQUE; + + case mozilla::dom::IDBCursorDirection::Prev: + return PREV; + + case mozilla::dom::IDBCursorDirection::Prevunique: + return PREV_UNIQUE; + + default: + MOZ_CRASH("Unknown direction!"); + } +} + // static already_AddRefed IDBCursor::CreateCommon(IDBRequest* aRequest, @@ -732,9 +754,12 @@ IDBCursor::Update(const jsval& aValue, return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; } - rv = mObjectStore->Put(aValue, JSVAL_VOID, aCx, 0, getter_AddRefs(request)); - if (NS_FAILED(rv)) { - return rv; + ErrorResult error; + JS::Rooted value(aCx, aValue); + Optional > keyValue(aCx); + request = mObjectStore->Put(aCx, value, keyValue, error); + if (error.Failed()) { + return error.ErrorCode(); } } else { @@ -742,9 +767,12 @@ IDBCursor::Update(const jsval& aValue, rv = objectKey.ToJSVal(aCx, &keyVal); NS_ENSURE_SUCCESS(rv, rv); - rv = mObjectStore->Put(aValue, keyVal, aCx, 1, getter_AddRefs(request)); - if (NS_FAILED(rv)) { - return rv; + ErrorResult error; + JS::Rooted value(aCx, aValue); + Optional > keyValue(aCx, keyVal); + request = mObjectStore->Put(aCx, value, keyValue, error); + if (error.Failed()) { + return error.ErrorCode(); } } @@ -813,10 +841,10 @@ IDBCursor::Delete(JSContext* aCx, nsresult rv = objectKey.ToJSVal(aCx, &key); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr request; - rv = mObjectStore->Delete(key, aCx, getter_AddRefs(request)); - if (NS_FAILED(rv)) { - return rv; + ErrorResult error; + nsCOMPtr request = mObjectStore->Delete(aCx, key, error); + if (error.Failed()) { + return error.ErrorCode(); } #ifdef IDB_PROFILER_USE_MARKS diff --git a/dom/indexedDB/IDBCursor.h b/dom/indexedDB/IDBCursor.h index 985c1c71c497..96ce13788dd2 100644 --- a/dom/indexedDB/IDBCursor.h +++ b/dom/indexedDB/IDBCursor.h @@ -8,13 +8,16 @@ #define mozilla_dom_indexeddb_idbcursor_h__ #include "mozilla/dom/indexedDB/IndexedDatabase.h" -#include "mozilla/dom/indexedDB/IDBObjectStore.h" -#include "mozilla/dom/indexedDB/Key.h" #include "nsIIDBCursorWithValue.h" +#include "mozilla/dom/IDBCursorBinding.h" #include "nsCycleCollectionParticipant.h" +#include "mozilla/dom/indexedDB/IDBObjectStore.h" +#include "mozilla/dom/indexedDB/Key.h" + + class nsIRunnable; class nsIScriptContext; class nsPIDOMWindow; @@ -113,8 +116,11 @@ public: return mRequest; } - static nsresult ParseDirection(const nsAString& aDirection, - Direction* aResult); + static nsresult + ParseDirection(const nsAString& aDirection, Direction* aResult); + + static Direction + ConvertDirection(IDBCursorDirection aDirection); void SetActor(IndexedDBCursorChild* aActorChild) diff --git a/dom/indexedDB/IDBDatabase.cpp b/dom/indexedDB/IDBDatabase.cpp index 4856dc5d5b33..7c9b6b719b5a 100644 --- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -525,7 +525,7 @@ NS_IMETHODIMP IDBDatabase::CreateObjectStore(const nsAString& aName, const jsval& aOptions, JSContext* aCx, - nsIIDBObjectStore** _retval) + nsISupports** _retval) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); diff --git a/dom/indexedDB/IDBIndex.cpp b/dom/indexedDB/IDBIndex.cpp index f564d6dc9495..5b6df3d5baa8 100644 --- a/dom/indexedDB/IDBIndex.cpp +++ b/dom/indexedDB/IDBIndex.cpp @@ -795,7 +795,8 @@ IDBIndex::GetStoreName(nsAString& aStoreName) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - return mObjectStore->GetName(aStoreName); + aStoreName.Assign(mObjectStore->Name()); + return NS_OK; } NS_IMETHODIMP @@ -840,11 +841,11 @@ IDBIndex::GetMultiEntry(bool* aMultiEntry) } NS_IMETHODIMP -IDBIndex::GetObjectStore(nsIIDBObjectStore** aObjectStore) +IDBIndex::GetObjectStore(nsISupports** aObjectStore) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - nsCOMPtr objectStore(mObjectStore); + nsCOMPtr objectStore(mObjectStore); objectStore.forget(aObjectStore); return NS_OK; } diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp index 9702d6c4d477..4eb7a3819827 100644 --- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -52,6 +52,7 @@ USING_INDEXEDDB_NAMESPACE using namespace mozilla::dom; using namespace mozilla::dom::indexedDB::ipc; using mozilla::dom::quota::FileOutputStream; +using mozilla::ErrorResult; BEGIN_INDEXEDDB_NAMESPACE @@ -1730,6 +1731,8 @@ IDBObjectStore::IDBObjectStore() mActorParent(nullptr) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + + SetIsDOMBinding(); } IDBObjectStore::~IDBObjectStore() @@ -1813,47 +1816,53 @@ IDBObjectStore::GetAddInfo(JSContext* aCx, return rv; } -nsresult -IDBObjectStore::AddOrPut(const jsval& aValue, - const jsval& aKey, - JSContext* aCx, - uint8_t aOptionalArgCount, - bool aOverwrite, - IDBRequest** _retval) +already_AddRefed +IDBObjectStore::AddOrPut(JSContext* aCx, JS::Handle aValue, + const Optional >& aKey, + bool aOverwrite, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (!mTransaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } if (!IsWriteAllowed()) { - return NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR); + return nullptr; } - JS::Rooted keyval(aCx, - (aOptionalArgCount >= 1) ? aKey : JSVAL_VOID); + JS::Rooted keyval(aCx, aKey.WasPassed() ? aKey.Value() + : JSVAL_VOID); StructuredCloneWriteInfo cloneWriteInfo; Key key; nsTArray updateInfo; JS::Rooted value(aCx, aValue); - nsresult rv = GetAddInfo(aCx, value, keyval, cloneWriteInfo, key, - updateInfo); - if (NS_FAILED(rv)) { - return rv; + aRv = GetAddInfo(aCx, value, keyval, cloneWriteInfo, key, updateInfo); + if (aRv.Failed()) { + return nullptr; } nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new AddHelper(mTransaction, request, this, cloneWriteInfo, key, aOverwrite, updateInfo); - rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + nsresult rv = helper->DispatchToTransactionPool(); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } #ifdef IDB_PROFILER_USE_MARKS if (aOverwrite) { @@ -1878,8 +1887,7 @@ IDBObjectStore::AddOrPut(const jsval& aValue, } #endif - request.forget(_retval); - return NS_OK; + return request.forget(); } nsresult @@ -1991,26 +1999,33 @@ IDBObjectStore::AddOrPutInternal( return NS_OK; } -nsresult -IDBObjectStore::GetInternal(IDBKeyRange* aKeyRange, - JSContext* aCx, - IDBRequest** _retval) +already_AddRefed +IDBObjectStore::GetInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(aKeyRange, "Null pointer!"); if (!mTransaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new GetHelper(mTransaction, request, this, aKeyRange); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s).get(%s)", @@ -2020,30 +2035,36 @@ IDBObjectStore::GetInternal(IDBKeyRange* aKeyRange, IDB_PROFILER_STRING(Transaction()), IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange)); - request.forget(_retval); - return NS_OK; + return request.forget(); } -nsresult +already_AddRefed IDBObjectStore::GetAllInternal(IDBKeyRange* aKeyRange, - uint32_t aLimit, - JSContext* aCx, - IDBRequest** _retval) + uint32_t aLimit, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (!mTransaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new GetAllHelper(mTransaction, request, this, aKeyRange, aLimit); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s)." @@ -2055,34 +2076,42 @@ IDBObjectStore::GetAllInternal(IDBKeyRange* aKeyRange, IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange), aLimit); - request.forget(_retval); - return NS_OK; + return request.forget(); } -nsresult +already_AddRefed IDBObjectStore::DeleteInternal(IDBKeyRange* aKeyRange, - JSContext* aCx, - IDBRequest** _retval) + ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(aKeyRange, "Null key range!"); if (!mTransaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } if (!IsWriteAllowed()) { - return NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR); + return nullptr; } nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new DeleteHelper(mTransaction, request, this, aKeyRange); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s).delete(%s)", @@ -2092,31 +2121,39 @@ IDBObjectStore::DeleteInternal(IDBKeyRange* aKeyRange, IDB_PROFILER_STRING(Transaction()), IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange)); - request.forget(_retval); - return NS_OK; + return request.forget(); } -nsresult -IDBObjectStore::ClearInternal(JSContext* aCx, - IDBRequest** _retval) +already_AddRefed +IDBObjectStore::Clear(ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (!mTransaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } if (!IsWriteAllowed()) { - return NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR); + return nullptr; } nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper(new ClearHelper(mTransaction, request, this)); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s).clear()", @@ -2126,28 +2163,34 @@ IDBObjectStore::ClearInternal(JSContext* aCx, IDB_PROFILER_STRING(Transaction()), IDB_PROFILER_STRING(this)); - request.forget(_retval); - return NS_OK; + return request.forget(); } -nsresult -IDBObjectStore::CountInternal(IDBKeyRange* aKeyRange, - JSContext* aCx, - IDBRequest** _retval) +already_AddRefed +IDBObjectStore::CountInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (!mTransaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new CountHelper(mTransaction, request, this, aKeyRange); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s).count(%s)", @@ -2157,33 +2200,39 @@ IDBObjectStore::CountInternal(IDBKeyRange* aKeyRange, IDB_PROFILER_STRING(Transaction()), IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange)); - request.forget(_retval); - return NS_OK; + return request.forget(); } -nsresult +already_AddRefed IDBObjectStore::OpenCursorInternal(IDBKeyRange* aKeyRange, - size_t aDirection, - JSContext* aCx, - IDBRequest** _retval) + size_t aDirection, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (!mTransaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } IDBCursor::Direction direction = static_cast(aDirection); nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new OpenCursorHelper(mTransaction, request, this, aKeyRange, direction); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s)." @@ -2195,8 +2244,7 @@ IDBObjectStore::OpenCursorInternal(IDBKeyRange* aKeyRange, IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange), IDB_PROFILER_STRING(direction)); - request.forget(_retval); - return NS_OK; + return request.forget(); } nsresult @@ -2245,9 +2293,8 @@ IDBObjectStore::SetInfo(ObjectStoreInfo* aInfo) mInfo = aInfo; } -nsresult -IDBObjectStore::CreateIndexInternal(const IndexInfo& aInfo, - IDBIndex** _retval) +already_AddRefed +IDBObjectStore::CreateIndexInternal(const IndexInfo& aInfo, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); @@ -2271,7 +2318,11 @@ IDBObjectStore::CreateIndexInternal(const IndexInfo& aInfo, new CreateIndexHelper(mTransaction, index); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } } autoRemove.forget(); @@ -2284,18 +2335,17 @@ IDBObjectStore::CreateIndexInternal(const IndexInfo& aInfo, IDB_PROFILER_STRING(Transaction()), IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(index)); - index.forget(_retval); - return NS_OK; + return index.forget(); } -nsresult -IDBObjectStore::IndexInternal(const nsAString& aName, - IDBIndex** _retval) +already_AddRefed +IDBObjectStore::Index(const nsAString& aName, ErrorResult &aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (mTransaction->IsFinished()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } IndexInfo* indexInfo = nullptr; @@ -2308,7 +2358,8 @@ IDBObjectStore::IndexInternal(const nsAString& aName, } if (!indexInfo) { - return NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR); + return nullptr; } nsRefPtr retval; @@ -2322,19 +2373,24 @@ IDBObjectStore::IndexInternal(const nsAString& aName, if (!retval) { retval = IDBIndex::Create(this, indexInfo, false); - NS_ENSURE_TRUE(retval, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!retval) { + NS_WARNING("Failed to create index!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } if (!mCreatedIndexes.AppendElement(retval)) { NS_WARNING("Out of memory!"); - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; } } - retval.forget(_retval); - return NS_OK; + return retval.forget(); } NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBObjectStore) + NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mCachedKeyPath) NS_IMPL_CYCLE_COLLECTION_TRACE_END @@ -2349,6 +2405,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBObjectStore) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBObjectStore) + NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER + // Don't unlink mTransaction! tmp->mCreatedIndexes.Clear(); @@ -2362,69 +2420,41 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBObjectStore) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBObjectStore) - NS_INTERFACE_MAP_ENTRY(nsIIDBObjectStore) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBObjectStore) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBObjectStore) NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBObjectStore) -DOMCI_DATA(IDBObjectStore, IDBObjectStore) - -NS_IMETHODIMP -IDBObjectStore::GetName(nsAString& aName) +JSObject* +IDBObjectStore::WrapObject(JSContext* aCx, JS::Handle aScope) { - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - aName.Assign(mName); - return NS_OK; + return IDBObjectStoreBinding::Wrap(aCx, aScope, this); } -NS_IMETHODIMP -IDBObjectStore::GetKeyPath(JSContext* aCx, - jsval* aVal) +JS::Value +IDBObjectStore::GetKeyPath(JSContext* aCx, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (!JSVAL_IS_VOID(mCachedKeyPath)) { - *aVal = mCachedKeyPath; - return NS_OK; + return mCachedKeyPath; } - nsresult rv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath); - NS_ENSURE_SUCCESS(rv, rv); + aRv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath); + ENSURE_SUCCESS(aRv, JSVAL_VOID); if (JSVAL_IS_GCTHING(mCachedKeyPath)) { NS_HOLD_JS_OBJECTS(this, IDBObjectStore); mRooted = true; } - *aVal = mCachedKeyPath; - return NS_OK; + return mCachedKeyPath; } -NS_IMETHODIMP -IDBObjectStore::GetTransaction(nsISupports** aTransaction) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - nsRefPtr transaction(mTransaction); - transaction.forget(aTransaction); - return NS_OK; -} - -NS_IMETHODIMP -IDBObjectStore::GetAutoIncrement(bool* aAutoIncrement) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - *aAutoIncrement = mAutoIncrement; - return NS_OK; -} - -NS_IMETHODIMP -IDBObjectStore::GetIndexNames(nsIDOMDOMStringList** aIndexNames) +already_AddRefed +IDBObjectStore::GetIndexNames(ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); @@ -2439,233 +2469,173 @@ IDBObjectStore::GetIndexNames(nsIDOMDOMStringList** aIndexNames) } for (uint32_t index = 0; index < count; index++) { - NS_ENSURE_TRUE(list->Add(names[index]), - NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - } - - list.forget(aIndexNames); - return NS_OK; -} - -NS_IMETHODIMP -IDBObjectStore::Get(const jsval& aKey, - JSContext* aCx, - nsIIDBRequest** _retval) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - if (!mTransaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; - } - - nsRefPtr keyRange; - nsresult rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); - NS_ENSURE_SUCCESS(rv, rv); - - if (!keyRange) { - // Must specify a key or keyRange for get(). - return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; - } - - nsRefPtr request; - rv = GetInternal(keyRange, aCx, getter_AddRefs(request)); - if (NS_FAILED(rv)) { - return rv; - } - - request.forget(_retval); - return NS_OK; -} - -NS_IMETHODIMP -IDBObjectStore::GetAll(const jsval& aKey, - uint32_t aLimit, - JSContext* aCx, - uint8_t aOptionalArgCount, - nsIIDBRequest** _retval) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - if (!mTransaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; - } - - nsresult rv; - - nsRefPtr keyRange; - if (aOptionalArgCount) { - rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); - NS_ENSURE_SUCCESS(rv, rv); - } - - if (aOptionalArgCount < 2 || aLimit == 0) { - aLimit = UINT32_MAX; - } - - nsRefPtr request; - rv = GetAllInternal(keyRange, aLimit, aCx, getter_AddRefs(request)); - if (NS_FAILED(rv)) { - return rv; - } - - request.forget(_retval); - return NS_OK; -} - -NS_IMETHODIMP -IDBObjectStore::Add(const jsval& aValue, - const jsval& aKey, - JSContext* aCx, - uint8_t aOptionalArgCount, - nsIIDBRequest** _retval) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - nsRefPtr request; - nsresult rv = AddOrPut(aValue, aKey, aCx, aOptionalArgCount, false, - getter_AddRefs(request)); - if (NS_FAILED(rv)) { - return rv; - } - - request.forget(_retval); - return NS_OK; -} - -NS_IMETHODIMP -IDBObjectStore::Put(const jsval& aValue, - const jsval& aKey, - JSContext* aCx, - uint8_t aOptionalArgCount, - nsIIDBRequest** _retval) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - nsRefPtr request; - nsresult rv = AddOrPut(aValue, aKey, aCx, aOptionalArgCount, true, - getter_AddRefs(request)); - if (NS_FAILED(rv)) { - return rv; - } - - request.forget(_retval); - return NS_OK; -} - -NS_IMETHODIMP -IDBObjectStore::Delete(const jsval& aKey, - JSContext* aCx, - nsIIDBRequest** _retval) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - if (!mTransaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; - } - - if (!IsWriteAllowed()) { - return NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR; - } - - nsRefPtr keyRange; - nsresult rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); - if (NS_FAILED(rv)) { - return rv; - } - - if (!keyRange) { - // Must specify a key or keyRange for delete(). - return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; - } - - nsRefPtr request; - rv = DeleteInternal(keyRange, aCx, getter_AddRefs(request)); - if (NS_FAILED(rv)) { - return rv; - } - - request.forget(_retval); - return NS_OK; -} - -NS_IMETHODIMP -IDBObjectStore::Clear(JSContext* aCx, nsIIDBRequest** _retval) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - nsRefPtr request; - nsresult rv = ClearInternal(aCx, getter_AddRefs(request)); - if (NS_FAILED(rv)) { - return rv; - } - - request.forget(_retval); - return NS_OK; -} - -NS_IMETHODIMP -IDBObjectStore::OpenCursor(const jsval& aKey, - const nsAString& aDirection, - JSContext* aCx, - uint8_t aOptionalArgCount, - nsIIDBRequest** _retval) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - if (!mTransaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; - } - - nsresult rv; - - IDBCursor::Direction direction = IDBCursor::NEXT; - - nsRefPtr keyRange; - if (aOptionalArgCount) { - rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); - NS_ENSURE_SUCCESS(rv, rv); - - if (aOptionalArgCount >= 2) { - rv = IDBCursor::ParseDirection(aDirection, &direction); - NS_ENSURE_SUCCESS(rv, rv); + if (!list->Add(names[index])) { + NS_WARNING("Failed to add element!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; } } - size_t argDirection = static_cast(direction); - - nsRefPtr request; - rv = OpenCursorInternal(keyRange, argDirection, aCx, - getter_AddRefs(request)); - if (NS_FAILED(rv)) { - return rv; - } - - request.forget(_retval); - return NS_OK; + return list.forget(); } -NS_IMETHODIMP -IDBObjectStore::CreateIndex(const nsAString& aName, - const jsval& aKeyPath, - const jsval& aOptions, - JSContext* aCx, - nsIIDBIndex** _retval) +already_AddRefed +IDBObjectStore::Get(JSContext* aCx, JS::Handle aKey, + ErrorResult& aRv) { - NS_PRECONDITION(NS_IsMainThread(), "Wrong thread!"); + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + + if (!mTransaction->IsOpen()) { + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; + } + + nsRefPtr keyRange; + aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); + ENSURE_SUCCESS(aRv, nullptr); + + if (!keyRange) { + // Must specify a key or keyRange for get(). + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR); + return nullptr; + } + + return GetInternal(keyRange, aRv); +} + +already_AddRefed +IDBObjectStore::GetAll(JSContext* aCx, + const Optional >& aKey, + const Optional& aLimit, ErrorResult& aRv) +{ + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + + if (!mTransaction->IsOpen()) { + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; + } + + nsRefPtr keyRange; + if (aKey.WasPassed()) { + aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange)); + ENSURE_SUCCESS(aRv, nullptr); + } + + uint32_t limit = UINT32_MAX; + if (aLimit.WasPassed() && aLimit.Value() != 0) { + limit = aLimit.Value(); + } + + return GetAllInternal(keyRange, limit, aRv); +} + +already_AddRefed +IDBObjectStore::Delete(JSContext* aCx, JS::Handle aKey, + ErrorResult& aRv) +{ + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + + if (!mTransaction->IsOpen()) { + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; + } + + if (!IsWriteAllowed()) { + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR); + return nullptr; + } + + nsRefPtr keyRange; + aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); + ENSURE_SUCCESS(aRv, nullptr); + + if (!keyRange) { + // Must specify a key or keyRange for delete(). + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR); + return nullptr; + } + + return DeleteInternal(keyRange, aRv); +} + +already_AddRefed +IDBObjectStore::OpenCursor(JSContext* aCx, + const Optional >& aRange, + IDBCursorDirection aDirection, ErrorResult& aRv) +{ + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + + if (!mTransaction->IsOpen()) { + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; + } + + nsRefPtr keyRange; + if (aRange.WasPassed()) { + aRv = IDBKeyRange::FromJSVal(aCx, aRange.Value(), getter_AddRefs(keyRange)); + ENSURE_SUCCESS(aRv, nullptr); + } + + IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection); + size_t argDirection = static_cast(direction); + + return OpenCursorInternal(keyRange, argDirection, aRv); +} + +already_AddRefed +IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName, + const nsAString& aKeyPath, + const IDBIndexParameters& aOptionalParameters, + ErrorResult& aRv) +{ + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); KeyPath keyPath(0); if (NS_FAILED(KeyPath::Parse(aCx, aKeyPath, &keyPath)) || !keyPath.IsValid()) { - return NS_ERROR_DOM_SYNTAX_ERR; + aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR); + return nullptr; } + return CreateIndex(aCx, aName, keyPath, aOptionalParameters, aRv); +} + +already_AddRefed +IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName, + const Sequence& aKeyPath, + const IDBIndexParameters& aOptionalParameters, + ErrorResult& aRv) +{ + NS_PRECONDITION(NS_IsMainThread(), "Wrong thread!"); + + if (!aKeyPath.Length()) { + aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR); + return nullptr; + } + + KeyPath keyPath(0); + if (NS_FAILED(KeyPath::Parse(aCx, aKeyPath, &keyPath))) { + aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR); + return nullptr; + } + + return CreateIndex(aCx, aName, keyPath, aOptionalParameters, aRv); +} + +already_AddRefed +IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName, + KeyPath& aKeyPath, + const IDBIndexParameters& aOptionalParameters, + ErrorResult& aRv) +{ // Check name and current mode IDBTransaction* transaction = AsyncConnectionHelper::GetCurrentTransaction(); if (!transaction || transaction != mTransaction || mTransaction->GetMode() != IDBTransaction::VERSION_CHANGE) { - return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); + return nullptr; } bool found = false; @@ -2678,7 +2648,8 @@ IDBObjectStore::CreateIndex(const nsAString& aName, } if (found) { - return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR); + return nullptr; } NS_ASSERTION(mTransaction->IsOpen(), "Impossible!"); @@ -2691,19 +2662,9 @@ IDBObjectStore::CreateIndex(const nsAString& aName, } #endif - nsresult rv; - mozilla::idl::IDBIndexParameters params; - - // Get optional arguments. - if (!JSVAL_IS_VOID(aOptions) && !JSVAL_IS_NULL(aOptions)) { - rv = params.Init(aCx, &aOptions); - if (NS_FAILED(rv)) { - return rv; - } - } - - if (params.multiEntry && keyPath.IsArray()) { - return NS_ERROR_DOM_INVALID_ACCESS_ERR; + if (aOptionalParameters.mMultiEntry && aKeyPath.IsArray()) { + aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); + return nullptr; } DatabaseInfo* databaseInfo = mTransaction->DBInfo(); @@ -2712,38 +2673,15 @@ IDBObjectStore::CreateIndex(const nsAString& aName, info.name = aName; info.id = databaseInfo->nextIndexId++; - info.keyPath = keyPath; - info.unique = params.unique; - info.multiEntry = params.multiEntry; + info.keyPath = aKeyPath; + info.unique = aOptionalParameters.mUnique; + info.multiEntry = aOptionalParameters.mMultiEntry; - nsRefPtr index; - rv = CreateIndexInternal(info, getter_AddRefs(index)); - if (NS_FAILED(rv)) { - return rv; - } - - index.forget(_retval); - return NS_OK; + return CreateIndexInternal(info, aRv); } -NS_IMETHODIMP -IDBObjectStore::Index(const nsAString& aName, - nsIIDBIndex** _retval) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - nsRefPtr index; - nsresult rv = IndexInternal(aName, getter_AddRefs(index)); - if (NS_FAILED(rv)) { - return rv; - } - - index.forget(_retval); - return NS_OK; -} - -NS_IMETHODIMP -IDBObjectStore::DeleteIndex(const nsAString& aName) +void +IDBObjectStore::DeleteIndex(const nsAString& aName, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); @@ -2752,7 +2690,8 @@ IDBObjectStore::DeleteIndex(const nsAString& aName) if (!transaction || transaction != mTransaction || mTransaction->GetMode() != IDBTransaction::VERSION_CHANGE) { - return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); + return; } NS_ASSERTION(mTransaction->IsOpen(), "Impossible!"); @@ -2765,17 +2704,20 @@ IDBObjectStore::DeleteIndex(const nsAString& aName) } if (index == mInfo->indexes.Length()) { - return NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR); + return; } - nsresult rv; - if (IndexedDatabaseManager::IsMainProcess()) { nsRefPtr helper = new DeleteIndexHelper(mTransaction, this, aName); - rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + nsresult rv = helper->DispatchToTransactionPool(); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return; + } } else { NS_ASSERTION(mActorChild, "Must have an actor here!"); @@ -2800,36 +2742,25 @@ IDBObjectStore::DeleteIndex(const nsAString& aName) IDB_PROFILER_STRING(Transaction()), IDB_PROFILER_STRING(this), NS_ConvertUTF16toUTF8(aName).get()); - - return NS_OK; } -NS_IMETHODIMP -IDBObjectStore::Count(const jsval& aKey, - JSContext* aCx, - uint8_t aOptionalArgCount, - nsIIDBRequest** _retval) +already_AddRefed +IDBObjectStore::Count(JSContext* aCx, + const Optional >& aKey, + ErrorResult& aRv) { if (!mTransaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } - nsresult rv; - nsRefPtr keyRange; - if (aOptionalArgCount) { - rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); - NS_ENSURE_SUCCESS(rv, rv); + if (aKey.WasPassed()) { + aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange)); + ENSURE_SUCCESS(aRv, nullptr); } - nsRefPtr request; - rv = CountInternal(keyRange, aCx, getter_AddRefs(request)); - if (NS_FAILED(rv)) { - return rv; - } - - request.forget(_retval); - return NS_OK; + return CountInternal(keyRange, aRv); } inline nsresult diff --git a/dom/indexedDB/IDBObjectStore.h b/dom/indexedDB/IDBObjectStore.h index c32ccbe2008c..7c0b87bab0fa 100644 --- a/dom/indexedDB/IDBObjectStore.h +++ b/dom/indexedDB/IDBObjectStore.h @@ -9,16 +9,19 @@ #include "mozilla/dom/indexedDB/IndexedDatabase.h" -#include "nsIIDBObjectStore.h" - +#include "mozilla/dom/IDBCursorBinding.h" +#include "mozilla/dom/IDBIndexBinding.h" +#include "mozilla/dom/IDBObjectStoreBinding.h" #include "nsCycleCollectionParticipant.h" +#include "mozilla/dom/indexedDB/IDBRequest.h" #include "mozilla/dom/indexedDB/IDBTransaction.h" #include "mozilla/dom/indexedDB/KeyPath.h" class nsIDOMBlob; class nsIScriptContext; class nsPIDOMWindow; +class nsIIDBIndex; namespace mozilla { namespace dom { @@ -46,12 +49,11 @@ struct ObjectStoreInfo; struct FileHandleData; struct BlobOrFileData; -class IDBObjectStore MOZ_FINAL : public nsIIDBObjectStore +class IDBObjectStore MOZ_FINAL : public nsISupports, + public nsWrapperCache { public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_NSIIDBOBJECTSTORE - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBObjectStore) static already_AddRefed @@ -197,13 +199,9 @@ public: return mActorParent; } - nsresult + already_AddRefed CreateIndexInternal(const IndexInfo& aInfo, - IDBIndex** _retval); - - nsresult - IndexInternal(const nsAString& aName, - IDBIndex** _retval); + ErrorResult& aRv); nsresult AddOrPutInternal( const SerializedStructuredCloneWriteInfo& aCloneWriteInfo, @@ -213,30 +211,27 @@ public: bool aOverwrite, IDBRequest** _retval); - nsresult GetInternal(IDBKeyRange* aKeyRange, - JSContext* aCx, - IDBRequest** _retval); + already_AddRefed + GetInternal(IDBKeyRange* aKeyRange, + ErrorResult& aRv); - nsresult GetAllInternal(IDBKeyRange* aKeyRange, - uint32_t aLimit, - JSContext* aCx, - IDBRequest** _retval); + already_AddRefed + GetAllInternal(IDBKeyRange* aKeyRange, + uint32_t aLimit, + ErrorResult& aRv); - nsresult DeleteInternal(IDBKeyRange* aKeyRange, - JSContext* aCx, - IDBRequest** _retval); + already_AddRefed + DeleteInternal(IDBKeyRange* aKeyRange, + ErrorResult& aRv); - nsresult ClearInternal(JSContext* aCx, - IDBRequest** _retval); + already_AddRefed + CountInternal(IDBKeyRange* aKeyRange, + ErrorResult& aRv); - nsresult CountInternal(IDBKeyRange* aKeyRange, - JSContext* aCx, - IDBRequest** _retval); - - nsresult OpenCursorInternal(IDBKeyRange* aKeyRange, - size_t aDirection, - JSContext* aCx, - IDBRequest** _retval); + already_AddRefed + OpenCursorInternal(IDBKeyRange* aKeyRange, + size_t aDirection, + ErrorResult& aRv); nsresult OpenCursorFromChildProcess( IDBRequest* aRequest, @@ -251,6 +246,96 @@ public: static JSClass sDummyPropJSClass; + // nsWrapperCache + virtual JSObject* + WrapObject(JSContext* aCx, JS::Handle aScope) MOZ_OVERRIDE; + + // WebIDL + IDBTransaction* + GetParentObject() const + { + return mTransaction; + } + + void + GetName(nsString& aName) const + { + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + aName.Assign(mName); + } + + JS::Value + GetKeyPath(JSContext* aCx, ErrorResult& aRv); + + already_AddRefed + GetIndexNames(ErrorResult& aRv); + + IDBTransaction* + Transaction() const + { + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + return mTransaction; + } + + bool + AutoIncrement() const + { + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + return mAutoIncrement; + } + + already_AddRefed + Put(JSContext* aCx, JS::Handle aValue, + const Optional >& aKey, ErrorResult& aRv) + { + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + return AddOrPut(aCx, aValue, aKey, true, aRv); + } + + already_AddRefed + Add(JSContext* aCx, JS::Handle aValue, + const Optional >& aKey, ErrorResult& aRv) + { + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + return AddOrPut(aCx, aValue, aKey, false, aRv); + } + + already_AddRefed + Delete(JSContext* aCx, JS::Handle aKey, ErrorResult& aRv); + + already_AddRefed + Get(JSContext* aCx, JS::Handle aKey, ErrorResult& aRv); + + already_AddRefed + Clear(ErrorResult& aRv); + + already_AddRefed + OpenCursor(JSContext* aCx, const Optional >& aRange, + IDBCursorDirection aDirection, ErrorResult& aRv); + + already_AddRefed + CreateIndex(JSContext* aCx, const nsAString& aName, const nsAString& aKeyPath, + const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv); + + already_AddRefed + CreateIndex(JSContext* aCx, const nsAString& aName, + const Sequence& aKeyPath, + const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv); + + already_AddRefed + Index(const nsAString& aName, ErrorResult &aRv); + + void + DeleteIndex(const nsAString& aIndexName, ErrorResult& aRv); + + already_AddRefed + Count(JSContext* aCx, const Optional >& aKey, + ErrorResult& aRv); + + already_AddRefed + GetAll(JSContext* aCx, const Optional >& aKey, + const Optional& aLimit, ErrorResult& aRv); + protected: IDBObjectStore(); ~IDBObjectStore(); @@ -262,12 +347,14 @@ protected: Key& aKey, nsTArray& aUpdateInfoArray); - nsresult AddOrPut(const jsval& aValue, - const jsval& aKey, - JSContext* aCx, - uint8_t aOptionalArgCount, - bool aOverwrite, - IDBRequest** _retval); + already_AddRefed + AddOrPut(JSContext* aCx, JS::Handle aValue, + const Optional >& aKey, bool aOverwrite, + ErrorResult& aRv); + + already_AddRefed + CreateIndex(JSContext* aCx, const nsAString& aName, KeyPath& aKeyPath, + const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv); static void ClearStructuredCloneBuffer(JSAutoStructuredCloneBuffer& aBuffer); diff --git a/dom/indexedDB/IDBTransaction.cpp b/dom/indexedDB/IDBTransaction.cpp index 436932988cd1..627a81f2a931 100644 --- a/dom/indexedDB/IDBTransaction.cpp +++ b/dom/indexedDB/IDBTransaction.cpp @@ -699,7 +699,7 @@ IDBTransaction::GetObjectStoreNames(ErrorResult& aRv) return list.forget(); } -already_AddRefed +already_AddRefed IDBTransaction::ObjectStore(const nsAString& aName, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); diff --git a/dom/indexedDB/IDBTransaction.h b/dom/indexedDB/IDBTransaction.h index 06ad181f1ec5..05c1f1d288be 100644 --- a/dom/indexedDB/IDBTransaction.h +++ b/dom/indexedDB/IDBTransaction.h @@ -240,7 +240,7 @@ public: DOMError* GetError(ErrorResult& aRv); - already_AddRefed + already_AddRefed ObjectStore(const nsAString& aName, ErrorResult& aRv); void diff --git a/dom/indexedDB/KeyPath.cpp b/dom/indexedDB/KeyPath.cpp index ea8f48c6eda3..0e362f5f050c 100644 --- a/dom/indexedDB/KeyPath.cpp +++ b/dom/indexedDB/KeyPath.cpp @@ -12,6 +12,8 @@ #include "nsJSUtils.h" #include "xpcpublic.h" +#include "mozilla/dom/BindingDeclarations.h" + USING_INDEXEDDB_NAMESPACE namespace { @@ -220,6 +222,39 @@ GetJSValFromKeyPathString(JSContext* aCx, } // anonymous namespace +// static +nsresult +KeyPath::Parse(JSContext* aCx, const nsAString& aString, KeyPath* aKeyPath) +{ + KeyPath keyPath(0); + keyPath.SetType(STRING); + + if (!keyPath.AppendStringWithValidation(aCx, aString)) { + return NS_ERROR_FAILURE; + } + + *aKeyPath = keyPath; + return NS_OK; +} + +//static +nsresult +KeyPath::Parse(JSContext* aCx, const mozilla::dom::Sequence& aStrings, + KeyPath* aKeyPath) +{ + KeyPath keyPath(0); + keyPath.SetType(ARRAY); + + for (uint32_t i = 0; i < aStrings.Length(); ++i) { + if (!keyPath.AppendStringWithValidation(aCx, aStrings[i])) { + return NS_ERROR_FAILURE; + } + } + + *aKeyPath = keyPath; + return NS_OK; +} + // static nsresult KeyPath::Parse(JSContext* aCx, const JS::Value& aValue, KeyPath* aKeyPath) diff --git a/dom/indexedDB/KeyPath.h b/dom/indexedDB/KeyPath.h index c15b526b6220..bee0c2cad0e8 100644 --- a/dom/indexedDB/KeyPath.h +++ b/dom/indexedDB/KeyPath.h @@ -9,6 +9,8 @@ #include "mozilla/dom/indexedDB/IndexedDatabase.h" +#include "mozilla/dom/BindingDeclarations.h" + BEGIN_INDEXEDDB_NAMESPACE class Key; @@ -45,6 +47,12 @@ public: MOZ_COUNT_DTOR(KeyPath); } + static nsresult + Parse(JSContext* aCx, const nsAString& aString, KeyPath* aKeyPath); + + static nsresult + Parse(JSContext* aCx, const Sequence& aStrings, KeyPath* aKeyPath); + static nsresult Parse(JSContext* aCx, const JS::Value& aValue, KeyPath* aKeyPath); diff --git a/dom/indexedDB/ipc/IndexedDBParent.cpp b/dom/indexedDB/ipc/IndexedDBParent.cpp index d928b2b6c1b5..2ba629da75e7 100644 --- a/dom/indexedDB/ipc/IndexedDBParent.cpp +++ b/dom/indexedDB/ipc/IndexedDBParent.cpp @@ -796,13 +796,9 @@ IndexedDBTransactionParent::RecvPIndexedDBObjectStoreConstructor( AutoSetCurrentTransaction asct(mTransaction); ErrorResult rv; - nsCOMPtr store = mTransaction->ObjectStore(name, rv); - if (rv.Failed()) { - NS_WARNING("Failed to get object store!"); - return false; - } + objectStore = mTransaction->ObjectStore(name, rv); + ENSURE_SUCCESS(rv, false); - objectStore = static_cast(store.get()); actor->SetObjectStore(objectStore); } @@ -1153,9 +1149,11 @@ IndexedDBObjectStoreParent::RecvPIndexedDBIndexConstructor( { AutoSetCurrentTransaction asct(mObjectStore->Transaction()); - nsresult rv = mObjectStore->IndexInternal(name, getter_AddRefs(index)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + nsCOMPtr obj = mObjectStore->Index(name, rv); + ENSURE_SUCCESS(rv, false); + index = static_cast(obj.get()); actor->SetIndex(index); } @@ -1253,16 +1251,15 @@ IndexedDBVersionChangeObjectStoreParent::RecvDeleteIndex(const nsString& aName) return true; } - nsresult rv; + ErrorResult rv; { AutoSetCurrentTransaction asct(mObjectStore->Transaction()); - rv = mObjectStore->DeleteIndex(aName); + mObjectStore->DeleteIndex(aName, rv); } - NS_ENSURE_SUCCESS(rv, false); - + ENSURE_SUCCESS(rv, false); return true; } @@ -1297,15 +1294,15 @@ IndexedDBVersionChangeObjectStoreParent::RecvPIndexedDBIndexConstructor( nsRefPtr index; - nsresult rv; - { AutoSetCurrentTransaction asct(mObjectStore->Transaction()); - rv = mObjectStore->CreateIndexInternal(info, getter_AddRefs(index)); - } + ErrorResult rv; + nsCOMPtr obj = mObjectStore->CreateIndexInternal(info, rv); + ENSURE_SUCCESS(rv, false); - NS_ENSURE_SUCCESS(rv, false); + index = static_cast(obj.get()); + } actor->SetIndex(index); index->SetActor(actor); @@ -1513,9 +1510,9 @@ IndexedDBObjectStoreRequestParent::Get(const GetParams& aParams) { AutoSetCurrentTransaction asct(mObjectStore->Transaction()); - nsresult rv = mObjectStore->GetInternal(keyRange, nullptr, - getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + request = mObjectStore->GetInternal(keyRange, rv); + ENSURE_SUCCESS(rv, false); } request->SetActor(this); @@ -1553,10 +1550,9 @@ IndexedDBObjectStoreRequestParent::GetAll(const GetAllParams& aParams) { AutoSetCurrentTransaction asct(mObjectStore->Transaction()); - nsresult rv = mObjectStore->GetAllInternal(keyRange, aParams.limit(), - nullptr, - getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + request = mObjectStore->GetAllInternal(keyRange, aParams.limit(), rv); + ENSURE_SUCCESS(rv, false); } request->SetActor(this); @@ -1635,9 +1631,9 @@ IndexedDBObjectStoreRequestParent::Delete(const DeleteParams& aParams) { AutoSetCurrentTransaction asct(mObjectStore->Transaction()); - nsresult rv = - mObjectStore->DeleteInternal(keyRange, nullptr, getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + request = mObjectStore->DeleteInternal(keyRange, rv); + ENSURE_SUCCESS(rv, false); } request->SetActor(this); @@ -1656,8 +1652,9 @@ IndexedDBObjectStoreRequestParent::Clear(const ClearParams& aParams) { AutoSetCurrentTransaction asct(mObjectStore->Transaction()); - nsresult rv = mObjectStore->ClearInternal(nullptr, getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + request = mObjectStore->Clear(rv); + ENSURE_SUCCESS(rv, false); } request->SetActor(this); @@ -1694,9 +1691,9 @@ IndexedDBObjectStoreRequestParent::Count(const CountParams& aParams) { AutoSetCurrentTransaction asct(mObjectStore->Transaction()); - nsresult rv = - mObjectStore->CountInternal(keyRange, nullptr, getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + request = mObjectStore->CountInternal(keyRange, rv); + ENSURE_SUCCESS(rv, false); } request->SetActor(this); @@ -1735,10 +1732,9 @@ IndexedDBObjectStoreRequestParent::OpenCursor(const OpenCursorParams& aParams) { AutoSetCurrentTransaction asct(mObjectStore->Transaction()); - nsresult rv = - mObjectStore->OpenCursorInternal(keyRange, direction, nullptr, - getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + request = mObjectStore->OpenCursorInternal(keyRange, direction, rv); + ENSURE_SUCCESS(rv, false); } request->SetActor(this); diff --git a/dom/indexedDB/moz.build b/dom/indexedDB/moz.build index 6f3785f02074..30685271877b 100644 --- a/dom/indexedDB/moz.build +++ b/dom/indexedDB/moz.build @@ -13,7 +13,6 @@ XPIDL_SOURCES += [ 'nsIIDBDatabase.idl', 'nsIIDBIndex.idl', 'nsIIDBKeyRange.idl', - 'nsIIDBObjectStore.idl', 'nsIIDBOpenDBRequest.idl', 'nsIIDBRequest.idl', 'nsIIndexedDatabaseManager.idl', diff --git a/dom/indexedDB/nsIIDBDatabase.idl b/dom/indexedDB/nsIIDBDatabase.idl index 4f6155311bfc..54ab80ea433a 100644 --- a/dom/indexedDB/nsIIDBDatabase.idl +++ b/dom/indexedDB/nsIIDBDatabase.idl @@ -6,7 +6,6 @@ #include "nsISupports.idl" -interface nsIIDBObjectStore; interface nsIIDBRequest; interface nsIDOMDOMStringList; interface nsIDOMEventListener; @@ -26,7 +25,7 @@ interface nsIIDBDatabase : nsISupports readonly attribute nsIDOMDOMStringList objectStoreNames; [implicit_jscontext] - nsIIDBObjectStore + nsISupports // IDBObjectStore createObjectStore([Null(Stringify)] in DOMString name, /* IDBObjectStoreParameters */ [optional /* none */] in jsval options); diff --git a/dom/indexedDB/nsIIDBIndex.idl b/dom/indexedDB/nsIIDBIndex.idl index 00bd6f3bcb58..5dd1d9fc57cb 100644 --- a/dom/indexedDB/nsIIDBIndex.idl +++ b/dom/indexedDB/nsIIDBIndex.idl @@ -6,7 +6,6 @@ #include "nsISupports.idl" -interface nsIIDBObjectStore; interface nsIIDBRequest; /** @@ -28,7 +27,8 @@ interface nsIIDBIndex : nsISupports readonly attribute boolean multiEntry; - readonly attribute nsIIDBObjectStore objectStore; + // This is a IDBObjectStore + readonly attribute nsISupports objectStore; [implicit_jscontext] nsIIDBRequest diff --git a/dom/indexedDB/nsIIDBObjectStore.idl b/dom/indexedDB/nsIIDBObjectStore.idl deleted file mode 100644 index 8dab6c433f3d..000000000000 --- a/dom/indexedDB/nsIIDBObjectStore.idl +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -interface nsIIDBIndex; -interface nsIIDBKeyRange; -interface nsIIDBRequest; -interface nsIDOMDOMStringList; - -dictionary IDBIndexParameters -{ - boolean unique; - boolean multiEntry; -}; - -/** - * nsIIDBObjectStore interface. See - * http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-nsIIDBObjectStore - * for more information. - */ -[scriptable, builtinclass, uuid(dd189afd-e1b7-4496-bf8d-629c58709595)] -interface nsIIDBObjectStore : nsISupports -{ - readonly attribute DOMString name; - - [implicit_jscontext] - readonly attribute jsval keyPath; - - readonly attribute nsIDOMDOMStringList indexNames; - - // IDBTransaction - readonly attribute nsISupports transaction; - - readonly attribute boolean autoIncrement; - - // Success fires IDBTransactionEvent, result == value for key - [implicit_jscontext] - nsIIDBRequest - get(in jsval key); - - // Success fires IDBTransactionEvent, result == array of values for given keys - [implicit_jscontext, optional_argc, binaryname(GetAll)] - nsIIDBRequest - mozGetAll([optional /* null */] in jsval key, - [optional /* unlimited */] in unsigned long limit); - - // Success fires IDBTransactionEvent, result == key - [implicit_jscontext, optional_argc] - nsIIDBRequest - add(in jsval value, - [optional /* undefined */] in jsval key); - - // Success fires IDBTransactionEvent, result == key - [implicit_jscontext, optional_argc] - nsIIDBRequest - put(in jsval value, - [optional /* undefined */] in jsval key); - - // Success fires IDBTransactionEvent, result == null - [implicit_jscontext] - nsIIDBRequest - delete(in jsval key); - - // Success fires IDBTransactionEvent, result == null - [implicit_jscontext] - nsIIDBRequest - clear(); - - // Success fires IDBTransactionEvent, result == IDBCursor or result == null if - // no match. - // direction can be "next", "nextunique", "prev" or "prevunique" - [implicit_jscontext, optional_argc] - nsIIDBRequest - openCursor([optional /* null */] in jsval range, - [optional /* "next" */] in DOMString direction); - - [implicit_jscontext] - nsIIDBIndex - createIndex([Null(Stringify)] in DOMString name, - in jsval keyPath, - /* nsIIDBIndexParameters */ - [optional /* none */] in jsval options); - - // Returns object immediately - nsIIDBIndex - index([Null(Stringify)] in DOMString name); - - void - deleteIndex([Null(Stringify)] in DOMString name); - - // Accepts null, a key value, or a nsIIDBKeyRange object. - [implicit_jscontext, optional_argc] - nsIIDBRequest - count([optional] in jsval key); -}; diff --git a/dom/indexedDB/test/unit/head.js b/dom/indexedDB/test/unit/head.js index 08f8055575f5..60d703234d28 100644 --- a/dom/indexedDB/test/unit/head.js +++ b/dom/indexedDB/test/unit/head.js @@ -10,7 +10,6 @@ const IDBCursor = Ci.nsIIDBCursor; const IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest; const IDBDatabase = Ci.nsIIDBDatabase const IDBIndex = Ci.nsIIDBIndex -const IDBObjectStore = Ci.nsIIDBObjectStore const IDBRequest = Ci.nsIIDBRequest function is(a, b, msg) { diff --git a/dom/indexedDB/test/unit/test_complex_keyPaths.js b/dom/indexedDB/test/unit/test_complex_keyPaths.js index 721358eb104e..95e5ad44a20e 100644 --- a/dom/indexedDB/test/unit/test_complex_keyPaths.js +++ b/dom/indexedDB/test/unit/test_complex_keyPaths.js @@ -7,8 +7,6 @@ var testGenerator = testSteps(); function testSteps() { - const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore; - // Test object stores const name = "test_complex_keyPaths"; diff --git a/dom/indexedDB/test/unit/test_objectStore_inline_autoincrement_key_added_on_put.js b/dom/indexedDB/test/unit/test_objectStore_inline_autoincrement_key_added_on_put.js index 661bc6567a20..a3db5d1b9e18 100644 --- a/dom/indexedDB/test/unit/test_objectStore_inline_autoincrement_key_added_on_put.js +++ b/dom/indexedDB/test/unit/test_objectStore_inline_autoincrement_key_added_on_put.js @@ -7,7 +7,6 @@ var testGenerator = testSteps(); function testSteps() { - const IDBObjectStore = Components.interfaces.nsIIDBObjectStore; const name = this.window ? window.location.pathname : "Splendid Test"; var request = indexedDB.open(name, 1); diff --git a/dom/indexedDB/test/unit/test_objectStore_remove_values.js b/dom/indexedDB/test/unit/test_objectStore_remove_values.js index 59c165dd436d..91c37681217d 100644 --- a/dom/indexedDB/test/unit/test_objectStore_remove_values.js +++ b/dom/indexedDB/test/unit/test_objectStore_remove_values.js @@ -7,7 +7,6 @@ var testGenerator = testSteps(); function testSteps() { - const IDBObjectStore = Components.interfaces.nsIIDBObjectStore; const name = this.window ? window.location.pathname : "Splendid Test"; var data = [ diff --git a/dom/indexedDB/test/unit/test_open_objectStore.js b/dom/indexedDB/test/unit/test_open_objectStore.js index 4d349fd60923..207107941c3a 100644 --- a/dom/indexedDB/test/unit/test_open_objectStore.js +++ b/dom/indexedDB/test/unit/test_open_objectStore.js @@ -7,7 +7,6 @@ var testGenerator = testSteps(); function testSteps() { - const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore; const name = this.window ? window.location.pathname : "Splendid Test"; const objectStoreName = "Objects"; diff --git a/dom/indexedDB/test/unit/test_remove_index.js b/dom/indexedDB/test/unit/test_remove_index.js index 5d13cff1fd48..2587486c110e 100644 --- a/dom/indexedDB/test/unit/test_remove_index.js +++ b/dom/indexedDB/test/unit/test_remove_index.js @@ -7,8 +7,6 @@ var testGenerator = testSteps(); function testSteps() { - const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore; - const name = this.window ? window.location.pathname : "Splendid Test"; const indexName = "My Test Index"; diff --git a/dom/indexedDB/test/unit/test_remove_objectStore.js b/dom/indexedDB/test/unit/test_remove_objectStore.js index f0bcaa6167ae..81366b122b31 100644 --- a/dom/indexedDB/test/unit/test_remove_objectStore.js +++ b/dom/indexedDB/test/unit/test_remove_objectStore.js @@ -7,8 +7,6 @@ var testGenerator = testSteps(); function testSteps() { - const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore; - const name = this.window ? window.location.pathname : "Splendid Test"; const objectStoreName = "Objects"; diff --git a/dom/webidl/IDBCursor.webidl b/dom/webidl/IDBCursor.webidl new file mode 100644 index 000000000000..97fb97802087 --- /dev/null +++ b/dom/webidl/IDBCursor.webidl @@ -0,0 +1,15 @@ +/* -*- Mode: IDL; 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/. + * + * The origin of this IDL file is + * https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBCursorDirection + */ + +enum IDBCursorDirection { + "next", + "nextunique", + "prev", + "prevunique" +}; diff --git a/dom/webidl/IDBIndex.webidl b/dom/webidl/IDBIndex.webidl new file mode 100644 index 000000000000..1a95c78aca94 --- /dev/null +++ b/dom/webidl/IDBIndex.webidl @@ -0,0 +1,14 @@ +/* -*- Mode: IDL; 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/. + * + * The origin of this IDL file is + * https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBIndexParameters + */ + +dictionary IDBIndexParameters { + boolean unique = false; + boolean multiEntry = false; +}; + diff --git a/dom/webidl/IDBObjectStore.webidl b/dom/webidl/IDBObjectStore.webidl new file mode 100644 index 000000000000..4f133e84d7c2 --- /dev/null +++ b/dom/webidl/IDBObjectStore.webidl @@ -0,0 +1,65 @@ +/* -*- Mode: IDL; 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/. + * + * The origin of this IDL file is + * https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBObjectStore + */ + +interface IDBRequest; +interface IDBIndex; + +interface IDBObjectStore { + readonly attribute DOMString name; + + [Throws] + readonly attribute any keyPath; + + [Throws] + readonly attribute DOMStringList indexNames; + readonly attribute IDBTransaction transaction; + readonly attribute boolean autoIncrement; + + [Throws] + IDBRequest put (any value, optional any key); + + [Throws] + IDBRequest add (any value, optional any key); + + [Throws] + IDBRequest delete (any key); + + [Throws] + IDBRequest get (any key); + + [Throws] + IDBRequest clear (); + + [Throws] + IDBRequest openCursor (optional any range, optional IDBCursorDirection direction = "next"); + + // Bug 899972 + // IDBIndex createIndex (DOMString name, (DOMString or sequence) keyPath, optional IDBIndexParameters optionalParameters); + + [Throws] + IDBIndex createIndex (DOMString name, DOMString keyPath, optional IDBIndexParameters optionalParameters); + + [Throws] + IDBIndex createIndex (DOMString name, sequence keyPath, optional IDBIndexParameters optionalParameters); + + [Throws] + IDBIndex index (DOMString name); + + [Throws] + void deleteIndex (DOMString indexName); + + [Throws] + IDBRequest count (optional any key); +}; + +partial interface IDBObjectStore { + // Success fires IDBTransactionEvent, result == array of values for given keys + [Throws] + IDBRequest mozGetAll (optional any key, optional unsigned long limit); +}; diff --git a/dom/webidl/IDBTransaction.webidl b/dom/webidl/IDBTransaction.webidl index bd42436b82f0..11df331d017f 100644 --- a/dom/webidl/IDBTransaction.webidl +++ b/dom/webidl/IDBTransaction.webidl @@ -8,8 +8,6 @@ * https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBTransactionMode */ -interface IDBObjectStore; - enum IDBTransactionMode { "readonly", "readwrite", diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index c4442e051f6c..5c86f859afef 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -164,9 +164,12 @@ webidl_files = \ HTMLTrackElement.webidl \ HTMLUListElement.webidl \ HTMLVideoElement.webidl \ + IDBCursor.webidl \ IDBDatabase.webidl \ IDBFactory.webidl \ IDBFileHandle.webidl \ + IDBIndex.webidl \ + IDBObjectStore.webidl \ IDBTransaction.webidl \ IDBVersionChangeEvent.webidl \ ImageData.webidl \ diff --git a/js/xpconnect/src/dictionary_helper_gen.conf b/js/xpconnect/src/dictionary_helper_gen.conf index fefb520e9393..ee90cdddc9ea 100644 --- a/js/xpconnect/src/dictionary_helper_gen.conf +++ b/js/xpconnect/src/dictionary_helper_gen.conf @@ -4,7 +4,6 @@ # Dictionary interface name, interface file name dictionaries = [ - [ 'IDBIndexParameters', 'nsIIDBObjectStore.idl' ], [ 'GeoPositionOptions', 'nsIDOMGeoGeolocation.idl' ], [ 'DOMFileMetadataParameters', 'nsIDOMLockedFile.idl' ], [ 'CameraSize', 'nsIDOMCameraManager.idl' ], diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index 1a6edc057408..6fc4e80bfbdd 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -89,7 +89,6 @@ members = [ 'nsIIDBDatabase.*', 'nsIIDBIndex.*', 'nsIIDBKeyRange.*', - 'nsIIDBObjectStore.*', 'nsIIDBRequest.*', 'nsIIDBOpenDBRequest.*', 'nsIIndexedDatabaseManager.*', diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index 9d30e008e759..f6fd9a555287 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -35,6 +35,7 @@ #include "XPCQuickStubs.h" #include "mozilla/dom/BindingUtils.h" +#include "mozilla/dom/IDBObjectStoreBinding.h" #include "mozilla/dom/IDBTransactionBinding.h" #include "mozilla/dom/IDBVersionChangeEventBinding.h" #include "mozilla/dom/TextDecoderBinding.h" @@ -544,7 +545,8 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext, MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL); // Init WebIDL binding constructors wanted on all XPConnect globals. - if (!IDBTransactionBinding::GetConstructorObject(aJSContext, global) || + if (!IDBObjectStoreBinding::GetConstructorObject(aJSContext, global) || + !IDBTransactionBinding::GetConstructorObject(aJSContext, global) || !IDBVersionChangeEventBinding::GetConstructorObject(aJSContext, global) || !TextDecoderBinding::GetConstructorObject(aJSContext, global) || !TextEncoderBinding::GetConstructorObject(aJSContext, global) || From 7d820ab021b199ffce92e4a79ba34cb4a9305657 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Wed, 31 Jul 2013 17:48:40 +0200 Subject: [PATCH 15/40] Bug 892065 - Move IDBIndex to WebIDL, r=janv --- addon-sdk/source/lib/sdk/indexed-db.js | 1 - addon-sdk/source/test/test-indexed-db.js | 4 +- dom/base/nsDOMClassInfo.cpp | 7 - dom/base/nsDOMClassInfoClasses.h | 1 - dom/bindings/Bindings.conf | 9 +- dom/indexedDB/IDBCursor.cpp | 23 -- dom/indexedDB/IDBCursor.h | 3 - dom/indexedDB/IDBIndex.cpp | 472 ++++++++++------------- dom/indexedDB/IDBIndex.h | 133 +++++-- dom/indexedDB/IDBObjectStore.cpp | 12 +- dom/indexedDB/IDBObjectStore.h | 11 +- dom/indexedDB/ipc/IndexedDBParent.cpp | 44 +-- dom/indexedDB/moz.build | 1 - dom/indexedDB/nsIIDBIndex.idl | 67 ---- dom/indexedDB/test/unit/head.js | 1 - dom/webidl/IDBIndex.webidl | 35 ++ dom/webidl/IDBObjectStore.webidl | 1 - js/xpconnect/src/dom_quickstubs.qsconf | 1 - js/xpconnect/src/nsXPConnect.cpp | 4 +- 19 files changed, 394 insertions(+), 436 deletions(-) delete mode 100644 dom/indexedDB/nsIIDBIndex.idl diff --git a/addon-sdk/source/lib/sdk/indexed-db.js b/addon-sdk/source/lib/sdk/indexed-db.js index b260f32a0dea..a6de686b1dc7 100644 --- a/addon-sdk/source/lib/sdk/indexed-db.js +++ b/addon-sdk/source/lib/sdk/indexed-db.js @@ -56,5 +56,4 @@ exports.DOMException = Ci.nsIDOMDOMException; exports.IDBCursor = Ci.nsIIDBCursor; exports.IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest; exports.IDBDatabase = Ci.nsIIDBDatabase; -exports.IDBIndex = Ci.nsIIDBIndex; exports.IDBRequest = Ci.nsIIDBRequest; diff --git a/addon-sdk/source/test/test-indexed-db.js b/addon-sdk/source/test/test-indexed-db.js index 1174b9544ae5..698f4ab9d30a 100644 --- a/addon-sdk/source/test/test-indexed-db.js +++ b/addon-sdk/source/test/test-indexed-db.js @@ -9,7 +9,7 @@ if (xulApp.versionInRange(xulApp.platformVersion, "16.0a1", "*")) { new function tests() { const { indexedDB, IDBKeyRange, DOMException, IDBCursor, - IDBOpenDBRequest, IDBDatabase, IDBIndex, IDBRequest + IDBOpenDBRequest, IDBDatabase, IDBRequest } = require("sdk/indexed-db"); exports["test indexedDB is frozen"] = function(assert){ @@ -23,7 +23,7 @@ exports["test indexedDB is frozen"] = function(assert){ exports["test db variables"] = function(assert) { [ indexedDB, IDBKeyRange, DOMException, IDBCursor, - IDBOpenDBRequest, IDBOpenDBRequest, IDBDatabase, IDBIndex, + IDBOpenDBRequest, IDBOpenDBRequest, IDBDatabase, IDBRequest ].forEach(function(value) { assert.notEqual(typeof(value), "undefined", "variable is defined"); diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index f42b2246af91..2f4b906f0663 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -206,7 +206,6 @@ #include "mozilla/dom/indexedDB/IDBDatabase.h" #include "mozilla/dom/indexedDB/IDBCursor.h" #include "mozilla/dom/indexedDB/IDBKeyRange.h" -#include "mozilla/dom/indexedDB/IDBIndex.h" using mozilla::dom::indexedDB::IDBWrapperCache; using mozilla::dom::workers::ResolveWorkerClasses; @@ -643,8 +642,6 @@ static nsDOMClassInfoData sClassInfoData[] = { DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(IDBKeyRange, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(IDBIndex, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(IDBOpenDBRequest, IDBEventTargetSH, IDBEVENTTARGET_SCRIPTABLE_FLAGS) @@ -1556,10 +1553,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIIDBKeyRange) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(IDBIndex, nsIIDBIndex) - DOM_CLASSINFO_MAP_ENTRY(nsIIDBIndex) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(IDBOpenDBRequest, nsIIDBOpenDBRequest) DOM_CLASSINFO_MAP_ENTRY(nsIIDBOpenDBRequest) DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest) diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index a27bf43bff05..2466a2bd3260 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -124,7 +124,6 @@ DOMCI_CLASS(IDBDatabase) DOMCI_CLASS(IDBCursor) DOMCI_CLASS(IDBCursorWithValue) DOMCI_CLASS(IDBKeyRange) -DOMCI_CLASS(IDBIndex) DOMCI_CLASS(IDBOpenDBRequest) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 838a9f1caa20..672cbd8b86d6 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -546,6 +546,14 @@ DOMInterfaces = { 'nativeType': 'mozilla::dom::indexedDB::IDBFileHandle', }, +'IDBIndex': { + 'nativeType': 'mozilla::dom::indexedDB::IDBIndex', + 'binaryNames': { + 'mozGetAll': 'getAll', + 'mozGetAllKeys': 'getAllKeys', + } +}, + 'IDBObjectStore': { 'nativeType': 'mozilla::dom::indexedDB::IDBObjectStore', 'implicitJSContext': [ 'createIndex' ], @@ -1668,7 +1676,6 @@ addExternalIface('FileCallback', nativeType='nsIFileCallback', headerFile='nsIDOMHTMLCanvasElement.h') addExternalIface('HitRegionOptions', nativeType='nsISupports') addExternalIface('IDBDatabase', nativeType='nsIIDBDatabase') -addExternalIface('IDBIndex', nativeType='nsIIDBIndex') addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest') addExternalIface('IDBRequest', nativeType='nsIIDBRequest') addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver') diff --git a/dom/indexedDB/IDBCursor.cpp b/dom/indexedDB/IDBCursor.cpp index 055e4834cd7f..86ddb5b8381d 100644 --- a/dom/indexedDB/IDBCursor.cpp +++ b/dom/indexedDB/IDBCursor.cpp @@ -272,29 +272,6 @@ IDBCursor::Create(IDBRequest* aRequest, return cursor.forget(); } -// static -nsresult -IDBCursor::ParseDirection(const nsAString& aDirection, Direction* aResult) -{ - if (aDirection.EqualsLiteral("next")) { - *aResult = NEXT; - } - else if (aDirection.EqualsLiteral("nextunique")) { - *aResult = NEXT_UNIQUE; - } - else if (aDirection.EqualsLiteral("prev")) { - *aResult = PREV; - } - else if (aDirection.EqualsLiteral("prevunique")) { - *aResult = PREV_UNIQUE; - } - else { - return NS_ERROR_TYPE_ERR; - } - - return NS_OK; -} - // static IDBCursor::Direction IDBCursor::ConvertDirection(mozilla::dom::IDBCursorDirection aDirection) diff --git a/dom/indexedDB/IDBCursor.h b/dom/indexedDB/IDBCursor.h index 96ce13788dd2..21e46d1b8a9e 100644 --- a/dom/indexedDB/IDBCursor.h +++ b/dom/indexedDB/IDBCursor.h @@ -116,9 +116,6 @@ public: return mRequest; } - static nsresult - ParseDirection(const nsAString& aDirection, Direction* aResult); - static Direction ConvertDirection(IDBCursorDirection aDirection); diff --git a/dom/indexedDB/IDBIndex.cpp b/dom/indexedDB/IDBIndex.cpp index 5b6df3d5baa8..3561c7d7ee4a 100644 --- a/dom/indexedDB/IDBIndex.cpp +++ b/dom/indexedDB/IDBIndex.cpp @@ -15,7 +15,6 @@ #include "mozilla/dom/ipc/Blob.h" #include "mozilla/storage.h" #include "nsContentUtils.h" -#include "nsDOMClassInfoID.h" #include "nsEventDispatcher.h" #include "nsThreadUtils.h" #include "xpcpublic.h" @@ -37,6 +36,7 @@ USING_INDEXEDDB_NAMESPACE using namespace mozilla::dom; using namespace mozilla::dom::indexedDB::ipc; +using mozilla::ErrorResult; namespace { @@ -406,6 +406,8 @@ IDBIndex::IDBIndex() mRooted(false) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + + SetIsDOMBinding(); } IDBIndex::~IDBIndex() @@ -425,26 +427,33 @@ IDBIndex::~IDBIndex() } } -nsresult -IDBIndex::GetInternal(IDBKeyRange* aKeyRange, - JSContext* aCx, - IDBRequest** _retval) +already_AddRefed +IDBIndex::GetInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); IDBTransaction* transaction = mObjectStore->Transaction(); if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new GetHelper(transaction, request, this, aKeyRange); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s).index(%s)." @@ -457,30 +466,36 @@ IDBIndex::GetInternal(IDBKeyRange* aKeyRange, IDB_PROFILER_STRING(ObjectStore()), IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange)); - request.forget(_retval); - return NS_OK; + return request.forget(); } -nsresult -IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange, - JSContext* aCx, - IDBRequest** _retval) +already_AddRefed +IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); IDBTransaction* transaction = mObjectStore->Transaction(); if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new GetKeyHelper(transaction, request, this, aKeyRange); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s).index(%s)." @@ -493,31 +508,37 @@ IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange, IDB_PROFILER_STRING(ObjectStore()), IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange)); - request.forget(_retval); - return NS_OK; + return request.forget(); } -nsresult -IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange, - uint32_t aLimit, - JSContext* aCx, - IDBRequest** _retval) +already_AddRefed +IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange, uint32_t aLimit, + ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); IDBTransaction* transaction = mObjectStore->Transaction(); if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new GetAllHelper(transaction, request, this, aKeyRange, aLimit); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s).index(%s)." @@ -531,31 +552,36 @@ IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange, IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange), aLimit); - request.forget(_retval); - return NS_OK; + return request.forget(); } -nsresult -IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange, - uint32_t aLimit, - JSContext* aCx, - IDBRequest** _retval) +already_AddRefed +IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit, + ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); IDBTransaction* transaction = mObjectStore->Transaction(); if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); } nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new GetAllKeysHelper(transaction, request, this, aKeyRange, aLimit); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s).index(%s)." @@ -569,30 +595,36 @@ IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange, IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange), aLimit); - request.forget(_retval); - return NS_OK; + return request.forget(); } -nsresult -IDBIndex::CountInternal(IDBKeyRange* aKeyRange, - JSContext* aCx, - IDBRequest** _retval) +already_AddRefed +IDBIndex::CountInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); IDBTransaction* transaction = mObjectStore->Transaction(); if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new CountHelper(transaction, request, this, aKeyRange); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s).index(%s)." @@ -605,34 +637,40 @@ IDBIndex::CountInternal(IDBKeyRange* aKeyRange, IDB_PROFILER_STRING(ObjectStore()), IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange)); - request.forget(_retval); - return NS_OK; + return request.forget(); } -nsresult -IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, - size_t aDirection, - JSContext* aCx, - IDBRequest** _retval) +already_AddRefed +IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection, + ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); IDBTransaction* transaction = mObjectStore->Transaction(); if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } IDBCursor::Direction direction = static_cast(aDirection); nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new OpenKeyCursorHelper(transaction, request, this, aKeyRange, direction); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Request %llu: " "database(%s).transaction(%s).objectStore(%s).index(%s)." @@ -646,8 +684,7 @@ IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange), IDB_PROFILER_STRING(direction)); - request.forget(_retval); - return NS_OK; + return request.forget(); } nsresult @@ -751,6 +788,7 @@ IDBIndex::OpenCursorFromChildProcess( } NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBIndex) + NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mCachedKeyPath) NS_IMPL_CYCLE_COLLECTION_TRACE_END @@ -760,6 +798,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBIndex) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBIndex) + NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER + // Don't unlink mObjectStore! tmp->mCachedKeyPath = JSVAL_VOID; @@ -771,316 +811,222 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBIndex) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBIndex) - NS_INTERFACE_MAP_ENTRY(nsIIDBIndex) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBIndex) + NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBIndex) NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBIndex) -DOMCI_DATA(IDBIndex, IDBIndex) - -NS_IMETHODIMP -IDBIndex::GetName(nsAString& aName) +JSObject* +IDBIndex::WrapObject(JSContext* aCx, JS::Handle aScope) { - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - aName.Assign(mName); - return NS_OK; + return IDBIndexBinding::Wrap(aCx, aScope, this); } -NS_IMETHODIMP -IDBIndex::GetStoreName(nsAString& aStoreName) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - aStoreName.Assign(mObjectStore->Name()); - return NS_OK; -} - -NS_IMETHODIMP -IDBIndex::GetKeyPath(JSContext* aCx, - jsval* aVal) +JS::Value +IDBIndex::GetKeyPath(JSContext* aCx, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (!JSVAL_IS_VOID(mCachedKeyPath)) { - *aVal = mCachedKeyPath; - return NS_OK; + return mCachedKeyPath; } - nsresult rv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath); - NS_ENSURE_SUCCESS(rv, rv); + aRv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath); + ENSURE_SUCCESS(aRv, JSVAL_VOID); if (JSVAL_IS_GCTHING(mCachedKeyPath)) { NS_HOLD_JS_OBJECTS(this, IDBIndex); mRooted = true; } - *aVal = mCachedKeyPath; - return NS_OK; + return mCachedKeyPath; } -NS_IMETHODIMP -IDBIndex::GetUnique(bool* aUnique) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - *aUnique = mUnique; - return NS_OK; -} - -NS_IMETHODIMP -IDBIndex::GetMultiEntry(bool* aMultiEntry) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - *aMultiEntry = mMultiEntry; - return NS_OK; -} - -NS_IMETHODIMP -IDBIndex::GetObjectStore(nsISupports** aObjectStore) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - nsCOMPtr objectStore(mObjectStore); - objectStore.forget(aObjectStore); - return NS_OK; -} - -NS_IMETHODIMP -IDBIndex::Get(const jsval& aKey, - JSContext* aCx, - nsIIDBRequest** _retval) +already_AddRefed +IDBIndex::Get(JSContext* aCx, JS::Handle aKey, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); IDBTransaction* transaction = mObjectStore->Transaction(); if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } nsRefPtr keyRange; - nsresult rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); - NS_ENSURE_SUCCESS(rv, rv); + aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); + ENSURE_SUCCESS(aRv, nullptr); + + if (!keyRange) { + // Must specify a key or keyRange for getKey(). + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR); + return nullptr; + } + + return GetInternal(keyRange, aRv); +} + +already_AddRefed +IDBIndex::GetKey(JSContext* aCx, JS::Handle aKey, ErrorResult& aRv) +{ + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + + IDBTransaction* transaction = mObjectStore->Transaction(); + if (!transaction->IsOpen()) { + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; + } + + nsRefPtr keyRange; + aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); + ENSURE_SUCCESS(aRv, nullptr); if (!keyRange) { // Must specify a key or keyRange for get(). - return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR); + return nullptr; } - nsRefPtr request; - rv = GetInternal(keyRange, aCx, getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, rv); - - request.forget(_retval); - return NS_OK; + return GetKeyInternal(keyRange, aRv); } -NS_IMETHODIMP -IDBIndex::GetKey(const jsval& aKey, - JSContext* aCx, - nsIIDBRequest** _retval) +already_AddRefed +IDBIndex::GetAll(JSContext* aCx, const Optional >& aKey, + const Optional& aLimit, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); IDBTransaction* transaction = mObjectStore->Transaction(); if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } nsRefPtr keyRange; - nsresult rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); - NS_ENSURE_SUCCESS(rv, rv); - - if (!keyRange) { - // Must specify a key or keyRange for get(). - return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; + if (aKey.WasPassed()) { + aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange)); + ENSURE_SUCCESS(aRv, nullptr); } - nsRefPtr request; - rv = GetKeyInternal(keyRange, aCx, getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, rv); + uint32_t limit = UINT32_MAX; + if (aLimit.WasPassed() && aLimit.Value() > 0) { + limit = aLimit.Value(); + } - request.forget(_retval); - return NS_OK; + return GetAllInternal(keyRange, limit, aRv); } -NS_IMETHODIMP -IDBIndex::GetAll(const jsval& aKey, - uint32_t aLimit, - JSContext* aCx, - uint8_t aOptionalArgCount, - nsIIDBRequest** _retval) +already_AddRefed +IDBIndex::GetAllKeys(JSContext* aCx, + const Optional >& aKey, + const Optional& aLimit, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); IDBTransaction* transaction = mObjectStore->Transaction(); if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } - nsresult rv; - nsRefPtr keyRange; - if (aOptionalArgCount) { - rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); - NS_ENSURE_SUCCESS(rv, rv); + if (aKey.WasPassed()) { + aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange)); + ENSURE_SUCCESS(aRv, nullptr); } - if (aOptionalArgCount < 2 || aLimit == 0) { - aLimit = UINT32_MAX; + uint32_t limit = UINT32_MAX; + if (aLimit.WasPassed() && aLimit.Value() > 0) { + limit = aLimit.Value(); } - nsRefPtr request; - rv = GetAllInternal(keyRange, aLimit, aCx, getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, rv); - - request.forget(_retval); - return NS_OK; + return GetAllKeysInternal(keyRange, limit, aRv); } -NS_IMETHODIMP -IDBIndex::GetAllKeys(const jsval& aKey, - uint32_t aLimit, - JSContext* aCx, - uint8_t aOptionalArgCount, - nsIIDBRequest** _retval) +already_AddRefed +IDBIndex::OpenCursor(JSContext* aCx, + const Optional >& aRange, + IDBCursorDirection aDirection, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); IDBTransaction* transaction = mObjectStore->Transaction(); if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } - nsresult rv; - nsRefPtr keyRange; - if (aOptionalArgCount) { - rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); - NS_ENSURE_SUCCESS(rv, rv); + if (aRange.WasPassed()) { + aRv = IDBKeyRange::FromJSVal(aCx, aRange.Value(), getter_AddRefs(keyRange)); + ENSURE_SUCCESS(aRv, nullptr); } - if (aOptionalArgCount < 2 || aLimit == 0) { - aLimit = UINT32_MAX; - } - - nsRefPtr request; - rv = GetAllKeysInternal(keyRange, aLimit, aCx, getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, rv); - - request.forget(_retval); - return NS_OK; -} - -NS_IMETHODIMP -IDBIndex::OpenCursor(const jsval& aKey, - const nsAString& aDirection, - JSContext* aCx, - uint8_t aOptionalArgCount, - nsIIDBRequest** _retval) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - IDBTransaction* transaction = mObjectStore->Transaction(); - if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; - } - - nsresult rv; - - IDBCursor::Direction direction = IDBCursor::NEXT; - - nsRefPtr keyRange; - if (aOptionalArgCount) { - rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); - NS_ENSURE_SUCCESS(rv, rv); - - if (aOptionalArgCount >= 2) { - rv = IDBCursor::ParseDirection(aDirection, &direction); - NS_ENSURE_SUCCESS(rv, rv); - } - } + IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection); nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!request) { + NS_WARNING("Failed to generate request!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } nsRefPtr helper = new OpenCursorHelper(transaction, request, this, keyRange, direction); - rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + nsresult rv = helper->DispatchToTransactionPool(); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } - request.forget(_retval); - return NS_OK; + return request.forget(); } -NS_IMETHODIMP -IDBIndex::OpenKeyCursor(const jsval& aKey, - const nsAString& aDirection, - JSContext* aCx, - uint8_t aOptionalArgCount, - nsIIDBRequest** _retval) +already_AddRefed +IDBIndex::OpenKeyCursor(JSContext* aCx, + const Optional >& aRange, + IDBCursorDirection aDirection, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); IDBTransaction* transaction = mObjectStore->Transaction(); if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } - nsresult rv; - - IDBCursor::Direction direction = IDBCursor::NEXT; - nsRefPtr keyRange; - if (aOptionalArgCount) { - rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); - NS_ENSURE_SUCCESS(rv, rv); - - if (aOptionalArgCount >= 2) { - rv = IDBCursor::ParseDirection(aDirection, &direction); - NS_ENSURE_SUCCESS(rv, rv); - } + if (aRange.WasPassed()) { + aRv = IDBKeyRange::FromJSVal(aCx, aRange.Value(), getter_AddRefs(keyRange)); + ENSURE_SUCCESS(aRv, nullptr); } - nsRefPtr request; - rv = OpenKeyCursorInternal(keyRange, direction, aCx, - getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, rv); + IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection); - request.forget(_retval); - return NS_OK; + return OpenKeyCursorInternal(keyRange, direction, aRv); } -NS_IMETHODIMP -IDBIndex::Count(const jsval& aKey, - JSContext* aCx, - uint8_t aOptionalArgCount, - nsIIDBRequest** _retval) +already_AddRefed +IDBIndex::Count(JSContext* aCx, const Optional >& aKey, + ErrorResult& aRv) { IDBTransaction* transaction = mObjectStore->Transaction(); if (!transaction->IsOpen()) { - return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR); + return nullptr; } - nsresult rv; - nsRefPtr keyRange; - if (aOptionalArgCount) { - rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange)); - NS_ENSURE_SUCCESS(rv, rv); + if (aKey.WasPassed()) { + aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange)); + ENSURE_SUCCESS(aRv, nullptr); } - nsRefPtr request; - rv = CountInternal(keyRange, aCx, getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, rv); - - request.forget(_retval); - return NS_OK; + return CountInternal(keyRange, aRv); } void diff --git a/dom/indexedDB/IDBIndex.h b/dom/indexedDB/IDBIndex.h index cf361bf20ffa..7cd28c66b2e1 100644 --- a/dom/indexedDB/IDBIndex.h +++ b/dom/indexedDB/IDBIndex.h @@ -8,11 +8,16 @@ #define mozilla_dom_indexeddb_idbindex_h__ #include "mozilla/dom/indexedDB/IndexedDatabase.h" -#include "mozilla/dom/indexedDB/KeyPath.h" - -#include "nsIIDBIndex.h" +#include "mozilla/Attributes.h" +#include "mozilla/dom/IDBCursorBinding.h" +#include "mozilla/ErrorResult.h" #include "nsCycleCollectionParticipant.h" +#include "nsWrapperCache.h" + +#include "mozilla/dom/indexedDB/IDBObjectStore.h" +#include "mozilla/dom/indexedDB/IDBRequest.h" +#include "mozilla/dom/indexedDB/KeyPath.h" class nsIScriptContext; class nsPIDOMWindow; @@ -30,12 +35,11 @@ class Key; struct IndexInfo; -class IDBIndex MOZ_FINAL : public nsIIDBIndex +class IDBIndex MOZ_FINAL : public nsISupports, + public nsWrapperCache { public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_NSIIDBINDEX - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBIndex) static already_AddRefed @@ -100,27 +104,27 @@ public: return mActorParent; } - nsresult GetInternal(IDBKeyRange* aKeyRange, - JSContext* aCx, - IDBRequest** _retval); + already_AddRefed + GetInternal(IDBKeyRange* aKeyRange, + ErrorResult& aRv); - nsresult GetKeyInternal(IDBKeyRange* aKeyRange, - JSContext* aCx, - IDBRequest** _retval); + already_AddRefed + GetKeyInternal(IDBKeyRange* aKeyRange, + ErrorResult& aRv); - nsresult GetAllInternal(IDBKeyRange* aKeyRange, - uint32_t aLimit, - JSContext* aCx, - IDBRequest** _retval); + already_AddRefed + GetAllInternal(IDBKeyRange* aKeyRange, + uint32_t aLimit, + ErrorResult& aRv); - nsresult GetAllKeysInternal(IDBKeyRange* aKeyRange, - uint32_t aLimit, - JSContext* aCx, - IDBRequest** _retval); + already_AddRefed + GetAllKeysInternal(IDBKeyRange* aKeyRange, + uint32_t aLimit, + ErrorResult& aRv); - nsresult CountInternal(IDBKeyRange* aKeyRange, - JSContext* aCx, - IDBRequest** _retval); + already_AddRefed + CountInternal(IDBKeyRange* aKeyRange, + ErrorResult& aRv); nsresult OpenCursorFromChildProcess( IDBRequest* aRequest, @@ -129,10 +133,10 @@ public: const Key& aObjectKey, IDBCursor** _retval); - nsresult OpenKeyCursorInternal(IDBKeyRange* aKeyRange, - size_t aDirection, - JSContext* aCx, - IDBRequest** _retval); + already_AddRefed + OpenKeyCursorInternal(IDBKeyRange* aKeyRange, + size_t aDirection, + ErrorResult& aRv); nsresult OpenCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection, @@ -147,6 +151,81 @@ public: nsTArray& aBlobs, IDBCursor** _retval); + // nsWrapperCache + virtual JSObject* + WrapObject(JSContext* aCx, JS::Handle aScope) MOZ_OVERRIDE; + + // WebIDL + IDBObjectStore* + GetParentObject() const + { + return mObjectStore; + } + + void + GetName(nsString& aName) const + { + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + aName.Assign(mName); + } + + IDBObjectStore* + ObjectStore() const + { + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + return mObjectStore; + } + + JS::Value + GetKeyPath(JSContext* aCx, ErrorResult& aRv); + + bool + MultiEntry() const + { + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + return mMultiEntry; + } + + bool + Unique() const + { + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + return mUnique; + } + + already_AddRefed + OpenCursor(JSContext* aCx, const Optional >& aRange, + IDBCursorDirection aDirection, ErrorResult& aRv); + + already_AddRefed + OpenKeyCursor(JSContext* aCx, const Optional >& aRange, + IDBCursorDirection aDirection, ErrorResult& aRv); + + already_AddRefed + Get(JSContext* aCx, JS::Handle aKey, ErrorResult& aRv); + + already_AddRefed + GetKey(JSContext* aCx, JS::Handle aKey, ErrorResult& aRv); + + already_AddRefed + Count(JSContext* aCx, const Optional >& aKey, + ErrorResult& aRv); + + void + GetStoreName(nsString& aStoreName) const + { + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + mObjectStore->GetName(aStoreName); + } + + already_AddRefed + GetAll(JSContext* aCx, const Optional >& aKey, + const Optional& aLimit, ErrorResult& aRv); + + already_AddRefed + GetAllKeys(JSContext* aCx, const Optional >& aKey, + const Optional& aLimit, ErrorResult& aRv); + private: IDBIndex(); ~IDBIndex(); diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp index 4eb7a3819827..3e238e28140a 100644 --- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -2293,7 +2293,7 @@ IDBObjectStore::SetInfo(ObjectStoreInfo* aInfo) mInfo = aInfo; } -already_AddRefed +already_AddRefed IDBObjectStore::CreateIndexInternal(const IndexInfo& aInfo, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); @@ -2338,7 +2338,7 @@ IDBObjectStore::CreateIndexInternal(const IndexInfo& aInfo, ErrorResult& aRv) return index.forget(); } -already_AddRefed +already_AddRefed IDBObjectStore::Index(const nsAString& aName, ErrorResult &aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); @@ -2400,7 +2400,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBObjectStore) for (uint32_t i = 0; i < tmp->mCreatedIndexes.Length(); i++) { NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mCreatedIndexes[i]"); - cb.NoteXPCOMChild(static_cast(tmp->mCreatedIndexes[i].get())); + cb.NoteXPCOMChild(static_cast(tmp->mCreatedIndexes[i].get())); } NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END @@ -2582,7 +2582,7 @@ IDBObjectStore::OpenCursor(JSContext* aCx, return OpenCursorInternal(keyRange, argDirection, aRv); } -already_AddRefed +already_AddRefed IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName, const nsAString& aKeyPath, const IDBIndexParameters& aOptionalParameters, @@ -2600,7 +2600,7 @@ IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName, return CreateIndex(aCx, aName, keyPath, aOptionalParameters, aRv); } -already_AddRefed +already_AddRefed IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName, const Sequence& aKeyPath, const IDBIndexParameters& aOptionalParameters, @@ -2622,7 +2622,7 @@ IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName, return CreateIndex(aCx, aName, keyPath, aOptionalParameters, aRv); } -already_AddRefed +already_AddRefed IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName, KeyPath& aKeyPath, const IDBIndexParameters& aOptionalParameters, diff --git a/dom/indexedDB/IDBObjectStore.h b/dom/indexedDB/IDBObjectStore.h index 7c0b87bab0fa..bd4fba9673b2 100644 --- a/dom/indexedDB/IDBObjectStore.h +++ b/dom/indexedDB/IDBObjectStore.h @@ -21,7 +21,6 @@ class nsIDOMBlob; class nsIScriptContext; class nsPIDOMWindow; -class nsIIDBIndex; namespace mozilla { namespace dom { @@ -199,7 +198,7 @@ public: return mActorParent; } - already_AddRefed + already_AddRefed CreateIndexInternal(const IndexInfo& aInfo, ErrorResult& aRv); @@ -313,16 +312,16 @@ public: OpenCursor(JSContext* aCx, const Optional >& aRange, IDBCursorDirection aDirection, ErrorResult& aRv); - already_AddRefed + already_AddRefed CreateIndex(JSContext* aCx, const nsAString& aName, const nsAString& aKeyPath, const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv); - already_AddRefed + already_AddRefed CreateIndex(JSContext* aCx, const nsAString& aName, const Sequence& aKeyPath, const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv); - already_AddRefed + already_AddRefed Index(const nsAString& aName, ErrorResult &aRv); void @@ -352,7 +351,7 @@ protected: const Optional >& aKey, bool aOverwrite, ErrorResult& aRv); - already_AddRefed + already_AddRefed CreateIndex(JSContext* aCx, const nsAString& aName, KeyPath& aKeyPath, const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv); diff --git a/dom/indexedDB/ipc/IndexedDBParent.cpp b/dom/indexedDB/ipc/IndexedDBParent.cpp index 2ba629da75e7..06e08357e28c 100644 --- a/dom/indexedDB/ipc/IndexedDBParent.cpp +++ b/dom/indexedDB/ipc/IndexedDBParent.cpp @@ -1150,10 +1150,9 @@ IndexedDBObjectStoreParent::RecvPIndexedDBIndexConstructor( AutoSetCurrentTransaction asct(mObjectStore->Transaction()); ErrorResult rv; - nsCOMPtr obj = mObjectStore->Index(name, rv); + index = mObjectStore->Index(name, rv); ENSURE_SUCCESS(rv, false); - index = static_cast(obj.get()); actor->SetIndex(index); } @@ -1298,10 +1297,8 @@ IndexedDBVersionChangeObjectStoreParent::RecvPIndexedDBIndexConstructor( AutoSetCurrentTransaction asct(mObjectStore->Transaction()); ErrorResult rv; - nsCOMPtr obj = mObjectStore->CreateIndexInternal(info, rv); + index = mObjectStore->CreateIndexInternal(info, rv); ENSURE_SUCCESS(rv, false); - - index = static_cast(obj.get()); } actor->SetIndex(index); @@ -1785,9 +1782,9 @@ IndexedDBIndexRequestParent::Get(const GetParams& aParams) { AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction()); - nsresult rv = mIndex->GetInternal(keyRange, nullptr, - getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + request = mIndex->GetInternal(keyRange, rv); + ENSURE_SUCCESS(rv, false); } request->SetActor(this); @@ -1810,9 +1807,9 @@ IndexedDBIndexRequestParent::GetKey(const GetKeyParams& aParams) { AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction()); - nsresult rv = mIndex->GetKeyInternal(keyRange, nullptr, - getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + request = mIndex->GetKeyInternal(keyRange, rv); + ENSURE_SUCCESS(rv, false); } request->SetActor(this); @@ -1849,9 +1846,9 @@ IndexedDBIndexRequestParent::GetAll(const GetAllParams& aParams) { AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction()); - nsresult rv = mIndex->GetAllInternal(keyRange, aParams.limit(), nullptr, - getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + request = mIndex->GetAllInternal(keyRange, aParams.limit(), rv); + ENSURE_SUCCESS(rv, false); } request->SetActor(this); @@ -1888,9 +1885,9 @@ IndexedDBIndexRequestParent::GetAllKeys(const GetAllKeysParams& aParams) { AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction()); - nsresult rv = mIndex->GetAllKeysInternal(keyRange, aParams.limit(), nullptr, - getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + request = mIndex->GetAllKeysInternal(keyRange, aParams.limit(), rv); + ENSURE_SUCCESS(rv, false); } request->SetActor(this); @@ -1927,9 +1924,9 @@ IndexedDBIndexRequestParent::Count(const CountParams& aParams) { AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction()); - nsresult rv = mIndex->CountInternal(keyRange, nullptr, - getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + request = mIndex->CountInternal(keyRange, rv); + ENSURE_SUCCESS(rv, false); } request->SetActor(this); @@ -2009,10 +2006,9 @@ IndexedDBIndexRequestParent::OpenKeyCursor(const OpenKeyCursorParams& aParams) { AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction()); - nsresult rv = - mIndex->OpenKeyCursorInternal(keyRange, direction, nullptr, - getter_AddRefs(request)); - NS_ENSURE_SUCCESS(rv, false); + ErrorResult rv; + request = mIndex->OpenKeyCursorInternal(keyRange, direction, rv); + ENSURE_SUCCESS(rv, false); } request->SetActor(this); diff --git a/dom/indexedDB/moz.build b/dom/indexedDB/moz.build index 30685271877b..5bc23eb40e6d 100644 --- a/dom/indexedDB/moz.build +++ b/dom/indexedDB/moz.build @@ -11,7 +11,6 @@ XPIDL_SOURCES += [ 'nsIIDBCursor.idl', 'nsIIDBCursorWithValue.idl', 'nsIIDBDatabase.idl', - 'nsIIDBIndex.idl', 'nsIIDBKeyRange.idl', 'nsIIDBOpenDBRequest.idl', 'nsIIDBRequest.idl', diff --git a/dom/indexedDB/nsIIDBIndex.idl b/dom/indexedDB/nsIIDBIndex.idl deleted file mode 100644 index 5dd1d9fc57cb..000000000000 --- a/dom/indexedDB/nsIIDBIndex.idl +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -interface nsIIDBRequest; - -/** - * IDBIndex interface. See - * http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-IDBIndex for more - * information. - */ -[scriptable, builtinclass, uuid(a859747a-0f05-4dfb-8f42-05c61415d4e4)] -interface nsIIDBIndex : nsISupports -{ - readonly attribute DOMString name; - - readonly attribute DOMString storeName; - - [implicit_jscontext] - readonly attribute jsval keyPath; - - readonly attribute boolean unique; - - readonly attribute boolean multiEntry; - - // This is a IDBObjectStore - readonly attribute nsISupports objectStore; - - [implicit_jscontext] - nsIIDBRequest - get(in jsval key); - - [implicit_jscontext] - nsIIDBRequest - getKey(in jsval key); - - [implicit_jscontext, optional_argc, binaryname(GetAll)] - nsIIDBRequest - mozGetAll([optional /* null */] in jsval key, - [optional /* unlimited */] in unsigned long limit); - - [implicit_jscontext, optional_argc, binaryname(GetAllKeys)] - nsIIDBRequest - mozGetAllKeys([optional /* null */] in jsval key, - [optional /* unlimited */] in unsigned long limit); - - // direction can be "next", "nextunique", "prev" or "prevunique" - [implicit_jscontext, optional_argc] - nsIIDBRequest - openCursor([optional /* null */] in jsval key, - [optional /* "next" */] in DOMString direction); - - // direction can be "next", "nextunique", "prev" or "prevunique" - [implicit_jscontext, optional_argc] - nsIIDBRequest - openKeyCursor([optional /* null */] in jsval key, - [optional /* "next" */] in DOMString direction); - - // Accepts null, a key value, or a nsIIDBKeyRange object. - [implicit_jscontext, optional_argc] - nsIIDBRequest - count([optional] in jsval key); -}; diff --git a/dom/indexedDB/test/unit/head.js b/dom/indexedDB/test/unit/head.js index 60d703234d28..f3f333155c4f 100644 --- a/dom/indexedDB/test/unit/head.js +++ b/dom/indexedDB/test/unit/head.js @@ -9,7 +9,6 @@ const DOMException = Ci.nsIDOMDOMException; const IDBCursor = Ci.nsIIDBCursor; const IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest; const IDBDatabase = Ci.nsIIDBDatabase -const IDBIndex = Ci.nsIIDBIndex const IDBRequest = Ci.nsIIDBRequest function is(a, b, msg) { diff --git a/dom/webidl/IDBIndex.webidl b/dom/webidl/IDBIndex.webidl index 1a95c78aca94..334cc2e66fd3 100644 --- a/dom/webidl/IDBIndex.webidl +++ b/dom/webidl/IDBIndex.webidl @@ -12,3 +12,38 @@ dictionary IDBIndexParameters { boolean multiEntry = false; }; +interface IDBIndex { + readonly attribute DOMString name; + readonly attribute IDBObjectStore objectStore; + + [Throws] + readonly attribute any keyPath; + + readonly attribute boolean multiEntry; + readonly attribute boolean unique; + + [Throws] + IDBRequest openCursor (optional any range, optional IDBCursorDirection direction = "next"); + + [Throws] + IDBRequest openKeyCursor (optional any range, optional IDBCursorDirection direction = "next"); + + [Throws] + IDBRequest get (any key); + + [Throws] + IDBRequest getKey (any key); + + [Throws] + IDBRequest count (optional any key); +}; + +partial interface IDBIndex { + readonly attribute DOMString storeName; + + [Throws] + IDBRequest mozGetAll (optional any key, optional unsigned long limit); + + [Throws] + IDBRequest mozGetAllKeys (optional any key, optional unsigned long limit); +}; diff --git a/dom/webidl/IDBObjectStore.webidl b/dom/webidl/IDBObjectStore.webidl index 4f133e84d7c2..f6c7eeeddf10 100644 --- a/dom/webidl/IDBObjectStore.webidl +++ b/dom/webidl/IDBObjectStore.webidl @@ -8,7 +8,6 @@ */ interface IDBRequest; -interface IDBIndex; interface IDBObjectStore { readonly attribute DOMString name; diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index 6fc4e80bfbdd..5fc188783156 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -87,7 +87,6 @@ members = [ 'nsIIDBCursor.*', 'nsIIDBCursorWithValue.*', 'nsIIDBDatabase.*', - 'nsIIDBIndex.*', 'nsIIDBKeyRange.*', 'nsIIDBRequest.*', 'nsIIDBOpenDBRequest.*', diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index f6fd9a555287..8c6a6b2cd77c 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -35,6 +35,7 @@ #include "XPCQuickStubs.h" #include "mozilla/dom/BindingUtils.h" +#include "mozilla/dom/IDBIndexBinding.h" #include "mozilla/dom/IDBObjectStoreBinding.h" #include "mozilla/dom/IDBTransactionBinding.h" #include "mozilla/dom/IDBVersionChangeEventBinding.h" @@ -545,7 +546,8 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext, MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL); // Init WebIDL binding constructors wanted on all XPConnect globals. - if (!IDBObjectStoreBinding::GetConstructorObject(aJSContext, global) || + if (!IDBIndexBinding::GetConstructorObject(aJSContext, global) || + !IDBObjectStoreBinding::GetConstructorObject(aJSContext, global) || !IDBTransactionBinding::GetConstructorObject(aJSContext, global) || !IDBVersionChangeEventBinding::GetConstructorObject(aJSContext, global) || !TextDecoderBinding::GetConstructorObject(aJSContext, global) || From af936eab73aba61a25b067fcbdc62747f670a404 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Wed, 31 Jul 2013 17:48:46 +0200 Subject: [PATCH 16/40] Bug 888596 - Move IDBDatabase to WebIDL, r=janv --- addon-sdk/source/lib/sdk/indexed-db.js | 1 - addon-sdk/source/test/test-indexed-db.js | 5 +- dom/base/nsDOMClassInfo.cpp | 8 - dom/base/nsDOMClassInfoClasses.h | 1 - dom/bindings/Bindings.conf | 5 +- dom/indexedDB/AsyncConnectionHelper.cpp | 2 +- dom/indexedDB/IDBDatabase.cpp | 311 +++++++----------- dom/indexedDB/IDBDatabase.h | 67 +++- dom/indexedDB/IDBFileHandle.cpp | 2 +- dom/indexedDB/IDBFileHandle.h | 7 +- dom/indexedDB/IDBTransaction.cpp | 2 +- dom/indexedDB/IDBTransaction.h | 6 +- dom/indexedDB/OpenDatabaseHelper.cpp | 2 +- dom/indexedDB/ipc/IndexedDBChild.cpp | 2 +- dom/indexedDB/ipc/IndexedDBParent.cpp | 79 ++--- dom/indexedDB/moz.build | 1 - dom/indexedDB/nsIIDBDatabase.idl | 55 ---- .../test/browser_permissionsPromptAllow.js | 4 +- .../test/browser_perwindow_privateBrowsing.js | 2 +- dom/indexedDB/test/unit/head.js | 1 - dom/quota/nsIOfflineStorage.h | 16 - dom/webidl/DummyBinding.webidl | 1 - dom/webidl/IDBDatabase.webidl | 41 ++- dom/webidl/IDBFileHandle.webidl | 2 - dom/webidl/IDBObjectStore.webidl | 6 + js/xpconnect/src/dom_quickstubs.qsconf | 1 - 26 files changed, 274 insertions(+), 356 deletions(-) delete mode 100644 dom/indexedDB/nsIIDBDatabase.idl diff --git a/addon-sdk/source/lib/sdk/indexed-db.js b/addon-sdk/source/lib/sdk/indexed-db.js index a6de686b1dc7..2eb7b1f53258 100644 --- a/addon-sdk/source/lib/sdk/indexed-db.js +++ b/addon-sdk/source/lib/sdk/indexed-db.js @@ -55,5 +55,4 @@ exports.IDBKeyRange = IDBKeyRange; exports.DOMException = Ci.nsIDOMDOMException; exports.IDBCursor = Ci.nsIIDBCursor; exports.IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest; -exports.IDBDatabase = Ci.nsIIDBDatabase; exports.IDBRequest = Ci.nsIIDBRequest; diff --git a/addon-sdk/source/test/test-indexed-db.js b/addon-sdk/source/test/test-indexed-db.js index 698f4ab9d30a..d413f22fe2e0 100644 --- a/addon-sdk/source/test/test-indexed-db.js +++ b/addon-sdk/source/test/test-indexed-db.js @@ -9,7 +9,7 @@ if (xulApp.versionInRange(xulApp.platformVersion, "16.0a1", "*")) { new function tests() { const { indexedDB, IDBKeyRange, DOMException, IDBCursor, - IDBOpenDBRequest, IDBDatabase, IDBRequest + IDBOpenDBRequest, IDBRequest } = require("sdk/indexed-db"); exports["test indexedDB is frozen"] = function(assert){ @@ -23,8 +23,7 @@ exports["test indexedDB is frozen"] = function(assert){ exports["test db variables"] = function(assert) { [ indexedDB, IDBKeyRange, DOMException, IDBCursor, - IDBOpenDBRequest, IDBOpenDBRequest, IDBDatabase, - IDBRequest + IDBOpenDBRequest, IDBOpenDBRequest, IDBRequest ].forEach(function(value) { assert.notEqual(typeof(value), "undefined", "variable is defined"); }); diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 2f4b906f0663..a403d98f3b39 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -203,7 +203,6 @@ #include "mozilla/dom/indexedDB/IDBWrapperCache.h" #include "mozilla/dom/indexedDB/IDBRequest.h" -#include "mozilla/dom/indexedDB/IDBDatabase.h" #include "mozilla/dom/indexedDB/IDBCursor.h" #include "mozilla/dom/indexedDB/IDBKeyRange.h" @@ -634,8 +633,6 @@ static nsDOMClassInfoData sClassInfoData[] = { NS_DEFINE_CLASSINFO_DATA(IDBRequest, IDBEventTargetSH, IDBEVENTTARGET_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(IDBDatabase, IDBEventTargetSH, - IDBEVENTTARGET_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(IDBCursor, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(IDBCursorWithValue, nsDOMGenericSH, @@ -1535,11 +1532,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(IDBDatabase, nsIIDBDatabase) - DOM_CLASSINFO_MAP_ENTRY(nsIIDBDatabase) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(IDBCursor, nsIIDBCursor) DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor) DOM_CLASSINFO_MAP_END diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 2466a2bd3260..d4b35761d384 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -120,7 +120,6 @@ DOMCI_CLASS(ChromeMessageBroadcaster) DOMCI_CLASS(ChromeMessageSender) DOMCI_CLASS(IDBRequest) -DOMCI_CLASS(IDBDatabase) DOMCI_CLASS(IDBCursor) DOMCI_CLASS(IDBCursorWithValue) DOMCI_CLASS(IDBKeyRange) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 672cbd8b86d6..47a12b841c1d 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -538,6 +538,10 @@ DOMInterfaces = { 'nativeType' : 'mozilla::dom::HTMLSharedListElement' }, +'IDBDatabase': { + 'nativeType': 'mozilla::dom::indexedDB::IDBDatabase', +}, + 'IDBFactory': { 'nativeType': 'mozilla::dom::indexedDB::IDBFactory', }, @@ -1675,7 +1679,6 @@ addExternalIface('File') addExternalIface('FileCallback', nativeType='nsIFileCallback', headerFile='nsIDOMHTMLCanvasElement.h') addExternalIface('HitRegionOptions', nativeType='nsISupports') -addExternalIface('IDBDatabase', nativeType='nsIIDBDatabase') addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest') addExternalIface('IDBRequest', nativeType='nsIIDBRequest') addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver') diff --git a/dom/indexedDB/AsyncConnectionHelper.cpp b/dom/indexedDB/AsyncConnectionHelper.cpp index 8f43b97f7bd2..02dd8b8bfa9d 100644 --- a/dom/indexedDB/AsyncConnectionHelper.cpp +++ b/dom/indexedDB/AsyncConnectionHelper.cpp @@ -173,7 +173,7 @@ AsyncConnectionHelper::~AsyncConnectionHelper() if (mainThread) { if (database) { - NS_ProxyRelease(mainThread, static_cast(database)); + NS_ProxyRelease(mainThread, static_cast(database)); } if (transaction) { NS_ProxyRelease(mainThread, static_cast(transaction)); diff --git a/dom/indexedDB/IDBDatabase.cpp b/dom/indexedDB/IDBDatabase.cpp index 7c9b6b719b5a..5ac96338985d 100644 --- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -43,6 +43,7 @@ using mozilla::dom::ContentParent; using mozilla::dom::quota::AssertIsOnIOThread; using mozilla::dom::quota::Client; using mozilla::dom::quota::QuotaManager; +using mozilla::ErrorResult; using namespace mozilla::dom; namespace { @@ -238,6 +239,8 @@ IDBDatabase::IDBDatabase() mRunningVersionChange(false) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + + SetIsDOMBinding(); } IDBDatabase::~IDBDatabase() @@ -401,10 +404,10 @@ IDBDatabase::OnUnlink() } } -nsresult +already_AddRefed IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction, const ObjectStoreInfoGuts& aInfo, - IDBObjectStore** _retval) + ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(aTransaction, "Null transaction!"); @@ -419,7 +422,8 @@ IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction, if (!databaseInfo->PutObjectStore(newInfo)) { NS_WARNING("Put failed!"); - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; } // Don't leave this in the hash if we fail below! @@ -427,14 +431,22 @@ IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction, nsRefPtr objectStore = aTransaction->GetOrCreateObjectStore(newInfo->name, newInfo, true); - NS_ENSURE_TRUE(objectStore, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!objectStore) { + NS_WARNING("Failed to get objectStore!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } if (IndexedDatabaseManager::IsMainProcess()) { nsRefPtr helper = new CreateObjectStoreHelper(aTransaction, objectStore); nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } } autoRemove.forget(); @@ -446,9 +458,7 @@ IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction, IDB_PROFILER_STRING(aTransaction), IDB_PROFILER_STRING(objectStore)); - objectStore.forget(_retval); - - return NS_OK; + return objectStore.forget(); } NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBDatabase, IDBWrapperCache) @@ -463,42 +473,29 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBDatabase, IDBWrapperCache) NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBDatabase) - NS_INTERFACE_MAP_ENTRY(nsIIDBDatabase) NS_INTERFACE_MAP_ENTRY(nsIFileStorage) NS_INTERFACE_MAP_ENTRY(nsIOfflineStorage) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBDatabase) NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache) NS_IMPL_ADDREF_INHERITED(IDBDatabase, IDBWrapperCache) NS_IMPL_RELEASE_INHERITED(IDBDatabase, IDBWrapperCache) -DOMCI_DATA(IDBDatabase, IDBDatabase) - -NS_IMPL_EVENT_HANDLER(IDBDatabase, abort) -NS_IMPL_EVENT_HANDLER(IDBDatabase, error) -NS_IMPL_EVENT_HANDLER(IDBDatabase, versionchange) - -NS_IMETHODIMP -IDBDatabase::GetName(nsAString& aName) +JSObject* +IDBDatabase::WrapObject(JSContext* aCx, JS::Handle aScope) { - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - aName.Assign(mName); - return NS_OK; + return IDBDatabaseBinding::Wrap(aCx, aScope, this); } -NS_IMETHODIMP -IDBDatabase::GetVersion(uint64_t* aVersion) +uint64_t +IDBDatabase::Version() const { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - DatabaseInfo* info = Info(); - *aVersion = info->version; - - return NS_OK; + return info->version; } -NS_IMETHODIMP -IDBDatabase::GetObjectStoreNames(nsIDOMDOMStringList** aObjectStores) +already_AddRefed +IDBDatabase::GetObjectStoreNames(ErrorResult& aRv) const { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); @@ -507,25 +504,28 @@ IDBDatabase::GetObjectStoreNames(nsIDOMDOMStringList** aObjectStores) nsAutoTArray objectStoreNames; if (!info->GetObjectStoreNames(objectStoreNames)) { NS_WARNING("Couldn't get names!"); - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; } nsRefPtr list(new nsDOMStringList()); uint32_t count = objectStoreNames.Length(); for (uint32_t index = 0; index < count; index++) { - NS_ENSURE_TRUE(list->Add(objectStoreNames[index]), - NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (!list->Add(objectStoreNames[index])) { + NS_WARNING("Failed to add element"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } } - list.forget(aObjectStores); - return NS_OK; + return list.forget(); } -NS_IMETHODIMP -IDBDatabase::CreateObjectStore(const nsAString& aName, - const jsval& aOptions, - JSContext* aCx, - nsISupports** _retval) +already_AddRefed +IDBDatabase::CreateObjectStore( + JSContext* aCx, const nsAString& aName, + const IDBObjectStoreParameters& aOptionalParameters, + ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); @@ -533,28 +533,26 @@ IDBDatabase::CreateObjectStore(const nsAString& aName, if (!transaction || transaction->GetMode() != IDBTransaction::VERSION_CHANGE) { - return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); + return nullptr; } DatabaseInfo* databaseInfo = transaction->DBInfo(); - RootedDictionary params(aCx); - JS::Rooted options(aCx, aOptions); - if (!params.Init(aCx, options)) { - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; - } - KeyPath keyPath(0); - if (NS_FAILED(KeyPath::Parse(aCx, params.mKeyPath, &keyPath))) { - return NS_ERROR_DOM_SYNTAX_ERR; + if (NS_FAILED(KeyPath::Parse(aCx, aOptionalParameters.mKeyPath, &keyPath))) { + aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR); + return nullptr; } if (databaseInfo->ContainsStoreName(aName)) { - return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR); + return nullptr; } - if (!keyPath.IsAllowedForObjectStore(params.mAutoIncrement)) { - return NS_ERROR_DOM_INVALID_ACCESS_ERR; + if (!keyPath.IsAllowedForObjectStore(aOptionalParameters.mAutoIncrement)) { + aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); + return nullptr; } ObjectStoreInfoGuts guts; @@ -562,19 +560,13 @@ IDBDatabase::CreateObjectStore(const nsAString& aName, guts.name = aName; guts.id = databaseInfo->nextObjectStoreId++; guts.keyPath = keyPath; - guts.autoIncrement = params.mAutoIncrement; + guts.autoIncrement = aOptionalParameters.mAutoIncrement; - nsRefPtr objectStore; - nsresult rv = CreateObjectStoreInternal(transaction, guts, - getter_AddRefs(objectStore)); - NS_ENSURE_SUCCESS(rv, rv); - - objectStore.forget(_retval); - return NS_OK; + return CreateObjectStoreInternal(transaction, guts, aRv); } -NS_IMETHODIMP -IDBDatabase::DeleteObjectStore(const nsAString& aName) +void +IDBDatabase::DeleteObjectStore(const nsAString& aName, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); @@ -582,23 +574,27 @@ IDBDatabase::DeleteObjectStore(const nsAString& aName) if (!transaction || transaction->GetMode() != IDBTransaction::VERSION_CHANGE) { - return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); + return; } DatabaseInfo* info = transaction->DBInfo(); ObjectStoreInfo* objectStoreInfo = info->GetObjectStore(aName); if (!objectStoreInfo) { - return NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR); + return; } - nsresult rv; - if (IndexedDatabaseManager::IsMainProcess()) { nsRefPtr helper = new DeleteObjectStoreHelper(transaction, objectStoreInfo->id); - rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + nsresult rv = helper->DispatchToTransactionPool(); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return; + } } else { IndexedDBTransactionChild* actor = transaction->GetActorChild(); @@ -615,188 +611,114 @@ IDBDatabase::DeleteObjectStore(const nsAString& aName) IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(transaction), NS_ConvertUTF16toUTF8(aName).get()); - - return NS_OK; } -NS_IMETHODIMP -IDBDatabase::Transaction(const jsval& aStoreNames, - const nsAString& aMode, - JSContext* aCx, - uint8_t aOptionalArgCount, - nsISupports** _retval) +already_AddRefed +IDBDatabase::Transaction(const Sequence& aStoreNames, + IDBTransactionMode aMode, ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (QuotaManager::IsShuttingDown()) { - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; } if (mClosed) { - return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); + return nullptr; } if (mRunningVersionChange) { - return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); + return nullptr; + } + + if (aStoreNames.IsEmpty()) { + aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR); + return nullptr; } IDBTransaction::Mode transactionMode = IDBTransaction::READ_ONLY; - if (aOptionalArgCount) { - if (aMode.EqualsLiteral("readwrite")) { + switch (aMode) { + case IDBTransactionMode::Readonly: + transactionMode = IDBTransaction::READ_ONLY; + break; + case IDBTransactionMode::Readwrite: transactionMode = IDBTransaction::READ_WRITE; - } - else if (!aMode.EqualsLiteral("readonly")) { - return NS_ERROR_TYPE_ERR; - } - } - - nsresult rv; - nsTArray storesToOpen; - - if (!JSVAL_IS_PRIMITIVE(aStoreNames)) { - JS::Rooted obj(aCx, JSVAL_TO_OBJECT(aStoreNames)); - - // See if this is a JS array. - if (JS_IsArrayObject(aCx, obj)) { - uint32_t length; - if (!JS_GetArrayLength(aCx, obj, &length)) { - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; - } - - if (!length) { - return NS_ERROR_DOM_INVALID_ACCESS_ERR; - } - - storesToOpen.SetCapacity(length); - - for (uint32_t index = 0; index < length; index++) { - JS::Rooted val(aCx); - JSString* jsstr; - nsDependentJSString str; - if (!JS_GetElement(aCx, obj, index, val.address()) || - !(jsstr = JS_ValueToString(aCx, val)) || - !str.init(aCx, jsstr)) { - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; - } - - storesToOpen.AppendElement(str); - } - - NS_ASSERTION(!storesToOpen.IsEmpty(), - "Must have something here or else code below will " - "misbehave!"); - } - else { - // Perhaps some kind of wrapped object? - nsIXPConnect* xpc = nsContentUtils::XPConnect(); - NS_ASSERTION(xpc, "This should never be null!"); - - nsCOMPtr wrapper; - rv = xpc->GetWrappedNativeOfJSObject(aCx, obj, getter_AddRefs(wrapper)); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - if (wrapper) { - nsISupports* wrappedObject = wrapper->Native(); - NS_ENSURE_TRUE(wrappedObject, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - // We only accept DOMStringList. - nsCOMPtr list = do_QueryInterface(wrappedObject); - if (list) { - uint32_t length; - rv = list->GetLength(&length); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - if (!length) { - return NS_ERROR_DOM_INVALID_ACCESS_ERR; - } - - storesToOpen.SetCapacity(length); - - for (uint32_t index = 0; index < length; index++) { - nsString* item = storesToOpen.AppendElement(); - NS_ASSERTION(item, "This should never fail!"); - - rv = list->Item(index, *item); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - } - - NS_ASSERTION(!storesToOpen.IsEmpty(), - "Must have something here or else code below will " - "misbehave!"); - } - } - } - } - - // If our list is empty here then the argument must have been an object that - // we don't support or a primitive. Either way we convert to a string. - if (storesToOpen.IsEmpty()) { - JSString* jsstr; - nsDependentJSString str; - if (!(jsstr = JS_ValueToString(aCx, aStoreNames)) || - !str.init(aCx, jsstr)) { - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; - } - - storesToOpen.AppendElement(str); + break; + case IDBTransactionMode::Versionchange: + transactionMode = IDBTransaction::VERSION_CHANGE; + break; + default: + MOZ_CRASH("Unknown mode!"); } // Now check to make sure the object store names we collected actually exist. DatabaseInfo* info = Info(); - for (uint32_t index = 0; index < storesToOpen.Length(); index++) { - if (!info->ContainsStoreName(storesToOpen[index])) { - return NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR; + for (uint32_t index = 0; index < aStoreNames.Length(); index++) { + if (!info->ContainsStoreName(aStoreNames[index])) { + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR); + return nullptr; } } nsRefPtr transaction = - IDBTransaction::Create(this, storesToOpen, transactionMode, false); - NS_ENSURE_TRUE(transaction, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + IDBTransaction::Create(this, aStoreNames, transactionMode, false); + if (!transaction) { + NS_WARNING("Failed to create the transaction!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } IDB_PROFILER_MARK("IndexedDB Transaction %llu: database(%s).transaction(%s)", "IDBTransaction[%llu] MT Started", transaction->GetSerialNumber(), IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(transaction)); - nsRefPtr tmp = transaction.get(); - tmp.forget(_retval); - return NS_OK; + return transaction.forget(); } -NS_IMETHODIMP +already_AddRefed IDBDatabase::MozCreateFileHandle(const nsAString& aName, - const nsAString& aType, - JSContext* aCx, - nsIIDBRequest** _retval) + const Optional& aType, + ErrorResult& aRv) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); if (!IndexedDatabaseManager::IsMainProcess()) { NS_WARNING("Not supported yet!"); - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; } if (QuotaManager::IsShuttingDown()) { - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; } if (mClosed) { - return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR); + return nullptr; } nsRefPtr request = IDBRequest::Create(nullptr, this, nullptr); nsRefPtr helper = - new CreateFileHelper(this, request, aName, aType); + new CreateFileHelper(this, request, aName, + aType.WasPassed() ? aType.Value() : EmptyString()); QuotaManager* quotaManager = QuotaManager::Get(); NS_ASSERTION(quotaManager, "We should definitely have a manager here"); nsresult rv = helper->Dispatch(quotaManager->IOThread()); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to dispatch!"); + aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + return nullptr; + } - request.forget(_retval); - return NS_OK; + return request.forget(); } NS_IMETHODIMP @@ -807,6 +729,7 @@ IDBDatabase::Close() CloseInternal(false); NS_ASSERTION(mClosed, "Should have set the closed flag!"); + return NS_OK; } diff --git a/dom/indexedDB/IDBDatabase.h b/dom/indexedDB/IDBDatabase.h index eee58a08946f..3fc702eeacaf 100644 --- a/dom/indexedDB/IDBDatabase.h +++ b/dom/indexedDB/IDBDatabase.h @@ -7,17 +7,19 @@ #ifndef mozilla_dom_indexeddb_idbdatabase_h__ #define mozilla_dom_indexeddb_idbdatabase_h__ -#include "mozilla/Attributes.h" #include "mozilla/dom/indexedDB/IndexedDatabase.h" #include "nsIDocument.h" #include "nsIFileStorage.h" -#include "nsIIDBDatabase.h" #include "nsIOfflineStorage.h" +#include "mozilla/Attributes.h" +#include "mozilla/dom/IDBObjectStoreBinding.h" +#include "mozilla/dom/IDBTransactionBinding.h" #include "nsDOMEventTargetHelper.h" #include "mozilla/dom/indexedDB/FileManager.h" +#include "mozilla/dom/indexedDB/IDBRequest.h" #include "mozilla/dom/indexedDB/IDBWrapperCache.h" class nsIScriptContext; @@ -46,7 +48,6 @@ class IndexedDBDatabaseParent; struct ObjectStoreInfoGuts; class IDBDatabase : public IDBWrapperCache, - public nsIIDBDatabase, public nsIOfflineStorage { friend class AsyncConnectionHelper; @@ -55,9 +56,8 @@ class IDBDatabase : public IDBWrapperCache, public: NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIIDBDATABASE NS_DECL_NSIFILESTORAGE - NS_DECL_NSIOFFLINESTORAGE_NOCLOSE + NS_DECL_NSIOFFLINESTORAGE NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBDatabase, IDBWrapperCache) @@ -156,10 +156,63 @@ public: return mContentParent; } - nsresult + already_AddRefed CreateObjectStoreInternal(IDBTransaction* aTransaction, const ObjectStoreInfoGuts& aInfo, - IDBObjectStore** _retval); + ErrorResult& aRv); + + // nsWrapperCache + virtual JSObject* + WrapObject(JSContext* aCx, JS::Handle aScope) MOZ_OVERRIDE; + + // WebIDL + nsPIDOMWindow* + GetParentObject() const + { + return GetOwner(); + } + + void + GetName(nsString& aName) const + { + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + aName.Assign(mName); + } + + uint64_t + Version() const; + + already_AddRefed + GetObjectStoreNames(ErrorResult& aRv) const; + + already_AddRefed + CreateObjectStore(JSContext* aCx, const nsAString& aName, + const IDBObjectStoreParameters& aOptionalParameters, + ErrorResult& aRv); + + void + DeleteObjectStore(const nsAString& name, ErrorResult& aRv); + + already_AddRefed + Transaction(const nsAString& aStoreName, IDBTransactionMode aMode, + ErrorResult& aRv) + { + Sequence list; + list.AppendElement(aStoreName); + return Transaction(list, aMode, aRv); + } + + already_AddRefed + Transaction(const Sequence& aStoreNames, IDBTransactionMode aMode, + ErrorResult& aRv); + + IMPL_EVENT_HANDLER(abort) + IMPL_EVENT_HANDLER(error) + IMPL_EVENT_HANDLER(versionchange) + + already_AddRefed + MozCreateFileHandle(const nsAString& aName, const Optional& aType, + ErrorResult& aRv); virtual void LastRelease() MOZ_OVERRIDE; private: diff --git a/dom/indexedDB/IDBFileHandle.cpp b/dom/indexedDB/IDBFileHandle.cpp index 4c17370afd5e..c9061b554bb1 100644 --- a/dom/indexedDB/IDBFileHandle.cpp +++ b/dom/indexedDB/IDBFileHandle.cpp @@ -106,7 +106,7 @@ IDBFileHandle::CreateFileObject(mozilla::dom::file::LockedFile* aLockedFile, return file.forget(); } -nsIIDBDatabase* +IDBDatabase* IDBFileHandle::Database() { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); diff --git a/dom/indexedDB/IDBFileHandle.h b/dom/indexedDB/IDBFileHandle.h index a15922fc09aa..94951aa18cc9 100644 --- a/dom/indexedDB/IDBFileHandle.h +++ b/dom/indexedDB/IDBFileHandle.h @@ -12,10 +12,10 @@ #include "mozilla/dom/file/FileHandle.h" #include "mozilla/dom/indexedDB/FileInfo.h" -class nsIIDBDatabase; - BEGIN_INDEXEDDB_NAMESPACE +class IDBDatabase; + class IDBFileHandle : public mozilla::dom::file::FileHandle { public: @@ -45,7 +45,8 @@ public: CreateFileObject(mozilla::dom::file::LockedFile* aLockedFile, uint32_t aFileSize); - nsIIDBDatabase* Database(); + IDBDatabase* + Database(); private: IDBFileHandle() diff --git a/dom/indexedDB/IDBTransaction.cpp b/dom/indexedDB/IDBTransaction.cpp index 627a81f2a931..4823b4c763d2 100644 --- a/dom/indexedDB/IDBTransaction.cpp +++ b/dom/indexedDB/IDBTransaction.cpp @@ -92,7 +92,7 @@ NS_IMPL_QUERY_INTERFACE1(StartTransactionRunnable, nsIRunnable) // static already_AddRefed IDBTransaction::CreateInternal(IDBDatabase* aDatabase, - nsTArray& aObjectStoreNames, + const Sequence& aObjectStoreNames, Mode aMode, bool aDispatchDelayed, bool aIsVersionChangeTransactionChild) diff --git a/dom/indexedDB/IDBTransaction.h b/dom/indexedDB/IDBTransaction.h index 05c1f1d288be..1c18bd5867bc 100644 --- a/dom/indexedDB/IDBTransaction.h +++ b/dom/indexedDB/IDBTransaction.h @@ -89,7 +89,7 @@ public: static already_AddRefed Create(IDBDatabase* aDatabase, - nsTArray& aObjectStoreNames, + const Sequence& aObjectStoreNames, Mode aMode, bool aDispatchDelayed) { @@ -230,7 +230,7 @@ public: IDBTransactionMode GetMode(ErrorResult& aRv) const; - nsIIDBDatabase* + IDBDatabase* Db() const { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); @@ -265,7 +265,7 @@ private: // Should only be called directly through IndexedDBDatabaseChild. static already_AddRefed CreateInternal(IDBDatabase* aDatabase, - nsTArray& aObjectStoreNames, + const Sequence& aObjectStoreNames, Mode aMode, bool aDispatchDelayed, bool aIsVersionChangeTransactionChild); diff --git a/dom/indexedDB/OpenDatabaseHelper.cpp b/dom/indexedDB/OpenDatabaseHelper.cpp index 6294a74a8ecc..57f80bee2c07 100644 --- a/dom/indexedDB/OpenDatabaseHelper.cpp +++ b/dom/indexedDB/OpenDatabaseHelper.cpp @@ -2059,7 +2059,7 @@ OpenDatabaseHelper::StartSetVersion() nsresult rv = EnsureSuccessResult(); NS_ENSURE_SUCCESS(rv, rv); - nsTArray storesToOpen; + Sequence storesToOpen; nsRefPtr transaction = IDBTransaction::Create(mDatabase, storesToOpen, IDBTransaction::VERSION_CHANGE, true); diff --git a/dom/indexedDB/ipc/IndexedDBChild.cpp b/dom/indexedDB/ipc/IndexedDBChild.cpp index ff4d03f8e8ef..561eaa1474c2 100644 --- a/dom/indexedDB/ipc/IndexedDBChild.cpp +++ b/dom/indexedDB/ipc/IndexedDBChild.cpp @@ -508,7 +508,7 @@ IndexedDBDatabaseChild::RecvPIndexedDBTransactionConstructor( nsRefPtr helper = new IPCOpenDatabaseHelper(mDatabase, mRequest); - nsTArray storesToOpen; + Sequence storesToOpen; nsRefPtr transaction = IDBTransaction::CreateInternal(mDatabase, storesToOpen, IDBTransaction::VERSION_CHANGE, false, true); diff --git a/dom/indexedDB/ipc/IndexedDBParent.cpp b/dom/indexedDB/ipc/IndexedDBParent.cpp index 06e08357e28c..c41a52662e99 100644 --- a/dom/indexedDB/ipc/IndexedDBParent.cpp +++ b/dom/indexedDB/ipc/IndexedDBParent.cpp @@ -2,30 +2,34 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ + #include "IndexedDBParent.h" -#include "AsyncConnectionHelper.h" +#include "nsIDOMEvent.h" +#include "nsIDOMFile.h" +#include "nsIXPConnect.h" + #include "mozilla/AppProcessChecker.h" #include "mozilla/Assertions.h" #include "mozilla/Attributes.h" #include "mozilla/dom/ContentParent.h" -#include "mozilla/dom/indexedDB/DatabaseInfo.h" -#include "mozilla/dom/indexedDB/IDBDatabase.h" -#include "mozilla/dom/indexedDB/IDBEvents.h" -#include "mozilla/dom/indexedDB/IDBFactory.h" -#include "mozilla/dom/indexedDB/IDBIndex.h" -#include "mozilla/dom/indexedDB/IDBKeyRange.h" -#include "mozilla/dom/indexedDB/IDBObjectStore.h" -#include "mozilla/dom/indexedDB/IDBTransaction.h" +#include "mozilla/dom/IDBDatabaseBinding.h" #include "mozilla/dom/ipc/Blob.h" #include "mozilla/dom/TabParent.h" #include "mozilla/unused.h" #include "mozilla/Util.h" #include "nsContentUtils.h" #include "nsCxPusher.h" -#include "nsIDOMEvent.h" -#include "nsIDOMFile.h" -#include "nsIXPConnect.h" + +#include "AsyncConnectionHelper.h" +#include "DatabaseInfo.h" +#include "IDBDatabase.h" +#include "IDBEvents.h" +#include "IDBFactory.h" +#include "IDBIndex.h" +#include "IDBKeyRange.h" +#include "IDBObjectStore.h" +#include "IDBTransaction.h" #define CHROME_ORIGIN "chrome" #define PERMISSION_PREFIX "indexedDB-chrome-" @@ -377,9 +381,6 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent, return NS_OK; } - nsIXPConnect* xpc = nsContentUtils::XPConnect(); - MOZ_ASSERT(xpc); - AutoSafeJSContext cx; JS::Rooted result(cx); @@ -388,20 +389,14 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent, MOZ_ASSERT(!JSVAL_IS_PRIMITIVE(result)); - nsCOMPtr wrapper; - rv = xpc->GetWrappedNativeOfJSObject(cx, JSVAL_TO_OBJECT(result), - getter_AddRefs(wrapper)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr database; - if (!wrapper || !(database = do_QueryInterface(wrapper->Native()))) { + IDBDatabase *database; + rv = UnwrapObject(cx, &result.toObject(), database); + if (NS_FAILED(rv)) { NS_WARNING("Didn't get the object we expected!"); - return NS_ERROR_FAILURE; + return rv; } - IDBDatabase* databaseConcrete = static_cast(database.get()); - - DatabaseInfo* dbInfo = databaseConcrete->Info(); + DatabaseInfo* dbInfo = database->Info(); MOZ_ASSERT(dbInfo); nsAutoTArray objectStoreNames; @@ -427,8 +422,7 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent, nsRefPtr request; mOpenRequest.swap(request); - EventTarget* target = - static_cast(databaseConcrete); + EventTarget* target = static_cast(database); #ifdef DEBUG { @@ -447,11 +441,11 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent, return NS_ERROR_FAILURE; } - MOZ_ASSERT(!mDatabase || mDatabase == databaseConcrete); + MOZ_ASSERT(!mDatabase || mDatabase == database); if (!mDatabase) { - databaseConcrete->SetActor(this); - mDatabase = databaseConcrete; + database->SetActor(this); + mDatabase = database; } return NS_OK; @@ -464,7 +458,7 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent, AsyncConnectionHelper::GetCurrentTransaction(); MOZ_ASSERT(transaction); - if (!CheckWritePermission(databaseConcrete->Name())) { + if (!CheckWritePermission(database->Name())) { // If we get here then the child process is either dead or in the process // of being killed. Abort the transaction now to prevent any changes to // the database. @@ -497,8 +491,8 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent, return NS_ERROR_FAILURE; } - databaseConcrete->SetActor(this); - mDatabase = databaseConcrete; + database->SetActor(this); + mDatabase = database; return NS_OK; } @@ -600,7 +594,7 @@ IndexedDBDatabaseParent::RecvPIndexedDBTransactionConstructor( return true; } - nsTArray storesToOpen; + Sequence storesToOpen; storesToOpen.AppendElements(params.names()); nsRefPtr transaction = @@ -870,16 +864,14 @@ IndexedDBVersionChangeTransactionParent::RecvDeleteObjectStore( IDBDatabase* db = mTransaction->Database(); MOZ_ASSERT(db); - nsresult rv; + ErrorResult rv; { AutoSetCurrentTransaction asct(mTransaction); - - rv = db->DeleteObjectStore(aName); + db->DeleteObjectStore(aName, rv); } - NS_ENSURE_SUCCESS(rv, false); - + ENSURE_SUCCESS(rv, false); return true; } @@ -920,16 +912,15 @@ IndexedDBVersionChangeTransactionParent::RecvPIndexedDBObjectStoreConstructor( nsRefPtr objectStore; - nsresult rv; + ErrorResult rv; { AutoSetCurrentTransaction asct(mTransaction); - rv = db->CreateObjectStoreInternal(mTransaction, info, - getter_AddRefs(objectStore)); + objectStore = db->CreateObjectStoreInternal(mTransaction, info, rv); } - NS_ENSURE_SUCCESS(rv, false); + ENSURE_SUCCESS(rv, false); actor->SetObjectStore(objectStore); objectStore->SetActor(actor); diff --git a/dom/indexedDB/moz.build b/dom/indexedDB/moz.build index 5bc23eb40e6d..b7d0ae6cdc45 100644 --- a/dom/indexedDB/moz.build +++ b/dom/indexedDB/moz.build @@ -10,7 +10,6 @@ TEST_DIRS += ['test'] XPIDL_SOURCES += [ 'nsIIDBCursor.idl', 'nsIIDBCursorWithValue.idl', - 'nsIIDBDatabase.idl', 'nsIIDBKeyRange.idl', 'nsIIDBOpenDBRequest.idl', 'nsIIDBRequest.idl', diff --git a/dom/indexedDB/nsIIDBDatabase.idl b/dom/indexedDB/nsIIDBDatabase.idl deleted file mode 100644 index 54ab80ea433a..000000000000 --- a/dom/indexedDB/nsIIDBDatabase.idl +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -interface nsIIDBRequest; -interface nsIDOMDOMStringList; -interface nsIDOMEventListener; - -/** - * IDBDatabase interface. See - * http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBDatabase - * for more information. - */ -[scriptable, builtinclass, uuid(89299bf8-e078-4ebc-abda-d97fe5618602)] -interface nsIIDBDatabase : nsISupports -{ - readonly attribute DOMString name; - - readonly attribute unsigned long long version; - - readonly attribute nsIDOMDOMStringList objectStoreNames; - - [implicit_jscontext] - nsISupports // IDBObjectStore - createObjectStore([Null(Stringify)] in DOMString name, - /* IDBObjectStoreParameters */ - [optional /* none */] in jsval options); - - void - deleteObjectStore([Null(Stringify)] in DOMString name); - - // mode can be either "readonly" or "readwrite" - [optional_argc, implicit_jscontext] - nsISupports - transaction(in jsval storeNames, // js array of strings - [optional /* "readonly" */] in DOMString mode); - - [implicit_jscontext] - nsIIDBRequest - mozCreateFileHandle(in DOMString name, - [optional] in DOMString type); - - void - close(); - - [implicit_jscontext] attribute jsval onabort; - - [implicit_jscontext] attribute jsval onerror; - - [implicit_jscontext] attribute jsval onversionchange; -}; diff --git a/dom/indexedDB/test/browser_permissionsPromptAllow.js b/dom/indexedDB/test/browser_permissionsPromptAllow.js index 7b04b6c6e27b..8bb6211c2bbb 100644 --- a/dom/indexedDB/test/browser_permissionsPromptAllow.js +++ b/dom/indexedDB/test/browser_permissionsPromptAllow.js @@ -24,7 +24,7 @@ function test1() gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); setFinishedCallback(function(result, exception) { - ok(result instanceof Components.interfaces.nsIIDBDatabase, + ok(result instanceof IDBDatabase, "First database creation was successful"); ok(!exception, "No exception"); is(getPermission(testPageURL, "indexedDB"), @@ -60,7 +60,7 @@ function test2() gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); setFinishedCallback(function(result, exception) { - ok(result instanceof Components.interfaces.nsIIDBDatabase, + ok(result instanceof IDBDatabase, "First database creation was successful"); ok(!exception, "No exception"); is(getPermission(testPageURL, "indexedDB"), diff --git a/dom/indexedDB/test/browser_perwindow_privateBrowsing.js b/dom/indexedDB/test/browser_perwindow_privateBrowsing.js index 5875ae6eb69c..39c3d2ed2c20 100644 --- a/dom/indexedDB/test/browser_perwindow_privateBrowsing.js +++ b/dom/indexedDB/test/browser_perwindow_privateBrowsing.js @@ -20,7 +20,7 @@ function test1() gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); setFinishedCallback(function(result, exception) { - ok(result instanceof Components.interfaces.nsIIDBDatabase, + ok(result instanceof IDBDatabase, "First database creation was successful"); ok(!exception, "No exception"); gBrowser.removeCurrentTab(); diff --git a/dom/indexedDB/test/unit/head.js b/dom/indexedDB/test/unit/head.js index f3f333155c4f..54af622557d1 100644 --- a/dom/indexedDB/test/unit/head.js +++ b/dom/indexedDB/test/unit/head.js @@ -8,7 +8,6 @@ const { 'classes': Cc, 'interfaces': Ci } = Components; const DOMException = Ci.nsIDOMDOMException; const IDBCursor = Ci.nsIIDBCursor; const IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest; -const IDBDatabase = Ci.nsIIDBDatabase const IDBRequest = Ci.nsIIDBRequest function is(a, b, msg) { diff --git a/dom/quota/nsIOfflineStorage.h b/dom/quota/nsIOfflineStorage.h index 8155b52f85bc..b97e2916f22b 100644 --- a/dom/quota/nsIOfflineStorage.h +++ b/dom/quota/nsIOfflineStorage.h @@ -73,20 +73,4 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIOfflineStorage, NS_OFFLINESTORAGE_IID) NS_IMETHOD_(void) \ Invalidate() MOZ_OVERRIDE; -#define NS_DECL_NSIOFFLINESTORAGE_NOCLOSE \ - NS_IMETHOD_(Client*) \ - GetClient() MOZ_OVERRIDE; \ - \ - NS_IMETHOD_(bool) \ - IsOwned(nsPIDOMWindow* aOwner) MOZ_OVERRIDE; \ - \ - NS_IMETHOD_(const nsACString&) \ - Origin() MOZ_OVERRIDE; \ - \ - NS_IMETHOD_(bool) \ - IsClosed() MOZ_OVERRIDE; \ - \ - NS_IMETHOD_(void) \ - Invalidate() MOZ_OVERRIDE; - #endif // nsIOfflineStorage_h__ diff --git a/dom/webidl/DummyBinding.webidl b/dom/webidl/DummyBinding.webidl index 7bdfbbe7dd3f..da48dbf6efa8 100644 --- a/dom/webidl/DummyBinding.webidl +++ b/dom/webidl/DummyBinding.webidl @@ -17,7 +17,6 @@ interface DummyInterface { void funcWebSocketDict(optional WebSocketDict arg); void funcDNSCacheDict(optional DNSCacheDict arg); void frameRequestCallback(FrameRequestCallback arg); - void idbObjectStoreParams(optional IDBObjectStoreParameters arg); void CameraPictureOptions(optional CameraPictureOptions arg); void MmsParameters(optional MmsParameters arg); void MmsAttachment(optional MmsAttachment arg); diff --git a/dom/webidl/IDBDatabase.webidl b/dom/webidl/IDBDatabase.webidl index 56151db2cd23..581e758480c7 100644 --- a/dom/webidl/IDBDatabase.webidl +++ b/dom/webidl/IDBDatabase.webidl @@ -10,11 +10,40 @@ * liability, trademark and document use rules apply. */ -dictionary IDBObjectStoreParameters { - // XXXbz this should be "(DOMString or sequence)?", but - // we don't support unions in dictionaries yet. See bug 767926. - any keyPath = null; - boolean autoIncrement = false; +interface IDBDatabase : EventTarget { + readonly attribute DOMString name; + readonly attribute unsigned long long version; + + [Throws] + readonly attribute DOMStringList objectStoreNames; + + [Throws] + IDBObjectStore createObjectStore (DOMString name, optional IDBObjectStoreParameters optionalParameters); + + [Throws] + void deleteObjectStore (DOMString name); + + // This should be: + // IDBTransaction transaction ((DOMString or sequence) storeNames, optional IDBTransactionMode mode = "readonly"); + // but unions are not currently supported. + + [Throws] + IDBTransaction transaction (DOMString storeName, optional IDBTransactionMode mode = "readonly"); + + [Throws] + IDBTransaction transaction (sequence storeNames, optional IDBTransactionMode mode = "readonly"); + + void close (); + + [SetterThrows] + attribute EventHandler onabort; + [SetterThrows] + attribute EventHandler onerror; + [SetterThrows] + attribute EventHandler onversionchange; }; -// If we start using IDBObjectStoreParameters here, remove it from DummyBinding. +partial interface IDBDatabase { + [Throws] + IDBRequest mozCreateFileHandle (DOMString name, optional DOMString type); +}; diff --git a/dom/webidl/IDBFileHandle.webidl b/dom/webidl/IDBFileHandle.webidl index b2eee301938c..5f9da55a12f9 100644 --- a/dom/webidl/IDBFileHandle.webidl +++ b/dom/webidl/IDBFileHandle.webidl @@ -3,8 +3,6 @@ * 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/. */ -interface IDBDatabase; - interface IDBFileHandle : FileHandle { readonly attribute IDBDatabase database; }; diff --git a/dom/webidl/IDBObjectStore.webidl b/dom/webidl/IDBObjectStore.webidl index f6c7eeeddf10..30eebe9c880b 100644 --- a/dom/webidl/IDBObjectStore.webidl +++ b/dom/webidl/IDBObjectStore.webidl @@ -9,6 +9,12 @@ interface IDBRequest; +dictionary IDBObjectStoreParameters { + // TODO (DOMString or sequence)? keyPath = null; + any keyPath = null; + boolean autoIncrement = false; +}; + interface IDBObjectStore { readonly attribute DOMString name; diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index 5fc188783156..004acfea83ca 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -86,7 +86,6 @@ members = [ # dom/indexedDB 'nsIIDBCursor.*', 'nsIIDBCursorWithValue.*', - 'nsIIDBDatabase.*', 'nsIIDBKeyRange.*', 'nsIIDBRequest.*', 'nsIIDBOpenDBRequest.*', From 2f2fb6ae5f92dc599911a42bd2f4bba945a94f38 Mon Sep 17 00:00:00 2001 From: Joel Maher Date: Wed, 31 Jul 2013 11:51:05 -0400 Subject: [PATCH 17/40] Bug 900018 - update talos on m-c to the latest version in build/talos. r=armenzg --- testing/talos/talos.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/talos/talos.json b/testing/talos/talos.json index 679df1c98fd9..8f708cbd6be7 100644 --- a/testing/talos/talos.json +++ b/testing/talos/talos.json @@ -5,7 +5,7 @@ }, "global": { "talos_repo": "http://hg.mozilla.org/build/talos", - "talos_revision": "fcbb9d7d3c78" + "talos_revision": "0c96f76c9a26" }, "suites": { "chromez": { From e93535f5c37cef794da2466a22b5645c5d32dd26 Mon Sep 17 00:00:00 2001 From: Geoff Brown Date: Wed, 31 Jul 2013 08:50:11 -0700 Subject: [PATCH 18/40] Bug 899655 - Update robocop testShareLink for JB+; r=jmaher --HG-- extra : rebase_source : 599441884b6dd1d44d218178d0736098a31b8bf8 --- .../android/base/tests/testShareLink.java.in | 114 ++++++++++-------- 1 file changed, 66 insertions(+), 48 deletions(-) diff --git a/mobile/android/base/tests/testShareLink.java.in b/mobile/android/base/tests/testShareLink.java.in index dd7323f67cac..074ba757fac0 100644 --- a/mobile/android/base/tests/testShareLink.java.in +++ b/mobile/android/base/tests/testShareLink.java.in @@ -2,24 +2,26 @@ package @ANDROID_PACKAGE_NAME@.tests; import @ANDROID_PACKAGE_NAME@.*; +import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; -import android.widget.ListView; -import android.view.View; -import android.view.ViewGroup; -import java.util.ArrayList; -import java.util.List; -import android.app.Activity; import android.os.Build; import android.util.DisplayMetrics; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AbsListView; +import android.widget.GridView; +import android.widget.ListView; +import android.widget.TextView; +import java.util.ArrayList; +import java.util.List; /** * This test covers the opening and content of the Share Link pop-up list * The test opens the Share menu from the app menu, the URL bar, a link context menu and the Awesomescreen tabs */ public class testShareLink extends BaseTest { - ListView list; String url; String urlTitle = "Big Link"; @@ -132,44 +134,54 @@ public class testShareLink extends BaseTest { return shareOptions; } + // Traverse the group of views, adding strings from TextViews to the list. + private void getGroupTextViews(ViewGroup group, ArrayList list) { + for (int i = 0; i < group.getChildCount(); i++) { + View child = group.getChildAt(i); + if (child instanceof AbsListView) { + getGroupTextViews((AbsListView)child, list); + } else if (child instanceof ViewGroup) { + getGroupTextViews((ViewGroup)child, list); + } else if (child instanceof TextView) { + String viewText = ((TextView)child).getText().toString(); + if (viewText != null && viewText.length() > 0) { + list.add(viewText); + } + } + } + } + + // Traverse the group of views, adding strings from TextViews to the list. + // This override is for AbsListView, which has adapters. If adapters are + // available, it is better to use them so that child views that are not + // yet displayed can be examined. + private void getGroupTextViews(AbsListView group, ArrayList list) { + for (int i = 0; i < group.getAdapter().getCount(); i++) { + View child = group.getAdapter().getView(i, null, group); + if (child instanceof AbsListView) { + getGroupTextViews((AbsListView)child, list); + } else if (child instanceof ViewGroup) { + getGroupTextViews((ViewGroup)child, list); + } else if (child instanceof TextView) { + String viewText = ((TextView)child).getText().toString(); + if (viewText != null && viewText.length() > 0) { + list.add(viewText); + } + } + } + } + public ArrayList getSharePopupOption() { ArrayList displayedOptions = new ArrayList(); - ListView shareMenu = getDisplayedShareList(); - - /* Will have to go in the ListView, get each child, for the child separate the icon and the label - and from the label get the label text in a String Array */ - for (int i = 0; i < shareMenu.getAdapter().getCount();i++) { - View shareItem = shareMenu.getAdapter().getView(i, null, null); - ViewGroup shareItemEntry = (ViewGroup)shareItem; - for (int j = 0; j < shareItemEntry.getChildCount(); j++) { - View shareItemLabel = shareItemEntry.getChildAt(j); - if (shareItemLabel instanceof android.widget.LinearLayout) { - // The Item label is a LinearLayout of LinearLayouts - ViewGroup itemLabel = (ViewGroup)shareItemLabel; - for (int k = 0; k < itemLabel.getChildCount(); k++) { - View shareItemName = itemLabel.getChildAt(k); - if (shareItemName instanceof android.widget.TextView) { - /* The displayedOptions list array will also contain other elements that make up the - share item label but we will check the option to be present here so there is no need - at the moment to try and clean this array up further */ - displayedOptions.add(((android.widget.TextView)shareItemName).getText().toString()); - } - } - } - } - } + AbsListView shareMenu = getDisplayedShareList(); + getGroupTextViews(shareMenu, displayedOptions); return displayedOptions; } public ArrayList getShareSubMenuOption() { ArrayList displayedOptions = new ArrayList(); - ListView shareMenu = getDisplayedShareList(); - for (int i = 0; i < shareMenu.getAdapter().getCount();i++) { - View shareItem = shareMenu.getAdapter().getView(i, null, shareMenu); - if (shareItem instanceof android.widget.TextView) { - displayedOptions.add(((android.widget.TextView)shareItem).getText().toString()); - } - } + AbsListView shareMenu = getDisplayedShareList(); + getGroupTextViews(shareMenu, displayedOptions); return displayedOptions; } @@ -190,21 +202,27 @@ public class testShareLink extends BaseTest { return false; } - private ListView getDisplayedShareList() { - final ArrayList views = mSolo.getCurrentListViews(); + private AbsListView mViewGroup; - list = null; + private AbsListView getDisplayedShareList() { + mViewGroup = null; boolean success = waitForTest(new BooleanTest() { @Override public boolean test() { - for (ListView view : views) { - list = view; - return true; - } - return false; + ArrayList views = mSolo.getCurrentViews(); + for (View view : views) { + // List may be displayed in different view formats. + // On JB, GridView is common; on ICS-, ListView is common. + if (view instanceof ListView || + view instanceof GridView) { + mViewGroup = (AbsListView)view; + return true; + } + } + return false; } }, MAX_WAIT_MS); - mAsserter.ok(success,"Got the displayed share options?", "Got the share options list"); - return list; + mAsserter.ok(success,"Got the displayed share options?", "Got the share options view"); + return mViewGroup; } } From d81ec64e26896a1b17469d4982df1ce52dba2493 Mon Sep 17 00:00:00 2001 From: Geoff Brown Date: Wed, 31 Jul 2013 08:50:14 -0700 Subject: [PATCH 19/40] Bug 899614 - Make tab count check more robust in testNewTab; r=jmaher --HG-- extra : rebase_source : 1e354f8d8d6d1b21c9b9af365dbfd605f8f4bc15 --- mobile/android/base/tests/testNewTab.java.in | 24 ++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/mobile/android/base/tests/testNewTab.java.in b/mobile/android/base/tests/testNewTab.java.in index a98b0746e25e..9f05e3d0487a 100644 --- a/mobile/android/base/tests/testNewTab.java.in +++ b/mobile/android/base/tests/testNewTab.java.in @@ -34,20 +34,17 @@ public class testNewTab extends BaseTest { "Checking elements", "all elements present"); int expectedTabCount = 1; - String tabCountText = tabCount.getText(); - tabCountInt = Integer.parseInt(tabCountText); + getTabCount(expectedTabCount); mAsserter.is(tabCountInt, expectedTabCount, "Initial number of tabs correct"); addTab(url); expectedTabCount++; - tabCountText = tabCount.getText(); - tabCountInt = Integer.parseInt(tabCountText); + getTabCount(expectedTabCount); mAsserter.is(tabCountInt, expectedTabCount, "Number of tabs increased"); addTab(url2); expectedTabCount++; - tabCountText = tabCount.getText(); - tabCountInt = Integer.parseInt(tabCountText); + getTabCount(expectedTabCount); mAsserter.is(tabCountInt, expectedTabCount, "Number of tabs increased"); // cleanup: close all opened tabs @@ -103,5 +100,18 @@ public class testNewTab extends BaseTest { mAsserter.ok(success, "Checking tab closed", "number of tabs now "+tabCountInt); } } -} + private void getTabCount(final int expected) { + waitForTest(new BooleanTest() { + @Override + public boolean test() { + String newTabCountText = tabCount.getText(); + tabCountInt = Integer.parseInt(newTabCountText); + if (tabCountInt == expected) { + return true; + } + return false; + } + }, MAX_WAIT_MS); + } +} From fdf14f768c71592067c34dd707391582b24d0d8e Mon Sep 17 00:00:00 2001 From: Geoff Brown Date: Wed, 31 Jul 2013 08:50:17 -0700 Subject: [PATCH 20/40] Bug 899794 - Fix testSettingsMenuItems timing on RAZR; r=jmaher --HG-- extra : rebase_source : 3dbec0198bcda6e78111e069f3a36d9668c9ac2e --- mobile/android/base/tests/testSettingsMenuItems.java.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mobile/android/base/tests/testSettingsMenuItems.java.in b/mobile/android/base/tests/testSettingsMenuItems.java.in index b0e25d05ef94..57ffb12b71c1 100644 --- a/mobile/android/base/tests/testSettingsMenuItems.java.in +++ b/mobile/android/base/tests/testSettingsMenuItems.java.in @@ -88,6 +88,7 @@ public class testSettingsMenuItems extends PixelTest { settingsMenuItems.put("Mozilla", OPTIONS_MOZILLA); selectMenuItem("Settings"); + waitForText("Settings"); // Dismiss the Settings screen and verify that the view is returned to about:home page mActions.sendSpecialKey(Actions.SpecialKey.BACK); @@ -96,6 +97,8 @@ public class testSettingsMenuItems extends PixelTest { waitForText("Enter Search"); // Waiting for page title to appear to be sure that is fully loaded before opening the menu selectMenuItem("Settings"); + waitForText("Settings"); + checkForSync(mDevice); checkMenuHierarchy(settingsMenuItems); From dc4bd05cb5cad41f15e0d2d7696be965ef94d9ce Mon Sep 17 00:00:00 2001 From: Tom Schuster Date: Wed, 31 Jul 2013 12:20:33 -0400 Subject: [PATCH 21/40] Bug 884410 - Handlify JS_GetPrototype. r=terrence --- caps/src/nsSecurityManagerFactory.cpp | 2 +- content/base/src/nsDocument.cpp | 4 ++-- content/base/src/nsObjectLoadingContent.cpp | 21 ++++++++----------- content/base/src/nsObjectLoadingContent.h | 4 ++-- content/xbl/src/nsXBLBinding.cpp | 6 +++--- content/xbl/src/nsXBLDocumentInfo.cpp | 2 +- dom/base/nsDOMClassInfo.cpp | 16 +++++++------- dom/base/nsGlobalWindow.cpp | 14 +++++++------ dom/bindings/BindingUtils.cpp | 4 ++-- dom/bindings/DOMJSProxyHandler.cpp | 2 +- dom/plugins/base/nsJSNPRuntime.cpp | 2 +- js/jsd/jsd_val.cpp | 4 ++-- js/src/builtin/BinaryData.cpp | 4 ++-- js/src/ctypes/CTypes.cpp | 20 ++++++++++-------- js/src/jsapi-tests/testTypedArrays.cpp | 4 ++-- js/src/jsapi.cpp | 8 ++----- js/src/jsapi.h | 2 +- js/src/jsfriendapi.h | 2 +- js/xpconnect/wrappers/ChromeObjectWrapper.cpp | 6 +++--- js/xpconnect/wrappers/WrapperFactory.cpp | 4 ++-- 20 files changed, 64 insertions(+), 67 deletions(-) diff --git a/caps/src/nsSecurityManagerFactory.cpp b/caps/src/nsSecurityManagerFactory.cpp index 07333299feef..c92e17c50ea7 100644 --- a/caps/src/nsSecurityManagerFactory.cpp +++ b/caps/src/nsSecurityManagerFactory.cpp @@ -77,7 +77,7 @@ nsSecurityNameSet::InitializeNameSet(nsIScriptContext* aScriptContext) JS::Rooted obj(cx, global); JS::Rooted proto(cx); for (;;) { - MOZ_ALWAYS_TRUE(JS_GetPrototype(cx, obj, proto.address())); + MOZ_ALWAYS_TRUE(JS_GetPrototype(cx, obj, &proto)); if (!proto) break; obj = proto; diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 9e9e2c94f91b..8f23c22e4067 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -5242,7 +5242,7 @@ nsDocument::Register(JSContext* aCx, const nsAString& aName, // Check the proto chain for HTMLElement prototype. JS::Rooted protoProto(aCx); - if (!JS_GetPrototype(aCx, protoObject, protoProto.address())) { + if (!JS_GetPrototype(aCx, protoObject, &protoProto)) { rv.Throw(NS_ERROR_UNEXPECTED); return nullptr; } @@ -5250,7 +5250,7 @@ nsDocument::Register(JSContext* aCx, const nsAString& aName, if (protoProto == htmlProto) { break; } - if (!JS_GetPrototype(aCx, protoProto, protoProto.address())) { + if (!JS_GetPrototype(aCx, protoProto, &protoProto)) { rv.Throw(NS_ERROR_UNEXPECTED); return nullptr; } diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp index db31939844a4..31cb4474e65c 100644 --- a/content/base/src/nsObjectLoadingContent.cpp +++ b/content/base/src/nsObjectLoadingContent.cpp @@ -3157,7 +3157,7 @@ nsObjectLoadingContent::LegacyCall(JSContext* aCx, JS::Rooted pi_obj(aCx); JS::Rooted pi_proto(aCx); - rv = GetPluginJSObject(aCx, obj, pi, pi_obj.address(), pi_proto.address()); + rv = GetPluginJSObject(aCx, obj, pi, &pi_obj, &pi_proto); if (NS_FAILED(rv)) { aRv.Throw(rv); return JS::UndefinedValue(); @@ -3223,7 +3223,7 @@ nsObjectLoadingContent::SetupProtoChain(JSContext* aCx, JS::Rooted pi_obj(aCx); // XPConnect-wrapped peer object, when we get it. JS::Rooted pi_proto(aCx); // 'pi.__proto__' - rv = GetPluginJSObject(aCx, aObject, pi, pi_obj.address(), pi_proto.address()); + rv = GetPluginJSObject(aCx, aObject, pi, &pi_obj, &pi_proto); if (NS_FAILED(rv)) { return; } @@ -3310,21 +3310,18 @@ nsresult nsObjectLoadingContent::GetPluginJSObject(JSContext *cx, JS::Handle obj, nsNPAPIPluginInstance *plugin_inst, - JSObject **plugin_obj, - JSObject **plugin_proto) + JS::MutableHandle plugin_obj, + JS::MutableHandle plugin_proto) { - *plugin_obj = nullptr; - *plugin_proto = nullptr; - // NB: We need an AutoEnterCompartment because we can be called from // nsObjectFrame when the plugin loads after the JS object for our content // node has been created. JSAutoCompartment ac(cx, obj); if (plugin_inst) { - plugin_inst->GetJSObject(cx, plugin_obj); - if (*plugin_obj) { - if (!::JS_GetPrototype(cx, *plugin_obj, plugin_proto)) { + plugin_inst->GetJSObject(cx, plugin_obj.address()); + if (plugin_obj) { + if (!::JS_GetPrototype(cx, plugin_obj, plugin_proto)) { return NS_ERROR_UNEXPECTED; } } @@ -3352,7 +3349,7 @@ nsObjectLoadingContent::TeardownProtoChain() // all JS objects of the class sNPObjectJSWrapperClass bool removed = false; while (obj) { - if (!::JS_GetPrototype(cx, obj, proto.address())) { + if (!::JS_GetPrototype(cx, obj, &proto)) { return; } if (!proto) { @@ -3362,7 +3359,7 @@ nsObjectLoadingContent::TeardownProtoChain() // an NP object, that counts too. if (JS_GetClass(js::UncheckedUnwrap(proto)) == &sNPObjectJSWrapperClass) { // We found an NPObject on the proto chain, get its prototype... - if (!::JS_GetPrototype(cx, proto, proto.address())) { + if (!::JS_GetPrototype(cx, proto, &proto)) { return; } diff --git a/content/base/src/nsObjectLoadingContent.h b/content/base/src/nsObjectLoadingContent.h index 3a3da648989e..a4f75abce0a7 100644 --- a/content/base/src/nsObjectLoadingContent.h +++ b/content/base/src/nsObjectLoadingContent.h @@ -481,8 +481,8 @@ class nsObjectLoadingContent : public nsImageLoadingContent static nsresult GetPluginJSObject(JSContext *cx, JS::Handle obj, nsNPAPIPluginInstance *plugin_inst, - JSObject **plugin_obj, - JSObject **plugin_proto); + JS::MutableHandle plugin_obj, + JS::MutableHandle plugin_proto); // The final listener for mChannel (uriloader, pluginstreamlistener, etc.) nsCOMPtr mFinalListener; diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp index ffecdb09b8bb..4a9f11407b75 100644 --- a/content/xbl/src/nsXBLBinding.cpp +++ b/content/xbl/src/nsXBLBinding.cpp @@ -765,7 +765,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen JS::Rooted base(cx, scriptObject); JS::Rooted proto(cx); for ( ; true; base = proto) { // Will break out on null proto - if (!JS_GetPrototype(cx, base, proto.address())) { + if (!JS_GetPrototype(cx, base, &proto)) { return; } if (!proto) { @@ -799,7 +799,7 @@ nsXBLBinding::ChangeDocument(nsIDocument* aOldDocument, nsIDocument* aNewDocumen // Alright! This is the right prototype. Pull it out of the // proto chain. JS::Rooted grandProto(cx); - if (!JS_GetPrototype(cx, proto, grandProto.address())) { + if (!JS_GetPrototype(cx, proto, &grandProto)) { return; } ::JS_SetPrototype(cx, base, grandProto); @@ -899,7 +899,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JS::Handle global, nsXBLJSClass* c = nullptr; if (obj) { // Retrieve the current prototype of obj. - if (!JS_GetPrototype(cx, obj, parent_proto.address())) { + if (!JS_GetPrototype(cx, obj, &parent_proto)) { return NS_ERROR_FAILURE; } if (parent_proto) { diff --git a/content/xbl/src/nsXBLDocumentInfo.cpp b/content/xbl/src/nsXBLDocumentInfo.cpp index ff41c282e306..24c2e2eb8502 100644 --- a/content/xbl/src/nsXBLDocumentInfo.cpp +++ b/content/xbl/src/nsXBLDocumentInfo.cpp @@ -104,7 +104,7 @@ nsXBLDocGlobalObject::doCheckAccess(JSContext *cx, JS::Handle obj, // down on the proto chain. JS::Rooted base(cx, obj); while (JS_GetClass(base) != &nsXBLDocGlobalObject::gSharedGlobalClass) { - if (!::JS_GetPrototype(cx, base, base.address())) { + if (!::JS_GetPrototype(cx, base, &base)) { return JS_FALSE; } if (!base) { diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index a403d98f3b39..046deeb9fc1f 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -2155,7 +2155,7 @@ nsDOMClassInfo::PostCreatePrototype(JSContext * cx, JSObject * aProto) #ifdef DEBUG JS::Rooted proto2(cx); - JS_GetPrototype(cx, proto, proto2.address()); + JS_GetPrototype(cx, proto, &proto2); NS_ASSERTION(proto2 && JS_GetClass(proto2) == sObjectClass, "Hmm, somebody did something evil?"); #endif @@ -2488,7 +2488,7 @@ nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JS::Handle o } JS::Rooted proto(cx); - if (!::JS_GetPrototype(cx, obj, proto.address())) { + if (!::JS_GetPrototype(cx, obj, &proto)) { return JS_FALSE; } JSBool hasProp; @@ -2550,7 +2550,7 @@ nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx, JS::Rooted obj(cx, aObj); for (;;) { - if (!::JS_GetPrototype(cx, obj, proto.address())) { + if (!::JS_GetPrototype(cx, obj, &proto)) { return JS_FALSE; } if (!proto) { @@ -2560,7 +2560,7 @@ nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx, if (JS_GetClass(proto) == &sGlobalScopePolluterClass) { JS::Rooted proto_proto(cx); - if (!::JS_GetPrototype(cx, proto, proto_proto.address())) { + if (!::JS_GetPrototype(cx, proto, &proto_proto)) { return JS_FALSE; } @@ -2592,7 +2592,7 @@ nsWindowSH::InstallGlobalScopePolluter(JSContext *cx, JS::Handle obj) // scope polluter (right before Object.prototype). for (;;) { - if (!::JS_GetPrototype(cx, o, proto.address())) { + if (!::JS_GetPrototype(cx, o, &proto)) { return NS_ERROR_OUT_OF_MEMORY; } if (!proto) { @@ -3194,7 +3194,7 @@ nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper, JS::Rooted proto(cx, dom_obj); for (;;) { - if (!JS_GetPrototype(cx, proto, proto.address())) { + if (!JS_GetPrototype(cx, proto, &proto)) { return NS_ERROR_UNEXPECTED; } if (!proto) { @@ -3556,7 +3556,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx, if (dot_prototype) { JSAutoCompartment ac(cx, dot_prototype); JS::Rooted xpc_proto_proto(cx); - if (!::JS_GetPrototype(cx, dot_prototype, xpc_proto_proto.address())) { + if (!::JS_GetPrototype(cx, dot_prototype, &xpc_proto_proto)) { return NS_ERROR_UNEXPECTED; } @@ -5178,7 +5178,7 @@ nsStorage2SH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, } JS::Rooted proto(cx); - if (!::JS_GetPrototype(cx, realObj, proto.address())) { + if (!::JS_GetPrototype(cx, realObj, &proto)) { return NS_ERROR_FAILURE; } JSBool hasProp; diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index ef7fccf2b939..f8f2c3029b3b 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2073,9 +2073,9 @@ nsGlobalWindow::SetOuterObject(JSContext* aCx, JS::Handle aOuterObjec js::SetDefaultObjectForContext(aCx, aOuterObject); // Set up the prototype for the outer object. - JSObject* inner = JS_GetParent(aOuterObject); + JS::Rooted inner(aCx, JS_GetParent(aOuterObject)); JS::Rooted proto(aCx); - if (!JS_GetPrototype(aCx, inner, proto.address())) { + if (!JS_GetPrototype(aCx, inner, &proto)) { return NS_ERROR_FAILURE; } JS_SetPrototype(aCx, aOuterObject, proto); @@ -2467,7 +2467,8 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, // Now that both the the inner and outer windows are initialized // let the script context do its magic to hook them together. #ifdef DEBUG - JSObject* newInnerJSObject = newInnerWindow->FastGetGlobalJSObject(); + JS::Rooted newInnerJSObject(cx, + newInnerWindow->FastGetGlobalJSObject()); #endif // Now that we're connecting the outer global to the inner one, @@ -2476,8 +2477,9 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, // so update that now since it might have changed. js::SetDefaultObjectForContext(cx, mJSObject); #ifdef DEBUG - JSObject *proto1, *proto2; - JS_GetPrototype(cx, mJSObject, &proto1); + JS::Rooted rootedJSObject(cx, mJSObject); + JS::Rooted proto1(cx), proto2(cx); + JS_GetPrototype(cx, rootedJSObject, &proto1); JS_GetPrototype(cx, newInnerJSObject, &proto2); NS_ASSERTION(proto1 == proto2, "outer and inner globals should have the same prototype"); @@ -6592,7 +6594,7 @@ nsGlobalWindow::CallerInnerWindow() { JSAutoCompartment ac(cx, scope); JS::Rooted scopeProto(cx); - bool ok = JS_GetPrototype(cx, scope, scopeProto.address()); + bool ok = JS_GetPrototype(cx, scope, &scopeProto); NS_ENSURE_TRUE(ok, nullptr); if (scopeProto && xpc::IsSandboxPrototypeProxy(scopeProto) && (scopeProto = js::CheckedUnwrap(scopeProto, /* stopAtOuter = */ false))) diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 31cc59a9268d..4a8a46d8f958 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -1755,7 +1755,7 @@ InterfaceHasInstance(JSContext* cx, JS::Handle obj, "Someone messed with our prototype property?"); JS::Rooted proto(cx); - if (!JS_GetPrototype(cx, instance, proto.address())) { + if (!JS_GetPrototype(cx, instance, &proto)) { return false; } @@ -1765,7 +1765,7 @@ InterfaceHasInstance(JSContext* cx, JS::Handle obj, return true; } - if (!JS_GetPrototype(cx, proto, proto.address())) { + if (!JS_GetPrototype(cx, proto, &proto)) { return false; } } diff --git a/dom/bindings/DOMJSProxyHandler.cpp b/dom/bindings/DOMJSProxyHandler.cpp index 5c356f338b74..854ea69ab7bf 100644 --- a/dom/bindings/DOMJSProxyHandler.cpp +++ b/dom/bindings/DOMJSProxyHandler.cpp @@ -230,7 +230,7 @@ bool DOMProxyHandler::enumerate(JSContext* cx, JS::Handle proxy, AutoIdVector& props) { JS::Rooted proto(cx); - if (!JS_GetPrototype(cx, proxy, proto.address())) { + if (!JS_GetPrototype(cx, proxy, &proto)) { return false; } return getOwnPropertyNames(cx, proxy, props) && diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index a7d85dea0e48..e72f44623652 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -1085,7 +1085,7 @@ GetNPObjectWrapper(JSContext *cx, JSObject *aObj, bool wrapResult = true) } return obj; } - if (!::JS_GetPrototype(cx, obj, obj.address())) { + if (!::JS_GetPrototype(cx, obj, &obj)) { return NULL; } } diff --git a/js/jsd/jsd_val.cpp b/js/jsd/jsd_val.cpp index a811a29fde05..5de8b7bebdd1 100644 --- a/js/jsd/jsd_val.cpp +++ b/js/jsd/jsd_val.cpp @@ -581,7 +581,7 @@ jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval) if(JSVAL_IS_PRIMITIVE(jsdval->val)) return NULL; obj = JSVAL_TO_OBJECT(jsdval->val); - if(!JS_GetPrototype(cx, obj, proto.address())) + if(!JS_GetPrototype(cx, obj, &proto)) return NULL; if(!proto) return NULL; @@ -632,7 +632,7 @@ jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval) if(JSVAL_IS_PRIMITIVE(jsdval->val)) return NULL; obj = JSVAL_TO_OBJECT(jsdval->val); - if(!JS_GetPrototype(cx, obj, proto.address())) + if(!JS_GetPrototype(cx, obj, &proto)) return NULL; if(!proto) return NULL; diff --git a/js/src/builtin/BinaryData.cpp b/js/src/builtin/BinaryData.cpp index 2ee1edf912e8..2226a6c000c3 100644 --- a/js/src/builtin/BinaryData.cpp +++ b/js/src/builtin/BinaryData.cpp @@ -476,8 +476,8 @@ SetupAndGetPrototypeObjectForComplexTypeInstance(JSContext *cx, RootedObject prototypeObj(cx, NewObjectWithGivenProto(cx, &JSObject::class_, NULL, global)); - if (!JS_SetPrototype(cx, prototypeObj, - complexTypePrototypePrototypeVal.toObjectOrNull())) + RootedObject proto(cx, complexTypePrototypePrototypeVal.toObjectOrNull()); + if (!JS_SetPrototype(cx, prototypeObj, proto)) return NULL; return prototypeObj; diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index 45d80f283c02..794df1bced30 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -832,7 +832,7 @@ InitCTypeClass(JSContext* cx, HandleObject parent) RootedObject ctor(cx, JS_GetFunctionObject(fun)); RootedObject fnproto(cx); - if (!JS_GetPrototype(cx, ctor, fnproto.address())) + if (!JS_GetPrototype(cx, ctor, &fnproto)) return NULL; JS_ASSERT(ctor); JS_ASSERT(fnproto); @@ -3573,13 +3573,14 @@ CType::GetProtoFromCtor(JSObject* obj, CTypeProtoSlot slot) } JSObject* -CType::GetProtoFromType(JSContext* cx, JSObject* obj, CTypeProtoSlot slot) +CType::GetProtoFromType(JSContext* cx, JSObject* objArg, CTypeProtoSlot slot) { - JS_ASSERT(IsCType(obj)); + JS_ASSERT(IsCType(objArg)); + RootedObject obj(cx, objArg); // Get the prototype of the type object. RootedObject proto(cx); - if (!JS_GetPrototype(cx, obj, proto.address())) + if (!JS_GetPrototype(cx, obj, &proto)) return NULL; JS_ASSERT(proto); JS_ASSERT(CType::IsCTypeProto(proto)); @@ -3760,7 +3761,7 @@ CType::HasInstance(JSContext* cx, HandleObject obj, MutableHandleValue v, JSBool RootedObject proto(cx, &v.toObject()); for (;;) { - if (!JS_GetPrototype(cx, proto, proto.address())) + if (!JS_GetPrototype(cx, proto, &proto)) return JS_FALSE; if (!proto) break; @@ -3773,12 +3774,13 @@ CType::HasInstance(JSContext* cx, HandleObject obj, MutableHandleValue v, JSBool } static JSObject* -CType::GetGlobalCTypes(JSContext* cx, JSObject* obj) +CType::GetGlobalCTypes(JSContext* cx, JSObject* objArg) { - JS_ASSERT(CType::IsCType(obj)); + JS_ASSERT(CType::IsCType(objArg)); + RootedObject obj(cx, objArg); RootedObject objTypeProto(cx); - if (!JS_GetPrototype(cx, obj, objTypeProto.address())) + if (!JS_GetPrototype(cx, obj, &objTypeProto)) return NULL; JS_ASSERT(objTypeProto); JS_ASSERT(CType::IsCTypeProto(objTypeProto)); @@ -5997,7 +5999,7 @@ CClosure::Create(JSContext* cx, // Get the prototype of the FunctionType object, of class CTypeProto, // which stores our JSContext for use with the closure. RootedObject proto(cx); - if (!JS_GetPrototype(cx, typeObj, proto.address())) + if (!JS_GetPrototype(cx, typeObj, &proto)) return NULL; JS_ASSERT(proto); JS_ASSERT(CType::IsCTypeProto(proto)); diff --git a/js/src/jsapi-tests/testTypedArrays.cpp b/js/src/jsapi-tests/testTypedArrays.cpp index f48858589e8f..e778df5620e1 100644 --- a/js/src/jsapi-tests/testTypedArrays.cpp +++ b/js/src/jsapi-tests/testTypedArrays.cpp @@ -31,7 +31,7 @@ BEGIN_TEST(testTypedArrays) CHECK(JS_IsArrayBufferObject(buffer)); RootedObject proto(cx); - JS_GetPrototype(cx, buffer, proto.address()); + JS_GetPrototype(cx, buffer, &proto); CHECK(!JS_IsArrayBufferObject(proto)); RootedObject dummy(cx, JS_GetParent(proto)); CHECK(!JS_IsArrayBufferObject(dummy)); @@ -67,7 +67,7 @@ TestPlainTypedArray(JSContext *cx) RootedObject array(cx, Create(cx, 7)); CHECK(JS_IsTypedArrayObject(array)); RootedObject proto(cx); - JS_GetPrototype(cx, array, proto.address()); + JS_GetPrototype(cx, array, &proto); CHECK(!JS_IsTypedArrayObject(proto)); RootedObject dummy(cx, JS_GetParent(proto)); CHECK(!JS_IsTypedArrayObject(dummy)); diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 8e2985039312..976b2687460c 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -2817,13 +2817,9 @@ JS_GetInstancePrivate(JSContext *cx, JSObject *objArg, JSClass *clasp, jsval *ar } JS_PUBLIC_API(JSBool) -JS_GetPrototype(JSContext *cx, JSObject *objArg, JSObject **protop) +JS_GetPrototype(JSContext *cx, JS::Handle obj, JS::MutableHandle protop) { - RootedObject obj(cx, objArg); - RootedObject proto(cx); - bool rv = JSObject::getProto(cx, obj, &proto); - *protop = proto; - return rv; + return JSObject::getProto(cx, obj, protop); } JS_PUBLIC_API(JSBool) diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 2abfcb5994c4..4fee4bb051f7 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -3181,7 +3181,7 @@ JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv); extern JS_PUBLIC_API(JSBool) -JS_GetPrototype(JSContext *cx, JSObject *obj, JSObject **protop); +JS_GetPrototype(JSContext *cx, JS::Handle obj, JS::MutableHandle protop); extern JS_PUBLIC_API(JSBool) JS_SetPrototype(JSContext *cx, JSObject *obj, JSObject *proto); diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index 5d14dda46b42..e378fb0997e4 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -495,7 +495,7 @@ GetObjectProto(JSContext *cx, JS::Handle obj, JS::MutableHandle(obj.get())->type->proto); diff --git a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp index 58b592323927..b4e22c5c1c08 100644 --- a/js/xpconnect/wrappers/ChromeObjectWrapper.cpp +++ b/js/xpconnect/wrappers/ChromeObjectWrapper.cpp @@ -83,7 +83,7 @@ ChromeObjectWrapper::getPropertyDescriptor(JSContext *cx, // If we found something or have no proto, we're done. RootedObject wrapperProto(cx); - if (!JS_GetPrototype(cx, wrapper, wrapperProto.address())) + if (!JS_GetPrototype(cx, wrapper, &wrapperProto)) return false; if (desc->obj || !wrapperProto) return true; @@ -107,7 +107,7 @@ ChromeObjectWrapper::has(JSContext *cx, HandleObject wrapper, // If we found something or have no prototype, we're done. RootedObject wrapperProto(cx); - if (!JS_GetPrototype(cx, wrapper, wrapperProto.address())) + if (!JS_GetPrototype(cx, wrapper, &wrapperProto)) return false; if (*bp || !wrapperProto) return true; @@ -145,7 +145,7 @@ ChromeObjectWrapper::get(JSContext *cx, HandleObject wrapper, // If we have no proto, we're done. RootedObject wrapperProto(cx); - if (!JS_GetPrototype(cx, wrapper, wrapperProto.address())) + if (!JS_GetPrototype(cx, wrapper, &wrapperProto)) return false; if (!wrapperProto) return true; diff --git a/js/xpconnect/wrappers/WrapperFactory.cpp b/js/xpconnect/wrappers/WrapperFactory.cpp index 612744c6d474..2cee17b88fe3 100644 --- a/js/xpconnect/wrappers/WrapperFactory.cpp +++ b/js/xpconnect/wrappers/WrapperFactory.cpp @@ -576,7 +576,7 @@ WrapperFactory::WrapSOWObject(JSContext *cx, JSObject *objArg) // XUL domain, in which we can't have SOWs. We should never be called in // that case. MOZ_ASSERT(xpc::AllowXBLScope(js::GetContextCompartment(cx))); - if (!JS_GetPrototype(cx, obj, proto.address())) + if (!JS_GetPrototype(cx, obj, &proto)) return NULL; JSObject *wrapperObj = Wrapper::New(cx, obj, proto, JS_GetGlobalForObject(cx, obj), @@ -596,7 +596,7 @@ JSObject * WrapperFactory::WrapComponentsObject(JSContext *cx, HandleObject obj) { RootedObject proto(cx); - if (!JS_GetPrototype(cx, obj, proto.address())) + if (!JS_GetPrototype(cx, obj, &proto)) return NULL; JSObject *wrapperObj = Wrapper::New(cx, obj, proto, JS_GetGlobalForObject(cx, obj), From 9ff34cdc530b6f6fc174179c7d8967a89b3df351 Mon Sep 17 00:00:00 2001 From: Tom Schuster Date: Wed, 31 Jul 2013 12:20:33 -0400 Subject: [PATCH 22/40] Bug 884410 - Handlify JS_SetPrototype. r=terrence --- dom/workers/WorkerScope.cpp | 8 ++++---- js/src/jsapi.cpp | 4 +--- js/src/jsapi.h | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index 5e204fc8c4ae..4ab5b995d9c5 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -979,14 +979,14 @@ CreateDedicatedWorkerGlobalScope(JSContext* aCx) return NULL; } - JSObject* scopeProto = - WorkerGlobalScope::InitClass(aCx, global, eventTargetProto); + JS::Rooted scopeProto(aCx, + WorkerGlobalScope::InitClass(aCx, global, eventTargetProto)); if (!scopeProto) { return NULL; } - JSObject* dedicatedScopeProto = - DedicatedWorkerGlobalScope::InitClass(aCx, global, scopeProto); + JS::Rooted dedicatedScopeProto(aCx, + DedicatedWorkerGlobalScope::InitClass(aCx, global, scopeProto)); if (!dedicatedScopeProto) { return NULL; } diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 976b2687460c..e37beedfddf8 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -2823,10 +2823,8 @@ JS_GetPrototype(JSContext *cx, JS::Handle obj, JS::MutableHandle obj, JS::Handle proto) { - RootedObject obj(cx, objArg); - RootedObject proto(cx, protoArg); AssertHeapIsIdle(cx); CHECK_REQUEST(cx); assertSameCompartment(cx, obj, proto); diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 4fee4bb051f7..93515ca967b4 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -3184,7 +3184,7 @@ extern JS_PUBLIC_API(JSBool) JS_GetPrototype(JSContext *cx, JS::Handle obj, JS::MutableHandle protop); extern JS_PUBLIC_API(JSBool) -JS_SetPrototype(JSContext *cx, JSObject *obj, JSObject *proto); +JS_SetPrototype(JSContext *cx, JS::Handle obj, JS::Handle proto); extern JS_PUBLIC_API(JSObject *) JS_GetParent(JSObject *obj); From 1edbba850cf80a51c598f6a55a6a24852a9e1423 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Wed, 31 Jul 2013 09:22:57 -0700 Subject: [PATCH 23/40] Bug 899801 - Don't keep more than five "momentums" values in BrowserElementPanning.js. r=vingtetun --HG-- extra : rebase_source : f9285a4208b307713d707e5750f39eb43c2b126c --- dom/browser-element/BrowserElementPanning.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dom/browser-element/BrowserElementPanning.js b/dom/browser-element/BrowserElementPanning.js index cf7cf7e371d0..4068e158fabe 100644 --- a/dom/browser-element/BrowserElementPanning.js +++ b/dom/browser-element/BrowserElementPanning.js @@ -645,9 +645,6 @@ const KineticPanning = { let momentums = this.momentums; let flick = momentums[momentums.length - 1].time - momentums[0].time < 300; - // Calculate the panning based on the last moves. - momentums = momentums.slice(-kSamples); - let distance = new Point(0, 0); momentums.forEach(function(momentum) { distance.add(momentum.dx, momentum.dy); @@ -707,6 +704,12 @@ const KineticPanning = { record: function kp_record(delta, timestamp) { this.momentums.push({ 'time': this._getTime(timestamp), 'dx' : delta.x, 'dy' : delta.y }); + + // We only need to keep kSamples in this.momentums. + if (this.momentums.length > kSamples) { + this.momentums.shift(); + } + this.distance.add(delta.x, delta.y); }, From 20744b2382b6bc4bca56ef3b1f218c93175492a9 Mon Sep 17 00:00:00 2001 From: Terrence Cole Date: Tue, 30 Jul 2013 16:29:59 -0700 Subject: [PATCH 24/40] Bug 899696 - Fix unsafe reference hazard in SendToGenerator; r=sfink --HG-- extra : rebase_source : 302da62f20ff1ddb14f35ddb8f3032b92961f6e0 --- js/src/jsiter.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp index 346e35c929ab..156e184907eb 100644 --- a/js/src/jsiter.cpp +++ b/js/src/jsiter.cpp @@ -1542,7 +1542,7 @@ typedef enum JSGeneratorOp { */ static JSBool SendToGenerator(JSContext *cx, JSGeneratorOp op, HandleObject obj, - JSGenerator *gen, const Value &arg) + JSGenerator *gen, HandleValue arg) { if (gen->state == JSGEN_RUNNING || gen->state == JSGEN_CLOSING) { JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NESTING_GENERATOR); @@ -1628,7 +1628,7 @@ CloseGenerator(JSContext *cx, HandleObject obj) if (gen->state == JSGEN_CLOSED) return true; - return SendToGenerator(cx, JSGENOP_CLOSE, obj, gen, UndefinedValue()); + return SendToGenerator(cx, JSGENOP_CLOSE, obj, gen, JS::UndefinedHandleValue); } JS_ALWAYS_INLINE bool @@ -1657,11 +1657,8 @@ generator_send_impl(JSContext *cx, CallArgs args) return false; } - if (!SendToGenerator(cx, JSGENOP_SEND, thisObj, gen, - args.length() > 0 ? args[0] : UndefinedValue())) - { + if (!SendToGenerator(cx, JSGENOP_SEND, thisObj, gen, args.get(0))) return false; - } args.rval().set(gen->fp->returnValue()); return true; @@ -1687,7 +1684,7 @@ generator_next_impl(JSContext *cx, CallArgs args) return js_ThrowStopIteration(cx); } - if (!SendToGenerator(cx, JSGENOP_NEXT, thisObj, gen, UndefinedValue())) + if (!SendToGenerator(cx, JSGENOP_NEXT, thisObj, gen, JS::UndefinedHandleValue)) return false; args.rval().set(gen->fp->returnValue()); @@ -1715,11 +1712,8 @@ generator_throw_impl(JSContext *cx, CallArgs args) return false; } - if (!SendToGenerator(cx, JSGENOP_THROW, thisObj, gen, - args.length() > 0 ? args[0] : UndefinedValue())) - { + if (!SendToGenerator(cx, JSGENOP_THROW, thisObj, gen, args.get(0))) return false; - } args.rval().set(gen->fp->returnValue()); return true; @@ -1752,7 +1746,7 @@ generator_close_impl(JSContext *cx, CallArgs args) return true; } - if (!SendToGenerator(cx, JSGENOP_CLOSE, thisObj, gen, UndefinedValue())) + if (!SendToGenerator(cx, JSGENOP_CLOSE, thisObj, gen, JS::UndefinedHandleValue)) return false; args.rval().set(gen->fp->returnValue()); From 82c142247875ed8f1a148c22202d815e6e22abe2 Mon Sep 17 00:00:00 2001 From: Terrence Cole Date: Tue, 30 Jul 2013 16:30:27 -0700 Subject: [PATCH 25/40] Bug 899693 - Fix unsafe reference hazards around HashableValue::setValue; r=sfink --HG-- extra : rebase_source : f296325db530ec1f94708a657cdc7ad885a85368 --- js/src/builtin/MapObject.cpp | 2 +- js/src/builtin/MapObject.h | 4 ++-- js/src/jsiter.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/js/src/builtin/MapObject.cpp b/js/src/builtin/MapObject.cpp index 39a2666e972c..0dc50cc9df6d 100644 --- a/js/src/builtin/MapObject.cpp +++ b/js/src/builtin/MapObject.cpp @@ -788,7 +788,7 @@ class OrderedHashSet /*** HashableValue *******************************************************************************/ bool -HashableValue::setValue(JSContext *cx, const Value &v) +HashableValue::setValue(JSContext *cx, HandleValue v) { if (v.isString()) { // Atomize so that hash() and operator==() are fast and infallible. diff --git a/js/src/builtin/MapObject.h b/js/src/builtin/MapObject.h index ea58ce4ee6a3..6f87ec56cc11 100644 --- a/js/src/builtin/MapObject.h +++ b/js/src/builtin/MapObject.h @@ -36,7 +36,7 @@ class HashableValue { HashableValue() : value(UndefinedValue()) {} - bool setValue(JSContext *cx, const Value &v); + bool setValue(JSContext *cx, HandleValue v); HashNumber hash() const; bool operator==(const HashableValue &other) const; HashableValue mark(JSTracer *trc) const; @@ -53,7 +53,7 @@ class AutoHashableValueRooter : private AutoGCRooter MOZ_GUARD_OBJECT_NOTIFIER_INIT; } - bool setValue(JSContext *cx, const Value &v) { + bool setValue(JSContext *cx, HandleValue v) { return value.setValue(cx, v); } diff --git a/js/src/jsiter.h b/js/src/jsiter.h index e5d87ba97f39..ef4383544369 100644 --- a/js/src/jsiter.h +++ b/js/src/jsiter.h @@ -300,10 +300,10 @@ class ForOfIterator return ok && !currentValue.get().isMagic(JS_NO_ITER_VALUE); } - Value &value() { + MutableHandleValue value() { JS_ASSERT(ok); JS_ASSERT(!closed); - return currentValue.get(); + return ¤tValue; } bool close() { From 386f5285db5f26fa2d69b8e87df38e33f6453f55 Mon Sep 17 00:00:00 2001 From: Jim Chen Date: Wed, 31 Jul 2013 13:26:21 -0400 Subject: [PATCH 26/40] Backout rev 9497429e8463 (bug 881018) to land real fix --- gfx/layers/TiledLayerBuffer.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/gfx/layers/TiledLayerBuffer.h b/gfx/layers/TiledLayerBuffer.h index 8bc1be2d69ad..e6fe6ea07753 100644 --- a/gfx/layers/TiledLayerBuffer.h +++ b/gfx/layers/TiledLayerBuffer.h @@ -111,16 +111,7 @@ public: bool RemoveTile(int x, int y, Tile& aRemovedTile); uint16_t GetTileLength() const { return TILEDLAYERBUFFER_TILE_SIZE; } - uint32_t GetScaledTileLength() const { - // volatile variables to help investigate bug 881018 - volatile float resolution = mResolution; - volatile float fScaledLength = TILEDLAYERBUFFER_TILE_SIZE / mResolution; - volatile uint32_t uiScaledLength = TILEDLAYERBUFFER_TILE_SIZE / mResolution; - if (!uiScaledLength) { - MOZ_CRASH(); - } - return uiScaledLength; - } + uint32_t GetScaledTileLength() const { return TILEDLAYERBUFFER_TILE_SIZE / mResolution; } unsigned int GetTileCount() const { return mRetainedTiles.Length(); } From c8dbf2cdac5cb9bb91123d6011a02c32d1c8e40e Mon Sep 17 00:00:00 2001 From: Jim Chen Date: Wed, 31 Jul 2013 13:26:44 -0400 Subject: [PATCH 27/40] Bug 881018 - Never inline TiledLayerBuffer::GetScaledTileLength to avoid crash; r=Cwiiis --- gfx/layers/TiledLayerBuffer.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gfx/layers/TiledLayerBuffer.h b/gfx/layers/TiledLayerBuffer.h index e6fe6ea07753..fb9f2cd780b7 100644 --- a/gfx/layers/TiledLayerBuffer.h +++ b/gfx/layers/TiledLayerBuffer.h @@ -111,6 +111,10 @@ public: bool RemoveTile(int x, int y, Tile& aRemovedTile); uint16_t GetTileLength() const { return TILEDLAYERBUFFER_TILE_SIZE; } + +#ifdef MOZ_WIDGET_ANDROID + MOZ_NEVER_INLINE // bug 881018 causes wrong results when GetScaledTileLength is inlined +#endif uint32_t GetScaledTileLength() const { return TILEDLAYERBUFFER_TILE_SIZE / mResolution; } unsigned int GetTileCount() const { return mRetainedTiles.Length(); } From 768b175839c776217bf988533c42cebd8b289f31 Mon Sep 17 00:00:00 2001 From: Tanvi Vyas Date: Wed, 31 Jul 2013 10:43:38 -0700 Subject: [PATCH 28/40] Bug 890963 - Update site identity message for pages where Mixed Active Content has loaded. r=dolske? --- browser/base/content/browser.js | 2 +- browser/locales/en-US/chrome/browser/browser.properties | 2 +- browser/themes/shared/identity-block.inc.css | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 74fb30e98496..0a1ed4177bdd 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -6406,7 +6406,7 @@ var gIdentityHandler = { this._encryptionLabel[this.IDENTITY_MODE_MIXED_DISPLAY_LOADED] = gNavigatorBundle.getString("identity.mixed_display_loaded"); this._encryptionLabel[this.IDENTITY_MODE_MIXED_ACTIVE_LOADED] = - gNavigatorBundle.getString("identity.mixed_active_loaded"); + gNavigatorBundle.getString("identity.mixed_active_loaded2"); this._encryptionLabel[this.IDENTITY_MODE_MIXED_DISPLAY_LOADED_ACTIVE_BLOCKED] = gNavigatorBundle.getString("identity.mixed_display_loaded_active_blocked"); return this._encryptionLabel; diff --git a/browser/locales/en-US/chrome/browser/browser.properties b/browser/locales/en-US/chrome/browser/browser.properties index d6b740b8fabb..8a7325a416b9 100644 --- a/browser/locales/en-US/chrome/browser/browser.properties +++ b/browser/locales/en-US/chrome/browser/browser.properties @@ -260,7 +260,7 @@ identity.identified.state_and_country=%S, %S identity.encrypted2=The connection to this website is secure. identity.mixed_display_loaded=The connection to this website is not fully secure because it contains unencrypted elements (such as images). identity.mixed_display_loaded_active_blocked=Interactive content (such as script) that isn't encrypted has been blocked for your protection. -identity.mixed_active_loaded=This website contains interactive content that isn't encrypted (such as scripts). Other people can view or modify the website's behavior. +identity.mixed_active_loaded2=This website contains interactive content that isn't encrypted (such as scripts). Other people can view your information or modify the website's behavior. identity.unencrypted=Your connection to this website is not encrypted. identity.unknown.tooltip=This website does not supply identity information. diff --git a/browser/themes/shared/identity-block.inc.css b/browser/themes/shared/identity-block.inc.css index a7fa7e8e60a0..59e078881b8f 100644 --- a/browser/themes/shared/identity-block.inc.css +++ b/browser/themes/shared/identity-block.inc.css @@ -86,3 +86,7 @@ margin-top: .5em; margin-bottom: .5em; } + +#identity-popup-content-box { + max-width: 50ch; +} From 926ee7435cf544c05ba334ff69f5e70739ee34a2 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Wed, 31 Jul 2013 18:02:05 +0100 Subject: [PATCH 29/40] Bug 899990 - Null check xhr.response to avoid spammy JS exceptions; r=jdm --HG-- extra : rebase_source : d1b78bc695896565c8ac7d327da62f324a44bb51 --- dom/system/NetworkGeolocationProvider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom/system/NetworkGeolocationProvider.js b/dom/system/NetworkGeolocationProvider.js index b1d679da5eb2..f533bad30136 100755 --- a/dom/system/NetworkGeolocationProvider.js +++ b/dom/system/NetworkGeolocationProvider.js @@ -185,7 +185,7 @@ WifiGeoPositionProvider.prototype = { return; } - if (!xhr.response.location) { + if (!xhr.response || !xhr.response.location) { return; } From 2c2ca3d74303ee1fe8a90557d9d94875ae0d714a Mon Sep 17 00:00:00 2001 From: Jonathan Griffin Date: Wed, 31 Jul 2013 10:55:44 -0700 Subject: [PATCH 30/40] Bug 900080 - Use e.message instead of e in onPacket errors, r=wlach --- testing/marionette/marionette-server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/marionette/marionette-server.js b/testing/marionette/marionette-server.js index 493b35c1043d..6c7da89cfeb4 100644 --- a/testing/marionette/marionette-server.js +++ b/testing/marionette/marionette-server.js @@ -168,7 +168,7 @@ MarionetteServerConnection.prototype = { } catch(e) { this.conn.send({ error: ("error occurred while processing '" + aPacket.type), - message: e }); + message: e.message }); } } else { this.conn.send({ error: "unrecognizedPacketType", From 2b32beaaad06547b4c961bc81cc447a0eec8dbb7 Mon Sep 17 00:00:00 2001 From: Martijn Wargers Date: Wed, 31 Jul 2013 11:30:54 +0200 Subject: [PATCH 31/40] Bug 899939 - Fix some tests that still use prefBranch instead of SpecialPowers.pushPrefEnv. r=jmaher --- content/svg/content/test/test_switch.xhtml | 11 +-- .../generic/test/test_movement_by_words.html | 82 ++++++++----------- testing/mochitest/b2g.json | 2 - 3 files changed, 37 insertions(+), 58 deletions(-) diff --git a/content/svg/content/test/test_switch.xhtml b/content/svg/content/test/test_switch.xhtml index e3f16e766255..f8386c19b26e 100644 --- a/content/svg/content/test/test_switch.xhtml +++ b/content/svg/content/test/test_switch.xhtml @@ -45,14 +45,12 @@ function checkWidth(element, x, y, w, h) function run() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); // Set accept_languages to something we know - var prefService = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefService); - var branch = prefService.getBranch("intl."); - var oldAcceptLanguages = branch.getCharPref("accept_languages"); - branch.setCharPref("accept_languages", "en-gb,en,it"); + SpecialPowers.pushPrefEnv({"set": [["intl.accept_languages", "en-gb,en,it"]]}, run1); +} +function run1() +{ try { var doc = $("svg").contentDocument; var s = doc.getElementById("s"); @@ -93,7 +91,6 @@ function run() checkWidth(s, 75, 100, 50, 50); } finally { - branch.setCharPref("accept_languages", oldAcceptLanguages); SimpleTest.finish(); } } diff --git a/layout/generic/test/test_movement_by_words.html b/layout/generic/test/test_movement_by_words.html index dbbb154de1ad..e272bd347e2f 100644 --- a/layout/generic/test/test_movement_by_words.html +++ b/layout/generic/test/test_movement_by_words.html @@ -27,54 +27,45 @@ function focusing() { } var eatSpace; +var wordModifiers = + (navigator.platform.indexOf("Mac") >= 0) ? {altKey:true} : {ctrlKey:true}; +var sel = window.getSelection(); +var editor = document.getElementById("editor"); -function getPrefs() { - const prefSvcContractID = "@mozilla.org/preferences-service;1"; - const prefSvcIID = Components.interfaces.nsIPrefService; - return Components.classes[prefSvcContractID].getService(prefSvcIID) - .getBranch("layout.word_select."); +function setPrefs(eat_space, stop_at_punctuation, callback) { + SpecialPowers.pushPrefEnv({"set": [["layout.word_select.eat_space_to_next_word", eat_space], ["layout.word_select.stop_at_punctuation", stop_at_punctuation]]}, callback); } -function setPrefs(eat_space, stop_at_punctuation) { - getPrefs().setBoolPref("eat_space_to_next_word", eat_space); - getPrefs().setBoolPref("stop_at_punctuation", stop_at_punctuation); - eatSpace = eat_space; +function errString(dir) { + return dir + " movement broken with eatSpace=" + eatSpace + " in \"" + editor.innerHTML + + "\"; sel.anchorNode.parentNode=" + sel.anchorNode.parentNode; } -function restorePrefs() { - getPrefs().clearUserPref("eat_space_to_next_word"); - getPrefs().clearUserPref("stop_at_punctuation"); +function testRight(node, offset) { + synthesizeKey("VK_RIGHT", wordModifiers); + is(sel.anchorNode, node, errString("Right")); + is(sel.anchorOffset, offset, errString("Right")); } +function testLeft(node, offset) { + synthesizeKey("VK_LEFT", wordModifiers); + is(sel.anchorNode, node, errString("Left")); + is(sel.anchorOffset, offset, errString("Left")); +} + +var afterEditorNode = document.getElementById("catch").firstChild; + +var ChineseChars = "漢字"; +var HiraganaChars = "ひらがな"; +var KatakanaChars = "カタカナ"; +var JapaneseFullStop = "。"; +var JapaneseComma = "、"; + function test() { - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - - var wordModifiers = - (navigator.platform.indexOf("Mac") >= 0) ? {altKey:true} : {ctrlKey:true}; - var sel = window.getSelection(); - var editor = document.getElementById("editor"); - - function errString(dir) { - return dir + " movement broken with eatSpace=" + eatSpace + " in \"" + editor.innerHTML + - "\"; sel.anchorNode.parentNode=" + sel.anchorNode.parentNode; - } - - function testRight(node, offset) { - synthesizeKey("VK_RIGHT", wordModifiers); - is(sel.anchorNode, node, errString("Right")); - is(sel.anchorOffset, offset, errString("Right")); - } - - function testLeft(node, offset) { - synthesizeKey("VK_LEFT", wordModifiers); - is(sel.anchorNode, node, errString("Left")); - is(sel.anchorOffset, offset, errString("Left")); - } - - var afterEditorNode = document.getElementById("catch").firstChild; - - setPrefs(false, true); + setPrefs(false, true, test1); +} +function test1() { editor.innerHTML = "Hello Kitty"; sel.collapse(editor.firstChild, 0); testRight(editor.firstChild, 5); @@ -127,12 +118,6 @@ function test() { testLeft(editor.firstChild, 5); testLeft(editor.firstChild, 0); - var ChineseChars = "漢字"; - var HiraganaChars = "ひらがな"; - var KatakanaChars = "カタカナ"; - var JapaneseFullStop = "。"; - var JapaneseComma = "、"; - editor.innerHTML = ChineseChars + HiraganaChars + ChineseChars; sel.collapse(editor.firstChild, 0); testRight(editor.firstChild, 2); @@ -187,10 +172,11 @@ function test() { testLeft(editor.firstChild, 3); testLeft(editor.firstChild, 0); - setPrefs(true, true); - // test basic word movement with eat_space_next_to_word true. + setPrefs(true, true, test2); +} +function test2() { editor.innerHTML = "Hello Kitty"; sel.collapse(editor.firstChild, 0); testRight(editor.firstChild, 6); @@ -295,8 +281,6 @@ function test() { testLeft(editor.firstChild, 3); testLeft(editor.firstChild, 0); - restorePrefs(); - SimpleTest.finish(); } diff --git a/testing/mochitest/b2g.json b/testing/mochitest/b2g.json index 6e586a76cd15..bff4f128bf7d 100644 --- a/testing/mochitest/b2g.json +++ b/testing/mochitest/b2g.json @@ -209,7 +209,6 @@ "content/html/document/test/test_bug369370.html":"", "content/html/document/test/test_bug391777.html":"", "content/svg/content/test/test_SVGAnimatedImageSMILDisabled.html":"", - "content/svg/content/test/test_switch.xhtml":"", "content/xml/document/test/test_bug392338.html":"", "content/xslt/tests/mochitest/test_bug319374.xhtml":"", "content/base/test/test_bothCSPheaders.html":"", @@ -432,7 +431,6 @@ "layout/generic/test/test_image_selection_2.html":"", "layout/generic/test/test_invalidate_during_plugin_paint.html":"", "layout/generic/test/test_movement_by_characters.html":"", - "layout/generic/test/test_movement_by_words.html":"", "layout/generic/test/test_page_scroll_with_fixed_pos.html":"", "layout/generic/test/test_plugin_clipping.xhtml":"", "layout/generic/test/test_plugin_clipping2.xhtml":"", From f886fc6f1079b5e3b38ea5ae3d51e96fd84fa14c Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Wed, 31 Jul 2013 12:51:58 +0200 Subject: [PATCH 32/40] Bug 852250 - When restarting recompute the process startup timestamp instead of using the timestamp stored it in MOZ_APP_RESTART during the shutdown procedure. r=nfroyd --- xpcom/ds/TimeStamp.cpp | 64 ++++++++++++++++++++++++++++++++++ xpcom/ds/TimeStamp.h | 10 ++++++ xpcom/ds/TimeStamp_darwin.cpp | 48 ++----------------------- xpcom/ds/TimeStamp_posix.cpp | 64 ++++++---------------------------- xpcom/ds/TimeStamp_windows.cpp | 49 +++----------------------- xpcom/ds/moz.build | 1 + 6 files changed, 93 insertions(+), 143 deletions(-) create mode 100644 xpcom/ds/TimeStamp.cpp diff --git a/xpcom/ds/TimeStamp.cpp b/xpcom/ds/TimeStamp.cpp new file mode 100644 index 000000000000..ac8c97c4c268 --- /dev/null +++ b/xpcom/ds/TimeStamp.cpp @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* 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/. */ + +/* + * Implementation of the OS-independent methods of the TimeStamp class + */ + +#include "mozilla/TimeStamp.h" +#include "prenv.h" + +namespace mozilla { + +TimeStamp TimeStamp::sFirstTimeStamp; +TimeStamp TimeStamp::sProcessCreation; + +TimeStamp +TimeStamp::ProcessCreation(bool& aIsInconsistent) +{ + aIsInconsistent = false; + + if (sProcessCreation.IsNull()) { + char *mozAppRestart = PR_GetEnv("MOZ_APP_RESTART"); + TimeStamp ts; + + /* When calling PR_SetEnv() with an empty value the existing variable may + * be unset or set to the empty string depending on the underlying platform + * thus we have to check if the variable is present and not empty. */ + if (mozAppRestart && (strcmp(mozAppRestart, "") != 0)) { + /* Firefox was restarted, use the first time-stamp we've taken as the new + * process startup time and unset MOZ_APP_RESTART. */ + ts = sFirstTimeStamp; + PR_SetEnv("MOZ_APP_RESTART="); + } else { + TimeStamp now = Now(); + uint64_t uptime = ComputeProcessUptime(); + + ts = now - TimeDuration::FromMicroseconds(uptime); + + if ((ts > sFirstTimeStamp) || (uptime == 0)) { + /* If the process creation timestamp was inconsistent replace it with + * the first one instead and notify that a telemetry error was + * detected. */ + aIsInconsistent = true; + ts = sFirstTimeStamp; + } + } + + sProcessCreation = ts; + } + + return sProcessCreation; +} + +void +TimeStamp::RecordProcessRestart() +{ + PR_SetEnv("MOZ_APP_RESTART=1"); + sProcessCreation = TimeStamp(); +} + +} // namespace mozilla diff --git a/xpcom/ds/TimeStamp.h b/xpcom/ds/TimeStamp.h index 23bbdec8551f..feb13b9a037d 100644 --- a/xpcom/ds/TimeStamp.h +++ b/xpcom/ds/TimeStamp.h @@ -342,6 +342,16 @@ private: static TimeStamp Now(bool aHighResolution); + /** + * Computes the uptime of the current process in microseconds. The result + * is platform-dependent and needs to be checked against existing timestamps + * for consistency. + * + * @returns The number of microseconds since the calling process was started + * or 0 if an error was encountered while computing the uptime + */ + static uint64_t ComputeProcessUptime(); + /** * When built with PRIntervalTime, a value of 0 means this instance * is "null". Otherwise, the low 32 bits represent a PRIntervalTime, diff --git a/xpcom/ds/TimeStamp_darwin.cpp b/xpcom/ds/TimeStamp_darwin.cpp index a5dc5a8ff884..b2bd1f686295 100644 --- a/xpcom/ds/TimeStamp_darwin.cpp +++ b/xpcom/ds/TimeStamp_darwin.cpp @@ -24,7 +24,6 @@ #include "mozilla/TimeStamp.h" #include "nsCRT.h" -#include "prenv.h" #include "prprf.h" // Estimate of the smallest duration of time we can measure. @@ -83,9 +82,6 @@ ClockResolutionNs() namespace mozilla { -TimeStamp TimeStamp::sFirstTimeStamp; -TimeStamp TimeStamp::sProcessCreation; - double TimeDuration::ToSeconds() const { @@ -176,8 +172,8 @@ TimeStamp::Now(bool aHighResolution) // Computes and returns the process uptime in microseconds. // Returns 0 if an error was encountered. -static uint64_t -ComputeProcessUptime() +uint64_t +TimeStamp::ComputeProcessUptime() { struct timeval tv; int rv = gettimeofday(&tv, NULL); @@ -212,42 +208,4 @@ ComputeProcessUptime() return now - startTime; } -TimeStamp -TimeStamp::ProcessCreation(bool& aIsInconsistent) -{ - aIsInconsistent = false; - - if (sProcessCreation.IsNull()) { - char *mozAppRestart = PR_GetEnv("MOZ_APP_RESTART"); - TimeStamp ts; - - if (mozAppRestart) { - ts = TimeStamp(nsCRT::atoll(mozAppRestart)); - } else { - TimeStamp now = TimeStamp::Now(); - uint64_t uptime = ComputeProcessUptime(); - - ts = now - TimeDuration::FromMicroseconds(uptime); - - if ((ts > sFirstTimeStamp) || (uptime == 0)) { - // If the process creation timestamp was inconsistent replace it with the - // first one instead and notify that a telemetry error was detected. - aIsInconsistent = true; - ts = sFirstTimeStamp; - } - } - - sProcessCreation = ts; - } - - return sProcessCreation; -} - -void -TimeStamp::RecordProcessRestart() -{ - PR_SetEnv(PR_smprintf("MOZ_APP_RESTART=%lld", ClockTime())); - sProcessCreation = TimeStamp(); -} - -} +} // namespace mozilla diff --git a/xpcom/ds/TimeStamp_posix.cpp b/xpcom/ds/TimeStamp_posix.cpp index e3d090cf35fd..c3af59227727 100644 --- a/xpcom/ds/TimeStamp_posix.cpp +++ b/xpcom/ds/TimeStamp_posix.cpp @@ -48,7 +48,6 @@ #include "mozilla/TimeStamp.h" #include "nsCRT.h" -#include "prenv.h" #include "prprf.h" #include "prthread.h" @@ -132,9 +131,6 @@ ClockResolutionNs() namespace mozilla { -TimeStamp TimeStamp::sFirstTimeStamp; -TimeStamp TimeStamp::sProcessCreation; - double TimeDuration::ToSeconds() const { @@ -283,11 +279,11 @@ ComputeProcessUptimeThread(void *aTime) *uptime = ((threadJiffies - selfJiffies) * kNsPerSec) / hz; } -// Computes and returns the process uptime in ns on Linux & its derivatives. +// Computes and returns the process uptime in us on Linux & its derivatives. // Returns 0 if an error was encountered. -static uint64_t -ComputeProcessUptime() +uint64_t +TimeStamp::ComputeProcessUptime() { uint64_t uptime = 0; PRThread *thread = PR_CreateThread(PR_USER_THREAD, @@ -300,17 +296,17 @@ ComputeProcessUptime() PR_JoinThread(thread); - return uptime; + return uptime / kNsPerUs; } #elif defined(__DragonFly__) || defined(__FreeBSD__) \ || defined(__NetBSD__) || defined(__OpenBSD__) -// Computes and returns the process uptime in ns on various BSD flavors. +// Computes and returns the process uptime in us on various BSD flavors. // Returns 0 if an error was encountered. -static uint64_t -ComputeProcessUptime() +uint64_t +TimeStamp::ComputeProcessUptime() { struct timespec ts; int rv = clock_gettime(CLOCK_REALTIME, &ts); @@ -345,55 +341,17 @@ ComputeProcessUptime() if (startTime > now) return 0; - return (now - startTime); + return (now - startTime) / kNsPerUs; } #else -static uint64_t -ComputeProcessUptime() +uint64_t +TimeStamp::ComputeProcessUptime() { return 0; } #endif -TimeStamp -TimeStamp::ProcessCreation(bool& aIsInconsistent) -{ - aIsInconsistent = false; - - if (sProcessCreation.IsNull()) { - char *mozAppRestart = PR_GetEnv("MOZ_APP_RESTART"); - TimeStamp ts; - - if (mozAppRestart) { - ts = TimeStamp(nsCRT::atoll(mozAppRestart)); - } else { - TimeStamp now = TimeStamp::Now(); - uint64_t uptime = ComputeProcessUptime(); - - ts = now - TimeDuration::FromMicroseconds(uptime / 1000); - - if ((ts > sFirstTimeStamp) || (uptime == 0)) { - // If the process creation timestamp was inconsistent replace it with the - // first one instead and notify that a telemetry error was detected. - aIsInconsistent = true; - ts = sFirstTimeStamp; - } - } - - sProcessCreation = ts; - } - - return sProcessCreation; -} - -void -TimeStamp::RecordProcessRestart() -{ - PR_SetEnv(PR_smprintf("MOZ_APP_RESTART=%lld", ClockTimeNs())); - sProcessCreation = TimeStamp(); -} - -} +} // namespace mozilla diff --git a/xpcom/ds/TimeStamp_windows.cpp b/xpcom/ds/TimeStamp_windows.cpp index 93f519d883b8..55a876d28118 100644 --- a/xpcom/ds/TimeStamp_windows.cpp +++ b/xpcom/ds/TimeStamp_windows.cpp @@ -18,7 +18,6 @@ #include "nsCRT.h" #include "prlog.h" -#include "prenv.h" #include "prprf.h" #include @@ -183,9 +182,6 @@ static DWORD sLastGTCRollover = 0; namespace mozilla { -TimeStamp TimeStamp::sFirstTimeStamp; -TimeStamp TimeStamp::sProcessCreation; - typedef ULONGLONG (WINAPI* GetTickCount64_t)(); static GetTickCount64_t sGetTickCount64 = nullptr; @@ -562,11 +558,11 @@ TimeStamp::Now(bool aHighResolution) return TimeStamp(TimeStampValue(GTC, QPC, useQPC)); } -// Computes and returns the current process uptime in microseconds. -// Returns 0 if an error was encountered while computing the uptime. +// Computes and returns the process uptime in microseconds. +// Returns 0 if an error was encountered. -static uint64_t -ComputeProcessUptime() +uint64_t +TimeStamp::ComputeProcessUptime() { SYSTEMTIME nowSys; GetSystemTime(&nowSys); @@ -595,41 +591,4 @@ ComputeProcessUptime() return (nowUsec.QuadPart - startUsec.QuadPart) / 10ULL; } -TimeStamp -TimeStamp::ProcessCreation(bool& aIsInconsistent) -{ - aIsInconsistent = false; - - if (sProcessCreation.IsNull()) { - char *mozAppRestart = PR_GetEnv("MOZ_APP_RESTART"); - TimeStamp ts; - - if (mozAppRestart) { - ts = TimeStamp(TimeStampValue(nsCRT::atoll(mozAppRestart), 0, false)); - } else { - TimeStamp now = TimeStamp::Now(); - uint64_t uptime = ComputeProcessUptime(); - ts = now - TimeDuration::FromMicroseconds(static_cast(uptime)); - - if ((ts > sFirstTimeStamp) || (uptime == 0)) { - // If the process creation timestamp was inconsistent replace it with the - // first one instead and notify that a telemetry error was detected. - aIsInconsistent = true; - ts = sFirstTimeStamp; - } - } - - sProcessCreation = ts; - } - - return sProcessCreation; -} - -void -TimeStamp::RecordProcessRestart() -{ - PR_SetEnv(PR_smprintf("MOZ_APP_RESTART=%lld", ms2mt(sGetTickCount64()))); - sProcessCreation = TimeStamp(); -} - } // namespace mozilla diff --git a/xpcom/ds/moz.build b/xpcom/ds/moz.build index af6a5a16abed..cd4b7825d369 100644 --- a/xpcom/ds/moz.build +++ b/xpcom/ds/moz.build @@ -95,6 +95,7 @@ CPP_SOURCES += [ 'nsSupportsPrimitives.cpp', 'nsUnicharBuffer.cpp', 'nsVariant.cpp', + 'TimeStamp.cpp', ] if CONFIG['OS_ARCH'] == 'WINNT': From f76a4b028fa9d38a8bbf6944981d84f215878887 Mon Sep 17 00:00:00 2001 From: Mihnea Dobrescu-Balaur Date: Wed, 24 Jul 2013 22:35:43 -0700 Subject: [PATCH 33/40] Bug 889182 - mozapps/extensions xpcshell tests cannot be run concurrently. r=Unfocused --- .../test/addons/blocklist_hard1_1/install.rdf | 1 - .../test/addons/blocklist_hard1_2/install.rdf | 1 - .../test/addons/blocklist_hard1_3/install.rdf | 1 - .../addons/blocklist_regexp1_1/install.rdf | 1 - .../addons/blocklist_regexp1_2/install.rdf | 1 - .../addons/blocklist_regexp1_3/install.rdf | 1 - .../test/addons/blocklist_soft1_1/install.rdf | 1 - .../test/addons/blocklist_soft1_2/install.rdf | 1 - .../test/addons/blocklist_soft1_3/install.rdf | 1 - .../test/addons/blocklist_soft2_1/install.rdf | 1 - .../test/addons/blocklist_soft2_2/install.rdf | 1 - .../test/addons/blocklist_soft2_3/install.rdf | 1 - .../test/addons/blocklist_soft3_1/install.rdf | 1 - .../test/addons/blocklist_soft3_2/install.rdf | 1 - .../test/addons/blocklist_soft3_3/install.rdf | 1 - .../test/addons/blocklist_soft4_1/install.rdf | 1 - .../test/addons/blocklist_soft4_2/install.rdf | 1 - .../test/addons/blocklist_soft4_3/install.rdf | 1 - .../test/addons/blocklist_soft5_1/install.rdf | 1 - .../test/addons/blocklist_soft5_2/install.rdf | 1 - .../test/addons/blocklist_soft5_3/install.rdf | 1 - .../addons/test_AddonRepository_1/install.rdf | 8 +- .../test/addons/test_bug463819_1/install.rdf | 18 --- .../test/addons/test_bug463819_2/install.rdf | 18 --- .../test/addons/test_bug463819_3/install.rdf | 18 --- .../test/addons/test_bug463819_4/install.rdf | 18 --- .../test/addons/test_bug463819_5/install.rdf | 18 --- .../test/addons/test_bug463819_6/install.rdf | 18 --- .../test/addons/test_bug463819_7/install.rdf | 18 --- .../test/addons/test_bug463819_8/install.rdf | 18 --- .../test/addons/test_bug463819_9/install.rdf | 18 --- .../test/addons/test_bug470377_1/install.rdf | 1 - .../test/addons/test_bug470377_2/install.rdf | 1 - .../test/addons/test_bug470377_3/install.rdf | 1 - .../test/addons/test_bug470377_4/install.rdf | 1 - .../test/addons/test_bug470377_5/install.rdf | 1 - .../test/addons/test_bug567184/install.rdf | 3 - .../test/addons/test_bug655254/install.rdf | 1 - .../data/blocklistchange/addon_update1.rdf | 14 +- .../data/blocklistchange/addon_update2.rdf | 14 +- .../data/blocklistchange/addon_update3.rdf | 14 +- .../xpcshell/data/test_AddonRepository.xml | 138 +++++++++--------- .../data/test_AddonRepository_cache.xml | 30 ++-- ...test_AddonRepository_compatmode_ignore.xml | 4 +- ...test_AddonRepository_compatmode_normal.xml | 4 +- ...test_AddonRepository_compatmode_strict.xml | 4 +- .../data/test_AddonRepository_failed.xml | 2 +- .../test_AddonRepository_getAddonsByIDs.xml | 34 ++--- .../xpcshell/data/test_backgroundupdate.rdf | 6 +- .../test/xpcshell/data/test_bug424262.xml | 32 ++-- .../xpcshell/data/test_bug470377/update_1.rdf | 2 +- .../xpcshell/data/test_bug470377/update_2.rdf | 2 +- .../xpcshell/data/test_bug470377/update_3.rdf | 2 +- .../xpcshell/data/test_bug470377/update_4.rdf | 2 +- .../xpcshell/data/test_bug470377/update_5.rdf | 2 +- .../test/xpcshell/data/test_bug554133.xml | 52 +++---- .../test/xpcshell/data/test_dictionary.rdf | 6 +- .../test/xpcshell/data/test_hotfix_1.rdf | 2 +- .../test/xpcshell/data/test_hotfix_2.rdf | 2 +- .../test/xpcshell/data/test_hotfix_3.rdf | 2 +- .../test/xpcshell/data/test_migrate4.rdf | 2 +- .../test/xpcshell/data/test_update.rdf | 18 +-- .../data/test_updatecompatmode_ignore.rdf | 2 +- .../data/test_updatecompatmode_normal.rdf | 2 +- .../data/test_updatecompatmode_strict.rdf | 2 +- .../extensions/test/xpcshell/head_addons.js | 71 ++++++++- .../test/xpcshell/test_AddonRepository.js | 45 +++--- .../test_AddonRepository_compatmode.js | 16 +- .../test/xpcshell/test_backgroundupdate.js | 19 +-- .../test/xpcshell/test_badschema.js | 14 +- .../test/xpcshell/test_blocklist_regexp.js | 16 +- .../test/xpcshell/test_blocklistchange.js | 83 ++++++----- .../test/xpcshell/test_bootstrap.js | 13 +- .../test/xpcshell/test_bug384052.js | 16 +- .../test/xpcshell/test_bug424262.js | 10 +- .../test/xpcshell/test_bug430120.js | 7 +- .../test/xpcshell/test_bug449027.js | 5 +- .../test/xpcshell/test_bug455906.js | 27 ++-- .../test/xpcshell/test_bug470377_1.js | 2 +- .../xpcshell/test_bug470377_1_strictcompat.js | 2 +- .../test/xpcshell/test_bug470377_2.js | 2 +- .../test/xpcshell/test_bug514327_3.js | 5 +- .../test/xpcshell/test_bug554133.js | 7 +- .../test/xpcshell/test_bug559800.js | 10 +- .../test/xpcshell/test_bug570173.js | 5 +- .../test/xpcshell/test_bug619730.js | 12 +- .../test/xpcshell/test_bug620837.js | 6 +- .../test/xpcshell/test_bug655254.js | 13 +- .../test/xpcshell/test_compatoverrides.js | 17 ++- .../extensions/test/xpcshell/test_corrupt.js | 19 +-- .../xpcshell/test_corrupt_strictcompat.js | 20 +-- .../test/xpcshell/test_dictionary.js | 23 +-- .../extensions/test/xpcshell/test_dss.js | 42 +++--- .../test/xpcshell/test_filepointer.js | 5 +- .../test/xpcshell/test_gfxBlacklist_Device.js | 12 +- .../xpcshell/test_gfxBlacklist_DriverNew.js | 12 +- .../test_gfxBlacklist_Equal_DriverNew.js | 12 +- .../test_gfxBlacklist_Equal_DriverOld.js | 12 +- .../xpcshell/test_gfxBlacklist_Equal_OK.js | 12 +- .../test_gfxBlacklist_GTE_DriverOld.js | 12 +- .../test/xpcshell/test_gfxBlacklist_GTE_OK.js | 12 +- .../test_gfxBlacklist_No_Comparison.js | 12 +- .../test/xpcshell/test_gfxBlacklist_OK.js | 12 +- .../test/xpcshell/test_gfxBlacklist_OS.js | 12 +- .../test_gfxBlacklist_OSVersion_match.js | 11 +- ...cklist_OSVersion_mismatch_DriverVersion.js | 11 +- ...xBlacklist_OSVersion_mismatch_OSVersion.js | 11 +- .../test/xpcshell/test_gfxBlacklist_Vendor.js | 12 +- .../test/xpcshell/test_gfxBlacklist_prefs.js | 12 +- .../extensions/test/xpcshell/test_hotfix.js | 36 +++-- .../extensions/test/xpcshell/test_install.js | 63 ++++---- .../test/xpcshell/test_install_icons.js | 12 +- .../extensions/test/xpcshell/test_locked.js | 16 +- .../test/xpcshell/test_locked_strictcompat.js | 16 +- .../test/xpcshell/test_mapURIToAddonID.js | 8 - .../extensions/test/xpcshell/test_migrate3.js | 10 +- .../extensions/test/xpcshell/test_migrate4.js | 26 ++-- .../xpcshell/test_migrateAddonRepository.js | 4 +- .../test/xpcshell/test_pluginBlocklistCtp.js | 29 ++-- .../extensions/test/xpcshell/test_theme.js | 36 ++--- .../extensions/test/xpcshell/test_update.js | 112 +++++++------- .../test/xpcshell/test_update_compatmode.js | 23 +-- .../test/xpcshell/test_update_ignorecompat.js | 20 +-- .../test/xpcshell/test_update_strictcompat.js | 78 +++++----- .../extensions/test/xpcshell/xpcshell.ini | 12 ++ 125 files changed, 872 insertions(+), 934 deletions(-) delete mode 100644 toolkit/mozapps/extensions/test/addons/test_bug463819_1/install.rdf delete mode 100644 toolkit/mozapps/extensions/test/addons/test_bug463819_2/install.rdf delete mode 100644 toolkit/mozapps/extensions/test/addons/test_bug463819_3/install.rdf delete mode 100644 toolkit/mozapps/extensions/test/addons/test_bug463819_4/install.rdf delete mode 100644 toolkit/mozapps/extensions/test/addons/test_bug463819_5/install.rdf delete mode 100644 toolkit/mozapps/extensions/test/addons/test_bug463819_6/install.rdf delete mode 100644 toolkit/mozapps/extensions/test/addons/test_bug463819_7/install.rdf delete mode 100644 toolkit/mozapps/extensions/test/addons/test_bug463819_8/install.rdf delete mode 100644 toolkit/mozapps/extensions/test/addons/test_bug463819_9/install.rdf diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_hard1_1/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_hard1_1/install.rdf index 76cb372c67f8..7b1b02a17e5c 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_hard1_1/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_hard1_1/install.rdf @@ -7,7 +7,6 @@ hardblock@tests.mozilla.org 1.0 Hardblocked add-on - http://localhost:4444/data/addon_update1.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_hard1_2/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_hard1_2/install.rdf index ebfbb4050544..ae364637e106 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_hard1_2/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_hard1_2/install.rdf @@ -7,7 +7,6 @@ hardblock@tests.mozilla.org 2.0 Hardblocked add-on - http://localhost:4444/data/addon_update2.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_hard1_3/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_hard1_3/install.rdf index a7978e1c8dd6..568c41a43fc8 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_hard1_3/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_hard1_3/install.rdf @@ -7,7 +7,6 @@ hardblock@tests.mozilla.org 3.0 Hardblocked add-on - http://localhost:4444/data/addon_update3.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_1/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_1/install.rdf index fd3b25ed7c0e..1281ab53f6a4 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_1/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_1/install.rdf @@ -7,7 +7,6 @@ regexpblock@tests.mozilla.org 1.0 RegExp-blocked add-on - http://localhost:4444/data/addon_update1.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_2/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_2/install.rdf index 3325bd7a3ec8..8b6dd09f5fe8 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_2/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_2/install.rdf @@ -7,7 +7,6 @@ regexpblock@tests.mozilla.org 2.0 RegExp-blocked add-on - http://localhost:4444/data/addon_update2.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_3/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_3/install.rdf index 5ddf66c8f75f..fade395f9863 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_3/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_regexp1_3/install.rdf @@ -7,7 +7,6 @@ regexpblock@tests.mozilla.org 3.0 RegExp-blocked add-on - http://localhost:4444/data/addon_update3.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft1_1/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft1_1/install.rdf index e2d910be6103..4a18f64e00c6 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft1_1/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft1_1/install.rdf @@ -7,7 +7,6 @@ softblock1@tests.mozilla.org 1.0 Softblocked add-on - http://localhost:4444/data/addon_update1.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft1_2/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft1_2/install.rdf index 1d58dbb962c0..8a2519222726 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft1_2/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft1_2/install.rdf @@ -7,7 +7,6 @@ softblock1@tests.mozilla.org 2.0 Softblocked add-on - http://localhost:4444/data/addon_update2.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft1_3/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft1_3/install.rdf index e9094cc9738d..2c55e5ff7c0a 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft1_3/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft1_3/install.rdf @@ -7,7 +7,6 @@ softblock1@tests.mozilla.org 3.0 Softblocked add-on - http://localhost:4444/data/addon_update3.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft2_1/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft2_1/install.rdf index 3026fa2d0ba3..eebac4b21eee 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft2_1/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft2_1/install.rdf @@ -7,7 +7,6 @@ softblock2@tests.mozilla.org 1.0 Softblocked add-on - http://localhost:4444/data/addon_update1.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft2_2/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft2_2/install.rdf index 4075277861f3..f37741d044e3 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft2_2/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft2_2/install.rdf @@ -7,7 +7,6 @@ softblock2@tests.mozilla.org 2.0 Softblocked add-on - http://localhost:4444/data/addon_update2.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft2_3/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft2_3/install.rdf index efa90afd70c3..e15f99264ba5 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft2_3/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft2_3/install.rdf @@ -7,7 +7,6 @@ softblock2@tests.mozilla.org 3.0 Softblocked add-on - http://localhost:4444/data/addon_update3.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft3_1/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft3_1/install.rdf index 3d45fb20f7a3..f4b70a24b0f7 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft3_1/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft3_1/install.rdf @@ -7,7 +7,6 @@ softblock3@tests.mozilla.org 1.0 Softblocked add-on - http://localhost:4444/data/addon_update1.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft3_2/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft3_2/install.rdf index a2fcb99ba474..987204fa6073 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft3_2/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft3_2/install.rdf @@ -7,7 +7,6 @@ softblock3@tests.mozilla.org 2.0 Softblocked add-on - http://localhost:4444/data/addon_update2.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft3_3/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft3_3/install.rdf index 17efb24fa8f8..19ab4b9fe156 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft3_3/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft3_3/install.rdf @@ -7,7 +7,6 @@ softblock3@tests.mozilla.org 3.0 Softblocked add-on - http://localhost:4444/data/addon_update3.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft4_1/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft4_1/install.rdf index 02c240e26d0c..a3cd06f5fec2 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft4_1/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft4_1/install.rdf @@ -7,7 +7,6 @@ softblock4@tests.mozilla.org 1.0 Softblocked add-on - http://localhost:4444/data/addon_update1.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft4_2/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft4_2/install.rdf index 728698cb0efd..eeff9fb79625 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft4_2/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft4_2/install.rdf @@ -7,7 +7,6 @@ softblock4@tests.mozilla.org 2.0 Softblocked add-on - http://localhost:4444/data/addon_update2.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft4_3/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft4_3/install.rdf index c155342e751d..1d26506038bb 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft4_3/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft4_3/install.rdf @@ -7,7 +7,6 @@ softblock4@tests.mozilla.org 3.0 Softblocked add-on - http://localhost:4444/data/addon_update3.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft5_1/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft5_1/install.rdf index b434512e868c..85d7108d603d 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft5_1/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft5_1/install.rdf @@ -7,7 +7,6 @@ softblock5@tests.mozilla.org 1.0 Softblocked add-on - http://localhost:4444/data/addon_update1.rdf test/1.0 diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft5_2/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft5_2/install.rdf index 0f9cdea1e750..394fd909e524 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft5_2/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft5_2/install.rdf @@ -7,7 +7,6 @@ softblock5@tests.mozilla.org 2.0 Softblocked add-on - http://localhost:4444/data/addon_update2.rdf test/1.0 diff --git a/toolkit/mozapps/extensions/test/addons/blocklist_soft5_3/install.rdf b/toolkit/mozapps/extensions/test/addons/blocklist_soft5_3/install.rdf index e345d5035f4b..2a1fec25aaf6 100644 --- a/toolkit/mozapps/extensions/test/addons/blocklist_soft5_3/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/blocklist_soft5_3/install.rdf @@ -7,7 +7,6 @@ softblock5@tests.mozilla.org 3.0 Softblocked add-on - http://localhost:4444/data/addon_update3.rdf test/1.0 diff --git a/toolkit/mozapps/extensions/test/addons/test_AddonRepository_1/install.rdf b/toolkit/mozapps/extensions/test/addons/test_AddonRepository_1/install.rdf index 35024b1d975e..82cfd0472f9d 100644 --- a/toolkit/mozapps/extensions/test/addons/test_AddonRepository_1/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/test_AddonRepository_1/install.rdf @@ -25,9 +25,9 @@ XPI Add-on 1 - Second Translator XPI Add-on 1 - First Contributor XPI Add-on 1 - Second Contributor - http://localhost:4444/xpi/1/homepage.html - http://localhost:4444/xpi/1/options.html - http://localhost:4444/xpi/1/about.html - http://localhost:4444/xpi/1/icon.png + http://localhost/xpi/1/homepage.html + http://localhost/xpi/1/options.html + http://localhost/xpi/1/about.html + http://localhost/xpi/1/icon.png diff --git a/toolkit/mozapps/extensions/test/addons/test_bug463819_1/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug463819_1/install.rdf deleted file mode 100644 index 52e516cf0cf3..000000000000 --- a/toolkit/mozapps/extensions/test/addons/test_bug463819_1/install.rdf +++ /dev/null @@ -1,18 +0,0 @@ - - - - - test_bug463819_1@tests.mozilla.org - 1 - - - xpcshell@tests.mozilla.org - 1 - 2 - - - Test for Bug 463819 - http://localhost:4444/test_bug463819.rdf - - diff --git a/toolkit/mozapps/extensions/test/addons/test_bug463819_2/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug463819_2/install.rdf deleted file mode 100644 index e0cf1a7a3f98..000000000000 --- a/toolkit/mozapps/extensions/test/addons/test_bug463819_2/install.rdf +++ /dev/null @@ -1,18 +0,0 @@ - - - - - test_bug463819_2@tests.mozilla.org - 1 - - - xpcshell@tests.mozilla.org - 1 - 1 - - - Test for Bug 463819 - http://localhost:4444/test_bug463819.rdf - - diff --git a/toolkit/mozapps/extensions/test/addons/test_bug463819_3/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug463819_3/install.rdf deleted file mode 100644 index da9500a221ac..000000000000 --- a/toolkit/mozapps/extensions/test/addons/test_bug463819_3/install.rdf +++ /dev/null @@ -1,18 +0,0 @@ - - - - - test_bug463819_3@tests.mozilla.org - 1 - - - xpcshell@tests.mozilla.org - 1 - 1 - - - Test for Bug 463819 - http://localhost:4444/test_bug463819.rdf - - diff --git a/toolkit/mozapps/extensions/test/addons/test_bug463819_4/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug463819_4/install.rdf deleted file mode 100644 index 0e7a677ed133..000000000000 --- a/toolkit/mozapps/extensions/test/addons/test_bug463819_4/install.rdf +++ /dev/null @@ -1,18 +0,0 @@ - - - - - test_bug463819_4@tests.mozilla.org - 1 - - - xpcshell@tests.mozilla.org - 1 - 2 - - - Test for Bug 463819 - http://localhost:4444/test_bug463819.rdf - - diff --git a/toolkit/mozapps/extensions/test/addons/test_bug463819_5/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug463819_5/install.rdf deleted file mode 100644 index 26f295e38650..000000000000 --- a/toolkit/mozapps/extensions/test/addons/test_bug463819_5/install.rdf +++ /dev/null @@ -1,18 +0,0 @@ - - - - - test_bug463819_5@tests.mozilla.org - 1 - - - xpcshell@tests.mozilla.org - 1 - 1 - - - Test for Bug 463819 - http://localhost:4444/test_bug463819.rdf - - diff --git a/toolkit/mozapps/extensions/test/addons/test_bug463819_6/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug463819_6/install.rdf deleted file mode 100644 index 05bedeae3780..000000000000 --- a/toolkit/mozapps/extensions/test/addons/test_bug463819_6/install.rdf +++ /dev/null @@ -1,18 +0,0 @@ - - - - - test_bug463819_6@tests.mozilla.org - 1 - - - xpcshell@tests.mozilla.org - 1 - 1 - - - Test for Bug 463819 - http://localhost:4444/test_bug463819.rdf - - diff --git a/toolkit/mozapps/extensions/test/addons/test_bug463819_7/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug463819_7/install.rdf deleted file mode 100644 index 5e0f408a068c..000000000000 --- a/toolkit/mozapps/extensions/test/addons/test_bug463819_7/install.rdf +++ /dev/null @@ -1,18 +0,0 @@ - - - - - test_bug463819_7@tests.mozilla.org - 1 - - - xpcshell@tests.mozilla.org - 1 - 2 - - - Test for Bug 463819 - http://localhost:4444/test_bug463819.rdf - - diff --git a/toolkit/mozapps/extensions/test/addons/test_bug463819_8/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug463819_8/install.rdf deleted file mode 100644 index be316b531adf..000000000000 --- a/toolkit/mozapps/extensions/test/addons/test_bug463819_8/install.rdf +++ /dev/null @@ -1,18 +0,0 @@ - - - - - test_bug463819_8@tests.mozilla.org - 1 - - - xpcshell@tests.mozilla.org - 1 - 1 - - - Test for Bug 463819 - http://localhost:4444/test_bug463819.rdf - - diff --git a/toolkit/mozapps/extensions/test/addons/test_bug463819_9/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug463819_9/install.rdf deleted file mode 100644 index eead04acd377..000000000000 --- a/toolkit/mozapps/extensions/test/addons/test_bug463819_9/install.rdf +++ /dev/null @@ -1,18 +0,0 @@ - - - - - test_bug463819_9@tests.mozilla.org - 1 - - - xpcshell@tests.mozilla.org - 1 - 1 - - - Test for Bug 463819 - http://localhost:4444/test_bug463819.rdf - - diff --git a/toolkit/mozapps/extensions/test/addons/test_bug470377_1/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug470377_1/install.rdf index dd0fac7df537..5397e8a87252 100644 --- a/toolkit/mozapps/extensions/test/addons/test_bug470377_1/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/test_bug470377_1/install.rdf @@ -13,6 +13,5 @@ Test for Bug 470377 - http://localhost:4444/test_bug470377_1.rdf diff --git a/toolkit/mozapps/extensions/test/addons/test_bug470377_2/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug470377_2/install.rdf index 1a5cb538ce99..b1dde7f7ae16 100644 --- a/toolkit/mozapps/extensions/test/addons/test_bug470377_2/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/test_bug470377_2/install.rdf @@ -13,6 +13,5 @@ Test for Bug 470377 - http://localhost:4444/test_bug470377_2.rdf diff --git a/toolkit/mozapps/extensions/test/addons/test_bug470377_3/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug470377_3/install.rdf index 4f055de19d29..ae483434a664 100644 --- a/toolkit/mozapps/extensions/test/addons/test_bug470377_3/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/test_bug470377_3/install.rdf @@ -13,6 +13,5 @@ Test for Bug 470377 - http://localhost:4444/test_bug470377_3.rdf diff --git a/toolkit/mozapps/extensions/test/addons/test_bug470377_4/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug470377_4/install.rdf index d0f3505e258d..97abacc5e1a6 100644 --- a/toolkit/mozapps/extensions/test/addons/test_bug470377_4/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/test_bug470377_4/install.rdf @@ -13,6 +13,5 @@ Test for Bug 470377 - http://localhost:4444/test_bug470377_4.rdf diff --git a/toolkit/mozapps/extensions/test/addons/test_bug470377_5/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug470377_5/install.rdf index b83a440e198a..bff1104a760d 100644 --- a/toolkit/mozapps/extensions/test/addons/test_bug470377_5/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/test_bug470377_5/install.rdf @@ -13,6 +13,5 @@ Test for Bug 470377 - http://localhost:4444/test_bug470377_5.rdf diff --git a/toolkit/mozapps/extensions/test/addons/test_bug567184/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug567184/install.rdf index df88dfd796a5..1e13ceb87384 100644 --- a/toolkit/mozapps/extensions/test/addons/test_bug567184/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/test_bug567184/install.rdf @@ -12,9 +12,6 @@ Bug 567184 Test Test Description - - http://localhost:4444/data/ - xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/addons/test_bug655254/install.rdf b/toolkit/mozapps/extensions/test/addons/test_bug655254/install.rdf index 2530cce4fff4..a3fa0d70751d 100644 --- a/toolkit/mozapps/extensions/test/addons/test_bug655254/install.rdf +++ b/toolkit/mozapps/extensions/test/addons/test_bug655254/install.rdf @@ -7,7 +7,6 @@ addon1@tests.mozilla.org 1.0 Test 1 - http://localhost:4444/data/test_bug655254.rdf xpcshell@tests.mozilla.org diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.rdf index 1b55ccfab261..5882909684f8 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.rdf +++ b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.rdf @@ -13,7 +13,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft1_2.xpi + http://localhost:%PORT%/addons/blocklist_soft1_2.xpi @@ -33,7 +33,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft2_2.xpi + http://localhost:%PORT%/addons/blocklist_soft2_2.xpi @@ -53,7 +53,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft3_2.xpi + http://localhost:%PORT%/addons/blocklist_soft3_2.xpi @@ -73,7 +73,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft4_2.xpi + http://localhost:%PORT%/addons/blocklist_soft4_2.xpi @@ -93,7 +93,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft5_2.xpi + http://localhost:%PORT%/addons/blocklist_soft5_2.xpi @@ -113,7 +113,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_hard1_2.xpi + http://localhost:%PORT%/addons/blocklist_hard1_2.xpi @@ -133,7 +133,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_regexp1_2.xpi + http://localhost:%PORT%/addons/blocklist_regexp1_2.xpi diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.rdf index a5be8a6f54ff..5c3747f5f48b 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.rdf +++ b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.rdf @@ -13,7 +13,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft1_3.xpi + http://localhost:%PORT%/addons/blocklist_soft1_3.xpi @@ -33,7 +33,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft2_3.xpi + http://localhost:%PORT%/addons/blocklist_soft2_3.xpi @@ -53,7 +53,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft3_3.xpi + http://localhost:%PORT%/addons/blocklist_soft3_3.xpi @@ -73,7 +73,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft4_3.xpi + http://localhost:%PORT%/addons/blocklist_soft4_3.xpi @@ -93,7 +93,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft5_3.xpi + http://localhost:%PORT%/addons/blocklist_soft5_3.xpi @@ -113,7 +113,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_hard1_3.xpi + http://localhost:%PORT%/addons/blocklist_hard1_3.xpi @@ -133,7 +133,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_regexp1_3.xpi + http://localhost:%PORT%/addons/blocklist_regexp1_3.xpi diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.rdf index fe1a39b479bb..d6070841423c 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.rdf +++ b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.rdf @@ -13,7 +13,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft1_1.xpi + http://localhost:%PORT%/addons/blocklist_soft1_1.xpi @@ -33,7 +33,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft2_1.xpi + http://localhost:%PORT%/addons/blocklist_soft2_1.xpi @@ -53,7 +53,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft3_1.xpi + http://localhost:%PORT%/addons/blocklist_soft3_1.xpi @@ -73,7 +73,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft4_1.xpi + http://localhost:%PORT%/addons/blocklist_soft4_1.xpi @@ -93,7 +93,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_soft5_1.xpi + http://localhost:%PORT%/addons/blocklist_soft5_1.xpi @@ -113,7 +113,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_hard1_1.xpi + http://localhost:%PORT%/addons/blocklist_hard1_1.xpi @@ -133,7 +133,7 @@ toolkit@mozilla.org 0 * - http://localhost:4444/addons/blocklist_regexp1_1.xpi + http://localhost:%PORT%/addons/blocklist_regexp1_1.xpi diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository.xml b/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository.xml index f2c8454e9b3f..0bebca2c1aec 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository.xml +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository.xml @@ -9,7 +9,7 @@ Test Creator 1 - http://localhost:4444/creator1.html + http://localhost:%PORT%/creator1.html Preliminarily Reviewed @@ -26,7 +26,7 @@ -2 - http://localhost:4444/test1.xpi + http://localhost:%PORT%/test1.xpi Test Creator 2 - http://localhost:4444/creator2.html + http://localhost:%PORT%/creator2.html Test Developer 2 - http://localhost:4444/developer2.html + http://localhost:%PORT%/developer2.html <h1>Test Summary 2</h1><p>paragraph</p> @@ -54,9 +54,9 @@ Test Developer Comments 2 Test EULA 2 - http://localhost:4444/icon2-64.png - http://localhost:4444/icon2-48.png - http://localhost:4444/icon2-32.png + http://localhost:%PORT%/icon2-64.png + http://localhost:%PORT%/icon2-48.png + http://localhost:%PORT%/icon2-32.png Public @@ -68,31 +68,31 @@ - http://localhost:4444/full1-2.png - http://localhost:4444/thumbnail1-2.png + http://localhost:%PORT%/full1-2.png + http://localhost:%PORT%/thumbnail1-2.png - http://localhost:4444/full2-2.png - http://localhost:4444/thumbnail2-2.png + http://localhost:%PORT%/full2-2.png + http://localhost:%PORT%/thumbnail2-2.png Caption 2 NaN - http://localhost:4444/learnmore2.html + http://localhost:%PORT%/learnmore2.html - http://localhost:4444/support2.html + http://localhost:%PORT%/support2.html - http://localhost:4444/contribution2.html - http://localhost:4444/meetDevelopers2.html + http://localhost:%PORT%/contribution2.html + http://localhost:%PORT%/meetDevelopers2.html - http://localhost:4444/review2.html + http://localhost:%PORT%/review2.html NaN NaN NaN Not an acual date - http://localhost:4444/test2.xpi + http://localhost:%PORT%/test2.xpi @@ -106,7 +106,7 @@ - http://localhost:4444/ignore3.html + http://localhost:%PORT%/ignore3.html @@ -115,11 +115,11 @@ Test Creator 3 - http://localhost:4444/creator3.html + http://localhost:%PORT%/creator3.html First Test Developer 3 - http://localhost:4444/developer1-3.html + http://localhost:%PORT%/developer1-3.html @@ -127,14 +127,14 @@ Second Test Developer 3 - http://localhost:4444/developer2-3.html + http://localhost:%PORT%/developer2-3.html Test Summary 3 Test Description 3<br><ul><li>List item 1<li>List item 2</ul> Test Developer Comments 3 Test EULA 3 - http://localhost:4444/icon3.png + http://localhost:%PORT%/icon3.png Preliminarily Reviewed @@ -152,7 +152,7 @@ - http://localhost:4444/full2-3.png + http://localhost:%PORT%/full2-3.png Caption 2 - 3 @@ -164,13 +164,13 @@ Caption ignore - 3 - http://localhost:4444/full1-3.png - http://localhost:4444/thumbnail1-3.png + http://localhost:%PORT%/full1-3.png + http://localhost:%PORT%/thumbnail1-3.png Caption 1 - 3 - http://localhost:4444/full3-3.png - http://localhost:4444/thumbnail3-3.png + http://localhost:%PORT%/full3-3.png + http://localhost:%PORT%/thumbnail3-3.png Caption 3 - 3 @@ -179,23 +179,23 @@ 2 - http://localhost:4444/learnmore3.html - http://localhost:4444/homepage3.html - http://localhost:4444/support3.html + http://localhost:%PORT%/learnmore3.html + http://localhost:%PORT%/homepage3.html + http://localhost:%PORT%/support3.html - http://localhost:4444/contribution3.html + http://localhost:%PORT%/contribution3.html $11.11 - http://localhost:4444/meetDevelopers3.html + http://localhost:%PORT%/meetDevelopers3.html - http://localhost:4444/review3.html + http://localhost:%PORT%/review3.html 2222 3333 4444 2010-02-01T14:04:05Z - http://localhost:4444/fail3.xpi + http://localhost:%PORT%/fail3.xpi - http://localhost:4444/test3.xpi + http://localhost:%PORT%/test3.xpi @@ -213,7 +213,7 @@ 1 - http://localhost:4444/test4.xpi + http://localhost:%PORT%/test4.xpi @@ -232,7 +232,7 @@ 1 - http://localhost:4444/test5.xpi + http://localhost:%PORT%/test5.xpi @@ -250,7 +250,7 @@ 1 - http://localhost:4444/test6.xpi + http://localhost:%PORT%/test6.xpi @@ -269,7 +269,7 @@ 1 - http://localhost:4444/test7.xpi + http://localhost:%PORT%/test7.xpi @@ -288,7 +288,7 @@ 1 - http://localhost:4444/test8.xpi + http://localhost:%PORT%/test8.xpi @@ -306,7 +306,7 @@ 1 - http://localhost:4444/test9.xpi + http://localhost:%PORT%/test9.xpi @@ -325,7 +325,7 @@ 1 - http://localhost:4444/test10.xpi + http://localhost:%PORT%/test10.xpi @@ -344,7 +344,7 @@ 1 - http://localhost:4444/test11.xpi + http://localhost:%PORT%/test11.xpi @@ -363,7 +363,7 @@ 1 - http://localhost:4444/test12.xpi + http://localhost:%PORT%/test12.xpi @@ -381,7 +381,7 @@ 1 - http://localhost:4444/test13.xpi + http://localhost:%PORT%/test13.xpi @@ -400,7 +400,7 @@ 1 - http://localhost:4444/test14.xpi + http://localhost:%PORT%/test14.xpi @@ -418,7 +418,7 @@ 1 - http://localhost:4444/test15.xpi + http://localhost:%PORT%/test15.xpi @@ -437,7 +437,7 @@ 1 - http://localhost:4444/test16.xpi + http://localhost:%PORT%/test16.xpi @@ -459,7 +459,7 @@ 1 - http://localhost:4444/test17.xpi + http://localhost:%PORT%/test17.xpi @@ -477,7 +477,7 @@ 1 - http://localhost:4444/test18.xpi + http://localhost:%PORT%/test18.xpi @@ -496,7 +496,7 @@ 1 - http://localhost:4444/test19.xpi + http://localhost:%PORT%/test19.xpi @@ -508,7 +508,7 @@ Test Creator 20 Public Add-on with undefined compatible_applications should be ignored. - http://localhost:4444/test20.xpi + http://localhost:%PORT%/test20.xpi @@ -527,7 +527,7 @@ 1 - http://localhost:4444/test21.xpi + http://localhost:%PORT%/test21.xpi @@ -545,7 +545,7 @@ 2.0 - http://localhost:4444/test22.xpi + http://localhost:%PORT%/test22.xpi @@ -564,7 +564,7 @@ 2.0 - http://localhost:4444/test23.xpi + http://localhost:%PORT%/test23.xpi @@ -582,7 +582,7 @@ 0.9 - http://localhost:4444/test24.xpi + http://localhost:%PORT%/test24.xpi @@ -601,7 +601,7 @@ 0.9.9 - http://localhost:4444/test25.xpi + http://localhost:%PORT%/test25.xpi @@ -657,8 +657,8 @@ 1 - http://localhost:4444/test28.xpi - http://localhost:4444/test28.xpi + http://localhost:%PORT%/test28.xpi + http://localhost:%PORT%/test28.xpi @@ -677,7 +677,7 @@ 1 - http://localhost:4444/addons/test_AddonRepository_2.xpi + http://localhost:%PORT%/addons/test_AddonRepository_2.xpi @@ -689,7 +689,7 @@ Test Creator - Last Passing - http://localhost:4444/creatorLastPassing.html + http://localhost:%PORT%/creatorLastPassing.html Public @@ -705,7 +705,7 @@ 5 - http://localhost:4444/purchaseURL1 + http://localhost:%PORT%/purchaseURL1 $5 @@ -719,7 +719,7 @@ Test Creator - Last Passing - http://localhost:4444/creatorLastPassing.html + http://localhost:%PORT%/creatorLastPassing.html Public @@ -735,7 +735,7 @@ 5 - http://localhost:4444/purchaseURL2 + http://localhost:%PORT%/purchaseURL2 $10 @@ -749,7 +749,7 @@ Test Creator - Last Passing - http://localhost:4444/creatorLastPassing.html + http://localhost:%PORT%/creatorLastPassing.html Public @@ -765,7 +765,7 @@ 5 - http://localhost:4444/purchaseURL3 + http://localhost:%PORT%/purchaseURL3 $10 @@ -781,7 +781,7 @@ Test Creator - Last Passing - http://localhost:4444/creatorLastPassing.html + http://localhost:%PORT%/creatorLastPassing.html Public @@ -794,7 +794,7 @@ 10 - http://localhost:4444/addons/test_AddonRepository_3.xpi + http://localhost:%PORT%/addons/test_AddonRepository_3.xpi @@ -160,7 +160,7 @@ 1 - http://localhost:4444/test3.xpi + http://localhost:%PORT%/test3.xpi