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"
|
|
|
|
|
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 "nsStyleConsts.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
|
2011-01-28 04:38:14 +00:00
|
|
|
#include "nsAccessibilityService.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
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLButtonControlFrame)
|
|
|
|
|
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
|
2009-12-24 05:21:15 +00:00
|
|
|
nsHTMLButtonControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2000-05-16 12:44:32 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
2011-05-11 23:53:34 +00:00
|
|
|
DestroyAbsoluteFrames(aDestructRoot);
|
2009-12-24 05:21:15 +00:00
|
|
|
nsHTMLContainerFrame::DestroyFrom(aDestructRoot);
|
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
|
|
|
}
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsHTMLButtonControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame)
|
1998-10-13 21:31:26 +00:00
|
|
|
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 12:02:03 +00:00
|
|
|
already_AddRefed<nsAccessible>
|
|
|
|
nsHTMLButtonControlFrame::CreateAccessible()
|
2001-05-17 23:52:32 +00:00
|
|
|
{
|
2011-01-28 04:38:14 +00:00
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
2001-05-17 23:52:32 +00:00
|
|
|
if (accService) {
|
2010-06-28 12:02:03 +00:00
|
|
|
return IsInput() ?
|
|
|
|
accService->CreateHTMLButtonAccessible(mContent, PresContext()->PresShell()) :
|
|
|
|
accService->CreateHTML4ButtonAccessible(mContent, PresContext()->PresShell());
|
2001-05-17 23:52:32 +00:00
|
|
|
}
|
|
|
|
|
2010-06-28 12:02:03 +00:00
|
|
|
return nsnull;
|
2001-05-17 23:52:32 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
1998-10-22 23:00:37 +00:00
|
|
|
void
|
2011-09-29 06:19:26 +00:00
|
|
|
nsHTMLButtonControlFrame::SetFocus(bool aOn, bool aRepaint)
|
1998-10-22 23:00:37 +00:00
|
|
|
{
|
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)) {
|
2009-02-10 08:45:13 +00:00
|
|
|
nsresult rv = mRenderer.DisplayButton(aBuilder, aLists.BorderBackground(), &onTop);
|
2006-01-26 02:29:17 +00:00
|
|
|
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
|
|
|
|
2010-01-25 16:03:43 +00:00
|
|
|
// clips to our padding box for <input>s but not <button>s, unless
|
|
|
|
// they have non-visible overflow..
|
|
|
|
if (IsInput() || GetStyleDisplay()->mOverflowX != NS_STYLE_OVERFLOW_VISIBLE) {
|
2009-07-23 01:31:45 +00:00
|
|
|
nsMargin border = GetStyleBorder()->GetActualBorder();
|
|
|
|
nsRect rect(aBuilder->ToReferenceFrame(this), GetSize());
|
|
|
|
rect.Deflate(border);
|
2010-09-09 15:21:46 +00:00
|
|
|
nscoord radii[8];
|
|
|
|
GetPaddingBoxBorderRadii(radii);
|
|
|
|
|
|
|
|
nsresult rv = OverflowClip(aBuilder, set, aLists, rect, radii);
|
2009-07-23 01:31:45 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
} else {
|
|
|
|
set.MoveTo(aLists);
|
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2009-07-23 01:31:45 +00:00
|
|
|
nsresult rv = DisplayOutline(aBuilder, aLists);
|
2006-01-26 02:29:17 +00:00
|
|
|
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
|
2010-09-09 15:21:46 +00:00
|
|
|
return DisplaySelectionOverlay(aBuilder, aLists.Content());
|
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
|
2011-04-08 01:04:40 +00:00
|
|
|
nsHTMLButtonControlFrame::GetMinWidth(nsRenderingContext* aRenderingContext)
|
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 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
|
2011-04-08 01:04:40 +00:00
|
|
|
nsHTMLButtonControlFrame::GetPrefWidth(nsRenderingContext* aRenderingContext)
|
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 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) {
|
2011-10-17 14:59:28 +00:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), 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.
|
2007-08-02 18:08:05 +00:00
|
|
|
if (aReflowState.ComputedHeight() != NS_INTRINSICSIZE)
|
|
|
|
aDesiredSize.height = aReflowState.ComputedHeight();
|
1999-11-03 00:05:30 +00:00
|
|
|
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
|
|
|
|
2010-10-07 04:25:46 +00:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, firstKid);
|
2011-05-11 23:53:34 +00:00
|
|
|
FinishReflowWithAbsoluteFrames(aPresContext, aDesiredSize, aReflowState, aStatus);
|
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
|
2009-09-16 15:01:36 +00:00
|
|
|
extraleft = NS_MIN(extraleft, aReflowState.mComputedPadding.left);
|
|
|
|
extraright = NS_MIN(extraright, aReflowState.mComputedPadding.right);
|
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 -= extraleft;
|
|
|
|
availSize.width += extraleft + extraright;
|
|
|
|
}
|
2009-09-16 15:01:36 +00:00
|
|
|
availSize.width = NS_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();
|
2009-09-16 15:01:36 +00:00
|
|
|
minInternalHeight = NS_MAX(minInternalHeight, 0);
|
2003-02-22 19:48:29 +00:00
|
|
|
|
|
|
|
// center child vertically
|
|
|
|
nscoord yoff = 0;
|
2007-08-02 18:08:05 +00:00
|
|
|
if (aReflowState.ComputedHeight() != NS_INTRINSICSIZE) {
|
|
|
|
yoff = (aReflowState.ComputedHeight() - aDesiredSize.height)/2;
|
2003-02-22 19:48:29 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
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,
|
2011-10-17 14:59:28 +00:00
|
|
|
aValue, 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
|
2011-08-24 20:54:30 +00:00
|
|
|
nsHTMLButtonControlFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
2000-08-02 22:16:12 +00:00
|
|
|
{
|
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
|
2011-08-24 20:54:30 +00:00
|
|
|
nsHTMLButtonControlFrame::InsertFrames(ChildListID aListID,
|
2003-11-18 02:12:24 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
2003-11-18 02:12:24 +00:00
|
|
|
{
|
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
|
2011-08-24 20:54:30 +00:00
|
|
|
nsHTMLButtonControlFrame::RemoveFrame(ChildListID aListID,
|
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
|
|
|
}
|