mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-19 17:38:36 +00:00
bug 127189 - changing the sizetopopup attribute to have two valid "on" modes: "pref", which sets the preferred size to the popup size, and "always", which sets both the preferred and min size to the popup size. Converting all current users of sizetopopup=true to sizetopopup=pref. r=saari, sr=hyatt, s=shaver.
This commit is contained in:
parent
37903d583c
commit
9534995ca2
@ -941,6 +941,32 @@ nsMenuFrame::GetMenuChildrenElement(nsIContent** aResult)
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMenuFrame::GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
|
||||
{
|
||||
// Our min size is the popup size (same as the pref size) if
|
||||
// sizetopopup="always" is set. However, we first need to check
|
||||
// to see if a min size was set in CSS.
|
||||
PRBool collapsed = PR_FALSE;
|
||||
IsCollapsed(aBoxLayoutState, collapsed);
|
||||
if (collapsed) {
|
||||
aSize.width = aSize.height = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIFrame* popupChild = mPopupFrames.FirstChild();
|
||||
|
||||
if (popupChild) {
|
||||
nsAutoString sizedToPopup;
|
||||
mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::sizetopopup, sizedToPopup);
|
||||
|
||||
if (sizedToPopup.EqualsIgnoreCase("always"))
|
||||
return GetPrefSize(aBoxLayoutState, aSize);
|
||||
}
|
||||
|
||||
return nsBoxFrame::GetMinSize(aBoxLayoutState, aSize);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMenuFrame::DoLayout(nsBoxLayoutState& aState)
|
||||
{
|
||||
@ -956,7 +982,8 @@ nsMenuFrame::DoLayout(nsBoxLayoutState& aState)
|
||||
if (popupChild) {
|
||||
nsAutoString sizedToPopup;
|
||||
mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::sizetopopup, sizedToPopup);
|
||||
PRBool sizeToPopup = (sizedToPopup.EqualsIgnoreCase("true"));
|
||||
PRBool sizeToPopup = (sizedToPopup.EqualsIgnoreCase("pref") ||
|
||||
sizedToPopup.EqualsIgnoreCase("always"));
|
||||
|
||||
nsIBox* ibox = nsnull;
|
||||
nsresult rv2 = popupChild->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox);
|
||||
@ -1970,7 +1997,8 @@ nsMenuFrame::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
|
||||
|
||||
nsAutoString sizedToPopup;
|
||||
mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::sizetopopup, sizedToPopup);
|
||||
PRBool sizeToPopup = (sizedToPopup.EqualsIgnoreCase("true"));
|
||||
PRBool sizeToPopup = (sizedToPopup.EqualsIgnoreCase("pref") ||
|
||||
sizedToPopup.EqualsIgnoreCase("always"));
|
||||
|
||||
if (sizeToPopup) {
|
||||
nsSize tmpSize(-1,0);
|
||||
|
@ -80,6 +80,7 @@ public:
|
||||
|
||||
// nsIBox
|
||||
NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
|
||||
NS_IMETHOD GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
|
||||
NS_IMETHOD GetPrefSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize);
|
||||
|
||||
// The nsITimerCallback interface
|
||||
|
@ -1158,7 +1158,8 @@ nsMenuPopupFrame::SyncViewWithFrame(nsIPresContext* aPresContext,
|
||||
if (tag.get() != nsXULAtoms::tooltip) {
|
||||
nsAutoString sizeToContent;
|
||||
parentContent->GetAttr(kNameSpaceID_None, nsXULAtoms::sizetopopup, sizeToContent);
|
||||
if (sizeToContent == NS_LITERAL_STRING("true")) {
|
||||
if (sizeToContent == NS_LITERAL_STRING("pref") ||
|
||||
sizeToContent == NS_LITERAL_STRING("always")) {
|
||||
nsBoxLayoutState state(mPresContext);
|
||||
SetBounds(state, nsRect(mRect.x, mRect.y, parentRect.width, mRect.height));
|
||||
}
|
||||
@ -1773,7 +1774,8 @@ nsMenuPopupFrame::IsValidItem(nsIContent* aContent)
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
aContent->GetTag(*getter_AddRefs(tag));
|
||||
if (tag && (tag.get() == nsXULAtoms::menu ||
|
||||
tag.get() == nsXULAtoms::menuitem))
|
||||
tag.get() == nsXULAtoms::menuitem ||
|
||||
tag.get() == nsHTMLAtoms::option))
|
||||
return PR_TRUE;
|
||||
|
||||
return PR_FALSE;
|
||||
|
@ -12,7 +12,7 @@
|
||||
<stylesheet src="chrome://global/skin/autocomplete.css"/>
|
||||
</resources>
|
||||
|
||||
<content sizetopopup="true">
|
||||
<content sizetopopup="pref">
|
||||
<xul:hbox class="autocomplete-textbox-container" flex="1">
|
||||
<children includes="image|deck">
|
||||
<xul:image class="autocomplete-icon" allowevents="true"/>
|
||||
|
@ -46,7 +46,7 @@
|
||||
<method name="setInitialSelection">
|
||||
<body>
|
||||
<![CDATA[
|
||||
this.setAttribute('sizetopopup', 'true');
|
||||
this.setAttribute('sizetopopup', 'pref');
|
||||
|
||||
if (this.childNodes.length) {
|
||||
// if there was a previously selected item, be sure to set our internal
|
||||
|
Loading…
x
Reference in New Issue
Block a user