mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1184996 (Part 1) - Create decoders with a DecoderFactory. r=tn (dacf21ed2) - Bug 1184996 (Part 2) - Clean up RasterImage's decoding API. r=tn (c127af0b3) - Bug 1184996 (Part 3) - Replace all remaining references to 'size decodes' with 'metadata decodes'. r=tn (3744e5df4) - Bug 1184996 (Part 4) - Forbid instantiation of decoders except via DecoderFactory. r=tn (588d56d84) - No bug - Remove extra printf left over from bug 1127618. r=smaug (b02f7bfe1) - Bug 1187386 (Part 1) - Make most decoder state private. r=tn (328dbc605) - Bug 1187386 (Part 2) - Rework decoder code to avoid calling Decode::GetImage(). r=tn (9a94096f9) - Bug 1187386 (Part 3) - Don't destroy Decoder::mImage if Decoder::mImage is null. r=tn (cbb6738cd) - Bug 1187386 (Part 4) - Make imgFrame::SetOptimizable() callable from off-main-thread. r=tn (f03478b28) - Bug 1187386 (Part 5) - Merge Decoder::SetSizeOnImage() into ImageMetadata::SetOnImage(). r=tn (8afb5d4a3) - Bug 1033090 - Truncate a large URI in the user message about it. r=seth (7bd4b447b) - Bug 1187386 (Part 6) - Merge Decoder::Finish() and RasterImage::OnDecodingComplete() into RasterImage::FinalizeDecoder(). r=tn (f342dd5db) - Bug 1181863 (Part 1) - Add support for reading from nsIInputStreams directly to SourceBuffer. r=tn (74748dad9) - Bug 1181863 (Part 2) - Add ImageOps::DecodeToSurface() to allow image decoding without involving any main-thread-only objects. r=tn (25b86eb50) - Bug 1181863 (Part 3) - Add tests for DecodeToSurface(). r=tn (9506eb2f6) - Bug 1181863 - Part 4: Fix the build bustage (aee05bdc9) - Bug 1187546 - Make it possible to ask image decoders to only decode the first frame. r=tn (1beeeefb6) - Bug 1191100 - Remove XPIDL signature comments in .cpp files. r=ehsan (ee75fe3b5)
This commit is contained in:
@@ -47,7 +47,6 @@ nsDefaultURIFixup::~nsDefaultURIFixup()
|
||||
{
|
||||
}
|
||||
|
||||
/* nsIURI createExposableURI (in nsIURI aURI); */
|
||||
NS_IMETHODIMP
|
||||
nsDefaultURIFixup::CreateExposableURI(nsIURI* aURI, nsIURI** aReturn)
|
||||
{
|
||||
@@ -111,7 +110,6 @@ nsDefaultURIFixup::CreateExposableURI(nsIURI* aURI, nsIURI** aReturn)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIURI createFixupURI (in nsAUTF8String aURIText, in unsigned long aFixupFlags); */
|
||||
NS_IMETHODIMP
|
||||
nsDefaultURIFixup::CreateFixupURI(const nsACString& aStringURI,
|
||||
uint32_t aFixupFlags,
|
||||
|
||||
@@ -1886,7 +1886,6 @@ nsDocShell::GetChromeEventHandler(nsIDOMEventTarget** aChromeEventHandler)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setCurrentURI (in nsIURI uri); */
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetCurrentURI(nsIURI* aURI)
|
||||
{
|
||||
@@ -7179,7 +7178,6 @@ nsDocShell::Embed(nsIContentViewer* aContentViewer,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setIsPrinting (in boolean aIsPrinting); */
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetIsPrinting(bool aIsPrinting)
|
||||
{
|
||||
@@ -13001,7 +12999,6 @@ nsDocShell::IsFrame()
|
||||
return !!parent;
|
||||
}
|
||||
|
||||
/* boolean IsBeingDestroyed (); */
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::IsBeingDestroyed(bool* aDoomed)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,6 @@ nsDocShellEnumerator::~nsDocShellEnumerator()
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsDocShellEnumerator, nsISimpleEnumerator)
|
||||
|
||||
/* nsISupports getNext (); */
|
||||
NS_IMETHODIMP
|
||||
nsDocShellEnumerator::GetNext(nsISupports** aResult)
|
||||
{
|
||||
@@ -45,7 +44,6 @@ nsDocShellEnumerator::GetNext(nsISupports** aResult)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* boolean hasMoreElements (); */
|
||||
NS_IMETHODIMP
|
||||
nsDocShellEnumerator::HasMoreElements(bool* aResult)
|
||||
{
|
||||
|
||||
@@ -198,7 +198,6 @@ nsDocShellLoadInfo::SetPostDataStream(nsIInputStream* aStream)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute nsIInputStream headersStream; */
|
||||
NS_IMETHODIMP
|
||||
nsDocShellLoadInfo::GetHeadersStream(nsIInputStream** aHeadersStream)
|
||||
{
|
||||
|
||||
@@ -35,15 +35,12 @@ AudioChannelAgent::~AudioChannelAgent()
|
||||
}
|
||||
}
|
||||
|
||||
/* readonly attribute long audioChannelType; */
|
||||
NS_IMETHODIMP AudioChannelAgent::GetAudioChannelType(int32_t *aAudioChannelType)
|
||||
{
|
||||
*aAudioChannelType = mAudioChannelType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean init (in nsIDOMWindow window, in long channelType,
|
||||
* in nsIAudioChannelAgentCallback callback); */
|
||||
NS_IMETHODIMP
|
||||
AudioChannelAgent::Init(nsIDOMWindow* aWindow, int32_t aChannelType,
|
||||
nsIAudioChannelAgentCallback *aCallback)
|
||||
@@ -52,8 +49,6 @@ AudioChannelAgent::Init(nsIDOMWindow* aWindow, int32_t aChannelType,
|
||||
/* useWeakRef = */ false);
|
||||
}
|
||||
|
||||
/* boolean initWithWeakCallback (in nsIDOMWindow window, in long channelType,
|
||||
* in nsIAudioChannelAgentCallback callback); */
|
||||
NS_IMETHODIMP
|
||||
AudioChannelAgent::InitWithWeakCallback(nsIDOMWindow* aWindow,
|
||||
int32_t aChannelType,
|
||||
@@ -118,7 +113,6 @@ AudioChannelAgent::InitInternal(nsIDOMWindow* aWindow, int32_t aChannelType,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean startPlaying (); */
|
||||
NS_IMETHODIMP AudioChannelAgent::StartPlaying(float *aVolume, bool* aMuted)
|
||||
{
|
||||
MOZ_ASSERT(aVolume);
|
||||
@@ -139,7 +133,6 @@ NS_IMETHODIMP AudioChannelAgent::StartPlaying(float *aVolume, bool* aMuted)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void stopPlaying (); */
|
||||
NS_IMETHODIMP AudioChannelAgent::StopPlaying(void)
|
||||
{
|
||||
if (mAudioChannelType == AUDIO_AGENT_CHANNEL_ERROR ||
|
||||
|
||||
@@ -292,7 +292,6 @@ Exception::StowJSVal(JS::Value& aVp)
|
||||
}
|
||||
}
|
||||
|
||||
/* readonly attribute AUTF8String message; */
|
||||
NS_IMETHODIMP
|
||||
Exception::GetMessageMoz(nsACString& aMessage)
|
||||
{
|
||||
@@ -302,7 +301,6 @@ Exception::GetMessageMoz(nsACString& aMessage)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsresult result; */
|
||||
NS_IMETHODIMP
|
||||
Exception::GetResult(nsresult* aResult)
|
||||
{
|
||||
@@ -313,7 +311,6 @@ Exception::GetResult(nsresult* aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute AUTF8String name; */
|
||||
NS_IMETHODIMP
|
||||
Exception::GetName(nsACString& aName)
|
||||
{
|
||||
@@ -335,7 +332,6 @@ Exception::GetName(nsACString& aName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute AString filename; */
|
||||
NS_IMETHODIMP
|
||||
Exception::GetFilename(nsAString& aFilename)
|
||||
{
|
||||
@@ -349,7 +345,6 @@ Exception::GetFilename(nsAString& aFilename)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute uint32_t lineNumber; */
|
||||
NS_IMETHODIMP
|
||||
Exception::GetLineNumber(uint32_t *aLineNumber)
|
||||
{
|
||||
@@ -367,7 +362,6 @@ Exception::GetLineNumber(uint32_t *aLineNumber)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute uint32_t columnNumber; */
|
||||
NS_IMETHODIMP
|
||||
Exception::GetColumnNumber(uint32_t* aColumnNumber)
|
||||
{
|
||||
@@ -378,7 +372,6 @@ Exception::GetColumnNumber(uint32_t* aColumnNumber)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIStackFrame location; */
|
||||
NS_IMETHODIMP
|
||||
Exception::GetLocation(nsIStackFrame** aLocation)
|
||||
{
|
||||
@@ -390,7 +383,6 @@ Exception::GetLocation(nsIStackFrame** aLocation)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsISupports data; */
|
||||
NS_IMETHODIMP
|
||||
Exception::GetData(nsISupports** aData)
|
||||
{
|
||||
@@ -402,7 +394,6 @@ Exception::GetData(nsISupports** aData)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* AUTF8String toString (); */
|
||||
NS_IMETHODIMP
|
||||
Exception::ToString(nsACString& _retval)
|
||||
{
|
||||
|
||||
@@ -179,21 +179,18 @@ NS_INTERFACE_MAP_END
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(NodeIterator)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(NodeIterator)
|
||||
|
||||
/* readonly attribute nsIDOMNode root; */
|
||||
NS_IMETHODIMP NodeIterator::GetRoot(nsIDOMNode * *aRoot)
|
||||
{
|
||||
NS_ADDREF(*aRoot = Root()->AsDOMNode());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long whatToShow; */
|
||||
NS_IMETHODIMP NodeIterator::GetWhatToShow(uint32_t *aWhatToShow)
|
||||
{
|
||||
*aWhatToShow = WhatToShow();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMNodeFilter filter; */
|
||||
NS_IMETHODIMP NodeIterator::GetFilter(nsIDOMNodeFilter **aFilter)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFilter);
|
||||
@@ -203,13 +200,11 @@ NS_IMETHODIMP NodeIterator::GetFilter(nsIDOMNodeFilter **aFilter)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIDOMNode nextNode () raises (DOMException); */
|
||||
NS_IMETHODIMP NodeIterator::NextNode(nsIDOMNode **_retval)
|
||||
{
|
||||
return ImplNodeGetter(&NodeIterator::NextNode, _retval);
|
||||
}
|
||||
|
||||
/* nsIDOMNode previousNode () raises (DOMException); */
|
||||
NS_IMETHODIMP NodeIterator::PreviousNode(nsIDOMNode **_retval)
|
||||
{
|
||||
return ImplNodeGetter(&NodeIterator::PreviousNode, _retval);
|
||||
@@ -248,7 +243,6 @@ NodeIterator::NextOrPrevNode(NodePointer::MoveToMethodType aMove,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* void detach (); */
|
||||
NS_IMETHODIMP NodeIterator::Detach(void)
|
||||
{
|
||||
if (mRoot) {
|
||||
@@ -257,7 +251,6 @@ NS_IMETHODIMP NodeIterator::Detach(void)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMNode referenceNode; */
|
||||
NS_IMETHODIMP NodeIterator::GetReferenceNode(nsIDOMNode * *aRefNode)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(GetReferenceNode()));
|
||||
@@ -265,7 +258,6 @@ NS_IMETHODIMP NodeIterator::GetReferenceNode(nsIDOMNode * *aRefNode)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute boolean pointerBeforeReferenceNode; */
|
||||
NS_IMETHODIMP NodeIterator::GetPointerBeforeReferenceNode(bool *aBeforeNode)
|
||||
{
|
||||
*aBeforeNode = PointerBeforeReferenceNode();
|
||||
|
||||
@@ -36,7 +36,6 @@ ProcessGlobal::Get()
|
||||
return static_cast<ProcessGlobal*>(service.get());
|
||||
}
|
||||
|
||||
/* [notxpcom] boolean markForCC (); */
|
||||
// This method isn't automatically forwarded safely because it's notxpcom, so
|
||||
// the IDL binding doesn't know what value to return.
|
||||
NS_IMETHODIMP_(bool)
|
||||
|
||||
@@ -61,21 +61,18 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(dom::TreeWalker)
|
||||
* nsIDOMTreeWalker Getters/Setters
|
||||
*/
|
||||
|
||||
/* readonly attribute nsIDOMNode root; */
|
||||
NS_IMETHODIMP TreeWalker::GetRoot(nsIDOMNode * *aRoot)
|
||||
{
|
||||
NS_ADDREF(*aRoot = Root()->AsDOMNode());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long whatToShow; */
|
||||
NS_IMETHODIMP TreeWalker::GetWhatToShow(uint32_t *aWhatToShow)
|
||||
{
|
||||
*aWhatToShow = WhatToShow();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMNodeFilter filter; */
|
||||
NS_IMETHODIMP TreeWalker::GetFilter(nsIDOMNodeFilter * *aFilter)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFilter);
|
||||
@@ -85,7 +82,6 @@ NS_IMETHODIMP TreeWalker::GetFilter(nsIDOMNodeFilter * *aFilter)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute nsIDOMNode currentNode; */
|
||||
NS_IMETHODIMP TreeWalker::GetCurrentNode(nsIDOMNode * *aCurrentNode)
|
||||
{
|
||||
if (mCurrentNode) {
|
||||
@@ -124,7 +120,6 @@ TreeWalker::SetCurrentNode(nsINode& aNode, ErrorResult& aResult)
|
||||
* nsIDOMTreeWalker functions
|
||||
*/
|
||||
|
||||
/* nsIDOMNode parentNode (); */
|
||||
NS_IMETHODIMP TreeWalker::ParentNode(nsIDOMNode **_retval)
|
||||
{
|
||||
return ImplNodeGetter(&TreeWalker::ParentNode, _retval);
|
||||
@@ -153,7 +148,6 @@ TreeWalker::ParentNode(ErrorResult& aResult)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* nsIDOMNode firstChild (); */
|
||||
NS_IMETHODIMP TreeWalker::FirstChild(nsIDOMNode **_retval)
|
||||
{
|
||||
return ImplNodeGetter(&TreeWalker::FirstChild, _retval);
|
||||
@@ -165,7 +159,6 @@ TreeWalker::FirstChild(ErrorResult& aResult)
|
||||
return FirstChildInternal(false, aResult);
|
||||
}
|
||||
|
||||
/* nsIDOMNode lastChild (); */
|
||||
NS_IMETHODIMP TreeWalker::LastChild(nsIDOMNode **_retval)
|
||||
{
|
||||
return ImplNodeGetter(&TreeWalker::LastChild, _retval);
|
||||
@@ -177,7 +170,6 @@ TreeWalker::LastChild(ErrorResult& aResult)
|
||||
return FirstChildInternal(true, aResult);
|
||||
}
|
||||
|
||||
/* nsIDOMNode previousSibling (); */
|
||||
NS_IMETHODIMP TreeWalker::PreviousSibling(nsIDOMNode **_retval)
|
||||
{
|
||||
return ImplNodeGetter(&TreeWalker::PreviousSibling, _retval);
|
||||
@@ -189,7 +181,6 @@ TreeWalker::PreviousSibling(ErrorResult& aResult)
|
||||
return NextSiblingInternal(true, aResult);
|
||||
}
|
||||
|
||||
/* nsIDOMNode nextSibling (); */
|
||||
NS_IMETHODIMP TreeWalker::NextSibling(nsIDOMNode **_retval)
|
||||
{
|
||||
return ImplNodeGetter(&TreeWalker::NextSibling, _retval);
|
||||
@@ -201,7 +192,6 @@ TreeWalker::NextSibling(ErrorResult& aResult)
|
||||
return NextSiblingInternal(false, aResult);
|
||||
}
|
||||
|
||||
/* nsIDOMNode previousNode (); */
|
||||
NS_IMETHODIMP TreeWalker::PreviousNode(nsIDOMNode **_retval)
|
||||
{
|
||||
return ImplNodeGetter(&TreeWalker::PreviousNode, _retval);
|
||||
@@ -260,7 +250,6 @@ TreeWalker::PreviousNode(ErrorResult& aResult)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* nsIDOMNode nextNode (); */
|
||||
NS_IMETHODIMP TreeWalker::NextNode(nsIDOMNode **_retval)
|
||||
{
|
||||
return ImplNodeGetter(&TreeWalker::NextNode, _retval);
|
||||
|
||||
@@ -174,7 +174,6 @@ public:
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsSelectionCommandsBase, nsIControllerCommand)
|
||||
|
||||
/* boolean isCommandEnabled (in string aCommandName, in nsISupports aCommandContext); */
|
||||
NS_IMETHODIMP
|
||||
nsSelectionCommandsBase::IsCommandEnabled(const char * aCommandName,
|
||||
nsISupports *aCommandContext,
|
||||
@@ -186,7 +185,6 @@ nsSelectionCommandsBase::IsCommandEnabled(const char * aCommandName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getCommandStateParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext); */
|
||||
NS_IMETHODIMP
|
||||
nsSelectionCommandsBase::GetCommandStateParams(const char *aCommandName,
|
||||
nsICommandParams *aParams, nsISupports *aCommandContext)
|
||||
@@ -195,7 +193,6 @@ nsSelectionCommandsBase::GetCommandStateParams(const char *aCommandName,
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void doCommandParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext); */
|
||||
NS_IMETHODIMP
|
||||
nsSelectionCommandsBase::DoCommandParams(const char *aCommandName,
|
||||
nsICommandParams *aParams, nsISupports *aCommandContext)
|
||||
@@ -856,7 +853,6 @@ nsWebNavigationBaseCommand::DoCommand(const char *aCommandName,
|
||||
return DoWebNavCommand(aCommandName, webNav);
|
||||
}
|
||||
|
||||
/* void doCommandParams (in string aCommandName, in nsICommandParams aParams, in nsISupports aCommandContext); */
|
||||
NS_IMETHODIMP
|
||||
nsWebNavigationBaseCommand::DoCommandParams(const char *aCommandName,
|
||||
nsICommandParams *aParams, nsISupports *aCommandContext)
|
||||
|
||||
@@ -113,7 +113,6 @@ nsInProcessTabChildGlobal::~nsInProcessTabChildGlobal()
|
||||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
|
||||
/* [notxpcom] boolean markForCC (); */
|
||||
// This method isn't automatically forwarded safely because it's notxpcom, so
|
||||
// the IDL binding doesn't know what value to return.
|
||||
NS_IMETHODIMP_(bool)
|
||||
|
||||
@@ -3045,7 +3045,6 @@ NS_IMETHODIMP nsJSArgArray::GetLength(uint32_t *aLength)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void queryElementAt (in unsigned long index, in nsIIDRef uuid, [iid_is (uuid), retval] out nsQIResult result); */
|
||||
NS_IMETHODIMP nsJSArgArray::QueryElementAt(uint32_t index, const nsIID & uuid, void * *result)
|
||||
{
|
||||
*result = nullptr;
|
||||
@@ -3062,13 +3061,11 @@ NS_IMETHODIMP nsJSArgArray::QueryElementAt(uint32_t index, const nsIID & uuid, v
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
/* unsigned long indexOf (in unsigned long startIndex, in nsISupports element); */
|
||||
NS_IMETHODIMP nsJSArgArray::IndexOf(uint32_t startIndex, nsISupports *element, uint32_t *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsISimpleEnumerator enumerate (); */
|
||||
NS_IMETHODIMP nsJSArgArray::Enumerate(nsISimpleEnumerator **_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
@@ -16,7 +16,6 @@ nsOpenURIInFrameParams::nsOpenURIInFrameParams() :
|
||||
nsOpenURIInFrameParams::~nsOpenURIInFrameParams() {
|
||||
}
|
||||
|
||||
/* attribute DOMString referrer; */
|
||||
NS_IMETHODIMP
|
||||
nsOpenURIInFrameParams::GetReferrer(nsAString& aReferrer)
|
||||
{
|
||||
@@ -30,7 +29,6 @@ nsOpenURIInFrameParams::SetReferrer(const nsAString& aReferrer)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute boolean isPrivate; */
|
||||
NS_IMETHODIMP
|
||||
nsOpenURIInFrameParams::GetIsPrivate(bool* aIsPrivate)
|
||||
{
|
||||
|
||||
@@ -582,7 +582,6 @@ nsXMLHttpRequest::SizeOfEventTargetIncludingThis(
|
||||
// - lots
|
||||
}
|
||||
|
||||
/* readonly attribute nsIChannel channel; */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetChannel(nsIChannel **aChannel)
|
||||
{
|
||||
@@ -604,7 +603,6 @@ static void LogMessage(const char* aWarning, nsPIDOMWindow* aWindow)
|
||||
aWarning);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMDocument responseXML; */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetResponseXML(nsIDOMDocument **aResponseXML)
|
||||
{
|
||||
@@ -718,7 +716,6 @@ nsXMLHttpRequest::AppendToResponseText(const char * aSrcBuffer,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute AString responseText; */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetResponseText(nsAString& aResponseText)
|
||||
{
|
||||
@@ -831,7 +828,6 @@ nsXMLHttpRequest::CreatePartialBlob()
|
||||
mResponseBlob = mBlobSet->GetBlobInternal(GetOwner(), contentType);
|
||||
}
|
||||
|
||||
/* attribute AString responseType; */
|
||||
NS_IMETHODIMP nsXMLHttpRequest::GetResponseType(nsAString& aResponseType)
|
||||
{
|
||||
switch (mResponseType) {
|
||||
@@ -892,7 +888,6 @@ nsXMLHttpRequest::StaticAssertions()
|
||||
}
|
||||
#endif
|
||||
|
||||
/* attribute AString responseType; */
|
||||
NS_IMETHODIMP nsXMLHttpRequest::SetResponseType(const nsAString& aResponseType)
|
||||
{
|
||||
nsXMLHttpRequest::ResponseTypeEnum responseType;
|
||||
@@ -961,7 +956,6 @@ nsXMLHttpRequest::SetResponseType(nsXMLHttpRequest::ResponseTypeEnum aResponseTy
|
||||
|
||||
}
|
||||
|
||||
/* readonly attribute jsval response; */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetResponse(JSContext *aCx, JS::MutableHandle<JS::Value> aResult)
|
||||
{
|
||||
@@ -1090,7 +1084,6 @@ nsXMLHttpRequest::IsDeniedCrossSiteRequest()
|
||||
return false;
|
||||
}
|
||||
|
||||
/* readonly attribute AString responseURL; */
|
||||
void
|
||||
nsXMLHttpRequest::GetResponseURL(nsAString& aUrl)
|
||||
{
|
||||
@@ -1119,7 +1112,6 @@ nsXMLHttpRequest::GetResponseURL(nsAString& aUrl)
|
||||
CopyUTF8toUTF16(temp, aUrl);
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long status; */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetStatus(uint32_t *aStatus)
|
||||
{
|
||||
@@ -1256,7 +1248,6 @@ nsXMLHttpRequest::CloseRequestWithError(const nsAString& aType,
|
||||
mState &= ~XML_HTTP_REQUEST_SYNCLOOPING;
|
||||
}
|
||||
|
||||
/* void abort (); */
|
||||
void
|
||||
nsXMLHttpRequest::Abort()
|
||||
{
|
||||
@@ -1326,7 +1317,6 @@ nsXMLHttpRequest::IsSafeHeader(const nsACString& header, nsIHttpChannel* httpCha
|
||||
return isSafe;
|
||||
}
|
||||
|
||||
/* ByteString getAllResponseHeaders(); */
|
||||
IMPL_CSTRING_GETTER(GetAllResponseHeaders)
|
||||
void
|
||||
nsXMLHttpRequest::GetAllResponseHeaders(nsCString& aResponseHeaders)
|
||||
@@ -1983,7 +1973,6 @@ nsXMLHttpRequest::OnDataAvailable(nsIRequest *request,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStartRequest (in nsIRequest request, in nsISupports ctxt); */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
||||
{
|
||||
@@ -2234,7 +2223,6 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopRequest (in nsIRequest request, in nsISupports ctxt, in nsresult status, in wstring statusArg); */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult status)
|
||||
{
|
||||
@@ -2665,7 +2653,6 @@ nsXMLHttpRequest::GetRequestBody(nsIVariant* aVariant,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void send (in nsIVariant aBody); */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::Send(nsIVariant *aBody)
|
||||
{
|
||||
@@ -3098,7 +3085,6 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void setRequestHeader (in ByteString header, in ByteString value); */
|
||||
// http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#dom-xmlhttprequest-setrequestheader
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::SetRequestHeader(const nsACString& header,
|
||||
@@ -3204,7 +3190,6 @@ nsXMLHttpRequest::SetRequestHeader(const nsACString& header,
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* attribute unsigned long timeout; */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetTimeout(uint32_t *aTimeout)
|
||||
{
|
||||
@@ -3268,7 +3253,6 @@ nsXMLHttpRequest::StartTimeoutTimer()
|
||||
);
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned short readyState; */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetReadyState(uint16_t *aState)
|
||||
{
|
||||
@@ -3296,7 +3280,6 @@ nsXMLHttpRequest::ReadyState()
|
||||
return DONE;
|
||||
}
|
||||
|
||||
/* void overrideMimeType(in DOMString mimetype); */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::SlowOverrideMimeType(const nsAString& aMimeType)
|
||||
{
|
||||
@@ -3304,7 +3287,6 @@ nsXMLHttpRequest::SlowOverrideMimeType(const nsAString& aMimeType)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute boolean mozBackgroundRequest; */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetMozBackgroundRequest(bool *_retval)
|
||||
{
|
||||
@@ -3347,7 +3329,6 @@ nsXMLHttpRequest::SetMozBackgroundRequest(bool aMozBackgroundRequest, nsresult&
|
||||
}
|
||||
}
|
||||
|
||||
/* attribute boolean withCredentials; */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetWithCredentials(bool *_retval)
|
||||
{
|
||||
|
||||
@@ -352,14 +352,12 @@ NS_IMPL_RELEASE_INHERITED(JSStackFrame, StackFrame)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(JSStackFrame)
|
||||
NS_INTERFACE_MAP_END_INHERITING(StackFrame)
|
||||
|
||||
/* readonly attribute uint32_t language; */
|
||||
NS_IMETHODIMP StackFrame::GetLanguage(uint32_t* aLanguage)
|
||||
{
|
||||
*aLanguage = mLanguage;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute string languageName; */
|
||||
NS_IMETHODIMP StackFrame::GetLanguageName(nsACString& aLanguageName)
|
||||
{
|
||||
aLanguageName.AssignLiteral("C++");
|
||||
@@ -409,7 +407,6 @@ GetValueIfNotCached(JSContext* aCx, JSObject* aStack,
|
||||
aPropGetter(aCx, stack, aValue);
|
||||
}
|
||||
|
||||
/* readonly attribute AString filename; */
|
||||
NS_IMETHODIMP JSStackFrame::GetFilename(nsAString& aFilename)
|
||||
{
|
||||
if (!mStack) {
|
||||
@@ -454,7 +451,6 @@ NS_IMETHODIMP StackFrame::GetFilename(nsAString& aFilename)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute AString name; */
|
||||
NS_IMETHODIMP JSStackFrame::GetName(nsAString& aFunction)
|
||||
{
|
||||
if (!mStack) {
|
||||
@@ -531,7 +527,6 @@ JSStackFrame::GetLineno()
|
||||
return line;
|
||||
}
|
||||
|
||||
/* readonly attribute int32_t lineNumber; */
|
||||
NS_IMETHODIMP StackFrame::GetLineNumber(int32_t* aLineNumber)
|
||||
{
|
||||
*aLineNumber = GetLineno();
|
||||
@@ -564,21 +559,18 @@ JSStackFrame::GetColNo()
|
||||
return col;
|
||||
}
|
||||
|
||||
/* readonly attribute int32_t columnNumber; */
|
||||
NS_IMETHODIMP StackFrame::GetColumnNumber(int32_t* aColumnNumber)
|
||||
{
|
||||
*aColumnNumber = GetColNo();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute AUTF8String sourceLine; */
|
||||
NS_IMETHODIMP StackFrame::GetSourceLine(nsACString& aSourceLine)
|
||||
{
|
||||
aSourceLine.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute AString asyncCause; */
|
||||
NS_IMETHODIMP JSStackFrame::GetAsyncCause(nsAString& aAsyncCause)
|
||||
{
|
||||
if (!mStack) {
|
||||
@@ -629,7 +621,6 @@ NS_IMETHODIMP StackFrame::GetAsyncCause(nsAString& aAsyncCause)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIStackFrame asyncCaller; */
|
||||
NS_IMETHODIMP JSStackFrame::GetAsyncCaller(nsIStackFrame** aAsyncCaller)
|
||||
{
|
||||
if (!mStack) {
|
||||
@@ -666,7 +657,6 @@ NS_IMETHODIMP StackFrame::GetAsyncCaller(nsIStackFrame** aAsyncCaller)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIStackFrame caller; */
|
||||
NS_IMETHODIMP JSStackFrame::GetCaller(nsIStackFrame** aCaller)
|
||||
{
|
||||
if (!mStack) {
|
||||
@@ -764,7 +754,6 @@ NS_IMETHODIMP StackFrame::GetFormattedStack(nsAString& aStack)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute jsval nativeSavedFrame; */
|
||||
NS_IMETHODIMP JSStackFrame::GetNativeSavedFrame(JS::MutableHandle<JS::Value> aSavedFrame)
|
||||
{
|
||||
aSavedFrame.setObjectOrNull(mStack);
|
||||
@@ -777,7 +766,6 @@ NS_IMETHODIMP StackFrame::GetNativeSavedFrame(JS::MutableHandle<JS::Value> aSave
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* AUTF8String toString (); */
|
||||
NS_IMETHODIMP StackFrame::ToString(nsACString& _retval)
|
||||
{
|
||||
_retval.Truncate();
|
||||
|
||||
@@ -1280,7 +1280,6 @@ WebGLContext::GetContextAttributes(Nullable<dom::WebGLContextAttributes>& retval
|
||||
result.mFailIfMajorPerformanceCaveat = mOptions.failIfMajorPerformanceCaveat;
|
||||
}
|
||||
|
||||
/* [noscript] DOMString mozGetUnderlyingParamString(in GLenum pname); */
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::MozGetUnderlyingParamString(uint32_t pname, nsAString& retval)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,6 @@ FocusEvent::FocusEvent(EventTarget* aOwner,
|
||||
}
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMEventTarget relatedTarget; */
|
||||
NS_IMETHODIMP
|
||||
FocusEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,6 @@ NS_INTERFACE_MAP_BEGIN(SimpleGestureEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMSimpleGestureEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
|
||||
|
||||
/* attribute unsigned long allowedDirections; */
|
||||
uint32_t
|
||||
SimpleGestureEvent::AllowedDirections()
|
||||
{
|
||||
@@ -61,7 +60,6 @@ SimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long direction; */
|
||||
uint32_t
|
||||
SimpleGestureEvent::Direction()
|
||||
{
|
||||
@@ -76,7 +74,6 @@ SimpleGestureEvent::GetDirection(uint32_t* aDirection)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute float delta; */
|
||||
double
|
||||
SimpleGestureEvent::Delta()
|
||||
{
|
||||
@@ -91,7 +88,6 @@ SimpleGestureEvent::GetDelta(double* aDelta)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long clickCount; */
|
||||
uint32_t
|
||||
SimpleGestureEvent::ClickCount()
|
||||
{
|
||||
|
||||
@@ -39,7 +39,6 @@ GamepadServiceTest::~GamepadServiceTest()
|
||||
{
|
||||
}
|
||||
|
||||
/* uint32_t addGamepad(in unsigned long index, in string id, in unsigned long mapping, in unsigned long numButtons, in unsigned long numAxes); */
|
||||
NS_IMETHODIMP
|
||||
GamepadServiceTest::AddGamepad(const char* aID,
|
||||
uint32_t aMapping,
|
||||
@@ -54,7 +53,6 @@ GamepadServiceTest::AddGamepad(const char* aID,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void removeGamepad (in uint32_t index); */
|
||||
NS_IMETHODIMP GamepadServiceTest::RemoveGamepad(uint32_t aIndex)
|
||||
{
|
||||
GamepadFunctions::RemoveGamepad(aIndex);
|
||||
|
||||
@@ -535,7 +535,6 @@ HTMLMediaElement::SetMozSrcObject(DOMMediaStream* aValue)
|
||||
DoLoad();
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMHTMLMediaElement mozAutoplayEnabled; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetMozAutoplayEnabled(bool *aAutoplayEnabled)
|
||||
{
|
||||
*aAutoplayEnabled = mAutoplayEnabled;
|
||||
@@ -543,7 +542,6 @@ NS_IMETHODIMP HTMLMediaElement::GetMozAutoplayEnabled(bool *aAutoplayEnabled)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMMediaError error; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetError(nsIDOMMediaError * *aError)
|
||||
{
|
||||
NS_IF_ADDREF(*aError = mError);
|
||||
@@ -551,7 +549,6 @@ NS_IMETHODIMP HTMLMediaElement::GetError(nsIDOMMediaError * *aError)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute boolean ended; */
|
||||
bool
|
||||
HTMLMediaElement::Ended()
|
||||
{
|
||||
@@ -572,7 +569,6 @@ NS_IMETHODIMP HTMLMediaElement::GetEnded(bool* aEnded)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute DOMString currentSrc; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetCurrentSrc(nsAString & aCurrentSrc)
|
||||
{
|
||||
nsAutoCString src;
|
||||
@@ -581,7 +577,6 @@ NS_IMETHODIMP HTMLMediaElement::GetCurrentSrc(nsAString & aCurrentSrc)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned short networkState; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetNetworkState(uint16_t* aNetworkState)
|
||||
{
|
||||
*aNetworkState = NetworkState();
|
||||
@@ -764,7 +759,6 @@ void HTMLMediaElement::QueueSelectResourceTask()
|
||||
NS_NewRunnableMethod(this, &HTMLMediaElement::SelectResourceWrapper));
|
||||
}
|
||||
|
||||
/* void load (); */
|
||||
NS_IMETHODIMP HTMLMediaElement::Load()
|
||||
{
|
||||
if (mIsRunningLoadMethod) {
|
||||
@@ -1311,7 +1305,6 @@ nsresult HTMLMediaElement::LoadWithChannel(nsIChannel* aChannel,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned short readyState; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetReadyState(uint16_t* aReadyState)
|
||||
{
|
||||
*aReadyState = ReadyState();
|
||||
@@ -1319,7 +1312,6 @@ NS_IMETHODIMP HTMLMediaElement::GetReadyState(uint16_t* aReadyState)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute boolean seeking; */
|
||||
bool
|
||||
HTMLMediaElement::Seeking() const
|
||||
{
|
||||
@@ -1332,7 +1324,6 @@ NS_IMETHODIMP HTMLMediaElement::GetSeeking(bool* aSeeking)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute double currentTime; */
|
||||
double
|
||||
HTMLMediaElement::CurrentTime() const
|
||||
{
|
||||
@@ -1545,7 +1536,6 @@ NS_IMETHODIMP HTMLMediaElement::SetCurrentTime(double aCurrentTime)
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
/* readonly attribute double duration; */
|
||||
double
|
||||
HTMLMediaElement::Duration() const
|
||||
{
|
||||
@@ -1577,7 +1567,6 @@ HTMLMediaElement::Seekable() const
|
||||
return ranges.forget();
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMHTMLTimeRanges seekable; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetSeekable(nsIDOMTimeRanges** aSeekable)
|
||||
{
|
||||
nsRefPtr<TimeRanges> ranges = Seekable();
|
||||
@@ -1585,7 +1574,6 @@ NS_IMETHODIMP HTMLMediaElement::GetSeekable(nsIDOMTimeRanges** aSeekable)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute boolean paused; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetPaused(bool* aPaused)
|
||||
{
|
||||
*aPaused = Paused();
|
||||
@@ -1621,7 +1609,6 @@ HTMLMediaElement::Played()
|
||||
return ranges.forget();
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMHTMLTimeRanges played; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetPlayed(nsIDOMTimeRanges** aPlayed)
|
||||
{
|
||||
nsRefPtr<TimeRanges> ranges = Played();
|
||||
@@ -1629,7 +1616,6 @@ NS_IMETHODIMP HTMLMediaElement::GetPlayed(nsIDOMTimeRanges** aPlayed)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void pause (); */
|
||||
void
|
||||
HTMLMediaElement::Pause(ErrorResult& aRv)
|
||||
{
|
||||
@@ -1665,7 +1651,6 @@ NS_IMETHODIMP HTMLMediaElement::Pause()
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
/* attribute double volume; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetVolume(double* aVolume)
|
||||
{
|
||||
*aVolume = Volume();
|
||||
@@ -1770,7 +1755,6 @@ HTMLMediaElement::MozGetMetadata(JSContext* cx, JS::MutableHandle<JS::Value> aVa
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
/* attribute boolean muted; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetMuted(bool* aMuted)
|
||||
{
|
||||
*aMuted = Muted();
|
||||
@@ -4270,7 +4254,6 @@ void HTMLMediaElement::GetCurrentSpec(nsCString& aString)
|
||||
}
|
||||
}
|
||||
|
||||
/* attribute double mozFragmentEnd; */
|
||||
double
|
||||
HTMLMediaElement::MozFragmentEnd()
|
||||
{
|
||||
@@ -4301,7 +4284,6 @@ static double ClampPlaybackRate(double aPlaybackRate)
|
||||
return aPlaybackRate;
|
||||
}
|
||||
|
||||
/* attribute double defaultPlaybackRate; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetDefaultPlaybackRate(double* aDefaultPlaybackRate)
|
||||
{
|
||||
*aDefaultPlaybackRate = DefaultPlaybackRate();
|
||||
@@ -4327,7 +4309,6 @@ NS_IMETHODIMP HTMLMediaElement::SetDefaultPlaybackRate(double aDefaultPlaybackRa
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
/* attribute double playbackRate; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetPlaybackRate(double* aPlaybackRate)
|
||||
{
|
||||
*aPlaybackRate = PlaybackRate();
|
||||
@@ -4367,7 +4348,6 @@ NS_IMETHODIMP HTMLMediaElement::SetPlaybackRate(double aPlaybackRate)
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
/* attribute bool mozPreservesPitch; */
|
||||
NS_IMETHODIMP HTMLMediaElement::GetMozPreservesPitch(bool* aPreservesPitch)
|
||||
{
|
||||
*aPreservesPitch = MozPreservesPitch();
|
||||
@@ -4495,7 +4475,6 @@ HTMLMediaElement::VideoTracks()
|
||||
return mVideoTrackList;
|
||||
}
|
||||
|
||||
/* readonly attribute TextTrackList? textTracks; */
|
||||
TextTrackList*
|
||||
HTMLMediaElement::GetTextTracks()
|
||||
{
|
||||
|
||||
@@ -57,7 +57,6 @@ protected:
|
||||
virtual ~UndoTxn() {}
|
||||
};
|
||||
|
||||
/* void doTransaction (); */
|
||||
NS_IMETHODIMP
|
||||
UndoTxn::DoTransaction()
|
||||
{
|
||||
@@ -66,21 +65,18 @@ UndoTxn::DoTransaction()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void doTransaction (); */
|
||||
NS_IMETHODIMP
|
||||
UndoTxn::RedoTransaction()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void doTransaction (); */
|
||||
NS_IMETHODIMP
|
||||
UndoTxn::UndoTransaction()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* readonly attribute boolean isTransient; */
|
||||
NS_IMETHODIMP
|
||||
UndoTxn::GetIsTransient(bool* aIsTransient)
|
||||
{
|
||||
@@ -88,7 +84,6 @@ UndoTxn::GetIsTransient(bool* aIsTransient)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean merge (in nsITransaction aTransaction); */
|
||||
NS_IMETHODIMP
|
||||
UndoTxn::Merge(nsITransaction* aTransaction, bool* aResult)
|
||||
{
|
||||
|
||||
@@ -2493,7 +2493,6 @@ nsHTMLDocument::GenerateParserKey(void)
|
||||
return script;
|
||||
}
|
||||
|
||||
/* attribute DOMString designMode; */
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetDesignMode(nsAString & aDesignMode)
|
||||
{
|
||||
@@ -3315,7 +3314,6 @@ nsHTMLDocument::ExecCommand(const nsAString& commandID,
|
||||
return !rv.Failed();
|
||||
}
|
||||
|
||||
/* boolean queryCommandEnabled(in DOMString commandID); */
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::QueryCommandEnabled(const nsAString& commandID,
|
||||
bool* _retval)
|
||||
@@ -3370,7 +3368,6 @@ nsHTMLDocument::QueryCommandEnabled(const nsAString& commandID, ErrorResult& rv)
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* boolean queryCommandIndeterm (in DOMString commandID); */
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::QueryCommandIndeterm(const nsAString & commandID,
|
||||
bool *_retval)
|
||||
@@ -3428,7 +3425,6 @@ nsHTMLDocument::QueryCommandIndeterm(const nsAString& commandID, ErrorResult& rv
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* boolean queryCommandState(in DOMString commandID); */
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::QueryCommandState(const nsAString & commandID, bool *_retval)
|
||||
{
|
||||
@@ -3512,7 +3508,6 @@ nsHTMLDocument::QueryCommandState(const nsAString& commandID, ErrorResult& rv)
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* boolean queryCommandSupported(in DOMString commandID); */
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::QueryCommandSupported(const nsAString & commandID,
|
||||
bool *_retval)
|
||||
@@ -3529,7 +3524,6 @@ nsHTMLDocument::QueryCommandSupported(const nsAString& commandID)
|
||||
return ConvertToMidasInternalCommand(commandID, cmdToDispatch);
|
||||
}
|
||||
|
||||
/* DOMString queryCommandValue(in DOMString commandID); */
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::QueryCommandValue(const nsAString & commandID,
|
||||
nsAString &_retval)
|
||||
|
||||
@@ -3501,7 +3501,6 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
NS_IMPL_ADDREF_INHERITED(TabChildGlobal, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(TabChildGlobal, DOMEventTargetHelper)
|
||||
|
||||
/* [notxpcom] boolean markForCC (); */
|
||||
// This method isn't automatically forwarded safely because it's notxpcom, so
|
||||
// the IDL binding doesn't know what value to return.
|
||||
NS_IMETHODIMP_(bool)
|
||||
|
||||
@@ -77,7 +77,6 @@ SVGGradientElement::GradientUnits()
|
||||
return mEnumAttributes[GRADIENTUNITS].ToDOMAnimatedEnum(this);
|
||||
}
|
||||
|
||||
/* readonly attribute SVGAnimatedTransformList gradientTransform; */
|
||||
already_AddRefed<SVGAnimatedTransformList>
|
||||
SVGGradientElement::GradientTransform()
|
||||
{
|
||||
|
||||
@@ -291,14 +291,12 @@ SVGSVGElement::SuspendRedraw(uint32_t max_wait_milliseconds)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* void unsuspendRedraw (in unsigned long suspend_handle_id); */
|
||||
void
|
||||
SVGSVGElement::UnsuspendRedraw(uint32_t suspend_handle_id)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
/* void unsuspendRedrawAll (); */
|
||||
void
|
||||
SVGSVGElement::UnsuspendRedrawAll()
|
||||
{
|
||||
|
||||
@@ -101,7 +101,6 @@ nsSVGElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/* readonly attribute SVGAnimatedString className; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetSVGClassName(nsISupports** aClassName)
|
||||
{
|
||||
@@ -109,7 +108,6 @@ nsSVGElement::GetSVGClassName(nsISupports** aClassName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMCSSStyleDeclaration style; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
|
||||
{
|
||||
@@ -1084,7 +1082,6 @@ nsSVGElement::sMaskMap[] = {
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMSVGElement methods
|
||||
|
||||
/* readonly attribute nsIDOMSVGSVGElement ownerSVGElement; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetOwnerSVGElement(nsIDOMSVGElement * *aOwnerSVGElement)
|
||||
{
|
||||
@@ -1098,7 +1095,6 @@ nsSVGElement::GetOwnerSVGElement()
|
||||
return GetCtx(); // this may return nullptr
|
||||
}
|
||||
|
||||
/* readonly attribute nsIDOMSVGElement viewportElement; */
|
||||
NS_IMETHODIMP
|
||||
nsSVGElement::GetViewportElement(nsIDOMSVGElement * *aViewportElement)
|
||||
{
|
||||
|
||||
@@ -81,7 +81,6 @@ nsresult nsVolumeMountLock::Init()
|
||||
return Lock(vol);
|
||||
}
|
||||
|
||||
/* void unlock (); */
|
||||
NS_IMETHODIMP nsVolumeMountLock::Unlock()
|
||||
{
|
||||
LOG("nsVolumeMountLock released for '%s'",
|
||||
|
||||
@@ -17,14 +17,12 @@ nsVolumeStat::nsVolumeStat(const nsAString& aPath)
|
||||
}
|
||||
}
|
||||
|
||||
/* readonly attribute long long totalBytes; */
|
||||
NS_IMETHODIMP nsVolumeStat::GetTotalBytes(int64_t* aTotalBytes)
|
||||
{
|
||||
*aTotalBytes = mStat.f_blocks * mStat.f_bsize;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute long long freeBytes; */
|
||||
NS_IMETHODIMP nsVolumeStat::GetFreeBytes(int64_t* aFreeBytes)
|
||||
{
|
||||
*aFreeBytes = mStat.f_bfree * mStat.f_bsize;
|
||||
|
||||
@@ -201,7 +201,6 @@ nsXULControllers::RemoveController(nsIController *controller)
|
||||
return NS_ERROR_FAILURE; // right thing to return if no controller found?
|
||||
}
|
||||
|
||||
/* unsigned long getControllerId (in nsIController controller); */
|
||||
NS_IMETHODIMP
|
||||
nsXULControllers::GetControllerId(nsIController *controller, uint32_t *_retval)
|
||||
{
|
||||
@@ -225,7 +224,6 @@ nsXULControllers::GetControllerId(nsIController *controller, uint32_t *_retval)
|
||||
return NS_ERROR_FAILURE; // none found
|
||||
}
|
||||
|
||||
/* nsIController getControllerById (in unsigned long controllerID); */
|
||||
NS_IMETHODIMP
|
||||
nsXULControllers::GetControllerById(uint32_t controllerID, nsIController **_retval)
|
||||
{
|
||||
|
||||
@@ -1840,7 +1840,6 @@ nsXULTreeBuilder::SortSubtree(nsTreeRows::Subtree* aSubtree)
|
||||
}
|
||||
|
||||
|
||||
/* boolean canDrop (in long index, in long orientation); */
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeBuilder::CanDrop(int32_t index, int32_t orientation,
|
||||
nsIDOMDataTransfer* dataTransfer, bool *_retval)
|
||||
|
||||
@@ -652,7 +652,6 @@ nsEditorSpellCheck::UninitSpellChecker()
|
||||
}
|
||||
|
||||
|
||||
/* void setFilter (in nsITextServicesFilter filter); */
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::SetFilter(nsITextServicesFilter *filter)
|
||||
{
|
||||
|
||||
@@ -607,7 +607,6 @@ nsEditor::GetWidget()
|
||||
return widget.forget();
|
||||
}
|
||||
|
||||
/* attribute string contentsMIMEType; */
|
||||
NS_IMETHODIMP
|
||||
nsEditor::GetContentsMIMEType(char * *aContentsMIMEType)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,6 @@ nsTransactionList::~nsTransactionList()
|
||||
mTxnItem = 0;
|
||||
}
|
||||
|
||||
/* readonly attribute long numItems; */
|
||||
NS_IMETHODIMP nsTransactionList::GetNumItems(int32_t *aNumItems)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNumItems, NS_ERROR_NULL_POINTER);
|
||||
@@ -60,7 +59,6 @@ NS_IMETHODIMP nsTransactionList::GetNumItems(int32_t *aNumItems)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* boolean itemIsBatch (in long aIndex); */
|
||||
NS_IMETHODIMP nsTransactionList::ItemIsBatch(int32_t aIndex, bool *aIsBatch)
|
||||
{
|
||||
NS_ENSURE_TRUE(aIsBatch, NS_ERROR_NULL_POINTER);
|
||||
@@ -123,7 +121,6 @@ NS_IMETHODIMP nsTransactionList::GetData(int32_t aIndex,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsITransaction getItem (in long aIndex); */
|
||||
NS_IMETHODIMP nsTransactionList::GetItem(int32_t aIndex, nsITransaction **aItem)
|
||||
{
|
||||
NS_ENSURE_TRUE(aItem, NS_ERROR_NULL_POINTER);
|
||||
@@ -152,7 +149,6 @@ NS_IMETHODIMP nsTransactionList::GetItem(int32_t aIndex, nsITransaction **aItem)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* long getNumChildrenForItem (in long aIndex); */
|
||||
NS_IMETHODIMP nsTransactionList::GetNumChildrenForItem(int32_t aIndex, int32_t *aNumChildren)
|
||||
{
|
||||
NS_ENSURE_TRUE(aNumChildren, NS_ERROR_NULL_POINTER);
|
||||
@@ -179,7 +175,6 @@ NS_IMETHODIMP nsTransactionList::GetNumChildrenForItem(int32_t aIndex, int32_t *
|
||||
return item->GetNumberOfChildren(aNumChildren);
|
||||
}
|
||||
|
||||
/* nsITransactionList getChildListForItem (in long aIndex); */
|
||||
NS_IMETHODIMP nsTransactionList::GetChildListForItem(int32_t aIndex, nsITransactionList **aTxnList)
|
||||
{
|
||||
NS_ENSURE_TRUE(aTxnList, NS_ERROR_NULL_POINTER);
|
||||
|
||||
@@ -35,7 +35,6 @@ nsPrintProgress::~nsPrintProgress()
|
||||
(void)ReleaseListeners();
|
||||
}
|
||||
|
||||
/* void openProgressDialog (in nsIDOMWindow parent, in string dialogURL, in nsISupports parameters); */
|
||||
NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent,
|
||||
const char *dialogURL,
|
||||
nsISupports *parameters,
|
||||
@@ -49,7 +48,6 @@ NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent,
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void closeProgressDialog (in boolean forceClose); */
|
||||
NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
|
||||
{
|
||||
MOZ_ASSERT_UNREACHABLE("The nsPrintingPromptService::ShowProgress "
|
||||
@@ -59,7 +57,6 @@ NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* nsIPrompt GetPrompter (); */
|
||||
NS_IMETHODIMP nsPrintProgress::GetPrompter(nsIPrompt **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
@@ -71,7 +68,6 @@ NS_IMETHODIMP nsPrintProgress::GetPrompter(nsIPrompt **_retval)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* attribute boolean processCanceledByUser; */
|
||||
NS_IMETHODIMP nsPrintProgress::GetProcessCanceledByUser(bool *aProcessCanceledByUser)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aProcessCanceledByUser);
|
||||
@@ -85,7 +81,6 @@ NS_IMETHODIMP nsPrintProgress::SetProcessCanceledByUser(bool aProcessCanceledByU
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void RegisterListener (in nsIWebProgressListener listener); */
|
||||
NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listener)
|
||||
{
|
||||
if (!listener) //Nothing to do with a null listener!
|
||||
@@ -105,7 +100,6 @@ NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listene
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void UnregisterListener (in nsIWebProgressListener listener); */
|
||||
NS_IMETHODIMP nsPrintProgress::UnregisterListener(nsIWebProgressListener *listener)
|
||||
{
|
||||
if (listener)
|
||||
@@ -114,7 +108,6 @@ NS_IMETHODIMP nsPrintProgress::UnregisterListener(nsIWebProgressListener *listen
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void doneIniting (); */
|
||||
NS_IMETHODIMP nsPrintProgress::DoneIniting()
|
||||
{
|
||||
if (m_observer) {
|
||||
@@ -123,7 +116,6 @@ NS_IMETHODIMP nsPrintProgress::DoneIniting()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in nsresult aStatus); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, uint32_t aStateFlags, nsresult aStatus)
|
||||
{
|
||||
m_pendingStateFlags = aStateFlags;
|
||||
@@ -140,7 +132,6 @@ NS_IMETHODIMP nsPrintProgress::OnStateChange(nsIWebProgress *aWebProgress, nsIRe
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, int32_t aCurSelfProgress, int32_t aMaxSelfProgress, int32_t aCurTotalProgress, int32_t aMaxTotalProgress)
|
||||
{
|
||||
uint32_t count = m_listenerList.Count();
|
||||
@@ -154,13 +145,11 @@ NS_IMETHODIMP nsPrintProgress::OnProgressChange(nsIWebProgress *aWebProgress, ns
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, uint32_t aFlags)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const char16_t *aMessage)
|
||||
{
|
||||
if (aMessage && *aMessage)
|
||||
@@ -177,7 +166,6 @@ NS_IMETHODIMP nsPrintProgress::OnStatusChange(nsIWebProgress *aWebProgress, nsIR
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long state); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, uint32_t state)
|
||||
{
|
||||
return NS_OK;
|
||||
@@ -194,31 +182,26 @@ NS_IMETHODIMP nsPrintProgress::ShowStatusString(const char16_t *status)
|
||||
return OnStatusChange(nullptr, nullptr, NS_OK, status);
|
||||
}
|
||||
|
||||
/* void startMeteors (); */
|
||||
NS_IMETHODIMP nsPrintProgress::StartMeteors()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void stopMeteors (); */
|
||||
NS_IMETHODIMP nsPrintProgress::StopMeteors()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void showProgress (in long percent); */
|
||||
NS_IMETHODIMP nsPrintProgress::ShowProgress(int32_t percent)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* [noscript] void setDocShell (in nsIDocShell shell, in nsIDOMWindow window); */
|
||||
NS_IMETHODIMP nsPrintProgress::SetDocShell(nsIDocShell *shell, nsIDOMWindow *window)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void closeWindow (); */
|
||||
NS_IMETHODIMP nsPrintProgress::CloseWindow()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
@@ -17,7 +17,6 @@ nsPrintProgressParams::~nsPrintProgressParams()
|
||||
{
|
||||
}
|
||||
|
||||
/* attribute wstring docTitle; */
|
||||
NS_IMETHODIMP nsPrintProgressParams::GetDocTitle(char16_t * *aDocTitle)
|
||||
{
|
||||
NS_ENSURE_ARG(aDocTitle);
|
||||
@@ -32,7 +31,6 @@ NS_IMETHODIMP nsPrintProgressParams::SetDocTitle(const char16_t * aDocTitle)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute wstring docURL; */
|
||||
NS_IMETHODIMP nsPrintProgressParams::GetDocURL(char16_t * *aDocURL)
|
||||
{
|
||||
NS_ENSURE_ARG(aDocURL);
|
||||
|
||||
@@ -42,7 +42,6 @@ nsPrintProgress::~nsPrintProgress()
|
||||
(void)ReleaseListeners();
|
||||
}
|
||||
|
||||
/* void openProgressDialog (in nsIDOMWindow parent, in string dialogURL, in nsISupports parameters); */
|
||||
NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent,
|
||||
const char *dialogURL,
|
||||
nsISupports *parameters,
|
||||
@@ -108,7 +107,6 @@ NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent,
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void closeProgressDialog (in boolean forceClose); */
|
||||
NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
|
||||
{
|
||||
m_closeProgress = true;
|
||||
@@ -117,7 +115,6 @@ NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
|
||||
(nsresult)forceClose);
|
||||
}
|
||||
|
||||
/* nsIPrompt GetPrompter (); */
|
||||
NS_IMETHODIMP nsPrintProgress::GetPrompter(nsIPrompt **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
@@ -129,7 +126,6 @@ NS_IMETHODIMP nsPrintProgress::GetPrompter(nsIPrompt **_retval)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* attribute boolean processCanceledByUser; */
|
||||
NS_IMETHODIMP nsPrintProgress::GetProcessCanceledByUser(bool *aProcessCanceledByUser)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aProcessCanceledByUser);
|
||||
@@ -145,7 +141,6 @@ NS_IMETHODIMP nsPrintProgress::SetProcessCanceledByUser(bool aProcessCanceledByU
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void RegisterListener (in nsIWebProgressListener listener); */
|
||||
NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listener)
|
||||
{
|
||||
if (!listener) //Nothing to do with a null listener!
|
||||
@@ -164,7 +159,6 @@ NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listene
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void UnregisterListener (in nsIWebProgressListener listener); */
|
||||
NS_IMETHODIMP nsPrintProgress::UnregisterListener(nsIWebProgressListener *listener)
|
||||
{
|
||||
if (listener)
|
||||
@@ -173,7 +167,6 @@ NS_IMETHODIMP nsPrintProgress::UnregisterListener(nsIWebProgressListener *listen
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void doneIniting (); */
|
||||
NS_IMETHODIMP nsPrintProgress::DoneIniting()
|
||||
{
|
||||
if (m_observer) {
|
||||
@@ -182,7 +175,6 @@ NS_IMETHODIMP nsPrintProgress::DoneIniting()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in nsresult aStatus); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, uint32_t aStateFlags, nsresult aStatus)
|
||||
{
|
||||
m_pendingStateFlags = aStateFlags;
|
||||
@@ -199,7 +191,6 @@ NS_IMETHODIMP nsPrintProgress::OnStateChange(nsIWebProgress *aWebProgress, nsIRe
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, int32_t aCurSelfProgress, int32_t aMaxSelfProgress, int32_t aCurTotalProgress, int32_t aMaxTotalProgress)
|
||||
{
|
||||
uint32_t count = m_listenerList.Count();
|
||||
@@ -213,13 +204,11 @@ NS_IMETHODIMP nsPrintProgress::OnProgressChange(nsIWebProgress *aWebProgress, ns
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, uint32_t aFlags)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const char16_t *aMessage)
|
||||
{
|
||||
if (aMessage && *aMessage)
|
||||
@@ -236,7 +225,6 @@ NS_IMETHODIMP nsPrintProgress::OnStatusChange(nsIWebProgress *aWebProgress, nsIR
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long state); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, uint32_t state)
|
||||
{
|
||||
return NS_OK;
|
||||
@@ -254,31 +242,26 @@ NS_IMETHODIMP nsPrintProgress::ShowStatusString(const char16_t *status)
|
||||
return OnStatusChange(nullptr, nullptr, NS_OK, status);
|
||||
}
|
||||
|
||||
/* void startMeteors (); */
|
||||
NS_IMETHODIMP nsPrintProgress::StartMeteors()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void stopMeteors (); */
|
||||
NS_IMETHODIMP nsPrintProgress::StopMeteors()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void showProgress (in long percent); */
|
||||
NS_IMETHODIMP nsPrintProgress::ShowProgress(int32_t percent)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* [noscript] void setDocShell (in nsIDocShell shell, in nsIDOMWindow window); */
|
||||
NS_IMETHODIMP nsPrintProgress::SetDocShell(nsIDocShell *shell, nsIDOMWindow *window)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void closeWindow (); */
|
||||
NS_IMETHODIMP nsPrintProgress::CloseWindow()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
@@ -17,7 +17,6 @@ nsPrintProgressParams::~nsPrintProgressParams()
|
||||
{
|
||||
}
|
||||
|
||||
/* attribute wstring docTitle; */
|
||||
NS_IMETHODIMP nsPrintProgressParams::GetDocTitle(char16_t * *aDocTitle)
|
||||
{
|
||||
NS_ENSURE_ARG(aDocTitle);
|
||||
@@ -32,7 +31,6 @@ NS_IMETHODIMP nsPrintProgressParams::SetDocTitle(const char16_t * aDocTitle)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute wstring docURL; */
|
||||
NS_IMETHODIMP nsPrintProgressParams::GetDocURL(char16_t * *aDocURL)
|
||||
{
|
||||
NS_ENSURE_ARG(aDocURL);
|
||||
|
||||
@@ -71,7 +71,6 @@ nsPrintingPromptService::Init()
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void showPrintDialog (in nsIDOMWindow parent, in nsIWebBrowserPrint webBrowserPrint, in nsIPrintSettings printSettings); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings)
|
||||
{
|
||||
@@ -94,7 +93,6 @@ nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrin
|
||||
return DoDialog(parent, block, webBrowserPrint, printSettings, kPrintDialogURL);
|
||||
}
|
||||
|
||||
/* void showProgress (in nsIDOMWindow parent, in nsIWebBrowserPrint webBrowserPrint, in nsIPrintSettings printSettings, in nsIObserver openDialogObserver, in boolean isForPrinting, out nsIWebProgressListener webProgressListener, out nsIPrintProgressParams printProgressParams, out boolean notifyOnOpen); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowProgress(nsIDOMWindow* parent,
|
||||
nsIWebBrowserPrint* webBrowserPrint, // ok to be null
|
||||
@@ -135,7 +133,6 @@ nsPrintingPromptService::ShowProgress(nsIDOMWindow* parent,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void showPageSetup (in nsIDOMWindow parent, in nsIPrintSettings printSettings); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *printSettings, nsIObserver *aObs)
|
||||
{
|
||||
@@ -156,7 +153,6 @@ nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *p
|
||||
return DoDialog(parent, block, nullptr, printSettings, kPageSetupDialogURL);
|
||||
}
|
||||
|
||||
/* void showPrinterProperties (in nsIDOMWindow parent, in wstring printerName, in nsIPrintSettings printSettings); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPrinterProperties(nsIDOMWindow *parent, const char16_t *printerName, nsIPrintSettings *printSettings)
|
||||
{
|
||||
@@ -251,7 +247,6 @@ nsPrintingPromptService::DoDialog(nsIDOMWindow *aParent,
|
||||
// nsIWebProgressListener
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in nsresult aStatus); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, uint32_t aStateFlags, nsresult aStatus)
|
||||
{
|
||||
@@ -266,7 +261,6 @@ nsPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, int32_t aCurSelfProgress, int32_t aMaxSelfProgress, int32_t aCurTotalProgress, int32_t aMaxTotalProgress)
|
||||
{
|
||||
@@ -276,7 +270,6 @@ nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIReque
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, uint32_t aFlags)
|
||||
{
|
||||
@@ -286,7 +279,6 @@ nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIReque
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const char16_t *aMessage)
|
||||
{
|
||||
@@ -296,7 +288,6 @@ nsPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long state); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, uint32_t state)
|
||||
{
|
||||
|
||||
@@ -69,7 +69,6 @@ nsPrintProgress::~nsPrintProgress()
|
||||
(void)ReleaseListeners();
|
||||
}
|
||||
|
||||
/* void openProgressDialog (in nsIDOMWindow parent, in string dialogURL, in nsISupports parameters); */
|
||||
NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent,
|
||||
const char *dialogURL,
|
||||
nsISupports *parameters,
|
||||
@@ -135,7 +134,6 @@ NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindow *parent,
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void closeProgressDialog (in boolean forceClose); */
|
||||
NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
|
||||
{
|
||||
m_closeProgress = true;
|
||||
@@ -144,7 +142,6 @@ NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose)
|
||||
static_cast<nsresult>(forceClose));
|
||||
}
|
||||
|
||||
/* nsIPrompt GetPrompter (); */
|
||||
NS_IMETHODIMP nsPrintProgress::GetPrompter(nsIPrompt **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
@@ -156,7 +153,6 @@ NS_IMETHODIMP nsPrintProgress::GetPrompter(nsIPrompt **_retval)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* attribute boolean processCanceledByUser; */
|
||||
NS_IMETHODIMP nsPrintProgress::GetProcessCanceledByUser(bool *aProcessCanceledByUser)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aProcessCanceledByUser);
|
||||
@@ -170,7 +166,6 @@ NS_IMETHODIMP nsPrintProgress::SetProcessCanceledByUser(bool aProcessCanceledByU
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void RegisterListener (in nsIWebProgressListener listener); */
|
||||
NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listener)
|
||||
{
|
||||
if (!listener) //Nothing to do with a null listener!
|
||||
@@ -190,7 +185,6 @@ NS_IMETHODIMP nsPrintProgress::RegisterListener(nsIWebProgressListener * listene
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void UnregisterListener (in nsIWebProgressListener listener); */
|
||||
NS_IMETHODIMP nsPrintProgress::UnregisterListener(nsIWebProgressListener *listener)
|
||||
{
|
||||
if (listener)
|
||||
@@ -199,7 +193,6 @@ NS_IMETHODIMP nsPrintProgress::UnregisterListener(nsIWebProgressListener *listen
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void doneIniting (); */
|
||||
NS_IMETHODIMP nsPrintProgress::DoneIniting()
|
||||
{
|
||||
if (m_observer) {
|
||||
@@ -208,7 +201,6 @@ NS_IMETHODIMP nsPrintProgress::DoneIniting()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long aStateFlags, in nsresult aStatus); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, uint32_t aStateFlags, nsresult aStatus)
|
||||
{
|
||||
m_pendingStateFlags = aStateFlags;
|
||||
@@ -225,7 +217,6 @@ NS_IMETHODIMP nsPrintProgress::OnStateChange(nsIWebProgress *aWebProgress, nsIRe
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, int32_t aCurSelfProgress, int32_t aMaxSelfProgress, int32_t aCurTotalProgress, int32_t aMaxTotalProgress)
|
||||
{
|
||||
uint32_t count = m_listenerList.Count();
|
||||
@@ -239,13 +230,11 @@ NS_IMETHODIMP nsPrintProgress::OnProgressChange(nsIWebProgress *aWebProgress, ns
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, uint32_t aFlags)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const char16_t *aMessage)
|
||||
{
|
||||
if (aMessage && *aMessage)
|
||||
@@ -262,7 +251,6 @@ NS_IMETHODIMP nsPrintProgress::OnStatusChange(nsIWebProgress *aWebProgress, nsIR
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long state); */
|
||||
NS_IMETHODIMP nsPrintProgress::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, uint32_t state)
|
||||
{
|
||||
return NS_OK;
|
||||
@@ -279,31 +267,26 @@ NS_IMETHODIMP nsPrintProgress::ShowStatusString(const char16_t *status)
|
||||
return OnStatusChange(nullptr, nullptr, NS_OK, status);
|
||||
}
|
||||
|
||||
/* void startMeteors (); */
|
||||
NS_IMETHODIMP nsPrintProgress::StartMeteors()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void stopMeteors (); */
|
||||
NS_IMETHODIMP nsPrintProgress::StopMeteors()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void showProgress (in long percent); */
|
||||
NS_IMETHODIMP nsPrintProgress::ShowProgress(int32_t percent)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* [noscript] void setDocShell (in nsIDocShell shell, in nsIDOMWindow window); */
|
||||
NS_IMETHODIMP nsPrintProgress::SetDocShell(nsIDocShell *shell, nsIDOMWindow *window)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void closeWindow (); */
|
||||
NS_IMETHODIMP nsPrintProgress::CloseWindow()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
@@ -17,7 +17,6 @@ nsPrintProgressParams::~nsPrintProgressParams()
|
||||
{
|
||||
}
|
||||
|
||||
/* attribute wstring docTitle; */
|
||||
NS_IMETHODIMP nsPrintProgressParams::GetDocTitle(char16_t * *aDocTitle)
|
||||
{
|
||||
NS_ENSURE_ARG(aDocTitle);
|
||||
@@ -32,7 +31,6 @@ NS_IMETHODIMP nsPrintProgressParams::SetDocTitle(const char16_t * aDocTitle)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute wstring docURL; */
|
||||
NS_IMETHODIMP nsPrintProgressParams::GetDocURL(char16_t * *aDocURL)
|
||||
{
|
||||
NS_ENSURE_ARG(aDocURL);
|
||||
|
||||
@@ -157,7 +157,6 @@ nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrin
|
||||
}
|
||||
|
||||
|
||||
/* void showProgress (in nsIDOMWindow parent, in nsIWebBrowserPrint webBrowserPrint, in nsIPrintSettings printSettings, in nsIObserver openDialogObserver, in boolean isForPrinting, out nsIWebProgressListener webProgressListener, out nsIPrintProgressParams printProgressParams, out boolean notifyOnOpen); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowProgress(nsIDOMWindow* parent,
|
||||
nsIWebBrowserPrint* webBrowserPrint, // ok to be null
|
||||
@@ -203,7 +202,6 @@ nsPrintingPromptService::ShowProgress(nsIDOMWindow* parent,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void showPageSetup (in nsIDOMWindow parent, in nsIPrintSettings printSettings); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *printSettings, nsIObserver *aObs)
|
||||
{
|
||||
@@ -229,7 +227,6 @@ nsPrintingPromptService::ShowPageSetup(nsIDOMWindow *parent, nsIPrintSettings *p
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void showPrinterProperties (in nsIDOMWindow parent, in wstring printerName, in nsIPrintSettings printSettings); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::ShowPrinterProperties(nsIDOMWindow *parent, const char16_t *printerName, nsIPrintSettings *printSettings)
|
||||
{
|
||||
@@ -293,7 +290,6 @@ nsPrintingPromptService::DoDialog(nsIDOMWindow *aParent,
|
||||
// nsIWebProgressListener
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aStateFlags, in nsresult aStatus); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, uint32_t aStateFlags, nsresult aStatus)
|
||||
{
|
||||
@@ -310,7 +306,6 @@ nsPrintingPromptService::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onProgressChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aCurSelfProgress, in long aMaxSelfProgress, in long aCurTotalProgress, in long aMaxTotalProgress); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, int32_t aCurSelfProgress, int32_t aMaxSelfProgress, int32_t aCurTotalProgress, int32_t aMaxTotalProgress)
|
||||
{
|
||||
@@ -321,7 +316,6 @@ nsPrintingPromptService::OnProgressChange(nsIWebProgress *aWebProgress, nsIReque
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* void onLocationChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsIURI location, in unsigned long aFlags); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location, uint32_t aFlags)
|
||||
{
|
||||
@@ -332,7 +326,6 @@ nsPrintingPromptService::OnLocationChange(nsIWebProgress *aWebProgress, nsIReque
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* void onStatusChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in nsresult aStatus, in wstring aMessage); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const char16_t *aMessage)
|
||||
{
|
||||
@@ -343,7 +336,6 @@ nsPrintingPromptService::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* void onSecurityChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in unsigned long state); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintingPromptService::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, uint32_t state)
|
||||
{
|
||||
|
||||
@@ -270,7 +270,6 @@ NS_IMETHODIMP nsWebBrowserPersist::GetInterface(const nsIID & aIID, void **aIFac
|
||||
// nsWebBrowserPersist::nsIWebBrowserPersist
|
||||
//*****************************************************************************
|
||||
|
||||
/* attribute unsigned long persistFlags; */
|
||||
NS_IMETHODIMP nsWebBrowserPersist::GetPersistFlags(uint32_t *aPersistFlags)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPersistFlags);
|
||||
@@ -285,7 +284,6 @@ NS_IMETHODIMP nsWebBrowserPersist::SetPersistFlags(uint32_t aPersistFlags)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long currentState; */
|
||||
NS_IMETHODIMP nsWebBrowserPersist::GetCurrentState(uint32_t *aCurrentState)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCurrentState);
|
||||
@@ -304,7 +302,6 @@ NS_IMETHODIMP nsWebBrowserPersist::GetCurrentState(uint32_t *aCurrentState)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long result; */
|
||||
NS_IMETHODIMP nsWebBrowserPersist::GetResult(nsresult *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
@@ -312,7 +309,6 @@ NS_IMETHODIMP nsWebBrowserPersist::GetResult(nsresult *aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute nsIWebBrowserPersistProgress progressListener; */
|
||||
NS_IMETHODIMP nsWebBrowserPersist::GetProgressListener(
|
||||
nsIWebProgressListener * *aProgressListener)
|
||||
{
|
||||
@@ -366,7 +362,6 @@ NS_IMETHODIMP nsWebBrowserPersist::SavePrivacyAwareURI(
|
||||
return NS_FAILED(rv) ? rv : NS_OK;
|
||||
}
|
||||
|
||||
/* void saveChannel (in nsIChannel aChannel, in nsISupports aFile); */
|
||||
NS_IMETHODIMP nsWebBrowserPersist::SaveChannel(
|
||||
nsIChannel *aChannel, nsISupports *aFile)
|
||||
{
|
||||
@@ -480,7 +475,6 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveDocument(
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void cancel(nsresult aReason); */
|
||||
NS_IMETHODIMP nsWebBrowserPersist::Cancel(nsresult aReason)
|
||||
{
|
||||
mCancel = true;
|
||||
@@ -489,7 +483,6 @@ NS_IMETHODIMP nsWebBrowserPersist::Cancel(nsresult aReason)
|
||||
}
|
||||
|
||||
|
||||
/* void cancelSave(); */
|
||||
NS_IMETHODIMP nsWebBrowserPersist::CancelSave()
|
||||
{
|
||||
return Cancel(NS_BINDING_ABORTED);
|
||||
|
||||
@@ -136,7 +136,6 @@ mozHunspell::~mozHunspell()
|
||||
delete mHunspell;
|
||||
}
|
||||
|
||||
/* attribute wstring dictionary; */
|
||||
NS_IMETHODIMP mozHunspell::GetDictionary(char16_t **aDictionary)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDictionary);
|
||||
@@ -237,7 +236,6 @@ NS_IMETHODIMP mozHunspell::SetDictionary(const char16_t *aDictionary)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute wstring language; */
|
||||
NS_IMETHODIMP mozHunspell::GetLanguage(char16_t **aLanguage)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLanguage);
|
||||
@@ -249,7 +247,6 @@ NS_IMETHODIMP mozHunspell::GetLanguage(char16_t **aLanguage)
|
||||
return *aLanguage ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* readonly attribute boolean providesPersonalDictionary; */
|
||||
NS_IMETHODIMP mozHunspell::GetProvidesPersonalDictionary(bool *aProvidesPersonalDictionary)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aProvidesPersonalDictionary);
|
||||
@@ -258,7 +255,6 @@ NS_IMETHODIMP mozHunspell::GetProvidesPersonalDictionary(bool *aProvidesPersonal
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute boolean providesWordUtils; */
|
||||
NS_IMETHODIMP mozHunspell::GetProvidesWordUtils(bool *aProvidesWordUtils)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aProvidesWordUtils);
|
||||
@@ -267,19 +263,16 @@ NS_IMETHODIMP mozHunspell::GetProvidesWordUtils(bool *aProvidesWordUtils)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute wstring name; */
|
||||
NS_IMETHODIMP mozHunspell::GetName(char16_t * *aName)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* readonly attribute wstring copyright; */
|
||||
NS_IMETHODIMP mozHunspell::GetCopyright(char16_t * *aCopyright)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* attribute mozIPersonalDictionary personalDictionary; */
|
||||
NS_IMETHODIMP mozHunspell::GetPersonalDictionary(mozIPersonalDictionary * *aPersonalDictionary)
|
||||
{
|
||||
*aPersonalDictionary = mPersonalDictionary;
|
||||
@@ -314,7 +307,6 @@ AppendNewString(const nsAString& aString, nsIFile* aFile, void* aClosure)
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
/* void GetDictionaryList ([array, size_is (count)] out wstring dictionaries, out uint32_t count); */
|
||||
NS_IMETHODIMP mozHunspell::GetDictionaryList(char16_t ***aDictionaries,
|
||||
uint32_t *aCount)
|
||||
{
|
||||
@@ -530,7 +522,6 @@ mozHunspell::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
"Memory used by the spell-checking engine.");
|
||||
}
|
||||
|
||||
/* boolean Check (in wstring word); */
|
||||
NS_IMETHODIMP mozHunspell::Check(const char16_t *aWord, bool *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aWord);
|
||||
@@ -549,7 +540,6 @@ NS_IMETHODIMP mozHunspell::Check(const char16_t *aWord, bool *aResult)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void Suggest (in wstring word, [array, size_is (count)] out wstring suggestions, out uint32_t count); */
|
||||
NS_IMETHODIMP mozHunspell::Suggest(const char16_t *aWord, char16_t ***aSuggestions, uint32_t *aSuggestionCount)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aSuggestions);
|
||||
@@ -612,7 +602,6 @@ mozHunspell::Observe(nsISupports* aSubj, const char *aTopic,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void addDirectory(in nsIFile dir); */
|
||||
NS_IMETHODIMP mozHunspell::AddDirectory(nsIFile *aDir)
|
||||
{
|
||||
mDynamicDirectories.AppendObject(aDir);
|
||||
@@ -620,7 +609,6 @@ NS_IMETHODIMP mozHunspell::AddDirectory(nsIFile *aDir)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void removeDirectory(in nsIFile dir); */
|
||||
NS_IMETHODIMP mozHunspell::RemoveDirectory(nsIFile *aDir)
|
||||
{
|
||||
mDynamicDirectories.RemoveObject(aDir);
|
||||
|
||||
@@ -36,7 +36,6 @@ mozEnglishWordUtils::~mozEnglishWordUtils()
|
||||
{
|
||||
}
|
||||
|
||||
/* attribute wstring language; */
|
||||
NS_IMETHODIMP mozEnglishWordUtils::GetLanguage(char16_t * *aLanguage)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
@@ -47,7 +46,6 @@ NS_IMETHODIMP mozEnglishWordUtils::GetLanguage(char16_t * *aLanguage)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void GetRootForm (in wstring aWord, in uint32_t type, [array, size_is (count)] out wstring words, out uint32_t count); */
|
||||
// return the possible root forms of aWord.
|
||||
NS_IMETHODIMP mozEnglishWordUtils::GetRootForm(const char16_t *aWord, uint32_t type, char16_t ***words, uint32_t *count)
|
||||
{
|
||||
@@ -138,7 +136,6 @@ bool mozEnglishWordUtils::ucIsAlpha(char16_t aChar)
|
||||
return nsIUGenCategory::kLetter == mozilla::unicode::GetGenCategory(aChar);
|
||||
}
|
||||
|
||||
/* void FindNextWord (in wstring word, in uint32_t length, in uint32_t offset, out uint32_t begin, out uint32_t end); */
|
||||
NS_IMETHODIMP mozEnglishWordUtils::FindNextWord(const char16_t *word, uint32_t length, uint32_t offset, int32_t *begin, int32_t *end)
|
||||
{
|
||||
const char16_t *p = word + offset;
|
||||
|
||||
@@ -18,25 +18,21 @@ mozGenericWordUtils::~mozGenericWordUtils()
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
/* readonly attribute wstring language; */
|
||||
NS_IMETHODIMP mozGenericWordUtils::GetLanguage(char16_t * *aLanguage)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void GetRootForm (in wstring word, in uint32_t type, [array, size_is (count)] out wstring words, out uint32_t count); */
|
||||
NS_IMETHODIMP mozGenericWordUtils::GetRootForm(const char16_t *word, uint32_t type, char16_t ***words, uint32_t *count)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void FromRootForm (in wstring word, [array, size_is (icount)] in wstring iwords, in uint32_t icount, [array, size_is (ocount)] out wstring owords, out uint32_t ocount); */
|
||||
NS_IMETHODIMP mozGenericWordUtils::FromRootForm(const char16_t *word, const char16_t **iwords, uint32_t icount, char16_t ***owords, uint32_t *ocount)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void FindNextWord (in wstring word, in uint32_t length, in uint32_t offset, out uint32_t begin, out uint32_t end); */
|
||||
NS_IMETHODIMP mozGenericWordUtils::FindNextWord(const char16_t *word, uint32_t length, uint32_t offset, int32_t *begin, int32_t *end)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
@@ -389,7 +389,6 @@ NS_IMETHODIMP mozPersonalDictionary::Save()
|
||||
return res;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIStringEnumerator GetWordList() */
|
||||
NS_IMETHODIMP mozPersonalDictionary::GetWordList(nsIStringEnumerator **aWords)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aWords);
|
||||
@@ -407,7 +406,6 @@ NS_IMETHODIMP mozPersonalDictionary::GetWordList(nsIStringEnumerator **aWords)
|
||||
return NS_NewAdoptingStringEnumerator(aWords, array);
|
||||
}
|
||||
|
||||
/* boolean Check (in wstring word, in wstring language); */
|
||||
NS_IMETHODIMP mozPersonalDictionary::Check(const char16_t *aWord, const char16_t *aLanguage, bool *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aWord);
|
||||
@@ -419,7 +417,6 @@ NS_IMETHODIMP mozPersonalDictionary::Check(const char16_t *aWord, const char16_t
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void AddWord (in wstring word); */
|
||||
NS_IMETHODIMP mozPersonalDictionary::AddWord(const char16_t *aWord, const char16_t *aLang)
|
||||
{
|
||||
nsresult res;
|
||||
@@ -430,7 +427,6 @@ NS_IMETHODIMP mozPersonalDictionary::AddWord(const char16_t *aWord, const char16
|
||||
return res;
|
||||
}
|
||||
|
||||
/* void RemoveWord (in wstring word); */
|
||||
NS_IMETHODIMP mozPersonalDictionary::RemoveWord(const char16_t *aWord, const char16_t *aLang)
|
||||
{
|
||||
nsresult res;
|
||||
@@ -441,7 +437,6 @@ NS_IMETHODIMP mozPersonalDictionary::RemoveWord(const char16_t *aWord, const cha
|
||||
return res;
|
||||
}
|
||||
|
||||
/* void IgnoreWord (in wstring word); */
|
||||
NS_IMETHODIMP mozPersonalDictionary::IgnoreWord(const char16_t *aWord)
|
||||
{
|
||||
// avoid adding duplicate words to the ignore list
|
||||
@@ -450,7 +445,6 @@ NS_IMETHODIMP mozPersonalDictionary::IgnoreWord(const char16_t *aWord)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void EndSession (); */
|
||||
NS_IMETHODIMP mozPersonalDictionary::EndSession()
|
||||
{
|
||||
WaitForLoad();
|
||||
@@ -460,25 +454,21 @@ NS_IMETHODIMP mozPersonalDictionary::EndSession()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void AddCorrection (in wstring word, in wstring correction); */
|
||||
NS_IMETHODIMP mozPersonalDictionary::AddCorrection(const char16_t *word, const char16_t *correction, const char16_t *lang)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void RemoveCorrection (in wstring word, in wstring correction); */
|
||||
NS_IMETHODIMP mozPersonalDictionary::RemoveCorrection(const char16_t *word, const char16_t *correction, const char16_t *lang)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void GetCorrection (in wstring word, [array, size_is (count)] out wstring words, out uint32_t count); */
|
||||
NS_IMETHODIMP mozPersonalDictionary::GetCorrection(const char16_t *word, char16_t ***words, uint32_t *count)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void observe (in nsISupports aSubject, in string aTopic, in wstring aData); */
|
||||
NS_IMETHODIMP mozPersonalDictionary::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *aData)
|
||||
{
|
||||
if (!nsCRT::strcmp(aTopic, "profile-do-change")) {
|
||||
|
||||
@@ -20,7 +20,6 @@ mozSpellI18NManager::~mozSpellI18NManager()
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
/* mozISpellI18NUtil GetUtil (in wstring language); */
|
||||
NS_IMETHODIMP mozSpellI18NManager::GetUtil(const char16_t *aLanguage, mozISpellI18NUtil **_retval)
|
||||
{
|
||||
if( nullptr == _retval) {
|
||||
|
||||
@@ -278,6 +278,7 @@ private:
|
||||
DECL_GFX_PREF(Live, "image.mozsamplesize.enabled", ImageMozSampleSizeEnabled, bool, false);
|
||||
DECL_GFX_PREF(Once, "image.multithreaded_decoding.limit", ImageMTDecodingLimit, int32_t, -1);
|
||||
DECL_GFX_PREF(Live, "image.single-color-optimization.enabled", ImageSingleColorOptimizationEnabled, bool, true);
|
||||
DECL_GFX_PREF(Live, "image.webp.enabled", ImageWebPEnabled, bool, true);
|
||||
|
||||
DECL_GFX_PREF(Once, "layers.acceleration.disabled", LayersAccelerationDisabled, bool, false);
|
||||
DECL_GFX_PREF(Live, "layers.acceleration.draw-fps", LayersDrawFPS, bool, false);
|
||||
|
||||
+9
-16
@@ -96,7 +96,6 @@ public:
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mDecoder->Finish();
|
||||
mDecoder->GetImage()->FinalizeDecoder(mDecoder);
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -203,8 +202,8 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if (aDecoder->IsSizeDecode()) {
|
||||
mSizeDecodeQueue.AppendElement(Move(decoder));
|
||||
if (aDecoder->IsMetadataDecode()) {
|
||||
mMetadataDecodeQueue.AppendElement(Move(decoder));
|
||||
} else {
|
||||
mFullDecodeQueue.AppendElement(Move(decoder));
|
||||
}
|
||||
@@ -218,14 +217,9 @@ public:
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
|
||||
do {
|
||||
// XXX(seth): The queue popping code below is NOT efficient, obviously,
|
||||
// since we're removing an element from the front of the array. However,
|
||||
// it's not worth implementing something better right now, because we are
|
||||
// replacing this FIFO behavior with LIFO behavior very soon.
|
||||
|
||||
// Prioritize size decodes over full decodes.
|
||||
if (!mSizeDecodeQueue.IsEmpty()) {
|
||||
return PopWorkFromQueue(mSizeDecodeQueue);
|
||||
// Prioritize metadata decodes over full decodes.
|
||||
if (!mMetadataDecodeQueue.IsEmpty()) {
|
||||
return PopWorkFromQueue(mMetadataDecodeQueue);
|
||||
}
|
||||
|
||||
if (!mFullDecodeQueue.IsEmpty()) {
|
||||
@@ -250,17 +244,17 @@ private:
|
||||
{
|
||||
Work work;
|
||||
work.mType = Work::Type::DECODE;
|
||||
work.mDecoder = aQueue.ElementAt(0);
|
||||
aQueue.RemoveElementAt(0);
|
||||
work.mDecoder = aQueue.LastElement();
|
||||
aQueue.RemoveElementAt(aQueue.Length() - 1);
|
||||
|
||||
return work;
|
||||
}
|
||||
|
||||
nsThreadPoolNaming mThreadNaming;
|
||||
|
||||
// mMonitor guards mQueue and mShuttingDown.
|
||||
// mMonitor guards the queues and mShuttingDown.
|
||||
Monitor mMonitor;
|
||||
nsTArray<nsRefPtr<Decoder>> mSizeDecodeQueue;
|
||||
nsTArray<nsRefPtr<Decoder>> mMetadataDecodeQueue;
|
||||
nsTArray<nsRefPtr<Decoder>> mFullDecodeQueue;
|
||||
bool mShuttingDown;
|
||||
};
|
||||
@@ -497,7 +491,6 @@ DecodePool::NotifyDecodeComplete(Decoder* aDecoder)
|
||||
return;
|
||||
}
|
||||
|
||||
aDecoder->Finish();
|
||||
aDecoder->GetImage()->FinalizeDecoder(aDecoder);
|
||||
}
|
||||
|
||||
|
||||
+26
-75
@@ -10,8 +10,6 @@
|
||||
#include "DecodePool.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsProxyRelease.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
@@ -24,27 +22,30 @@ namespace mozilla {
|
||||
namespace image {
|
||||
|
||||
Decoder::Decoder(RasterImage* aImage)
|
||||
: mImage(aImage)
|
||||
, mProgress(NoProgress)
|
||||
, mImageData(nullptr)
|
||||
: mImageData(nullptr)
|
||||
, mImageDataLength(0)
|
||||
, mColormap(nullptr)
|
||||
, mColormapSize(0)
|
||||
, mImage(aImage)
|
||||
, mProgress(NoProgress)
|
||||
, mFrameCount(0)
|
||||
, mFailCode(NS_OK)
|
||||
, mChunkCount(0)
|
||||
, mFlags(0)
|
||||
, mBytesDecoded(0)
|
||||
, mInitialized(false)
|
||||
, mMetadataDecode(false)
|
||||
, mSendPartialInvalidations(false)
|
||||
, mImageIsTransient(false)
|
||||
, mImageIsLocked(false)
|
||||
, mFirstFrameDecode(false)
|
||||
, mInFrame(false)
|
||||
, mIsAnimated(false)
|
||||
, mDataDone(false)
|
||||
, mDecodeDone(false)
|
||||
, mDataError(false)
|
||||
, mDecodeAborted(false)
|
||||
, mShouldReportError(false)
|
||||
, mImageIsTransient(false)
|
||||
, mImageIsLocked(false)
|
||||
, mFrameCount(0)
|
||||
, mFailCode(NS_OK)
|
||||
, mInitialized(false)
|
||||
, mSizeDecode(false)
|
||||
, mInFrame(false)
|
||||
, mIsAnimated(false)
|
||||
{ }
|
||||
|
||||
Decoder::~Decoder()
|
||||
@@ -55,7 +56,7 @@ Decoder::~Decoder()
|
||||
"Destroying Decoder without taking all its invalidations");
|
||||
mInitialized = false;
|
||||
|
||||
if (!NS_IsMainThread()) {
|
||||
if (mImage && !NS_IsMainThread()) {
|
||||
// Dispatch mImage to main thread to prevent it from being destructed by the
|
||||
// decode thread.
|
||||
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
|
||||
@@ -81,6 +82,11 @@ Decoder::Init()
|
||||
// No re-initializing
|
||||
MOZ_ASSERT(!mInitialized, "Can't re-initialize a decoder!");
|
||||
|
||||
// It doesn't make sense to decode anything but the first frame if we can't
|
||||
// store anything in the SurfaceCache, since only the last frame we decode
|
||||
// will be retrievable.
|
||||
MOZ_ASSERT(ShouldUseSurfaceCache() || IsFirstFrameDecode());
|
||||
|
||||
// Implementation-specific initialization
|
||||
InitInternal();
|
||||
|
||||
@@ -169,7 +175,7 @@ Decoder::Write(const char* aBuffer, uint32_t aCount)
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsSizeDecode() && HasSize()) {
|
||||
if (IsMetadataDecode() && HasSize()) {
|
||||
// More data came in since we found the size. We have nothing to do here.
|
||||
return;
|
||||
}
|
||||
@@ -200,7 +206,7 @@ Decoder::CompleteDecode()
|
||||
// early because of low-memory conditions or losing a race with another
|
||||
// decoder, we need to send teardown notifications (and report an error to the
|
||||
// console later).
|
||||
if (!IsSizeDecode() && !mDecodeDone && !WasAborted()) {
|
||||
if (!IsMetadataDecode() && !mDecodeDone && !WasAborted()) {
|
||||
mShouldReportError = true;
|
||||
|
||||
// If we only have a data error, we're usable if we have at least one
|
||||
@@ -218,52 +224,14 @@ Decoder::CompleteDecode()
|
||||
PostDecodeDone();
|
||||
} else {
|
||||
// We're not usable. Record some final progress indicating the error.
|
||||
if (!IsSizeDecode()) {
|
||||
if (!IsMetadataDecode()) {
|
||||
mProgress |= FLAG_DECODE_COMPLETE;
|
||||
}
|
||||
mProgress |= FLAG_HAS_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Decoder::Finish()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
MOZ_ASSERT(HasError() || !mInFrame, "Finishing while we're still in a frame");
|
||||
|
||||
// If we detected an error in CompleteDecode(), log it to the error console.
|
||||
if (mShouldReportError && !WasAborted()) {
|
||||
nsCOMPtr<nsIConsoleService> consoleService =
|
||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIScriptError> errorObject =
|
||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
|
||||
|
||||
if (consoleService && errorObject && !HasDecoderError()) {
|
||||
nsAutoString msg(NS_LITERAL_STRING("Image corrupt or truncated: ") +
|
||||
NS_ConvertUTF8toUTF16(mImage->GetURIString()));
|
||||
|
||||
if (NS_SUCCEEDED(errorObject->InitWithWindowID(
|
||||
msg,
|
||||
NS_ConvertUTF8toUTF16(mImage->GetURIString()),
|
||||
EmptyString(), 0, 0, nsIScriptError::errorFlag,
|
||||
"Image", mImage->InnerWindowID()
|
||||
))) {
|
||||
consoleService->LogMessage(errorObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set image metadata before calling DecodingComplete, because
|
||||
// DecodingComplete calls Optimize().
|
||||
mImageMetadata.SetOnImage(mImage);
|
||||
|
||||
if (HasSize()) {
|
||||
SetSizeOnImage();
|
||||
}
|
||||
|
||||
if (mDecodeDone && !IsSizeDecode()) {
|
||||
if (mDecodeDone && !IsMetadataDecode()) {
|
||||
MOZ_ASSERT(HasError() || mCurrentFrame, "Should have an error or a frame");
|
||||
|
||||
// If this image wasn't animated and isn't a transient image, mark its frame
|
||||
@@ -272,8 +240,6 @@ Decoder::Finish()
|
||||
if (!mIsAnimated && !mImageIsTransient && mCurrentFrame) {
|
||||
mCurrentFrame->SetOptimizable();
|
||||
}
|
||||
|
||||
mImage->OnDecodingComplete(mIsAnimated);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,26 +365,11 @@ Decoder::AllocateFrameInternal(uint32_t aFrameNum,
|
||||
return ref;
|
||||
}
|
||||
|
||||
void
|
||||
Decoder::SetSizeOnImage()
|
||||
{
|
||||
MOZ_ASSERT(mImageMetadata.HasSize(), "Should have size");
|
||||
MOZ_ASSERT(mImageMetadata.HasOrientation(), "Should have orientation");
|
||||
|
||||
nsresult rv = mImage->SetSize(mImageMetadata.GetWidth(),
|
||||
mImageMetadata.GetHeight(),
|
||||
mImageMetadata.GetOrientation());
|
||||
if (NS_FAILED(rv)) {
|
||||
PostResizeError();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Hook stubs. Override these as necessary in decoder implementations.
|
||||
*/
|
||||
|
||||
void Decoder::InitInternal() { }
|
||||
void Decoder::WriteInternal(const char* aBuffer, uint32_t aCount) { }
|
||||
void Decoder::FinishInternal() { }
|
||||
void Decoder::FinishWithErrorInternal() { }
|
||||
|
||||
@@ -472,7 +423,7 @@ Decoder::PostFrameStop(Opacity aFrameOpacity /* = Opacity::TRANSPARENT */,
|
||||
BlendMethod aBlendMethod /* = BlendMethod::OVER */)
|
||||
{
|
||||
// We should be mid-frame
|
||||
MOZ_ASSERT(!IsSizeDecode(), "Stopping frame during a size decode");
|
||||
MOZ_ASSERT(!IsMetadataDecode(), "Stopping frame during metadata decode");
|
||||
MOZ_ASSERT(mInFrame, "Stopping frame when we didn't start one");
|
||||
MOZ_ASSERT(mCurrentFrame, "Stopping frame when we don't have one");
|
||||
|
||||
@@ -511,7 +462,7 @@ Decoder::PostInvalidation(const nsIntRect& aRect,
|
||||
void
|
||||
Decoder::PostDecodeDone(int32_t aLoopCount /* = 0 */)
|
||||
{
|
||||
MOZ_ASSERT(!IsSizeDecode(), "Can't be done with decoding with size decode!");
|
||||
MOZ_ASSERT(!IsMetadataDecode(), "Done with decoding in metadata decode");
|
||||
MOZ_ASSERT(!mInFrame, "Can't be done decoding if we're mid-frame!");
|
||||
MOZ_ASSERT(!mDecodeDone, "Decode already done!");
|
||||
mDecodeDone = true;
|
||||
|
||||
+74
-43
@@ -42,12 +42,6 @@ public:
|
||||
*/
|
||||
nsresult Decode();
|
||||
|
||||
/**
|
||||
* Cleans up the decoder's state and notifies our image about success or
|
||||
* failure. May only be called on the main thread.
|
||||
*/
|
||||
void Finish();
|
||||
|
||||
/**
|
||||
* Given a maximum number of bytes we're willing to decode, @aByteLimit,
|
||||
* returns true if we should attempt to run this decoder synchronously.
|
||||
@@ -97,15 +91,17 @@ public:
|
||||
* State.
|
||||
*/
|
||||
|
||||
// If we're doing a "size decode", we more or less pass through the image
|
||||
// data, stopping only to scoop out the image dimensions. A size decode
|
||||
// must be enabled by SetSizeDecode() _before_calling Init().
|
||||
bool IsSizeDecode() { return mSizeDecode; }
|
||||
void SetSizeDecode(bool aSizeDecode)
|
||||
/**
|
||||
* If we're doing a metadata decode, we only decode the image's headers, which
|
||||
* is enough to determine the image's intrinsic size. A metadata decode is
|
||||
* enabled by calling SetMetadataDecode() *before* calling Init().
|
||||
*/
|
||||
void SetMetadataDecode(bool aMetadataDecode)
|
||||
{
|
||||
MOZ_ASSERT(!mInitialized, "Shouldn't be initialized yet");
|
||||
mSizeDecode = aSizeDecode;
|
||||
mMetadataDecode = aMetadataDecode;
|
||||
}
|
||||
bool IsMetadataDecode() const { return mMetadataDecode; }
|
||||
|
||||
/**
|
||||
* If this decoder supports downscale-during-decode, sets the target size that
|
||||
@@ -125,6 +121,22 @@ public:
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the requested sample size for this decoder. Used to implement the
|
||||
* -moz-sample-size media fragment.
|
||||
*
|
||||
* XXX(seth): Support for -moz-sample-size will be removed in bug 1120056.
|
||||
*/
|
||||
virtual void SetSampleSize(int aSampleSize) { }
|
||||
|
||||
/**
|
||||
* Set the requested resolution for this decoder. Used to implement the
|
||||
* -moz-resolution media fragment.
|
||||
*
|
||||
* XXX(seth): Support for -moz-resolution will be removed in bug 1118926.
|
||||
*/
|
||||
virtual void SetResolution(const gfx::IntSize& aResolution) { }
|
||||
|
||||
/**
|
||||
* Set whether should send partial invalidations.
|
||||
*
|
||||
@@ -182,6 +194,18 @@ public:
|
||||
|
||||
bool ImageIsLocked() const { return mImageIsLocked; }
|
||||
|
||||
|
||||
/**
|
||||
* Set whether we should stop decoding after the first frame.
|
||||
*/
|
||||
void SetIsFirstFrameDecode()
|
||||
{
|
||||
MOZ_ASSERT(!mInitialized, "Shouldn't be initialized yet");
|
||||
mFirstFrameDecode = true;
|
||||
}
|
||||
|
||||
bool IsFirstFrameDecode() const { return mFirstFrameDecode; }
|
||||
|
||||
size_t BytesDecoded() const { return mBytesDecoded; }
|
||||
|
||||
// The amount of time we've spent inside Write() so far for this decoder.
|
||||
@@ -200,18 +224,31 @@ public:
|
||||
return mInFrame ? mFrameCount - 1 : mFrameCount;
|
||||
}
|
||||
|
||||
// Did we discover that the image we're decoding is animated?
|
||||
bool HasAnimation() const { return mIsAnimated; }
|
||||
|
||||
// Error tracking
|
||||
bool HasError() const { return HasDataError() || HasDecoderError(); }
|
||||
bool HasDataError() const { return mDataError; }
|
||||
bool HasDecoderError() const { return NS_FAILED(mFailCode); }
|
||||
bool ShouldReportError() const { return mShouldReportError; }
|
||||
nsresult GetDecoderError() const { return mFailCode; }
|
||||
void PostResizeError() { PostDataError(); }
|
||||
|
||||
/// Did we finish decoding enough that calling Decode() again would be useless?
|
||||
bool GetDecodeDone() const
|
||||
{
|
||||
return mDecodeDone || (mSizeDecode && HasSize()) || HasError() || mDataDone;
|
||||
return mDecodeDone || (mMetadataDecode && HasSize()) ||
|
||||
HasError() || mDataDone;
|
||||
}
|
||||
|
||||
/// Did we finish decoding enough to set |RasterImage::mHasBeenDecoded|?
|
||||
// XXX(seth): This will be removed in bug 1187401.
|
||||
bool GetDecodeTotallyDone() const { return mDecodeDone && !IsMetadataDecode(); }
|
||||
|
||||
/// Are we in the middle of a frame right now? Used for assertions only.
|
||||
bool InFrame() const { return mInFrame; }
|
||||
|
||||
/**
|
||||
* Returns true if this decoder was aborted.
|
||||
*
|
||||
@@ -234,7 +271,6 @@ public:
|
||||
uint32_t GetDecodeFlags() const { return DecodeFlags(mFlags); }
|
||||
|
||||
bool HasSize() const { return mImageMetadata.HasSize(); }
|
||||
void SetSizeOnImage();
|
||||
|
||||
nsIntSize GetSize() const
|
||||
{
|
||||
@@ -251,9 +287,6 @@ public:
|
||||
*/
|
||||
RasterImage* GetImage() const { MOZ_ASSERT(mImage); return mImage.get(); }
|
||||
|
||||
// XXX(seth): This should be removed once we can optimize imgFrame objects
|
||||
// off-main-thread. It only exists to support the code in Finish() for
|
||||
// nsICODecoder.
|
||||
RawAccessFrameRef GetCurrentFrameRef()
|
||||
{
|
||||
return mCurrentFrame ? mCurrentFrame->RawAccessRef()
|
||||
@@ -282,7 +315,7 @@ protected:
|
||||
* only these methods.
|
||||
*/
|
||||
virtual void InitInternal();
|
||||
virtual void WriteInternal(const char* aBuffer, uint32_t aCount);
|
||||
virtual void WriteInternal(const char* aBuffer, uint32_t aCount) = 0;
|
||||
virtual void FinishInternal();
|
||||
virtual void FinishWithErrorInternal();
|
||||
|
||||
@@ -386,10 +419,13 @@ protected:
|
||||
uint8_t aPaletteDepth,
|
||||
imgFrame* aPreviousFrame);
|
||||
|
||||
/*
|
||||
* Member variables.
|
||||
*
|
||||
*/
|
||||
protected:
|
||||
uint8_t* mImageData; // Pointer to image data in either Cairo or 8bit format
|
||||
uint32_t mImageDataLength;
|
||||
uint32_t* mColormap; // Current colormap to be used in Cairo format
|
||||
uint32_t mColormapSize;
|
||||
|
||||
private:
|
||||
nsRefPtr<RasterImage> mImage;
|
||||
Maybe<SourceBufferIterator> mIterator;
|
||||
RawAccessFrameRef mCurrentFrame;
|
||||
@@ -397,10 +433,9 @@ protected:
|
||||
nsIntRect mInvalidRect; // Tracks an invalidation region in the current frame.
|
||||
Progress mProgress;
|
||||
|
||||
uint8_t* mImageData; // Pointer to image data in either Cairo or 8bit format
|
||||
uint32_t mImageDataLength;
|
||||
uint32_t* mColormap; // Current colormap to be used in Cairo format
|
||||
uint32_t mColormapSize;
|
||||
uint32_t mFrameCount; // Number of frames, including anything in-progress
|
||||
|
||||
nsresult mFailCode;
|
||||
|
||||
// Telemetry data for this decoder.
|
||||
TimeDuration mDecodeTime;
|
||||
@@ -408,24 +443,20 @@ protected:
|
||||
|
||||
uint32_t mFlags;
|
||||
size_t mBytesDecoded;
|
||||
bool mSendPartialInvalidations;
|
||||
bool mDataDone;
|
||||
bool mDecodeDone;
|
||||
bool mDataError;
|
||||
bool mDecodeAborted;
|
||||
bool mShouldReportError;
|
||||
bool mImageIsTransient;
|
||||
bool mImageIsLocked;
|
||||
|
||||
private:
|
||||
uint32_t mFrameCount; // Number of frames, including anything in-progress
|
||||
|
||||
nsresult mFailCode;
|
||||
|
||||
bool mInitialized;
|
||||
bool mSizeDecode;
|
||||
bool mInFrame;
|
||||
bool mIsAnimated;
|
||||
bool mInitialized : 1;
|
||||
bool mMetadataDecode : 1;
|
||||
bool mSendPartialInvalidations : 1;
|
||||
bool mImageIsTransient : 1;
|
||||
bool mImageIsLocked : 1;
|
||||
bool mFirstFrameDecode : 1;
|
||||
bool mInFrame : 1;
|
||||
bool mIsAnimated : 1;
|
||||
bool mDataDone : 1;
|
||||
bool mDecodeDone : 1;
|
||||
bool mDataError : 1;
|
||||
bool mDecodeAborted : 1;
|
||||
bool mShouldReportError : 1;
|
||||
};
|
||||
|
||||
} // namespace image
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DecoderFactory.h"
|
||||
|
||||
#include "nsMimeTypes.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "Decoder.h"
|
||||
#include "nsPNGDecoder.h"
|
||||
#include "nsGIFDecoder2.h"
|
||||
#include "nsJPEGDecoder.h"
|
||||
#ifdef MOZ_JXR
|
||||
#include "nsJXRDecoder.h"
|
||||
#endif
|
||||
#include "nsBMPDecoder.h"
|
||||
#include "nsICODecoder.h"
|
||||
#include "nsIconDecoder.h"
|
||||
#include "nsWEBPDecoder.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
using namespace gfx;
|
||||
|
||||
namespace image {
|
||||
|
||||
/* static */ DecoderType
|
||||
DecoderFactory::GetDecoderType(const char* aMimeType)
|
||||
{
|
||||
// By default we don't know.
|
||||
DecoderType type = DecoderType::UNKNOWN;
|
||||
|
||||
// PNG
|
||||
if (!strcmp(aMimeType, IMAGE_PNG)) {
|
||||
type = DecoderType::PNG;
|
||||
} else if (!strcmp(aMimeType, IMAGE_X_PNG)) {
|
||||
type = DecoderType::PNG;
|
||||
|
||||
// GIF
|
||||
} else if (!strcmp(aMimeType, IMAGE_GIF)) {
|
||||
type = DecoderType::GIF;
|
||||
|
||||
// JPEG
|
||||
} else if (!strcmp(aMimeType, IMAGE_JPEG)) {
|
||||
type = DecoderType::JPEG;
|
||||
} else if (!strcmp(aMimeType, IMAGE_PJPEG)) {
|
||||
type = DecoderType::JPEG;
|
||||
} else if (!strcmp(aMimeType, IMAGE_JPG)) {
|
||||
type = DecoderType::JPEG;
|
||||
|
||||
// BMP
|
||||
} else if (!strcmp(aMimeType, IMAGE_BMP)) {
|
||||
type = DecoderType::BMP;
|
||||
} else if (!strcmp(aMimeType, IMAGE_BMP_MS)) {
|
||||
type = DecoderType::BMP;
|
||||
|
||||
// ICO
|
||||
} else if (!strcmp(aMimeType, IMAGE_ICO)) {
|
||||
type = DecoderType::ICO;
|
||||
} else if (!strcmp(aMimeType, IMAGE_ICO_MS)) {
|
||||
type = DecoderType::ICO;
|
||||
|
||||
// Icon
|
||||
} else if (!strcmp(aMimeType, IMAGE_ICON_MS)) {
|
||||
type = DecoderType::ICON;
|
||||
|
||||
// WebP
|
||||
} else if (!strcmp(aMimeType, IMAGE_WEBP) &&
|
||||
gfxPrefs::ImageWebPEnabled()) {
|
||||
type = DecoderType::WEBP;
|
||||
|
||||
#ifdef MOZ_JXR
|
||||
} else if (!strcmp(aMimeType, IMAGE_JXR) || !strcmp(aMimeType, IMAGE_MS_PHOTO)) {
|
||||
if (gfxPrefs::MediaJXREnabled()) {
|
||||
type = DecoderType::JXR;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<Decoder>
|
||||
DecoderFactory::GetDecoder(DecoderType aType,
|
||||
RasterImage* aImage,
|
||||
bool aIsRedecode)
|
||||
{
|
||||
nsRefPtr<Decoder> decoder;
|
||||
|
||||
switch (aType) {
|
||||
case DecoderType::PNG:
|
||||
decoder = new nsPNGDecoder(aImage);
|
||||
break;
|
||||
case DecoderType::GIF:
|
||||
decoder = new nsGIFDecoder2(aImage);
|
||||
break;
|
||||
case DecoderType::JPEG:
|
||||
// If we have all the data we don't want to waste cpu time doing
|
||||
// a progressive decode.
|
||||
decoder = new nsJPEGDecoder(aImage,
|
||||
aIsRedecode ? Decoder::SEQUENTIAL
|
||||
: Decoder::PROGRESSIVE);
|
||||
break;
|
||||
case DecoderType::BMP:
|
||||
decoder = new nsBMPDecoder(aImage);
|
||||
break;
|
||||
case DecoderType::ICO:
|
||||
decoder = new nsICODecoder(aImage);
|
||||
break;
|
||||
case DecoderType::ICON:
|
||||
decoder = new nsIconDecoder(aImage);
|
||||
break;
|
||||
case DecoderType::WEBP:
|
||||
decoder = new nsWEBPDecoder(aImage);
|
||||
break;
|
||||
#ifdef MOZ_JXR
|
||||
case DecoderType::JXR:
|
||||
decoder = new nsJXRDecoder(aImage, aIsRedecode);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unknown decoder type");
|
||||
}
|
||||
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<Decoder>
|
||||
DecoderFactory::CreateDecoder(DecoderType aType,
|
||||
RasterImage* aImage,
|
||||
SourceBuffer* aSourceBuffer,
|
||||
const Maybe<IntSize>& aTargetSize,
|
||||
uint32_t aFlags,
|
||||
int aSampleSize,
|
||||
const IntSize& aResolution,
|
||||
bool aIsRedecode,
|
||||
bool aImageIsTransient,
|
||||
bool aImageIsLocked)
|
||||
{
|
||||
if (aType == DecoderType::UNKNOWN) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<Decoder> decoder = GetDecoder(aType, aImage, aIsRedecode);
|
||||
MOZ_ASSERT(decoder, "Should have a decoder now");
|
||||
|
||||
// Initialize the decoder.
|
||||
decoder->SetMetadataDecode(false);
|
||||
decoder->SetIterator(aSourceBuffer->Iterator());
|
||||
decoder->SetFlags(aFlags);
|
||||
decoder->SetSampleSize(aSampleSize);
|
||||
decoder->SetResolution(aResolution);
|
||||
decoder->SetSendPartialInvalidations(!aIsRedecode);
|
||||
decoder->SetImageIsTransient(aImageIsTransient);
|
||||
|
||||
if (aImageIsLocked) {
|
||||
decoder->SetImageIsLocked();
|
||||
}
|
||||
|
||||
// Set a target size for downscale-during-decode if applicable.
|
||||
if (aTargetSize) {
|
||||
DebugOnly<nsresult> rv = decoder->SetTargetSize(*aTargetSize);
|
||||
MOZ_ASSERT(nsresult(rv) != NS_ERROR_NOT_AVAILABLE,
|
||||
"We're downscale-during-decode but decoder doesn't support it?");
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv), "Bad downscale-during-decode target size?");
|
||||
}
|
||||
|
||||
decoder->Init();
|
||||
if (NS_FAILED(decoder->GetDecoderError())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<Decoder>
|
||||
DecoderFactory::CreateMetadataDecoder(DecoderType aType,
|
||||
RasterImage* aImage,
|
||||
SourceBuffer* aSourceBuffer,
|
||||
int aSampleSize,
|
||||
const IntSize& aResolution)
|
||||
{
|
||||
if (aType == DecoderType::UNKNOWN) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<Decoder> decoder =
|
||||
GetDecoder(aType, aImage, /* aIsRedecode = */ false);
|
||||
MOZ_ASSERT(decoder, "Should have a decoder now");
|
||||
|
||||
// Initialize the decoder.
|
||||
decoder->SetMetadataDecode(true);
|
||||
decoder->SetIterator(aSourceBuffer->Iterator());
|
||||
decoder->SetSampleSize(aSampleSize);
|
||||
decoder->SetResolution(aResolution);
|
||||
|
||||
decoder->Init();
|
||||
if (NS_FAILED(decoder->GetDecoderError())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<Decoder>
|
||||
DecoderFactory::CreateAnonymousDecoder(DecoderType aType,
|
||||
SourceBuffer* aSourceBuffer,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
if (aType == DecoderType::UNKNOWN) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<Decoder> decoder =
|
||||
GetDecoder(aType, /* aImage = */ nullptr, /* aIsRedecode = */ false);
|
||||
MOZ_ASSERT(decoder, "Should have a decoder now");
|
||||
|
||||
// Initialize the decoder.
|
||||
decoder->SetMetadataDecode(false);
|
||||
decoder->SetIterator(aSourceBuffer->Iterator());
|
||||
decoder->SetFlags(aFlags);
|
||||
decoder->SetImageIsTransient(true);
|
||||
|
||||
// Without an image, the decoder can't store anything in the SurfaceCache, so
|
||||
// callers will only be able to retrieve the most recent frame via
|
||||
// Decoder::GetCurrentFrame(). That means that anonymous decoders should
|
||||
// always be first-frame-only decoders, because nobody ever wants the *last*
|
||||
// frame.
|
||||
decoder->SetIsFirstFrameDecode();
|
||||
|
||||
decoder->Init();
|
||||
if (NS_FAILED(decoder->GetDecoderError())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
} // namespace image
|
||||
} // namespace mozilla
|
||||
@@ -0,0 +1,125 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_image_DecoderFactory_h
|
||||
#define mozilla_image_DecoderFactory_h
|
||||
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsACString;
|
||||
|
||||
namespace mozilla {
|
||||
namespace image {
|
||||
|
||||
class Decoder;
|
||||
class RasterImage;
|
||||
class SourceBuffer;
|
||||
|
||||
enum class DecoderType
|
||||
{
|
||||
PNG,
|
||||
GIF,
|
||||
JPEG,
|
||||
BMP,
|
||||
ICO,
|
||||
ICON,
|
||||
WEBP,
|
||||
JXR,
|
||||
UNKNOWN
|
||||
};
|
||||
|
||||
class DecoderFactory
|
||||
{
|
||||
public:
|
||||
/// @return the type of decoder which is appropriate for @aMimeType.
|
||||
static DecoderType GetDecoderType(const char* aMimeType);
|
||||
|
||||
/**
|
||||
* Creates and initializes a decoder of type @aType. The decoder will send
|
||||
* notifications to @aImage.
|
||||
*
|
||||
* XXX(seth): @aIsRedecode, @aImageIsTransient, and @aImageIsLocked should
|
||||
* really be part of @aFlags. This requires changes to the way that decoder
|
||||
* flags work, though. See bug 1185800.
|
||||
*
|
||||
* @param aType Which type of decoder to create - JPEG, PNG, etc.
|
||||
* @param aImage The image will own the decoder and which should receive
|
||||
* notifications as decoding progresses.
|
||||
* @param aSourceBuffer The SourceBuffer which the decoder will read its data
|
||||
* from.
|
||||
* @param aTargetSize If not Nothing(), the target size which the image should
|
||||
* be scaled to during decoding. It's an error to specify
|
||||
* a target size for a decoder type which doesn't support
|
||||
* downscale-during-decode.
|
||||
* @param aFlags Flags specifying what type of output the decoder should
|
||||
* produce; see GetDecodeFlags() in RasterImage.h.
|
||||
* @param aSampleSize The sample size requested using #-moz-samplesize (or 0
|
||||
* if none).
|
||||
* @param aResolution The resolution requested using #-moz-resolution (or an
|
||||
* empty rect if none).
|
||||
* @param aIsRedecode Specify 'true' if this image has been decoded before.
|
||||
* @param aImageIsTransient Specify 'true' if this image is transient.
|
||||
* @param aImageIsLocked Specify 'true' if this image is locked for the
|
||||
* lifetime of this decoder, and should be unlocked
|
||||
* when the decoder finishes.
|
||||
*/
|
||||
static already_AddRefed<Decoder>
|
||||
CreateDecoder(DecoderType aType,
|
||||
RasterImage* aImage,
|
||||
SourceBuffer* aSourceBuffer,
|
||||
const Maybe<gfx::IntSize>& aTargetSize,
|
||||
uint32_t aFlags,
|
||||
int aSampleSize,
|
||||
const gfx::IntSize& aResolution,
|
||||
bool aIsRedecode,
|
||||
bool aImageIsTransient,
|
||||
bool aImageIsLocked);
|
||||
|
||||
/**
|
||||
* Creates and initializes a metadata decoder of type @aType. This decoder
|
||||
* will only decode the image's header, extracting metadata like the size of
|
||||
* the image. No actual image data will be decoded and no surfaces will be
|
||||
* allocated. The decoder will send notifications to @aImage.
|
||||
*
|
||||
* @param aType Which type of decoder to create - JPEG, PNG, etc.
|
||||
* @param aImage The image will own the decoder and which should receive
|
||||
* notifications as decoding progresses.
|
||||
* @param aSourceBuffer The SourceBuffer which the decoder will read its data
|
||||
* from.
|
||||
* @param aSampleSize The sample size requested using #-moz-samplesize (or 0
|
||||
* if none).
|
||||
* @param aResolution The resolution requested using #-moz-resolution (or an
|
||||
* empty rect if none).
|
||||
*/
|
||||
static already_AddRefed<Decoder>
|
||||
CreateMetadataDecoder(DecoderType aType,
|
||||
RasterImage* aImage,
|
||||
SourceBuffer* aSourceBuffer,
|
||||
int aSampleSize,
|
||||
const gfx::IntSize& aResolution);
|
||||
|
||||
static already_AddRefed<Decoder>
|
||||
CreateAnonymousDecoder(DecoderType aType,
|
||||
SourceBuffer* aSourceBuffer,
|
||||
uint32_t aFlags);
|
||||
|
||||
private:
|
||||
virtual ~DecoderFactory() = 0;
|
||||
|
||||
/**
|
||||
* An internal method which allocates a new decoder of the requested @aType.
|
||||
*/
|
||||
static already_AddRefed<Decoder> GetDecoder(DecoderType aType,
|
||||
RasterImage* aImage,
|
||||
bool aIsRedecode);
|
||||
};
|
||||
|
||||
} // namespace image
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_image_DecoderFactory_h
|
||||
@@ -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/. */
|
||||
|
||||
#include "nsMimeTypes.h"
|
||||
|
||||
#include "Image.h"
|
||||
#include "nsRefreshDriver.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
@@ -69,65 +67,6 @@ ImageResource::~ImageResource()
|
||||
mProgressTracker->ResetImage();
|
||||
}
|
||||
|
||||
// Translates a mimetype into a concrete decoder
|
||||
Image::eDecoderType
|
||||
Image::GetDecoderType(const char* aMimeType)
|
||||
{
|
||||
// By default we don't know
|
||||
eDecoderType rv = eDecoderType_unknown;
|
||||
|
||||
// PNG
|
||||
if (!strcmp(aMimeType, IMAGE_PNG)) {
|
||||
rv = eDecoderType_png;
|
||||
} else if (!strcmp(aMimeType, IMAGE_X_PNG)) {
|
||||
rv = eDecoderType_png;
|
||||
|
||||
// GIF
|
||||
} else if (!strcmp(aMimeType, IMAGE_GIF)) {
|
||||
rv = eDecoderType_gif;
|
||||
|
||||
// JPEG
|
||||
} else if (!strcmp(aMimeType, IMAGE_JPEG)) {
|
||||
rv = eDecoderType_jpeg;
|
||||
} else if (!strcmp(aMimeType, IMAGE_PJPEG)) {
|
||||
rv = eDecoderType_jpeg;
|
||||
} else if (!strcmp(aMimeType, IMAGE_JPG)) {
|
||||
rv = eDecoderType_jpeg;
|
||||
|
||||
#ifdef MOZ_JXR
|
||||
// JXR (JPEG XR)
|
||||
} else if (
|
||||
!strcmp(aMimeType, IMAGE_JXR) || !strcmp(aMimeType, IMAGE_MS_PHOTO)
|
||||
) {
|
||||
if (gfxPrefs::MediaJXREnabled()) {
|
||||
rv = eDecoderType_jxr;
|
||||
}
|
||||
#endif
|
||||
|
||||
// WEBP
|
||||
} else if (!strcmp(aMimeType, IMAGE_WEBP)) {
|
||||
rv = eDecoderType_webp;
|
||||
|
||||
// BMP
|
||||
} else if (!strcmp(aMimeType, IMAGE_BMP)) {
|
||||
rv = eDecoderType_bmp;
|
||||
} else if (!strcmp(aMimeType, IMAGE_BMP_MS)) {
|
||||
rv = eDecoderType_bmp;
|
||||
|
||||
// ICO
|
||||
} else if (!strcmp(aMimeType, IMAGE_ICO)) {
|
||||
rv = eDecoderType_ico;
|
||||
} else if (!strcmp(aMimeType, IMAGE_ICO_MS)) {
|
||||
rv = eDecoderType_ico;
|
||||
|
||||
// Icon
|
||||
} else if (!strcmp(aMimeType, IMAGE_ICON_MS)) {
|
||||
rv = eDecoderType_icon;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
ImageResource::IncrementAnimationConsumers()
|
||||
{
|
||||
|
||||
@@ -129,24 +129,6 @@ private:
|
||||
class Image : public imgIContainer
|
||||
{
|
||||
public:
|
||||
// Mimetype translation
|
||||
enum eDecoderType {
|
||||
eDecoderType_png = 0,
|
||||
eDecoderType_gif = 1,
|
||||
eDecoderType_jpeg = 2,
|
||||
eDecoderType_bmp = 3,
|
||||
eDecoderType_ico = 4,
|
||||
eDecoderType_icon = 5,
|
||||
eDecoderType_webp = 6,
|
||||
#ifdef MOZ_JXR
|
||||
eDecoderType_jxr = 7,
|
||||
eDecoderType_unknown = 8
|
||||
#else
|
||||
eDecoderType_unknown = 7
|
||||
#endif
|
||||
};
|
||||
static eDecoderType GetDecoderType(const char* aMimeType);
|
||||
|
||||
/**
|
||||
* Flags for Image initialization.
|
||||
*
|
||||
|
||||
+23
-23
@@ -221,6 +221,29 @@ ImageFactory::CreateRasterImage(nsIRequest* aRequest,
|
||||
aProgressTracker->SetImage(newImage);
|
||||
newImage->SetProgressTracker(aProgressTracker);
|
||||
|
||||
nsAutoCString ref;
|
||||
aURI->GetRef(ref);
|
||||
net::nsMediaFragmentURIParser parser(ref);
|
||||
if (parser.HasResolution()) {
|
||||
newImage->SetRequestedResolution(parser.GetResolution());
|
||||
}
|
||||
|
||||
if (parser.HasSampleSize()) {
|
||||
/* Get our principal */
|
||||
nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
if (chan) {
|
||||
nsContentUtils::GetSecurityManager()
|
||||
->GetChannelResultPrincipal(chan, getter_AddRefs(principal));
|
||||
}
|
||||
|
||||
if ((principal &&
|
||||
principal->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED) ||
|
||||
gfxPrefs::ImageMozSampleSizeEnabled()) {
|
||||
newImage->SetRequestedSampleSize(parser.GetSampleSize());
|
||||
}
|
||||
}
|
||||
|
||||
rv = newImage->Init(aMimeType.get(), aImageFlags);
|
||||
NS_ENSURE_SUCCESS(rv, BadImage(newImage));
|
||||
|
||||
@@ -245,29 +268,6 @@ ImageFactory::CreateRasterImage(nsIRequest* aRequest,
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoCString ref;
|
||||
aURI->GetRef(ref);
|
||||
net::nsMediaFragmentURIParser parser(ref);
|
||||
if (parser.HasResolution()) {
|
||||
newImage->SetRequestedResolution(parser.GetResolution());
|
||||
}
|
||||
|
||||
if (parser.HasSampleSize()) {
|
||||
/* Get our principal */
|
||||
nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
if (chan) {
|
||||
nsContentUtils::GetSecurityManager()
|
||||
->GetChannelResultPrincipal(chan, getter_AddRefs(principal));
|
||||
}
|
||||
|
||||
if ((principal &&
|
||||
principal->GetAppStatus() == nsIPrincipal::APP_STATUS_CERTIFIED) ||
|
||||
gfxPrefs::ImageMozSampleSizeEnabled()) {
|
||||
newImage->SetRequestedSampleSize(parser.GetSampleSize());
|
||||
}
|
||||
}
|
||||
|
||||
return newImage.forget();
|
||||
}
|
||||
|
||||
|
||||
+14
-5
@@ -14,9 +14,11 @@
|
||||
namespace mozilla {
|
||||
namespace image {
|
||||
|
||||
void
|
||||
ImageMetadata::SetOnImage(RasterImage* image)
|
||||
nsresult
|
||||
ImageMetadata::SetOnImage(RasterImage* aImage)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mHotspotX != -1 && mHotspotY != -1) {
|
||||
nsCOMPtr<nsISupportsPRUint32> intwrapx =
|
||||
do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID);
|
||||
@@ -24,11 +26,18 @@ ImageMetadata::SetOnImage(RasterImage* image)
|
||||
do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID);
|
||||
intwrapx->SetData(mHotspotX);
|
||||
intwrapy->SetData(mHotspotY);
|
||||
image->Set("hotspotX", intwrapx);
|
||||
image->Set("hotspotY", intwrapy);
|
||||
aImage->Set("hotspotX", intwrapx);
|
||||
aImage->Set("hotspotY", intwrapy);
|
||||
}
|
||||
|
||||
image->SetLoopCount(mLoopCount);
|
||||
aImage->SetLoopCount(mLoopCount);
|
||||
|
||||
if (HasSize()) {
|
||||
MOZ_ASSERT(HasOrientation(), "Should have orientation");
|
||||
rv = aImage->SetSize(GetWidth(), GetHeight(), GetOrientation());
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
} // namespace image
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
{ }
|
||||
|
||||
// Set the metadata this object represents on an image.
|
||||
void SetOnImage(RasterImage* image);
|
||||
nsresult SetOnImage(RasterImage* aImage);
|
||||
|
||||
void SetHotspot(uint16_t hotspotx, uint16_t hotspoty)
|
||||
{
|
||||
|
||||
+76
-3
@@ -4,14 +4,22 @@
|
||||
* 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 "imgIContainer.h"
|
||||
#include "ImageOps.h"
|
||||
|
||||
#include "ClippedImage.h"
|
||||
#include "DecodePool.h"
|
||||
#include "Decoder.h"
|
||||
#include "DecoderFactory.h"
|
||||
#include "DynamicImage.h"
|
||||
#include "FrozenImage.h"
|
||||
#include "OrientedImage.h"
|
||||
#include "Image.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "OrientedImage.h"
|
||||
#include "SourceBuffer.h"
|
||||
|
||||
#include "ImageOps.h"
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
namespace mozilla {
|
||||
namespace image {
|
||||
@@ -68,5 +76,70 @@ ImageOps::CreateFromDrawable(gfxDrawable* aDrawable)
|
||||
return drawableImage.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<gfx::SourceSurface>
|
||||
ImageOps::DecodeToSurface(nsIInputStream* aInputStream,
|
||||
const nsACString& aMimeType,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
MOZ_ASSERT(aInputStream);
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// Prepare the input stream.
|
||||
nsCOMPtr<nsIInputStream> inputStream = aInputStream;
|
||||
if (!NS_InputStreamIsBuffered(aInputStream)) {
|
||||
nsCOMPtr<nsIInputStream> bufStream;
|
||||
rv = NS_NewBufferedInputStream(getter_AddRefs(bufStream),
|
||||
aInputStream, 1024);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
inputStream = bufStream;
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out how much data we've been passed.
|
||||
uint64_t length;
|
||||
rv = inputStream->Available(&length);
|
||||
if (NS_FAILED(rv) || length > UINT32_MAX) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Write the data into a SourceBuffer.
|
||||
nsRefPtr<SourceBuffer> sourceBuffer = new SourceBuffer();
|
||||
sourceBuffer->ExpectLength(length);
|
||||
rv = sourceBuffer->AppendFromInputStream(inputStream, length);
|
||||
if (NS_FAILED(rv)) {
|
||||
return nullptr;
|
||||
}
|
||||
sourceBuffer->Complete(NS_OK);
|
||||
|
||||
// Create a decoder.
|
||||
DecoderType decoderType =
|
||||
DecoderFactory::GetDecoderType(PromiseFlatCString(aMimeType).get());
|
||||
nsRefPtr<Decoder> decoder =
|
||||
DecoderFactory::CreateAnonymousDecoder(decoderType, sourceBuffer, aFlags);
|
||||
if (!decoder) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Run the decoder synchronously.
|
||||
decoder->Decode();
|
||||
if (!decoder->GetDecodeDone() || decoder->HasError()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Pull out the surface.
|
||||
RawAccessFrameRef frame = decoder->GetCurrentFrameRef();
|
||||
if (!frame) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<SourceSurface> surface = frame->GetSurface();
|
||||
if (!surface) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return surface.forget();
|
||||
}
|
||||
|
||||
} // namespace image
|
||||
} // namespace mozilla
|
||||
|
||||
@@ -12,8 +12,14 @@
|
||||
|
||||
class gfxDrawable;
|
||||
class imgIContainer;
|
||||
class nsIInputStream;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace gfx {
|
||||
class SourceSurface;
|
||||
}
|
||||
|
||||
namespace image {
|
||||
|
||||
class Image;
|
||||
@@ -61,6 +67,23 @@ public:
|
||||
static already_AddRefed<imgIContainer>
|
||||
CreateFromDrawable(gfxDrawable* aDrawable);
|
||||
|
||||
/**
|
||||
* Decodes an image from an nsIInputStream directly into a SourceSurface,
|
||||
* without ever creating an Image or imgIContainer (which are mostly
|
||||
* main-thread-only). That means that this function may be called
|
||||
* off-main-thread.
|
||||
*
|
||||
* @param aInputStream An input stream containing an encoded image.
|
||||
* @param aMimeType The MIME type of the image.
|
||||
* @param aFlags Flags of the imgIContainer::FLAG_DECODE_* variety.
|
||||
* @return A SourceSurface containing the first frame of the image at its
|
||||
* intrinsic size, or nullptr if the image cannot be decoded.
|
||||
*/
|
||||
static already_AddRefed<gfx::SourceSurface>
|
||||
DecodeToSurface(nsIInputStream* aInputStream,
|
||||
const nsACString& aMimeType,
|
||||
uint32_t aFlags);
|
||||
|
||||
private:
|
||||
// This is a static utility class, so disallow instantiation.
|
||||
virtual ~ImageOps() = 0;
|
||||
|
||||
@@ -47,6 +47,23 @@ public:
|
||||
/// A weak pointer to the URI spec for this ImageURL. For logging only.
|
||||
const char* Spec() const { return mSpec.get(); }
|
||||
|
||||
enum TruncatedSpecStatus {
|
||||
FitsInto1k,
|
||||
TruncatedTo1k
|
||||
};
|
||||
TruncatedSpecStatus GetSpecTruncatedTo1k(nsACString& result)
|
||||
{
|
||||
static const size_t sMaxTruncatedLength = 1024;
|
||||
|
||||
if (sMaxTruncatedLength >= mSpec.Length()) {
|
||||
result = mSpec;
|
||||
return FitsInto1k;
|
||||
}
|
||||
|
||||
result = Substring(mSpec, 0, sMaxTruncatedLength);
|
||||
return TruncatedTo1k;
|
||||
}
|
||||
|
||||
nsresult GetScheme(nsACString& result)
|
||||
{
|
||||
result = mScheme;
|
||||
|
||||
+217
-286
@@ -21,6 +21,9 @@
|
||||
#include "ImageRegion.h"
|
||||
#include "Layers.h"
|
||||
#include "LookupResult.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "SourceBuffer.h"
|
||||
#include "SurfaceCache.h"
|
||||
@@ -47,7 +50,6 @@
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include <stdint.h>
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/gfx/Scale.h"
|
||||
@@ -235,7 +237,7 @@ RasterImage::RasterImage(ImageURL* aURI /* = nullptr */) :
|
||||
mAnimationFinished(false),
|
||||
mWantFullDecode(false)
|
||||
{
|
||||
Telemetry::GetHistogramById(Telemetry::IMAGE_DECODE_COUNT)->Add(0);
|
||||
//Telemetry::GetHistogramById(Telemetry::IMAGE_DECODE_COUNT)->Add(0);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
@@ -286,8 +288,8 @@ RasterImage::Init(const char* aMimeType,
|
||||
// Use the MIME type to select a decoder type, and make sure there *is* a
|
||||
// decoder for this MIME type.
|
||||
NS_ENSURE_ARG_POINTER(aMimeType);
|
||||
mDecoderType = GetDecoderType(aMimeType);
|
||||
if (mDecoderType == eDecoderType_unknown) {
|
||||
mDecoderType = DecoderFactory::GetDecoderType(aMimeType);
|
||||
if (mDecoderType == DecoderType::UNKNOWN) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
@@ -298,8 +300,8 @@ RasterImage::Init(const char* aMimeType,
|
||||
}
|
||||
|
||||
if (!mSyncLoad) {
|
||||
// Create an async size decoder and verify that we succeed in doing so.
|
||||
nsresult rv = Decode(Nothing(), DECODE_FLAGS_DEFAULT);
|
||||
// Create an async metadata decoder and verify we succeed in doing so.
|
||||
nsresult rv = DecodeMetadata(DECODE_FLAGS_DEFAULT);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@@ -349,7 +351,6 @@ RasterImage::RequestRefresh(const TimeStamp& aTime)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* readonly attribute int32_t width; */
|
||||
NS_IMETHODIMP
|
||||
RasterImage::GetWidth(int32_t* aWidth)
|
||||
{
|
||||
@@ -365,7 +366,6 @@ RasterImage::GetWidth(int32_t* aWidth)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* readonly attribute int32_t height; */
|
||||
NS_IMETHODIMP
|
||||
RasterImage::GetHeight(int32_t* aHeight)
|
||||
{
|
||||
@@ -381,7 +381,6 @@ RasterImage::GetHeight(int32_t* aHeight)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* [noscript] readonly attribute nsSize intrinsicSize; */
|
||||
NS_IMETHODIMP
|
||||
RasterImage::GetIntrinsicSize(nsSize* aSize)
|
||||
{
|
||||
@@ -395,7 +394,6 @@ RasterImage::GetIntrinsicSize(nsSize* aSize)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* [noscript] readonly attribute nsSize intrinsicRatio; */
|
||||
NS_IMETHODIMP
|
||||
RasterImage::GetIntrinsicRatio(nsSize* aRatio)
|
||||
{
|
||||
@@ -414,7 +412,6 @@ RasterImage::GetOrientation()
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* unsigned short GetType(); */
|
||||
NS_IMETHODIMP
|
||||
RasterImage::GetType(uint16_t* aType)
|
||||
{
|
||||
@@ -492,7 +489,7 @@ RasterImage::LookupFrame(uint32_t aFrameNum,
|
||||
// yet.) Trigger decoding so it'll be available next time.
|
||||
MOZ_ASSERT(!mAnim, "Animated frames should be locked");
|
||||
|
||||
Decode(Some(requestedSize), aFlags);
|
||||
Decode(requestedSize, aFlags);
|
||||
|
||||
// If we can sync decode, we should already have the frame.
|
||||
if (aFlags & FLAG_SYNC_DECODE) {
|
||||
@@ -578,7 +575,6 @@ RasterImage::OnSurfaceDiscarded()
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* readonly attribute boolean animated; */
|
||||
NS_IMETHODIMP
|
||||
RasterImage::GetAnimated(bool* aAnimated)
|
||||
{
|
||||
@@ -607,7 +603,6 @@ RasterImage::GetAnimated(bool* aAnimated)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* [notxpcom] int32_t getFirstFrameDelay (); */
|
||||
NS_IMETHODIMP_(int32_t)
|
||||
RasterImage::GetFirstFrameDelay()
|
||||
{
|
||||
@@ -985,42 +980,6 @@ RasterImage::SetSize(int32_t aWidth, int32_t aHeight, Orientation aOrientation)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
RasterImage::OnDecodingComplete(bool aIsAnimated)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mError) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Flag that we've been decoded before.
|
||||
mHasBeenDecoded = true;
|
||||
|
||||
if (aIsAnimated) {
|
||||
if (mAnim) {
|
||||
mAnim->SetDoneDecoding(true);
|
||||
} else {
|
||||
// The OnAddedFrame event that will create mAnim is still in the event
|
||||
// queue. Wait for it.
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
NS_NewRunnableMethod(this, &RasterImage::MarkAnimationDecoded);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RasterImage::MarkAnimationDecoded()
|
||||
{
|
||||
MOZ_ASSERT(mAnim, "Should have an animation now");
|
||||
if (!mAnim) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAnim->SetDoneDecoding(true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RasterImage::SetAnimationMode(uint16_t aAnimationMode)
|
||||
{
|
||||
@@ -1031,7 +990,7 @@ RasterImage::SetAnimationMode(uint16_t aAnimationMode)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void StartAnimation () */
|
||||
|
||||
nsresult
|
||||
RasterImage::StartAnimation()
|
||||
{
|
||||
@@ -1063,7 +1022,6 @@ RasterImage::StartAnimation()
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void stopAnimation (); */
|
||||
nsresult
|
||||
RasterImage::StopAnimation()
|
||||
{
|
||||
@@ -1081,7 +1039,6 @@ RasterImage::StopAnimation()
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void resetAnimation (); */
|
||||
NS_IMETHODIMP
|
||||
RasterImage::ResetAnimation()
|
||||
{
|
||||
@@ -1166,21 +1123,22 @@ RasterImage::OnImageDataComplete(nsIRequest*, nsISupports*, nsresult aStatus,
|
||||
// Let decoders know that there won't be any more data coming.
|
||||
mSourceBuffer->Complete(aStatus);
|
||||
|
||||
// Allow a synchronous size decode if mSyncLoad was set, or if we're running
|
||||
// on a single thread (in which case waiting for the async size decoder could
|
||||
// delay this image's load event quite a bit), or if this image is transient.
|
||||
bool canSyncSizeDecode = mSyncLoad || mTransient ||
|
||||
DecodePool::NumberOfCores() < 2;
|
||||
// Allow a synchronous metadata decode if mSyncLoad was set, or if we're
|
||||
// running on a single thread (in which case waiting for the async metadata
|
||||
// decoder could delay this image's load event quite a bit), or if this image
|
||||
// is transient.
|
||||
bool canSyncDecodeMetadata = mSyncLoad || mTransient ||
|
||||
DecodePool::NumberOfCores() < 2;
|
||||
|
||||
if (canSyncSizeDecode && !mHasSize) {
|
||||
if (canSyncDecodeMetadata && !mHasSize) {
|
||||
// We're loading this image synchronously, so it needs to be usable after
|
||||
// this call returns. Since we haven't gotten our size yet, we need to do a
|
||||
// synchronous size decode here.
|
||||
Decode(Nothing(), FLAG_SYNC_DECODE);
|
||||
// synchronous metadata decode here.
|
||||
DecodeMetadata(FLAG_SYNC_DECODE);
|
||||
}
|
||||
|
||||
// Determine our final status, giving precedence to Necko failure codes. We
|
||||
// check after running the size decode above in case it triggered an error.
|
||||
// check after running the metadata decode in case it triggered an error.
|
||||
nsresult finalStatus = mError ? NS_ERROR_FAILURE : NS_OK;
|
||||
if (NS_FAILED(aStatus)) {
|
||||
finalStatus = aStatus;
|
||||
@@ -1195,7 +1153,8 @@ RasterImage::OnImageDataComplete(nsIRequest*, nsISupports*, nsresult aStatus,
|
||||
|
||||
if (!mHasSize && !mError) {
|
||||
// We don't have our size yet, so we'll fire the load event in SetSize().
|
||||
MOZ_ASSERT(!canSyncSizeDecode, "Firing load async but canSyncSizeDecode?");
|
||||
MOZ_ASSERT(!canSyncDecodeMetadata,
|
||||
"Firing load async after metadata sync decode?");
|
||||
NotifyProgress(FLAG_ONLOAD_BLOCKED);
|
||||
mLoadProgress = Some(loadProgress);
|
||||
return finalStatus;
|
||||
@@ -1226,20 +1185,16 @@ RasterImage::NotifyForLoadEvent(Progress aProgress)
|
||||
nsresult
|
||||
RasterImage::OnImageDataAvailable(nsIRequest*,
|
||||
nsISupports*,
|
||||
nsIInputStream* aInStr,
|
||||
uint64_t aOffset,
|
||||
nsIInputStream* aInputStream,
|
||||
uint64_t,
|
||||
uint32_t aCount)
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv = mSourceBuffer->AppendFromInputStream(aInputStream, aCount);
|
||||
MOZ_ASSERT(rv == NS_OK || rv == NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// WriteToSourceBuffer always consumes everything it gets if it doesn't run
|
||||
// out of memory.
|
||||
uint32_t bytesRead;
|
||||
rv = aInStr->ReadSegments(WriteToSourceBuffer, this, aCount, &bytesRead);
|
||||
|
||||
MOZ_ASSERT(bytesRead == aCount || HasError() || NS_FAILED(rv),
|
||||
"WriteToSourceBuffer should consume everything if ReadSegments succeeds or "
|
||||
"the image must be in error!");
|
||||
if (MOZ_UNLIKELY(rv == NS_ERROR_OUT_OF_MEMORY)) {
|
||||
DoError();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
@@ -1325,132 +1280,15 @@ RasterImage::CanDiscard() {
|
||||
!mAnim; // Can never discard animated images
|
||||
}
|
||||
|
||||
// Sets up a decoder for this image.
|
||||
already_AddRefed<Decoder>
|
||||
RasterImage::CreateDecoder(const Maybe<IntSize>& aSize, uint32_t aFlags)
|
||||
{
|
||||
// Make sure we actually get size before doing a full decode.
|
||||
if (aSize) {
|
||||
MOZ_ASSERT(mHasSize, "Must do a size decode before a full decode!");
|
||||
MOZ_ASSERT(mDownscaleDuringDecode || *aSize == mSize,
|
||||
"Can only decode to our intrinsic size if we're not allowed to "
|
||||
"downscale-during-decode");
|
||||
} else {
|
||||
MOZ_ASSERT(!mHasSize, "Should not do unnecessary size decodes");
|
||||
}
|
||||
|
||||
// Instantiate the appropriate decoder.
|
||||
nsRefPtr<Decoder> decoder;
|
||||
switch (mDecoderType) {
|
||||
case eDecoderType_png:
|
||||
decoder = new nsPNGDecoder(this);
|
||||
break;
|
||||
case eDecoderType_gif:
|
||||
decoder = new nsGIFDecoder2(this);
|
||||
break;
|
||||
case eDecoderType_jpeg:
|
||||
// If we have all the data we don't want to waste cpu time doing
|
||||
// a progressive decode.
|
||||
decoder = new nsJPEGDecoder(this,
|
||||
mHasBeenDecoded ? Decoder::SEQUENTIAL :
|
||||
Decoder::PROGRESSIVE);
|
||||
break;
|
||||
#ifdef MOZ_JXR
|
||||
case eDecoderType_jxr:
|
||||
decoder = new nsJXRDecoder(this, mHasBeenDecoded);
|
||||
break;
|
||||
#endif
|
||||
case eDecoderType_bmp:
|
||||
decoder = new nsBMPDecoder(this);
|
||||
break;
|
||||
case eDecoderType_ico:
|
||||
decoder = new nsICODecoder(this);
|
||||
break;
|
||||
case eDecoderType_icon:
|
||||
decoder = new nsIconDecoder(this);
|
||||
break;
|
||||
case eDecoderType_webp:
|
||||
decoder = new nsWEBPDecoder(this);
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unknown decoder type");
|
||||
}
|
||||
|
||||
MOZ_ASSERT(decoder, "Should have a decoder now");
|
||||
|
||||
// Initialize the decoder.
|
||||
decoder->SetSizeDecode(!aSize);
|
||||
decoder->SetSendPartialInvalidations(!mHasBeenDecoded);
|
||||
decoder->SetImageIsTransient(mTransient);
|
||||
decoder->SetFlags(aFlags);
|
||||
|
||||
if (!mHasBeenDecoded && aSize) {
|
||||
// Lock the image while we're decoding, so that it doesn't get evicted from
|
||||
// the SurfaceCache before we have a chance to realize that it's animated.
|
||||
// The corresponding unlock happens in FinalizeDecoder.
|
||||
LockImage();
|
||||
decoder->SetImageIsLocked();
|
||||
}
|
||||
|
||||
decoder->SetIterator(mSourceBuffer->Iterator());
|
||||
|
||||
// Set a target size for downscale-during-decode if applicable.
|
||||
if (mDownscaleDuringDecode && aSize && *aSize != mSize) {
|
||||
DebugOnly<nsresult> rv = decoder->SetTargetSize(*aSize);
|
||||
MOZ_ASSERT(nsresult(rv) != NS_ERROR_NOT_AVAILABLE,
|
||||
"We're downscale-during-decode but decoder doesn't support it?");
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv), "Bad downscale-during-decode target size?");
|
||||
}
|
||||
|
||||
decoder->Init();
|
||||
|
||||
if (NS_FAILED(decoder->GetDecoderError())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (aSize) {
|
||||
// Add a placeholder for the first frame to the SurfaceCache so we won't
|
||||
// trigger any more decoders with the same parameters.
|
||||
InsertOutcome outcome =
|
||||
SurfaceCache::InsertPlaceholder(ImageKey(this),
|
||||
RasterSurfaceKey(*aSize,
|
||||
decoder->GetDecodeFlags(),
|
||||
/* aFrameNum = */ 0));
|
||||
if (outcome != InsertOutcome::SUCCESS) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Telemetry::GetHistogramById(
|
||||
Telemetry::IMAGE_DECODE_COUNT)->Subtract(mDecodeCount);
|
||||
mDecodeCount++;
|
||||
Telemetry::GetHistogramById(
|
||||
Telemetry::IMAGE_DECODE_COUNT)->Add(mDecodeCount);
|
||||
|
||||
if (mDecodeCount > sMaxDecodeCount) {
|
||||
// Don't subtract out 0 from the histogram, because that causes its count
|
||||
// to go negative, which is not kosher.
|
||||
if (sMaxDecodeCount > 0) {
|
||||
Telemetry::GetHistogramById(
|
||||
Telemetry::IMAGE_MAX_DECODE_COUNT)->Subtract(sMaxDecodeCount);
|
||||
}
|
||||
sMaxDecodeCount = mDecodeCount;
|
||||
Telemetry::GetHistogramById(
|
||||
Telemetry::IMAGE_MAX_DECODE_COUNT)->Add(sMaxDecodeCount);
|
||||
}
|
||||
}
|
||||
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void requestDecode() */
|
||||
|
||||
NS_IMETHODIMP
|
||||
RasterImage::RequestDecode()
|
||||
{
|
||||
return RequestDecodeForSize(mSize, DECODE_FLAGS_DEFAULT);
|
||||
}
|
||||
|
||||
/* void startDecode() */
|
||||
|
||||
NS_IMETHODIMP
|
||||
RasterImage::StartDecoding()
|
||||
{
|
||||
@@ -1492,22 +1330,52 @@ RasterImage::RequestDecodeForSize(const IntSize& aSize, uint32_t aFlags)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RasterImage::Decode(const Maybe<IntSize>& aSize, uint32_t aFlags)
|
||||
static void
|
||||
LaunchDecoder(Decoder* aDecoder,
|
||||
RasterImage* aImage,
|
||||
uint32_t aFlags,
|
||||
bool aHaveSourceData)
|
||||
{
|
||||
MOZ_ASSERT(!aSize || NS_IsMainThread());
|
||||
if (aHaveSourceData) {
|
||||
// If we have all the data, we can sync decode if requested.
|
||||
if (aFlags & imgIContainer::FLAG_SYNC_DECODE) {
|
||||
PROFILER_LABEL_PRINTF("DecodePool", "SyncDecodeIfPossible",
|
||||
js::ProfileEntry::Category::GRAPHICS,
|
||||
"%s", aImage->GetURIString().get());
|
||||
DecodePool::Singleton()->SyncDecodeIfPossible(aDecoder);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aFlags & imgIContainer::FLAG_SYNC_DECODE_IF_FAST) {
|
||||
PROFILER_LABEL_PRINTF("DecodePool", "SyncDecodeIfSmall",
|
||||
js::ProfileEntry::Category::GRAPHICS,
|
||||
"%s", aImage->GetURIString().get());
|
||||
DecodePool::Singleton()->SyncDecodeIfSmall(aDecoder);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Perform an async decode. We also take this path if we don't have all the
|
||||
// source data yet, since sync decoding is impossible in that situation.
|
||||
DecodePool::Singleton()->AsyncDecode(aDecoder);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RasterImage::Decode(const IntSize& aSize, uint32_t aFlags)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mError) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// If we don't have a size yet, we can't do any other decoding.
|
||||
if (!mHasSize && aSize) {
|
||||
if (!mHasSize) {
|
||||
mWantFullDecode = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mDownscaleDuringDecode && aSize) {
|
||||
if (mDownscaleDuringDecode) {
|
||||
// We're about to decode again, which may mean that some of the previous
|
||||
// sizes we've decoded at aren't useful anymore. We can allow them to
|
||||
// expire from the cache by unlocking them here. When the decode finishes,
|
||||
@@ -1518,32 +1386,80 @@ RasterImage::Decode(const Maybe<IntSize>& aSize, uint32_t aFlags)
|
||||
SurfaceCache::UnlockSurfaces(ImageKey(this));
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mDownscaleDuringDecode || aSize == mSize,
|
||||
"Can only decode to our intrinsic size if we're not allowed to "
|
||||
"downscale-during-decode");
|
||||
|
||||
Maybe<IntSize> targetSize = mSize != aSize ? Some(aSize) : Nothing();
|
||||
|
||||
bool imageIsLocked = false;
|
||||
if (!mHasBeenDecoded) {
|
||||
// Lock the image while we're decoding, so that it doesn't get evicted from
|
||||
// the SurfaceCache before we have a chance to realize that it's animated.
|
||||
// The corresponding unlock happens in FinalizeDecoder.
|
||||
LockImage();
|
||||
imageIsLocked = true;
|
||||
}
|
||||
|
||||
// Create a decoder.
|
||||
nsRefPtr<Decoder> decoder = CreateDecoder(aSize, aFlags);
|
||||
nsRefPtr<Decoder> decoder =
|
||||
DecoderFactory::CreateDecoder(mDecoderType, this, mSourceBuffer, targetSize,
|
||||
aFlags, mRequestedSampleSize, mRequestedResolution,
|
||||
mHasBeenDecoded, mTransient, imageIsLocked);
|
||||
|
||||
// Make sure DecoderFactory was able to create a decoder successfully.
|
||||
if (!decoder) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mHasSourceData) {
|
||||
// If we have all the data, we can sync decode if requested.
|
||||
if (aFlags & FLAG_SYNC_DECODE) {
|
||||
PROFILER_LABEL_PRINTF("DecodePool", "SyncDecodeIfPossible",
|
||||
js::ProfileEntry::Category::GRAPHICS, "%s", GetURIString().get());
|
||||
DecodePool::Singleton()->SyncDecodeIfPossible(decoder);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aFlags & FLAG_SYNC_DECODE_IF_FAST) {
|
||||
PROFILER_LABEL_PRINTF("DecodePool", "SyncDecodeIfSmall",
|
||||
js::ProfileEntry::Category::GRAPHICS, "%s", GetURIString().get());
|
||||
DecodePool::Singleton()->SyncDecodeIfSmall(decoder);
|
||||
return NS_OK;
|
||||
}
|
||||
// Add a placeholder for the first frame to the SurfaceCache so we won't
|
||||
// trigger any more decoders with the same parameters.
|
||||
InsertOutcome outcome =
|
||||
SurfaceCache::InsertPlaceholder(ImageKey(this),
|
||||
RasterSurfaceKey(aSize,
|
||||
decoder->GetDecodeFlags(),
|
||||
/* aFrameNum = */ 0));
|
||||
if (outcome != InsertOutcome::SUCCESS) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Perform an async decode. We also take this path if we don't have all the
|
||||
// source data yet, since sync decoding is impossible in that situation.
|
||||
DecodePool::Singleton()->AsyncDecode(decoder);
|
||||
if (mDecodeCount > sMaxDecodeCount) {
|
||||
// Don't subtract out 0 from the histogram, because that causes its count
|
||||
// to go negative, which is not kosher.
|
||||
if (sMaxDecodeCount > 0) {
|
||||
/*Telemetry::GetHistogramById(Telemetry::IMAGE_MAX_DECODE_COUNT)
|
||||
->Subtract(sMaxDecodeCount);*/
|
||||
}
|
||||
sMaxDecodeCount = mDecodeCount;
|
||||
}
|
||||
|
||||
// We're ready to decode; start the decoder.
|
||||
LaunchDecoder(decoder, this, aFlags, mHasSourceData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RasterImage::DecodeMetadata(uint32_t aFlags)
|
||||
{
|
||||
if (mError) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!mHasSize, "Should not do unnecessary metadata decodes");
|
||||
|
||||
// Create a decoder.
|
||||
nsRefPtr<Decoder> decoder =
|
||||
DecoderFactory::CreateMetadataDecoder(mDecoderType, this, mSourceBuffer,
|
||||
mRequestedSampleSize,
|
||||
mRequestedResolution);
|
||||
|
||||
// Make sure DecoderFactory was able to create a decoder successfully.
|
||||
if (!decoder) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// We're ready to decode; start the decoder.
|
||||
LaunchDecoder(decoder, this, aFlags, mHasSourceData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1562,13 +1478,13 @@ RasterImage::RecoverFromLossOfFrames(const IntSize& aSize, uint32_t aFlags)
|
||||
// Animated images require some special handling, because we normally require
|
||||
// that they never be discarded.
|
||||
if (mAnim) {
|
||||
Decode(Some(mSize), aFlags | FLAG_SYNC_DECODE);
|
||||
Decode(mSize, aFlags | FLAG_SYNC_DECODE);
|
||||
ResetAnimation();
|
||||
return;
|
||||
}
|
||||
|
||||
// For non-animated images, it's fine to recover using an async decode.
|
||||
Decode(Some(aSize), aFlags);
|
||||
Decode(aSize, aFlags);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -1829,24 +1745,14 @@ RasterImage::Draw(gfxContext* aContext,
|
||||
return DrawResult::NOT_READY;
|
||||
}
|
||||
|
||||
bool shouldRecordTelemetry = !mDrawStartTime.IsNull() &&
|
||||
ref->IsImageComplete();
|
||||
|
||||
auto result = DrawWithPreDownscaleIfNeeded(Move(ref), aContext, aSize,
|
||||
aRegion, aFilter, flags);
|
||||
|
||||
if (shouldRecordTelemetry) {
|
||||
TimeDuration drawLatency = TimeStamp::Now() - mDrawStartTime;
|
||||
Telemetry::Accumulate(Telemetry::IMAGE_DECODE_ON_DRAW_LATENCY,
|
||||
int32_t(drawLatency.ToMicroseconds()));
|
||||
mDrawStartTime = TimeStamp();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void lockImage() */
|
||||
|
||||
NS_IMETHODIMP
|
||||
RasterImage::LockImage()
|
||||
{
|
||||
@@ -1868,7 +1774,7 @@ RasterImage::LockImage()
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void unlockImage() */
|
||||
|
||||
NS_IMETHODIMP
|
||||
RasterImage::UnlockImage()
|
||||
{
|
||||
@@ -1897,7 +1803,7 @@ RasterImage::UnlockImage()
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void requestDiscard() */
|
||||
|
||||
NS_IMETHODIMP
|
||||
RasterImage::RequestDiscard()
|
||||
{
|
||||
@@ -1970,36 +1876,6 @@ RasterImage::HandleErrorWorker::Run()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIInputStream callback to copy the incoming image data directly to the
|
||||
// RasterImage without processing. The RasterImage is passed as the closure.
|
||||
// Always reads everything it gets, even if the data is erroneous.
|
||||
NS_METHOD
|
||||
RasterImage::WriteToSourceBuffer(nsIInputStream* /* unused */,
|
||||
void* aClosure,
|
||||
const char* aFromRawSegment,
|
||||
uint32_t /* unused */,
|
||||
uint32_t aCount,
|
||||
uint32_t* aWriteCount)
|
||||
{
|
||||
// Retrieve the RasterImage
|
||||
RasterImage* image = static_cast<RasterImage*>(aClosure);
|
||||
|
||||
// Copy the source data. Unless we hit OOM, we squelch the return value
|
||||
// here, because returning an error means that ReadSegments stops
|
||||
// reading data, violating our invariant that we read everything we get.
|
||||
// If we hit OOM then we fail and the load is aborted.
|
||||
nsresult rv = image->mSourceBuffer->Append(aFromRawSegment, aCount);
|
||||
if (rv == NS_ERROR_OUT_OF_MEMORY) {
|
||||
image->DoError();
|
||||
return rv;
|
||||
}
|
||||
|
||||
// We wrote everything we got
|
||||
*aWriteCount = aCount;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
RasterImage::ShouldAnimate()
|
||||
{
|
||||
@@ -2007,7 +1883,6 @@ RasterImage::ShouldAnimate()
|
||||
!mAnimationFinished;
|
||||
}
|
||||
|
||||
/* readonly attribute uint32_t framesNotified; */
|
||||
#ifdef DEBUG
|
||||
NS_IMETHODIMP
|
||||
RasterImage::GetFramesNotified(uint32_t* aFramesNotified)
|
||||
@@ -2046,47 +1921,63 @@ RasterImage::FinalizeDecoder(Decoder* aDecoder)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aDecoder);
|
||||
MOZ_ASSERT(aDecoder->HasError() || !aDecoder->InFrame(),
|
||||
"Finalizing a decoder in the middle of a frame");
|
||||
|
||||
// If the decoder detected an error, log it to the error console.
|
||||
if (aDecoder->ShouldReportError() && !aDecoder->WasAborted()) {
|
||||
ReportDecoderError(aDecoder);
|
||||
}
|
||||
|
||||
// Record all the metadata the decoder gathered about this image.
|
||||
nsresult rv = aDecoder->GetImageMetadata().SetOnImage(this);
|
||||
if (NS_FAILED(rv)) {
|
||||
aDecoder->PostResizeError();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mError || mHasSize || !aDecoder->HasSize(),
|
||||
"Should have handed off size by now");
|
||||
|
||||
if (aDecoder->GetDecodeTotallyDone() && !mError) {
|
||||
// Flag that we've been decoded before.
|
||||
mHasBeenDecoded = true;
|
||||
|
||||
if (aDecoder->HasAnimation()) {
|
||||
if (mAnim) {
|
||||
mAnim->SetDoneDecoding(true);
|
||||
} else {
|
||||
// The OnAddedFrame event that will create mAnim is still in the event
|
||||
// queue. Wait for it.
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
NS_NewRunnableMethod(this, &RasterImage::MarkAnimationDecoded);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send out any final notifications.
|
||||
NotifyProgress(aDecoder->TakeProgress(),
|
||||
aDecoder->TakeInvalidRect(),
|
||||
aDecoder->GetDecodeFlags());
|
||||
|
||||
bool wasSize = aDecoder->IsSizeDecode();
|
||||
bool wasMetadata = aDecoder->IsMetadataDecode();
|
||||
bool done = aDecoder->GetDecodeDone();
|
||||
|
||||
if (!wasSize && aDecoder->ChunkCount()) {
|
||||
Telemetry::Accumulate(Telemetry::IMAGE_DECODE_CHUNKS,
|
||||
aDecoder->ChunkCount());
|
||||
if (!wasMetadata && aDecoder->ChunkCount()) {
|
||||
/*Telemetry::Accumulate(Telemetry::IMAGE_DECODE_CHUNKS,
|
||||
aDecoder->ChunkCount());*/
|
||||
}
|
||||
|
||||
if (done) {
|
||||
// Do some telemetry if this isn't a size decode.
|
||||
if (!wasSize) {
|
||||
Telemetry::Accumulate(Telemetry::IMAGE_DECODE_TIME,
|
||||
int32_t(aDecoder->DecodeTime().ToMicroseconds()));
|
||||
|
||||
// We record the speed for only some decoders. The rest have
|
||||
// SpeedHistogram return HistogramCount.
|
||||
Telemetry::ID id = aDecoder->SpeedHistogram();
|
||||
if (id < Telemetry::HistogramCount) {
|
||||
int32_t KBps = int32_t(aDecoder->BytesDecoded() /
|
||||
(1024 * aDecoder->DecodeTime().ToSeconds()));
|
||||
Telemetry::Accumulate(id, KBps);
|
||||
}
|
||||
}
|
||||
|
||||
// Detect errors.
|
||||
if (aDecoder->HasError() && !aDecoder->WasAborted()) {
|
||||
DoError();
|
||||
} else if (wasSize && !mHasSize) {
|
||||
} else if (wasMetadata && !mHasSize) {
|
||||
DoError();
|
||||
}
|
||||
|
||||
// If we were waiting to fire the load event, go ahead and fire it now.
|
||||
if (mLoadProgress && wasSize) {
|
||||
if (mLoadProgress && wasMetadata) {
|
||||
NotifyForLoadEvent(*mLoadProgress);
|
||||
mLoadProgress = Nothing();
|
||||
NotifyProgress(FLAG_ONLOAD_UNBLOCKED);
|
||||
@@ -2098,13 +1989,53 @@ RasterImage::FinalizeDecoder(Decoder* aDecoder)
|
||||
UnlockImage();
|
||||
}
|
||||
|
||||
// If we were a size decode and a full decode was requested, now's the time.
|
||||
if (done && wasSize && mWantFullDecode) {
|
||||
// If we were a metadata decode and a full decode was requested, do it.
|
||||
if (done && wasMetadata && mWantFullDecode) {
|
||||
mWantFullDecode = false;
|
||||
RequestDecode();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RasterImage::MarkAnimationDecoded()
|
||||
{
|
||||
MOZ_ASSERT(mAnim, "Should have an animation now");
|
||||
if (!mAnim) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAnim->SetDoneDecoding(true);
|
||||
}
|
||||
|
||||
void
|
||||
RasterImage::ReportDecoderError(Decoder* aDecoder)
|
||||
{
|
||||
nsCOMPtr<nsIConsoleService> consoleService =
|
||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIScriptError> errorObject =
|
||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
|
||||
|
||||
if (consoleService && errorObject && !aDecoder->HasDecoderError()) {
|
||||
nsAutoString msg(NS_LITERAL_STRING("Image corrupt or truncated."));
|
||||
nsAutoString src;
|
||||
if (GetURI()) {
|
||||
nsCString uri;
|
||||
if (GetURI()->GetSpecTruncatedTo1k(uri) == ImageURL::TruncatedTo1k) {
|
||||
msg += NS_LITERAL_STRING(" URI in this note truncated due to length.");
|
||||
}
|
||||
src = NS_ConvertUTF8toUTF16(uri);
|
||||
}
|
||||
if (NS_SUCCEEDED(errorObject->InitWithWindowID(
|
||||
msg,
|
||||
src,
|
||||
EmptyString(), 0, 0, nsIScriptError::errorFlag,
|
||||
"Image", InnerWindowID()
|
||||
))) {
|
||||
consoleService->LogMessage(errorObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<imgIContainer>
|
||||
RasterImage::Unwrap()
|
||||
{
|
||||
|
||||
+21
-31
@@ -26,6 +26,7 @@
|
||||
#include "LookupResult.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "DecodePool.h"
|
||||
#include "DecoderFactory.h"
|
||||
#include "Orientation.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
@@ -169,12 +170,6 @@ public:
|
||||
// Methods inherited from Image
|
||||
virtual void OnSurfaceDiscarded() override;
|
||||
|
||||
// Raster-specific methods
|
||||
static NS_METHOD WriteToSourceBuffer(nsIInputStream* aIn, void* aClosure,
|
||||
const char* aFromRawSegment,
|
||||
uint32_t aToOffset, uint32_t aCount,
|
||||
uint32_t* aWriteCount);
|
||||
|
||||
/* The total number of frames in this image. */
|
||||
uint32_t GetNumFrames() const { return mFrameCount; }
|
||||
|
||||
@@ -205,12 +200,6 @@ public:
|
||||
*/
|
||||
void SetLoopCount(int32_t aLoopCount);
|
||||
|
||||
/// Notification that the entire image has been decoded.
|
||||
void OnDecodingComplete(bool aIsAnimated);
|
||||
|
||||
/// Helper method for OnDecodingComplete.
|
||||
void MarkAnimationDecoded();
|
||||
|
||||
/**
|
||||
* Sends the provided progress notifications to ProgressTracker.
|
||||
*
|
||||
@@ -233,6 +222,10 @@ public:
|
||||
*/
|
||||
void FinalizeDecoder(Decoder* aDecoder);
|
||||
|
||||
// Helper methods for FinalizeDecoder.
|
||||
void MarkAnimationDecoded();
|
||||
void ReportDecoderError(Decoder* aDecoder);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Network callbacks.
|
||||
@@ -268,18 +261,11 @@ public:
|
||||
mRequestedResolution = requestedResolution;
|
||||
}
|
||||
|
||||
nsIntSize GetRequestedResolution() {
|
||||
return mRequestedResolution;
|
||||
}
|
||||
/* Provide a hint for the requested dimension of the resulting image. */
|
||||
void SetRequestedSampleSize(int requestedSampleSize) {
|
||||
mRequestedSampleSize = requestedSampleSize;
|
||||
}
|
||||
|
||||
int GetRequestedSampleSize() {
|
||||
return mRequestedSampleSize;
|
||||
}
|
||||
|
||||
nsCString GetURIString() {
|
||||
nsCString spec;
|
||||
if (GetURI()) {
|
||||
@@ -339,19 +325,23 @@ private:
|
||||
|
||||
/**
|
||||
* Creates and runs a decoder, either synchronously or asynchronously
|
||||
* according to @aFlags. Passes the provided target size @aSize and decode
|
||||
* flags @aFlags to CreateDecoder. If a size decode is desired, pass Nothing
|
||||
* for @aSize.
|
||||
* according to @aFlags. Decodes at the provided target size @aSize, using
|
||||
* decode flags @aFlags.
|
||||
*
|
||||
* It's an error to call Decode() before this image's intrinsic size is
|
||||
* available. A metadata decode must successfully complete first.
|
||||
*
|
||||
* If downscale-during-decode is not enabled for this image (i.e., if
|
||||
* mDownscaleDuringDecode is false), it is an error to pass an @aSize value
|
||||
* different from this image's intrinsic size.
|
||||
*/
|
||||
NS_IMETHOD Decode(const Maybe<nsIntSize>& aSize, uint32_t aFlags);
|
||||
NS_IMETHOD Decode(const gfx::IntSize& aSize, uint32_t aFlags);
|
||||
|
||||
/**
|
||||
* Creates a new decoder with a target size of @aSize and decode flags
|
||||
* specified by @aFlags. If a size decode is desired, pass Nothing() for
|
||||
* @aSize.
|
||||
* Creates and runs a metadata decoder, either synchronously or
|
||||
* asynchronously according to @aFlags.
|
||||
*/
|
||||
already_AddRefed<Decoder> CreateDecoder(const Maybe<nsIntSize>& aSize,
|
||||
uint32_t aFlags);
|
||||
NS_IMETHOD DecodeMetadata(uint32_t aFlags);
|
||||
|
||||
/**
|
||||
* In catastrophic circumstances like a GPU driver crash, we may lose our
|
||||
@@ -376,7 +366,7 @@ private: // data
|
||||
uint32_t mLockCount;
|
||||
|
||||
// The type of decoder this image needs. Computed from the MIME type in Init().
|
||||
eDecoderType mDecoderType;
|
||||
DecoderType mDecoderType;
|
||||
|
||||
// How many times we've decoded this image.
|
||||
// This is currently only used for statistics
|
||||
@@ -425,8 +415,8 @@ private: // data
|
||||
// of frames, or no more owning request
|
||||
bool mAnimationFinished:1;
|
||||
|
||||
// Whether, once we are done doing a size decode, we should immediately kick
|
||||
// off a full decode.
|
||||
// Whether, once we are done doing a metadata decode, we should immediately
|
||||
// kick off a full decode.
|
||||
bool mWantFullDecode:1;
|
||||
|
||||
TimeStamp mDrawStartTime;
|
||||
|
||||
@@ -33,9 +33,11 @@
|
||||
// undef the GetCurrentTime macro defined in WinBase.h from the MS Platform SDK
|
||||
#undef GetCurrentTime
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
using namespace dom;
|
||||
using namespace gfx;
|
||||
|
||||
namespace image {
|
||||
|
||||
NS_IMPL_ISUPPORTS(SVGDocumentWrapper,
|
||||
@@ -213,7 +215,6 @@ SVGDocumentWrapper::OnDataAvailable(nsIRequest* aRequest, nsISupports* ctxt,
|
||||
|
||||
/** nsIRequestObserver methods **/
|
||||
|
||||
/* void onStartRequest (in nsIRequest request, in nsISupports ctxt); */
|
||||
NS_IMETHODIMP
|
||||
SVGDocumentWrapper::OnStartRequest(nsIRequest* aRequest, nsISupports* ctxt)
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include "mozilla/Likely.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "MainThreadUtils.h"
|
||||
#include "SurfaceCache.h"
|
||||
|
||||
@@ -354,6 +355,46 @@ SourceBuffer::Append(const char* aData, size_t aLength)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static NS_METHOD
|
||||
AppendToSourceBuffer(nsIInputStream*,
|
||||
void* aClosure,
|
||||
const char* aFromRawSegment,
|
||||
uint32_t,
|
||||
uint32_t aCount,
|
||||
uint32_t* aWriteCount)
|
||||
{
|
||||
SourceBuffer* sourceBuffer = static_cast<SourceBuffer*>(aClosure);
|
||||
|
||||
// Copy the source data. Unless we hit OOM, we squelch the return value here,
|
||||
// because returning an error means that ReadSegments stops reading data, and
|
||||
// we want to ensure that we read everything we get. If we hit OOM then we
|
||||
// return a failed status to the caller.
|
||||
nsresult rv = sourceBuffer->Append(aFromRawSegment, aCount);
|
||||
if (rv == NS_ERROR_OUT_OF_MEMORY) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Report that we wrote everything we got.
|
||||
*aWriteCount = aCount;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
SourceBuffer::AppendFromInputStream(nsIInputStream* aInputStream,
|
||||
uint32_t aCount)
|
||||
{
|
||||
uint32_t bytesRead;
|
||||
nsresult rv = aInputStream->ReadSegments(AppendToSourceBuffer, this,
|
||||
aCount, &bytesRead);
|
||||
|
||||
MOZ_ASSERT(bytesRead == aCount || rv == NS_ERROR_OUT_OF_MEMORY,
|
||||
"AppendToSourceBuffer should consume everything unless "
|
||||
"we run out of memory");
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
SourceBuffer::Complete(nsresult aStatus)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "mozilla/nsRefPtr.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
class nsIInputStream;
|
||||
|
||||
namespace mozilla {
|
||||
namespace image {
|
||||
|
||||
@@ -235,6 +237,9 @@ public:
|
||||
/// Append the provided data to the buffer.
|
||||
nsresult Append(const char* aData, size_t aLength);
|
||||
|
||||
/// Append the data available on the provided nsIInputStream to the buffer.
|
||||
nsresult AppendFromInputStream(nsIInputStream* aInputStream, uint32_t aCount);
|
||||
|
||||
/**
|
||||
* Mark the buffer complete, with a status that will be available to
|
||||
* consumers. Further calls to Append() are forbidden after Complete().
|
||||
|
||||
+4
-15
@@ -484,7 +484,6 @@ VectorImage::SetAnimationStartTime(const TimeStamp& aTime)
|
||||
// imgIContainer methods
|
||||
|
||||
//******************************************************************************
|
||||
/* readonly attribute int32_t width; */
|
||||
NS_IMETHODIMP
|
||||
VectorImage::GetWidth(int32_t* aWidth)
|
||||
{
|
||||
@@ -500,7 +499,6 @@ VectorImage::GetWidth(int32_t* aWidth)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* [notxpcom] void requestRefresh ([const] in TimeStamp aTime); */
|
||||
NS_IMETHODIMP_(void)
|
||||
VectorImage::RequestRefresh(const TimeStamp& aTime)
|
||||
{
|
||||
@@ -550,7 +548,6 @@ VectorImage::GetImageSpaceInvalidationRect(const IntRect& aRect)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* readonly attribute int32_t height; */
|
||||
NS_IMETHODIMP
|
||||
VectorImage::GetHeight(int32_t* aHeight)
|
||||
{
|
||||
@@ -566,7 +563,6 @@ VectorImage::GetHeight(int32_t* aHeight)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* [noscript] readonly attribute nsSize intrinsicSize; */
|
||||
NS_IMETHODIMP
|
||||
VectorImage::GetIntrinsicSize(nsSize* aSize)
|
||||
{
|
||||
@@ -592,7 +588,6 @@ VectorImage::GetIntrinsicSize(nsSize* aSize)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* [noscript] readonly attribute nsSize intrinsicRatio; */
|
||||
NS_IMETHODIMP
|
||||
VectorImage::GetIntrinsicRatio(nsSize* aRatio)
|
||||
{
|
||||
@@ -616,7 +611,6 @@ VectorImage::GetOrientation()
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* readonly attribute unsigned short type; */
|
||||
NS_IMETHODIMP
|
||||
VectorImage::GetType(uint16_t* aType)
|
||||
{
|
||||
@@ -627,7 +621,6 @@ VectorImage::GetType(uint16_t* aType)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* readonly attribute boolean animated; */
|
||||
NS_IMETHODIMP
|
||||
VectorImage::GetAnimated(bool* aAnimated)
|
||||
{
|
||||
@@ -640,7 +633,6 @@ VectorImage::GetAnimated(bool* aAnimated)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* [notxpcom] int32_t getFirstFrameDelay (); */
|
||||
int32_t
|
||||
VectorImage::GetFirstFrameDelay()
|
||||
{
|
||||
@@ -722,7 +714,6 @@ VectorImage::IsImageContainerAvailable(LayerManager* aManager, uint32_t aFlags)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* [noscript] ImageContainer getImageContainer(); */
|
||||
NS_IMETHODIMP_(already_AddRefed<ImageContainer>)
|
||||
VectorImage::GetImageContainer(LayerManager* aManager, uint32_t aFlags)
|
||||
{
|
||||
@@ -970,7 +961,7 @@ VectorImage::RecoverFromLossOfSurfaces()
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void requestDecode() */
|
||||
|
||||
NS_IMETHODIMP
|
||||
VectorImage::RequestDecode()
|
||||
{
|
||||
@@ -995,7 +986,7 @@ VectorImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags)
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void lockImage() */
|
||||
|
||||
NS_IMETHODIMP
|
||||
VectorImage::LockImage()
|
||||
{
|
||||
@@ -1016,7 +1007,7 @@ VectorImage::LockImage()
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void unlockImage() */
|
||||
|
||||
NS_IMETHODIMP
|
||||
VectorImage::UnlockImage()
|
||||
{
|
||||
@@ -1042,7 +1033,7 @@ VectorImage::UnlockImage()
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void requestDiscard() */
|
||||
|
||||
NS_IMETHODIMP
|
||||
VectorImage::RequestDiscard()
|
||||
{
|
||||
@@ -1067,7 +1058,6 @@ VectorImage::OnSurfaceDiscarded()
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* void resetAnimation (); */
|
||||
NS_IMETHODIMP
|
||||
VectorImage::ResetAnimation()
|
||||
{
|
||||
@@ -1097,7 +1087,6 @@ VectorImage::GetFrameIndex(uint32_t aWhichFrame)
|
||||
// nsIRequestObserver methods
|
||||
|
||||
//******************************************************************************
|
||||
/* void onStartRequest(in nsIRequest request, in nsISupports ctxt); */
|
||||
NS_IMETHODIMP
|
||||
VectorImage::OnStartRequest(nsIRequest* aRequest, nsISupports* aCtxt)
|
||||
{
|
||||
|
||||
@@ -140,7 +140,7 @@ nsBMPDecoder::FinishInternal()
|
||||
MOZ_ASSERT(GetFrameCount() <= 1, "Multiple BMP frames?");
|
||||
|
||||
// Send notifications if appropriate
|
||||
if (!IsSizeDecode() && HasSize()) {
|
||||
if (!IsMetadataDecode() && HasSize()) {
|
||||
|
||||
// Invalidate
|
||||
nsIntRect r(0, 0, mBIH.width, GetHeight());
|
||||
@@ -368,9 +368,8 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
return;
|
||||
}
|
||||
|
||||
// We have the size. If we're doing a size decode, we got what
|
||||
// we came for.
|
||||
if (IsSizeDecode()) {
|
||||
// We have the size. If we're doing a metadata decode, we're done.
|
||||
if (IsMetadataDecode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ class RasterImage;
|
||||
class nsBMPDecoder : public Decoder
|
||||
{
|
||||
public:
|
||||
|
||||
explicit nsBMPDecoder(RasterImage* aImage);
|
||||
~nsBMPDecoder();
|
||||
|
||||
// Specifies whether or not the BMP file will contain alpha data
|
||||
@@ -55,6 +53,12 @@ public:
|
||||
virtual void FinishInternal() override;
|
||||
|
||||
private:
|
||||
friend class DecoderFactory;
|
||||
friend class nsICODecoder;
|
||||
|
||||
// Decoders should only be instantiated via DecoderFactory.
|
||||
// XXX(seth): nsICODecoder is temporarily an exception to this rule.
|
||||
explicit nsBMPDecoder(RasterImage* aImage);
|
||||
|
||||
/// Calculates the red-, green- and blueshift in mBitFields using
|
||||
/// the bitmasks from mBitFields
|
||||
|
||||
@@ -103,7 +103,7 @@ nsGIFDecoder2::FinishInternal()
|
||||
MOZ_ASSERT(!HasError(), "Shouldn't call FinishInternal after error!");
|
||||
|
||||
// If the GIF got cut off, handle it anyway
|
||||
if (!IsSizeDecode() && mGIFOpen) {
|
||||
if (!IsMetadataDecode() && mGIFOpen) {
|
||||
if (mCurrentFrameIndex == mGIFStruct.images_decoded) {
|
||||
EndImageFrame();
|
||||
}
|
||||
@@ -689,7 +689,7 @@ nsGIFDecoder2::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
mGIFStruct.screen_height = GETINT16(q + 2);
|
||||
mGIFStruct.global_colormap_depth = (q[4]&0x07) + 1;
|
||||
|
||||
if (IsSizeDecode()) {
|
||||
if (IsMetadataDecode()) {
|
||||
MOZ_ASSERT(!mGIFOpen, "Gif should not be open at this point");
|
||||
PostSize(mGIFStruct.screen_width, mGIFStruct.screen_height);
|
||||
return;
|
||||
@@ -901,6 +901,13 @@ nsGIFDecoder2::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
break;
|
||||
|
||||
case gif_image_header: {
|
||||
if (mGIFStruct.images_decoded > 0 && IsFirstFrameDecode()) {
|
||||
// We're about to get a second frame, but we only want the first. Stop
|
||||
// decoding now.
|
||||
mGIFStruct.state = gif_done;
|
||||
break;
|
||||
}
|
||||
|
||||
// Get image offsets, with respect to the screen origin
|
||||
mGIFStruct.x_offset = GETINT16(q);
|
||||
mGIFStruct.y_offset = GETINT16(q + 2);
|
||||
@@ -929,8 +936,8 @@ nsGIFDecoder2::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
return;
|
||||
}
|
||||
|
||||
// If we were doing a size decode, we're done
|
||||
if (IsSizeDecode()) {
|
||||
// If we were doing a metadata decode, we're done.
|
||||
if (IsMetadataDecode()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1090,7 +1097,8 @@ nsGIFDecoder2::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
break;
|
||||
|
||||
case gif_done:
|
||||
MOZ_ASSERT(!IsSizeDecode(), "Size decodes shouldn't reach gif_done");
|
||||
MOZ_ASSERT(!IsMetadataDecode(),
|
||||
"Metadata decodes shouldn't reach gif_done");
|
||||
FinishInternal();
|
||||
goto done;
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ class RasterImage;
|
||||
class nsGIFDecoder2 : public Decoder
|
||||
{
|
||||
public:
|
||||
|
||||
explicit nsGIFDecoder2(RasterImage* aImage);
|
||||
~nsGIFDecoder2();
|
||||
|
||||
virtual void WriteInternal(const char* aBuffer, uint32_t aCount) override;
|
||||
@@ -31,9 +29,13 @@ public:
|
||||
virtual Telemetry::ID SpeedHistogram() override;
|
||||
|
||||
private:
|
||||
friend class DecoderFactory;
|
||||
|
||||
// Decoders should only be instantiated via DecoderFactory.
|
||||
explicit nsGIFDecoder2(RasterImage* aImage);
|
||||
|
||||
// These functions will be called when the decoder has a decoded row,
|
||||
// frame size information, etc.
|
||||
|
||||
void BeginGIF();
|
||||
nsresult BeginImageFrame(uint16_t aDepth);
|
||||
void EndImageFrame();
|
||||
|
||||
@@ -266,9 +266,10 @@ nsICODecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
}
|
||||
|
||||
uint16_t colorDepth = 0;
|
||||
nsIntSize prefSize = mImage->GetRequestedResolution();
|
||||
if (prefSize.width == 0 && prefSize.height == 0) {
|
||||
prefSize.SizeTo(PREFICONSIZE, PREFICONSIZE);
|
||||
|
||||
// If we didn't get a #-moz-resolution, default to PREFICONSIZE.
|
||||
if (mResolution.width == 0 && mResolution.height == 0) {
|
||||
mResolution.SizeTo(PREFICONSIZE, PREFICONSIZE);
|
||||
}
|
||||
|
||||
// A measure of the difference in size between the entry we've found
|
||||
@@ -306,8 +307,8 @@ nsICODecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
// Calculate the delta between this image's size and the desired size,
|
||||
// so we can see if it is better than our current-best option.
|
||||
// In the case of several equally-good images, we use the last one.
|
||||
int32_t delta = (e.mWidth == 0 ? 256 : e.mWidth) - prefSize.width +
|
||||
(e.mHeight == 0 ? 256 : e.mHeight) - prefSize.height;
|
||||
int32_t delta = (e.mWidth == 0 ? 256 : e.mWidth) - mResolution.width +
|
||||
(e.mHeight == 0 ? 256 : e.mHeight) - mResolution.height;
|
||||
if (e.mBitCount >= colorDepth &&
|
||||
((diff < 0 && delta >= diff) || (delta >= 0 && delta <= diff))) {
|
||||
diff = delta;
|
||||
@@ -358,8 +359,11 @@ nsICODecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
PNGSIGNATURESIZE);
|
||||
if (mIsPNG) {
|
||||
mContainedDecoder = new nsPNGDecoder(mImage);
|
||||
mContainedDecoder->SetSizeDecode(IsSizeDecode());
|
||||
mContainedDecoder->SetMetadataDecode(IsMetadataDecode());
|
||||
mContainedDecoder->SetSendPartialInvalidations(mSendPartialInvalidations);
|
||||
if (mFirstFrameDecode) {
|
||||
mContainedDecoder->SetIsFirstFrameDecode();
|
||||
}
|
||||
mContainedDecoder->Init();
|
||||
if (!WriteToContainedDecoder(mSignature, PNGSIGNATURESIZE)) {
|
||||
return;
|
||||
@@ -384,7 +388,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
|
||||
// Raymond Chen says that 32bpp only are valid PNG ICOs
|
||||
// http://blogs.msdn.com/b/oldnewthing/archive/2010/10/22/10079192.aspx
|
||||
if (!IsSizeDecode() &&
|
||||
if (!IsMetadataDecode() &&
|
||||
!static_cast<nsPNGDecoder*>(mContainedDecoder.get())->IsValidICO()) {
|
||||
PostDataError();
|
||||
}
|
||||
@@ -435,8 +439,11 @@ nsICODecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
nsBMPDecoder* bmpDecoder = new nsBMPDecoder(mImage);
|
||||
mContainedDecoder = bmpDecoder;
|
||||
bmpDecoder->SetUseAlphaData(true);
|
||||
mContainedDecoder->SetSizeDecode(IsSizeDecode());
|
||||
mContainedDecoder->SetMetadataDecode(IsMetadataDecode());
|
||||
mContainedDecoder->SetSendPartialInvalidations(mSendPartialInvalidations);
|
||||
if (mFirstFrameDecode) {
|
||||
mContainedDecoder->SetIsFirstFrameDecode();
|
||||
}
|
||||
mContainedDecoder->Init();
|
||||
|
||||
// The ICO format when containing a BMP does not include the 14 byte
|
||||
@@ -470,9 +477,8 @@ nsICODecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
PostSize(mContainedDecoder->GetImageMetadata().GetWidth(),
|
||||
mContainedDecoder->GetImageMetadata().GetHeight());
|
||||
|
||||
// We have the size. If we're doing a size decode, we got what
|
||||
// we came for.
|
||||
if (IsSizeDecode()) {
|
||||
// We have the size. If we're doing a metadata decode, we're done.
|
||||
if (IsMetadataDecode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ class RasterImage;
|
||||
class nsICODecoder : public Decoder
|
||||
{
|
||||
public:
|
||||
|
||||
explicit nsICODecoder(RasterImage* aImage);
|
||||
virtual ~nsICODecoder();
|
||||
|
||||
// Obtains the width of the icon directory entry
|
||||
@@ -38,11 +36,21 @@ public:
|
||||
return mDirEntry.mHeight == 0 ? 256 : mDirEntry.mHeight;
|
||||
}
|
||||
|
||||
virtual void SetResolution(const gfx::IntSize& aResolution) override
|
||||
{
|
||||
mResolution = aResolution;
|
||||
}
|
||||
|
||||
virtual void WriteInternal(const char* aBuffer, uint32_t aCount) override;
|
||||
virtual void FinishInternal() override;
|
||||
virtual void FinishWithErrorInternal() override;
|
||||
|
||||
private:
|
||||
friend class DecoderFactory;
|
||||
|
||||
// Decoders should only be instantiated via DecoderFactory.
|
||||
explicit nsICODecoder(RasterImage* aImage);
|
||||
|
||||
// Writes to the contained decoder and sets the appropriate errors
|
||||
// Returns true if there are no errors.
|
||||
bool WriteToContainedDecoder(const char* aBuffer, uint32_t aCount);
|
||||
@@ -74,6 +82,7 @@ private:
|
||||
// Obtains the number of colors from the BPP, mBPP must be filled in
|
||||
uint16_t GetNumColors();
|
||||
|
||||
gfx::IntSize mResolution; // The requested -moz-resolution for this icon.
|
||||
uint16_t mBPP; // Stores the images BPP
|
||||
uint32_t mPos; // Keeps track of the position we have decoded up until
|
||||
uint16_t mNumIcons; // Stores the number of icons in the ICO file
|
||||
|
||||
@@ -67,8 +67,8 @@ nsIconDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
return;
|
||||
}
|
||||
|
||||
// If We're doing a size decode, we're done
|
||||
if (IsSizeDecode()) {
|
||||
// If we're doing a metadata decode, we're done.
|
||||
if (IsMetadataDecode()) {
|
||||
mState = iconStateFinished;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -37,12 +37,17 @@ class RasterImage;
|
||||
class nsIconDecoder : public Decoder
|
||||
{
|
||||
public:
|
||||
|
||||
explicit nsIconDecoder(RasterImage* aImage);
|
||||
virtual ~nsIconDecoder();
|
||||
|
||||
virtual void WriteInternal(const char* aBuffer, uint32_t aCount) override;
|
||||
|
||||
private:
|
||||
friend class DecoderFactory;
|
||||
|
||||
// Decoders should only be instantiated via DecoderFactory.
|
||||
explicit nsIconDecoder(RasterImage* aImage);
|
||||
|
||||
public:
|
||||
uint8_t mWidth;
|
||||
uint8_t mHeight;
|
||||
uint32_t mPixBytesRead;
|
||||
|
||||
@@ -85,6 +85,7 @@ nsJPEGDecoder::nsJPEGDecoder(RasterImage* aImage,
|
||||
Decoder::DecodeStyle aDecodeStyle)
|
||||
: Decoder(aImage)
|
||||
, mDecodeStyle(aDecodeStyle)
|
||||
, mSampleSize(0)
|
||||
{
|
||||
mState = JPEG_HEADER;
|
||||
mReading = true;
|
||||
@@ -196,7 +197,7 @@ nsJPEGDecoder::FinishInternal()
|
||||
// If we're not in any sort of error case, force our state to JPEG_DONE.
|
||||
if ((mState != JPEG_DONE && mState != JPEG_SINK_NON_JPEG_TRAILER) &&
|
||||
(mState != JPEG_ERROR) &&
|
||||
!IsSizeDecode()) {
|
||||
!IsMetadataDecode()) {
|
||||
mState = JPEG_DONE;
|
||||
}
|
||||
}
|
||||
@@ -249,10 +250,10 @@ nsJPEGDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
return; // I/O suspension
|
||||
}
|
||||
|
||||
int sampleSize = mImage->GetRequestedSampleSize();
|
||||
if (sampleSize > 0) {
|
||||
// If we have a sample size specified for -moz-sample-size, use it.
|
||||
if (mSampleSize > 0) {
|
||||
mInfo.scale_num = 1;
|
||||
mInfo.scale_denom = sampleSize;
|
||||
mInfo.scale_denom = mSampleSize;
|
||||
}
|
||||
|
||||
// Used to set up image size so arrays can be allocated
|
||||
@@ -267,8 +268,8 @@ nsJPEGDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're doing a size decode, we're done.
|
||||
if (IsSizeDecode()) {
|
||||
// If we're doing a metadata decode, we're done.
|
||||
if (IsMetadataDecode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,11 +53,15 @@ struct Orientation;
|
||||
class nsJPEGDecoder : public Decoder
|
||||
{
|
||||
public:
|
||||
nsJPEGDecoder(RasterImage* aImage, Decoder::DecodeStyle aDecodeStyle);
|
||||
virtual ~nsJPEGDecoder();
|
||||
|
||||
virtual nsresult SetTargetSize(const nsIntSize& aSize) override;
|
||||
|
||||
virtual void SetSampleSize(int aSampleSize) override
|
||||
{
|
||||
mSampleSize = aSampleSize;
|
||||
}
|
||||
|
||||
virtual void InitInternal() override;
|
||||
virtual void WriteInternal(const char* aBuffer, uint32_t aCount) override;
|
||||
virtual void FinishInternal() override;
|
||||
@@ -71,6 +75,12 @@ protected:
|
||||
|
||||
Maybe<Downscaler> mDownscaler;
|
||||
|
||||
private:
|
||||
friend class DecoderFactory;
|
||||
|
||||
// Decoders should only be instantiated via DecoderFactory.
|
||||
nsJPEGDecoder(RasterImage* aImage, Decoder::DecodeStyle aDecodeStyle);
|
||||
|
||||
public:
|
||||
struct jpeg_decompress_struct mInfo;
|
||||
struct jpeg_source_mgr mSourceMgr;
|
||||
@@ -98,6 +108,8 @@ public:
|
||||
const Decoder::DecodeStyle mDecodeStyle;
|
||||
|
||||
uint32_t mCMSMode;
|
||||
|
||||
int mSampleSize;
|
||||
};
|
||||
|
||||
} // namespace image
|
||||
|
||||
@@ -2599,7 +2599,7 @@ void nsJXRDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
|
||||
|
||||
// We have the size. If we're doing a size decode, we got what
|
||||
// we came for.
|
||||
if (IsSizeDecode())
|
||||
if (IsMetadataDecode())
|
||||
return;
|
||||
|
||||
CreateColorTransform();
|
||||
@@ -2671,7 +2671,7 @@ void nsJXRDecoder::FinishInternal()
|
||||
//MOZ_ASSERT(GetFrameCount() <= 1, "Multiple JPEG-XR frames?");
|
||||
|
||||
// Send notifications if appropriate
|
||||
if (!IsSizeDecode() && HasSize())
|
||||
if (!IsMetadataDecode() && HasSize())
|
||||
{
|
||||
if (DecodeAtEnd())
|
||||
{
|
||||
|
||||
@@ -51,8 +51,6 @@ class RasterImage;
|
||||
class nsJXRDecoder : public Decoder
|
||||
{
|
||||
public:
|
||||
|
||||
nsJXRDecoder(RasterImage* aImage, bool hasBeenDecoded);
|
||||
~nsJXRDecoder();
|
||||
|
||||
virtual void InitInternal();
|
||||
@@ -60,6 +58,10 @@ public:
|
||||
virtual void FinishInternal();
|
||||
|
||||
private:
|
||||
friend class DecoderFactory;
|
||||
|
||||
// Decoders should only be instantiated via DecoderFactory.
|
||||
nsJXRDecoder(RasterImage* aImage, bool hasBeenDecoded);
|
||||
|
||||
tagPKImageDecode *m_pDecoder;
|
||||
tagPKFormatConverter *m_pConverter;
|
||||
|
||||
@@ -54,7 +54,7 @@ GetPNGDecoderAccountingLog()
|
||||
# define MOZ_PNG_MAX_PIX 268435456 // 256 Mpix = 16Ki x 16Ki
|
||||
#endif
|
||||
|
||||
// For size decodes
|
||||
// For metadata decodes.
|
||||
#define WIDTH_OFFSET 16
|
||||
#define HEIGHT_OFFSET (WIDTH_OFFSET + 4)
|
||||
#define BYTES_NEEDED_FOR_DIMENSIONS (HEIGHT_OFFSET + 4)
|
||||
@@ -122,6 +122,7 @@ nsPNGDecoder::nsPNGDecoder(RasterImage* aImage)
|
||||
mHeaderBytesRead(0), mCMSMode(0),
|
||||
mChannels(0), mFrameIsHidden(false),
|
||||
mDisablePremultipliedAlpha(false),
|
||||
mSuccessfulEarlyFinish(false),
|
||||
mNumFrames(0)
|
||||
{
|
||||
}
|
||||
@@ -183,9 +184,8 @@ nsPNGDecoder::CreateFrame(png_uint_32 aXOffset, png_uint_32 aYOffset,
|
||||
|
||||
MOZ_LOG(GetPNGDecoderAccountingLog(), LogLevel::Debug,
|
||||
("PNGDecoderAccounting: nsPNGDecoder::CreateFrame -- created "
|
||||
"image frame with %dx%d pixels in container %p",
|
||||
aWidth, aHeight,
|
||||
&mImage));
|
||||
"image frame with %dx%d pixels for decoder %p",
|
||||
aWidth, aHeight, this));
|
||||
|
||||
#ifdef PNG_APNG_SUPPORTED
|
||||
if (png_get_valid(mPNG, mInfo, PNG_INFO_acTL)) {
|
||||
@@ -233,8 +233,8 @@ nsPNGDecoder::EndImageFrame()
|
||||
void
|
||||
nsPNGDecoder::InitInternal()
|
||||
{
|
||||
// For size decodes, we don't need to initialize the png decoder
|
||||
if (IsSizeDecode()) {
|
||||
// For metadata decodes, we don't need to initialize the PNG decoder.
|
||||
if (IsMetadataDecode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -337,8 +337,8 @@ nsPNGDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
{
|
||||
MOZ_ASSERT(!HasError(), "Shouldn't call WriteInternal after error!");
|
||||
|
||||
// If we only want width/height, we don't need to go through libpng
|
||||
if (IsSizeDecode()) {
|
||||
// If we only want width/height, we don't need to go through libpng.
|
||||
if (IsMetadataDecode()) {
|
||||
|
||||
// Are we done?
|
||||
if (mHeaderBytesRead == BYTES_NEEDED_FOR_DIMENSIONS) {
|
||||
@@ -392,7 +392,7 @@ nsPNGDecoder::WriteInternal(const char* aBuffer, uint32_t aCount)
|
||||
|
||||
// We might not really know what caused the error, but it makes more
|
||||
// sense to blame the data.
|
||||
if (!HasError()) {
|
||||
if (!mSuccessfulEarlyFinish && !HasError()) {
|
||||
PostDataError();
|
||||
}
|
||||
|
||||
@@ -846,6 +846,14 @@ nsPNGDecoder::frame_info_callback(png_structp png_ptr, png_uint_32 frame_num)
|
||||
// old frame is done
|
||||
decoder->EndImageFrame();
|
||||
|
||||
if (!decoder->mFrameIsHidden && decoder->IsFirstFrameDecode()) {
|
||||
// We're about to get a second non-hidden frame, but we only want the first.
|
||||
// Stop decoding now.
|
||||
decoder->PostDecodeDone();
|
||||
decoder->mSuccessfulEarlyFinish = true;
|
||||
png_longjmp(decoder->mPNG, 1);
|
||||
}
|
||||
|
||||
// Only the first frame can be hidden, so unhide unconditionally here.
|
||||
decoder->mFrameIsHidden = false;
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ class RasterImage;
|
||||
class nsPNGDecoder : public Decoder
|
||||
{
|
||||
public:
|
||||
explicit nsPNGDecoder(RasterImage* aImage);
|
||||
virtual ~nsPNGDecoder();
|
||||
|
||||
virtual void InitInternal() override;
|
||||
@@ -67,6 +66,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
friend class DecoderFactory;
|
||||
friend class nsICODecoder;
|
||||
|
||||
// Decoders should only be instantiated via DecoderFactory.
|
||||
// XXX(seth): nsICODecoder is temporarily an exception to this rule.
|
||||
explicit nsPNGDecoder(RasterImage* aImage);
|
||||
|
||||
public:
|
||||
png_structp mPNG;
|
||||
png_infop mInfo;
|
||||
@@ -78,7 +85,7 @@ public:
|
||||
|
||||
gfx::SurfaceFormat format;
|
||||
|
||||
// For size decodes
|
||||
// For metadata decodes.
|
||||
uint8_t mSizeBytes[8]; // Space for width and height, both 4 bytes
|
||||
uint32_t mHeaderBytesRead;
|
||||
|
||||
@@ -88,6 +95,7 @@ public:
|
||||
uint8_t mChannels;
|
||||
bool mFrameIsHidden;
|
||||
bool mDisablePremultipliedAlpha;
|
||||
bool mSuccessfulEarlyFinish;
|
||||
|
||||
struct AnimFrameInfo
|
||||
{
|
||||
|
||||
@@ -65,7 +65,7 @@ nsWEBPDecoder::FinishInternal()
|
||||
MOZ_ASSERT(GetFrameCount() <= 1, "Multiple WebP frames?");
|
||||
|
||||
// Send notifications if appropriate
|
||||
if (!IsSizeDecode() && (GetFrameCount() == 1)) {
|
||||
if (!IsMetadataDecode() && (GetFrameCount() == 1)) {
|
||||
PostFrameStop();
|
||||
PostDecodeDone();
|
||||
}
|
||||
@@ -115,7 +115,7 @@ nsWEBPDecoder::WriteInternal(const char *aBuffer, uint32_t aCount)
|
||||
if (!HasSize())
|
||||
PostSize(width, height);
|
||||
|
||||
if (IsSizeDecode())
|
||||
if (IsMetadataDecode())
|
||||
return;
|
||||
|
||||
// The only valid format for WebP decoding for both alpha and non-alpha
|
||||
|
||||
@@ -21,13 +21,17 @@ class RasterImage;
|
||||
class nsWEBPDecoder : public Decoder
|
||||
{
|
||||
public:
|
||||
nsWEBPDecoder(RasterImage* aImage);
|
||||
~nsWEBPDecoder() override;
|
||||
virtual ~nsWEBPDecoder();
|
||||
|
||||
void InitInternal() override;
|
||||
void WriteInternal(const char* aBuffer, uint32_t aCount) override;
|
||||
void FinishInternal() override;
|
||||
private:
|
||||
friend class DecoderFactory;
|
||||
|
||||
// Decoders should only be instantiated via DecoderFactory.
|
||||
explicit nsWEBPDecoder(RasterImage* aImage);
|
||||
|
||||
WebPIDecoder *mDecoder;
|
||||
uint8_t *mData; // Pointer to WebP-decoded data.
|
||||
int mPreviousLastLine; // Last image scan-line read so far.
|
||||
|
||||
@@ -238,7 +238,6 @@ nsJPEGEncoder::EndImageEncode()
|
||||
}
|
||||
|
||||
|
||||
/* void close (); */
|
||||
NS_IMETHODIMP
|
||||
nsJPEGEncoder::Close()
|
||||
{
|
||||
@@ -252,7 +251,6 @@ nsJPEGEncoder::Close()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* unsigned long available (); */
|
||||
NS_IMETHODIMP
|
||||
nsJPEGEncoder::Available(uint64_t* _retval)
|
||||
{
|
||||
@@ -264,7 +262,6 @@ nsJPEGEncoder::Available(uint64_t* _retval)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] unsigned long read (in charPtr aBuf, in unsigned long aCount); */
|
||||
NS_IMETHODIMP
|
||||
nsJPEGEncoder::Read(char* aBuf, uint32_t aCount, uint32_t* _retval)
|
||||
{
|
||||
@@ -302,7 +299,6 @@ nsJPEGEncoder::ReadSegments(nsWriteSegmentFun aWriter,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isNonBlocking (); */
|
||||
NS_IMETHODIMP
|
||||
nsJPEGEncoder::IsNonBlocking(bool* _retval)
|
||||
{
|
||||
|
||||
@@ -524,7 +524,6 @@ nsPNGEncoder::ParseOptions(const nsAString& aOptions,
|
||||
}
|
||||
|
||||
|
||||
/* void close (); */
|
||||
NS_IMETHODIMP
|
||||
nsPNGEncoder::Close()
|
||||
{
|
||||
@@ -538,7 +537,6 @@ nsPNGEncoder::Close()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* unsigned long available (); */
|
||||
NS_IMETHODIMP
|
||||
nsPNGEncoder::Available(uint64_t* _retval)
|
||||
{
|
||||
@@ -592,7 +590,6 @@ nsPNGEncoder::ReadSegments(nsWriteSegmentFun aWriter,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isNonBlocking (); */
|
||||
NS_IMETHODIMP
|
||||
nsPNGEncoder::IsNonBlocking(bool* _retval)
|
||||
{
|
||||
|
||||
+2
-2
@@ -140,12 +140,12 @@ imgFrame::imgFrame()
|
||||
, mBlendMethod(BlendMethod::OVER)
|
||||
, mHasNoAlpha(false)
|
||||
, mAborted(false)
|
||||
, mOptimizable(false)
|
||||
, mPalettedImageData(nullptr)
|
||||
, mPaletteDepth(0)
|
||||
, mNonPremult(false)
|
||||
, mSinglePixel(false)
|
||||
, mCompositingFailed(false)
|
||||
, mOptimizable(false)
|
||||
{
|
||||
static bool hasCheckedOptimize = false;
|
||||
if (!hasCheckedOptimize) {
|
||||
@@ -958,8 +958,8 @@ imgFrame::UnlockImageData()
|
||||
void
|
||||
imgFrame::SetOptimizable()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
AssertImageDataLocked();
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
mOptimizable = true;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -342,6 +342,7 @@ private: // data
|
||||
|
||||
bool mHasNoAlpha;
|
||||
bool mAborted;
|
||||
bool mOptimizable;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -371,7 +372,6 @@ private: // data
|
||||
|
||||
bool mSinglePixel;
|
||||
bool mCompositingFailed;
|
||||
bool mOptimizable;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+3
-6
@@ -41,6 +41,7 @@
|
||||
#include "nsIApplicationCacheContainer.h"
|
||||
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "DecoderFactory.h"
|
||||
#include "Image.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "prtime.h"
|
||||
@@ -1365,7 +1366,6 @@ void imgLoader::ReadAcceptHeaderPref()
|
||||
}
|
||||
}
|
||||
|
||||
/* void clearCache (in boolean chrome); */
|
||||
NS_IMETHODIMP
|
||||
imgLoader::ClearCache(bool chrome)
|
||||
{
|
||||
@@ -1376,7 +1376,6 @@ imgLoader::ClearCache(bool chrome)
|
||||
}
|
||||
}
|
||||
|
||||
/* void removeEntry(in nsIURI uri); */
|
||||
NS_IMETHODIMP
|
||||
imgLoader::RemoveEntry(nsIURI* aURI)
|
||||
{
|
||||
@@ -1387,7 +1386,6 @@ imgLoader::RemoveEntry(nsIURI* aURI)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
/* imgIRequest findEntry(in nsIURI uri); */
|
||||
NS_IMETHODIMP
|
||||
imgLoader::FindEntryProperties(nsIURI* uri, nsIProperties** _retval)
|
||||
{
|
||||
@@ -2544,7 +2542,8 @@ imgLoader::SupportImageWithMimeType(const char* aMimeType,
|
||||
return true;
|
||||
}
|
||||
|
||||
return Image::GetDecoderType(mimeType.get()) != Image::eDecoderType_unknown;
|
||||
DecoderType type = DecoderFactory::GetDecoderType(mimeType.get());
|
||||
return type != DecoderType::UNKNOWN;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@@ -2820,7 +2819,6 @@ ProxyListener::~ProxyListener()
|
||||
|
||||
/** nsIRequestObserver methods **/
|
||||
|
||||
/* void onStartRequest (in nsIRequest request, in nsISupports ctxt); */
|
||||
NS_IMETHODIMP
|
||||
ProxyListener::OnStartRequest(nsIRequest* aRequest, nsISupports* ctxt)
|
||||
{
|
||||
@@ -2973,7 +2971,6 @@ imgCacheValidator::RemoveProxy(imgRequestProxy* aProxy)
|
||||
|
||||
/** nsIRequestObserver methods **/
|
||||
|
||||
/* void onStartRequest (in nsIRequest request, in nsISupports ctxt); */
|
||||
NS_IMETHODIMP
|
||||
imgCacheValidator::OnStartRequest(nsIRequest* aRequest, nsISupports* ctxt)
|
||||
{
|
||||
|
||||
@@ -714,7 +714,6 @@ imgRequest::GetMultipart() const
|
||||
|
||||
/** nsIRequestObserver methods **/
|
||||
|
||||
/* void onStartRequest (in nsIRequest request, in nsISupports ctxt); */
|
||||
NS_IMETHODIMP
|
||||
imgRequest::OnStartRequest(nsIRequest* aRequest, nsISupports* ctxt)
|
||||
{
|
||||
|
||||
@@ -281,7 +281,6 @@ imgRequestProxy::RemoveFromLoadGroup(bool releaseLoadGroup)
|
||||
|
||||
/** nsIRequest / imgIRequest methods **/
|
||||
|
||||
/* readonly attribute wstring name; */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetName(nsACString& aName)
|
||||
{
|
||||
@@ -294,21 +293,18 @@ imgRequestProxy::GetName(nsACString& aName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean isPending (); */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::IsPending(bool* _retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* readonly attribute nsresult status; */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetStatus(nsresult* aStatus)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void cancel (in nsresult status); */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::Cancel(nsresult status)
|
||||
{
|
||||
@@ -334,7 +330,6 @@ imgRequestProxy::DoCancel(nsresult status)
|
||||
NullOutListener();
|
||||
}
|
||||
|
||||
/* void cancelAndForgetObserver (in nsresult aStatus); */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::CancelAndForgetObserver(nsresult aStatus)
|
||||
{
|
||||
@@ -378,7 +373,6 @@ imgRequestProxy::CancelAndForgetObserver(nsresult aStatus)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void startDecode (); */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::StartDecoding()
|
||||
{
|
||||
@@ -397,7 +391,6 @@ imgRequestProxy::StartDecoding()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void requestDecode (); */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::RequestDecode()
|
||||
{
|
||||
@@ -417,7 +410,6 @@ imgRequestProxy::RequestDecode()
|
||||
}
|
||||
|
||||
|
||||
/* void lockImage (); */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::LockImage()
|
||||
{
|
||||
@@ -429,7 +421,6 @@ imgRequestProxy::LockImage()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void unlockImage (); */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::UnlockImage()
|
||||
{
|
||||
@@ -443,7 +434,6 @@ imgRequestProxy::UnlockImage()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void requestDiscard (); */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::RequestDiscard()
|
||||
{
|
||||
@@ -492,21 +482,18 @@ imgRequestProxy::ClearAnimationConsumers()
|
||||
}
|
||||
}
|
||||
|
||||
/* void suspend (); */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::Suspend()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void resume (); */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::Resume()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* attribute nsILoadGroup loadGroup */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetLoadGroup(nsILoadGroup** loadGroup)
|
||||
{
|
||||
@@ -520,7 +507,6 @@ imgRequestProxy::SetLoadGroup(nsILoadGroup* loadGroup)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute nsLoadFlags loadFlags */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetLoadFlags(nsLoadFlags* flags)
|
||||
{
|
||||
@@ -536,7 +522,6 @@ imgRequestProxy::SetLoadFlags(nsLoadFlags flags)
|
||||
|
||||
/** imgIRequest methods **/
|
||||
|
||||
/* attribute imgIContainer image; */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetImage(imgIContainer** aImage)
|
||||
{
|
||||
@@ -562,7 +547,6 @@ imgRequestProxy::GetImage(imgIContainer** aImage)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long imageStatus; */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetImageStatus(uint32_t* aStatus)
|
||||
{
|
||||
@@ -572,7 +556,6 @@ imgRequestProxy::GetImageStatus(uint32_t* aStatus)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nresult imageErrorCode; */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetImageErrorCode(nsresult* aStatus)
|
||||
{
|
||||
@@ -585,7 +568,6 @@ imgRequestProxy::GetImageErrorCode(nsresult* aStatus)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIURI URI; */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetURI(nsIURI** aURI)
|
||||
{
|
||||
@@ -617,7 +599,6 @@ imgRequestProxy::GetURI(ImageURL** aURI)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute imgINotificationObserver notificationObserver; */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetNotificationObserver(imgINotificationObserver** aObserver)
|
||||
{
|
||||
@@ -626,7 +607,6 @@ imgRequestProxy::GetNotificationObserver(imgINotificationObserver** aObserver)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute string mimeType; */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetMimeType(char** aMimeType)
|
||||
{
|
||||
@@ -716,7 +696,6 @@ imgRequestProxy::PerformClone(imgINotificationObserver* aObserver,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIPrincipal imagePrincipal; */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetImagePrincipal(nsIPrincipal** aPrincipal)
|
||||
{
|
||||
@@ -728,7 +707,6 @@ imgRequestProxy::GetImagePrincipal(nsIPrincipal** aPrincipal)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute bool multipart; */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetMultipart(bool* aMultipart)
|
||||
{
|
||||
@@ -741,7 +719,6 @@ imgRequestProxy::GetMultipart(bool* aMultipart)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute int32_t CORSMode; */
|
||||
NS_IMETHODIMP
|
||||
imgRequestProxy::GetCORSMode(int32_t* aCorsMode)
|
||||
{
|
||||
|
||||
@@ -61,6 +61,8 @@ imgTools::DecodeImage(nsIInputStream* aInStr,
|
||||
const nsACString& aMimeType,
|
||||
imgIContainer** aContainer)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsresult rv;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aInStr);
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DIRS += ['build', 'decoders', 'encoders']
|
||||
if CONFIG['ENABLE_TESTS']:
|
||||
DIRS += ['test/gtest']
|
||||
|
||||
with Files('**'):
|
||||
BUG_COMPONENT = ('Core', 'ImageLib')
|
||||
|
||||
BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini']
|
||||
|
||||
@@ -49,6 +54,7 @@ UNIFIED_SOURCES += [
|
||||
'ClippedImage.cpp',
|
||||
'DecodePool.cpp',
|
||||
'Decoder.cpp',
|
||||
'DecoderFactory.cpp',
|
||||
'DynamicImage.cpp',
|
||||
'FrameAnimator.cpp',
|
||||
'FrozenImage.cpp',
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIProperties.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "mozilla/nsRefPtr.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
using namespace gfx;
|
||||
|
||||
using std::abs;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Helpers
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// These macros work like gtest's ASSERT_* macros, except that they can be used
|
||||
// in functions that return values.
|
||||
#define ASSERT_TRUE_OR_RETURN(e, rv) \
|
||||
EXPECT_TRUE(e); \
|
||||
if (!(e)) { \
|
||||
return rv; \
|
||||
}
|
||||
|
||||
#define ASSERT_EQ_OR_RETURN(a, b, rv) \
|
||||
EXPECT_EQ(a, b); \
|
||||
if ((a) != (b)) { \
|
||||
return rv; \
|
||||
}
|
||||
|
||||
#define ASSERT_LE_OR_RETURN(a, b, rv) \
|
||||
EXPECT_LE(a, b); \
|
||||
if (!((a) <= (b))) { \
|
||||
return rv; \
|
||||
}
|
||||
|
||||
already_AddRefed<nsIInputStream>
|
||||
LoadFile(const char* aRelativePath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIProperties> dirService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
|
||||
ASSERT_TRUE_OR_RETURN(dirService != nullptr, nullptr);
|
||||
|
||||
// Retrieve the current working directory.
|
||||
nsCOMPtr<nsIFile> file;
|
||||
rv = dirService->Get(NS_OS_CURRENT_WORKING_DIR,
|
||||
NS_GET_IID(nsIFile), getter_AddRefs(file));
|
||||
ASSERT_TRUE_OR_RETURN(NS_SUCCEEDED(rv), nullptr);
|
||||
|
||||
// Construct the final path by appending the working path to the current
|
||||
// working directory.
|
||||
file->AppendNative(nsAutoCString(aRelativePath));
|
||||
|
||||
// Construct an input stream for the requested file.
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream), file);
|
||||
ASSERT_TRUE_OR_RETURN(NS_SUCCEEDED(rv), nullptr);
|
||||
|
||||
return inputStream.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
IsSolidColor(SourceSurface* aSurface, BGRAColor aColor, bool aFuzzy)
|
||||
{
|
||||
nsRefPtr<DataSourceSurface> dataSurface = aSurface->GetDataSurface();
|
||||
ASSERT_TRUE_OR_RETURN(dataSurface != nullptr, false);
|
||||
|
||||
ASSERT_EQ_OR_RETURN(dataSurface->Stride(), aSurface->GetSize().width * 4,
|
||||
false);
|
||||
|
||||
DataSourceSurface::ScopedMap mapping(dataSurface,
|
||||
DataSourceSurface::MapType::READ);
|
||||
ASSERT_TRUE_OR_RETURN(mapping.IsMapped(), false);
|
||||
|
||||
uint8_t* data = dataSurface->GetData();
|
||||
ASSERT_TRUE_OR_RETURN(data != nullptr, false);
|
||||
|
||||
int32_t length = dataSurface->Stride() * aSurface->GetSize().height;
|
||||
for (int32_t i = 0 ; i < length ; i += 4) {
|
||||
if (aFuzzy) {
|
||||
ASSERT_LE_OR_RETURN(abs(aColor.mBlue - data[i + 0]), 1, false);
|
||||
ASSERT_LE_OR_RETURN(abs(aColor.mGreen - data[i + 1]), 1, false);
|
||||
ASSERT_LE_OR_RETURN(abs(aColor.mRed - data[i + 2]), 1, false);
|
||||
ASSERT_LE_OR_RETURN(abs(aColor.mAlpha - data[i + 3]), 1, false);
|
||||
} else {
|
||||
ASSERT_EQ_OR_RETURN(aColor.mBlue, data[i + 0], false);
|
||||
ASSERT_EQ_OR_RETURN(aColor.mGreen, data[i + 1], false);
|
||||
ASSERT_EQ_OR_RETURN(aColor.mRed, data[i + 2], false);
|
||||
ASSERT_EQ_OR_RETURN(aColor.mAlpha, data[i + 3], false);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Test Data
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ImageTestCase GreenPNGTestCase()
|
||||
{
|
||||
return ImageTestCase("green.png", "image/png", IntSize(100, 100));
|
||||
}
|
||||
|
||||
ImageTestCase GreenGIFTestCase()
|
||||
{
|
||||
return ImageTestCase("green.gif", "image/gif", IntSize(100, 100));
|
||||
}
|
||||
|
||||
ImageTestCase GreenJPGTestCase()
|
||||
{
|
||||
return ImageTestCase("green.jpg", "image/jpeg", IntSize(100, 100),
|
||||
/* aFuzzy = */ true);
|
||||
}
|
||||
|
||||
ImageTestCase GreenBMPTestCase()
|
||||
{
|
||||
return ImageTestCase("green.bmp", "image/bmp", IntSize(100, 100));
|
||||
}
|
||||
|
||||
ImageTestCase GreenICOTestCase()
|
||||
{
|
||||
return ImageTestCase("green.ico", "image/x-icon", IntSize(100, 100));
|
||||
}
|
||||
|
||||
ImageTestCase GreenFirstFrameAnimatedGIFTestCase()
|
||||
{
|
||||
return ImageTestCase("first-frame-green.gif", "image/gif", IntSize(100, 100));
|
||||
}
|
||||
|
||||
ImageTestCase GreenFirstFrameAnimatedPNGTestCase()
|
||||
{
|
||||
return ImageTestCase("first-frame-green.png", "image/png", IntSize(100, 100));
|
||||
}
|
||||
|
||||
ImageTestCase CorruptTestCase()
|
||||
{
|
||||
return ImageTestCase("corrupt.jpg", "image/jpeg", IntSize(100, 100));
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
@@ -0,0 +1,91 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_image_test_gtest_Common_h
|
||||
#define mozilla_image_test_gtest_Common_h
|
||||
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIInputStream;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Types
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct ImageTestCase
|
||||
{
|
||||
ImageTestCase(const char* aPath,
|
||||
const char* aMimeType,
|
||||
gfx::IntSize aSize,
|
||||
bool aFuzzy = false)
|
||||
: mPath(aPath)
|
||||
, mMimeType(aMimeType)
|
||||
, mSize(aSize)
|
||||
, mFuzzy(aFuzzy)
|
||||
{ }
|
||||
|
||||
const char* mPath;
|
||||
const char* mMimeType;
|
||||
gfx::IntSize mSize;
|
||||
bool mFuzzy;
|
||||
};
|
||||
|
||||
struct BGRAColor
|
||||
{
|
||||
BGRAColor(uint8_t aBlue, uint8_t aGreen, uint8_t aRed, uint8_t aAlpha)
|
||||
: mBlue(aBlue)
|
||||
, mGreen(aGreen)
|
||||
, mRed(aRed)
|
||||
, mAlpha(aAlpha)
|
||||
{ }
|
||||
|
||||
static BGRAColor Green() { return BGRAColor(0x00, 0xFF, 0x00, 0xFF); }
|
||||
|
||||
uint8_t mBlue;
|
||||
uint8_t mGreen;
|
||||
uint8_t mRed;
|
||||
uint8_t mAlpha;
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Helpers
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Loads a file from the current directory. @return an nsIInputStream for it.
|
||||
already_AddRefed<nsIInputStream> LoadFile(const char* aRelativePath);
|
||||
|
||||
/**
|
||||
* @returns true if every pixel of @aSurface is @aColor.
|
||||
*
|
||||
* If @aFuzzy is true, a tolerance of 1 is allowed in each color component. This
|
||||
* may be necessary for tests that involve JPEG images.
|
||||
*/
|
||||
bool IsSolidColor(gfx::SourceSurface* aSurface,
|
||||
BGRAColor aColor,
|
||||
bool aFuzzy = false);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Test Data
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ImageTestCase GreenPNGTestCase();
|
||||
ImageTestCase GreenGIFTestCase();
|
||||
ImageTestCase GreenJPGTestCase();
|
||||
ImageTestCase GreenBMPTestCase();
|
||||
ImageTestCase GreenICOTestCase();
|
||||
|
||||
ImageTestCase GreenFirstFrameAnimatedGIFTestCase();
|
||||
ImageTestCase GreenFirstFrameAnimatedPNGTestCase();
|
||||
|
||||
ImageTestCase CorruptTestCase();
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_image_test_gtest_Common_h
|
||||
@@ -0,0 +1,119 @@
|
||||
/* 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 "gtest/gtest.h"
|
||||
|
||||
#include "Common.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "imgITools.h"
|
||||
#include "ImageOps.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsIThread.h"
|
||||
#include "mozilla/nsRefPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::image;
|
||||
|
||||
|
||||
TEST(ImageDecodeToSurface, ImageModuleAvailable)
|
||||
{
|
||||
// We can run into problems if XPCOM modules get initialized in the wrong
|
||||
// order. It's important that this test run first, both as a sanity check and
|
||||
// to ensure we get the module initialization order we want.
|
||||
nsCOMPtr<imgITools> imgTools =
|
||||
do_CreateInstance("@mozilla.org/image/tools;1");
|
||||
EXPECT_TRUE(imgTools != nullptr);
|
||||
}
|
||||
|
||||
class DecodeToSurfaceRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
DecodeToSurfaceRunnable(nsIInputStream* aInputStream,
|
||||
const ImageTestCase& aTestCase)
|
||||
: mInputStream(aInputStream)
|
||||
, mTestCase(aTestCase)
|
||||
{ }
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
Go();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void Go()
|
||||
{
|
||||
nsRefPtr<SourceSurface> surface =
|
||||
ImageOps::DecodeToSurface(mInputStream,
|
||||
nsAutoCString(mTestCase.mMimeType),
|
||||
imgIContainer::DECODE_FLAGS_DEFAULT);
|
||||
ASSERT_TRUE(surface != nullptr);
|
||||
|
||||
EXPECT_EQ(SurfaceType::DATA, surface->GetType());
|
||||
EXPECT_TRUE(surface->GetFormat() == SurfaceFormat::B8G8R8X8 ||
|
||||
surface->GetFormat() == SurfaceFormat::B8G8R8A8);
|
||||
EXPECT_EQ(mTestCase.mSize, surface->GetSize());
|
||||
|
||||
EXPECT_TRUE(IsSolidColor(surface, BGRAColor::Green(), mTestCase.mFuzzy));
|
||||
}
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIInputStream> mInputStream;
|
||||
ImageTestCase mTestCase;
|
||||
};
|
||||
|
||||
static void
|
||||
RunDecodeToSurface(const ImageTestCase& aTestCase)
|
||||
{
|
||||
nsCOMPtr<nsIInputStream> inputStream = LoadFile(aTestCase.mPath);
|
||||
ASSERT_TRUE(inputStream != nullptr);
|
||||
|
||||
nsCOMPtr<nsIThread> thread;
|
||||
nsresult rv = NS_NewThread(getter_AddRefs(thread), nullptr);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
|
||||
// We run the DecodeToSurface tests off-main-thread to ensure that
|
||||
// DecodeToSurface doesn't require any main-thread-only code.
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
new DecodeToSurfaceRunnable(inputStream, aTestCase);
|
||||
thread->Dispatch(runnable, nsIThread::DISPATCH_SYNC);
|
||||
|
||||
thread->Shutdown();
|
||||
}
|
||||
|
||||
TEST(ImageDecodeToSurface, PNG) { RunDecodeToSurface(GreenPNGTestCase()); }
|
||||
TEST(ImageDecodeToSurface, GIF) { RunDecodeToSurface(GreenGIFTestCase()); }
|
||||
TEST(ImageDecodeToSurface, JPG) { RunDecodeToSurface(GreenJPGTestCase()); }
|
||||
TEST(ImageDecodeToSurface, BMP) { RunDecodeToSurface(GreenBMPTestCase()); }
|
||||
TEST(ImageDecodeToSurface, ICO) { RunDecodeToSurface(GreenICOTestCase()); }
|
||||
|
||||
TEST(ImageDecodeToSurface, AnimatedGIF)
|
||||
{
|
||||
RunDecodeToSurface(GreenFirstFrameAnimatedGIFTestCase());
|
||||
}
|
||||
|
||||
TEST(ImageDecodeToSurface, AnimatedPNG)
|
||||
{
|
||||
RunDecodeToSurface(GreenFirstFrameAnimatedPNGTestCase());
|
||||
}
|
||||
|
||||
TEST(ImageDecodeToSurface, Corrupt)
|
||||
{
|
||||
ImageTestCase testCase = CorruptTestCase();
|
||||
|
||||
nsCOMPtr<nsIInputStream> inputStream = LoadFile(testCase.mPath);
|
||||
ASSERT_TRUE(inputStream != nullptr);
|
||||
|
||||
nsRefPtr<SourceSurface> surface =
|
||||
ImageOps::DecodeToSurface(inputStream,
|
||||
nsAutoCString(testCase.mMimeType),
|
||||
imgIContainer::DECODE_FLAGS_DEFAULT);
|
||||
EXPECT_TRUE(surface == nullptr);
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 317 B |
Binary file not shown.
|
After Width: | Height: | Size: 364 B |
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 156 B |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user