2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-08-06 09:13:07 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04: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/
|
1999-08-06 09:13:07 +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.
|
1999-08-06 09:13:07 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* 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
|
2004-04-18 18:30:37 +04: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-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-08-06 09:13:07 +04:00
|
|
|
|
|
|
|
#include "nsGfxButtonControlFrame.h"
|
|
|
|
#include "nsIButton.h"
|
1999-08-10 23:13:57 +04:00
|
|
|
#include "nsWidgetsCID.h"
|
1999-11-23 01:04:53 +03:00
|
|
|
#include "nsIFontMetrics.h"
|
2000-01-09 05:07:00 +03:00
|
|
|
#include "nsFormControlFrame.h"
|
2000-02-21 08:55:25 +03:00
|
|
|
#include "nsISupportsArray.h"
|
2000-12-30 22:22:22 +03:00
|
|
|
#include "nsINameSpaceManager.h"
|
2001-02-20 00:50:04 +03:00
|
|
|
#include "nsContentCID.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-04-01 05:01:33 +04:00
|
|
|
#include "nsIAccessibilityService.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-04-01 05:01:33 +04:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
2001-06-30 04:25:09 +04:00
|
|
|
#include "nsLayoutAtoms.h"
|
2002-06-04 04:44:04 +04:00
|
|
|
#include "nsReflowPath.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsAutoPtr.h"
|
2004-01-28 03:18:22 +03:00
|
|
|
#include "nsStyleSet.h"
|
2002-05-23 15:25:58 +04:00
|
|
|
// MouseEvent suppression in PP
|
|
|
|
#include "nsGUIEvent.h"
|
2001-04-01 05:01:33 +04:00
|
|
|
|
2001-02-20 00:50:04 +03:00
|
|
|
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
1999-08-06 09:13:07 +04:00
|
|
|
|
2001-02-06 04:31:18 +03:00
|
|
|
// Saving PresState
|
|
|
|
#include "nsIPresState.h"
|
|
|
|
|
1999-08-10 23:13:57 +04:00
|
|
|
const nscoord kSuggestedNotSet = -1;
|
|
|
|
|
|
|
|
nsGfxButtonControlFrame::nsGfxButtonControlFrame()
|
|
|
|
{
|
|
|
|
mSuggestedWidth = kSuggestedNotSet;
|
|
|
|
mSuggestedHeight = kSuggestedNotSet;
|
|
|
|
}
|
|
|
|
|
1999-08-06 09:13:07 +04:00
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewGfxButtonControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1999-08-06 09:13:07 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsGfxButtonControlFrame* it = new (aPresShell) nsGfxButtonControlFrame;
|
1999-08-06 09:13:07 +04:00
|
|
|
if (!it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
*aNewFrame = it;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-14 00:40:59 +04:00
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsGfxButtonControlFrame::GetType() const
|
2001-06-30 04:25:09 +04:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::gfxButtonControlFrame;
|
2001-06-30 04:25:09 +04:00
|
|
|
}
|
1999-08-10 23:13:57 +04:00
|
|
|
|
2000-02-21 08:55:25 +03:00
|
|
|
// Special check for the browse button of a file input.
|
|
|
|
//
|
|
|
|
// Since this is actually type "NS_FORM_INPUT_BUTTON", we
|
|
|
|
// can't tell if it is part of a file input by the type.
|
|
|
|
// We'll return PR_TRUE if either:
|
|
|
|
// (a) type is NS_FORM_BROWSE or
|
|
|
|
// (b) type is NS_FORM_INPUT_BUTTON and our parent is a file input
|
|
|
|
PRBool
|
2002-09-16 10:23:52 +04:00
|
|
|
nsGfxButtonControlFrame::IsFileBrowseButton(PRInt32 type)
|
2000-02-21 08:55:25 +03:00
|
|
|
{
|
2000-02-23 23:56:39 +03:00
|
|
|
PRBool rv = PR_FALSE;
|
2000-02-21 08:55:25 +03:00
|
|
|
if (NS_FORM_BROWSE == type) {
|
2000-02-23 23:56:39 +03:00
|
|
|
rv = PR_TRUE;
|
2000-02-21 08:55:25 +03:00
|
|
|
}
|
2000-02-23 23:56:39 +03:00
|
|
|
else if (NS_FORM_INPUT_BUTTON == type) {
|
2000-02-21 08:55:25 +03:00
|
|
|
// Check to see if parent is a file input
|
2003-11-19 04:20:56 +03:00
|
|
|
nsCOMPtr<nsIFormControl> formCtrl =
|
|
|
|
do_QueryInterface(mContent->GetParent());
|
2000-02-23 23:56:39 +03:00
|
|
|
|
2003-11-19 04:20:56 +03:00
|
|
|
if (formCtrl && formCtrl->GetType() == NS_FORM_INPUT_FILE) {
|
|
|
|
rv = PR_TRUE;
|
2000-02-21 08:55:25 +03:00
|
|
|
}
|
|
|
|
}
|
2000-02-23 23:56:39 +03:00
|
|
|
return rv;
|
2000-02-21 08:55:25 +03:00
|
|
|
}
|
|
|
|
|
2000-02-03 01:24:56 +03:00
|
|
|
/*
|
|
|
|
* FIXME: this ::GetIID() method has no meaning in life and should be
|
|
|
|
* removed.
|
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
|
|
|
*/
|
1999-08-10 23:13:57 +04:00
|
|
|
const nsIID&
|
|
|
|
nsGfxButtonControlFrame::GetIID()
|
1999-08-06 09:13:07 +04:00
|
|
|
{
|
2001-01-04 23:44:42 +03:00
|
|
|
return NS_GET_IID(nsIButton);
|
1999-08-10 23:13:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
const nsIID&
|
|
|
|
nsGfxButtonControlFrame::GetCID()
|
|
|
|
{
|
|
|
|
static NS_DEFINE_IID(kButtonCID, NS_BUTTON_CID);
|
|
|
|
return kButtonCID;
|
1999-08-06 09:13:07 +04:00
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1999-08-06 09:13:07 +04:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsGfxButtonControlFrame::GetFrameName(nsAString& aResult) const
|
1999-08-06 09:13:07 +04:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("ButtonControl"), aResult);
|
1999-08-10 23:13:57 +04:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-08-06 09:13:07 +04:00
|
|
|
|
1999-08-31 17:03:38 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::AddComputedBorderPaddingToDesiredSize(nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aSuggestedReflowState)
|
|
|
|
{
|
|
|
|
if (kSuggestedNotSet == mSuggestedWidth) {
|
|
|
|
aDesiredSize.width += aSuggestedReflowState.mComputedBorderPadding.left + aSuggestedReflowState.mComputedBorderPadding.right;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kSuggestedNotSet == mSuggestedHeight) {
|
|
|
|
aDesiredSize.height += aSuggestedReflowState.mComputedBorderPadding.top + aSuggestedReflowState.mComputedBorderPadding.bottom;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-02-21 08:55:25 +03:00
|
|
|
// Create the text content used as label for the button.
|
|
|
|
// The frame will be generated by the frame constructor.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
|
|
|
|
nsISupportsArray& aChildList)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
|
|
|
|
// Get the text from the "value" attribute.
|
|
|
|
// If it is zero length, set it to a default value (localized)
|
|
|
|
nsAutoString initvalue, value;
|
2002-09-11 06:30:52 +04:00
|
|
|
result = GetValue(&initvalue);
|
2000-02-21 08:55:25 +03:00
|
|
|
value = initvalue;
|
2002-09-11 06:30:52 +04:00
|
|
|
if (result != NS_CONTENT_ATTR_HAS_VALUE && value.IsEmpty()) {
|
2000-02-21 08:55:25 +03:00
|
|
|
// Generate localized label.
|
|
|
|
// We can't make any assumption as to what the default would be
|
|
|
|
// because the value is localized for non-english platforms, thus
|
|
|
|
// it might not be the string "Reset", "Submit Query", or "Browse..."
|
|
|
|
result = GetDefaultLabel(value);
|
|
|
|
if (NS_FAILED(result)) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compress whitespace out of label if needed.
|
2003-05-15 07:42:21 +04:00
|
|
|
if (!GetStyleText()->WhiteSpaceIsSignificant()) {
|
2000-02-21 08:55:25 +03:00
|
|
|
value.CompressWhitespace();
|
2002-11-16 22:32:49 +03:00
|
|
|
} else if (value.Length() > 2 && value[0] == ' ' &&
|
|
|
|
value[value.Length() - 1] == ' '){
|
|
|
|
// This is a bit of a hack. The reason this is here is as follows: we now
|
|
|
|
// have default padding on our buttons to make them non-ugly.
|
|
|
|
// Unfortunately, IE-windows does not have such padding, so people will
|
|
|
|
// stick values like " ok " (with the spaces) in the buttons in an attempt
|
|
|
|
// to make them look decent. Unfortunately, if they do this the button
|
|
|
|
// looks way too big in Mozilla. Worse yet, if they do this _and_ set a
|
|
|
|
// fixed width for the button we run into trouble because our focus-rect
|
|
|
|
// border/padding and outer border take up 10px of the horizontal button
|
|
|
|
// space or so; the result is that the text is misaligned, even with the
|
|
|
|
// recentering we do in nsHTMLButtonFrame::Reflow. So to solve this, even
|
|
|
|
// if the whitespace is significant, single leading and trailing _spaces_
|
|
|
|
// (and not other whitespace) are removed. The proper solution, of
|
|
|
|
// course, is to not have the focus rect painting taking up 6px of
|
|
|
|
// horizontal space. We should do that instead (via XBL form controls or
|
|
|
|
// changing the renderer) and remove this.
|
|
|
|
value.Cut(0, 1);
|
|
|
|
value.Truncate(value.Length() - 1);
|
2002-09-11 06:30:52 +04:00
|
|
|
}
|
|
|
|
|
2000-02-21 08:55:25 +03:00
|
|
|
// Add a child text content node for the label
|
2001-02-20 00:50:04 +03:00
|
|
|
nsCOMPtr<nsIContent> labelContent(do_CreateInstance(kTextNodeCID,&result));
|
2000-02-21 08:55:25 +03:00
|
|
|
if (NS_SUCCEEDED(result) && labelContent) {
|
2000-02-23 23:56:39 +03:00
|
|
|
// set the value of the text node and add it to the child list
|
|
|
|
mTextContent = do_QueryInterface(labelContent, &result);
|
|
|
|
if (NS_SUCCEEDED(result) && mTextContent) {
|
2004-05-08 00:55:17 +04:00
|
|
|
mTextContent->SetText(value, PR_TRUE);
|
2000-02-23 23:56:39 +03:00
|
|
|
aChildList.AppendElement(mTextContent);
|
|
|
|
}
|
2000-02-21 08:55:25 +03:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-08-23 14:38:42 +04:00
|
|
|
// Create the text content used as label for the button.
|
|
|
|
// The frame will be generated by the frame constructor.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::CreateFrameFor(nsIPresContext* aPresContext,
|
|
|
|
nsIContent * aContent,
|
|
|
|
nsIFrame** aFrame)
|
|
|
|
{
|
|
|
|
nsIFrame * newFrame = nsnull;
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
if (aFrame)
|
|
|
|
*aFrame = nsnull;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content(do_QueryInterface(mTextContent));
|
|
|
|
if (aContent == content.get()) {
|
|
|
|
nsIFrame * parentFrame = mFrames.FirstChild();
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* styleContext = parentFrame->GetStyleContext();
|
2000-08-23 14:38:42 +04:00
|
|
|
|
2003-12-21 08:36:36 +03:00
|
|
|
rv = NS_NewTextFrame(aPresContext->PresShell(), &newFrame);
|
2000-08-23 14:38:42 +04:00
|
|
|
if (NS_FAILED(rv)) { return rv; }
|
|
|
|
if (!newFrame) { return NS_ERROR_NULL_POINTER; }
|
2003-02-22 03:32:13 +03:00
|
|
|
nsRefPtr<nsStyleContext> textStyleContext;
|
2004-01-28 03:18:22 +03:00
|
|
|
textStyleContext = aPresContext->StyleSet()->
|
|
|
|
ResolveStyleForNonElement(styleContext);
|
2000-08-23 14:38:42 +04:00
|
|
|
if (!textStyleContext) { return NS_ERROR_NULL_POINTER; }
|
|
|
|
|
|
|
|
if (styleContext) {
|
|
|
|
// initialize the text frame
|
|
|
|
newFrame->Init(aPresContext, content, parentFrame, textStyleContext, nsnull);
|
|
|
|
newFrame->SetInitialChildList(aPresContext, nsnull, nsnull);
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aFrame) {
|
|
|
|
*aFrame = newFrame;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-18 03:52:32 +04:00
|
|
|
NS_IMETHODIMP nsGfxButtonControlFrame::GetAccessible(nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
|
|
|
|
if (accService) {
|
|
|
|
return accService->CreateHTMLButtonAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-05-18 03:52:32 +04:00
|
|
|
|
2000-02-21 08:55:25 +03:00
|
|
|
// Frames are not refcounted, no need to AddRef
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
2001-02-06 04:31:18 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
|
|
|
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) {
|
|
|
|
*aInstancePtr = NS_STATIC_CAST(nsIAnonymousContentCreator*, this);
|
2001-05-18 03:52:32 +04:00
|
|
|
}
|
2001-04-01 05:01:33 +04:00
|
|
|
else {
|
2001-02-06 04:31:18 +03:00
|
|
|
return nsHTMLButtonControlFrame::QueryInterface(aIID, aInstancePtr);
|
2000-02-21 08:55:25 +03:00
|
|
|
}
|
2001-02-06 04:31:18 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
2000-02-21 08:55:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Initially we hardcoded the default strings here.
|
|
|
|
// Next, we used html.css to store the default label for various types
|
|
|
|
// of buttons. (nsGfxButtonControlFrame::DoNavQuirksReflow rev 1.20)
|
|
|
|
// However, since html.css is not internationalized, we now grab the default
|
|
|
|
// label from a string bundle as is done for all other UI strings.
|
|
|
|
// See bug 16999 for further details.
|
2002-09-16 10:23:52 +04:00
|
|
|
nsresult
|
2000-02-21 08:55:25 +03:00
|
|
|
nsGfxButtonControlFrame::GetDefaultLabel(nsString& aString)
|
|
|
|
{
|
2001-01-27 17:09:34 +03:00
|
|
|
const char * propname = nsFormControlHelper::GetHTMLPropertiesFileName();
|
2000-02-21 08:55:25 +03:00
|
|
|
nsresult rv = NS_OK;
|
2003-10-31 23:19:18 +03:00
|
|
|
PRInt32 type = GetFormControlType();
|
2002-09-16 10:23:52 +04:00
|
|
|
if (type == NS_FORM_INPUT_RESET) {
|
2001-09-26 04:36:45 +04:00
|
|
|
rv = nsFormControlHelper::GetLocalizedString(propname, NS_LITERAL_STRING("Reset").get(), aString);
|
2000-02-21 08:55:25 +03:00
|
|
|
}
|
2002-09-16 10:23:52 +04:00
|
|
|
else if (type == NS_FORM_INPUT_SUBMIT) {
|
2001-09-26 04:36:45 +04:00
|
|
|
rv = nsFormControlHelper::GetLocalizedString(propname, NS_LITERAL_STRING("Submit").get(), aString);
|
2000-02-21 08:55:25 +03:00
|
|
|
}
|
2002-09-16 10:23:52 +04:00
|
|
|
else if (IsFileBrowseButton(type)) {
|
2001-09-26 04:36:45 +04:00
|
|
|
rv = nsFormControlHelper::GetLocalizedString(propname, NS_LITERAL_STRING("Browse").get(), aString);
|
2000-02-21 08:55:25 +03:00
|
|
|
}
|
|
|
|
else {
|
2004-01-30 01:04:45 +03:00
|
|
|
aString.Truncate();
|
2000-02-21 08:55:25 +03:00
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
|
|
|
PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aAttribute,
|
2003-07-12 01:16:12 +04:00
|
|
|
PRInt32 aModType)
|
2000-02-21 08:55:25 +03:00
|
|
|
{
|
2000-02-23 23:56:39 +03:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2000-02-21 08:55:25 +03:00
|
|
|
// If the value attribute is set, update the text of the label
|
|
|
|
if (nsHTMLAtoms::value == aAttribute) {
|
2000-02-23 23:56:39 +03:00
|
|
|
nsAutoString value;
|
|
|
|
if (mTextContent && mContent) {
|
2001-08-17 12:14:14 +04:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE != mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::value, value)) {
|
2002-09-11 06:30:52 +04:00
|
|
|
value.Truncate();
|
2000-02-23 23:56:39 +03:00
|
|
|
}
|
2004-05-08 00:55:17 +04:00
|
|
|
mTextContent->SetText(value, PR_TRUE);
|
2000-02-23 23:56:39 +03:00
|
|
|
} else {
|
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
2000-02-21 08:55:25 +03:00
|
|
|
}
|
|
|
|
|
2000-02-23 23:56:39 +03:00
|
|
|
// defer to HTMLButtonControlFrame
|
|
|
|
} else {
|
2003-07-12 01:16:12 +04:00
|
|
|
rv = nsHTMLButtonControlFrame::AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aModType);
|
2000-02-23 23:56:39 +03:00
|
|
|
}
|
|
|
|
return rv;
|
2000-02-21 08:55:25 +03:00
|
|
|
}
|
|
|
|
|
1999-08-10 23:13:57 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsGfxButtonControlFrame::Reflow(nsIPresContext* aPresContext,
|
1999-10-08 01:07:38 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-08-06 09:13:07 +04:00
|
|
|
{
|
2000-04-22 01:51:35 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsGfxButtonControlFrame", 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
|
|
|
|
1999-08-10 23:13:57 +04:00
|
|
|
if ((kSuggestedNotSet != mSuggestedWidth) ||
|
1999-08-31 17:03:38 +04:00
|
|
|
(kSuggestedNotSet != mSuggestedHeight)) {
|
1999-08-10 23:13:57 +04:00
|
|
|
nsHTMLReflowState suggestedReflowState(aReflowState);
|
1999-08-31 17:03:38 +04:00
|
|
|
|
1999-08-10 23:13:57 +04:00
|
|
|
// Honor the suggested width and/or height.
|
|
|
|
if (kSuggestedNotSet != mSuggestedWidth) {
|
|
|
|
suggestedReflowState.mComputedWidth = mSuggestedWidth;
|
|
|
|
}
|
1999-08-06 09:13:07 +04:00
|
|
|
|
1999-08-10 23:13:57 +04:00
|
|
|
if (kSuggestedNotSet != mSuggestedHeight) {
|
|
|
|
suggestedReflowState.mComputedHeight = mSuggestedHeight;
|
1999-08-06 09:13:07 +04:00
|
|
|
}
|
|
|
|
|
2002-11-12 22:17:51 +03:00
|
|
|
return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, suggestedReflowState, aStatus);
|
1999-11-23 01:04:53 +03:00
|
|
|
|
1999-08-06 09:13:07 +04:00
|
|
|
}
|
2002-11-12 22:17:51 +03:00
|
|
|
|
|
|
|
// Normal reflow.
|
1999-10-08 01:07:38 +04:00
|
|
|
|
2002-11-12 22:17:51 +03:00
|
|
|
return nsHTMLButtonControlFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2002-09-16 10:23:52 +04:00
|
|
|
}
|
|
|
|
|
1999-08-10 23:13:57 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsGfxButtonControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
|
1999-08-06 09:13:07 +04:00
|
|
|
{
|
1999-08-10 23:13:57 +04:00
|
|
|
mSuggestedWidth = aWidth;
|
|
|
|
mSuggestedHeight = aHeight;
|
2000-03-07 18:54:31 +03:00
|
|
|
//mState |= NS_FRAME_IS_DIRTY;
|
1999-08-10 23:13:57 +04:00
|
|
|
return NS_OK;
|
1999-08-06 09:13:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsGfxButtonControlFrame::HandleEvent(nsIPresContext* aPresContext,
|
1999-08-10 23:13:57 +04:00
|
|
|
nsGUIEvent* aEvent,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsEventStatus* aEventStatus)
|
1999-08-06 09:13:07 +04:00
|
|
|
{
|
2002-05-23 15:25:58 +04:00
|
|
|
// temp fix until Bug 124990 gets fixed
|
2004-03-03 21:24:20 +03:00
|
|
|
if (aPresContext->IsPaginated() && NS_IS_MOUSE_EVENT(aEvent)) {
|
2002-05-23 15:25:58 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-10 23:13:57 +04:00
|
|
|
// Override the HandleEvent to prevent the nsFrame::HandleEvent
|
|
|
|
// from being called. The nsFrame::HandleEvent causes the button label
|
|
|
|
// to be selected (Drawn with an XOR rectangle over the label)
|
|
|
|
|
2000-05-31 06:24:48 +04:00
|
|
|
// Do nothing here, nsHTMLInputElement::HandleDOMEvent
|
|
|
|
// takes cares of calling MouseClicked for us.
|
1999-08-10 23:13:57 +04:00
|
|
|
|
2000-08-09 03:38:00 +04:00
|
|
|
// do we have user-input style?
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleUserInterface* uiStyle = GetStyleUserInterface();
|
2000-08-09 03:38:00 +04:00
|
|
|
if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || uiStyle->mUserInput == NS_STYLE_USER_INPUT_DISABLED)
|
|
|
|
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
|
|
|
|
1999-08-10 23:13:57 +04:00
|
|
|
return NS_OK;
|
1999-08-06 09:13:07 +04:00
|
|
|
}
|