2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-10-14 01:31:26 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
1998-10-14 01:31:26 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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-14 01:31:26 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either 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"),
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-04-22 02:46:15 +04:00
|
|
|
|
|
|
|
#include "nsHTMLButtonControlFrame.h"
|
|
|
|
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-10-14 01:31:26 +04:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
1999-01-22 18:32:57 +03:00
|
|
|
#include "nsFormControlHelper.h"
|
1998-10-14 01:31:26 +04:00
|
|
|
#include "nsIFormControlFrame.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIFormControl.h"
|
|
|
|
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#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"
|
|
|
|
#include "nsHTMLAtoms.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
1998-10-14 01:31:26 +04:00
|
|
|
#include "nsIImage.h"
|
|
|
|
#include "nsStyleConsts.h"
|
2002-03-27 03:13:57 +03:00
|
|
|
#include "nsIHTMLContent.h"
|
1998-10-14 01:31:26 +04:00
|
|
|
#include "nsIWidget.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1998-10-14 01:31:26 +04:00
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsViewsCID.h"
|
1998-10-17 04:35:32 +04:00
|
|
|
#include "nsColor.h"
|
1999-01-23 02:10:02 +03:00
|
|
|
#include "nsIDocument.h"
|
1999-03-06 22:43:13 +03:00
|
|
|
#include "nsButtonFrameRenderer.h"
|
2000-01-08 18:53:48 +03:00
|
|
|
#include "nsFormControlFrame.h"
|
2000-09-12 23:41:27 +04:00
|
|
|
#include "nsIFrameManager.h"
|
2000-12-30 22:22:22 +03:00
|
|
|
#include "nsINameSpaceManager.h"
|
2002-06-04 04:44:04 +04:00
|
|
|
#include "nsReflowPath.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2002-06-26 05:53:11 +04:00
|
|
|
#include "nsIDOMHTMLButtonElement.h"
|
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-12 01:11:38 +04:00
|
|
|
#include "nsIAccessibilityService.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
1998-10-14 01:31:26 +04:00
|
|
|
|
2002-01-09 18:44:32 +03:00
|
|
|
#if 0
|
|
|
|
// see nsHTMLButtonControlFrame::Reflow()
|
1998-10-14 01:31:26 +04:00
|
|
|
static NS_DEFINE_IID(kViewCID, NS_VIEW_CID);
|
2002-01-09 18:44:32 +03:00
|
|
|
#endif
|
1998-10-14 01:31:26 +04:00
|
|
|
|
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewHTMLButtonControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-10-14 01:31:26 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsHTMLButtonControlFrame* it = new (aPresShell) nsHTMLButtonControlFrame;
|
1999-05-12 02:03:29 +04:00
|
|
|
if (!it) {
|
1998-10-14 01:31:26 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-10-14 01:31:26 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-03 09:31:43 +03:00
|
|
|
nsHTMLButtonControlFrame::nsHTMLButtonControlFrame()
|
|
|
|
: nsHTMLContainerFrame()
|
1998-10-14 01:31:26 +04:00
|
|
|
{
|
|
|
|
mInline = PR_TRUE;
|
1998-10-15 03:01:44 +04:00
|
|
|
mPreviousCursor = eCursor_standard;
|
1998-10-17 04:35:32 +04:00
|
|
|
mTranslatedRect = nsRect(0,0,0,0);
|
1998-11-14 02:13:42 +03:00
|
|
|
mDidInit = PR_FALSE;
|
2000-01-08 18:53:48 +03:00
|
|
|
|
|
|
|
mCacheSize.width = -1;
|
|
|
|
mCacheSize.height = -1;
|
2003-01-09 17:26:32 +03:00
|
|
|
mCachedMaxElementWidth = -1;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::Destroy(nsIPresContext *aPresContext)
|
|
|
|
{
|
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_FALSE);
|
|
|
|
return nsHTMLContainerFrame::Destroy(aPresContext);
|
1999-11-05 02:16:47 +03:00
|
|
|
}
|
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLButtonControlFrame::Init(nsIPresContext* aPresContext,
|
1999-03-06 22:43:13 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
1999-03-06 22:43:13 +03:00
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
|
|
|
mRenderer.SetFrame(this,aPresContext);
|
1999-11-12 04:45:53 +03:00
|
|
|
// cache our display type
|
|
|
|
const nsStyleDisplay* styleDisplay;
|
|
|
|
GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&) styleDisplay);
|
|
|
|
mInline = (NS_STYLE_DISPLAY_BLOCK != styleDisplay->mDisplay);
|
|
|
|
|
|
|
|
PRUint32 flags = NS_BLOCK_SPACE_MGR;
|
|
|
|
if (mInline) {
|
|
|
|
flags |= NS_BLOCK_SHRINK_WRAP;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
1999-11-12 04:45:53 +03:00
|
|
|
nsIFrame* areaFrame;
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewAreaFrame(shell, &areaFrame, flags);
|
1999-11-12 04:45:53 +03:00
|
|
|
mFrames.SetFrames(areaFrame);
|
|
|
|
|
|
|
|
// Resolve style and initialize the frame
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> styleContext;
|
|
|
|
styleContext = aPresContext->ResolvePseudoStyleContextFor(mContent,
|
2002-11-17 18:37:56 +03:00
|
|
|
nsCSSAnonBoxes::buttonContent,
|
2003-02-22 03:32:13 +03:00
|
|
|
mStyleContext);
|
1999-11-12 04:45:53 +03:00
|
|
|
mFrames.FirstChild()->Init(aPresContext, mContent, this, styleContext, nsnull);
|
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
return rv;
|
1998-10-14 01:31:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsHTMLButtonControlFrame::AddRef(void)
|
|
|
|
{
|
|
|
|
NS_WARNING("not supported");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt nsHTMLButtonControlFrame::Release(void)
|
|
|
|
{
|
|
|
|
NS_WARNING("not supported");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1999-11-02 04:50:15 +03:00
|
|
|
// Frames are not refcounted, no need to AddRef
|
|
|
|
NS_IMETHODIMP
|
1998-10-14 01:31:26 +04:00
|
|
|
nsHTMLButtonControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2001-01-04 23:44:42 +03:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
|
1998-10-14 01:31:26 +04:00
|
|
|
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-05-12 01:11:38 +04:00
|
|
|
|
1998-10-14 01:31:26 +04:00
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-18 03:52:32 +04:00
|
|
|
NS_IMETHODIMP nsHTMLButtonControlFrame::GetAccessible(nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
|
|
|
|
if (accService) {
|
2002-06-26 05:53:11 +04:00
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
GetContent(getter_AddRefs(content));
|
|
|
|
nsCOMPtr<nsIDOMHTMLButtonElement> buttonElement(do_QueryInterface(content));
|
|
|
|
if (buttonElement) //If turned XBL-base form control off, the frame contains HTML 4 button
|
|
|
|
return accService->CreateHTML4ButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(content));
|
|
|
|
if (inputElement) //If turned XBL-base form control on, the frame contains normal HTML button
|
|
|
|
return accService->CreateHTMLButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
2001-05-18 03:52:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-05-18 03:52:32 +04:00
|
|
|
|
|
|
|
|
2002-12-19 02:38:09 +03:00
|
|
|
NS_IMETHODIMP_(PRInt32)
|
|
|
|
nsHTMLButtonControlFrame::GetType() const
|
1998-10-14 01:31:26 +04:00
|
|
|
{
|
2002-12-19 02:38:09 +03:00
|
|
|
return nsFormControlHelper::GetType(mContent);
|
1998-10-14 01:31:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-11-02 10:40:01 +03:00
|
|
|
nsHTMLButtonControlFrame::GetName(nsAString* aResult)
|
1998-10-14 01:31:26 +04:00
|
|
|
{
|
2002-08-07 03:50:08 +04:00
|
|
|
return nsFormControlHelper::GetName(mContent, aResult);
|
1998-10-14 01:31:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-11-02 10:40:01 +03:00
|
|
|
nsHTMLButtonControlFrame::GetValue(nsAString* aResult)
|
1998-10-14 01:31:26 +04:00
|
|
|
{
|
2002-08-07 03:50:08 +04:00
|
|
|
return nsFormControlHelper::GetValueAttr(mContent, aResult);
|
1998-10-14 01:31:26 +04:00
|
|
|
}
|
|
|
|
|
1999-09-14 00:40:59 +04:00
|
|
|
PRBool
|
|
|
|
nsHTMLButtonControlFrame::IsReset(PRInt32 type)
|
|
|
|
{
|
|
|
|
if (NS_FORM_BUTTON_RESET == type) {
|
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
2001-09-19 17:00:23 +04:00
|
|
|
nsHTMLButtonControlFrame::IsSubmit(PRInt32 type)
|
1999-09-14 00:40:59 +04:00
|
|
|
{
|
2001-09-19 17:00:23 +04:00
|
|
|
if (NS_FORM_BUTTON_SUBMIT == type) {
|
1999-09-14 00:40:59 +04:00
|
|
|
return PR_TRUE;
|
|
|
|
} else {
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-14 01:31:26 +04:00
|
|
|
void
|
|
|
|
nsHTMLButtonControlFrame::MouseClicked(nsIPresContext* aPresContext)
|
|
|
|
{
|
2002-02-09 02:50:51 +03:00
|
|
|
// This is no longer called; click events are handled in
|
|
|
|
// nsHTMLInputElement::HandleDOMEvent().
|
1998-10-14 01:31:26 +04:00
|
|
|
}
|
|
|
|
|
1998-10-23 03:00:37 +04:00
|
|
|
void
|
|
|
|
nsHTMLButtonControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
|
|
|
{
|
1998-10-17 04:35:32 +04:00
|
|
|
}
|
|
|
|
|
1999-08-21 04:09:24 +04:00
|
|
|
void
|
|
|
|
nsHTMLButtonControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
if (aPresContext) {
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
2000-09-08 09:53:28 +04:00
|
|
|
if (presShell) {
|
|
|
|
presShell->ScrollFrameIntoView(this,
|
2000-01-26 01:19:39 +03:00
|
|
|
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE);
|
1999-08-21 04:09:24 +04:00
|
|
|
|
2000-09-08 09:53:28 +04:00
|
|
|
}
|
1999-08-21 04:09:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-17 04:35:32 +04:00
|
|
|
void
|
1999-10-26 08:44:41 +04:00
|
|
|
nsHTMLButtonControlFrame::GetTranslatedRect(nsIPresContext* aPresContext, nsRect& aRect)
|
1998-10-17 04:35:32 +04:00
|
|
|
{
|
|
|
|
nsIView* view;
|
|
|
|
nsPoint viewOffset(0,0);
|
1999-10-26 08:44:41 +04:00
|
|
|
GetOffsetFromView(aPresContext, viewOffset, &view);
|
1998-10-17 04:35:32 +04:00
|
|
|
while (nsnull != view) {
|
|
|
|
nsPoint tempOffset;
|
|
|
|
view->GetPosition(&tempOffset.x, &tempOffset.y);
|
|
|
|
viewOffset += tempOffset;
|
|
|
|
view->GetParent(view);
|
|
|
|
}
|
|
|
|
aRect = nsRect(viewOffset.x, viewOffset.y, mRect.width, mRect.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLButtonControlFrame::HandleEvent(nsIPresContext* 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-11-18 08:25:26 +03:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsHTMLButtonControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
2000-03-22 05:43:08 +03:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
1999-10-26 08:44:41 +04:00
|
|
|
nsIFrame** aFrame)
|
1998-11-18 08:25:26 +03:00
|
|
|
{
|
2002-04-06 19:31:53 +04:00
|
|
|
if (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND &&
|
|
|
|
mRect.Contains(aPoint)) {
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleVisibility* vis =
|
|
|
|
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
|
|
|
|
|
|
|
|
if (vis->IsVisible()) {
|
2000-03-22 05:43:08 +03:00
|
|
|
*aFrame = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-11-18 08:25:26 +03:00
|
|
|
}
|
|
|
|
|
1998-10-14 01:31:26 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLButtonControlFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
1998-11-10 09:05:32 +03:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-10-14 01:31:26 +04:00
|
|
|
{
|
2000-09-12 23:41:27 +04:00
|
|
|
// get the frame manager and the style context of the new parent frame
|
|
|
|
// this is used whent he children are reparented below
|
|
|
|
// NOTE: the whole reparenting should not need to happen: see bugzilla bug 51767
|
|
|
|
//
|
|
|
|
nsCOMPtr<nsIPresShell> shell;
|
|
|
|
nsCOMPtr<nsIFrameManager> frameManager;
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* newParentContext;
|
2000-09-12 23:41:27 +04:00
|
|
|
aPresContext->GetShell(getter_AddRefs(shell));
|
|
|
|
if (shell) {
|
|
|
|
shell->GetFrameManager(getter_AddRefs(frameManager));
|
|
|
|
}
|
|
|
|
// get the new parent context from the first child: that is the frame that the
|
|
|
|
// subsequent children will be made children of
|
2003-02-22 03:32:13 +03:00
|
|
|
newParentContext = mFrames.FirstChild()->GetStyleContext();
|
2000-09-12 23:41:27 +04:00
|
|
|
|
1999-01-14 08:16:23 +03:00
|
|
|
// Set the parent for each of the child frames
|
1999-02-10 09:13:38 +03:00
|
|
|
for (nsIFrame* frame = aChildList; nsnull != frame; frame->GetNextSibling(&frame)) {
|
1999-01-16 01:52:05 +03:00
|
|
|
frame->SetParent(mFrames.FirstChild());
|
2000-09-12 23:41:27 +04:00
|
|
|
// now reparent the contexts for the reparented frame too
|
|
|
|
if (frameManager) {
|
|
|
|
frameManager->ReParentStyleContext(aPresContext,frame,newParentContext);
|
|
|
|
}
|
1998-10-14 01:31:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Queue up the frames for the inline frame
|
1999-01-16 01:52:05 +03:00
|
|
|
return mFrames.FirstChild()->SetInitialChildList(aPresContext, nsnull, aChildList);
|
1998-10-14 01:31:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-09-19 16:35:19 +04:00
|
|
|
nsHTMLButtonControlFrame::Paint(nsIPresContext* aPresContext,
|
1998-10-14 01:31:26 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-10-14 01:31:26 +04:00
|
|
|
{
|
2001-01-27 17:09:34 +03:00
|
|
|
PRBool isVisible;
|
2002-04-06 19:31:53 +04:00
|
|
|
if (aWhichLayer != NS_FRAME_PAINT_LAYER_FOREGROUND ||
|
|
|
|
(NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible)) {
|
2001-01-27 17:09:34 +03:00
|
|
|
return NS_OK;
|
1999-04-26 00:07:45 +04:00
|
|
|
}
|
1999-03-06 22:43:13 +03:00
|
|
|
|
2001-01-27 17:09:34 +03:00
|
|
|
nsRect rect(0, 0, mRect.width, mRect.height);
|
2002-04-06 19:31:53 +04:00
|
|
|
mRenderer.PaintButton(aPresContext, aRenderingContext, aDirtyRect, rect);
|
2001-01-27 17:09:34 +03:00
|
|
|
|
1999-11-03 03:05:30 +03:00
|
|
|
#if 0 // old way
|
2002-04-06 19:31:53 +04:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_BACKGROUND);
|
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FLOATERS);
|
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FOREGROUND);
|
1999-03-06 22:43:13 +03:00
|
|
|
|
1999-11-03 03:05:30 +03:00
|
|
|
#else // temporary
|
|
|
|
// XXX This is temporary
|
1999-12-03 01:07:43 +03:00
|
|
|
// clips to it's size minus the border
|
1999-11-03 03:05:30 +03:00
|
|
|
// but the real problem is the FirstChild (the AreaFrame)
|
|
|
|
// isn't being constrained properly
|
|
|
|
// Bug #17474
|
2001-02-07 12:57:26 +03:00
|
|
|
const nsStyleBorder* borderStyle;
|
|
|
|
GetStyleData(eStyleStruct_Border, (const nsStyleStruct *&)borderStyle);
|
1999-12-03 01:07:43 +03:00
|
|
|
nsMargin border;
|
|
|
|
border.SizeTo(0, 0, 0, 0);
|
2001-02-07 12:57:26 +03:00
|
|
|
borderStyle->CalcBorderFor(this, border);
|
1999-11-03 03:05:30 +03:00
|
|
|
|
1999-12-03 01:07:43 +03:00
|
|
|
rect.Deflate(border);
|
1999-11-03 03:05:30 +03:00
|
|
|
aRenderingContext.PushState();
|
|
|
|
PRBool clipEmpty;
|
|
|
|
|
1999-12-22 22:50:47 +03:00
|
|
|
aRenderingContext.SetClipRect(rect, nsClipCombine_kIntersect, clipEmpty);
|
1999-11-03 03:05:30 +03:00
|
|
|
|
2002-04-06 19:31:53 +04:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_BACKGROUND);
|
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FLOATERS);
|
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, NS_FRAME_PAINT_LAYER_FOREGROUND);
|
1999-11-03 03:05:30 +03:00
|
|
|
|
|
|
|
aRenderingContext.PopState(clipEmpty);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2000-08-09 03:38:00 +04:00
|
|
|
// to draw border when selected in editor
|
|
|
|
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1998-10-14 01:31:26 +04:00
|
|
|
}
|
|
|
|
|
1999-08-31 17:05:31 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aSuggestedReflowState)
|
|
|
|
{
|
|
|
|
aDesiredSize.width += aSuggestedReflowState.mComputedBorderPadding.left + aSuggestedReflowState.mComputedBorderPadding.right;
|
|
|
|
aDesiredSize.height += aSuggestedReflowState.mComputedBorderPadding.top + aSuggestedReflowState.mComputedBorderPadding.bottom;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-14 01:31:26 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLButtonControlFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-14 01:31:26 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2000-04-22 01:51:35 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsHTMLButtonControlFrame", aReflowState.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2000-04-22 01:51:35 +04:00
|
|
|
|
2002-06-04 04:44:04 +04:00
|
|
|
if (eReflowReason_Initial == aReflowState.reason) {
|
2000-02-09 22:34:39 +03:00
|
|
|
nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE);
|
1999-09-14 00:40:59 +04:00
|
|
|
}
|
|
|
|
|
2000-02-09 22:34:39 +03:00
|
|
|
#if 0
|
2003-01-09 17:26:32 +03:00
|
|
|
nsresult skiprv = nsFormControlFrame::SkipResizeReflow(mCacheSize, mCachedMaxElementWidth, aPresContext,
|
2000-01-08 18:53:48 +03:00
|
|
|
aDesiredSize, aReflowState, aStatus);
|
|
|
|
if (NS_SUCCEEDED(skiprv)) {
|
|
|
|
return skiprv;
|
|
|
|
}
|
2000-02-09 22:34:39 +03:00
|
|
|
#endif
|
1999-03-06 22:43:13 +03:00
|
|
|
|
|
|
|
// commenting this out for now. We need a view to do mouse grabbing but
|
|
|
|
// it doesn't really seem to work correctly. When you press the only event
|
|
|
|
// you can get after that is a release. You need mouse enter and exit.
|
|
|
|
// the view also breaks the outline code. For some reason you can not reset
|
|
|
|
// the clip rect to draw outside you bounds if you have a view. And you need to
|
|
|
|
// because the outline must be drawn outside of our bounds according to CSS. -EDV
|
1999-11-19 18:33:29 +03:00
|
|
|
|
|
|
|
// XXX If you do decide you need a view, then create it in the Init() function
|
|
|
|
// and not here...
|
1999-03-06 22:43:13 +03:00
|
|
|
#if 0
|
1998-11-14 02:13:42 +03:00
|
|
|
if (!mDidInit) {
|
|
|
|
// create our view, we need a view to grab the mouse
|
|
|
|
nsIView* view;
|
1999-02-10 08:38:18 +03:00
|
|
|
GetView(&view);
|
1998-11-14 02:13:42 +03:00
|
|
|
if (!view) {
|
2001-01-04 23:44:42 +03:00
|
|
|
nsresult result = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView), (void **)&view);
|
2003-02-22 22:48:29 +03:00
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
2003-02-22 22:48:29 +03:00
|
|
|
nsCOMPtr<nsIViewManager> viewMan;
|
1999-02-12 20:45:58 +03:00
|
|
|
presShell->GetViewManager(getter_AddRefs(viewMan));
|
1998-11-14 02:13:42 +03:00
|
|
|
|
|
|
|
nsIFrame* parWithView;
|
2003-02-22 22:48:29 +03:00
|
|
|
nsIView *parView;
|
1999-02-10 08:38:18 +03:00
|
|
|
GetParentWithView(&parWithView);
|
2003-02-22 22:48:29 +03:00
|
|
|
parWithView->GetView(&parView);
|
1998-11-14 02:13:42 +03:00
|
|
|
// the view's size is not know yet, but its size will be kept in synch with our frame.
|
|
|
|
nsRect boundBox(0, 0, 500, 500);
|
|
|
|
result = view->Init(viewMan, boundBox, parView, nsnull);
|
|
|
|
viewMan->InsertChild(parView, view, 0);
|
|
|
|
SetView(view);
|
|
|
|
|
|
|
|
const nsStyleColor* color = (const nsStyleColor*) mStyleContext->GetStyleData(eStyleStruct_Color);
|
|
|
|
// set the opacity
|
|
|
|
viewMan->SetViewOpacity(view, color->mOpacity);
|
|
|
|
|
|
|
|
}
|
|
|
|
mDidInit = PR_TRUE;
|
|
|
|
}
|
1999-03-06 22:43:13 +03:00
|
|
|
#endif
|
1998-11-14 02:13:42 +03: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-07-23 04:11:21 +04:00
|
|
|
nsSize availSize(aReflowState.mComputedWidth, NS_INTRINSICSIZE);
|
1999-02-23 06:48:01 +03:00
|
|
|
|
2003-02-22 22:48:29 +03:00
|
|
|
// Indent the child inside us by the the focus border. We must do this separate from the
|
1999-05-10 01:46:24 +04:00
|
|
|
// regular border.
|
|
|
|
nsMargin focusPadding = mRenderer.GetAddedButtonBorderAndPadding();
|
1999-02-23 06:48:01 +03:00
|
|
|
|
1999-07-23 04:11:21 +04:00
|
|
|
|
1999-02-23 06:48:01 +03:00
|
|
|
if (NS_INTRINSICSIZE != availSize.width) {
|
1999-05-10 01:46:24 +04:00
|
|
|
availSize.width -= focusPadding.left + focusPadding.right;
|
1999-02-23 06:48:01 +03:00
|
|
|
availSize.width = PR_MAX(availSize.width,0);
|
|
|
|
}
|
|
|
|
if (NS_AUTOHEIGHT != availSize.height) {
|
1999-05-10 01:46:24 +04:00
|
|
|
availSize.height -= focusPadding.top + focusPadding.bottom;
|
1999-02-23 06:48:01 +03:00
|
|
|
availSize.height = PR_MAX(availSize.height,0);
|
|
|
|
}
|
1999-07-23 04:11:21 +04:00
|
|
|
|
1999-01-23 02:10:02 +03:00
|
|
|
// XXX Proper handling of incremental reflow...
|
2002-05-10 22:22:41 +04:00
|
|
|
nsReflowReason reason = aReflowState.reason;
|
|
|
|
if (eReflowReason_Incremental == reason) {
|
1999-01-23 02:10:02 +03:00
|
|
|
// See if it's targeted at us
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowCommand *command = aReflowState.path->mReflowCommand;
|
|
|
|
if (command) {
|
1999-11-24 09:03:41 +03:00
|
|
|
Invalidate(aPresContext, nsRect(0,0,mRect.width,mRect.height), PR_FALSE);
|
1999-07-23 04:11:21 +04:00
|
|
|
|
2001-12-18 01:39:59 +03:00
|
|
|
nsReflowType reflowType;
|
2002-05-10 22:22:41 +04:00
|
|
|
command->GetType(reflowType);
|
2001-12-18 01:39:59 +03:00
|
|
|
if (eReflowType_StyleChanged == reflowType) {
|
2002-05-10 22:22:41 +04:00
|
|
|
reason = eReflowReason_StyleChange;
|
1999-09-29 07:35:51 +04:00
|
|
|
}
|
|
|
|
else {
|
2002-05-10 22:22:41 +04:00
|
|
|
reason = eReflowReason_Resize;
|
1999-09-29 07:35:51 +04:00
|
|
|
}
|
1999-01-23 02:10:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-22 22:48:29 +03:00
|
|
|
// Reflow the contents of the button a first time.
|
|
|
|
ReflowButtonContents(aPresContext, aDesiredSize, aReflowState, firstKid,
|
|
|
|
availSize, reason, focusPadding, aStatus);
|
2002-05-10 22:22:41 +04:00
|
|
|
|
2003-02-22 22:48:29 +03:00
|
|
|
// If we just performed the first pass of a shrink-wrap reflow (which will have
|
|
|
|
// found the requested size of the children, but not placed them), perform
|
|
|
|
// the second pass of a shrink-wrap reflow (which places the children
|
|
|
|
// within this parent button which has now shrink-wrapped around them).
|
|
|
|
if (availSize.width == NS_SHRINKWRAPWIDTH) {
|
|
|
|
nsSize newAvailSize(aDesiredSize.width, NS_INTRINSICSIZE);
|
2000-01-18 23:29:22 +03:00
|
|
|
|
2003-02-22 22:48:29 +03:00
|
|
|
ReflowButtonContents(aPresContext, aDesiredSize, aReflowState, firstKid,
|
|
|
|
newAvailSize, eReflowReason_Resize, focusPadding, aStatus);
|
2002-11-16 22:32:49 +03:00
|
|
|
}
|
1998-10-14 01:31:26 +04:00
|
|
|
|
2003-02-22 22:48:29 +03:00
|
|
|
// If computed use the computed values.
|
1999-11-03 03:05:30 +03:00
|
|
|
if (aReflowState.mComputedWidth != NS_INTRINSICSIZE)
|
|
|
|
aDesiredSize.width = aReflowState.mComputedWidth;
|
|
|
|
else
|
|
|
|
aDesiredSize.width += focusPadding.left + focusPadding.right;
|
|
|
|
|
|
|
|
if (aReflowState.mComputedHeight != NS_INTRINSICSIZE)
|
|
|
|
aDesiredSize.height = aReflowState.mComputedHeight;
|
|
|
|
else
|
|
|
|
aDesiredSize.height += focusPadding.top + focusPadding.bottom;
|
|
|
|
|
1999-08-31 17:05:31 +04:00
|
|
|
AddComputedBorderPaddingToDesiredSize(aDesiredSize, aReflowState);
|
2002-11-12 22:17:51 +03:00
|
|
|
|
1999-08-31 17:05:31 +04:00
|
|
|
//aDesiredSize.width += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
|
|
|
|
//aDesiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
|
1998-10-14 01:31:26 +04:00
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaxElementWidth = aDesiredSize.width;
|
2000-04-30 17:27:49 +04:00
|
|
|
}
|
1999-07-23 04:11:21 +04:00
|
|
|
|
2000-12-20 18:12:06 +03:00
|
|
|
// Make sure we obey min/max-width and min/max-height
|
|
|
|
if (aDesiredSize.width > aReflowState.mComputedMaxWidth) {
|
|
|
|
aDesiredSize.width = aReflowState.mComputedMaxWidth;
|
|
|
|
}
|
|
|
|
if (aDesiredSize.width < aReflowState.mComputedMinWidth) {
|
|
|
|
aDesiredSize.width = aReflowState.mComputedMinWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aDesiredSize.height > aReflowState.mComputedMaxHeight) {
|
|
|
|
aDesiredSize.height = aReflowState.mComputedMaxHeight;
|
|
|
|
}
|
|
|
|
if (aDesiredSize.height < aReflowState.mComputedMinHeight) {
|
|
|
|
aDesiredSize.height = aReflowState.mComputedMinHeight;
|
2002-11-12 22:17:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
aDesiredSize.ascent += aReflowState.mComputedBorderPadding.top + focusPadding.top;
|
|
|
|
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
|
|
|
|
|
1998-10-14 01:31:26 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2000-01-08 18:53:48 +03:00
|
|
|
|
2002-11-12 22:17:51 +03:00
|
|
|
nsFormControlFrame::SetupCachedSizes(mCacheSize, mCachedAscent,
|
2003-01-09 17:26:32 +03:00
|
|
|
mCachedMaxElementWidth, aDesiredSize);
|
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
|
|
|
|
nsHTMLButtonControlFrame::ReflowButtonContents(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsIFrame* aFirstKid,
|
|
|
|
const nsSize& aAvailSize,
|
|
|
|
nsReflowReason aReason,
|
|
|
|
nsMargin aFocusPadding,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
nsHTMLReflowState reflowState(aPresContext, aReflowState, aFirstKid, aAvailSize, aReason);
|
|
|
|
|
|
|
|
ReflowChild(aFirstKid, aPresContext, aDesiredSize, reflowState,
|
|
|
|
aFocusPadding.left + aReflowState.mComputedBorderPadding.left,
|
|
|
|
aFocusPadding.top + aReflowState.mComputedBorderPadding.top,
|
|
|
|
0, aStatus);
|
|
|
|
|
|
|
|
// calculate the min internal size so the contents gets centered correctly
|
|
|
|
// minInternalWidth is not being used at all and causes a warning--commenting
|
|
|
|
// out until someone wants it.
|
|
|
|
// nscoord minInternalWidth = aReflowState.mComputedMinWidth == 0?0:aReflowState.mComputedMinWidth -
|
|
|
|
// (aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right);
|
|
|
|
nscoord minInternalHeight = aReflowState.mComputedMinHeight == 0?0:aReflowState.mComputedMinHeight -
|
|
|
|
(aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom);
|
|
|
|
|
|
|
|
// 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. If we have a non-intrinsic width, we want to
|
|
|
|
// reduce the left padding as needed to try and fit the text in the
|
|
|
|
// button
|
|
|
|
nscoord xoffset = aFocusPadding.left + aReflowState.mComputedBorderPadding.left;
|
|
|
|
if (aReflowState.mComputedWidth != NS_INTRINSICSIZE) {
|
|
|
|
// First, how much did we "overflow"? This is the width of our
|
|
|
|
// kid plus our special focus stuff (which did not get accounted
|
|
|
|
// for in calculating aReflowState.mComputedWidth minus the width
|
|
|
|
// we're forced to be.
|
|
|
|
nscoord extrawidth =
|
|
|
|
aDesiredSize.width + aFocusPadding.left + aFocusPadding.right
|
|
|
|
- aReflowState.mComputedWidth;
|
|
|
|
if (extrawidth > 0) {
|
|
|
|
// Split it evenly between right and left
|
|
|
|
extrawidth /= 2;
|
|
|
|
// But do not shoot out the left side of the button, please
|
|
|
|
extrawidth = PR_MIN(extrawidth, aReflowState.mComputedPadding.left);
|
|
|
|
xoffset -= extrawidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Place the child
|
|
|
|
FinishReflowChild(aFirstKid, aPresContext, &reflowState, aDesiredSize,
|
|
|
|
xoffset,
|
|
|
|
yoff + aFocusPadding.top + aReflowState.mComputedBorderPadding.top, 0);
|
|
|
|
}
|
|
|
|
|
2002-11-19 06:39:44 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::IsPercentageBase(PRBool& aBase) const
|
|
|
|
{
|
|
|
|
aBase = PR_TRUE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-14 01:31:26 +04:00
|
|
|
PRIntn
|
|
|
|
nsHTMLButtonControlFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-01-22 18:32:57 +03:00
|
|
|
NS_IMETHODIMP
|
2000-02-09 22:34:39 +03:00
|
|
|
nsHTMLButtonControlFrame::GetFont(nsIPresContext* aPresContext,
|
|
|
|
const nsFont*& aFont)
|
1999-01-22 18:32:57 +03:00
|
|
|
{
|
2000-02-09 22:34:39 +03:00
|
|
|
return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont);
|
1999-01-22 18:32:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::GetFormContent(nsIContent*& aContent) const
|
|
|
|
{
|
1999-02-10 03:42:56 +03:00
|
|
|
nsIContent* content;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = GetContent(&content);
|
|
|
|
aContent = content;
|
|
|
|
return rv;
|
1999-01-22 18:32:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLButtonControlFrame::GetVerticalInsidePadding(nsIPresContext* aPresContext,
|
1999-09-30 15:30:04 +04:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerHeight) const
|
1999-01-22 18:32:57 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
1999-11-24 09:03:41 +03:00
|
|
|
nsHTMLButtonControlFrame::GetHorizontalInsidePadding(nsIPresContext* aPresContext,
|
1999-01-22 18:32:57 +03:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerWidth,
|
|
|
|
nscoord aCharWidth) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
nsresult nsHTMLButtonControlFrame::RequiresWidget(PRBool& aRequiresWidget)
|
|
|
|
{
|
|
|
|
aRequiresWidget = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-26 08:44:41 +04:00
|
|
|
NS_IMETHODIMP nsHTMLButtonControlFrame::SetProperty(nsIPresContext* aPresContext,
|
2002-03-24 01:26:36 +03:00
|
|
|
nsIAtom* aName, const nsAString& aValue)
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
2001-02-06 04:31:18 +03:00
|
|
|
if (nsHTMLAtoms::value == aName) {
|
|
|
|
nsCOMPtr<nsIHTMLContent> formControl(do_QueryInterface(mContent));
|
|
|
|
if (formControl) {
|
2001-08-17 12:14:14 +04:00
|
|
|
return formControl->SetAttr(kNameSpaceID_None, nsHTMLAtoms::value, aValue, PR_TRUE);
|
2001-02-06 04:31:18 +03:00
|
|
|
}
|
|
|
|
}
|
1999-01-26 01:16:27 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-03-24 01:26:36 +03:00
|
|
|
NS_IMETHODIMP nsHTMLButtonControlFrame::GetProperty(nsIAtom* aName, nsAString& aValue)
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
2001-02-06 04:31:18 +03:00
|
|
|
if (nsHTMLAtoms::value == aName) {
|
|
|
|
nsCOMPtr<nsIHTMLContent> formControl(do_QueryInterface(mContent));
|
|
|
|
if (formControl) {
|
2001-08-17 12:14:14 +04:00
|
|
|
formControl->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, aValue);
|
2001-02-06 04:31:18 +03:00
|
|
|
}
|
|
|
|
}
|
1999-01-26 01:16:27 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext*
|
|
|
|
nsHTMLButtonControlFrame::GetAdditionalStyleContext(PRInt32 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
|
1999-09-04 03:36:32 +04:00
|
|
|
nsHTMLButtonControlFrame::SetAdditionalStyleContext(PRInt32 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
|
|
|
}
|
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
NS_IMETHODIMP nsHTMLButtonControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
|
|
|
|
{
|
|
|
|
// mSuggestedWidth = aWidth;
|
|
|
|
// mSuggestedHeight = aHeight;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
|
1999-01-26 01:16:27 +03:00
|
|
|
|
2000-08-03 02:16:12 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::AppendFrames(nsIPresContext* aPresContext,
|
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
return mFrames.FirstChild()->AppendFrames(aPresContext,
|
|
|
|
aPresShell,
|
|
|
|
aListName,
|
|
|
|
aFrameList);
|
|
|
|
}
|
1998-10-14 01:31:26 +04:00
|
|
|
|
2001-11-02 10:40:01 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonControlFrame::OnContentReset()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|