mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 666446, Part 3/18 - Create hook functions in nsLayoutUtils to coalesce some of the new code for frame-like objects and avoid code duplication. [r=roc]
This commit is contained in:
parent
cd06eebd31
commit
6b33216408
@ -4292,6 +4292,102 @@ nsLayoutUtils::Shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
nsLayoutUtils::RegisterImageRequest(nsPresContext* aPresContext,
|
||||
imgIRequest* aRequest,
|
||||
bool* aRequestRegistered)
|
||||
{
|
||||
if (!aPresContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aRequestRegistered && *aRequestRegistered) {
|
||||
// Our request is already registered with the refresh driver, so
|
||||
// no need to register it again.
|
||||
return;
|
||||
}
|
||||
|
||||
if (aRequest) {
|
||||
nsCOMPtr<imgIContainer> image;
|
||||
aRequest->GetImage(getter_AddRefs(image));
|
||||
if (image) {
|
||||
if (!aPresContext->RefreshDriver()->AddImageRequest(aRequest)) {
|
||||
NS_WARNING("Unable to add image request");
|
||||
return;
|
||||
}
|
||||
|
||||
if (aRequestRegistered) {
|
||||
*aRequestRegistered = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
nsLayoutUtils::DeregisterImageRequest(nsPresContext* aPresContext,
|
||||
imgIRequest* aRequest,
|
||||
bool* aRequestRegistered)
|
||||
{
|
||||
if (!aPresContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Deregister our imgIRequest with the refresh driver to
|
||||
// complete tear-down, but only if it has been registered
|
||||
if (aRequestRegistered && !*aRequestRegistered) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aRequest) {
|
||||
nsCOMPtr<imgIContainer> image;
|
||||
aRequest->GetImage(getter_AddRefs(image));
|
||||
if (image) {
|
||||
aPresContext->RefreshDriver()->RemoveImageRequest(aRequest);
|
||||
|
||||
if (aRequestRegistered) {
|
||||
*aRequestRegistered = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
nsLayoutUtils::DeregisterImageRequestIfNotAnimated(nsPresContext* aPresContext,
|
||||
imgIRequest* aRequest,
|
||||
bool* aRequestRegistered)
|
||||
{
|
||||
if (!aPresContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aRequestRegistered && !*aRequestRegistered) {
|
||||
// Image request isn't registered with the refresh driver - no need
|
||||
// to try and deregister it.
|
||||
return;
|
||||
}
|
||||
|
||||
// Deregister the imgIRequest with the refresh driver if the
|
||||
// image is not animated
|
||||
nsCOMPtr<imgIContainer> imageContainer;
|
||||
if (aRequest) {
|
||||
aRequest->GetImage(getter_AddRefs(imageContainer));
|
||||
bool animated;
|
||||
|
||||
if (!imageContainer) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv = imageContainer->GetAnimated(&animated);
|
||||
if (NS_SUCCEEDED(rv) && !animated) {
|
||||
nsLayoutUtils::DeregisterImageRequest(aPresContext, aRequest,
|
||||
aRequestRegistered);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsSetAttrRunnable::nsSetAttrRunnable(nsIContent* aContent, nsIAtom* aAttrName,
|
||||
const nsAString& aValue)
|
||||
: mContent(aContent),
|
||||
|
@ -1440,6 +1440,63 @@ public:
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
/**
|
||||
* Register an imgIRequest object with a refresh driver.
|
||||
*
|
||||
* @param aPresContext The nsPresContext whose refresh driver we want to
|
||||
* register with.
|
||||
* @param aRequest A pointer to the imgIRequest object which the client wants
|
||||
* to register with the refresh driver.
|
||||
* @param aRequestRegistered A pointer to a boolean value which indicates
|
||||
* whether the given image request is registered. If
|
||||
* *aRequestRegistered is true, then this request will not be
|
||||
* registered again. If the request is registered by this function,
|
||||
* then *aRequestRegistered will be set to true upon the completion of
|
||||
* this function.
|
||||
*
|
||||
*/
|
||||
static void RegisterImageRequest(nsPresContext* aPresContext,
|
||||
imgIRequest* aRequest,
|
||||
bool* aRequestRegistered);
|
||||
/**
|
||||
* Deregister an imgIRequest object from a refresh driver.
|
||||
*
|
||||
* @param aPresContext The nsPresContext whose refresh driver we want to
|
||||
* deregister from.
|
||||
* @param aRequest A pointer to the imgIRequest object with which the client
|
||||
* previously registered and now wants to deregister from the refresh
|
||||
* driver.
|
||||
* @param aRequestRegistered A pointer to a boolean value which indicates
|
||||
* whether the given image request is registered. If
|
||||
* *aRequestRegistered is false, then this request will not be
|
||||
* deregistered. If the request is deregistered by this function,
|
||||
* then *aRequestRegistered will be set to false upon the completion of
|
||||
* this function.
|
||||
*/
|
||||
static void DeregisterImageRequest(nsPresContext* aPresContext,
|
||||
imgIRequest* aRequest,
|
||||
bool* aRequestRegistered);
|
||||
/**
|
||||
* Deregister an imgIRequest object from a refresh driver, if the
|
||||
* imgIRequest object represents a static (i.e. not animated) image.
|
||||
*
|
||||
* @param aPresContext The nsPresContext whose refresh driver we want to
|
||||
* deregister from.
|
||||
* @param aRequest A pointer to the imgIRequest object with which the client
|
||||
* previously registered and now wants to deregister from the refresh
|
||||
* driver.
|
||||
* @param aRequestRegistered A pointer to a boolean value which indicates
|
||||
* whether the given image request is registered. If
|
||||
* *aRequestRegistered is false, then this request will not be
|
||||
* deregistered. If the request is deregistered by this function,
|
||||
* then *aRequestRegistered will be set to false upon the completion of
|
||||
* this function.
|
||||
*/
|
||||
|
||||
static void DeregisterImageRequestIfNotAnimated(nsPresContext* aPresContext,
|
||||
imgIRequest* aRequest,
|
||||
bool* aRequestRegistered);
|
||||
|
||||
#ifdef DEBUG
|
||||
/**
|
||||
* Assert that there are no duplicate continuations of the same frame
|
||||
|
Loading…
Reference in New Issue
Block a user