diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 21e3354de..c07c1b2fd 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -178,6 +178,12 @@ nsIContent::DoGetClasses() const NS_IMETHODIMP Element::QueryInterface(REFNSIID aIID, void** aInstancePtr) { + if (aIID.Equals(NS_GET_IID(Element))) { + NS_ADDREF_THIS(); + *aInstancePtr = this; + return NS_OK; + } + NS_ASSERTION(aInstancePtr, "QueryInterface requires a non-NULL destination!"); nsresult rv = FragmentOrElement::QueryInterface(aIID, aInstancePtr); diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index e43ca48b2..4a9ee4948 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -1935,7 +1935,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_INTERFACE_MAP_BEGIN(FragmentOrElement) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(FragmentOrElement) - NS_INTERFACE_MAP_ENTRY(Element) NS_INTERFACE_MAP_ENTRY(nsIContent) NS_INTERFACE_MAP_ENTRY(nsINode) NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget) diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index eeeaba5eb..76cb9b26a 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -1497,6 +1497,10 @@ MediaStreamGraphImpl::RunInStableState(bool aSourceIsMSG) RefPtr driver = CurrentDriver(); MonitorAutoUnlock unlock(mMonitor); driver->Start(); + // It's not safe to Shutdown() a thread from StableState, and + // releasing this may shutdown a SystemClockDriver thread. + // Proxy the release to outside of StableState. + NS_ReleaseOnMainThread(driver.forget(), true); // always proxy } } diff --git a/dom/svg/SVGClipPathElement.cpp b/dom/svg/SVGClipPathElement.cpp index 60d72fdf0..682d1271e 100644 --- a/dom/svg/SVGClipPathElement.cpp +++ b/dom/svg/SVGClipPathElement.cpp @@ -50,6 +50,13 @@ SVGClipPathElement::GetEnumInfo() ArrayLength(sEnumInfo)); } +bool +SVGClipPathElement::IsUnitsObjectBoundingBox() const +{ + return mEnumAttributes[CLIPPATHUNITS].GetAnimValue() == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX; +} + + //---------------------------------------------------------------------- // nsIDOMNode methods diff --git a/dom/svg/SVGClipPathElement.h b/dom/svg/SVGClipPathElement.h index d84f5b30f..2d9f4c15e 100644 --- a/dom/svg/SVGClipPathElement.h +++ b/dom/svg/SVGClipPathElement.h @@ -36,6 +36,10 @@ public: // WebIDL already_AddRefed ClipPathUnits(); + // This is an internal method that does not flush style, and thus + // the answer may be out of date if there's a pending style flush. + bool IsUnitsObjectBoundingBox() const; + protected: enum { CLIPPATHUNITS }; diff --git a/dom/svg/SVGTextContentElement.h b/dom/svg/SVGTextContentElement.h index 905468228..5f126c811 100644 --- a/dom/svg/SVGTextContentElement.h +++ b/dom/svg/SVGTextContentElement.h @@ -29,6 +29,7 @@ typedef SVGGraphicsElement SVGTextContentElementBase; class SVGTextContentElement : public SVGTextContentElementBase { + friend class ::SVGTextFrame; public: using FragmentOrElement::TextLength; diff --git a/intl/uconv/nsScriptableUConv.cpp b/intl/uconv/nsScriptableUConv.cpp index 7d4e932e2..04c15256c 100644 --- a/intl/uconv/nsScriptableUConv.cpp +++ b/intl/uconv/nsScriptableUConv.cpp @@ -11,6 +11,7 @@ #include "nsIUnicodeDecoder.h" #include "nsIUnicodeEncoder.h" #include "mozilla/dom/EncodingUtils.h" +#include "mozilla/CheckedInt.h" using mozilla::dom::EncodingUtils; @@ -39,8 +40,13 @@ nsScriptableUnicodeConverter::ConvertFromUnicodeWithLength(const nsAString& aSrc const nsAFlatString& flatSrc = PromiseFlatString(aSrc); rv = mEncoder->GetMaxLength(flatSrc.get(), inLength, aOutLen); if (NS_SUCCEEDED(rv)) { - *_retval = (char*)malloc(*aOutLen+1); - if (!*_retval) + mozilla::CheckedInt needed(*aOutLen); + needed += 1; + if (MOZ_UNLIKELY(!needed.isValid())) { + return NS_ERROR_OUT_OF_MEMORY; + } + *_retval = (char*)malloc(needed.value()); + if (MOZ_UNLIKELY(!*_retval)) return NS_ERROR_OUT_OF_MEMORY; rv = mEncoder->Convert(flatSrc.get(), &inLength, *_retval, aOutLen); @@ -145,8 +151,14 @@ nsScriptableUnicodeConverter::ConvertFromByteArray(const uint8_t* aData, inLength, &outLength); if (NS_SUCCEEDED(rv)) { - char16_t* buf = (char16_t*)malloc((outLength+1) * sizeof(char16_t)); - if (!buf) + mozilla::CheckedInt needed(outLength); + needed += 1; + needed *= sizeof(char16_t); + if (MOZ_UNLIKELY(!needed.isValid())) { + return NS_ERROR_OUT_OF_MEMORY; + } + char16_t* buf = (char16_t*)malloc(needed.value()); + if (MOZ_UNLIKELY(!buf)) return NS_ERROR_OUT_OF_MEMORY; rv = mDecoder->Convert(reinterpret_cast(aData), diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index f9a219008..1659af200 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -5202,8 +5202,8 @@ SVGTextFrame::DoGlyphPositioning() float actualTextLength = static_cast(presContext->AppUnitsToGfxUnits(frameLength) * factor); - RefPtr lengthAdjustEnum = element->LengthAdjust(); - uint16_t lengthAdjust = lengthAdjustEnum->AnimVal(); + uint16_t lengthAdjust = + element->EnumAttributes()[SVGTextContentElement::LENGTHADJUST].GetAnimValue(); switch (lengthAdjust) { case SVG_LENGTHADJUST_SPACINGANDGLYPHS: // Scale the glyphs and their positions. diff --git a/layout/svg/nsSVGUtils.cpp b/layout/svg/nsSVGUtils.cpp index 9ae9aa9d3..e364fe4f1 100644 --- a/layout/svg/nsSVGUtils.cpp +++ b/layout/svg/nsSVGUtils.cpp @@ -1003,8 +1003,7 @@ nsSVGUtils::GetBBox(nsIFrame *aFrame, uint32_t aFlags) if (clipPathFrame && isOK) { SVGClipPathElement *clipContent = static_cast(clipPathFrame->GetContent()); - RefPtr units = clipContent->ClipPathUnits(); - if (units->AnimVal() == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { + if (clipContent->IsUnitsObjectBoundingBox()) { matrix.Translate(gfxPoint(x, y)); matrix.Scale(width, height); } else if (aFrame->GetType() == nsGkAtoms::svgForeignObjectFrame) {