diff --git a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp index ea3be739d86..a7c21109d66 100644 --- a/mozilla/content/html/content/src/nsHTMLButtonElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLButtonElement.cpp @@ -56,7 +56,7 @@ #include "nsIDocument.h" #include "nsGUIEvent.h" #include "nsUnicharUtils.h" - +#include "nsLayoutUtils.h" class nsHTMLButtonElement : public nsGenericHTMLFormElement, public nsIDOMHTMLButtonElement, @@ -250,7 +250,7 @@ nsHTMLButtonElement::SetFocus(nsPresContext* aPresContext) nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { formControlFrame->SetFocus(PR_TRUE, PR_TRUE); - formControlFrame->ScrollIntoView(aPresContext); + nsLayoutUtils::ScrollIntoView(formControlFrame); } } } diff --git a/mozilla/content/html/content/src/nsHTMLInputElement.cpp b/mozilla/content/html/content/src/nsHTMLInputElement.cpp index 7a6b17acab9..779a788032f 100644 --- a/mozilla/content/html/content/src/nsHTMLInputElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLInputElement.cpp @@ -84,6 +84,7 @@ #include "nsLinebreakConverter.h" //to strip out carriage returns #include "nsReadableUtils.h" #include "nsUnicharUtils.h" +#include "nsLayoutUtils.h" #include "nsIDOMMutationEvent.h" #include "nsIDOMEventReceiver.h" @@ -607,7 +608,7 @@ nsHTMLInputElement::GetValue(nsAString& aValue) } if (frameOwnsValue) { - formControlFrame->GetProperty(nsHTMLAtoms::value, aValue); + formControlFrame->GetFormProperty(nsHTMLAtoms::value, aValue); } else { if (!GET_BOOLBIT(mBitField, BF_VALUE_CHANGED) || !mValue) { GetDefaultValue(aValue); @@ -695,8 +696,7 @@ nsHTMLInputElement::SetValueInternal(const nsAString& aValue, } // If the frame owns the value, set the value in the frame if (frameOwnsValue) { - nsCOMPtr presContext = GetPresContext(); - formControlFrame->SetProperty(presContext, nsHTMLAtoms::value, aValue); + formControlFrame->SetFormProperty(nsHTMLAtoms::value, aValue); return NS_OK; } @@ -1075,7 +1075,7 @@ nsHTMLInputElement::SetFocus(nsPresContext* aPresContext) nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { formControlFrame->SetFocus(PR_TRUE, PR_TRUE); - formControlFrame->ScrollIntoView(aPresContext); + nsLayoutUtils::ScrollIntoView(formControlFrame); } } } @@ -1170,8 +1170,7 @@ nsHTMLInputElement::SelectAll(nsPresContext* aPresContext) nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { - formControlFrame->SetProperty(aPresContext, nsHTMLAtoms::select, - EmptyString()); + formControlFrame->SetFormProperty(nsHTMLAtoms::select, EmptyString()); } } @@ -2094,10 +2093,6 @@ nsHTMLInputElement::Reset() break; } - // Notify frame that it has been reset - if (formControlFrame) { - formControlFrame->OnContentReset(); - } return rv; } diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index f39f33d0e5a..124c2e9002b 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -48,6 +48,7 @@ #include "nsHTMLAtoms.h" #include "nsStyleConsts.h" #include "nsPresContext.h" +#include "nsLayoutUtils.h" #include "nsMappedAttributes.h" #include "nsIForm.h" #include "nsIFormSubmission.h" @@ -77,6 +78,8 @@ #include "nsIDocument.h" #include "nsIPresShell.h" #include "nsIFormControlFrame.h" +#include "nsIComboboxControlFrame.h" +#include "nsIListControlFrame.h" #include "nsIFrame.h" #include "nsDOMError.h" @@ -411,6 +414,12 @@ protected: return !isMultiple && size <= 1; } + /** + * Helper method for dispatching ContentReset notifications to list + * and combo box frames. + */ + void DispatchContentReset(); + /** The options[] array */ nsHTMLOptionCollection* mOptions; /** false if the parser is in the middle of adding children. */ @@ -1566,7 +1575,7 @@ nsHTMLSelectElement::SetFocus(nsPresContext* aPresContext) nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { formControlFrame->SetFocus(PR_TRUE, PR_TRUE); - formControlFrame->ScrollIntoView(aPresContext); + nsLayoutUtils::ScrollIntoView(formControlFrame); } } } @@ -1844,10 +1853,7 @@ nsHTMLSelectElement::RestoreState(nsPresState* aState) // Don't flush, if the frame doesn't exist yet it doesn't care if // we're reset or not. - nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_FALSE); - if (formControlFrame) { - formControlFrame->OnContentReset(); - } + DispatchContentReset(); } return PR_FALSE; @@ -1943,10 +1949,7 @@ nsHTMLSelectElement::Reset() // Don't flush, if there's no frame yet it won't care about us being // reset even if we forced it to be created now. // - nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_FALSE); - if (formControlFrame) { - formControlFrame->OnContentReset(); - } + DispatchContentReset(); return NS_OK; } @@ -2026,6 +2029,27 @@ nsHTMLSelectElement::DispatchDOMEvent(const nsAString& aName) aName, PR_TRUE, PR_TRUE); } +void nsHTMLSelectElement::DispatchContentReset() { + nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_FALSE); + if (formControlFrame) { + // Only dispatch content reset notification if this is a list control + // frame or combo box control frame. + if (IsCombobox()) { + nsIComboboxControlFrame* comboFrame = nsnull; + CallQueryInterface(formControlFrame, &comboFrame); + if (comboFrame) { + comboFrame->OnContentReset(); + } + } else { + nsIListControlFrame* listFrame = nsnull; + CallQueryInterface(formControlFrame, &listFrame); + if (listFrame) { + listFrame->OnContentReset(); + } + } + } +} + //---------------------------------------------------------------------- // // nsHTMLOptionCollection implementation diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index 50f08e00689..15b9be7c222 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -69,6 +69,7 @@ #include "nsIDOMText.h" #include "nsReadableUtils.h" #include "nsITextContent.h" +#include "nsLayoutUtils.h" static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID); @@ -253,7 +254,7 @@ nsHTMLTextAreaElement::SetFocus(nsPresContext* aPresContext) nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { formControlFrame->SetFocus(PR_TRUE, PR_TRUE); - formControlFrame->ScrollIntoView(aPresContext); + nsLayoutUtils::ScrollIntoView(formControlFrame); } } } @@ -311,8 +312,7 @@ nsHTMLTextAreaElement::SelectAll(nsPresContext* aPresContext) nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { - formControlFrame->SetProperty(aPresContext, nsHTMLAtoms::select, - EmptyString()); + formControlFrame->SetFormProperty(nsHTMLAtoms::select, EmptyString()); } return NS_OK; @@ -404,8 +404,7 @@ nsHTMLTextAreaElement::SetValueInternal(const nsAString& aValue, textControlFrame->OwnsValue(&frameOwnsValue); } if (frameOwnsValue) { - formControlFrame->SetProperty(GetPresContext(), - nsHTMLAtoms::value, aValue); + formControlFrame->SetFormProperty(nsHTMLAtoms::value, aValue); } else { if (mValue) { @@ -766,7 +765,6 @@ nsHTMLTextAreaElement::Reset() GetDefaultValue(resetVal); rv = SetValue(resetVal); NS_ENSURE_SUCCESS(rv, rv); - formControlFrame->OnContentReset(); } SetValueChanged(PR_FALSE); return NS_OK; diff --git a/mozilla/layout/base/nsLayoutUtils.cpp b/mozilla/layout/base/nsLayoutUtils.cpp index c279fe670d7..2ee7b791655 100644 --- a/mozilla/layout/base/nsLayoutUtils.cpp +++ b/mozilla/layout/base/nsLayoutUtils.cpp @@ -37,6 +37,7 @@ #include "nsLayoutUtils.h" #include "nsIFrame.h" +#include "nsIFormControlFrame.h" #include "nsPresContext.h" #include "nsIContent.h" #include "nsFrameList.h" @@ -597,3 +598,20 @@ nsLayoutUtils::BinarySearchForPosition(nsIRenderingContext* aRendContext, return PR_FALSE; } +void +nsLayoutUtils::ScrollIntoView(nsIFormControlFrame* aFormFrame) +{ + NS_ASSERTION(aFormFrame, "Null frame passed into ScrollIntoView"); + nsIFrame* frame = nsnull; + CallQueryInterface(aFormFrame, &frame); + NS_ASSERTION(frame, "Form frame did not implement nsIFrame."); + if (frame) { + nsIPresShell* presShell = frame->GetPresContext()->GetPresShell(); + if (presShell) { + presShell->ScrollFrameIntoView(frame, + NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE, + NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); + } + } +} + diff --git a/mozilla/layout/base/nsLayoutUtils.h b/mozilla/layout/base/nsLayoutUtils.h index 73024e37133..b2d453df65a 100644 --- a/mozilla/layout/base/nsLayoutUtils.h +++ b/mozilla/layout/base/nsLayoutUtils.h @@ -39,6 +39,7 @@ #define nsLayoutUtils_h__ class nsIFrame; +class nsIFormControlFrame; class nsPresContext; class nsIContent; class nsIAtom; @@ -321,6 +322,12 @@ public: PRInt32 aCursorPos, PRInt32& aIndex, PRInt32& aTextWidth); + + /** + * Scroll the given form control frame into view. + * @param aFormFrame Frame to scroll into view. + */ + static void ScrollIntoView(nsIFormControlFrame* aFormFrame); }; #endif // nsLayoutUtils_h__ diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index d8f613d88fe..7c7896d5805 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -42,6 +42,7 @@ #include "nsIDOMEventReceiver.h" #include "nsFrameManager.h" #include "nsFormControlFrame.h" +#include "nsGfxButtonControlFrame.h" #include "nsHTMLAtoms.h" #include "nsCSSAnonBoxes.h" #include "nsHTMLParts.h" @@ -418,64 +419,6 @@ nsComboboxControlFrame::Init(nsPresContext* aPresContext, return nsAreaFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); } -//-------------------------------------------------------------- -void -nsComboboxControlFrame::InitializeControl(nsPresContext* aPresContext) -{ - nsFormControlHelper::Reset(this, aPresContext); -} - -//-------------------------------------------------------------- -NS_IMETHODIMP_(PRInt32) -nsComboboxControlFrame::GetFormControlType() const -{ - return NS_FORM_SELECT; -} - -//-------------------------------------------------------------- -NS_IMETHODIMP -nsComboboxControlFrame::GetFormContent(nsIContent*& aContent) const -{ - aContent = GetContent(); - NS_IF_ADDREF(aContent); - return NS_OK; -} - -//-------------------------------------------------------------- -nscoord -nsComboboxControlFrame::GetVerticalBorderWidth(float aPixToTwip) const -{ - return 0; -} - - -//-------------------------------------------------------------- -nscoord -nsComboboxControlFrame::GetHorizontalBorderWidth(float aPixToTwip) const -{ - return 0; -} - - -//-------------------------------------------------------------- -nscoord -nsComboboxControlFrame::GetVerticalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerHeight) const -{ - return 0; -} - -//-------------------------------------------------------------- -nscoord -nsComboboxControlFrame::GetHorizontalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const -{ - return 0; -} - void nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) { @@ -505,19 +448,6 @@ nsComboboxControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) } } -void -nsComboboxControlFrame::ScrollIntoView(nsPresContext* aPresContext) -{ - if (aPresContext) { - nsIPresShell *presShell = aPresContext->GetPresShell(); - if (presShell) { - presShell->ScrollFrameIntoView(this, - NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); - } - } -} - - void nsComboboxControlFrame::ShowPopup(PRBool aShowPopup) { @@ -627,17 +557,16 @@ nsComboboxControlFrame::ReflowComboChildFrame(nsIFrame* aFrame, return rv; } -// Suggest a size for the child frame. -// Only frames which implement the nsIFormControlFrame interface and -// honor the SetSuggestedSize method will be placed and sized correctly. - +// Resize the child button frame to the specified size. void -nsComboboxControlFrame::SetChildFrameSize(nsIFrame* aFrame, nscoord aWidth, nscoord aHeight) +nsComboboxControlFrame::SetButtonFrameSize(const nsSize& aSize) { - nsIFormControlFrame* fcFrame = nsnull; - nsresult result = aFrame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame); - if (NS_SUCCEEDED(result) && (nsnull != fcFrame)) { - fcFrame->SetSuggestedSize(aWidth, aHeight); + // Check that the child frame being resized is an nsGfxButtonControlFrame. + if (mButtonFrame->GetType() == nsLayoutAtoms::gfxButtonControlFrame) { + NS_STATIC_CAST(nsGfxButtonControlFrame*, mButtonFrame)->SetSuggestedSize(aSize); + } else { + // This function should never be called with another frame type. + NS_NOTREACHED("Wrong type in SetButtonFrameSize"); } } @@ -841,7 +770,6 @@ nsComboboxControlFrame::ReflowCombobox(nsPresContext * aPresContext, nsHTMLReflowMetrics& aDesiredSize, nsReflowStatus& aStatus, nsIFrame * aDisplayFrame, - nsIFrame * aDropDownBtn, nscoord& aDisplayWidth, nscoord aBtnWidth, const nsMargin& aBorderPadding, @@ -880,8 +808,8 @@ nsComboboxControlFrame::ReflowCombobox(nsPresContext * aPresContext, nsRect displayRect(0,0,0,0); aBtnWidth = 0; aDisplayFrame->SetRect(displayRect); - aDropDownBtn->SetRect(buttonRect); - SetChildFrameSize(aDropDownBtn, aBtnWidth, aDesiredSize.height); + mButtonFrame->SetRect(buttonRect); + SetButtonFrameSize(nsSize(aBtnWidth, aDesiredSize.height)); aDesiredSize.width = 0; aDesiredSize.height = dispHeight + aBorderPadding.top + aBorderPadding.bottom; // XXX What about ascent and descent? @@ -893,7 +821,7 @@ nsComboboxControlFrame::ReflowCombobox(nsPresContext * aPresContext, // This sets the button to be a specific size // so no matter what it reflows at these values - SetChildFrameSize(aDropDownBtn, aBtnWidth, dispHeight); + SetButtonFrameSize(nsSize(aBtnWidth, dispHeight)); #ifdef FIX_FOR_BUG_53259 // Make sure we obey min/max-width and min/max-height @@ -1012,11 +940,11 @@ nsComboboxControlFrame::ReflowCombobox(nsPresContext * aPresContext, } } #endif // IBMBIDI - aDropDownBtn->SetRect(buttonRect); + mButtonFrame->SetRect(buttonRect); // since we have changed the height of the button // make sure it has these new values - SetChildFrameSize(aDropDownBtn, aBtnWidth, aDesiredSize.height); + SetButtonFrameSize(nsSize(aBtnWidth, aDesiredSize.height)); // This is a last minute adjustment, if the CSS width was set and // we calculated it to be a little big, then make sure we are no bigger the computed size @@ -1239,7 +1167,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext, // so do a simple reflow and bail out REFLOW_DEBUG_MSG("------------Reflowing AreaFrame and bailing----\n\n"); ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus, - mDisplayFrame, mButtonFrame, mItemDisplayWidth, + mDisplayFrame, mItemDisplayWidth, scrollbarWidth, aReflowState.mComputedBorderPadding); REFLOW_COUNTER(); UNCONSTRAINED_CHECK(); @@ -1297,8 +1225,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext, REFLOW_DEBUG_MSG("---- Doing AreaFrame Reflow and then bailing out\n"); // Do simple reflow and bail out ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus, - mDisplayFrame, mButtonFrame, - mItemDisplayWidth, scrollbarWidth, + mDisplayFrame, mItemDisplayWidth, scrollbarWidth, aReflowState.mComputedBorderPadding, kSizeNotSet, PR_TRUE); REFLOW_DEBUG_MSG3("+** Done nsCCF DW: %d DH: %d\n\n", PX(aDesiredSize.width), PX(aDesiredSize.height)); @@ -1529,7 +1456,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext, // this reflows and makes and last minute adjustments ReflowCombobox(aPresContext, firstPassState, aDesiredSize, aStatus, - mDisplayFrame, mButtonFrame, mItemDisplayWidth, scrollbarWidth, + mDisplayFrame, mItemDisplayWidth, scrollbarWidth, aReflowState.mComputedBorderPadding, size.height); // The dropdown was reflowed UNCONSTRAINED before, now we need to reflow it @@ -1607,13 +1534,6 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext, } //-------------------------------------------------------------- -NS_IMETHODIMP -nsComboboxControlFrame::GetName(nsAString* aResult) -{ - nsFormControlHelper::GetName(mContent, aResult); - - return NS_OK; -} nsIFrame* nsComboboxControlFrame::GetFrameForPoint(const nsPoint& aPoint, @@ -1935,26 +1855,32 @@ nsComboboxControlFrame::HandleEvent(nsPresContext* aPresContext, } -NS_IMETHODIMP -nsComboboxControlFrame::SetProperty(nsPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue) +nsresult +nsComboboxControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue) { nsIFormControlFrame* fcFrame = nsnull; nsresult result = CallQueryInterface(mDropdownFrame, &fcFrame); - if ((NS_SUCCEEDED(result)) && (nsnull != fcFrame)) { - return fcFrame->SetProperty(aPresContext, aName, aValue); + if (NS_FAILED(result)) { + return result; } - return result; + if (fcFrame) { + return fcFrame->SetFormProperty(aName, aValue); + } + return NS_OK; } -NS_IMETHODIMP -nsComboboxControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue) +nsresult +nsComboboxControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const { nsIFormControlFrame* fcFrame = nsnull; nsresult result = CallQueryInterface(mDropdownFrame, &fcFrame); - if ((NS_SUCCEEDED(result)) && (nsnull != fcFrame)) { - return fcFrame->GetProperty(aName, aValue); + if(NS_FAILED(result)) { + return result; } - return result; + if (fcFrame) { + return fcFrame->GetFormProperty(aName, aValue); + } + return NS_OK; } nsIFrame* @@ -1974,10 +1900,8 @@ nsComboboxControlFrame::CreateAnonymousContent(nsPresContext* aPresContext, // // Note: The value attribute of the display content is set when an item is selected in the dropdown list. // If the content specified below does not honor the value attribute than nothing will be displayed. - // In addition, if the frame created by content below for does not implement the nsIFormControlFrame - // interface and honor the SetSuggestedSize method the placement and size of the display area will not - // match what is normally desired for a combobox. - + // In addition, if the frame created by content below for the button is not an nsGfxScrollFrame + // things will go wrong ... see SetButtonFrameSize. // For now the content that is created corresponds to two input buttons. It would be better to create the // tag as something other than input, but then there isn't any way to create a button frame since it @@ -2105,17 +2029,6 @@ nsComboboxControlFrame::CreateFrameFor(nsPresContext* aPresContext, return NS_OK; } - - - -NS_IMETHODIMP -nsComboboxControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight) -{ - return NS_OK; -} - - - NS_IMETHODIMP nsComboboxControlFrame::Destroy(nsPresContext* aPresContext) { @@ -2178,9 +2091,8 @@ nsComboboxControlFrame::SetInitialChildList(nsPresContext* aPresContext, for (nsIFrame * child = aChildList; child; child = child->GetNextSibling()) { - nsIFormControlFrame* fcFrame = nsnull; - CallQueryInterface(child, &fcFrame); - if (fcFrame && fcFrame->GetFormControlType() == NS_FORM_INPUT_BUTTON) { + nsCOMPtr formControl = do_QueryInterface(child->GetContent()); + if (formControl && formControl->GetType() == NS_FORM_INPUT_BUTTON) { mButtonFrame = child; break; } @@ -2385,15 +2297,12 @@ void nsComboboxControlFrame::FireValueChangeEvent() } } -NS_IMETHODIMP +void nsComboboxControlFrame::OnContentReset() { if (mListControlFrame) { - nsCOMPtr formControl = - do_QueryInterface(mListControlFrame); - formControl->OnContentReset(); + mListControlFrame->OnContentReset(); } - return NS_OK; } diff --git a/mozilla/layout/forms/nsComboboxControlFrame.h b/mozilla/layout/forms/nsComboboxControlFrame.h index c12b1a273f9..1e464680f53 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.h +++ b/mozilla/layout/forms/nsComboboxControlFrame.h @@ -143,26 +143,10 @@ public: virtual nsIFrame* GetContentInsertionFrame(); - // nsIFormControlFrame - NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); - NS_IMETHOD GetName(nsAString* aName); - NS_IMETHOD_(PRInt32) GetFormControlType() const; - NS_IMETHOD SetProperty(nsPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); - NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); - void SetFocus(PRBool aOn, PRBool aRepaint); - void ScrollIntoView(nsPresContext* aPresContext); - virtual void InitializeControl(nsPresContext* aPresContext); - NS_IMETHOD OnContentReset(); - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; - virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const; - virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const; - virtual nscoord GetVerticalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerHeight) const; - virtual nscoord GetHorizontalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const; + // nsIFormControlFrame + virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue); + virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const; + virtual void SetFocus(PRBool aOn, PRBool aRepaint); //nsIComboboxControlFrame NS_IMETHOD IsDroppedDown(PRBool * aDoDropDown) { *aDoDropDown = mDroppedDown; return NS_OK; } @@ -175,6 +159,7 @@ public: NS_IMETHOD GetIndexOfDisplayArea(PRInt32* aSelectedIndex); NS_IMETHOD RedisplaySelectedText(); NS_IMETHOD_(PRInt32) UpdateRecentIndex(PRInt32 aIndex); + virtual void OnContentReset(); // nsISelectControlFrame NS_IMETHOD AddOption(nsPresContext* aPresContext, PRInt32 index); @@ -237,7 +222,7 @@ public: protected: void ShowPopup(PRBool aShowPopup); void ShowList(nsPresContext* aPresContext, PRBool aShowList); - void SetChildFrameSize(nsIFrame* aFrame, nscoord aWidth, nscoord aHeight); + void SetButtonFrameSize(const nsSize& aSize); void CheckFireOnChange(); void FireValueChangeEvent(); nsresult RedisplayText(PRInt32 aIndex); @@ -251,7 +236,6 @@ protected: nsHTMLReflowMetrics& aDesiredSize, nsReflowStatus& aStatus, nsIFrame * aDisplayFrame, - nsIFrame * aDropDownBtn, nscoord& aDisplayWidth, nscoord aBtnWidth, const nsMargin& aBorderPadding, diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp index 4efbf1e7570..15385a260a2 100644 --- a/mozilla/layout/forms/nsFileControlFrame.cpp +++ b/mozilla/layout/forms/nsFileControlFrame.cpp @@ -254,13 +254,6 @@ nsFileControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr); } -NS_IMETHODIMP_(PRInt32) -nsFileControlFrame::GetFormControlType() const -{ - return NS_FORM_INPUT_FILE; -} - - void nsFileControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) { @@ -273,18 +266,6 @@ nsFileControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) } } -void -nsFileControlFrame::ScrollIntoView(nsPresContext* aPresContext) -{ - if (aPresContext) { - nsIPresShell *presShell = aPresContext->GetPresShell(); - if (presShell) { - presShell->ScrollFrameIntoView(this, - NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); - } - } -} - /** * This is called when our browse button is clicked */ @@ -332,7 +313,7 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent) // Set default directry and filename nsAutoString defaultName; - GetProperty(nsHTMLAtoms::value, defaultName); + GetFormProperty(nsHTMLAtoms::value, defaultName); nsCOMPtr currentFile = do_CreateInstance("@mozilla.org/file/local;1"); if (currentFile && !defaultName.IsEmpty()) { @@ -378,8 +359,7 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent) nsAutoString unicodePath; result = localFile->GetPath(unicodePath); if (!unicodePath.IsEmpty()) { - mTextFrame->SetProperty(GetPresContext(), nsHTMLAtoms::value, - unicodePath); + mTextFrame->SetFormProperty(nsHTMLAtoms::value, unicodePath); // May need to fire an onchange here mTextFrame->CheckFireOnChange(); return NS_OK; @@ -402,9 +382,9 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsPresContext* aPresContext, if (eReflowReason_Initial == aReflowState.reason) { mTextFrame = GetTextControlFrame(aPresContext, this); - if (!mTextFrame) return NS_ERROR_UNEXPECTED; + NS_ENSURE_TRUE(mTextFrame, NS_ERROR_UNEXPECTED); if (mCachedState) { - mTextFrame->SetProperty(aPresContext, nsHTMLAtoms::value, *mCachedState); + mTextFrame->SetFormProperty(nsHTMLAtoms::value, *mCachedState); delete mCachedState; mCachedState = nsnull; } @@ -524,15 +504,6 @@ nsFileControlFrame::GetSkipSides() const return 0; } - -NS_IMETHODIMP -nsFileControlFrame::GetName(nsAString* aResult) -{ - nsFormControlHelper::GetName(mContent, aResult); - - return NS_OK; -} - void nsFileControlFrame::SyncAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aWhichControls) @@ -604,49 +575,23 @@ nsFileControlFrame::GetFrameName(nsAString& aResult) const } #endif -NS_IMETHODIMP -nsFileControlFrame::GetFormContent(nsIContent*& aContent) const -{ - aContent = GetContent(); - NS_IF_ADDREF(aContent); - return NS_OK; -} - -nscoord -nsFileControlFrame::GetVerticalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerHeight) const -{ - return 0; -} - -nscoord -nsFileControlFrame::GetHorizontalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const -{ - return 0; -} - -NS_IMETHODIMP nsFileControlFrame::SetProperty(nsPresContext* aPresContext, - nsIAtom* aName, +NS_IMETHODIMP nsFileControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue) { - nsresult rv = NS_OK; if (nsHTMLAtoms::value == aName) { if (mTextFrame) { mTextFrame->SetValue(aValue); } else { if (mCachedState) delete mCachedState; mCachedState = new nsString(aValue); - if (!mCachedState) rv = NS_ERROR_OUT_OF_MEMORY; + NS_ENSURE_TRUE(mCachedState, NS_ERROR_OUT_OF_MEMORY); } } - return rv; + return NS_OK; } -NS_IMETHODIMP nsFileControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue) +nsresult +nsFileControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const { aValue.Truncate(); // initialize out param @@ -681,8 +626,3 @@ nsFileControlFrame::Paint(nsPresContext* aPresContext, return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer); } -NS_IMETHODIMP -nsFileControlFrame::OnContentReset() -{ - return NS_OK; -} diff --git a/mozilla/layout/forms/nsFileControlFrame.h b/mozilla/layout/forms/nsFileControlFrame.h index cead4c81a97..104924a87ed 100644 --- a/mozilla/layout/forms/nsFileControlFrame.h +++ b/mozilla/layout/forms/nsFileControlFrame.h @@ -73,12 +73,12 @@ public: const nsRect& aDirtyRect, nsFramePaintLayer aWhichLayer, PRUint32 aFlags = 0); - - // nsIFormControlFrame - NS_IMETHOD SetProperty(nsPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); - NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - NS_IMETHOD OnContentReset(); + + // nsIFormControlFrame + virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue); + virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const; + virtual void SetFocus(PRBool aOn, PRBool aRepaint); NS_IMETHOD Reflow(nsPresContext* aCX, nsHTMLReflowMetrics& aDesiredSize, @@ -92,7 +92,7 @@ public: #ifdef NS_DEBUG NS_IMETHOD GetFrameName(nsAString& aResult) const; #endif - NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight) { return NS_OK; }; + virtual nsIFrame* GetFrameForPoint(const nsPoint& aPoint, nsFramePaintLayer aWhichLayer); NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, @@ -100,19 +100,7 @@ public: PRInt32 aModType); virtual PRBool IsLeaf() const; - NS_IMETHOD GetName(nsAString* aName); - NS_IMETHOD_(PRInt32) GetFormControlType() const; - void SetFocus(PRBool aOn, PRBool aRepaint); - void ScrollIntoView(nsPresContext* aPresContext); - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; - virtual nscoord GetVerticalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerHeight) const; - virtual nscoord GetHorizontalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const; // from nsIAnonymousContentCreator NS_IMETHOD CreateAnonymousContent(nsPresContext* aPresContext, diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp index 63ee15c381e..39dbf9291e0 100644 --- a/mozilla/layout/forms/nsFormControlFrame.cpp +++ b/mozilla/layout/forms/nsFormControlFrame.cpp @@ -108,8 +108,6 @@ nsFormControlFrame::nsFormControlFrame() : nsLeafFrame() { mDidInit = PR_FALSE; - mSuggestedWidth = NS_FORMSIZE_NOTSET; - mSuggestedHeight = NS_FORMSIZE_NOTSET; // Reflow Optimization mCacheSize.width = kSizeNotSet; @@ -529,7 +527,7 @@ nsFormControlFrame::Reflow(nsPresContext* aPresContext, DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); if (!mDidInit) { - InitializeControl(aPresContext); + RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE); mDidInit = PR_TRUE; } @@ -580,29 +578,11 @@ nsFormControlFrame::RegUnRegAccessKey(nsPresContext* aPresContext, nsIFrame * aF return NS_ERROR_FAILURE; } -void -nsFormControlFrame::InitializeControl(nsPresContext* aPresContext) -{ - RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE); -} - void nsFormControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) { } -void -nsFormControlFrame::ScrollIntoView(nsPresContext* aPresContext) -{ - if (aPresContext) { - nsIPresShell *presShell = aPresContext->GetPresShell(); - if (presShell) { - presShell->ScrollFrameIntoView(this, - NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); - } - } -} - /* * FIXME: this ::GetIID() method has no meaning in life and should be * removed. @@ -621,30 +601,6 @@ nsFormControlFrame::GetCID() return kButtonCID; } -NS_IMETHODIMP_(PRInt32) -nsFormControlFrame::GetFormControlType() const -{ - return nsFormControlHelper::GetType(mContent); -} - -NS_IMETHODIMP -nsFormControlFrame::GetName(nsAString* aResult) -{ - nsFormControlHelper::GetName(mContent, aResult); - - return NS_OK; -} - - -NS_IMETHODIMP -nsFormControlFrame::GetValue(nsAString* aResult) -{ - nsFormControlHelper::GetValueAttr(mContent, aResult); - - return NS_OK; -} - - NS_METHOD nsFormControlFrame::HandleEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent, @@ -697,14 +653,6 @@ nsFormControlFrame::GetStyleSize(nsPresContext* aPresContext, } } -NS_IMETHODIMP -nsFormControlFrame::GetFormContent(nsIContent*& aContent) const -{ - aContent = GetContent(); - NS_IF_ADDREF(aContent); - return NS_OK; -} - void nsFormControlFrame::GetCurrentCheckState(PRBool *aState) { @@ -714,27 +662,19 @@ nsFormControlFrame::GetCurrentCheckState(PRBool *aState) } } -NS_IMETHODIMP -nsFormControlFrame::SetProperty(nsPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue) +nsresult +nsFormControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue) { return NS_OK; } -NS_IMETHODIMP -nsFormControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue) +nsresult +nsFormControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const { aValue.Truncate(); return NS_OK; } -NS_IMETHODIMP -nsFormControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight) -{ - mSuggestedWidth = aWidth; - mSuggestedHeight = aHeight; - return NS_OK; -} - nsresult nsFormControlFrame::GetScreenHeight(nsPresContext* aPresContext, nscoord& aHeight) diff --git a/mozilla/layout/forms/nsFormControlFrame.h b/mozilla/layout/forms/nsFormControlFrame.h index f17bc894338..aa3af6e3e60 100644 --- a/mozilla/layout/forms/nsFormControlFrame.h +++ b/mozilla/layout/forms/nsFormControlFrame.h @@ -150,10 +150,6 @@ public: */ virtual const nsIID& GetIID(); - NS_IMETHOD_(PRInt32) GetFormControlType() const; - NS_IMETHOD GetName(nsAString* aName); - NS_IMETHOD GetValue(nsAString* aName); - /** * Respond to a enter key being pressed */ @@ -164,13 +160,7 @@ public: */ virtual void ControlChanged(nsPresContext* aPresContext) {} - /** - * Chance to Initialize to a default value - */ - virtual void InitializeControl(nsPresContext* aPresContext); - virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE); - virtual void ScrollIntoView(nsPresContext* aPresContext); /** * Perform opertations before the widget associated with this frame has been @@ -187,8 +177,6 @@ public: virtual void SetClickPoint(nscoord aX, nscoord aY); - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; - /** * Get the width and height of this control based on CSS * @param aPresContext the presentation context @@ -199,11 +187,12 @@ public: const nsHTMLReflowState& aReflowState, nsSize& aSize); - // nsIFormControlFrame - NS_IMETHOD SetProperty(nsPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); + // nsIFormControlFrame + virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue); - NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); - // Resize Reflow Optimiaztion Methods + virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const; + + // Resize Reflow Optimization Methods static void SetupCachedSizes(nsSize& aCacheSize, nscoord& aCachedAscent, nscoord& aCachedMaxElementWidth, @@ -253,9 +242,6 @@ protected: const nsHTMLReflowState& aReflowState, nsHTMLReflowMetrics& aDesiredLayoutSize, nsSize& aDesiredWidgetSize); - - NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); - // //------------------------------------------------------------------------------------- // Utility methods for managing checkboxes and radiobuttons @@ -268,12 +254,10 @@ protected: */ void GetCurrentCheckState(PRBool* aState); - + nsSize mWidgetSize; PRBool mDidInit; nsPoint mLastClickPoint; - nscoord mSuggestedWidth; - nscoord mSuggestedHeight; // Reflow Optimization nsSize mCacheSize; diff --git a/mozilla/layout/forms/nsFormControlHelper.cpp b/mozilla/layout/forms/nsFormControlHelper.cpp index 30a57f92068..8d386a39419 100644 --- a/mozilla/layout/forms/nsFormControlHelper.cpp +++ b/mozilla/layout/forms/nsFormControlHelper.cpp @@ -118,7 +118,6 @@ void nsFormControlHelper::GetBoolString(const PRBool aValue, aResult.Assign(NS_STRING_FALSE); } - nsresult nsFormControlHelper::GetFrameFontFM(nsIFrame* aFrame, nsIFontMetrics** aFontMet) { @@ -319,26 +318,6 @@ nsFormControlHelper::PaintCheckMark(nsIRenderingContext& aRenderingContext, aRenderingContext.FillPolygon(checkedPolygon, checkpoints); } -PRBool -nsFormControlHelper::GetName(nsIContent* aContent, nsAString* aResult) -{ - NS_PRECONDITION(aResult, "Null pointer bad!"); - return aContent->IsContentOfType(nsIContent::eHTML) && - aContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::name, *aResult); -} - -PRInt32 -nsFormControlHelper::GetType(nsIContent* aContent) -{ - nsCOMPtr formControl(do_QueryInterface(aContent)); - if (formControl) { - return formControl->GetType(); - } - - NS_ERROR("Form control not implementing nsIFormControl, assuming TEXT type"); - return NS_FORM_INPUT_TEXT; -} - PRBool nsFormControlHelper::GetValueAttr(nsIContent* aContent, nsAString* aResult) { diff --git a/mozilla/layout/forms/nsFormControlHelper.h b/mozilla/layout/forms/nsFormControlHelper.h index 5ae9d3238ae..86613ed10eb 100644 --- a/mozilla/layout/forms/nsFormControlHelper.h +++ b/mozilla/layout/forms/nsFormControlHelper.h @@ -94,20 +94,7 @@ public: static PRBool GetDisabled(nsIContent* aContent) { return aContent->HasAttr(kNameSpaceID_None, nsHTMLAtoms::disabled); }; - /** - * Get the name of the form control - * @param aContent the content to get the name of - * @param aResult the returned name of the form control [OUT] - * @return PR_TRUE if things go well - * PR_FALSE if the name attribute is undefined - */ - static PRBool GetName(nsIContent* aContent, nsAString* aResult); - /** - * Get the type of the form control (if it's not obvious from the frame type) - * @param aContent the content to get the name of - * @return the returned type of the form control [OUT] - */ - static PRInt32 GetType(nsIContent* aContent); + /** * Get the value of the form control (if it's just living in an attr) * @param aContent the content to get the name of @@ -137,6 +124,7 @@ public: * if aValue equals PR_TRUE, "0" if aValue equals PR_FALSE. */ static void GetBoolString(const PRBool aValue, nsAString& aResult); + static void GetRepChars(char& char1, char& char2) { char1 = 'W'; diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp index 0702330194a..b6391a66fd0 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.cpp @@ -60,10 +60,9 @@ const nscoord kSuggestedNotSet = -1; -nsGfxButtonControlFrame::nsGfxButtonControlFrame() +nsGfxButtonControlFrame::nsGfxButtonControlFrame(): +mSuggestedSize(kSuggestedNotSet, kSuggestedNotSet) { - mSuggestedWidth = kSuggestedNotSet; - mSuggestedHeight = kSuggestedNotSet; } nsIFrame* @@ -126,11 +125,11 @@ NS_IMETHODIMP nsGfxButtonControlFrame::AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aSuggestedReflowState) { - if (kSuggestedNotSet == mSuggestedWidth) { + if (kSuggestedNotSet == mSuggestedSize.width) { aDesiredSize.width += aSuggestedReflowState.mComputedBorderPadding.left + aSuggestedReflowState.mComputedBorderPadding.right; } - if (kSuggestedNotSet == mSuggestedHeight) { + if (kSuggestedNotSet == mSuggestedSize.height) { aDesiredSize.height += aSuggestedReflowState.mComputedBorderPadding.top + aSuggestedReflowState.mComputedBorderPadding.bottom; } return NS_OK; @@ -144,10 +143,10 @@ nsGfxButtonControlFrame::CreateAnonymousContent(nsPresContext* aPresContext, { // Get the text from the "value" attribute. // If it is zero length, set it to a default value (localized) - nsAutoString initvalue; - GetValue(&initvalue); + nsAutoString initValue; + nsFormControlHelper::GetValueAttr(mContent, &initValue); nsXPIDLString value; - value.Assign(initvalue); + value.Assign(initValue); if (value.IsEmpty()) { // Generate localized label. // We can't make any assumption as to what the default would be @@ -274,8 +273,10 @@ else { nsresult nsGfxButtonControlFrame::GetDefaultLabel(nsXPIDLString& aString) { - nsresult rv = NS_OK; - PRInt32 type = GetFormControlType(); + nsCOMPtr form = do_QueryInterface(mContent); + NS_ENSURE_TRUE(form, NS_ERROR_UNEXPECTED); + + PRInt32 type = form->GetType(); const char *prop; if (type == NS_FORM_INPUT_RESET) { prop = "Reset"; @@ -334,17 +335,17 @@ nsGfxButtonControlFrame::Reflow(nsPresContext* aPresContext, DO_GLOBAL_REFLOW_COUNT("nsGfxButtonControlFrame", aReflowState.reason); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); - if ((kSuggestedNotSet != mSuggestedWidth) || - (kSuggestedNotSet != mSuggestedHeight)) { + if ((kSuggestedNotSet != mSuggestedSize.width) || + (kSuggestedNotSet != mSuggestedSize.height)) { nsHTMLReflowState suggestedReflowState(aReflowState); // Honor the suggested width and/or height. - if (kSuggestedNotSet != mSuggestedWidth) { - suggestedReflowState.mComputedWidth = mSuggestedWidth; + if (kSuggestedNotSet != mSuggestedSize.width) { + suggestedReflowState.mComputedWidth = mSuggestedSize.width; } - if (kSuggestedNotSet != mSuggestedHeight) { - suggestedReflowState.mComputedHeight = mSuggestedHeight; + if (kSuggestedNotSet != mSuggestedSize.height) { + suggestedReflowState.mComputedHeight = mSuggestedSize.height; } return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, suggestedReflowState, aStatus); @@ -356,13 +357,11 @@ nsGfxButtonControlFrame::Reflow(nsPresContext* aPresContext, return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); } -NS_IMETHODIMP -nsGfxButtonControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight) +void +nsGfxButtonControlFrame::SetSuggestedSize(const nsSize& aSize) { - mSuggestedWidth = aWidth; - mSuggestedHeight = aHeight; + mSuggestedSize = aSize; //mState |= NS_FRAME_IS_DIRTY; - return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/layout/forms/nsGfxButtonControlFrame.h b/mozilla/layout/forms/nsGfxButtonControlFrame.h index a1c87866e8d..d3ed1b88a1b 100644 --- a/mozilla/layout/forms/nsGfxButtonControlFrame.h +++ b/mozilla/layout/forms/nsGfxButtonControlFrame.h @@ -78,8 +78,6 @@ public: virtual nsIAtom* GetType() const; - // nsFormControlFrame - NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); #ifdef DEBUG NS_IMETHOD GetFrameName(nsAString& aResult) const; #endif @@ -98,6 +96,14 @@ public: PRInt32 aModType); virtual PRBool IsLeaf() const; + + /** + * Set the suggested size of the button. + * @note This is NOT a virtual function, it will be called + * directly on an instance of this class. + * @param aSize The suggested size. + */ + void SetSuggestedSize(const nsSize& aSize); protected: NS_IMETHOD AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize, @@ -110,8 +116,7 @@ private: NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; } - nscoord mSuggestedWidth; - nscoord mSuggestedHeight; + nsSize mSuggestedSize; nsCOMPtr mTextContent; }; diff --git a/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp b/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp index 72a4506512a..4a26772c4b1 100644 --- a/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxCheckboxControlFrame.cpp @@ -284,8 +284,3 @@ nsGfxCheckboxControlFrame::Reflow(nsPresContext* aPresContext, } #endif -NS_IMETHODIMP -nsGfxCheckboxControlFrame::OnContentReset() -{ - return NS_OK; -} diff --git a/mozilla/layout/forms/nsGfxCheckboxControlFrame.h b/mozilla/layout/forms/nsGfxCheckboxControlFrame.h index a36e5bafe69..9f0dce864ba 100644 --- a/mozilla/layout/forms/nsGfxCheckboxControlFrame.h +++ b/mozilla/layout/forms/nsGfxCheckboxControlFrame.h @@ -84,9 +84,6 @@ public: virtual void SetAdditionalStyleContext(PRInt32 aIndex, nsStyleContext* aStyleContext); - // nsIFormControlFrame - NS_IMETHOD OnContentReset(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); #ifdef DEBUG_rodsXXX diff --git a/mozilla/layout/forms/nsGfxRadioControlFrame.cpp b/mozilla/layout/forms/nsGfxRadioControlFrame.cpp index 4ca72bd0a39..e7075bbb265 100644 --- a/mozilla/layout/forms/nsGfxRadioControlFrame.cpp +++ b/mozilla/layout/forms/nsGfxRadioControlFrame.cpp @@ -260,8 +260,3 @@ nsGfxRadioControlFrame::Reflow(nsPresContext* aPresContext, } #endif -NS_IMETHODIMP -nsGfxRadioControlFrame::OnContentReset() -{ - return NS_OK; -} diff --git a/mozilla/layout/forms/nsGfxRadioControlFrame.h b/mozilla/layout/forms/nsGfxRadioControlFrame.h index 96cf169570b..83d00010d5d 100644 --- a/mozilla/layout/forms/nsGfxRadioControlFrame.h +++ b/mozilla/layout/forms/nsGfxRadioControlFrame.h @@ -91,9 +91,6 @@ public: nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect); - // nsIFormControlFrame - NS_IMETHOD OnContentReset(); - ///XXX: End o the temporary methods #ifdef DEBUG_rodsXXX NS_IMETHOD Reflow(nsPresContext* aCX, diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp index 75d44781085..0161cd18cec 100644 --- a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp @@ -169,29 +169,6 @@ NS_IMETHODIMP nsHTMLButtonControlFrame::GetAccessible(nsIAccessible** aAccessibl } #endif - -NS_IMETHODIMP_(PRInt32) -nsHTMLButtonControlFrame::GetFormControlType() const -{ - return nsFormControlHelper::GetType(mContent); -} - -NS_IMETHODIMP -nsHTMLButtonControlFrame::GetName(nsAString* aResult) -{ - nsFormControlHelper::GetName(mContent, aResult); - - return NS_OK; -} - -NS_IMETHODIMP -nsHTMLButtonControlFrame::GetValue(nsAString* aResult) -{ - nsFormControlHelper::GetValueAttr(mContent, aResult); - - return NS_OK; -} - void nsHTMLButtonControlFrame::ReParentFrameList(nsFrameManager* aFrameManager, nsIFrame* aFrameList) @@ -236,19 +213,6 @@ nsHTMLButtonControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) { } -void -nsHTMLButtonControlFrame::ScrollIntoView(nsPresContext* aPresContext) -{ - if (aPresContext) { - nsIPresShell *presShell = aPresContext->GetPresShell(); - if (presShell) { - presShell->ScrollFrameIntoView(this, - NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); - - } - } -} - NS_IMETHODIMP nsHTMLButtonControlFrame::HandleEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent, @@ -555,33 +519,7 @@ nsHTMLButtonControlFrame::GetSkipSides() const return 0; } -NS_IMETHODIMP -nsHTMLButtonControlFrame::GetFormContent(nsIContent*& aContent) const -{ - aContent = GetContent(); - NS_IF_ADDREF(aContent); - return NS_OK; -} - -nscoord -nsHTMLButtonControlFrame::GetVerticalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerHeight) const -{ - return 0; -} - -nscoord -nsHTMLButtonControlFrame::GetHorizontalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const -{ - return 0; -} - -NS_IMETHODIMP nsHTMLButtonControlFrame::SetProperty(nsPresContext* aPresContext, - nsIAtom* aName, const nsAString& aValue) +nsresult nsHTMLButtonControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue) { if (nsHTMLAtoms::value == aName) { return mContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::value, @@ -590,7 +528,7 @@ NS_IMETHODIMP nsHTMLButtonControlFrame::SetProperty(nsPresContext* aPresContext, return NS_OK; } -NS_IMETHODIMP nsHTMLButtonControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue) +nsresult nsHTMLButtonControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const { if (nsHTMLAtoms::value == aName) mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, aValue); @@ -611,16 +549,6 @@ nsHTMLButtonControlFrame::SetAdditionalStyleContext(PRInt32 aIndex, mRenderer.SetStyleContext(aIndex, aStyleContext); } - -NS_IMETHODIMP nsHTMLButtonControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight) -{ -// mSuggestedWidth = aWidth; -// mSuggestedHeight = aHeight; - return NS_OK; -} - - - NS_IMETHODIMP nsHTMLButtonControlFrame::AppendFrames(nsIAtom* aListName, nsIFrame* aFrameList) @@ -653,9 +581,3 @@ nsHTMLButtonControlFrame::ReplaceFrame(nsIAtom* aListName, ReParentFrameList(GetPresContext()->FrameManager(), aNewFrame); return mFrames.FirstChild()->ReplaceFrame(aListName, aOldFrame, aNewFrame); } - -NS_IMETHODIMP -nsHTMLButtonControlFrame::OnContentReset() -{ - return NS_OK; -} diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.h b/mozilla/layout/forms/nsHTMLButtonControlFrame.h index e73c4d17dea..d908232604f 100644 --- a/mozilla/layout/forms/nsHTMLButtonControlFrame.h +++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.h @@ -126,27 +126,10 @@ public: } #endif - NS_IMETHOD_(PRInt32) GetFormControlType() const; - NS_IMETHOD GetName(nsAString* aName); - NS_IMETHOD GetValue(nsAString* aName); - NS_IMETHOD OnContentReset(); - - void SetFocus(PRBool aOn, PRBool aRepaint); - void ScrollIntoView(nsPresContext* aPresContext); - - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; - virtual nscoord GetVerticalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerHeight) const; - virtual nscoord GetHorizontalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const; - // nsIFormControlFrame - NS_IMETHOD SetProperty(nsPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); - NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); - NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); + void SetFocus(PRBool aOn, PRBool aRepaint); + virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue); + virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const; // Inserted child content gets its frames parented by our child block virtual nsIFrame* GetContentInsertionFrame() { diff --git a/mozilla/layout/forms/nsIComboboxControlFrame.h b/mozilla/layout/forms/nsIComboboxControlFrame.h index c6f5f0cb056..5c55f5baea7 100644 --- a/mozilla/layout/forms/nsIComboboxControlFrame.h +++ b/mozilla/layout/forms/nsIComboboxControlFrame.h @@ -50,8 +50,8 @@ class nsCSSFrameConstructor; // IID for the nsIComboboxControlFrame class #define NS_ICOMBOBOXCONTROLFRAME_IID \ -{ 0x6961f791, 0xa662, 0x11d2, \ - { 0x8d, 0xcf, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } } + { 0x23f75e9c, 0x6850, 0x11da, \ + { 0x95, 0x2c, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f } } /** * nsIComboboxControlFrame is the common interface for frames of form controls. It @@ -108,6 +108,11 @@ public: */ NS_IMETHOD GetAbsoluteRect(nsRect* aRect) = 0; + /** + * Notification that the content has been reset + */ + virtual void OnContentReset() = 0; + /** * This returns the index of the item that is currently being displayed * in the display area. It may differ from what the currently Selected index diff --git a/mozilla/layout/forms/nsIFormControlFrame.h b/mozilla/layout/forms/nsIFormControlFrame.h index 109a79da23f..af736bb47c4 100644 --- a/mozilla/layout/forms/nsIFormControlFrame.h +++ b/mozilla/layout/forms/nsIFormControlFrame.h @@ -39,17 +39,15 @@ #define nsIFormControlFrame_h___ #include "nsISupports.h" -#include "nsFont.h" -class nsPresContext; class nsAString; class nsIContent; class nsIAtom; - +struct nsSize; // IID for the nsIFormControlFrame class #define NS_IFORMCONTROLFRAME_IID \ - { 0xf1911a34, 0xcdf7, 0x4f10, \ - { 0xbc, 0x2a, 0x77, 0x1f, 0x68, 0xce, 0xbc, 0x54 } } + { 0x189e1565, 0x44f, 0x11da, \ + { 0x94, 0xfc, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f } } /** * nsIFormControlFrame is the common interface for frames of form controls. It @@ -61,33 +59,13 @@ class nsIFormControlFrame : public nsISupports { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFORMCONTROLFRAME_IID) - NS_IMETHOD_(PRInt32) GetFormControlType() const = 0; - - NS_IMETHOD GetName(nsAString* aName) = 0; - + /** + * + * @param aOn + * @param aRepaint + */ virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE) = 0; - virtual void ScrollIntoView(nsPresContext* aPresContext) = 0; - - /** - * Set the suggested size for the form element. - * This is used to control the size of the element during reflow if it hasn't had its size - * explicitly set. - * @param aWidth width of the form element - * @param aHeight height of the form element - * @returns NS_OK - */ - - NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight) = 0; - - /** - * Get the content object associated with this frame. Adds a reference to - * the content object so the caller must do a release. - * - * @see nsISupports#Release() - */ - NS_IMETHOD GetFormContent(nsIContent*& aContent) const = 0; - /** * Set a property on the form control frame. * @@ -95,24 +73,17 @@ public: * @param aValue value of the property * @returns NS_OK if the property name is valid, otherwise an error code */ - - NS_IMETHOD SetProperty(nsPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue) = 0; + virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue) = 0; /** * Get a property from the form control frame * - * @param aName name of the property to get - * @param aValue value of the property - * @returns NS_OK if the property name is valid, otherwise an error code + * @param aName name of the property to get. + * @param aValue Value to set. + * @returns NS_OK if the property name is valid, otherwise an error code. */ - NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue) = 0; - - /** - * Notification that the content has been reset - */ - NS_IMETHOD OnContentReset() = 0; - + virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIFormControlFrame, NS_IFORMCONTROLFRAME_IID) diff --git a/mozilla/layout/forms/nsIListControlFrame.h b/mozilla/layout/forms/nsIListControlFrame.h index 69fa45ab09c..9b1a91065da 100644 --- a/mozilla/layout/forms/nsIListControlFrame.h +++ b/mozilla/layout/forms/nsIListControlFrame.h @@ -46,8 +46,8 @@ class nsIContent; // IID for the nsIListControlFrame class #define NS_ILISTCONTROLFRAME_IID \ -{ 0xf44db101, 0xa73c, 0x11d2, \ - { 0x8d, 0xcf, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } } + { 0xa28ca6f, 0x6850, 0x11da, \ + { 0x95, 0x2c, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f } } /** * nsIListControlFrame is the interface for frame-based listboxes. @@ -124,6 +124,11 @@ public: * @param aIndex the index to actually select */ NS_IMETHOD ComboboxFinish(PRInt32 aIndex) = 0; + + /** + * Notification that the content has been reset + */ + virtual void OnContentReset() = 0; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIListControlFrame, NS_ILISTCONTROLFRAME_IID) diff --git a/mozilla/layout/forms/nsITextControlFrame.h b/mozilla/layout/forms/nsITextControlFrame.h index 1df6474060a..efc353516bb 100644 --- a/mozilla/layout/forms/nsITextControlFrame.h +++ b/mozilla/layout/forms/nsITextControlFrame.h @@ -45,9 +45,9 @@ class nsIDocShell; class nsISelectionController; #define NS_IGFXTEXTCONTROLFRAME2_IID \ -{/* A744CFC9-2DA8-416d-A058-ADB1D4B3B534*/ \ -0xa744cfc9, 0x2da8, 0x416d, \ -{ 0xa0, 0x58, 0xad, 0xb1, 0xd4, 0xb3, 0xb5, 0x34 } } +{/* 0c3b64da-4431-11da-94fd-00e08161165f*/ \ +0xc3b64da, 0x4431, 0x11da, \ +{ 0x94, 0xfd, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f } } class nsITextControlFrame : public nsIFormControlFrame { @@ -72,7 +72,7 @@ public: * value. If this is true, linebreaks will not be inserted even if * wrap=hard. */ - NS_IMETHOD GetValue(nsAString& aValue, PRBool aIgnoreWrap) = 0; + NS_IMETHOD GetValue(nsAString& aValue, PRBool aIgnoreWrap) const = 0; NS_IMETHOD GetTextLength(PRInt32* aTextLength) = 0; diff --git a/mozilla/layout/forms/nsImageControlFrame.cpp b/mozilla/layout/forms/nsImageControlFrame.cpp index f23be69aa45..0b77859d5ed 100644 --- a/mozilla/layout/forms/nsImageControlFrame.cpp +++ b/mozilla/layout/forms/nsImageControlFrame.cpp @@ -98,29 +98,10 @@ public: NS_IMETHOD GetCursor(const nsPoint& aPoint, nsIFrame::Cursor& aCursor); - - NS_IMETHOD_(PRInt32) GetFormControlType() const; - - NS_IMETHOD GetName(nsAString* aName); - - void SetFocus(PRBool aOn, PRBool aRepaint); - void ScrollIntoView(nsPresContext* aPresContext); - - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; - virtual nscoord GetVerticalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerHeight) const; - virtual nscoord GetHorizontalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const; - - - // nsIFormControlFrame - NS_IMETHOD SetProperty(nsPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); - NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); - NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); - NS_IMETHOD OnContentReset(); + // nsIFormContromFrame + virtual void SetFocus(PRBool aOn, PRBool aRepaint); + virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue); + virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const; // nsIImageControlFrame NS_IMETHOD GetClickedX(PRInt32* aX); @@ -269,32 +250,6 @@ nsImageControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) { } -void -nsImageControlFrame::ScrollIntoView(nsPresContext* aPresContext) -{ - if (aPresContext) { - nsIPresShell *presShell = aPresContext->GetPresShell(); - if (presShell) { - presShell->ScrollFrameIntoView(this, - NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); - } - } -} - -NS_IMETHODIMP_(PRInt32) -nsImageControlFrame::GetFormControlType() const -{ - return NS_FORM_INPUT_IMAGE; -} - -NS_IMETHODIMP -nsImageControlFrame::GetName(nsAString* aResult) -{ - nsFormControlHelper::GetName(mContent, aResult); - - return NS_OK; -} - NS_IMETHODIMP nsImageControlFrame::GetCursor(const nsPoint& aPoint, nsIFrame::Cursor& aCursor) @@ -310,58 +265,21 @@ nsImageControlFrame::GetCursor(const nsPoint& aPoint, return NS_OK; } -NS_IMETHODIMP -nsImageControlFrame::GetFormContent(nsIContent*& aContent) const -{ - aContent = GetContent(); - NS_IF_ADDREF(aContent); - return NS_OK; -} - -nscoord -nsImageControlFrame::GetVerticalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerHeight) const -{ - return 0; -} - -nscoord -nsImageControlFrame::GetHorizontalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const -{ - return 0; -} - -NS_IMETHODIMP nsImageControlFrame::SetProperty(nsPresContext* aPresContext, - nsIAtom* aName, - const nsAString& aValue) +nsresult +nsImageControlFrame::SetFormProperty(nsIAtom* aName, + const nsAString& aValue) { return NS_OK; } -NS_IMETHODIMP nsImageControlFrame::GetProperty(nsIAtom* aName, - nsAString& aValue) +nsresult +nsImageControlFrame::GetFormProperty(nsIAtom* aName, + nsAString& aValue) const { aValue.Truncate(); return NS_OK; } -NS_IMETHODIMP nsImageControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight) -{ -// mSuggestedWidth = aWidth; -// mSuggestedHeight = aHeight; - return NS_OK; -} - -NS_IMETHODIMP -nsImageControlFrame::OnContentReset() -{ - return NS_OK; -} - NS_IMETHODIMP nsImageControlFrame::GetClickedX(PRInt32* aX) { diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index 29133285670..70fbcaa7bfb 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -968,9 +968,7 @@ nsListControlFrame::Reflow(nsPresContext* aPresContext, // We add in the height of optgroup labels (within the constraint above), bug 300474. visibleHeight = ::GetOptGroupLabelsHeight(GetPresContext(), mContent, heightOfARow); - PRBool multipleSelections = PR_FALSE; - GetMultiple(&multipleSelections); - if (multipleSelections) { + if (GetMultiple()) { if (length < 2) { // Add in 1 heightOfARow also when length==0 to match how we calculate the desired size. visibleHeight = heightOfARow + PR_MAX(heightOfARow, visibleHeight); @@ -1116,15 +1114,6 @@ nsListControlFrame::Reflow(nsPresContext* aPresContext, return NS_OK; } -//--------------------------------------------------------- -NS_IMETHODIMP -nsListControlFrame::GetFormContent(nsIContent*& aContent) const -{ - aContent = GetContent(); - NS_IF_ADDREF(aContent); - return NS_OK; -} - nsGfxScrollFrameInner::ScrollbarStyles nsListControlFrame::GetScrollbarStyles() const { @@ -1285,11 +1274,9 @@ nsListControlFrame::PerformSelection(PRInt32 aClickedIndex, { PRBool wasChanged = PR_FALSE; - PRBool isMultiple; - GetMultiple(&isMultiple); - if (aClickedIndex == kNothingSelected) { - } else if (isMultiple) { + } + else if (GetMultiple()) { if (aIsShift) { // Make sure shift+click actually does something expected when // the user has never clicked on the select @@ -1528,47 +1515,29 @@ nsListControlFrame::Init(nsPresContext* aPresContext, return result; } - -//--------------------------------------------------------- -nscoord -nsListControlFrame::GetVerticalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerHeight) const -{ - return NSIntPixelsToTwips(0, aPixToTwip); -} - - -//--------------------------------------------------------- -nscoord -nsListControlFrame::GetHorizontalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const -{ - return GetVerticalInsidePadding(aPresContext, aPixToTwip, aInnerWidth); -} - - //--------------------------------------------------------- // Returns whether the nsIDOMHTMLSelectElement supports // mulitple selection //--------------------------------------------------------- -NS_IMETHODIMP -nsListControlFrame::GetMultiple(PRBool* aMultiple, nsIDOMHTMLSelectElement* aSelect) +PRBool +nsListControlFrame::GetMultiple(nsIDOMHTMLSelectElement* aSelect) const { - if (!aSelect) { - nsIDOMHTMLSelectElement* selectElement = nsnull; - nsresult result = mContent->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement), - (void**)&selectElement); - if (NS_SUCCEEDED(result) && selectElement) { - result = selectElement->GetMultiple(aMultiple); - NS_RELEASE(selectElement); - } - return result; + PRBool multiple = PR_FALSE; + nsresult rv = NS_OK; + if (aSelect) { + rv = aSelect->GetMultiple(&multiple); } else { - return aSelect->GetMultiple(aMultiple); + nsCOMPtr selectElement = + do_QueryInterface(mContent); + + if (selectElement) { + rv = selectElement->GetMultiple(&multiple); + } } + if (NS_SUCCEEDED(rv)) { + return multiple; + } + return PR_FALSE; } @@ -1614,7 +1583,7 @@ nsListControlFrame::GetOptionAsContent(nsIDOMHTMLOptionsCollection* aCollection, // from the select //--------------------------------------------------------- already_AddRefed -nsListControlFrame::GetOptionContent(PRInt32 aIndex) +nsListControlFrame::GetOptionContent(PRInt32 aIndex) const { nsCOMPtr options = @@ -1678,7 +1647,7 @@ nsListControlFrame::GetOption(nsIDOMHTMLOptionsCollection* aCollection, // return PR_TRUE if it is, PR_FALSE if it is NOT //--------------------------------------------------------- PRBool -nsListControlFrame::IsContentSelected(nsIContent* aContent) +nsListControlFrame::IsContentSelected(nsIContent* aContent) const { PRBool isSelected = PR_FALSE; @@ -1694,7 +1663,7 @@ nsListControlFrame::IsContentSelected(nsIContent* aContent) // For a given index is return whether the content is selected //--------------------------------------------------------- PRBool -nsListControlFrame::IsContentSelectedByIndex(PRInt32 aIndex) +nsListControlFrame::IsContentSelectedByIndex(PRInt32 aIndex) const { nsCOMPtr content = GetOptionContent(aIndex); NS_ASSERTION(content, "Failed to retrieve option content"); @@ -1726,17 +1695,10 @@ nsListControlFrame::GetSkipSides() const } //--------------------------------------------------------- -NS_IMETHODIMP_(PRInt32) -nsListControlFrame::GetFormControlType() const -{ - return NS_FORM_SELECT; -} - -NS_IMETHODIMP +void nsListControlFrame::OnContentReset() { ResetList(PR_TRUE); - return NS_OK; } //--------------------------------------------------------- @@ -1773,17 +1735,7 @@ nsListControlFrame::ResetList(PRBool aAllowScrolling) // Combobox will redisplay itself with the OnOptionSelected event } - -//--------------------------------------------------------- -NS_IMETHODIMP -nsListControlFrame::GetName(nsAString* aResult) -{ - nsFormControlHelper::GetName(mContent, aResult); - - return NS_OK; -} - //--------------------------------------------------------- void nsListControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) @@ -1806,20 +1758,6 @@ void nsListControlFrame::ComboboxFocusSet() gLastKeyTime = 0; } -//--------------------------------------------------------- -void -nsListControlFrame::ScrollIntoView(nsPresContext* aPresContext) -{ - if (aPresContext) { - nsIPresShell *presShell = aPresContext->GetPresShell(); - if (presShell) { - presShell->ScrollFrameIntoView(this, - NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); - } - } -} - - //--------------------------------------------------------- NS_IMETHODIMP nsListControlFrame::SetComboboxFrame(nsIFrame* aComboboxFrame) @@ -2169,8 +2107,8 @@ nsListControlFrame::OnSetSelectedIndex(PRInt32 aOldIndex, PRInt32 aNewIndex) //---------------------------------------------------------------------- //--------------------------------------------------------- -NS_IMETHODIMP -nsListControlFrame::SetProperty(nsPresContext* aPresContext, nsIAtom* aName, +nsresult +nsListControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue) { if (nsHTMLAtoms::selected == aName) { @@ -2187,8 +2125,8 @@ nsListControlFrame::SetProperty(nsPresContext* aPresContext, nsIAtom* aName, } //--------------------------------------------------------- -NS_IMETHODIMP -nsListControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue) +nsresult +nsListControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const { // Get the selected value of option from local cache (optimization vs. widget) if (nsHTMLAtoms::selected == aName) { @@ -2321,14 +2259,6 @@ nsListControlFrame::GetMaximumSize(nsSize &aSize) return NS_OK; } - -//--------------------------------------------------------- -NS_IMETHODIMP -nsListControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight) -{ - return NS_OK; -} - //---------------------------------------------------------------------- nsresult nsListControlFrame::IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled) @@ -3097,11 +3027,8 @@ nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) keycode == nsIDOMKeyEvent::DOM_VK_LEFT || keycode == nsIDOMKeyEvent::DOM_VK_DOWN || keycode == nsIDOMKeyEvent::DOM_VK_RIGHT)) { - PRBool isMultiple; - GetMultiple(&isMultiple); // Don't go into multiple select mode unless this list can handle it - mControlSelectMode = isMultiple; - isControl = isMultiple; + isControl = mControlSelectMode = GetMultiple(); } else if (charcode != ' ') { mControlSelectMode = PR_FALSE; } diff --git a/mozilla/layout/forms/nsListControlFrame.h b/mozilla/layout/forms/nsListControlFrame.h index f7bf8f2a830..f764f6d791c 100644 --- a/mozilla/layout/forms/nsListControlFrame.h +++ b/mozilla/layout/forms/nsListControlFrame.h @@ -130,23 +130,9 @@ public: #endif // nsIFormControlFrame - NS_IMETHOD_(PRInt32) GetFormControlType() const; - NS_IMETHOD GetName(nsAString* aName); - NS_IMETHOD SetProperty(nsPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); - NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); - NS_IMETHOD GetMultiple(PRBool* aResult, nsIDOMHTMLSelectElement* aSelect = nsnull); - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; - NS_IMETHOD OnContentReset(); - + virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue); + virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const; virtual void SetFocus(PRBool aOn = PR_TRUE, PRBool aRepaint = PR_FALSE); - virtual void ScrollIntoView(nsPresContext* aPresContext); - virtual nscoord GetVerticalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerHeight) const; - virtual nscoord GetHorizontalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const; virtual nsGfxScrollFrameInner::ScrollbarStyles GetScrollbarStyles() const; @@ -164,7 +150,6 @@ public: NS_IMETHOD GetOptionText(PRInt32 aIndex, nsAString & aStr); NS_IMETHOD CaptureMouseEvents(nsPresContext* aPresContext, PRBool aGrabMouseEvents); NS_IMETHOD GetMaximumSize(nsSize &aSize); - NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); NS_IMETHOD GetNumberOfOptions(PRInt32* aNumOptions); NS_IMETHOD SyncViewWithFrame(); NS_IMETHOD AboutToDropDown(); @@ -173,6 +158,7 @@ public: NS_IMETHOD SetOverrideReflowOptimization(PRBool aValue) { mOverrideReflowOpt = aValue; return NS_OK; } NS_IMETHOD FireOnChange(); NS_IMETHOD ComboboxFinish(PRInt32 aIndex); + virtual void OnContentReset(); // nsISelectControlFrame NS_IMETHOD AddOption(nsPresContext* aPresContext, PRInt32 index); @@ -213,7 +199,7 @@ public: #endif protected: - + PRBool GetMultiple(nsIDOMHTMLSelectElement* aSelect = nsnull) const; void DropDownToggleKey(nsIDOMEvent* aKeyEvent); nsresult IsOptionDisabled(PRInt32 anIndex, PRBool &aIsDisabled); nsresult ScrollToFrame(nsIContent * aOptElement); @@ -231,9 +217,9 @@ protected: nsresult GetSizeAttribute(PRInt32 *aSize); nsIContent* GetOptionFromContent(nsIContent *aContent); nsresult GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, PRInt32& aCurIndex); - already_AddRefed GetOptionContent(PRInt32 aIndex); - PRBool IsContentSelected(nsIContent* aContent); - PRBool IsContentSelectedByIndex(PRInt32 aIndex); + already_AddRefed GetOptionContent(PRInt32 aIndex) const; + PRBool IsContentSelected(nsIContent* aContent) const; + PRBool IsContentSelectedByIndex(PRInt32 aIndex) const; PRBool IsOptionElement(nsIContent* aContent); PRBool CheckIfAllFramesHere(); PRInt32 GetIndexFromContent(nsIContent *aContent); diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 6048c36849a..56ee8cef075 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -270,8 +270,7 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection* nsISelectionListener::KEYPRESS_REASON | nsISelectionListener::SELECTALL_REASON))) { - nsCOMPtr content; - mFrame->GetFormContent(*getter_AddRefs(content)); + nsIContent* content = mFrame->GetContent(); if (content) { nsCOMPtr doc = content->GetDocument(); @@ -1275,8 +1274,6 @@ nsTextControlFrame::nsTextControlFrame(nsIPresShell* aShell) mUseEditor = PR_FALSE; mIsProcessing = PR_FALSE; mNotifyOnInput = PR_TRUE; - mSuggestedWidth = NS_FORMSIZE_NOTSET; - mSuggestedHeight = NS_FORMSIZE_NOTSET; mScrollableView = nsnull; mDidPreDestroy = PR_FALSE; } @@ -1449,8 +1446,12 @@ nsTextControlFrame::GetType() const // XXX: wouldn't it be nice to get this from the style context! PRBool nsTextControlFrame::IsSingleLineTextControl() const { - PRInt32 type = GetFormControlType(); - return (type == NS_FORM_INPUT_TEXT) || (type == NS_FORM_INPUT_PASSWORD); + nsCOMPtr formControl = do_QueryInterface(mContent); + if (formControl) { + PRInt32 type = formControl->GetType(); + return (type == NS_FORM_INPUT_TEXT) || (type == NS_FORM_INPUT_PASSWORD); + } + return PR_FALSE; } PRBool nsTextControlFrame::IsTextArea() const @@ -1467,7 +1468,8 @@ PRBool nsTextControlFrame::IsPlainTextControl() const PRBool nsTextControlFrame::IsPasswordTextControl() const { - return GetFormControlType() == NS_FORM_INPUT_PASSWORD; + nsCOMPtr formControl = do_QueryInterface(mContent); + return formControl && formControl->GetType() == NS_FORM_INPUT_PASSWORD; } @@ -2243,20 +2245,7 @@ nsTextControlFrame::IsLeaf() const return PR_TRUE; } -//IMPLEMENTING NS_IFORMCONTROLFRAME -NS_IMETHODIMP -nsTextControlFrame::GetName(nsAString* aResult) -{ - nsFormControlHelper::GetName(mContent, aResult); - return NS_OK; -} - -NS_IMETHODIMP_(PRInt32) -nsTextControlFrame::GetFormControlType() const -{ - return nsFormControlHelper::GetType(mContent); -} static PRBool IsFocusedContent(nsPresContext* aPresContext, nsIContent* aContent) @@ -2267,7 +2256,8 @@ IsFocusedContent(nsPresContext* aPresContext, nsIContent* aContent) return focusedContent == aContent; } -void nsTextControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) +//IMPLEMENTING NS_IFORMCONTROLFRAME +void nsTextControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) { if (!aOn || !mSelCon) return; @@ -2307,54 +2297,7 @@ void nsTextControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) docSel->RemoveAllRanges(); } -void nsTextControlFrame::ScrollIntoView(nsPresContext* aPresContext) -{ - if (aPresContext) { - nsIPresShell *presShell = aPresContext->GetPresShell(); - if (presShell) { - presShell->ScrollFrameIntoView(this, - NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE); - } - } -} - -nscoord -nsTextControlFrame::GetVerticalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerHeight) const -{ - return NSIntPixelsToTwips(0, aPixToTwip); -} - - -//--------------------------------------------------------- -nscoord -nsTextControlFrame::GetHorizontalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const -{ - return GetVerticalInsidePadding(aPresContext, aPixToTwip, aInnerWidth); -} - - -NS_IMETHODIMP -nsTextControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight) -{ - mSuggestedWidth = aWidth; - mSuggestedHeight = aHeight; - return NS_OK; -} - -NS_IMETHODIMP -nsTextControlFrame::GetFormContent(nsIContent*& aContent) const -{ - aContent = GetContent(); - NS_IF_ADDREF(aContent); - return NS_OK; -} - -NS_IMETHODIMP nsTextControlFrame::SetProperty(nsPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue) +nsresult nsTextControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue) { if (!mIsProcessing)//some kind of lock. { @@ -2386,8 +2329,8 @@ NS_IMETHODIMP nsTextControlFrame::SetProperty(nsPresContext* aPresContext, nsIAt return NS_OK; } -NS_IMETHODIMP -nsTextControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue) +nsresult +nsTextControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const { // Return the value of the property from the widget it is not null. // If widget is null, assume the widget is GFX-rendered and return a member variable instead. @@ -3022,8 +2965,8 @@ nsresult nsTextControlFrame::FireOnChange() { // Dispatch th1e change event - nsCOMPtr content; - if (NS_SUCCEEDED(GetFormContent(*getter_AddRefs(content)))) + nsIContent* content = GetContent(); + if (content) { nsEventStatus status = nsEventStatus_eIgnore; nsInputEvent event(PR_TRUE, NS_FORM_CHANGE, nsnull); @@ -3042,7 +2985,7 @@ nsTextControlFrame::FireOnChange() //privates NS_IMETHODIMP -nsTextControlFrame::GetValue(nsAString& aValue, PRBool aIgnoreWrap) +nsTextControlFrame::GetValue(nsAString& aValue, PRBool aIgnoreWrap) const { aValue.Truncate(); // initialize out param nsresult rv = NS_OK; @@ -3330,12 +3273,6 @@ nsTextControlFrame::IsScrollable() const return !IsSingleLineTextControl(); } -NS_IMETHODIMP -nsTextControlFrame::OnContentReset() -{ - return NS_OK; -} - void nsTextControlFrame::SetValueChanged(PRBool aValueChanged) { diff --git a/mozilla/layout/forms/nsTextControlFrame.h b/mozilla/layout/forms/nsTextControlFrame.h index a240f76a2bc..23cde6a37c1 100644 --- a/mozilla/layout/forms/nsTextControlFrame.h +++ b/mozilla/layout/forms/nsTextControlFrame.h @@ -126,22 +126,9 @@ public: nsIFrame* aChildList); //==== BEGIN NSIFORMCONTROLFRAME - NS_IMETHOD_(PRInt32) GetFormControlType() const; //* - NS_IMETHOD GetName(nsAString* aName);//* virtual void SetFocus(PRBool aOn , PRBool aRepaint); - virtual void ScrollIntoView(nsPresContext* aPresContext); - virtual nscoord GetVerticalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerHeight) const; - virtual nscoord GetHorizontalInsidePadding(nsPresContext* aPresContext, - float aPixToTwip, - nscoord aInnerWidth, - nscoord aCharWidth) const;/**/ - NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; - NS_IMETHOD SetProperty(nsPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); - NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); - NS_IMETHOD OnContentReset(); + virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue); + virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const; //==== END NSIFORMCONTROLFRAME @@ -150,7 +137,7 @@ public: NS_IMETHOD GetEditor(nsIEditor **aEditor); NS_IMETHOD OwnsValue(PRBool* aOwnsValue); - NS_IMETHOD GetValue(nsAString& aValue, PRBool aIgnoreWrap); + NS_IMETHOD GetValue(nsAString& aValue, PRBool aIgnoreWrap) const; NS_IMETHOD GetTextLength(PRInt32* aTextLength); NS_IMETHOD CheckFireOnChange(); NS_IMETHOD SetSelectionStart(PRInt32 aSelectionStart); @@ -208,7 +195,6 @@ public: //for methods who access nsTextControlFrame directly static NS_HIDDEN_(void) ShutDown(); protected: - /** * Find out whether this control is scrollable (i.e. if it is not a single * line text control) @@ -294,8 +280,6 @@ private: nsCOMPtr mSelCon; //cached sizes and states - nscoord mSuggestedWidth; - nscoord mSuggestedHeight; nsSize mSize; // these packed bools could instead use the high order bits on mState, saving 4 bytes