зеркало из https://github.com/mozilla/gecko-dev.git
Back out 236889 due to 253755.
This commit is contained in:
Родитель
6686a8f05a
Коммит
1236bd859f
|
@ -3517,8 +3517,8 @@ nsRuleNode::ComputeListData(nsStyleStruct* aStartStruct,
|
|||
}
|
||||
|
||||
// list-style-image: url, none, inherit
|
||||
if (eCSSUnit_Image == listData.mImage.GetUnit()) {
|
||||
list->mListStyleImage = listData.mImage.GetImageValue();
|
||||
if (eCSSUnit_URL == listData.mImage.GetUnit()) {
|
||||
list->mListStyleImage = listData.mImage.GetURLValue();
|
||||
}
|
||||
else if (eCSSUnit_None == listData.mImage.GetUnit()) {
|
||||
list->mListStyleImage = nsnull;
|
||||
|
|
|
@ -185,8 +185,7 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
|
|||
if (target->GetUnit() == eCSSUnit_Null) {
|
||||
const nsCSSValue *val = ValueAtCursor(cursor);
|
||||
NS_ASSERTION(val->GetUnit() != eCSSUnit_Null, "oops");
|
||||
if ((iProp == eCSSProperty_background_image ||
|
||||
iProp == eCSSProperty_list_style_image) &&
|
||||
if (iProp == eCSSProperty_background_image &&
|
||||
val->GetUnit() == eCSSUnit_URL) {
|
||||
val->StartImageLoad(aRuleData->mPresContext->GetDocument());
|
||||
}
|
||||
|
|
|
@ -1411,11 +1411,7 @@ nsComputedDOMStyle::GetListStyleImage(nsIFrame *aFrame,
|
|||
if (!list->mListStyleImage) {
|
||||
val->SetIdent(nsLayoutAtoms::none);
|
||||
} else {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (list->mListStyleImage) {
|
||||
list->mListStyleImage->GetURI(getter_AddRefs(uri));
|
||||
}
|
||||
val->SetURI(uri);
|
||||
val->SetURI(list->mListStyleImage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -578,7 +578,7 @@ struct nsStyleList : public nsStyleStruct {
|
|||
|
||||
PRUint8 mListStyleType; // [inherited] See nsStyleConsts.h
|
||||
PRUint8 mListStylePosition; // [inherited]
|
||||
nsCOMPtr<imgIRequest> mListStyleImage; // [inherited]
|
||||
nsCOMPtr<nsIURI> mListStyleImage; // [inherited]
|
||||
nsRect mImageRegion; // [inherited] the rect to use within an image
|
||||
};
|
||||
|
||||
|
|
|
@ -680,7 +680,7 @@ nsStyleList::nsStyleList(const nsStyleList& aSource)
|
|||
nsChangeHint nsStyleList::CalcDifference(const nsStyleList& aOther) const
|
||||
{
|
||||
if (mListStylePosition == aOther.mListStylePosition &&
|
||||
EqualImages(mListStyleImage, aOther.mListStyleImage) &&
|
||||
EqualURIs(mListStyleImage, aOther.mListStyleImage) &&
|
||||
mListStyleType == aOther.mListStyleType) {
|
||||
if (mImageRegion == aOther.mImageRegion)
|
||||
return NS_STYLE_HINT_NONE;
|
||||
|
|
|
@ -123,11 +123,26 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
|
|||
mPresContext = aPresContext;
|
||||
|
||||
nsresult rv = nsFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
imgIRequest *imgRequest = GetStyleList()->mListStyleImage;
|
||||
if (imgRequest) {
|
||||
nsIURI *imgURI = GetStyleList()->mListStyleImage;
|
||||
if (imgURI) {
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
|
||||
|
||||
// Get the document URI for the referrer...
|
||||
nsIURI *documentURI = nsnull;
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (mContent) {
|
||||
doc = mContent->GetDocument();
|
||||
if (doc) {
|
||||
documentURI = doc->GetDocumentURI();
|
||||
}
|
||||
}
|
||||
|
||||
if (!mListener) {
|
||||
nsBulletListener *listener;
|
||||
NS_NEWXPCOM(listener, nsBulletListener);
|
||||
|
@ -138,7 +153,10 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
|
|||
NS_RELEASE(listener);
|
||||
}
|
||||
|
||||
imgRequest->Clone(mListener, getter_AddRefs(mImageRequest));
|
||||
if (nsContentUtils::CanLoadImage(imgURI, doc, doc)) {
|
||||
// XXX: initialDocumentURI is NULL !
|
||||
il->LoadImage(imgURI, nsnull, documentURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1567,9 +1585,9 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
if (isStyleChange) {
|
||||
imgIRequest *newRequest = GetStyleList()->mListStyleImage;
|
||||
nsIURI *newURI = GetStyleList()->mListStyleImage;
|
||||
|
||||
if (newRequest) {
|
||||
if (newURI) {
|
||||
|
||||
if (!mListener) {
|
||||
nsBulletListener *listener;
|
||||
|
@ -1587,9 +1605,7 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
|
|||
// Reload the image, maybe...
|
||||
nsCOMPtr<nsIURI> oldURI;
|
||||
mImageRequest->GetURI(getter_AddRefs(oldURI));
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
newRequest->GetURI(getter_AddRefs(newURI));
|
||||
if (oldURI && newURI) {
|
||||
if (oldURI) {
|
||||
PRBool same;
|
||||
newURI->Equals(oldURI, &same);
|
||||
if (same) {
|
||||
|
@ -1602,7 +1618,29 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
if (needNewRequest) {
|
||||
newRequest->Clone(mListener, getter_AddRefs(mImageRequest));
|
||||
nsresult rv;
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
|
||||
|
||||
// Get the document URI for the referrer...
|
||||
nsIURI* documentURI = nsnull;
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (mContent) {
|
||||
doc = mContent->GetDocument();
|
||||
if (doc) {
|
||||
documentURI = doc->GetDocumentURI();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// XXX: initialDocumentURI is NULL !
|
||||
il->LoadImage(newURI, nsnull, documentURI, loadGroup, mListener, doc,
|
||||
nsIRequest::LOAD_NORMAL, nsnull, nsnull,
|
||||
getter_AddRefs(mImageRequest));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,11 +123,26 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
|
|||
mPresContext = aPresContext;
|
||||
|
||||
nsresult rv = nsFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
imgIRequest *imgRequest = GetStyleList()->mListStyleImage;
|
||||
if (imgRequest) {
|
||||
nsIURI *imgURI = GetStyleList()->mListStyleImage;
|
||||
if (imgURI) {
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
|
||||
|
||||
// Get the document URI for the referrer...
|
||||
nsIURI *documentURI = nsnull;
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (mContent) {
|
||||
doc = mContent->GetDocument();
|
||||
if (doc) {
|
||||
documentURI = doc->GetDocumentURI();
|
||||
}
|
||||
}
|
||||
|
||||
if (!mListener) {
|
||||
nsBulletListener *listener;
|
||||
NS_NEWXPCOM(listener, nsBulletListener);
|
||||
|
@ -138,7 +153,10 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
|
|||
NS_RELEASE(listener);
|
||||
}
|
||||
|
||||
imgRequest->Clone(mListener, getter_AddRefs(mImageRequest));
|
||||
if (nsContentUtils::CanLoadImage(imgURI, doc, doc)) {
|
||||
// XXX: initialDocumentURI is NULL !
|
||||
il->LoadImage(imgURI, nsnull, documentURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1567,9 +1585,9 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
if (isStyleChange) {
|
||||
imgIRequest *newRequest = GetStyleList()->mListStyleImage;
|
||||
nsIURI *newURI = GetStyleList()->mListStyleImage;
|
||||
|
||||
if (newRequest) {
|
||||
if (newURI) {
|
||||
|
||||
if (!mListener) {
|
||||
nsBulletListener *listener;
|
||||
|
@ -1587,9 +1605,7 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
|
|||
// Reload the image, maybe...
|
||||
nsCOMPtr<nsIURI> oldURI;
|
||||
mImageRequest->GetURI(getter_AddRefs(oldURI));
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
newRequest->GetURI(getter_AddRefs(newURI));
|
||||
if (oldURI && newURI) {
|
||||
if (oldURI) {
|
||||
PRBool same;
|
||||
newURI->Equals(oldURI, &same);
|
||||
if (same) {
|
||||
|
@ -1602,7 +1618,29 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
if (needNewRequest) {
|
||||
newRequest->Clone(mListener, getter_AddRefs(mImageRequest));
|
||||
nsresult rv;
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
|
||||
|
||||
// Get the document URI for the referrer...
|
||||
nsIURI* documentURI = nsnull;
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (mContent) {
|
||||
doc = mContent->GetDocument();
|
||||
if (doc) {
|
||||
documentURI = doc->GetDocumentURI();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// XXX: initialDocumentURI is NULL !
|
||||
il->LoadImage(newURI, nsnull, documentURI, loadGroup, mListener, doc,
|
||||
nsIRequest::LOAD_NORMAL, nsnull, nsnull,
|
||||
getter_AddRefs(mImageRequest));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,8 +185,7 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
|
|||
if (target->GetUnit() == eCSSUnit_Null) {
|
||||
const nsCSSValue *val = ValueAtCursor(cursor);
|
||||
NS_ASSERTION(val->GetUnit() != eCSSUnit_Null, "oops");
|
||||
if ((iProp == eCSSProperty_background_image ||
|
||||
iProp == eCSSProperty_list_style_image) &&
|
||||
if (iProp == eCSSProperty_background_image &&
|
||||
val->GetUnit() == eCSSUnit_URL) {
|
||||
val->StartImageLoad(aRuleData->mPresContext->GetDocument());
|
||||
}
|
||||
|
|
|
@ -1411,11 +1411,7 @@ nsComputedDOMStyle::GetListStyleImage(nsIFrame *aFrame,
|
|||
if (!list->mListStyleImage) {
|
||||
val->SetIdent(nsLayoutAtoms::none);
|
||||
} else {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (list->mListStyleImage) {
|
||||
list->mListStyleImage->GetURI(getter_AddRefs(uri));
|
||||
}
|
||||
val->SetURI(uri);
|
||||
val->SetURI(list->mListStyleImage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3517,8 +3517,8 @@ nsRuleNode::ComputeListData(nsStyleStruct* aStartStruct,
|
|||
}
|
||||
|
||||
// list-style-image: url, none, inherit
|
||||
if (eCSSUnit_Image == listData.mImage.GetUnit()) {
|
||||
list->mListStyleImage = listData.mImage.GetImageValue();
|
||||
if (eCSSUnit_URL == listData.mImage.GetUnit()) {
|
||||
list->mListStyleImage = listData.mImage.GetURLValue();
|
||||
}
|
||||
else if (eCSSUnit_None == listData.mImage.GetUnit()) {
|
||||
list->mListStyleImage = nsnull;
|
||||
|
|
|
@ -680,7 +680,7 @@ nsStyleList::nsStyleList(const nsStyleList& aSource)
|
|||
nsChangeHint nsStyleList::CalcDifference(const nsStyleList& aOther) const
|
||||
{
|
||||
if (mListStylePosition == aOther.mListStylePosition &&
|
||||
EqualImages(mListStyleImage, aOther.mListStyleImage) &&
|
||||
EqualURIs(mListStyleImage, aOther.mListStyleImage) &&
|
||||
mListStyleType == aOther.mListStyleType) {
|
||||
if (mImageRegion == aOther.mImageRegion)
|
||||
return NS_STYLE_HINT_NONE;
|
||||
|
|
|
@ -578,7 +578,7 @@ struct nsStyleList : public nsStyleStruct {
|
|||
|
||||
PRUint8 mListStyleType; // [inherited] See nsStyleConsts.h
|
||||
PRUint8 mListStylePosition; // [inherited]
|
||||
nsCOMPtr<imgIRequest> mListStyleImage; // [inherited]
|
||||
nsCOMPtr<nsIURI> mListStyleImage; // [inherited]
|
||||
nsRect mImageRegion; // [inherited] the rect to use within an image
|
||||
};
|
||||
|
||||
|
|
|
@ -261,13 +261,12 @@ nsImageBoxFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|||
{
|
||||
nsresult rv = nsLeafBoxFrame::AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aModType);
|
||||
|
||||
if (aAttribute == nsHTMLAtoms::src) {
|
||||
UpdateImage();
|
||||
PRBool aResize = UpdateAttributes(aAttribute);
|
||||
|
||||
if (aResize) {
|
||||
nsBoxLayoutState state(aPresContext);
|
||||
MarkDirty(state);
|
||||
}
|
||||
else if (aAttribute == nsXULAtoms::validate)
|
||||
UpdateLoadFlags();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -275,6 +274,8 @@ nsImageBoxFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|||
nsImageBoxFrame::nsImageBoxFrame(nsIPresShell* aShell) :
|
||||
nsLeafBoxFrame(aShell),
|
||||
mUseSrcAttr(PR_FALSE),
|
||||
mSizeFrozen(PR_FALSE),
|
||||
mHasImage(PR_FALSE),
|
||||
mSuppressStyleCheck(PR_FALSE),
|
||||
mIntrinsicSize(0,0),
|
||||
mLoadFlags(nsIRequest::LOAD_NORMAL)
|
||||
|
@ -328,21 +329,17 @@ nsImageBoxFrame::Init(nsIPresContext* aPresContext,
|
|||
nsresult rv = nsLeafBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
||||
mSuppressStyleCheck = PR_FALSE;
|
||||
|
||||
GetImageSource();
|
||||
UpdateLoadFlags();
|
||||
|
||||
UpdateImage();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
nsImageBoxFrame::UpdateImage()
|
||||
nsImageBoxFrame::GetImageSource()
|
||||
{
|
||||
if (mImageRequest) {
|
||||
mImageRequest->Cancel(NS_ERROR_FAILURE);
|
||||
mImageRequest = nsnull;
|
||||
mIntrinsicSize.SizeTo(0, 0);
|
||||
}
|
||||
|
||||
// get the new image src
|
||||
nsAutoString src;
|
||||
mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::src, src);
|
||||
|
@ -353,37 +350,33 @@ nsImageBoxFrame::UpdateImage()
|
|||
baseURI = mContent->GetBaseURI();
|
||||
}
|
||||
// XXX origin charset needed
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), src, nsnull, baseURI);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (uri && NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = GetLoadGroup();
|
||||
|
||||
// Get the document URI for the referrer...
|
||||
nsIDocument* doc = mContent ? mContent->GetDocument() : nsnull;
|
||||
nsIURI *documentURI = doc ? doc->GetDocumentURI() : nsnull;
|
||||
|
||||
// XXX: initialDocumentURI is NULL!
|
||||
il->LoadImage(uri, nsnull, documentURI, loadGroup, mListener, doc,
|
||||
mLoadFlags, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
NS_NewURI(getter_AddRefs(mURI), src, nsnull, baseURI);
|
||||
} else {
|
||||
// Only get the list-style-image if we aren't being drawn
|
||||
// by a native theme.
|
||||
PRUint8 appearance = GetStyleDisplay()->mAppearance;
|
||||
if (!(appearance && nsBox::gTheme &&
|
||||
nsBox::gTheme->ThemeSupportsWidget(nsnull, this, appearance))) {
|
||||
// get the list-style-image
|
||||
imgIRequest *styleRequest = GetStyleList()->mListStyleImage;
|
||||
if (styleRequest) {
|
||||
styleRequest->Clone(mListener, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
}
|
||||
const nsStyleDisplay* disp = GetStyleDisplay();
|
||||
if (disp->mAppearance && nsBox::gTheme &&
|
||||
nsBox::gTheme->ThemeSupportsWidget(nsnull, this, disp->mAppearance))
|
||||
return;
|
||||
|
||||
// get the list-style-image
|
||||
mURI = GetStyleList()->mListStyleImage;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsImageBoxFrame::UpdateAttributes(nsIAtom* aAttribute)
|
||||
{
|
||||
if (aAttribute == nsnull || aAttribute == nsHTMLAtoms::src) {
|
||||
GetImageSource();
|
||||
return UpdateImage();
|
||||
}
|
||||
else if (aAttribute == nsXULAtoms::validate)
|
||||
UpdateLoadFlags();
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsImageBoxFrame::UpdateLoadFlags()
|
||||
{
|
||||
|
@ -397,6 +390,66 @@ nsImageBoxFrame::UpdateLoadFlags()
|
|||
mLoadFlags = nsIRequest::LOAD_NORMAL;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsImageBoxFrame::UpdateImage()
|
||||
{
|
||||
// get the new image src
|
||||
if (!mURI) {
|
||||
mSizeFrozen = PR_TRUE;
|
||||
mHasImage = PR_FALSE;
|
||||
|
||||
if (mImageRequest) {
|
||||
mImageRequest->Cancel(NS_ERROR_FAILURE);
|
||||
mImageRequest = nsnull;
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
if (mImageRequest) {
|
||||
nsCOMPtr<nsIURI> requestURI;
|
||||
rv = mImageRequest->GetURI(getter_AddRefs(requestURI));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv) && requestURI,"no request URI");
|
||||
if (NS_FAILED(rv) || !requestURI) return PR_FALSE;
|
||||
|
||||
PRBool eq;
|
||||
// if the source uri and the current one are the same, return
|
||||
if (NS_SUCCEEDED(requestURI->Equals(mURI, &eq)) && eq)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
mSizeFrozen = PR_FALSE;
|
||||
mHasImage = PR_TRUE;
|
||||
|
||||
// otherwise, we need to load the new uri
|
||||
if (mImageRequest) {
|
||||
mImageRequest->Cancel(NS_ERROR_FAILURE);
|
||||
mImageRequest = nsnull;
|
||||
}
|
||||
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = GetLoadGroup();
|
||||
|
||||
// Get the document URI for the referrer...
|
||||
nsIURI *documentURI = nsnull;
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
if (mContent) {
|
||||
doc = mContent->GetDocument();
|
||||
if (doc) {
|
||||
documentURI = doc->GetDocumentURI();
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: initialDocumentURI is NULL!
|
||||
il->LoadImage(mURI, nsnull, documentURI, loadGroup, mListener, doc,
|
||||
mLoadFlags, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageBoxFrame::Paint(nsIPresContext* aPresContext,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
|
@ -437,7 +490,7 @@ nsImageBoxFrame::PaintImage(nsIRenderingContext& aRenderingContext,
|
|||
return;
|
||||
|
||||
// don't draw if the image is not dirty
|
||||
if (!aDirtyRect.Intersects(rect))
|
||||
if (!mHasImage || !aDirtyRect.Intersects(rect))
|
||||
return;
|
||||
|
||||
nsCOMPtr<imgIContainer> imgCon;
|
||||
|
@ -495,17 +548,14 @@ nsImageBoxFrame::DidSetStyleContext( nsIPresContext* aPresContext )
|
|||
return NS_OK;
|
||||
|
||||
// If list-style-image changes, we have a new image.
|
||||
nsCOMPtr<nsIURI> oldURI, newURI;
|
||||
if (mImageRequest)
|
||||
mImageRequest->GetURI(getter_AddRefs(oldURI));
|
||||
if (myList->mListStyleImage)
|
||||
myList->mListStyleImage->GetURI(getter_AddRefs(newURI));
|
||||
nsIURI *newURI = myList->mListStyleImage;
|
||||
PRBool equal;
|
||||
if (newURI == oldURI || // handles null==null
|
||||
(newURI && oldURI &&
|
||||
NS_SUCCEEDED(newURI->Equals(oldURI, &equal)) && equal))
|
||||
if (newURI == mURI || // handles null==null
|
||||
(newURI && mURI && NS_SUCCEEDED(newURI->Equals(mURI, &equal)) && equal))
|
||||
return NS_OK;
|
||||
|
||||
mURI = newURI;
|
||||
|
||||
UpdateImage();
|
||||
return NS_OK;
|
||||
} // DidSetStyleContext
|
||||
|
@ -513,13 +563,36 @@ nsImageBoxFrame::DidSetStyleContext( nsIPresContext* aPresContext )
|
|||
void
|
||||
nsImageBoxFrame::GetImageSize()
|
||||
{
|
||||
if (mIntrinsicSize.width > 0 && mIntrinsicSize.height > 0) {
|
||||
mImageSize.width = mIntrinsicSize.width;
|
||||
mImageSize.height = mIntrinsicSize.height;
|
||||
} else {
|
||||
mImageSize.width = 0;
|
||||
mImageSize.height = 0;
|
||||
}
|
||||
nsHTMLReflowMetrics desiredSize(PR_TRUE);
|
||||
const PRInt32 kDefaultSize = 0;
|
||||
// XXX constant zero?
|
||||
const PRInt32 kDefaultSizeInTwips =
|
||||
GetPresContext()->IntScaledPixelsToTwips(kDefaultSize);
|
||||
|
||||
// not calculated? Get the intrinsic size
|
||||
if (mHasImage) {
|
||||
// get the size of the image and set the desired size
|
||||
if (mSizeFrozen) {
|
||||
mImageSize.width = kDefaultSizeInTwips;
|
||||
mImageSize.height = kDefaultSizeInTwips;
|
||||
return;
|
||||
} else {
|
||||
// Ask the image loader for the *intrinsic* image size
|
||||
if (mIntrinsicSize.width > 0 && mIntrinsicSize.height > 0) {
|
||||
mImageSize.width = mIntrinsicSize.width;
|
||||
mImageSize.height = mIntrinsicSize.height;
|
||||
return;
|
||||
} else {
|
||||
mImageSize.width = kDefaultSizeInTwips;
|
||||
mImageSize.height = kDefaultSizeInTwips;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// XXX constant zero?
|
||||
mImageSize.width = desiredSize.width;
|
||||
mImageSize.height = desiredSize.height;
|
||||
}
|
||||
|
||||
|
||||
|
@ -610,6 +683,9 @@ NS_IMETHODIMP nsImageBoxFrame::OnStartContainer(imgIRequest *request,
|
|||
// Ensure the animation (if any) is started
|
||||
image->StartAnimation();
|
||||
|
||||
mHasImage = PR_TRUE;
|
||||
mSizeFrozen = PR_FALSE;
|
||||
|
||||
nscoord w, h;
|
||||
image->GetWidth(&w);
|
||||
image->GetHeight(&h);
|
||||
|
|
|
@ -97,12 +97,19 @@ public:
|
|||
NS_IMETHOD GetFrameName(nsAString& aResult) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Update mUseSrcAttr from appropriate content attributes or from
|
||||
* style, throw away the current image, and load the appropriate
|
||||
/**
|
||||
* Update internal state when a given attribute changes. Does not reload the
|
||||
* image.
|
||||
* @return Whether the size of the image (possibly) changed
|
||||
*/
|
||||
PRBool UpdateAttributes(nsIAtom* aAttribute);
|
||||
|
||||
/**
|
||||
* Load the image to which mURI points, or throw away the current image if
|
||||
* mURI is nsnull. Usually, this is preceded by a call to GetImageSource.
|
||||
* @return PR_TRUE if the image is (possibly) of a different size
|
||||
* */
|
||||
void UpdateImage();
|
||||
PRBool UpdateImage();
|
||||
|
||||
/**
|
||||
* Update mLoadFlags from content attributes. Does not attempt to reload the
|
||||
|
@ -134,6 +141,12 @@ protected:
|
|||
|
||||
nsImageBoxFrame(nsIPresShell* aShell);
|
||||
|
||||
/**
|
||||
* Update mURI and mUseSrcAttr from appropriate content attributes or from
|
||||
* style. Does not reload the image.
|
||||
*/
|
||||
void GetImageSource();
|
||||
|
||||
/**
|
||||
* Get the load group for the current document, that should be used for
|
||||
* network requests.
|
||||
|
@ -147,7 +160,11 @@ private:
|
|||
nsCOMPtr<imgIRequest> mImageRequest;
|
||||
nsCOMPtr<imgIDecoderObserver> mListener;
|
||||
|
||||
nsCOMPtr<nsIURI> mURI; ///< The URI of the image.
|
||||
|
||||
PRPackedBool mUseSrcAttr; ///< Whether or not the image src comes from an attribute.
|
||||
PRPackedBool mSizeFrozen;
|
||||
PRPackedBool mHasImage;
|
||||
PRPackedBool mSuppressStyleCheck;
|
||||
|
||||
nsRect mSubRect; ///< If set, indicates that only the portion of the image specified by the rect should be used.
|
||||
|
|
|
@ -1627,18 +1627,15 @@ nsTreeBodyFrame::GetImage(PRInt32 aRowIndex, nsTreeColumn* aCol, PRBool aUseCont
|
|||
|
||||
nsAutoString imageSrc;
|
||||
mView->GetImageSrc(aRowIndex, aCol, imageSrc);
|
||||
nsCOMPtr<imgIRequest> styleRequest;
|
||||
if (!aUseContext && !imageSrc.IsEmpty()) {
|
||||
aAllowImageRegions = PR_FALSE;
|
||||
}
|
||||
else {
|
||||
// Obtain the URL from the style context.
|
||||
aAllowImageRegions = PR_TRUE;
|
||||
styleRequest = aStyleContext->GetStyleList()->mListStyleImage;
|
||||
if (!styleRequest)
|
||||
nsIURI* uri = aStyleContext->GetStyleList()->mListStyleImage;
|
||||
if (!uri)
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
styleRequest->GetURI(getter_AddRefs(uri));
|
||||
nsCAutoString spec;
|
||||
uri->GetSpec(spec);
|
||||
CopyUTF8toUTF16(spec, imageSrc);
|
||||
|
@ -1679,35 +1676,30 @@ nsTreeBodyFrame::GetImage(PRInt32 aRowIndex, nsTreeColumn* aCol, PRBool aUseCont
|
|||
listener->AddCell(aRowIndex, aCol);
|
||||
nsCOMPtr<imgIDecoderObserver> imgDecoderObserver = listener;
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
|
||||
if (!doc)
|
||||
// The page is currently being torn down. Why bother.
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
baseURI = mContent->GetBaseURI();
|
||||
|
||||
nsCOMPtr<nsIURI> srcURI;
|
||||
// XXX origin charset needed
|
||||
NS_NewURI(getter_AddRefs(srcURI), imageSrc, nsnull, baseURI);
|
||||
if (!srcURI)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<imgIRequest> imageRequest;
|
||||
if (styleRequest) {
|
||||
styleRequest->Clone(imgDecoderObserver, getter_AddRefs(imageRequest));
|
||||
} else {
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
|
||||
if (!doc)
|
||||
// The page is currently being torn down. Why bother.
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
baseURI = mContent->GetBaseURI();
|
||||
nsresult rv;
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIURI> srcURI;
|
||||
// XXX origin charset needed
|
||||
NS_NewURI(getter_AddRefs(srcURI), imageSrc, nsnull, baseURI);
|
||||
if (!srcURI)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<imgILoader> il =
|
||||
do_GetService("@mozilla.org/image/loader;1", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// XXX: initialDocumentURI is NULL!
|
||||
rv = il->LoadImage(srcURI, nsnull, doc->GetDocumentURI(), nsnull,
|
||||
imgDecoderObserver, doc, nsIRequest::LOAD_NORMAL,
|
||||
nsnull, nsnull, getter_AddRefs(imageRequest));
|
||||
}
|
||||
// XXX: initialDocumentURI is NULL!
|
||||
rv = il->LoadImage(srcURI, nsnull, doc->GetDocumentURI(), nsnull,
|
||||
imgDecoderObserver, doc, nsIRequest::LOAD_NORMAL,
|
||||
nsnull, nsnull, getter_AddRefs(imageRequest));
|
||||
listener->UnsuppressInvalidation();
|
||||
|
||||
if (!imageRequest)
|
||||
|
|
Загрузка…
Ссылка в новой задаче