mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Hardcode sizetopopup=always behavior for HTML select widgets, that way we don't pollute the HTML DOM with our attribute. Also, factoring out the sizetopopup check into a helper method. Bug 128947, r=jkeiser, sr=brendan, a=dbaron.
This commit is contained in:
parent
e09687ddf6
commit
21df11ab85
@ -654,7 +654,7 @@
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
<content sizetopopup="always">
|
||||
<content>
|
||||
<xul:hbox class="select-label-box" flex="1">
|
||||
<xul:label flex="1" value=" " inherits="value=label"/>
|
||||
</xul:hbox>
|
||||
|
@ -654,7 +654,7 @@
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
<content sizetopopup="always">
|
||||
<content>
|
||||
<xul:hbox class="select-label-box" flex="1">
|
||||
<xul:label flex="1" value=" " inherits="value=label"/>
|
||||
</xul:hbox>
|
||||
|
@ -938,6 +938,24 @@ nsMenuFrame::GetMenuChildrenElement(nsIContent** aResult)
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsMenuFrame::IsSizedToPopup(nsIContent* aContent, PRBool aRequireAlways)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
aContent->GetTag(*getter_AddRefs(tag));
|
||||
PRBool sizeToPopup;
|
||||
if (tag == nsHTMLAtoms::select)
|
||||
sizeToPopup = PR_TRUE;
|
||||
else {
|
||||
nsAutoString sizedToPopup;
|
||||
aContent->GetAttr(kNameSpaceID_None, nsXULAtoms::sizetopopup, sizedToPopup);
|
||||
sizeToPopup = (sizedToPopup.EqualsIgnoreCase("always") ||
|
||||
(!aRequireAlways && sizedToPopup.EqualsIgnoreCase("pref")));
|
||||
}
|
||||
|
||||
return sizeToPopup;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMenuFrame::GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
|
||||
{
|
||||
@ -953,13 +971,8 @@ nsMenuFrame::GetMinSize(nsBoxLayoutState& aBoxLayoutState, nsSize& aSize)
|
||||
|
||||
nsIFrame* popupChild = mPopupFrames.FirstChild();
|
||||
|
||||
if (popupChild) {
|
||||
nsAutoString sizedToPopup;
|
||||
mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::sizetopopup, sizedToPopup);
|
||||
|
||||
if (sizedToPopup.EqualsIgnoreCase("always"))
|
||||
return GetPrefSize(aBoxLayoutState, aSize);
|
||||
}
|
||||
if (popupChild && IsSizedToPopup(mContent, PR_TRUE))
|
||||
return GetPrefSize(aBoxLayoutState, aSize);
|
||||
|
||||
return nsBoxFrame::GetMinSize(aBoxLayoutState, aSize);
|
||||
}
|
||||
@ -977,11 +990,7 @@ nsMenuFrame::DoLayout(nsBoxLayoutState& aState)
|
||||
nsIFrame* popupChild = mPopupFrames.FirstChild();
|
||||
|
||||
if (popupChild) {
|
||||
nsAutoString sizedToPopup;
|
||||
mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::sizetopopup, sizedToPopup);
|
||||
PRBool sizeToPopup = (sizedToPopup.EqualsIgnoreCase("pref") ||
|
||||
sizedToPopup.EqualsIgnoreCase("always"));
|
||||
|
||||
PRBool sizeToPopup = IsSizedToPopup(mContent, PR_FALSE);
|
||||
nsIBox* ibox = nsnull;
|
||||
nsresult rv2 = popupChild->QueryInterface(NS_GET_IID(nsIBox), (void**)&ibox);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv2) && ibox,"popupChild is not box!!");
|
||||
@ -1983,12 +1992,7 @@ nsMenuFrame::GetPrefSize(nsBoxLayoutState& aState, nsSize& aSize)
|
||||
aSize.height = 0;
|
||||
nsresult rv = nsBoxFrame::GetPrefSize(aState, aSize);
|
||||
|
||||
nsAutoString sizedToPopup;
|
||||
mContent->GetAttr(kNameSpaceID_None, nsXULAtoms::sizetopopup, sizedToPopup);
|
||||
PRBool sizeToPopup = (sizedToPopup.EqualsIgnoreCase("pref") ||
|
||||
sizedToPopup.EqualsIgnoreCase("always"));
|
||||
|
||||
if (sizeToPopup) {
|
||||
if (IsSizedToPopup(mContent, PR_FALSE)) {
|
||||
nsSize tmpSize(-1,0);
|
||||
nsIBox::AddCSSPrefSize(aState, this, tmpSize);
|
||||
nscoord flex;
|
||||
|
@ -196,6 +196,8 @@ public:
|
||||
mFrameConstructor = aFC;
|
||||
}
|
||||
|
||||
static PRBool IsSizedToPopup(nsIContent* aContent, PRBool aRequireAlways);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void RePositionPopup(nsBoxLayoutState& aState);
|
||||
|
@ -1163,14 +1163,10 @@ nsMenuPopupFrame::SyncViewWithFrame(nsIPresContext* aPresContext,
|
||||
aFrame->GetContent(getter_AddRefs(parentContent));
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
mContent->GetTag(*getter_AddRefs(tag));
|
||||
if (tag.get() != nsXULAtoms::tooltip) {
|
||||
nsAutoString sizeToContent;
|
||||
parentContent->GetAttr(kNameSpaceID_None, nsXULAtoms::sizetopopup, sizeToContent);
|
||||
if (sizeToContent == NS_LITERAL_STRING("pref") ||
|
||||
sizeToContent == NS_LITERAL_STRING("always")) {
|
||||
if (tag.get() != nsXULAtoms::tooltip &&
|
||||
nsMenuFrame::IsSizedToPopup(parentContent, PR_FALSE)) {
|
||||
nsBoxLayoutState state(mPresContext);
|
||||
SetBounds(state, nsRect(mRect.x, mRect.y, parentRect.width, mRect.height));
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString shouldDisplay, menuActive;
|
||||
|
Loading…
Reference in New Issue
Block a user