2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-04-22 02:46:15 +04:00
|
|
|
|
|
|
|
#include "nsHTMLButtonControlFrame.h"
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2011-12-28 00:18:48 +04:00
|
|
|
#include "nsContainerFrame.h"
|
1998-10-14 01:31:26 +04:00
|
|
|
#include "nsIFormControlFrame.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIFormControl.h"
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1998-10-14 01:31:26 +04:00
|
|
|
#include "nsIPresShell.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-10-14 01:31:26 +04:00
|
|
|
#include "nsLeafFrame.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsISupports.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
1998-10-14 01:31:26 +04:00
|
|
|
#include "nsStyleConsts.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1999-03-06 22:43:13 +03:00
|
|
|
#include "nsButtonFrameRenderer.h"
|
2000-01-08 18:53:48 +03:00
|
|
|
#include "nsFormControlFrame.h"
|
2004-02-24 00:29:06 +03:00
|
|
|
#include "nsFrameManager.h"
|
2000-12-30 22:22:22 +03:00
|
|
|
#include "nsINameSpaceManager.h"
|
2002-06-04 04:44:04 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2002-06-26 05:53:11 +04:00
|
|
|
#include "nsIDOMHTMLButtonElement.h"
|
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
2004-01-28 03:18:22 +03:00
|
|
|
#include "nsStyleSet.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
1998-10-14 01:31:26 +04:00
|
|
|
|
2012-09-29 01:53:44 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2005-11-01 23:40:54 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-10-14 01:31:26 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsHTMLButtonControlFrame(aContext);
|
1998-10-14 01:31:26 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsHTMLButtonControlFrame)
|
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsHTMLButtonControlFrame::nsHTMLButtonControlFrame(nsStyleContext* aContext)
|
2011-12-28 00:18:48 +04:00
|
|
|
: nsContainerFrame(aContext)
|
1998-10-14 01:31:26 +04:00
|
|
|
{
|
1999-03-06 22:43:13 +03:00
|
|
|
}
|
|
|
|
|
1999-11-05 02:16:47 +03:00
|
|
|
nsHTMLButtonControlFrame::~nsHTMLButtonControlFrame()
|
|
|
|
{
|
2000-05-16 16:44:32 +04:00
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsHTMLButtonControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2000-05-16 16:44:32 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
|
2011-12-28 00:18:48 +04:00
|
|
|
nsContainerFrame::DestroyFrom(aDestructRoot);
|
1999-11-05 02:16:47 +03:00
|
|
|
}
|
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
NS_IMETHODIMP
|
2006-03-09 21:55:21 +03:00
|
|
|
nsHTMLButtonControlFrame::Init(
|
1999-03-06 22:43:13 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
2011-12-28 00:18:48 +04:00
|
|
|
nsresult rv = nsContainerFrame::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 08:38:33 +03:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2007-03-31 01:11:41 +04: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 08:38:33 +03:00
|
|
|
}
|
1999-03-06 22:43:13 +03:00
|
|
|
return rv;
|
1998-10-14 01:31:26 +04:00
|
|
|
}
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsHTMLButtonControlFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIFormControlFrame)
|
2011-12-28 00:18:48 +04:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
1998-10-14 01:31:26 +04:00
|
|
|
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-29 01:53:44 +04:00
|
|
|
a11y::AccType
|
|
|
|
nsHTMLButtonControlFrame::AccessibleType()
|
2001-05-18 03:52:32 +04:00
|
|
|
{
|
2012-12-18 05:25:52 +04:00
|
|
|
return a11y::eHTMLButtonType;
|
2001-05-18 03:52:32 +04:00
|
|
|
}
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-05-18 03:52:32 +04:00
|
|
|
|
2006-04-25 23:56:45 +04:00
|
|
|
nsIAtom*
|
|
|
|
nsHTMLButtonControlFrame::GetType() const
|
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::HTMLButtonControlFrame;
|
2006-04-25 23:56:45 +04:00
|
|
|
}
|
|
|
|
|
1998-10-23 03:00:37 +04:00
|
|
|
void
|
2011-09-29 10:19:26 +04:00
|
|
|
nsHTMLButtonControlFrame::SetFocus(bool aOn, bool aRepaint)
|
1998-10-23 03:00:37 +04:00
|
|
|
{
|
1998-10-17 04:35:32 +04:00
|
|
|
}
|
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLButtonControlFrame::HandleEvent(nsPresContext* aPresContext,
|
1999-03-31 10:02:12 +04:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsEventStatus* aEventStatus)
|
1998-10-14 01:31:26 +04:00
|
|
|
{
|
1999-03-06 22:43:13 +03:00
|
|
|
// if disabled do nothing
|
|
|
|
if (mRenderer.isDisabled()) {
|
1998-10-17 04:35:32 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-10-15 03:01:44 +04:00
|
|
|
|
2000-06-21 04:40:11 +04:00
|
|
|
// mouse clicks are handled by content
|
1999-05-13 05:35:16 +04: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-14 01:31:26 +04:00
|
|
|
}
|
|
|
|
|
1998-10-15 03:01:44 +04:00
|
|
|
|
1998-10-14 01:31:26 +04:00
|
|
|
NS_IMETHODIMP
|
2006-01-26 05:29:17 +03:00
|
|
|
nsHTMLButtonControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
nsDisplayList onTop;
|
|
|
|
if (IsVisibleForPainting(aBuilder)) {
|
2009-02-10 11:45:13 +03:00
|
|
|
nsresult rv = mRenderer.DisplayButton(aBuilder, aLists.BorderBackground(), &onTop);
|
2006-01-26 05:29:17 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-04-26 00:07:45 +04:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
|
|
|
|
nsDisplayListCollection set;
|
2006-02-19 23:14:11 +03: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 05:29:17 +03:00
|
|
|
|
|
|
|
// Put the foreground outline and focus rects on top of the children
|
|
|
|
set.Content()->AppendToTop(&onTop);
|
1999-03-06 22:43:13 +03:00
|
|
|
|
2010-01-25 19:03:43 +03: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) {
|
2012-05-31 09:19:49 +04:00
|
|
|
nsMargin border = GetStyleBorder()->GetComputedBorder();
|
2009-07-23 05:31:45 +04:00
|
|
|
nsRect rect(aBuilder->ToReferenceFrame(this), GetSize());
|
|
|
|
rect.Deflate(border);
|
2010-09-09 19:21:46 +04:00
|
|
|
nscoord radii[8];
|
|
|
|
GetPaddingBoxBorderRadii(radii);
|
|
|
|
|
|
|
|
nsresult rv = OverflowClip(aBuilder, set, aLists, rect, radii);
|
2009-07-23 05:31:45 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
} else {
|
|
|
|
set.MoveTo(aLists);
|
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2009-07-23 05:31:45 +04:00
|
|
|
nsresult rv = DisplayOutline(aBuilder, aLists);
|
2006-01-26 05:29:17 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2004-11-11 18:07:22 +03:00
|
|
|
|
2000-08-09 03:38:00 +04:00
|
|
|
// to draw border when selected in editor
|
2010-09-09 19:21:46 +04:00
|
|
|
return DisplaySelectionOverlay(aBuilder, aLists.Content());
|
1998-10-14 01:31:26 +04: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 08:38:33 +03:00
|
|
|
nscoord
|
2011-04-08 05:04:40 +04: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 08:38:33 +03:00
|
|
|
{
|
|
|
|
nscoord result;
|
|
|
|
DISPLAY_MIN_WIDTH(this, result);
|
2007-01-30 08:52:27 +03: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 08:38:33 +03:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2011-04-08 05:04:40 +04: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 08:38:33 +03: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 17:05:31 +04:00
|
|
|
|
1998-10-14 01:31:26 +04:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-14 01:31:26 +04: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 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLButtonControlFrame");
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2000-04-22 01:51:35 +04:00
|
|
|
|
2007-01-26 03:05:12 +03: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 08:38:33 +03:00
|
|
|
"Should have real computed width by now");
|
|
|
|
|
|
|
|
if (mState & NS_FRAME_FIRST_REFLOW) {
|
2011-10-17 18:59:28 +04:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), true);
|
1999-09-14 00:40:59 +04:00
|
|
|
}
|
|
|
|
|
2003-02-22 22:48:29 +03:00
|
|
|
// Reflow the child
|
1999-01-16 01:52:05 +03:00
|
|
|
nsIFrame* firstKid = mFrames.FirstChild();
|
1999-02-23 06:48:01 +03: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 08:38:33 +03:00
|
|
|
// XXXbz Eventually we may want to check-and-bail if
|
|
|
|
// !aReflowState.ShouldReflowAllKids() &&
|
2007-05-06 23:16:51 +04: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 08:38:33 +03:00
|
|
|
// We'd need to cache our ascent for that, of course.
|
1999-07-23 04:11:21 +04: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 08:38:33 +03:00
|
|
|
nsMargin focusPadding = mRenderer.GetAddedButtonBorderAndPadding();
|
1999-07-23 04:11:21 +04: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 08:38:33 +03:00
|
|
|
// Reflow the contents of the button.
|
2003-02-22 22:48:29 +03: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 08:38:33 +03:00
|
|
|
focusPadding, aStatus);
|
1998-10-14 01:31:26 +04:00
|
|
|
|
2007-01-26 03:05:12 +03:00
|
|
|
aDesiredSize.width = aReflowState.ComputedWidth();
|
1999-11-03 03:05:30 +03: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 08:38:33 +03:00
|
|
|
// If computed use the computed value.
|
2012-08-27 23:46:23 +04:00
|
|
|
if (aReflowState.ComputedHeight() != NS_INTRINSICSIZE) {
|
2007-08-02 22:08:05 +04:00
|
|
|
aDesiredSize.height = aReflowState.ComputedHeight();
|
2012-08-27 23:46:23 +04: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 08:38:33 +03:00
|
|
|
aDesiredSize.height += focusPadding.TopBottom();
|
1999-07-23 04:11:21 +04:00
|
|
|
|
2012-08-27 23:46:23 +04:00
|
|
|
// Make sure we obey min/max-height in the case when we're doing intrinsic
|
|
|
|
// sizing (we get it for free when we have a non-intrinsic
|
|
|
|
// aReflowState.ComputedHeight()). Note that we do this before adjusting
|
|
|
|
// for borderpadding, since mComputedMaxHeight and mComputedMinHeight are
|
|
|
|
// content heights.
|
|
|
|
aDesiredSize.height = NS_CSS_MINMAX(aDesiredSize.height,
|
|
|
|
aReflowState.mComputedMinHeight,
|
|
|
|
aReflowState.mComputedMaxHeight);
|
|
|
|
}
|
2000-12-20 18:12:06 +03:00
|
|
|
|
2012-08-27 23:46:23 +04:00
|
|
|
aDesiredSize.width += aReflowState.mComputedBorderPadding.LeftRight();
|
|
|
|
aDesiredSize.height += aReflowState.mComputedBorderPadding.TopBottom();
|
2002-11-12 22:17:51 +03: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 08:38:33 +03:00
|
|
|
aDesiredSize.ascent +=
|
|
|
|
aReflowState.mComputedBorderPadding.top + focusPadding.top;
|
2002-11-12 22:17:51 +03:00
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.SetOverflowAreasToDesiredBounds();
|
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, firstKid);
|
2011-05-12 03:53:34 +04:00
|
|
|
FinishReflowWithAbsoluteFrames(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2004-11-11 18:07:22 +03:00
|
|
|
|
1998-10-14 01:31:26 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2000-01-08 18:53:48 +03:00
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-10-14 01:31:26 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-02-22 22:48:29 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
|
2003-02-22 22:48:29 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsIFrame* aFirstKid,
|
|
|
|
nsMargin aFocusPadding,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2007-01-26 03:05:12 +03: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 08:38:33 +03: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 08:52:27 +03:00
|
|
|
nscoord extrawidth = GetMinWidth(aReflowState.rendContext) -
|
2007-01-26 03:05:12 +03: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 08:38:33 +03: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
|
2013-01-15 16:22:03 +04:00
|
|
|
extraleft = std::min(extraleft, aReflowState.mComputedPadding.left);
|
|
|
|
extraright = std::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 08:38:33 +03:00
|
|
|
xoffset -= extraleft;
|
|
|
|
availSize.width += extraleft + extraright;
|
|
|
|
}
|
2013-01-15 16:22:03 +04:00
|
|
|
availSize.width = std::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 08:38:33 +03:00
|
|
|
|
|
|
|
nsHTMLReflowState reflowState(aPresContext, aReflowState, aFirstKid,
|
|
|
|
availSize);
|
2003-02-22 22:48:29 +03: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 08:38:33 +03:00
|
|
|
xoffset,
|
2003-02-22 22:48:29 +03: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 08:38:33 +03: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();
|
2013-01-15 16:22:03 +04:00
|
|
|
minInternalHeight = std::max(minInternalHeight, 0);
|
2003-02-22 22:48:29 +03:00
|
|
|
|
|
|
|
// center child vertically
|
|
|
|
nscoord yoff = 0;
|
2007-08-02 22:08:05 +04:00
|
|
|
if (aReflowState.ComputedHeight() != NS_INTRINSICSIZE) {
|
|
|
|
yoff = (aReflowState.ComputedHeight() - aDesiredSize.height)/2;
|
2003-02-22 22:48:29 +03: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 07:06:56 +03: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 22:48:29 +03:00
|
|
|
}
|
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
nsresult nsHTMLButtonControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue)
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::value == aName) {
|
|
|
|
return mContent->SetAttr(kNameSpaceID_None, nsGkAtoms::value,
|
2011-10-17 18:59:28 +04:00
|
|
|
aValue, true);
|
2001-02-06 04:31:18 +03:00
|
|
|
}
|
1999-01-26 01:16:27 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-12-13 02:53:06 +03:00
|
|
|
nsresult nsHTMLButtonControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::value == aName)
|
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, aValue);
|
2005-01-12 22:45:38 +03:00
|
|
|
|
1999-01-26 01:16:27 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext*
|
2012-08-22 19:56:38 +04:00
|
|
|
nsHTMLButtonControlFrame::GetAdditionalStyleContext(int32_t aIndex) const
|
1999-09-04 03:36:32 +04:00
|
|
|
{
|
2003-02-22 03:32:13 +03:00
|
|
|
return mRenderer.GetStyleContext(aIndex);
|
1999-09-04 03:36:32 +04:00
|
|
|
}
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsHTMLButtonControlFrame::SetAdditionalStyleContext(int32_t aIndex,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aStyleContext)
|
1999-09-04 03:36:32 +04:00
|
|
|
{
|
2003-02-22 03:32:13 +03:00
|
|
|
mRenderer.SetStyleContext(aIndex, aStyleContext);
|
1999-09-04 03:36:32 +04:00
|
|
|
}
|
|
|
|
|
2000-08-03 02:16:12 +04:00
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsHTMLButtonControlFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2000-08-03 02:16:12 +04:00
|
|
|
{
|
2006-01-13 10:58:12 +03:00
|
|
|
NS_NOTREACHED("unsupported operation");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-11-18 05:12:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsHTMLButtonControlFrame::InsertFrames(ChildListID aListID,
|
2003-11-18 05:12:24 +03:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2003-11-18 05:12:24 +03:00
|
|
|
{
|
2006-01-13 10:58:12 +03:00
|
|
|
NS_NOTREACHED("unsupported operation");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-11-18 05:12:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-25 00:54:30 +04:00
|
|
|
nsHTMLButtonControlFrame::RemoveFrame(ChildListID aListID,
|
2003-11-18 05:12:24 +03:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2006-01-13 10:58:12 +03:00
|
|
|
NS_NOTREACHED("unsupported operation");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
2003-11-18 05:12:24 +03:00
|
|
|
}
|