From dbc4cb4f8a4b7c997e3c1943e568de2ea3074129 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Sat, 28 Apr 2001 06:38:23 +0000 Subject: [PATCH] Fix 75516. r=danm, sr=ben git-svn-id: svn://10.0.0.236/trunk@93381 18797224-902f-48f8-a5cc-f745e15eee43 --- .../layout/xul/base/src/nsImageBoxFrame.cpp | 71 ------------------- mozilla/layout/xul/base/src/nsMenuFrame.cpp | 14 +++- mozilla/widget/src/mac/nsMenu.cpp | 14 +++- mozilla/widget/src/mac/nsMenuX.cpp | 14 +++- 4 files changed, 33 insertions(+), 80 deletions(-) diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp index 41478dd0fce..3065194ede2 100644 --- a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp @@ -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 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 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 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 il(do_GetService("@mozilla.org/image/loader;1", &rv)); - if (NS_FAILED(rv)) - return rv; - - nsCOMPtr 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; } diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.cpp b/mozilla/layout/xul/base/src/nsMenuFrame.cpp index 7435b88a556..9a333df0542 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuFrame.cpp @@ -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); } diff --git a/mozilla/widget/src/mac/nsMenu.cpp b/mozilla/widget/src/mac/nsMenu.cpp index 1ce7aa9e322..175e5ffcaae 100644 --- a/mozilla/widget/src/mac/nsMenu.cpp +++ b/mozilla/widget/src/mac/nsMenu.cpp @@ -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); } diff --git a/mozilla/widget/src/mac/nsMenuX.cpp b/mozilla/widget/src/mac/nsMenuX.cpp index d5d585342f9..cc56a08ea66 100644 --- a/mozilla/widget/src/mac/nsMenuX.cpp +++ b/mozilla/widget/src/mac/nsMenuX.cpp @@ -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); }