1999-10-09 00:41:19 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03: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/
|
1999-10-09 00:41:19 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03: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-10-09 00:41:19 +04:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
1999-11-06 06:40:37 +03:00
|
|
|
* Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-10-09 00:41:19 +04:00
|
|
|
*/
|
1999-02-20 09:05:15 +03:00
|
|
|
#include "nsButtonFrameRenderer.h"
|
1999-02-19 21:23:02 +03:00
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
1999-02-26 09:41:10 +03:00
|
|
|
#include "nsIPresContext.h"
|
1999-02-19 21:23:02 +03:00
|
|
|
#include "nsGenericHTMLElement.h"
|
1999-03-06 22:43:13 +03:00
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
1999-03-13 02:47:52 +03:00
|
|
|
#include "nsHTMLAtoms.h"
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
#define ACTIVE "active"
|
|
|
|
#define HOVER "hover"
|
|
|
|
#define FOCUS "focus"
|
1999-02-26 11:48:24 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_DECL_CTOR_COUNTER(nsButtonFrameRenderer);
|
|
|
|
|
1999-02-19 21:23:02 +03:00
|
|
|
nsButtonFrameRenderer::nsButtonFrameRenderer()
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_CTOR(nsButtonFrameRenderer);
|
|
|
|
mNameSpace = kNameSpaceID_HTML;
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
nsButtonFrameRenderer::~nsButtonFrameRenderer()
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
MOZ_COUNT_DTOR(nsButtonFrameRenderer);
|
1999-02-26 09:41:10 +03:00
|
|
|
}
|
|
|
|
|
1999-02-19 21:23:02 +03:00
|
|
|
void
|
1999-02-26 09:41:10 +03:00
|
|
|
nsButtonFrameRenderer::SetNameSpace(PRInt32 aNameSpace)
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
mNameSpace = aNameSpace;
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
void
|
1999-11-24 09:03:41 +03:00
|
|
|
nsButtonFrameRenderer::SetFrame(nsFrame* aFrame, nsIPresContext* aPresContext)
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
mFrame = aFrame;
|
|
|
|
ReResolveStyles(aPresContext);
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
1999-09-15 02:17:19 +04:00
|
|
|
nsIFrame*
|
|
|
|
nsButtonFrameRenderer::GetFrame()
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
return mFrame;
|
1999-09-15 02:17:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32
|
|
|
|
nsButtonFrameRenderer::GetNameSpace()
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
return mNameSpace;
|
1999-09-15 02:17:19 +04:00
|
|
|
}
|
|
|
|
|
1999-02-26 11:48:24 +03:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::SetDisabled(PRBool aDisabled, PRBool notify)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
// get the content
|
1999-03-13 02:47:52 +03:00
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
mFrame->GetContent(getter_AddRefs(content));
|
|
|
|
|
|
|
|
if (aDisabled)
|
2000-04-16 15:19:26 +04:00
|
|
|
content->SetAttribute(mNameSpace, nsHTMLAtoms::disabled, nsAutoString(), notify);
|
1999-03-13 02:47:52 +03:00
|
|
|
else
|
1999-10-09 00:41:19 +04:00
|
|
|
content->UnsetAttribute(mNameSpace, nsHTMLAtoms::disabled, notify);
|
1999-03-13 02:47:52 +03:00
|
|
|
|
1999-02-26 11:48:24 +03:00
|
|
|
}
|
1999-02-26 09:41:10 +03:00
|
|
|
|
1999-02-26 11:48:24 +03:00
|
|
|
PRBool
|
|
|
|
nsButtonFrameRenderer::isDisabled()
|
|
|
|
{
|
1999-03-13 02:47:52 +03:00
|
|
|
// get the content
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
mFrame->GetContent(getter_AddRefs(content));
|
1999-09-03 07:47:06 +04:00
|
|
|
nsAutoString value;
|
1999-03-13 02:47:52 +03:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(mNameSpace, nsHTMLAtoms::disabled, value))
|
|
|
|
return PR_TRUE;
|
|
|
|
|
|
|
|
return PR_FALSE;
|
1999-02-26 11:48:24 +03:00
|
|
|
}
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
void
|
1999-10-26 08:44:41 +04:00
|
|
|
nsButtonFrameRenderer::Redraw(nsIPresContext* aPresContext)
|
1999-05-13 05:35:16 +04:00
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
mFrame->GetRect(rect);
|
|
|
|
rect.x = 0;
|
|
|
|
rect.y = 0;
|
1999-10-26 08:44:41 +04:00
|
|
|
mFrame->Invalidate(aPresContext, rect, PR_FALSE);
|
1999-02-26 09:41:10 +03:00
|
|
|
}
|
|
|
|
|
1999-02-19 21:23:02 +03:00
|
|
|
void
|
1999-11-24 09:03:41 +03:00
|
|
|
nsButtonFrameRenderer::PaintButton (nsIPresContext* aPresContext,
|
1999-10-09 00:41:19 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
const nsRect& aRect)
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
1999-03-02 08:00:51 +03:00
|
|
|
//printf("painted width='%d' height='%d'\n",aRect.width, aRect.height);
|
1999-03-02 04:25:33 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
// draw the border and background inside the focus and outline borders
|
|
|
|
PaintBorderAndBackground(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aRect);
|
1999-02-26 09:41:10 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
// draw the focus and outline borders
|
1999-05-13 05:35:16 +04:00
|
|
|
PaintOutlineAndFocusBorders(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aRect);
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
void
|
1999-11-24 09:03:41 +03:00
|
|
|
nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext,
|
1999-10-09 00:41:19 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
const nsRect& aRect)
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
// once we have all that let draw the focus if we have it. We will need to draw 2 focuses.
|
|
|
|
// the inner and the outer. This is so we can do any kind of look and feel some buttons have
|
|
|
|
// focus on the outside like mac and motif. While others like windows have it inside (dotted line).
|
|
|
|
// Usually only one will be specifed. But I guess you could have both if you wanted to.
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
nsRect rect;
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-03-27 03:58:29 +03:00
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer)
|
1999-10-09 00:41:19 +04:00
|
|
|
{
|
|
|
|
if (mOuterFocusStyle) {
|
|
|
|
// ---------- paint the outer focus border -------------
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
GetButtonOuterFocusRect(aRect, rect);
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Spacing);
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
|
|
|
aDirtyRect, rect, *spacing, mOuterFocusStyle, 0);
|
|
|
|
}
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
// ---------- paint the inner focus border -------------
|
|
|
|
if (mInnerFocusStyle) {
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
GetButtonInnerFocusRect(aRect, rect);
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
|
|
|
aDirtyRect, rect, *spacing, mInnerFocusStyle, 0);
|
|
|
|
}
|
|
|
|
}
|
1999-02-19 21:23:02 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
void
|
1999-11-24 09:03:41 +03:00
|
|
|
nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext* aPresContext,
|
1999-10-09 00:41:19 +04:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
const nsRect& aRect)
|
1999-02-26 09:41:10 +03:00
|
|
|
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND != aWhichLayer)
|
|
|
|
return;
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
// get the button rect this is inside the focus and outline rects
|
|
|
|
nsRect buttonRect;
|
|
|
|
GetButtonRect(aRect, buttonRect);
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
nsCOMPtr<nsIStyleContext> context;
|
|
|
|
mFrame->GetStyleContext(getter_AddRefs(context));
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
// get the styles
|
|
|
|
const nsStyleSpacing* spacing =
|
1999-02-19 21:23:02 +03:00
|
|
|
(const nsStyleSpacing*)context->GetStyleData(eStyleStruct_Spacing);
|
1999-10-09 00:41:19 +04:00
|
|
|
const nsStyleColor* color =
|
1999-02-19 21:23:02 +03:00
|
|
|
(const nsStyleColor*)context->GetStyleData(eStyleStruct_Color);
|
|
|
|
|
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
// paint the border and background
|
1999-03-06 22:43:13 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
|
|
|
|
aDirtyRect, buttonRect, *color, *spacing, 0, 0);
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
|
|
|
aDirtyRect, buttonRect, *spacing, context, 0);
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
}
|
1999-02-19 21:23:02 +03:00
|
|
|
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonOutlineRect(const nsRect& aRect, nsRect& outlineRect)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
outlineRect = aRect;
|
|
|
|
outlineRect.Inflate(GetButtonOutlineBorderAndPadding());
|
1999-02-26 09:41:10 +03:00
|
|
|
}
|
1999-02-19 21:23:02 +03:00
|
|
|
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonOuterFocusRect(const nsRect& aRect, nsRect& focusRect)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
focusRect = aRect;
|
1999-02-26 09:41:10 +03:00
|
|
|
}
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonRect(const nsRect& aRect, nsRect& r)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
r = aRect;
|
|
|
|
r.Deflate(GetButtonOuterFocusBorderAndPadding());
|
1999-02-26 09:41:10 +03:00
|
|
|
}
|
1999-02-19 21:23:02 +03:00
|
|
|
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& focusRect)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
GetButtonRect(aRect, focusRect);
|
|
|
|
focusRect.Deflate(GetButtonBorderAndPadding());
|
|
|
|
focusRect.Deflate(GetButtonInnerFocusMargin());
|
1999-02-26 09:41:10 +03:00
|
|
|
}
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonContentRect(const nsRect& aRect, nsRect& r)
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
GetButtonInnerFocusRect(aRect, r);
|
|
|
|
r.Deflate(GetButtonInnerFocusBorderAndPadding());
|
1999-02-26 09:41:10 +03:00
|
|
|
}
|
1999-02-19 21:23:02 +03:00
|
|
|
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonOuterFocusBorderAndPadding()
|
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
nsMargin focusBorderAndPadding(0,0,0,0);
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
if (mOuterFocusStyle) {
|
|
|
|
// get the outer focus border and padding
|
|
|
|
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
if (!spacing->GetBorderPadding(focusBorderAndPadding)) {
|
1999-07-28 08:48:34 +04:00
|
|
|
NS_NOTYETIMPLEMENTED("percentage border");
|
|
|
|
}
|
1999-10-09 00:41:19 +04:00
|
|
|
}
|
1999-02-26 09:41:10 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
return focusBorderAndPadding;
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonBorderAndPadding()
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
nsCOMPtr<nsIStyleContext> context;
|
|
|
|
mFrame->GetStyleContext(getter_AddRefs(context));
|
|
|
|
|
|
|
|
nsMargin borderAndPadding(0,0,0,0);
|
|
|
|
const nsStyleSpacing* spacing = (const nsStyleSpacing*)context ->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
if (!spacing->GetBorderPadding(borderAndPadding)) {
|
|
|
|
NS_NOTYETIMPLEMENTED("percentage border");
|
|
|
|
}
|
|
|
|
return borderAndPadding;
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
/**
|
|
|
|
* Gets the size of the buttons border this is the union of the normal and disabled borders.
|
|
|
|
*/
|
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonInnerFocusMargin()
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
nsMargin innerFocusMargin(0,0,0,0);
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
// get the outer focus border and padding
|
|
|
|
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
spacing->GetMargin(innerFocusMargin);
|
|
|
|
}
|
1999-02-26 09:41:10 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
return innerFocusMargin;
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonInnerFocusBorderAndPadding()
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
nsMargin innerFocusBorderAndPadding(0,0,0,0);
|
1999-02-19 21:23:02 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
// get the outer focus border and padding
|
|
|
|
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
|
|
|
|
if (!spacing->GetBorderPadding(innerFocusBorderAndPadding)) {
|
1999-07-28 08:48:34 +04:00
|
|
|
NS_NOTYETIMPLEMENTED("percentage border");
|
|
|
|
}
|
1999-10-09 00:41:19 +04:00
|
|
|
}
|
1999-02-26 09:41:10 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
return innerFocusBorderAndPadding;
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
1999-02-26 09:41:10 +03:00
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonOutlineBorderAndPadding()
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
1999-10-09 00:41:19 +04:00
|
|
|
nsMargin borderAndPadding(0,0,0,0);
|
|
|
|
return borderAndPadding;
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
|
|
|
|
1999-03-27 03:58:29 +03:00
|
|
|
// gets the full size of our border with all the focus borders
|
1999-03-06 22:43:13 +03:00
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetFullButtonBorderAndPadding()
|
|
|
|
{
|
1999-03-27 03:58:29 +03:00
|
|
|
return GetAddedButtonBorderAndPadding() + GetButtonBorderAndPadding();
|
|
|
|
}
|
|
|
|
|
|
|
|
// gets all the focus borders and padding that will be added to the regular border
|
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetAddedButtonBorderAndPadding()
|
|
|
|
{
|
|
|
|
return GetButtonOuterFocusBorderAndPadding() + GetButtonInnerFocusMargin() + GetButtonInnerFocusBorderAndPadding();
|
1999-03-06 22:43:13 +03:00
|
|
|
}
|
|
|
|
|
1999-05-13 05:35:16 +04:00
|
|
|
/**
|
|
|
|
* Call this when styles change
|
|
|
|
*/
|
1999-02-26 09:41:10 +03:00
|
|
|
void
|
1999-11-24 09:03:41 +03:00
|
|
|
nsButtonFrameRenderer::ReResolveStyles(nsIPresContext* aPresContext)
|
1999-02-19 21:23:02 +03:00
|
|
|
{
|
1999-05-13 05:35:16 +04:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
// get all the styles
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
mFrame->GetContent(getter_AddRefs(content));
|
|
|
|
nsCOMPtr<nsIStyleContext> context;
|
|
|
|
mFrame->GetStyleContext(getter_AddRefs(context));
|
1999-02-26 09:41:10 +03:00
|
|
|
|
1999-10-09 00:41:19 +04:00
|
|
|
|
|
|
|
// style for the inner such as a dotted line (Windows)
|
1999-11-30 04:13:36 +03:00
|
|
|
aPresContext->ProbePseudoStyleContextFor(content, nsHTMLAtoms::mozFocusInnerPseudo, context,
|
1999-10-09 00:41:19 +04:00
|
|
|
PR_FALSE,
|
|
|
|
getter_AddRefs(mInnerFocusStyle));
|
|
|
|
|
|
|
|
// style for outer focus like a ridged border (MAC).
|
1999-11-30 04:13:36 +03:00
|
|
|
aPresContext->ProbePseudoStyleContextFor(content, nsHTMLAtoms::mozFocusOuterPseudo, context,
|
1999-10-09 00:41:19 +04:00
|
|
|
PR_FALSE,
|
|
|
|
getter_AddRefs(mOuterFocusStyle));
|
1999-06-16 10:17:21 +04:00
|
|
|
|
1999-02-19 21:23:02 +03:00
|
|
|
}
|
1999-09-04 03:36:32 +04:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsButtonFrameRenderer::GetStyleContext(PRInt32 aIndex, nsIStyleContext** aStyleContext) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aStyleContext, "null OUT parameter pointer");
|
|
|
|
if (aIndex < 0) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
*aStyleContext = nsnull;
|
|
|
|
switch (aIndex) {
|
1999-11-12 04:45:53 +03:00
|
|
|
|
1999-09-04 03:36:32 +04:00
|
|
|
case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
|
|
|
|
*aStyleContext = mInnerFocusStyle;
|
1999-09-21 11:56:18 +04:00
|
|
|
NS_IF_ADDREF(*aStyleContext);
|
1999-09-04 03:36:32 +04:00
|
|
|
break;
|
|
|
|
case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX:
|
|
|
|
*aStyleContext = mOuterFocusStyle;
|
1999-09-21 11:56:18 +04:00
|
|
|
NS_IF_ADDREF(*aStyleContext);
|
1999-09-04 03:36:32 +04:00
|
|
|
break;
|
1999-09-21 11:56:18 +04:00
|
|
|
default:
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
1999-09-04 03:36:32 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsButtonFrameRenderer::SetStyleContext(PRInt32 aIndex, nsIStyleContext* aStyleContext)
|
|
|
|
{
|
|
|
|
if (aIndex < 0) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
switch (aIndex) {
|
1999-11-12 04:45:53 +03:00
|
|
|
|
1999-09-04 03:36:32 +04:00
|
|
|
case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
|
|
|
|
mInnerFocusStyle = aStyleContext;
|
|
|
|
break;
|
|
|
|
case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX:
|
|
|
|
mOuterFocusStyle = aStyleContext;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|