2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsButtonFrameRenderer.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsCSSPseudoElements.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsStyleSet.h"
|
|
|
|
#include "nsDisplayList.h"
|
|
|
|
#include "nsITheme.h"
|
|
|
|
#include "nsThemeConstants.h"
|
2011-04-21 10:35:52 -07:00
|
|
|
#include "nsEventStates.h"
|
2011-07-20 12:18:54 -07:00
|
|
|
#include "mozilla/dom/Element.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define ACTIVE "active"
|
|
|
|
#define HOVER "hover"
|
|
|
|
#define FOCUS "focus"
|
|
|
|
|
|
|
|
nsButtonFrameRenderer::nsButtonFrameRenderer()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsButtonFrameRenderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsButtonFrameRenderer::~nsButtonFrameRenderer()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsButtonFrameRenderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::SetFrame(nsFrame* aFrame, nsPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
mFrame = aFrame;
|
|
|
|
ReResolveStyles(aPresContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
nsButtonFrameRenderer::GetFrame()
|
|
|
|
{
|
|
|
|
return mFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-09-28 23:19:26 -07:00
|
|
|
nsButtonFrameRenderer::SetDisabled(bool aDisabled, bool notify)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aDisabled)
|
|
|
|
mFrame->GetContent()->SetAttr(kNameSpaceID_None, nsGkAtoms::disabled, EmptyString(),
|
|
|
|
notify);
|
|
|
|
else
|
|
|
|
mFrame->GetContent()->UnsetAttr(kNameSpaceID_None, nsGkAtoms::disabled, notify);
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2007-03-22 10:30:00 -07:00
|
|
|
nsButtonFrameRenderer::isDisabled()
|
|
|
|
{
|
2011-05-31 18:46:56 -07:00
|
|
|
return mFrame->GetContent()->AsElement()->
|
2011-05-31 18:46:57 -07:00
|
|
|
State().HasState(NS_EVENT_STATE_DISABLED);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-02-10 00:45:13 -08:00
|
|
|
class nsDisplayButtonBoxShadowOuter : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayButtonBoxShadowOuter(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsButtonFrameRenderer* aRenderer)
|
|
|
|
: nsDisplayItem(aBuilder, aRenderer->GetFrame()), mBFR(aRenderer) {
|
2009-02-10 00:45:13 -08:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayButtonBoxShadowOuter);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayButtonBoxShadowOuter() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayButtonBoxShadowOuter);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-06 17:35:14 -07:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* aCtx);
|
2012-04-10 04:24:18 -07:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap);
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("ButtonBoxShadowOuter", TYPE_BUTTON_BOX_SHADOW_OUTER)
|
2009-02-10 00:45:13 -08:00
|
|
|
private:
|
|
|
|
nsButtonFrameRenderer* mBFR;
|
|
|
|
};
|
|
|
|
|
|
|
|
nsRect
|
2012-04-10 04:24:18 -07:00
|
|
|
nsDisplayButtonBoxShadowOuter::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) {
|
|
|
|
*aSnap = false;
|
2011-10-21 10:45:32 -07:00
|
|
|
return mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
|
2009-02-10 00:45:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsDisplayButtonBoxShadowOuter::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* aCtx) {
|
2010-08-13 03:01:58 -07:00
|
|
|
nsRect frameRect = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
2009-02-10 00:45:13 -08:00
|
|
|
|
|
|
|
nsRect buttonRect;
|
|
|
|
mBFR->GetButtonRect(frameRect, buttonRect);
|
|
|
|
|
|
|
|
nsCSSRendering::PaintBoxShadowOuter(mFrame->PresContext(), *aCtx, mFrame,
|
2009-09-06 17:35:14 -07:00
|
|
|
buttonRect, mVisibleRect);
|
2009-02-10 00:45:13 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsDisplayButtonBorderBackground : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayButtonBorderBackground(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsButtonFrameRenderer* aRenderer)
|
|
|
|
: nsDisplayItem(aBuilder, aRenderer->GetFrame()), mBFR(aRenderer) {
|
2007-03-22 10:30:00 -07:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayButtonBorderBackground);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayButtonBorderBackground() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayButtonBorderBackground);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-04-07 17:31:26 -07:00
|
|
|
virtual void HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect,
|
|
|
|
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames) {
|
|
|
|
aOutFrames->AppendElement(mFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-09-06 17:35:14 -07:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* aCtx);
|
2012-08-28 22:39:01 -07:00
|
|
|
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap);
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("ButtonBorderBackground", TYPE_BUTTON_BORDER_BACKGROUND)
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
nsButtonFrameRenderer* mBFR;
|
|
|
|
};
|
|
|
|
|
2012-08-28 22:39:01 -07:00
|
|
|
nsRect
|
|
|
|
nsDisplayButtonBorderBackground::GetBounds(nsDisplayListBuilder* aBuilder, bool* aSnap) {
|
|
|
|
*aSnap = false;
|
2012-09-28 04:19:38 -07:00
|
|
|
return aBuilder->IsForEventDelivery() ? nsRect(ToReferenceFrame(), mFrame->GetSize())
|
|
|
|
: mFrame->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
|
2012-08-28 22:39:01 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
class nsDisplayButtonForeground : public nsDisplayItem {
|
|
|
|
public:
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayButtonForeground(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsButtonFrameRenderer* aRenderer)
|
|
|
|
: nsDisplayItem(aBuilder, aRenderer->GetFrame()), mBFR(aRenderer) {
|
2007-03-22 10:30:00 -07:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayButtonForeground);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayButtonForeground() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayButtonForeground);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-06 17:35:14 -07:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* aCtx);
|
2010-07-15 14:07:49 -07:00
|
|
|
NS_DISPLAY_DECL_NAME("ButtonForeground", TYPE_BUTTON_FOREGROUND)
|
2007-03-22 10:30:00 -07:00
|
|
|
private:
|
|
|
|
nsButtonFrameRenderer* mBFR;
|
|
|
|
};
|
|
|
|
|
|
|
|
void nsDisplayButtonBorderBackground::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* aCtx)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(mFrame, "No frame?");
|
2007-03-30 14:11:41 -07:00
|
|
|
nsPresContext* pc = mFrame->PresContext();
|
2010-08-13 03:01:58 -07:00
|
|
|
nsRect r = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// draw the border and background inside the focus and outline borders
|
2009-09-06 17:35:14 -07:00
|
|
|
mBFR->PaintBorderAndBackground(pc, *aCtx, mVisibleRect, r,
|
2009-09-12 15:44:18 -07:00
|
|
|
aBuilder->GetBackgroundPaintFlags());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsDisplayButtonForeground::Paint(nsDisplayListBuilder* aBuilder,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext* aCtx)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-03-30 14:11:41 -07:00
|
|
|
nsPresContext *presContext = mFrame->PresContext();
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsStyleDisplay *disp = mFrame->GetStyleDisplay();
|
|
|
|
if (!mFrame->IsThemed(disp) ||
|
|
|
|
!presContext->GetTheme()->ThemeDrawsFocusForWidget(presContext, mFrame, disp->mAppearance)) {
|
|
|
|
// draw the focus and outline borders
|
2010-08-13 03:01:58 -07:00
|
|
|
nsRect r = nsRect(ToReferenceFrame(), mFrame->GetSize());
|
2009-09-06 17:35:14 -07:00
|
|
|
mBFR->PaintOutlineAndFocusBorders(presContext, *aCtx, mVisibleRect, r);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsDisplayList* aBackground,
|
|
|
|
nsDisplayList* aForeground)
|
|
|
|
{
|
2009-02-10 00:45:13 -08:00
|
|
|
if (mFrame->GetStyleBorder()->mBoxShadow) {
|
|
|
|
nsresult rv = aBackground->AppendNewToTop(new (aBuilder)
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayButtonBoxShadowOuter(aBuilder, this));
|
2009-02-10 00:45:13 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult rv = aBackground->AppendNewToTop(new (aBuilder)
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayButtonBorderBackground(aBuilder, this));
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
return aForeground->AppendNewToTop(new (aBuilder)
|
2010-08-13 03:01:13 -07:00
|
|
|
nsDisplayButtonForeground(aBuilder, this));
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsPresContext* aPresContext,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext& aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsRect& aRect)
|
|
|
|
{
|
2008-08-06 03:33:18 -07:00
|
|
|
// once we have all that we'll 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.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsRect rect;
|
|
|
|
|
|
|
|
if (mOuterFocusStyle) {
|
|
|
|
// ---------- paint the outer focus border -------------
|
|
|
|
|
|
|
|
GetButtonOuterFocusRect(aRect, rect);
|
|
|
|
|
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
2010-04-02 18:58:26 -07:00
|
|
|
aDirtyRect, rect, mOuterFocusStyle);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
// ---------- paint the inner focus border -------------
|
|
|
|
|
|
|
|
GetButtonInnerFocusRect(aRect, rect);
|
|
|
|
|
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
2010-04-02 18:58:26 -07:00
|
|
|
aDirtyRect, rect, mInnerFocusStyle);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::PaintBorderAndBackground(nsPresContext* aPresContext,
|
2011-04-07 18:04:40 -07:00
|
|
|
nsRenderingContext& aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsRect& aDirtyRect,
|
2009-09-12 15:44:18 -07:00
|
|
|
const nsRect& aRect,
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t aBGFlags)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
{
|
|
|
|
// get the button rect this is inside the focus and outline rects
|
|
|
|
nsRect buttonRect;
|
|
|
|
GetButtonRect(aRect, buttonRect);
|
|
|
|
|
|
|
|
nsStyleContext* context = mFrame->GetStyleContext();
|
|
|
|
|
|
|
|
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
|
2009-09-12 15:44:18 -07:00
|
|
|
aDirtyRect, buttonRect, aBGFlags);
|
2009-02-10 00:45:13 -08:00
|
|
|
nsCSSRendering::PaintBoxShadowInner(aPresContext, aRenderingContext,
|
|
|
|
mFrame, buttonRect, aDirtyRect);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
|
2010-04-02 18:58:26 -07:00
|
|
|
aDirtyRect, buttonRect, context);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonOuterFocusRect(const nsRect& aRect, nsRect& focusRect)
|
|
|
|
{
|
|
|
|
focusRect = aRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonRect(const nsRect& aRect, nsRect& r)
|
|
|
|
{
|
|
|
|
r = aRect;
|
|
|
|
r.Deflate(GetButtonOuterFocusBorderAndPadding());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& focusRect)
|
|
|
|
{
|
|
|
|
GetButtonRect(aRect, focusRect);
|
|
|
|
focusRect.Deflate(GetButtonBorderAndPadding());
|
|
|
|
focusRect.Deflate(GetButtonInnerFocusMargin());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonOuterFocusBorderAndPadding()
|
|
|
|
{
|
|
|
|
nsMargin result(0,0,0,0);
|
|
|
|
|
|
|
|
if (mOuterFocusStyle) {
|
|
|
|
if (!mOuterFocusStyle->GetStylePadding()->GetPadding(result)) {
|
|
|
|
NS_NOTYETIMPLEMENTED("percentage padding");
|
|
|
|
}
|
2012-05-30 22:19:49 -07:00
|
|
|
result += mOuterFocusStyle->GetStyleBorder()->GetComputedBorder();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonBorderAndPadding()
|
|
|
|
{
|
|
|
|
return mFrame->GetUsedBorderAndPadding();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the size of the buttons border this is the union of the normal and disabled borders.
|
|
|
|
*/
|
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonInnerFocusMargin()
|
|
|
|
{
|
|
|
|
nsMargin innerFocusMargin(0,0,0,0);
|
|
|
|
|
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
const nsStyleMargin* margin = mInnerFocusStyle->GetStyleMargin();
|
|
|
|
if (!margin->GetMargin(innerFocusMargin)) {
|
|
|
|
NS_NOTYETIMPLEMENTED("percentage margin");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return innerFocusMargin;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetButtonInnerFocusBorderAndPadding()
|
|
|
|
{
|
|
|
|
nsMargin result(0,0,0,0);
|
|
|
|
|
|
|
|
if (mInnerFocusStyle) {
|
|
|
|
if (!mInnerFocusStyle->GetStylePadding()->GetPadding(result)) {
|
|
|
|
NS_NOTYETIMPLEMENTED("percentage padding");
|
|
|
|
}
|
2012-05-30 22:19:49 -07:00
|
|
|
result += mInnerFocusStyle->GetStyleBorder()->GetComputedBorder();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// gets all the focus borders and padding that will be added to the regular border
|
|
|
|
nsMargin
|
|
|
|
nsButtonFrameRenderer::GetAddedButtonBorderAndPadding()
|
|
|
|
{
|
|
|
|
return GetButtonOuterFocusBorderAndPadding() + GetButtonInnerFocusMargin() + GetButtonInnerFocusBorderAndPadding();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Call this when styles change
|
|
|
|
*/
|
2007-05-23 13:32:56 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
nsButtonFrameRenderer::ReResolveStyles(nsPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
// get all the styles
|
|
|
|
nsStyleContext* context = mFrame->GetStyleContext();
|
|
|
|
nsStyleSet *styleSet = aPresContext->StyleSet();
|
|
|
|
|
|
|
|
// style for the inner such as a dotted line (Windows)
|
2009-12-10 23:37:40 -08:00
|
|
|
mInnerFocusStyle =
|
2010-04-30 06:12:06 -07:00
|
|
|
styleSet->ProbePseudoElementStyle(mFrame->GetContent()->AsElement(),
|
2009-12-10 23:37:40 -08:00
|
|
|
nsCSSPseudoElements::ePseudo_mozFocusInner,
|
|
|
|
context);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// style for outer focus like a ridged border (MAC).
|
2009-12-10 23:37:40 -08:00
|
|
|
mOuterFocusStyle =
|
2010-04-30 06:12:06 -07:00
|
|
|
styleSet->ProbePseudoElementStyle(mFrame->GetContent()->AsElement(),
|
2009-12-10 23:37:40 -08:00
|
|
|
nsCSSPseudoElements::ePseudo_mozFocusOuter,
|
|
|
|
context);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsStyleContext*
|
2012-08-22 08:56:38 -07:00
|
|
|
nsButtonFrameRenderer::GetStyleContext(int32_t aIndex) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
switch (aIndex) {
|
|
|
|
case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
|
|
|
|
return mInnerFocusStyle;
|
|
|
|
case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX:
|
|
|
|
return mOuterFocusStyle;
|
|
|
|
default:
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
nsButtonFrameRenderer::SetStyleContext(int32_t aIndex, nsStyleContext* aStyleContext)
|
2007-03-22 10:30:00 -07: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;
|
|
|
|
}
|
|
|
|
}
|