2001-09-28 20:14:13 +00: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
|
1999-10-08 20:41:19 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00: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-08 20:41:19 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-10-08 20:41:19 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2001-09-28 20:14:13 +00: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 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* 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-02-20 06:05:15 +00:00
|
|
|
#include "nsButtonFrameRenderer.h"
|
1999-02-19 18:23:02 +00:00
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
1999-02-26 06:41:10 +00:00
|
|
|
#include "nsIPresContext.h"
|
1999-03-06 19:43:13 +00:00
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsIViewManager.h"
|
1999-03-12 23:47:52 +00:00
|
|
|
#include "nsHTMLAtoms.h"
|
2002-11-17 15:37:56 +00:00
|
|
|
#include "nsCSSPseudoElements.h"
|
2000-12-30 19:22:22 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
1999-02-19 18:23:02 +00:00
|
|
|
|
1999-03-06 19:43:13 +00:00
|
|
|
#define ACTIVE "active"
|
|
|
|
#define HOVER "hover"
|
|
|
|
#define FOCUS "focus"
|
1999-02-26 08:48:24 +00:00
|
|
|
|
2001-01-27 23:06:33 +00:00
|
|
|
MOZ_DECL_CTOR_COUNTER(nsButtonFrameRenderer)
|
1999-10-08 20:41:19 +00:00
|
|
|
|
1999-02-19 18:23:02 +00:00
|
|
|
nsButtonFrameRenderer::nsButtonFrameRenderer()
|
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
MOZ_COUNT_CTOR(nsButtonFrameRenderer);
|
1999-02-19 18:23:02 +00:00
|
|
|
}
|
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
nsButtonFrameRenderer::~nsButtonFrameRenderer()
|
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
MOZ_COUNT_DTOR(nsButtonFrameRenderer);
|
1999-02-26 06:41:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-11-24 06:03:41 +00:00
|
|
|
nsButtonFrameRenderer::SetFrame(nsFrame* aFrame, nsIPresContext* aPresContext)
|
1999-02-19 18:23:02 +00:00
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
mFrame = aFrame;
|
|
|
|
ReResolveStyles(aPresContext);
|
1999-02-19 18:23:02 +00:00
|
|
|
}
|
|
|
|
|
1999-09-14 22:17:19 +00:00
|
|
|
nsIFrame*
|
|
|
|
nsButtonFrameRenderer::GetFrame()
|
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
return mFrame;
|
1999-09-14 22:17:19 +00:00
|
|
|
}
|
|
|
|
|
1999-02-26 08:48:24 +00:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::SetDisabled(PRBool aDisabled, PRBool notify)
|
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
// get the content
|
1999-03-12 23:47:52 +00:00
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
mFrame->GetContent(getter_AddRefs(content));
|
|
|
|
|
|
|
|
if (aDisabled)
|
2002-05-20 22:47:02 +00:00
|
|
|
content->SetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, nsString(),
|
|
|
|
notify);
|
1999-03-12 23:47:52 +00:00
|
|
|
else
|
2002-05-20 22:47:02 +00:00
|
|
|
content->UnsetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, notify);
|
1999-03-12 23:47:52 +00:00
|
|
|
|
1999-02-26 08:48:24 +00:00
|
|
|
}
|
1999-02-26 06:41:10 +00:00
|
|
|
|
1999-02-26 08:48:24 +00:00
|
|
|
PRBool
|
|
|
|
nsButtonFrameRenderer::isDisabled()
|
|
|
|
{
|
1999-03-12 23:47:52 +00:00
|
|
|
// get the content
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
mFrame->GetContent(getter_AddRefs(content));
|
1999-09-03 03:47:06 +00:00
|
|
|
nsAutoString value;
|
2002-05-20 22:47:02 +00:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::disabled, value))
|
1999-03-12 23:47:52 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
|
|
|
|
return PR_FALSE;
|
1999-02-26 08:48:24 +00:00
|
|
|
}
|
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
void
|
1999-10-26 04:44:41 +00:00
|
|
|
nsButtonFrameRenderer::Redraw(nsIPresContext* aPresContext)
|
1999-05-13 01:35:16 +00:00
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
mFrame->GetRect(rect);
|
|
|
|
rect.x = 0;
|
|
|
|
rect.y = 0;
|
1999-10-26 04:44:41 +00:00
|
|
|
mFrame->Invalidate(aPresContext, rect, PR_FALSE);
|
1999-02-26 06:41:10 +00:00
|
|
|
}
|
|
|
|
|
1999-02-19 18:23:02 +00:00
|
|
|
void
|
1999-11-24 06:03:41 +00:00
|
|
|
nsButtonFrameRenderer::PaintButton (nsIPresContext* aPresContext,
|
1999-10-08 20:41:19 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsRect& aRect)
|
1999-02-19 18:23:02 +00:00
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
//printf("painted width='%d' height='%d'\n",aRect.width, aRect.height);
|
1999-03-02 01:25:33 +00:00
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
// draw the border and background inside the focus and outline borders
|
2002-04-06 15:31:53 +00:00
|
|
|
PaintBorderAndBackground(aPresContext, aRenderingContext, aDirtyRect, aRect);
|
1999-02-26 06:41:10 +00:00
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
// draw the focus and outline borders
|
2002-04-06 15:31:53 +00:00
|
|
|
PaintOutlineAndFocusBorders(aPresContext, aRenderingContext, aDirtyRect, aRect);
|
1999-02-19 18:23:02 +00:00
|
|
|
}
|
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
void
|
1999-11-24 06:03:41 +00:00
|
|
|
nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext* aPresContext,
|
1999-10-08 20:41:19 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsRect& aRect)
|
1999-02-19 18:23:02 +00:00
|
|
|
{
|
1999-10-08 20:41:19 +00: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 18:23:02 +00:00
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
nsRect rect;
|
1999-02-19 18:23:02 +00:00
|
|
|
|
2002-04-06 15:31:53 +00:00
|
|
|
if (mOuterFocusStyle) {
|
|
|
|
// ---------- paint the outer focus border -------------
|
1999-02-19 18:23:02 +00:00
|
|
|
|
2002-04-06 15:31:53 +00:00
|
|
|
GetButtonOuterFocusRect(aRect, rect);
|
1999-02-19 18:23:02 +00:00
|
|
|
|
2002-04-06 15:31:53 +00:00
|
|
|
const nsStyleBorder* border;
|
2003-02-22 04:27:23 +00:00
|
|
|
::GetStyleData(mOuterFocusStyle.get(), &border);
|
2002-04-06 15:31:53 +00:00
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
|
|
|
aDirtyRect, rect, *border, mOuterFocusStyle, 0);
|
|
|
|
}
|
1999-02-19 18:23:02 +00:00
|
|
|
|
2002-04-06 15:31:53 +00:00
|
|
|
if (mInnerFocusStyle) {
|
1999-10-08 20:41:19 +00:00
|
|
|
// ---------- paint the inner focus border -------------
|
1999-02-19 18:23:02 +00:00
|
|
|
|
2002-04-06 15:31:53 +00:00
|
|
|
GetButtonInnerFocusRect(aRect, rect);
|
1999-02-19 18:23:02 +00:00
|
|
|
|
2002-04-06 15:31:53 +00:00
|
|
|
const nsStyleBorder* border;
|
2003-02-22 04:27:23 +00:00
|
|
|
::GetStyleData(mInnerFocusStyle.get(), &border);
|
2002-04-06 15:31:53 +00:00
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
|
|
|
aDirtyRect, rect, *border, mInnerFocusStyle, 0);
|
1999-10-08 20:41:19 +00:00
|
|
|
}
|
1999-02-19 18:23:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
void
|
1999-11-24 06:03:41 +00:00
|
|
|
nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext* aPresContext,
|
1999-10-08 20:41:19 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsRect& aRect)
|
1999-02-26 06:41:10 +00:00
|
|
|
|
1999-02-19 18:23:02 +00:00
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
// get the button rect this is inside the focus and outline rects
|
|
|
|
nsRect buttonRect;
|
|
|
|
GetButtonRect(aRect, buttonRect);
|
1999-02-19 18:23:02 +00:00
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* context = mFrame->GetStyleContext();
|
1999-02-19 18:23:02 +00:00
|
|
|
|
2001-02-07 09:57:26 +00:00
|
|
|
const nsStyleBorder* border =
|
|
|
|
(const nsStyleBorder*)context->GetStyleData(eStyleStruct_Border);
|
2002-10-08 10:24:53 +00:00
|
|
|
const nsStylePadding* padding =
|
|
|
|
(const nsStylePadding*)context->GetStyleData(eStyleStruct_Padding);
|
1999-03-06 19:43:13 +00:00
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
|
2002-10-08 10:24:53 +00:00
|
|
|
aDirtyRect, buttonRect, *border, *padding,
|
2003-02-01 23:54:32 +00:00
|
|
|
0, 0, PR_FALSE);
|
1999-10-08 20:41:19 +00:00
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
2001-02-07 09:57:26 +00:00
|
|
|
aDirtyRect, buttonRect, *border, context, 0);
|
1999-02-26 06:41:10 +00:00
|
|
|
}
|
1999-02-19 18:23:02 +00:00
|
|
|
|
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonOutlineRect(const nsRect& aRect, nsRect& outlineRect)
|
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
outlineRect = aRect;
|
|
|
|
outlineRect.Inflate(GetButtonOutlineBorderAndPadding());
|
1999-02-26 06:41:10 +00:00
|
|
|
}
|
1999-02-19 18:23:02 +00:00
|
|
|
|
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonOuterFocusRect(const nsRect& aRect, nsRect& focusRect)
|
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
focusRect = aRect;
|
1999-02-26 06:41:10 +00:00
|
|
|
}
|
1999-02-19 18:23:02 +00:00
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonRect(const nsRect& aRect, nsRect& r)
|
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
r = aRect;
|
|
|
|
r.Deflate(GetButtonOuterFocusBorderAndPadding());
|
1999-02-26 06:41:10 +00:00
|
|
|
}
|
1999-02-19 18:23:02 +00:00
|
|
|
|
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& focusRect)
|
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
GetButtonRect(aRect, focusRect);
|
|
|
|
focusRect.Deflate(GetButtonBorderAndPadding());
|
|
|
|
focusRect.Deflate(GetButtonInnerFocusMargin());
|
1999-02-26 06:41:10 +00:00
|
|
|
}
|
1999-02-19 18:23:02 +00:00
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonContentRect(const nsRect& aRect, nsRect& r)
|
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
GetButtonInnerFocusRect(aRect, r);
|
|
|
|
r.Deflate(GetButtonInnerFocusBorderAndPadding());
|
1999-02-26 06:41:10 +00:00
|
|
|
}
|
1999-02-19 18:23:02 +00:00
|
|
|
|
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonOuterFocusBorderAndPadding()
|
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
nsMargin focusBorderAndPadding(0,0,0,0);
|
1999-02-19 18:23:02 +00:00
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
if (mOuterFocusStyle) {
|
2001-02-07 09:57:26 +00:00
|
|
|
nsStyleBorderPadding bPad;
|
2001-05-31 22:19:43 +00:00
|
|
|
mOuterFocusStyle->GetBorderPaddingFor(bPad);
|
2001-02-07 09:57:26 +00:00
|
|
|
if (!bPad.GetBorderPadding(focusBorderAndPadding)) {
|
1999-07-28 04:48:34 +00:00
|
|
|
NS_NOTYETIMPLEMENTED("percentage border");
|
|
|
|
}
|
1999-10-08 20:41:19 +00:00
|
|
|
}
|
1999-02-26 06:41:10 +00:00
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
return focusBorderAndPadding;
|
1999-02-19 18:23:02 +00:00
|
|
|
}
|
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonBorderAndPadding()
|
1999-02-19 18:23:02 +00:00
|
|
|
{
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* context = mFrame->GetStyleContext();
|
1999-10-08 20:41:19 +00:00
|
|
|
|
2001-02-07 09:57:26 +00:00
|
|
|
nsMargin innerFocusBorderAndPadding(0,0,0,0);
|
|
|
|
nsStyleBorderPadding bPad;
|
2001-05-31 22:19:43 +00:00
|
|
|
context->GetBorderPaddingFor(bPad);
|
2001-02-07 09:57:26 +00:00
|
|
|
if (!bPad.GetBorderPadding(innerFocusBorderAndPadding)) {
|
1999-10-08 20:41:19 +00:00
|
|
|
NS_NOTYETIMPLEMENTED("percentage border");
|
|
|
|
}
|
2001-02-07 09:57:26 +00:00
|
|
|
return innerFocusBorderAndPadding;
|
1999-02-19 18:23:02 +00:00
|
|
|
}
|
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
/**
|
|
|
|
* Gets the size of the buttons border this is the union of the normal and disabled borders.
|
|
|
|
*/
|
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonInnerFocusMargin()
|
1999-02-19 18:23:02 +00:00
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
nsMargin innerFocusMargin(0,0,0,0);
|
1999-02-19 18:23:02 +00:00
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
// get the outer focus border and padding
|
2001-02-07 09:57:26 +00:00
|
|
|
const nsStyleMargin* margin = (const nsStyleMargin*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Margin);
|
|
|
|
margin->GetMargin(innerFocusMargin);
|
1999-10-08 20:41:19 +00:00
|
|
|
}
|
1999-02-26 06:41:10 +00:00
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
return innerFocusMargin;
|
1999-02-19 18:23:02 +00:00
|
|
|
}
|
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonInnerFocusBorderAndPadding()
|
1999-02-19 18:23:02 +00:00
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
nsMargin innerFocusBorderAndPadding(0,0,0,0);
|
1999-02-19 18:23:02 +00:00
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
// get the outer focus border and padding
|
2001-02-07 09:57:26 +00:00
|
|
|
nsStyleBorderPadding bPad;
|
2001-05-31 22:19:43 +00:00
|
|
|
mInnerFocusStyle->GetBorderPaddingFor(bPad);
|
2001-02-07 09:57:26 +00:00
|
|
|
if (!bPad.GetBorderPadding(innerFocusBorderAndPadding)) {
|
1999-07-28 04:48:34 +00:00
|
|
|
NS_NOTYETIMPLEMENTED("percentage border");
|
|
|
|
}
|
1999-10-08 20:41:19 +00:00
|
|
|
}
|
1999-02-26 06:41:10 +00:00
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
return innerFocusBorderAndPadding;
|
1999-02-19 18:23:02 +00:00
|
|
|
}
|
|
|
|
|
1999-02-26 06:41:10 +00:00
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonOutlineBorderAndPadding()
|
1999-02-19 18:23:02 +00:00
|
|
|
{
|
1999-10-08 20:41:19 +00:00
|
|
|
nsMargin borderAndPadding(0,0,0,0);
|
|
|
|
return borderAndPadding;
|
1999-02-19 18:23:02 +00:00
|
|
|
}
|
|
|
|
|
1999-03-27 00:58:29 +00:00
|
|
|
// gets the full size of our border with all the focus borders
|
1999-03-06 19:43:13 +00:00
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetFullButtonBorderAndPadding()
|
|
|
|
{
|
1999-03-27 00:58:29 +00: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 19:43:13 +00:00
|
|
|
}
|
|
|
|
|
1999-05-13 01:35:16 +00:00
|
|
|
/**
|
|
|
|
* Call this when styles change
|
|
|
|
*/
|
1999-02-26 06:41:10 +00:00
|
|
|
void
|
1999-11-24 06:03:41 +00:00
|
|
|
nsButtonFrameRenderer::ReResolveStyles(nsIPresContext* aPresContext)
|
1999-02-19 18:23:02 +00:00
|
|
|
{
|
1999-05-13 01:35:16 +00:00
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
// get all the styles
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
mFrame->GetContent(getter_AddRefs(content));
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* context = mFrame->GetStyleContext();
|
1999-02-26 06:41:10 +00:00
|
|
|
|
1999-10-08 20:41:19 +00:00
|
|
|
|
|
|
|
// style for the inner such as a dotted line (Windows)
|
2003-02-22 00:32:13 +00:00
|
|
|
mInnerFocusStyle = aPresContext->ProbePseudoStyleContextFor(content,
|
|
|
|
nsCSSPseudoElements::mozFocusInner,
|
|
|
|
context);
|
1999-10-08 20:41:19 +00:00
|
|
|
|
|
|
|
// style for outer focus like a ridged border (MAC).
|
2003-02-22 00:32:13 +00:00
|
|
|
mOuterFocusStyle = aPresContext->ProbePseudoStyleContextFor(content,
|
|
|
|
nsCSSPseudoElements::mozFocusOuter,
|
|
|
|
context);
|
1999-06-16 06:17:21 +00:00
|
|
|
|
1999-02-19 18:23:02 +00:00
|
|
|
}
|
1999-09-03 23:36:32 +00:00
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext*
|
|
|
|
nsButtonFrameRenderer::GetStyleContext(PRInt32 aIndex) const
|
1999-09-03 23:36:32 +00:00
|
|
|
{
|
|
|
|
switch (aIndex) {
|
|
|
|
case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
|
2003-02-22 00:32:13 +00:00
|
|
|
return mInnerFocusStyle;
|
1999-09-03 23:36:32 +00:00
|
|
|
case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX:
|
2003-02-22 00:32:13 +00:00
|
|
|
return mOuterFocusStyle;
|
1999-09-21 07:56:18 +00:00
|
|
|
default:
|
2003-02-22 00:32:13 +00:00
|
|
|
return nsnull;
|
1999-09-03 23:36:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::SetStyleContext(PRInt32 aIndex, nsStyleContext* aStyleContext)
|
1999-09-03 23:36:32 +00:00
|
|
|
{
|
|
|
|
switch (aIndex) {
|
|
|
|
case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
|
|
|
|
mInnerFocusStyle = aStyleContext;
|
|
|
|
break;
|
|
|
|
case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX:
|
|
|
|
mOuterFocusStyle = aStyleContext;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|