зеркало из https://github.com/mozilla/pjs.git
Bug 253851: wait for background image loads before firing onload (match behavior of IE/Safari/Opera), r+sr=dbaron
This commit is contained in:
Родитель
870a35b0ca
Коммит
c5fce4809d
|
@ -2388,7 +2388,7 @@ nsGenericHTMLElement::MapBackgroundInto(const nsMappedAttributes* aAttributes,
|
|||
// in the mapped attrs or something?)
|
||||
nsCSSValue::Image *img =
|
||||
new nsCSSValue::Image(uri, buffer, doc->GetDocumentURI(),
|
||||
doc->NodePrincipal(), doc, PR_TRUE);
|
||||
doc->NodePrincipal(), doc);
|
||||
buffer->Release();
|
||||
if (NS_LIKELY(img != 0)) {
|
||||
aData->mColorData->mBackImage.SetImageValue(img);
|
||||
|
|
|
@ -210,8 +210,7 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
|
|||
if ((iProp == eCSSProperty_background_image ||
|
||||
iProp == eCSSProperty_list_style_image) &&
|
||||
val->GetUnit() == eCSSUnit_URL) {
|
||||
val->StartImageLoad(aRuleData->mPresContext->Document(),
|
||||
iProp == eCSSProperty_background_image);
|
||||
val->StartImageLoad(aRuleData->mPresContext->Document());
|
||||
}
|
||||
*target = *val;
|
||||
if (iProp == eCSSProperty_font_family) {
|
||||
|
|
|
@ -355,7 +355,7 @@ void nsCSSValue::SetSystemFontValue()
|
|||
mUnit = eCSSUnit_System_Font;
|
||||
}
|
||||
|
||||
void nsCSSValue::StartImageLoad(nsIDocument* aDocument, PRBool aIsBGImage) const
|
||||
void nsCSSValue::StartImageLoad(nsIDocument* aDocument) const
|
||||
{
|
||||
NS_PRECONDITION(eCSSUnit_URL == mUnit, "Not a URL value!");
|
||||
nsCSSValue::Image* image =
|
||||
|
@ -363,7 +363,7 @@ void nsCSSValue::StartImageLoad(nsIDocument* aDocument, PRBool aIsBGImage) const
|
|||
mValue.mURL->mString,
|
||||
mValue.mURL->mReferrer,
|
||||
mValue.mURL->mOriginPrincipal,
|
||||
aDocument, aIsBGImage);
|
||||
aDocument);
|
||||
if (image) {
|
||||
nsCSSValue* writable = NS_CONST_CAST(nsCSSValue*, this);
|
||||
writable->SetImageValue(image);
|
||||
|
@ -429,28 +429,15 @@ nsCSSValue::URL::operator==(const URL& aOther) const
|
|||
|
||||
nsCSSValue::Image::Image(nsIURI* aURI, nsStringBuffer* aString,
|
||||
nsIURI* aReferrer, nsIPrincipal* aOriginPrincipal,
|
||||
nsIDocument* aDocument, PRBool aIsBGImage)
|
||||
nsIDocument* aDocument)
|
||||
: URL(aURI, aString, aReferrer, aOriginPrincipal)
|
||||
{
|
||||
MOZ_COUNT_CTOR(nsCSSValue::Image);
|
||||
|
||||
// If the pref is enabled, force all background image loads to
|
||||
// complete before firing onload for the document. Otherwise, background
|
||||
// image loads are special and don't block onload.
|
||||
PRInt32 loadFlag = (PRInt32)nsIRequest::LOAD_NORMAL;
|
||||
if (aIsBGImage) {
|
||||
static PRBool onloadAfterImageBackgroundLoads =
|
||||
nsContentUtils::GetBoolPref
|
||||
("layout.fire_onload_after_image_background_loads");
|
||||
if (!onloadAfterImageBackgroundLoads) {
|
||||
loadFlag = (PRInt32)nsIRequest::LOAD_BACKGROUND;
|
||||
}
|
||||
}
|
||||
|
||||
if (mURI &&
|
||||
nsContentUtils::CanLoadImage(mURI, aDocument, aDocument)) {
|
||||
nsContentUtils::LoadImage(mURI, aDocument, aReferrer, nsnull,
|
||||
loadFlag,
|
||||
nsIRequest::LOAD_NORMAL,
|
||||
getter_AddRefs(mRequest));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,8 +277,7 @@ public:
|
|||
NS_HIDDEN_(void) SetNoneValue();
|
||||
NS_HIDDEN_(void) SetNormalValue();
|
||||
NS_HIDDEN_(void) SetSystemFontValue();
|
||||
NS_HIDDEN_(void) StartImageLoad(nsIDocument* aDocument,
|
||||
PRBool aIsBGImage = PR_FALSE)
|
||||
NS_HIDDEN_(void) StartImageLoad(nsIDocument* aDocument)
|
||||
const; // Not really const, but pretending
|
||||
|
||||
// Returns an already addrefed buffer. Can return null on allocation
|
||||
|
@ -407,8 +406,7 @@ public:
|
|||
// this header is included all over.
|
||||
// aString must not be null.
|
||||
Image(nsIURI* aURI, nsStringBuffer* aString, nsIURI* aReferrer,
|
||||
nsIPrincipal* aOriginPrincipal, nsIDocument* aDocument,
|
||||
PRBool aIsBGImage = PR_FALSE) NS_HIDDEN;
|
||||
nsIPrincipal* aOriginPrincipal, nsIDocument* aDocument) NS_HIDDEN;
|
||||
~Image() NS_HIDDEN;
|
||||
|
||||
// Inherit operator== from nsCSSValue::URL
|
||||
|
|
Загрузка…
Ссылка в новой задаче