Fix 75516. r=danm, sr=ben
git-svn-id: svn://10.0.0.236/trunk@93381 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -189,7 +189,6 @@ nsImageBoxFrame::Init(nsIPresContext* aPresContext,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow)
|
||||
{
|
||||
#ifdef USE_IMG2
|
||||
if (!mListener) {
|
||||
nsImageBoxListener *listener;
|
||||
NS_NEWXPCOM(listener, nsImageBoxListener);
|
||||
@@ -198,78 +197,8 @@ nsImageBoxFrame::Init(nsIPresContext* aPresContext,
|
||||
listener->QueryInterface(NS_GET_IID(imgIDecoderObserver), getter_AddRefs(mListener));
|
||||
NS_RELEASE(listener);
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult rv = nsLeafBoxFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
||||
|
||||
mHasImage = PR_FALSE;
|
||||
|
||||
// Always set the image loader's base URL, because someone may
|
||||
// decide to change a button _without_ an image to have an image
|
||||
// later.
|
||||
nsCOMPtr<nsIURI> baseURL;
|
||||
GetBaseURI(getter_AddRefs(baseURL));
|
||||
|
||||
// Initialize the image loader. Make sure the source is correct so
|
||||
// that UpdateAttributes doesn't double start an image load.
|
||||
nsAutoString src;
|
||||
GetImageSource(src);
|
||||
|
||||
#ifdef USE_IMG2
|
||||
|
||||
PRBool needLoad = PR_FALSE;
|
||||
|
||||
if (!src.IsEmpty()) {
|
||||
mHasImage = PR_TRUE;
|
||||
needLoad = PR_TRUE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> srcURI;
|
||||
NS_NewURI(getter_AddRefs(srcURI), src, baseURL);
|
||||
|
||||
// if we don't have an image request, then we certainly need to load
|
||||
if (!mImageRequest) {
|
||||
needLoad = PR_TRUE;
|
||||
} else {
|
||||
// check to see if the uri we are about to load is the same as the
|
||||
// one the image request came from.
|
||||
nsCOMPtr<nsIURI> requestURI;
|
||||
rv = mImageRequest->GetURI(getter_AddRefs(requestURI));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv) && requestURI,"no request URI");
|
||||
if (NS_FAILED(rv) || !requestURI) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
PRBool eq;
|
||||
requestURI->Equals(srcURI, &eq);
|
||||
|
||||
if (eq) {
|
||||
needLoad = PR_FALSE;
|
||||
} else {
|
||||
needLoad = PR_TRUE;
|
||||
mImageRequest->Cancel(NS_ERROR_FAILURE);
|
||||
mImageRequest = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
if (mHasImage && needLoad) {
|
||||
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));
|
||||
|
||||
il->LoadImage(srcURI, loadGroup, mListener, aPresContext, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
#else
|
||||
if (!src.IsEmpty()) {
|
||||
mHasImage = PR_TRUE;
|
||||
}
|
||||
|
||||
mImageLoader.Init(this, UpdateImageFrame, nsnull, baseURL, src);
|
||||
#endif
|
||||
|
||||
PRBool a,b;
|
||||
UpdateAttributes(aPresContext, nsnull, a, b);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -1510,13 +1510,21 @@ nsMenuFrame::OnCreate()
|
||||
else grandChild->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::disabled, commandDisabled, PR_TRUE);
|
||||
}
|
||||
|
||||
// The menu's value and checked states need to be updated to match the command.
|
||||
// Note that (unlike the disabled state) if the command has *no* value for either, we
|
||||
// assume the menu is supplying its own.
|
||||
nsAutoString commandChecked, menuChecked;
|
||||
commandContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::checked, commandChecked);
|
||||
grandChild->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::checked, menuChecked);
|
||||
if (!commandChecked.Equals(menuChecked)) {
|
||||
if (!commandChecked.IsEmpty())
|
||||
grandChild->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::checked, commandChecked, PR_TRUE);
|
||||
}
|
||||
|
||||
nsAutoString commandValue, menuValue;
|
||||
commandContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::value, commandValue);
|
||||
grandChild->GetAttribute(kNameSpaceID_None, nsXULAtoms::value, menuValue);
|
||||
if (!commandValue.Equals(menuValue)) {
|
||||
// The menu's value state needs to be updated to match the command.
|
||||
// Note that (unlike the disabled state) if the command has *no* value, we
|
||||
// assume the menu is supplying its own.
|
||||
if (!commandValue.IsEmpty())
|
||||
grandChild->SetAttribute(kNameSpaceID_None, nsXULAtoms::value, commandValue, PR_TRUE);
|
||||
}
|
||||
|
||||
@@ -1211,13 +1211,21 @@ nsMenu::OnCreate()
|
||||
else grandChild->SetAttribute(kNameSpaceID_None, nsWidgetAtoms::disabled, commandDisabled, PR_TRUE);
|
||||
}
|
||||
|
||||
// The menu's value and checked states need to be updated to match the command.
|
||||
// Note that (unlike the disabled state) if the command has *no* value for either, we
|
||||
// assume the menu is supplying its own.
|
||||
nsAutoString commandChecked, menuChecked;
|
||||
commandContent->GetAttribute(kNameSpaceID_None, nsWidgetAtoms::checked, commandChecked);
|
||||
grandChild->GetAttribute(kNameSpaceID_None, nsWidgetAtoms::checked, menuChecked);
|
||||
if (!commandChecked.Equals(menuChecked)) {
|
||||
if (!commandChecked.IsEmpty())
|
||||
grandChild->SetAttribute(kNameSpaceID_None, nsWidgetAtoms::checked, commandChecked, PR_TRUE);
|
||||
}
|
||||
|
||||
nsAutoString commandValue, menuValue;
|
||||
commandContent->GetAttribute(kNameSpaceID_None, nsWidgetAtoms::label, commandValue);
|
||||
grandChild->GetAttribute(kNameSpaceID_None, nsWidgetAtoms::label, menuValue);
|
||||
if (!commandValue.Equals(menuValue)) {
|
||||
// The menu's label state needs to be updated to match the command.
|
||||
// Note that (unlike the disabled state) if the command has *no* label, we
|
||||
// assume the menu is supplying its own.
|
||||
if (!commandValue.IsEmpty())
|
||||
grandChild->SetAttribute(kNameSpaceID_None, nsWidgetAtoms::label, commandValue, PR_TRUE);
|
||||
}
|
||||
|
||||
@@ -1093,13 +1093,21 @@ nsMenuX::OnCreate()
|
||||
else grandChild->SetAttribute(kNameSpaceID_None, nsWidgetAtoms::disabled, commandDisabled, PR_TRUE);
|
||||
}
|
||||
|
||||
// The menu's value and checked states need to be updated to match the command.
|
||||
// Note that (unlike the disabled state) if the command has *no* value for either, we
|
||||
// assume the menu is supplying its own.
|
||||
nsAutoString commandChecked, menuChecked;
|
||||
commandContent->GetAttribute(kNameSpaceID_None, nsWidgetAtoms::checked, commandChecked);
|
||||
grandChild->GetAttribute(kNameSpaceID_None, nsWidgetAtoms::checked, menuChecked);
|
||||
if (!commandChecked.Equals(menuChecked)) {
|
||||
if (!commandChecked.IsEmpty())
|
||||
grandChild->SetAttribute(kNameSpaceID_None, nsWidgetAtoms::checked, commandChecked, PR_TRUE);
|
||||
}
|
||||
|
||||
nsAutoString commandValue, menuValue;
|
||||
commandContent->GetAttribute(kNameSpaceID_None, nsWidgetAtoms::label, commandValue);
|
||||
grandChild->GetAttribute(kNameSpaceID_None, nsWidgetAtoms::label, menuValue);
|
||||
if (!commandValue.Equals(menuValue)) {
|
||||
// The menu's label state needs to be updated to match the command.
|
||||
// Note that (unlike the disabled state) if the command has *no* label, we
|
||||
// assume the menu is supplying its own.
|
||||
if (!commandValue.IsEmpty())
|
||||
grandChild->SetAttribute(kNameSpaceID_None, nsWidgetAtoms::label, commandValue, PR_TRUE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user