2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-10-13 21:31:26 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla 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/MPL/
|
1998-10-13 21:31:26 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +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.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
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"
|
|
|
|
#include "nsIFormControlFrame.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIFormControl.h"
|
|
|
|
|
|
|
|
#include "nsIRenderingContext.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
1998-10-13 21:31:26 +00:00
|
|
|
#include "nsIPresShell.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1998-10-13 21:31:26 +00:00
|
|
|
#include "nsLeafFrame.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsISupports.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2002-11-17 15:37:56 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
1998-10-13 21:31:26 +00:00
|
|
|
#include "nsIImage.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIWidget.h"
|
1999-03-09 09:44:27 +00:00
|
|
|
#include "nsIComponentManager.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"
|
2004-02-23 21:29:06 +00:00
|
|
|
#include "nsFrameManager.h"
|
2000-12-30 19:22:22 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
2002-06-04 00:44:04 +00:00
|
|
|
#include "nsIServiceManager.h"
|
2002-06-26 01:53:11 +00:00
|
|
|
#include "nsIDOMHTMLButtonElement.h"
|
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
2004-01-28 00:18:22 +00:00
|
|
|
#include "nsStyleSet.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-11 21:11:38 +00:00
|
|
|
#include "nsIAccessibilityService.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
1998-10-13 21:31:26 +00:00
|
|
|
|
2005-11-01 20:40:54 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-10-13 21:31:26 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsHTMLButtonControlFrame(aContext);
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsHTMLButtonControlFrame::nsHTMLButtonControlFrame(nsStyleContext* aContext)
|
|
|
|
: nsHTMLContainerFrame(aContext)
|
1998-10-13 21:31:26 +00:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2006-04-10 00:16:29 +00:00
|
|
|
void
|
|
|
|
nsHTMLButtonControlFrame::Destroy()
|
2000-05-16 12:44:32 +00:00
|
|
|
{
|
2007-07-08 07:08:04 +00:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), PR_FALSE);
|
2006-04-10 00:16:29 +00:00
|
|
|
nsHTMLContainerFrame::Destroy();
|
1999-11-04 23:16:47 +00:00
|
|
|
}
|
|
|
|
|
1999-03-06 19:43:13 +00:00
|
|
|
NS_IMETHODIMP
|
2006-03-09 18:55:21 +00:00
|
|
|
nsHTMLButtonControlFrame::Init(
|
1999-03-06 19:43:13 +00:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
nsresult rv = nsHTMLContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2007-03-30 21:11:41 +00:00
|
|
|
mRenderer.SetFrame(this, PresContext());
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
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)
|
|
|
|
{
|
2007-07-04 02:15:31 +00:00
|
|
|
NS_PRECONDITION(aInstancePtr, "null out param");
|
|
|
|
|
2001-01-04 20:44:42 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
|
2007-07-08 07:08:04 +00:00
|
|
|
*aInstancePtr = static_cast<nsIFormControlFrame*>(this);
|
1998-10-13 21:31:26 +00:00
|
|
|
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-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
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) {
|
2003-07-04 12:50:32 +00:00
|
|
|
nsIContent* content = GetContent();
|
2002-06-26 01:53:11 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLButtonElement> buttonElement(do_QueryInterface(content));
|
|
|
|
if (buttonElement) //If turned XBL-base form control off, the frame contains HTML 4 button
|
2007-07-08 07:08:04 +00:00
|
|
|
return accService->CreateHTML4ButtonAccessible(static_cast<nsIFrame*>(this), aAccessible);
|
2002-06-26 01:53:11 +00:00
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(content));
|
|
|
|
if (inputElement) //If turned XBL-base form control on, the frame contains normal HTML button
|
2007-07-08 07:08:04 +00:00
|
|
|
return accService->CreateHTMLButtonAccessible(static_cast<nsIFrame*>(this), aAccessible);
|
2001-05-17 23:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-05-17 23:52:32 +00:00
|
|
|
|
2006-04-25 19:56:45 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsHTMLButtonControlFrame::GetType() const
|
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::HTMLButtonControlFrame;
|
2006-04-25 19:56:45 +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
|
2001-09-19 13:00:23 +00:00
|
|
|
nsHTMLButtonControlFrame::IsSubmit(PRInt32 type)
|
1999-09-13 20:40:59 +00:00
|
|
|
{
|
2001-09-19 13:00:23 +00:00
|
|
|
if (NS_FORM_BUTTON_SUBMIT == type) {
|
1999-09-13 20:40:59 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-22 23:00:37 +00:00
|
|
|
void
|
|
|
|
nsHTMLButtonControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
|
|
|
{
|
1998-10-17 00:35:32 +00:00
|
|
|
}
|
|
|
|
|
1998-11-18 05:25:26 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsHTMLButtonControlFrame::HandleEvent(nsPresContext* 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-10-13 21:31:26 +00:00
|
|
|
NS_IMETHODIMP
|
2006-01-26 02:29:17 +00:00
|
|
|
nsHTMLButtonControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
nsDisplayList onTop;
|
|
|
|
if (IsVisibleForPainting(aBuilder)) {
|
|
|
|
nsresult rv = mRenderer.DisplayButton(aBuilder, aLists.BorderBackground(), &onTop);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-04-25 20:07:45 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
nsDisplayListCollection set;
|
2006-02-19 20:14:11 +00:00
|
|
|
// Do not allow the child subtree to receive events.
|
|
|
|
if (!aBuilder->IsForEventDelivery()) {
|
|
|
|
nsresult rv =
|
|
|
|
BuildDisplayListForChild(aBuilder, mFrames.FirstChild(), aDirtyRect, set,
|
|
|
|
DISPLAY_CHILD_FORCE_PSEUDO_STACKING_CONTEXT);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
// That should put the display items in set.Content()
|
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
// Put the foreground outline and focus rects on top of the children
|
|
|
|
set.Content()->AppendToTop(&onTop);
|
1999-03-06 19:43:13 +00:00
|
|
|
|
1999-11-03 00:05:30 +00:00
|
|
|
// XXX This is temporary
|
2005-11-20 22:05:24 +00:00
|
|
|
// clips to its 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
|
2006-12-13 23:04:57 +00:00
|
|
|
nsMargin border = GetStyleBorder()->GetBorder();
|
2006-01-26 02:29:17 +00:00
|
|
|
nsRect rect(aBuilder->ToReferenceFrame(this), GetSize());
|
1999-12-02 22:07:43 +00:00
|
|
|
rect.Deflate(border);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2006-02-19 20:14:11 +00:00
|
|
|
nsresult rv = OverflowClip(aBuilder, set, aLists, rect);
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
rv = DisplayOutline(aBuilder, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2004-11-11 15:07:22 +00:00
|
|
|
|
2000-08-08 23:38:00 +00:00
|
|
|
// to draw border when selected in editor
|
2006-01-26 02:29:17 +00:00
|
|
|
return DisplaySelectionOverlay(aBuilder, aLists);
|
1998-10-13 21:31:26 +00:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nscoord
|
|
|
|
nsHTMLButtonControlFrame::GetMinWidth(nsIRenderingContext* aRenderingContext)
|
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
2007-01-30 05:52:27 +00:00
|
|
|
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
result = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
kid,
|
|
|
|
nsLayoutUtils::MIN_WIDTH);
|
|
|
|
|
|
|
|
result += mRenderer.GetAddedButtonBorderAndPadding().LeftRight();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsHTMLButtonControlFrame::GetPrefWidth(nsIRenderingContext* aRenderingContext)
|
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
|
|
|
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
result = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
kid,
|
|
|
|
nsLayoutUtils::PREF_WIDTH);
|
|
|
|
result += mRenderer.GetAddedButtonBorderAndPadding().LeftRight();
|
|
|
|
return result;
|
|
|
|
}
|
1999-08-31 13:05:31 +00:00
|
|
|
|
1998-10-13 21:31:26 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-13 21:31:26 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLButtonControlFrame");
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2000-04-21 21:51:35 +00:00
|
|
|
|
2007-01-26 00:05:12 +00:00
|
|
|
NS_PRECONDITION(aReflowState.ComputedWidth() != NS_INTRINSICSIZE,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
"Should have real computed width by now");
|
|
|
|
|
|
|
|
if (mState & NS_FRAME_FIRST_REFLOW) {
|
2007-07-08 07:08:04 +00:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), PR_TRUE);
|
1999-09-13 20:40:59 +00:00
|
|
|
}
|
|
|
|
|
2003-02-22 19:48:29 +00:00
|
|
|
// Reflow the child
|
1999-01-15 22:52:05 +00:00
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
1999-02-23 03:48:01 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// XXXbz Eventually we may want to check-and-bail if
|
|
|
|
// !aReflowState.ShouldReflowAllKids() &&
|
2007-05-06 19:16:51 +00:00
|
|
|
// !NS_SUBTREE_DIRTY(firstKid).
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// We'd need to cache our ascent for that, of course.
|
1999-07-23 00:11:21 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsMargin focusPadding = mRenderer.GetAddedButtonBorderAndPadding();
|
1999-07-23 00:11:21 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Reflow the contents of the button.
|
2003-02-22 19:48:29 +00:00
|
|
|
ReflowButtonContents(aPresContext, aDesiredSize, aReflowState, firstKid,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
focusPadding, aStatus);
|
1998-10-13 21:31:26 +00:00
|
|
|
|
2007-01-26 00:05:12 +00:00
|
|
|
aDesiredSize.width = aReflowState.ComputedWidth();
|
1999-11-03 00:05:30 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// If computed use the computed value.
|
1999-11-03 00:05:30 +00:00
|
|
|
if (aReflowState.mComputedHeight != NS_INTRINSICSIZE)
|
|
|
|
aDesiredSize.height = aReflowState.mComputedHeight;
|
|
|
|
else
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
aDesiredSize.height += focusPadding.TopBottom();
|
|
|
|
|
|
|
|
aDesiredSize.width += aReflowState.mComputedBorderPadding.LeftRight();
|
|
|
|
aDesiredSize.height += aReflowState.mComputedBorderPadding.TopBottom();
|
1999-07-23 00:11:21 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Make sure we obey min/max-height. Note that we do this after adjusting
|
|
|
|
// for borderpadding, since buttons have border-box sizing...
|
2000-12-20 15:12:06 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// XXXbz unless someone overrides that, of course! We should really consider
|
|
|
|
// exposing nsHTMLReflowState::AdjustComputed* or something.
|
|
|
|
aDesiredSize.height = NS_CSS_MINMAX(aDesiredSize.height,
|
|
|
|
aReflowState.mComputedMinHeight,
|
|
|
|
aReflowState.mComputedMaxHeight);
|
2002-11-12 19:17:51 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
aDesiredSize.ascent +=
|
|
|
|
aReflowState.mComputedBorderPadding.top + focusPadding.top;
|
2002-11-12 19:17:51 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
aDesiredSize.mOverflowArea =
|
|
|
|
nsRect(0, 0, aDesiredSize.width, aDesiredSize.height);
|
2005-03-31 02:19:48 +00:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowArea, firstKid);
|
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
2004-11-11 15:07:22 +00:00
|
|
|
|
1998-10-13 21:31:26 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2000-01-08 15:53:48 +00:00
|
|
|
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-10-13 21:31:26 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-02-22 19:48:29 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
|
2003-02-22 19:48:29 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsIFrame* aFirstKid,
|
|
|
|
nsMargin aFocusPadding,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2007-01-26 00:05:12 +00:00
|
|
|
nsSize availSize(aReflowState.ComputedWidth(), NS_INTRINSICSIZE);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
// Indent the child inside us by the focus border. We must do this separate
|
|
|
|
// from the regular border.
|
|
|
|
availSize.width -= aFocusPadding.LeftRight();
|
|
|
|
|
|
|
|
// See whether out availSize's width is big enough. If it's smaller than our
|
|
|
|
// intrinsic min width, that means that the kid wouldn't really fit; for a
|
|
|
|
// better look in such cases we adjust the available width and our left
|
|
|
|
// offset to allow the kid to spill left into our padding.
|
|
|
|
nscoord xoffset = aFocusPadding.left + aReflowState.mComputedBorderPadding.left;
|
2007-01-30 05:52:27 +00:00
|
|
|
nscoord extrawidth = GetMinWidth(aReflowState.rendContext) -
|
2007-01-26 00:05:12 +00:00
|
|
|
aReflowState.ComputedWidth();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (extrawidth > 0) {
|
|
|
|
nscoord extraleft = extrawidth / 2;
|
|
|
|
nscoord extraright = extrawidth - extraleft;
|
|
|
|
NS_ASSERTION(extraright >=0, "How'd that happen?");
|
|
|
|
|
|
|
|
// Do not allow the extras to be bigger than the relevant padding
|
|
|
|
extraleft = PR_MIN(extraleft, aReflowState.mComputedPadding.left);
|
|
|
|
extraright = PR_MIN(extraright, aReflowState.mComputedPadding.right);
|
|
|
|
xoffset -= extraleft;
|
|
|
|
availSize.width += extraleft + extraright;
|
|
|
|
}
|
2007-07-07 00:48:29 +00:00
|
|
|
availSize.width = PR_MAX(availSize.width,0);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
nsHTMLReflowState reflowState(aPresContext, aReflowState, aFirstKid,
|
|
|
|
availSize);
|
2003-02-22 19:48:29 +00:00
|
|
|
|
|
|
|
ReflowChild(aFirstKid, aPresContext, aDesiredSize, reflowState,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
xoffset,
|
2003-02-22 19:48:29 +00:00
|
|
|
aFocusPadding.top + aReflowState.mComputedBorderPadding.top,
|
|
|
|
0, aStatus);
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// calculate the min internal height so the contents gets centered correctly.
|
|
|
|
// XXXbz this assumes border-box sizing.
|
|
|
|
nscoord minInternalHeight = aReflowState.mComputedMinHeight -
|
|
|
|
aReflowState.mComputedBorderPadding.TopBottom();
|
|
|
|
minInternalHeight = PR_MAX(minInternalHeight, 0);
|
2003-02-22 19:48:29 +00:00
|
|
|
|
|
|
|
// center child vertically
|
|
|
|
nscoord yoff = 0;
|
|
|
|
if (aReflowState.mComputedHeight != NS_INTRINSICSIZE) {
|
|
|
|
yoff = (aReflowState.mComputedHeight - aDesiredSize.height)/2;
|
|
|
|
if (yoff < 0) {
|
|
|
|
yoff = 0;
|
|
|
|
}
|
|
|
|
} else if (aDesiredSize.height < minInternalHeight) {
|
|
|
|
yoff = (minInternalHeight - aDesiredSize.height) / 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Place the child
|
|
|
|
FinishReflowChild(aFirstKid, aPresContext, &reflowState, aDesiredSize,
|
|
|
|
xoffset,
|
|
|
|
yoff + aFocusPadding.top + aReflowState.mComputedBorderPadding.top, 0);
|
2007-01-23 04:06:56 +00:00
|
|
|
|
|
|
|
if (aDesiredSize.ascent == nsHTMLReflowMetrics::ASK_FOR_BASELINE)
|
|
|
|
aDesiredSize.ascent = aFirstKid->GetBaseline();
|
|
|
|
|
|
|
|
// Adjust the baseline by our offset (since we moved the child's
|
|
|
|
// baseline by that much).
|
|
|
|
aDesiredSize.ascent += yoff;
|
2003-02-22 19:48:29 +00:00
|
|
|
}
|
|
|
|
|
2004-03-12 04:40:17 +00:00
|
|
|
/* virtual */ PRBool
|
|
|
|
nsHTMLButtonControlFrame::IsContainingBlock() const
|
2002-11-19 03:39:44 +00:00
|
|
|
{
|
2004-03-12 04:40:17 +00:00
|
|
|
return PR_TRUE;
|
2002-11-19 03:39:44 +00:00
|
|
|
}
|
|
|
|
|
1998-10-13 21:31:26 +00:00
|
|
|
PRIntn
|
|
|
|
nsHTMLButtonControlFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-12-12 23:53:06 +00:00
|
|
|
nsresult nsHTMLButtonControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue)
|
1999-01-25 22:16:27 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
if (nsGkAtoms::value == aName) {
|
|
|
|
return mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::value,
|
2005-01-12 19:45:38 +00:00
|
|
|
aValue, PR_TRUE);
|
2001-02-06 01:31:18 +00:00
|
|
|
}
|
1999-01-25 22:16:27 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-12-12 23:53:06 +00:00
|
|
|
nsresult nsHTMLButtonControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const
|
1999-01-25 22:16:27 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
if (nsGkAtoms::value == aName)
|
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, aValue);
|
2005-01-12 19:45:38 +00:00
|
|
|
|
1999-01-25 22:16:27 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext*
|
|
|
|
nsHTMLButtonControlFrame::GetAdditionalStyleContext(PRInt32 aIndex) const
|
1999-09-03 23:36:32 +00:00
|
|
|
{
|
2003-02-22 00:32:13 +00:00
|
|
|
return mRenderer.GetStyleContext(aIndex);
|
1999-09-03 23:36:32 +00:00
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
void
|
1999-09-03 23:36:32 +00:00
|
|
|
nsHTMLButtonControlFrame::SetAdditionalStyleContext(PRInt32 aIndex,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aStyleContext)
|
1999-09-03 23:36:32 +00:00
|
|
|
{
|
2003-02-22 00:32:13 +00:00
|
|
|
mRenderer.SetStyleContext(aIndex, aStyleContext);
|
1999-09-03 23:36:32 +00:00
|
|
|
}
|
|
|
|
|
2000-08-02 22:16:12 +00:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsHTMLButtonControlFrame::AppendFrames(nsIAtom* aListName,
|
2000-08-02 22:16:12 +00:00
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2006-01-13 07:58:12 +00:00
|
|
|
NS_NOTREACHED("unsupported operation");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-11-18 02:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsHTMLButtonControlFrame::InsertFrames(nsIAtom* aListName,
|
2003-11-18 02:12:24 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2006-01-13 07:58:12 +00:00
|
|
|
NS_NOTREACHED("unsupported operation");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-11-18 02:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsHTMLButtonControlFrame::RemoveFrame(nsIAtom* aListName,
|
2003-11-18 02:12:24 +00:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2006-01-13 07:58:12 +00:00
|
|
|
NS_NOTREACHED("unsupported operation");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-11-18 02:12:24 +00:00
|
|
|
}
|