1998-10-13 21:31:26 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-10-13 21:31:26 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-10-13 21:31:26 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-10-13 21:31:26 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:40:37 +00:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-10-13 21:31:26 +00:00
|
|
|
*/
|
1999-04-21 22:46:15 +00:00
|
|
|
|
|
|
|
#include "nsHTMLButtonControlFrame.h"
|
|
|
|
|
1999-02-12 17:45:58 +00:00
|
|
|
#include "nsCOMPtr.h"
|
1998-10-13 21:31:26 +00:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
1999-01-22 15:32:57 +00:00
|
|
|
#include "nsFormControlHelper.h"
|
1998-10-13 21:31:26 +00:00
|
|
|
#include "nsIFormControlFrame.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIFormControl.h"
|
|
|
|
#include "nsFormFrame.h"
|
|
|
|
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsLeafFrame.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
|
|
|
#include "nsIImage.h"
|
|
|
|
#include "nsStyleUtil.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIHTMLAttributes.h"
|
|
|
|
#include "nsIWidget.h"
|
1999-03-09 09:44:27 +00:00
|
|
|
#include "nsIComponentManager.h"
|
1998-10-13 21:31:26 +00:00
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsViewsCID.h"
|
1998-10-17 00:35:32 +00:00
|
|
|
#include "nsColor.h"
|
1999-01-22 23:10:02 +00:00
|
|
|
#include "nsIDocument.h"
|
1999-03-06 19:43:13 +00:00
|
|
|
#include "nsButtonFrameRenderer.h"
|
2000-01-08 15:53:48 +00:00
|
|
|
#include "nsFormControlFrame.h"
|
2000-09-12 19:41:27 +00:00
|
|
|
#include "nsIFrameManager.h"
|
2000-12-30 19:22:22 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
2001-05-11 21:11:38 +00:00
|
|
|
#include "nsIAccessibilityService.h"
|
1998-10-13 21:31:26 +00:00
|
|
|
|
|
|
|
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
|
|
|
|
|
|
|
nsresult
|
1999-12-04 23:49:50 +00:00
|
|
|
NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-10-13 21:31:26 +00:00
|
|
|
{
|
1999-05-11 22:03:29 +00:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-04 23:49:50 +00:00
|
|
|
nsHTMLButtonControlFrame* it = new (aPresShell) nsHTMLButtonControlFrame;
|
1999-05-11 22:03:29 +00:00
|
|
|
if (!it) {
|
1998-10-13 21:31:26 +00:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-11 22:03:29 +00:00
|
|
|
*aNewFrame = it;
|
1998-10-13 21:31:26 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-03 06:31:43 +00:00
|
|
|
nsHTMLButtonControlFrame::nsHTMLButtonControlFrame()
|
|
|
|
: nsHTMLContainerFrame()
|
1998-10-13 21:31:26 +00:00
|
|
|
{
|
|
|
|
mInline = PR_TRUE;
|
1998-10-14 23:01:44 +00:00
|
|
|
mPreviousCursor = eCursor_standard;
|
1998-10-17 00:35:32 +00:00
|
|
|
mTranslatedRect = nsRect(0,0,0,0);
|
1998-11-13 23:13:42 +00:00
|
|
|
mDidInit = PR_FALSE;
|
1999-03-06 19:43:13 +00:00
|
|
|
mRenderer.SetNameSpace(kNameSpaceID_None);
|
2000-01-08 15:53:48 +00:00
|
|
|
|
|
|
|
mCacheSize.width = -1;
|
|
|
|
mCacheSize.height = -1;
|
|
|
|
mCachedMaxElementSize.width = -1;
|
|
|
|
mCachedMaxElementSize.height = -1;
|
1999-03-06 19:43:13 +00:00
|
|
|
}
|
|
|
|
|
1999-11-04 23:16:47 +00:00
|
|
|
nsHTMLButtonControlFrame::~nsHTMLButtonControlFrame()
|
|
|
|
{
|
2000-05-16 12:44:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::Destroy(nsIPresContext *aPresContext)
|
|
|
|
{
|
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE);
|
1999-11-04 23:16:47 +00:00
|
|
|
if (mFormFrame) {
|
|
|
|
mFormFrame->RemoveFormControlFrame(*this);
|
|
|
|
mFormFrame = nsnull;
|
|
|
|
}
|
2000-05-16 12:44:32 +00:00
|
|
|
return nsHTMLContainerFrame::Destroy(aPresContext);
|
1999-11-04 23:16:47 +00:00
|
|
|
}
|
|
|
|
|
1999-03-06 19:43:13 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsHTMLButtonControlFrame::Init(nsIPresContext* aPresContext,
|
1999-03-06 19:43:13 +00:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
|
|
|
mRenderer.SetFrame(this,aPresContext);
|
1999-11-12 01:45:53 +00:00
|
|
|
// cache our display type
|
|
|
|
const nsStyleDisplay* styleDisplay;
|
|
|
|
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
|
|
|
|
mInline = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay);
|
|
|
|
|
|
|
|
PRUint32 flags = NS_BLOCK_SPACE_MGR;
|
|
|
|
if (mInline) {
|
|
|
|
flags |= NS_BLOCK_SHRINK_WRAP;
|
|
|
|
}
|
1999-12-04 23:49:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
1999-11-12 01:45:53 +00:00
|
|
|
nsIFrame* areaFrame;
|
1999-12-04 23:49:50 +00:00
|
|
|
NS_NewAreaFrame(shell, &areaFrame, flags);
|
1999-11-12 01:45:53 +00:00
|
|
|
mFrames.SetFrames(areaFrame);
|
|
|
|
|
|
|
|
// Resolve style and initialize the frame
|
|
|
|
nsIStyleContext* styleContext;
|
1999-11-24 06:03:41 +00:00
|
|
|
aPresContext->ResolvePseudoStyleContextFor(mContent, nsHTMLAtoms::buttonContentPseudo,
|
1999-11-12 01:45:53 +00:00
|
|
|
mStyleContext, PR_FALSE,
|
|
|
|
&styleContext);
|
|
|
|
mFrames.FirstChild()->Init(aPresContext, mContent, this, styleContext, nsnull);
|
|
|
|
NS_RELEASE(styleContext);
|
|
|
|
|
1999-03-06 19:43:13 +00:00
|
|
|
return rv;
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsHTMLButtonControlFrame::AddRef(void)
|
|
|
|
{
|
|
|
|
NS_WARNING("not supported");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsHTMLButtonControlFrame::Release(void)
|
|
|
|
{
|
|
|
|
NS_WARNING("not supported");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:50:15 +00:00
|
|
|
// Frames are not refcounted, no need to AddRef
|
|
|
|
NS_IMETHODIMP
|
1998-10-13 21:31:26 +00:00
|
|
|
nsHTMLButtonControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2001-01-04 20:44:42 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
|
1998-10-13 21:31:26 +00:00
|
|
|
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-05-11 21:11:38 +00:00
|
|
|
|
1998-10-13 21:31:26 +00:00
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
2001-05-17 23:52:32 +00:00
|
|
|
NS_IMETHODIMP nsHTMLButtonControlFrame::GetAccessible(nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
|
|
|
|
if (accService) {
|
|
|
|
nsIAccessible* acc = nsnull;
|
|
|
|
return accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-13 21:31:26 +00:00
|
|
|
void
|
|
|
|
nsHTMLButtonControlFrame::GetDefaultLabel(nsString& aString)
|
|
|
|
{
|
|
|
|
PRInt32 type;
|
|
|
|
GetType(&type);
|
|
|
|
if (NS_FORM_BUTTON_BUTTON == type) {
|
2000-04-15 21:18:29 +00:00
|
|
|
aString.AssignWithConversion("Button");
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
else if (NS_FORM_BUTTON_RESET == type) {
|
2000-04-15 21:18:29 +00:00
|
|
|
aString.AssignWithConversion("Reset");
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
else if (NS_FORM_BUTTON_SUBMIT == type) {
|
2000-04-15 21:18:29 +00:00
|
|
|
aString.AssignWithConversion("Submit");
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRInt32
|
|
|
|
nsHTMLButtonControlFrame::GetMaxNumValues()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsHTMLButtonControlFrame::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,
|
|
|
|
nsString* aValues, nsString* aNames)
|
|
|
|
{
|
|
|
|
nsAutoString name;
|
|
|
|
nsresult result = GetName(&name);
|
|
|
|
if ((aMaxNumValues <= 0) || (NS_CONTENT_ATTR_HAS_VALUE != result)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 type;
|
|
|
|
GetType(&type);
|
|
|
|
nsAutoString value;
|
|
|
|
nsresult valResult = GetValue(&value);
|
|
|
|
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == valResult) {
|
|
|
|
aValues[0] = value;
|
|
|
|
aNames[0] = name;
|
|
|
|
aNumValues = 1;
|
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
aNumValues = 0;
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
1999-09-13 20:40:59 +00:00
|
|
|
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::GetType(PRInt32* aType) const
|
|
|
|
{
|
|
|
|
nsresult result = NS_FORM_NOTOK;
|
|
|
|
if (mContent) {
|
|
|
|
nsIFormControl* formControl = nsnull;
|
2001-01-04 20:44:42 +00:00
|
|
|
result = mContent->QueryInterface(NS_GET_IID(nsIFormControl), (void**)&formControl);
|
1998-10-13 21:31:26 +00:00
|
|
|
if ((NS_OK == result) && formControl) {
|
|
|
|
result = formControl->GetType(aType);
|
|
|
|
NS_RELEASE(formControl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::GetName(nsString* aResult)
|
|
|
|
{
|
|
|
|
nsresult result = NS_FORM_NOTOK;
|
|
|
|
if (mContent) {
|
|
|
|
nsIHTMLContent* formControl = nsnull;
|
|
|
|
result = mContent->QueryInterface(kIHTMLContentIID, (void**)&formControl);
|
|
|
|
if ((NS_OK == result) && formControl) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 01:21:23 +00:00
|
|
|
result = formControl->GetHTMLAttribute(nsHTMLAtoms::name, value);
|
1998-10-13 21:31:26 +00:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
|
|
|
if (eHTMLUnit_String == value.GetUnit()) {
|
|
|
|
value.GetStringValue(*aResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(formControl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::GetValue(nsString* aResult)
|
|
|
|
{
|
|
|
|
nsresult result = NS_FORM_NOTOK;
|
|
|
|
if (mContent) {
|
|
|
|
nsIHTMLContent* formControl = nsnull;
|
|
|
|
result = mContent->QueryInterface(kIHTMLContentIID, (void**)&formControl);
|
|
|
|
if ((NS_OK == result) && formControl) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 01:21:23 +00:00
|
|
|
result = formControl->GetHTMLAttribute(nsHTMLAtoms::value, value);
|
1998-10-13 21:31:26 +00:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
|
|
|
if (eHTMLUnit_String == value.GetUnit()) {
|
|
|
|
value.GetStringValue(*aResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(formControl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
1998-10-30 18:05:29 +00:00
|
|
|
nsHTMLButtonControlFrame::IsSuccessful(nsIFormControlFrame* aSubmitter)
|
1998-10-13 21:31:26 +00:00
|
|
|
{
|
2000-08-03 23:32:02 +00:00
|
|
|
PRBool successful = PR_TRUE;
|
1998-10-30 18:05:29 +00:00
|
|
|
if (this == (aSubmitter)) {
|
|
|
|
nsAutoString name;
|
2000-08-03 23:32:02 +00:00
|
|
|
PRBool disabled = PR_FALSE;
|
|
|
|
nsFormControlHelper::GetDisabled(mContent, &disabled);
|
|
|
|
successful = !disabled && (NS_CONTENT_ATTR_HAS_VALUE == GetName(&name));
|
1998-10-30 18:05:29 +00:00
|
|
|
} else {
|
2000-08-03 23:32:02 +00:00
|
|
|
successful = PR_FALSE;
|
1998-10-30 18:05:29 +00:00
|
|
|
}
|
2000-08-03 23:32:02 +00:00
|
|
|
return successful;
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
|
1999-09-13 20:40:59 +00:00
|
|
|
PRBool
|
|
|
|
nsHTMLButtonControlFrame::IsReset(PRInt32 type)
|
|
|
|
{
|
|
|
|
if (NS_FORM_BUTTON_RESET == type) {
|
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
2000-12-20 15:12:06 +00:00
|
|
|
nsHTMLButtonControlFrame::IsSubmit(nsIPresContext* aPresContext, PRInt32 type)
|
1999-09-13 20:40:59 +00:00
|
|
|
{
|
2000-12-20 15:12:06 +00:00
|
|
|
nsCompatibility mode;
|
|
|
|
aPresContext->GetCompatibilityMode(&mode);
|
|
|
|
if (eCompatibility_Standard == mode && mContent != nsnull) {
|
|
|
|
// The default type for a html4 button is NS_FORM_BUTTON_BUTTON,
|
|
|
|
// but that does not mean that the type was actually set to "button"
|
|
|
|
// so we need to check here to see if a type was actually set
|
|
|
|
// and oif it wasn't explicitly then we we allow to be a submit
|
|
|
|
if (NS_FORM_BUTTON_BUTTON == type) {
|
|
|
|
nsAutoString type;
|
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::type, type)) {
|
|
|
|
return PR_FALSE;
|
|
|
|
} else {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_FORM_BUTTON_SUBMIT == type || NS_FORM_INPUT_SUBMIT == type) {
|
1999-09-13 20:40:59 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-13 21:31:26 +00:00
|
|
|
void
|
|
|
|
nsHTMLButtonControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
|
|
|
{
|
1999-09-13 20:40:59 +00:00
|
|
|
if ((nsnull != mFormFrame) && !nsFormFrame::GetDisabled(this)) {
|
2001-02-23 01:01:08 +00:00
|
|
|
PRInt32 type;
|
|
|
|
GetType(&type);
|
1999-09-13 20:40:59 +00:00
|
|
|
|
2001-02-23 01:01:08 +00:00
|
|
|
if (IsReset(type) == PR_TRUE) {
|
|
|
|
// do Reset & Frame processing of event
|
|
|
|
nsFormControlHelper::DoManualSubmitOrReset(aPresContext, nsnull, mFormFrame,
|
|
|
|
this, PR_FALSE, PR_FALSE);
|
|
|
|
}
|
|
|
|
else if (IsSubmit(aPresContext, type) == PR_TRUE) {
|
|
|
|
// do Submit & Frame processing of event
|
|
|
|
nsFormControlHelper::DoManualSubmitOrReset(aPresContext, nsnull, mFormFrame,
|
|
|
|
this, PR_TRUE, PR_FALSE);
|
1999-09-13 20:40:59 +00:00
|
|
|
}
|
|
|
|
}
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
|
1998-10-22 23:00:37 +00:00
|
|
|
void
|
|
|
|
nsHTMLButtonControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
|
|
|
{
|
1998-10-17 00:35:32 +00:00
|
|
|
}
|
|
|
|
|
1999-08-21 00:09:24 +00:00
|
|
|
void
|
|
|
|
nsHTMLButtonControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
if (aPresContext) {
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
2000-09-08 05:53:28 +00:00
|
|
|
if (presShell) {
|
|
|
|
presShell->ScrollFrameIntoView(this,
|
2000-01-25 22:19:39 +00:00
|
|
|
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE);
|
1999-08-21 00:09:24 +00:00
|
|
|
|
2000-09-08 05:53:28 +00:00
|
|
|
}
|
1999-08-21 00:09:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-17 00:35:32 +00:00
|
|
|
void
|
1999-10-26 04:44:41 +00:00
|
|
|
nsHTMLButtonControlFrame::GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect)
|
1998-10-17 00:35:32 +00:00
|
|
|
{
|
|
|
|
nsIView* view;
|
|
|
|
nsPoint viewOffset(0,0);
|
1999-10-26 04:44:41 +00:00
|
|
|
GetOffsetFromView(aPresContext, viewOffset, &view);
|
1998-10-17 00:35:32 +00:00
|
|
|
while (nsnull != view) {
|
|
|
|
nsPoint tempOffset;
|
|
|
|
view->GetPosition(&tempOffset.x, &tempOffset.y);
|
|
|
|
viewOffset += tempOffset;
|
|
|
|
view->GetParent(view);
|
|
|
|
}
|
|
|
|
aRect = nsRect(viewOffset.x, viewOffset.y, mRect.width, mRect.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-03-06 19:43:13 +00:00
|
|
|
|
1998-11-18 05:25:26 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsHTMLButtonControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
1999-03-31 06:02:12 +00:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 06:03:41 +00:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-10-13 21:31:26 +00:00
|
|
|
{
|
1999-03-06 19:43:13 +00:00
|
|
|
// if disabled do nothing
|
|
|
|
if (mRenderer.isDisabled()) {
|
1998-10-17 00:35:32 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-10-14 23:01:44 +00:00
|
|
|
|
2000-06-21 00:40:11 +00:00
|
|
|
// mouse clicks are handled by content
|
1999-05-13 01:35:16 +00:00
|
|
|
// we don't want our children to get any events. So just pass it to frame.
|
|
|
|
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
|
1998-10-14 23:01:44 +00:00
|
|
|
|
1998-11-18 05:25:26 +00:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 04:44:41 +00:00
|
|
|
nsHTMLButtonControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
2000-03-22 02:43:08 +00:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
1999-10-26 04:44:41 +00:00
|
|
|
nsIFrame** aFrame)
|
1998-11-18 05:25:26 +00:00
|
|
|
{
|
2000-03-22 02:43:08 +00:00
|
|
|
if (mRect.Contains(aPoint)) {
|
|
|
|
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Display);
|
|
|
|
if (disp->IsVisible()) {
|
|
|
|
*aFrame = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-11-18 05:25:26 +00:00
|
|
|
}
|
|
|
|
|
1998-10-13 21:31:26 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsHTMLButtonControlFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
1998-11-10 06:05:32 +00:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-10-13 21:31:26 +00:00
|
|
|
{
|
1998-10-30 18:05:29 +00:00
|
|
|
// add ourself as an nsIFormControlFrame
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFormFrame::AddFormControlFrame(aPresContext, *NS_STATIC_CAST(nsIFrame*, this));
|
1998-10-30 18:05:29 +00:00
|
|
|
|
2000-09-12 19:41:27 +00:00
|
|
|
// get the frame manager and the style context of the new parent frame
|
|
|
|
// this is used whent he children are reparented below
|
|
|
|
// NOTE: the whole reparenting should not need to happen: see bugzilla bug 51767
|
|
|
|
//
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
nsCOMPtr<nsIFrameManager> frameManager;
|
|
|
|
nsCOMPtr<nsIStyleContext> newParentContext;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
if (shell) {
|
|
|
|
shell->GetFrameManager(getter_AddRefs(frameManager));
|
|
|
|
}
|
|
|
|
// get the new parent context from the first child: that is the frame that the
|
|
|
|
// subsequent children will be made children of
|
|
|
|
mFrames.FirstChild()->GetStyleContext(getter_AddRefs(newParentContext));
|
|
|
|
|
1999-01-14 05:16:23 +00:00
|
|
|
// Set the parent for each of the child frames
|
1999-02-10 06:13:38 +00:00
|
|
|
for (nsIFrame* frame = aChildList; nsnull != frame; frame->GetNextSibling(&frame)) {
|
1999-01-15 22:52:05 +00:00
|
|
|
frame->SetParent(mFrames.FirstChild());
|
2000-09-12 19:41:27 +00:00
|
|
|
// now reparent the contexts for the reparented frame too
|
|
|
|
if (frameManager) {
|
|
|
|
frameManager->ReParentStyleContext(aPresContext,frame,newParentContext);
|
|
|
|
}
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Queue up the frames for the inline frame
|
1999-01-15 22:52:05 +00:00
|
|
|
return mFrames.FirstChild()->SetInitialChildList(aPresContext, nsnull, aChildList);
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext,
|
1998-10-13 21:31:26 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer)
|
1998-10-13 21:31:26 +00:00
|
|
|
{
|
2001-01-27 14:09:34 +00:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
1999-04-25 20:07:45 +00:00
|
|
|
}
|
1999-03-06 19:43:13 +00:00
|
|
|
|
2001-01-27 14:09:34 +00:00
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
|
|
|
mRenderer.PaintButton(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, rect);
|
|
|
|
|
1999-11-03 00:05:30 +00:00
|
|
|
#if 0 // old way
|
1999-03-06 19:43:13 +00:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
|
|
|
|
1999-11-03 00:05:30 +00:00
|
|
|
#else // temporary
|
|
|
|
// XXX This is temporary
|
1999-12-02 22:07:43 +00:00
|
|
|
// clips to it's size minus the border
|
1999-11-03 00:05:30 +00:00
|
|
|
// but the real problem is the FirstChild (the AreaFrame)
|
|
|
|
// isn't being constrained properly
|
|
|
|
// Bug #17474
|
2001-02-07 09:57:26 +00:00
|
|
|
const nsStyleBorder* borderStyle;
|
|
|
|
GetStyleData(eStyleStruct_Border, (const nsStyleStruct *&)borderStyle);
|
1999-12-02 22:07:43 +00:00
|
|
|
nsMargin border;
|
|
|
|
border.SizeTo(0, 0, 0, 0);
|
2001-02-07 09:57:26 +00:00
|
|
|
borderStyle->CalcBorderFor(this, border);
|
1999-11-03 00:05:30 +00:00
|
|
|
|
1999-12-02 22:07:43 +00:00
|
|
|
rect.Deflate(border);
|
1999-11-03 00:05:30 +00:00
|
|
|
aRenderingContext.PushState();
|
|
|
|
PRBool clipEmpty;
|
|
|
|
|
1999-12-22 19:50:47 +00:00
|
|
|
aRenderingContext.SetClipRect(rect, nsClipCombine_kIntersect, clipEmpty);
|
1999-11-03 00:05:30 +00:00
|
|
|
|
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
|
|
|
|
|
|
|
aRenderingContext.PopState(clipEmpty);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2000-08-08 23:38:00 +00:00
|
|
|
// to draw border when selected in editor
|
|
|
|
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
|
1999-02-23 03:48:01 +00:00
|
|
|
// XXX a hack until the reflow state does this correctly
|
|
|
|
// XXX when it gets fixed, leave in the printf statements or add an assertion
|
1999-03-02 15:15:46 +00:00
|
|
|
static
|
1999-02-23 03:48:01 +00:00
|
|
|
void ButtonHack(nsHTMLReflowState& aReflowState, char* aMessage)
|
|
|
|
{
|
1999-07-20 03:41:03 +00:00
|
|
|
if (aReflowState.mComputedWidth == 0) {
|
|
|
|
aReflowState.mComputedWidth = aReflowState.availableWidth;
|
1999-02-23 03:48:01 +00:00
|
|
|
}
|
1999-07-20 03:41:03 +00:00
|
|
|
if ((aReflowState.mComputedWidth != NS_INTRINSICSIZE) &&
|
|
|
|
(aReflowState.mComputedWidth > aReflowState.availableWidth) &&
|
1999-02-23 03:48:01 +00:00
|
|
|
(aReflowState.availableWidth > 0)) {
|
2000-10-28 22:17:53 +00:00
|
|
|
// printf("BUG - %s has a computed width = %d, available width = %d \n",
|
|
|
|
// aMessage, aReflowState.mComputedWidth, aReflowState.availableWidth);
|
1999-07-20 03:41:03 +00:00
|
|
|
aReflowState.mComputedWidth = aReflowState.availableWidth;
|
2000-10-28 22:17:53 +00:00
|
|
|
}
|
|
|
|
if (aReflowState.mComputedHeight == 0) {
|
1999-07-20 03:41:03 +00:00
|
|
|
aReflowState.mComputedHeight = aReflowState.availableHeight;
|
1999-02-23 03:48:01 +00:00
|
|
|
}
|
1999-07-20 03:41:03 +00:00
|
|
|
if ((aReflowState.mComputedHeight != NS_INTRINSICSIZE) &&
|
|
|
|
(aReflowState.mComputedHeight > aReflowState.availableHeight) &&
|
1999-02-23 03:48:01 +00:00
|
|
|
(aReflowState.availableHeight > 0)) {
|
2000-10-28 22:17:53 +00:00
|
|
|
// printf("BUG - %s has a computed height = %d, available height = %d \n",
|
|
|
|
// aMessage, aReflowState.mComputedHeight, aReflowState.availableHeight);
|
1999-07-20 03:41:03 +00:00
|
|
|
aReflowState.mComputedHeight = aReflowState.availableHeight;
|
2000-10-28 22:17:53 +00:00
|
|
|
}
|
|
|
|
}
|
1999-02-23 03:48:01 +00:00
|
|
|
|
1999-08-31 13:05:31 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aSuggestedReflowState)
|
|
|
|
{
|
|
|
|
aDesiredSize.width += aSuggestedReflowState.mComputedBorderPadding.left + aSuggestedReflowState.mComputedBorderPadding.right;
|
|
|
|
aDesiredSize.height += aSuggestedReflowState.mComputedBorderPadding.top + aSuggestedReflowState.mComputedBorderPadding.bottom;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-13 21:31:26 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-13 21:31:26 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2000-04-21 21:51:35 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLButtonControlFrame", aReflowState.reason);
|
|
|
|
|
1999-09-13 20:40:59 +00:00
|
|
|
if (!mFormFrame && (eReflowReason_Initial == aReflowState.reason)) {
|
2000-02-09 19:34:39 +00:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE);
|
1999-11-24 06:03:41 +00:00
|
|
|
nsFormFrame::AddFormControlFrame(aPresContext, *NS_STATIC_CAST(nsIFrame*, this));
|
1999-09-13 20:40:59 +00:00
|
|
|
}
|
|
|
|
|
2000-02-09 19:34:39 +00:00
|
|
|
#if 0
|
2000-01-08 15:53:48 +00:00
|
|
|
nsresult skiprv = nsFormControlFrame::SkipResizeReflow(mCacheSize, mCachedMaxElementSize, aPresContext,
|
|
|
|
aDesiredSize, aReflowState, aStatus);
|
|
|
|
if (NS_SUCCEEDED(skiprv)) {
|
|
|
|
return skiprv;
|
|
|
|
}
|
2000-02-09 19:34:39 +00:00
|
|
|
#endif
|
1999-02-23 03:48:01 +00:00
|
|
|
// XXX remove the following when the reflow state is fixed
|
|
|
|
ButtonHack((nsHTMLReflowState&)aReflowState, "html4 button");
|
1999-03-06 19:43:13 +00:00
|
|
|
|
|
|
|
// commenting this out for now. We need a view to do mouse grabbing but
|
|
|
|
// it doesn't really seem to work correctly. When you press the only event
|
|
|
|
// you can get after that is a release. You need mouse enter and exit.
|
|
|
|
// the view also breaks the outline code. For some reason you can not reset
|
|
|
|
// the clip rect to draw outside you bounds if you have a view. And you need to
|
|
|
|
// because the outline must be drawn outside of our bounds according to CSS. -EDV
|
1999-11-19 15:33:29 +00:00
|
|
|
|
|
|
|
// XXX If you do decide you need a view, then create it in the Init() function
|
|
|
|
// and not here...
|
1999-03-06 19:43:13 +00:00
|
|
|
#if 0
|
1998-11-13 23:13:42 +00:00
|
|
|
if (!mDidInit) {
|
|
|
|
// create our view, we need a view to grab the mouse
|
|
|
|
nsIView* view;
|
1999-02-10 05:38:18 +00:00
|
|
|
GetView(&view);
|
1998-11-13 23:13:42 +00:00
|
|
|
if (!view) {
|
2001-01-04 20:44:42 +00:00
|
|
|
nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView), (void **)&view);
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
1999-11-24 06:03:41 +00:00
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
1999-02-12 17:45:58 +00:00
|
|
|
nsCOMPtr<nsIViewManager> viewMan;
|
|
|
|
presShell->GetViewManager(getter_AddRefs(viewMan));
|
1998-11-13 23:13:42 +00:00
|
|
|
|
|
|
|
nsIFrame* parWithView;
|
|
|
|
nsIView *parView;
|
1999-02-10 05:38:18 +00:00
|
|
|
GetParentWithView(&parWithView);
|
|
|
|
parWithView->GetView(&parView);
|
1998-11-13 23:13:42 +00:00
|
|
|
// the view's size is not know yet, but its size will be kept in synch with our frame.
|
|
|
|
nsRect boundBox(0, 0, 500, 500);
|
|
|
|
result = view->Init(viewMan, boundBox, parView, nsnull);
|
|
|
|
viewMan->InsertChild(parView, view, 0);
|
|
|
|
SetView(view);
|
|
|
|
|
|
|
|
const nsStyleColor* color = (const nsStyleColor*) mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
// set the opacity
|
|
|
|
viewMan->SetViewOpacity(view, color->mOpacity);
|
|
|
|
|
|
|
|
}
|
|
|
|
mDidInit = PR_TRUE;
|
|
|
|
}
|
1999-03-06 19:43:13 +00:00
|
|
|
#endif
|
1998-11-13 23:13:42 +00:00
|
|
|
|
1998-10-13 21:31:26 +00:00
|
|
|
// reflow the child
|
1999-01-15 22:52:05 +00:00
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
1999-07-23 00:11:21 +00:00
|
|
|
nsSize availSize(aReflowState.mComputedWidth, NS_INTRINSICSIZE);
|
1999-02-23 03:48:01 +00:00
|
|
|
|
1999-05-09 21:46:24 +00:00
|
|
|
// indent the child inside us by the the focus border. We must do this separate from the
|
|
|
|
// regular border.
|
|
|
|
nsMargin focusPadding = mRenderer.GetAddedButtonBorderAndPadding();
|
1999-02-23 03:48:01 +00:00
|
|
|
|
1999-07-23 00:11:21 +00:00
|
|
|
|
1999-02-23 03:48:01 +00:00
|
|
|
if (NS_INTRINSICSIZE != availSize.width) {
|
1999-05-09 21:46:24 +00:00
|
|
|
availSize.width -= focusPadding.left + focusPadding.right;
|
1999-02-23 03:48:01 +00:00
|
|
|
availSize.width = PR_MAX(availSize.width,0);
|
|
|
|
}
|
|
|
|
if (NS_AUTOHEIGHT != availSize.height) {
|
1999-05-09 21:46:24 +00:00
|
|
|
availSize.height -= focusPadding.top + focusPadding.bottom;
|
1999-02-23 03:48:01 +00:00
|
|
|
availSize.height = PR_MAX(availSize.height,0);
|
|
|
|
}
|
1999-07-23 00:11:21 +00:00
|
|
|
|
1999-03-05 04:19:09 +00:00
|
|
|
nsHTMLReflowState reflowState(aPresContext, aReflowState, firstKid, availSize);
|
1999-07-23 00:11:21 +00:00
|
|
|
//reflowState.computedWidth = availSize;
|
|
|
|
|
1999-02-23 03:48:01 +00:00
|
|
|
// XXX remove the following when the reflow state is fixed
|
1999-05-09 21:46:24 +00:00
|
|
|
//ButtonHack(reflowState, "html4 button's area");
|
1999-01-22 23:10:02 +00:00
|
|
|
|
|
|
|
// XXX Proper handling of incremental reflow...
|
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
|
|
|
nsIFrame* targetFrame;
|
|
|
|
|
|
|
|
// See if it's targeted at us
|
|
|
|
aReflowState.reflowCommand->GetTarget(targetFrame);
|
|
|
|
if (this == targetFrame) {
|
1999-11-24 06:03:41 +00:00
|
|
|
Invalidate(aPresContext, nsRect(0,0,mRect.width,mRect.height), PR_FALSE);
|
1999-07-23 00:11:21 +00:00
|
|
|
|
1999-09-29 03:35:51 +00:00
|
|
|
nsIReflowCommand::ReflowType reflowType;
|
|
|
|
aReflowState.reflowCommand->GetType(reflowType);
|
|
|
|
if (nsIReflowCommand::StyleChanged == reflowType) {
|
|
|
|
reflowState.reason = eReflowReason_StyleChange;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
reflowState.reason = eReflowReason_Resize;
|
|
|
|
}
|
1999-01-22 23:10:02 +00:00
|
|
|
} else {
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
|
|
|
|
// Remove the next frame from the reflow path
|
1999-04-21 22:46:15 +00:00
|
|
|
aReflowState.reflowCommand->GetNext(nextFrame);
|
1999-01-22 23:10:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-19 15:33:29 +00:00
|
|
|
ReflowChild(firstKid, aPresContext, aDesiredSize, reflowState,
|
|
|
|
focusPadding.left + aReflowState.mComputedBorderPadding.left,
|
|
|
|
focusPadding.top + aReflowState.mComputedBorderPadding.top,
|
|
|
|
0, aStatus);
|
1998-10-13 21:31:26 +00:00
|
|
|
|
2000-12-20 15:12:06 +00:00
|
|
|
// calculate the min internal size so the contents gets centered correctly
|
|
|
|
nscoord minInternalWidth = aReflowState.mComputedMinWidth == 0?0:aReflowState.mComputedMinWidth -
|
|
|
|
(aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
|
|
|
|
nscoord minInternalHeight = aReflowState.mComputedMinHeight == 0?0:aReflowState.mComputedMinHeight -
|
|
|
|
(aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
|
|
|
|
|
2000-01-18 20:29:22 +00:00
|
|
|
// center child vertically
|
|
|
|
nscoord yoff = 0;
|
|
|
|
if (aReflowState.mComputedHeight != NS_INTRINSICSIZE) {
|
|
|
|
yoff = (aReflowState.mComputedHeight - aDesiredSize.height)/2;
|
2000-12-20 15:12:06 +00:00
|
|
|
if (yoff < 0) {
|
|
|
|
yoff = 0;
|
|
|
|
}
|
|
|
|
} else if (aDesiredSize.height < minInternalHeight) {
|
|
|
|
yoff = (minInternalHeight - aDesiredSize.height) / 2;
|
2000-01-18 20:29:22 +00:00
|
|
|
}
|
|
|
|
|
1998-10-13 21:31:26 +00:00
|
|
|
// Place the child
|
1999-11-19 15:33:29 +00:00
|
|
|
FinishReflowChild(firstKid, aPresContext, aDesiredSize,
|
2001-04-03 14:10:47 +00:00
|
|
|
focusPadding.left + aReflowState.mComputedBorderPadding.right,
|
2000-01-18 20:29:22 +00:00
|
|
|
yoff + focusPadding.top + aReflowState.mComputedBorderPadding.top, 0);
|
1998-10-13 21:31:26 +00:00
|
|
|
|
1999-11-03 00:05:30 +00:00
|
|
|
#if 0 // old way
|
1999-07-23 00:11:21 +00:00
|
|
|
// if computed use the computed values.
|
|
|
|
if (aReflowState.mComputedWidth != NS_INTRINSICSIZE && (aDesiredSize.width < aReflowState.mComputedWidth))
|
|
|
|
aDesiredSize.width = aReflowState.mComputedWidth;
|
|
|
|
else
|
|
|
|
aDesiredSize.width += focusPadding.left + focusPadding.right;
|
|
|
|
|
|
|
|
if (aReflowState.mComputedHeight != NS_INTRINSICSIZE && (aDesiredSize.height < aReflowState.mComputedHeight))
|
|
|
|
aDesiredSize.height = aReflowState.mComputedHeight;
|
|
|
|
else
|
|
|
|
aDesiredSize.height += focusPadding.top + focusPadding.bottom;
|
1999-05-09 21:46:24 +00:00
|
|
|
|
1999-11-03 00:05:30 +00:00
|
|
|
#else // temporary for Bug #17474
|
|
|
|
// if computed use the computed values.
|
|
|
|
if (aReflowState.mComputedWidth != NS_INTRINSICSIZE)
|
|
|
|
aDesiredSize.width = aReflowState.mComputedWidth;
|
|
|
|
else
|
|
|
|
aDesiredSize.width += focusPadding.left + focusPadding.right;
|
|
|
|
|
|
|
|
if (aReflowState.mComputedHeight != NS_INTRINSICSIZE)
|
|
|
|
aDesiredSize.height = aReflowState.mComputedHeight;
|
|
|
|
else
|
|
|
|
aDesiredSize.height += focusPadding.top + focusPadding.bottom;
|
|
|
|
#endif
|
|
|
|
|
1999-08-31 13:05:31 +00:00
|
|
|
AddComputedBorderPaddingToDesiredSize(aDesiredSize, aReflowState);
|
|
|
|
//aDesiredSize.width += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
|
|
|
|
//aDesiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
|
1998-10-13 21:31:26 +00:00
|
|
|
|
2000-03-03 00:58:00 +00:00
|
|
|
#if 0
|
1999-02-23 03:48:01 +00:00
|
|
|
//adjust our max element size, if necessary
|
2000-01-05 16:42:47 +00:00
|
|
|
if (aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.AddBorderPaddingToMaxElementSize(aReflowState.mComputedBorderPadding);
|
|
|
|
}
|
2000-02-09 19:34:39 +00:00
|
|
|
#endif
|
1998-10-19 23:02:41 +00:00
|
|
|
|
1998-10-13 21:31:26 +00:00
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
|
2000-04-30 13:27:49 +00:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
|
|
|
aDesiredSize.maxElementSize->width = aDesiredSize.width;
|
|
|
|
aDesiredSize.maxElementSize->height = aDesiredSize.height;
|
|
|
|
}
|
1999-07-23 00:11:21 +00:00
|
|
|
|
2000-12-20 15:12:06 +00:00
|
|
|
// Make sure we obey min/max-width and min/max-height
|
|
|
|
if (aDesiredSize.width > aReflowState.mComputedMaxWidth) {
|
|
|
|
aDesiredSize.width = aReflowState.mComputedMaxWidth;
|
|
|
|
}
|
|
|
|
if (aDesiredSize.width < aReflowState.mComputedMinWidth) {
|
|
|
|
aDesiredSize.width = aReflowState.mComputedMinWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aDesiredSize.height > aReflowState.mComputedMaxHeight) {
|
|
|
|
aDesiredSize.height = aReflowState.mComputedMaxHeight;
|
|
|
|
}
|
|
|
|
if (aDesiredSize.height < aReflowState.mComputedMinHeight) {
|
|
|
|
aDesiredSize.height = aReflowState.mComputedMinHeight;
|
|
|
|
}
|
1998-10-13 21:31:26 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2000-01-08 15:53:48 +00:00
|
|
|
|
|
|
|
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedMaxElementSize, aDesiredSize);
|
1998-10-13 21:31:26 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIntn
|
|
|
|
nsHTMLButtonControlFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-01-22 15:32:57 +00:00
|
|
|
NS_IMETHODIMP
|
2000-02-09 19:34:39 +00:00
|
|
|
nsHTMLButtonControlFrame::GetFont(nsIPresContext* aPresContext,
|
|
|
|
const nsFont*& aFont)
|
1999-01-22 15:32:57 +00:00
|
|
|
{
|
2000-02-09 19:34:39 +00:00
|
|
|
return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont);
|
1999-01-22 15:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::GetFormContent(nsIContent*& aContent) const
|
|
|
|
{
|
1999-02-10 00:42:56 +00:00
|
|
|
nsIContent* content;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = GetContent(&content);
|
|
|
|
aContent = content;
|
|
|
|
return rv;
|
1999-01-22 15:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
1999-11-24 06:03:41 +00:00
|
|
|
nsHTMLButtonControlFrame::GetVerticalInsidePadding(nsIPresContext* aPresContext,
|
1999-09-30 11:30:04 +00:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerHeight) const
|
1999-01-22 15:32:57 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
1999-11-24 06:03:41 +00:00
|
|
|
nsHTMLButtonControlFrame::GetHorizontalInsidePadding(nsIPresContext* aPresContext,
|
1999-01-22 15:32:57 +00:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerWidth,
|
|
|
|
nscoord aCharWidth) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-03-06 19:43:13 +00:00
|
|
|
nsresult nsHTMLButtonControlFrame::RequiresWidget(PRBool& aRequiresWidget)
|
|
|
|
{
|
|
|
|
aRequiresWidget = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-26 04:44:41 +00:00
|
|
|
NS_IMETHODIMP nsHTMLButtonControlFrame::SetProperty(nsIPresContext* aPresContext,
|
2000-08-23 17:27:06 +00:00
|
|
|
nsIAtom* aName, const nsAReadableString& aValue)
|
1999-01-25 22:16:27 +00:00
|
|
|
{
|
2001-02-06 01:31:18 +00:00
|
|
|
if (nsHTMLAtoms::value == aName) {
|
|
|
|
nsCOMPtr<nsIHTMLContent> formControl(do_QueryInterface(mContent));
|
|
|
|
if (formControl) {
|
|
|
|
return formControl->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, aValue, PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
1999-01-25 22:16:27 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-08-23 17:27:06 +00:00
|
|
|
NS_IMETHODIMP nsHTMLButtonControlFrame::GetProperty(nsIAtom* aName, nsAWritableString& aValue)
|
1999-01-25 22:16:27 +00:00
|
|
|
{
|
2001-02-06 01:31:18 +00:00
|
|
|
if (nsHTMLAtoms::value == aName) {
|
|
|
|
nsCOMPtr<nsIHTMLContent> formControl(do_QueryInterface(mContent));
|
|
|
|
if (formControl) {
|
|
|
|
formControl->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::value, aValue);
|
|
|
|
}
|
|
|
|
}
|
1999-01-25 22:16:27 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-09-03 23:36:32 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::GetAdditionalStyleContext(PRInt32 aIndex,
|
|
|
|
nsIStyleContext** aStyleContext) const
|
|
|
|
{
|
|
|
|
return mRenderer.GetStyleContext(aIndex, aStyleContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::SetAdditionalStyleContext(PRInt32 aIndex,
|
|
|
|
nsIStyleContext* aStyleContext)
|
|
|
|
{
|
|
|
|
return mRenderer.SetStyleContext(aIndex, aStyleContext);
|
|
|
|
}
|
|
|
|
|
1999-03-06 19:43:13 +00:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-14 22:00:24 +00:00
|
|
|
NS_IMETHODIMP nsHTMLButtonControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
|
|
|
|
{
|
|
|
|
// mSuggestedWidth = aWidth;
|
|
|
|
// mSuggestedHeight = aHeight;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-06 19:43:13 +00:00
|
|
|
|
1999-01-25 22:16:27 +00:00
|
|
|
|
2000-08-02 22:16:12 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::AppendFrames(nsIPresContext* aPresContext,
|
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
return mFrames.FirstChild()->AppendFrames(aPresContext,
|
|
|
|
aPresShell,
|
|
|
|
aListName,
|
|
|
|
aFrameList);
|
|
|
|
}
|
1998-10-13 21:31:26 +00:00
|
|
|
|