Cleanup moz-decl-counter usage and fix NS_LOG_ADDREF usage

git-svn-id: svn://10.0.0.236/trunk@50239 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
kipp%netscape.com
1999-10-08 20:41:19 +00:00
parent 0f9df28d81
commit e18af2d0ee
265 changed files with 1186 additions and 2477 deletions

View File

@@ -1,3 +1,21 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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/
*
* 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.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "nsButtonFrameRenderer.h"
#include "nsIRenderingContext.h"
#include "nsCSSRendering.h"
@@ -11,51 +29,55 @@
#define HOVER "hover"
#define FOCUS "focus"
MOZ_DECL_CTOR_COUNTER(nsButtonFrameRenderer);
nsButtonFrameRenderer::nsButtonFrameRenderer()
{
mNameSpace = kNameSpaceID_HTML;
MOZ_COUNT_CTOR(nsButtonFrameRenderer);
mNameSpace = kNameSpaceID_HTML;
}
nsButtonFrameRenderer::~nsButtonFrameRenderer()
{
MOZ_COUNT_DTOR(nsButtonFrameRenderer);
}
void
nsButtonFrameRenderer::SetNameSpace(PRInt32 aNameSpace)
{
mNameSpace = aNameSpace;
mNameSpace = aNameSpace;
}
void
nsButtonFrameRenderer::SetFrame(nsFrame* aFrame, nsIPresContext& aPresContext)
{
mFrame = aFrame;
ReResolveStyles(aPresContext);
mFrame = aFrame;
ReResolveStyles(aPresContext);
}
nsIFrame*
nsButtonFrameRenderer::GetFrame()
{
return mFrame;
return mFrame;
}
PRInt32
nsButtonFrameRenderer::GetNameSpace()
{
return mNameSpace;
return mNameSpace;
}
void
nsButtonFrameRenderer::SetDisabled(PRBool aDisabled, PRBool notify)
{
// get the content
// get the content
nsCOMPtr<nsIContent> content;
mFrame->GetContent(getter_AddRefs(content));
if (aDisabled)
content->SetAttribute(mNameSpace, nsHTMLAtoms::disabled, "", notify);
content->SetAttribute(mNameSpace, nsHTMLAtoms::disabled, "", notify);
else
content->UnsetAttribute(mNameSpace, nsHTMLAtoms::disabled, notify);
content->UnsetAttribute(mNameSpace, nsHTMLAtoms::disabled, notify);
}
@@ -84,119 +106,119 @@ nsButtonFrameRenderer::Redraw()
void
nsButtonFrameRenderer::PaintButton (nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
const nsRect& aRect)
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
const nsRect& aRect)
{
//printf("painted width='%d' height='%d'\n",aRect.width, aRect.height);
// draw the border and background inside the focus and outline borders
PaintBorderAndBackground(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aRect);
// draw the border and background inside the focus and outline borders
PaintBorderAndBackground(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aRect);
// draw the focus and outline borders
// draw the focus and outline borders
PaintOutlineAndFocusBorders(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aRect);
}
void
nsButtonFrameRenderer::PaintOutlineAndFocusBorders(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
const nsRect& aRect)
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
const nsRect& aRect)
{
// 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.
// 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.
nsRect rect;
nsRect rect;
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer)
{
if (mOuterFocusStyle) {
// ---------- paint the outer focus border -------------
{
if (mOuterFocusStyle) {
// ---------- paint the outer focus border -------------
GetButtonOuterFocusRect(aRect, rect);
GetButtonOuterFocusRect(aRect, rect);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Spacing);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Spacing);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *spacing, mOuterFocusStyle, 0);
}
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *spacing, mOuterFocusStyle, 0);
}
// ---------- paint the inner focus border -------------
if (mInnerFocusStyle) {
// ---------- paint the inner focus border -------------
if (mInnerFocusStyle) {
GetButtonInnerFocusRect(aRect, rect);
GetButtonInnerFocusRect(aRect, rect);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *spacing, mInnerFocusStyle, 0);
}
}
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *spacing, mInnerFocusStyle, 0);
}
}
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer)
{
{
/*
if (mOutlineStyle) {
if (mOutlineStyle) {
GetButtonOutlineRect(aRect, rect);
GetButtonOutlineRect(aRect, rect);
mOutlineRect = rect;
mOutlineRect = rect;
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOutlineStyle ->GetStyleData(eStyleStruct_Spacing);
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOutlineStyle ->GetStyleData(eStyleStruct_Spacing);
// set the clipping area so we can draw outside our bounds.
aRenderingContext.PushState();
PRBool clipEmpty;
// set the clipping area so we can draw outside our bounds.
aRenderingContext.PushState();
PRBool clipEmpty;
aRenderingContext.SetClipRect(rect, nsClipCombine_kReplace, clipEmpty);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *spacing, mOutlineStyle, 0);
aRenderingContext.SetClipRect(rect, nsClipCombine_kReplace, clipEmpty);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, rect, *spacing, mOutlineStyle, 0);
aRenderingContext.PopState(clipEmpty);
}
aRenderingContext.PopState(clipEmpty);
}
*/
}
}
}
void
nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext& aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
const nsRect& aRect)
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
const nsRect& aRect)
{
if (NS_FRAME_PAINT_LAYER_BACKGROUND != aWhichLayer)
return;
if (NS_FRAME_PAINT_LAYER_BACKGROUND != aWhichLayer)
return;
// get the button rect this is inside the focus and outline rects
nsRect buttonRect;
GetButtonRect(aRect, buttonRect);
// get the button rect this is inside the focus and outline rects
nsRect buttonRect;
GetButtonRect(aRect, buttonRect);
nsCOMPtr<nsIStyleContext> context;
mFrame->GetStyleContext(getter_AddRefs(context));
nsCOMPtr<nsIStyleContext> context;
mFrame->GetStyleContext(getter_AddRefs(context));
// get the styles
const nsStyleSpacing* spacing =
// get the styles
const nsStyleSpacing* spacing =
(const nsStyleSpacing*)context->GetStyleData(eStyleStruct_Spacing);
const nsStyleColor* color =
const nsStyleColor* color =
(const nsStyleColor*)context->GetStyleData(eStyleStruct_Color);
// paint the border and background
// paint the border and background
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *color, *spacing, 0, 0);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *color, *spacing, 0, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *spacing, context, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, *spacing, context, 0);
}
@@ -204,69 +226,69 @@ nsButtonFrameRenderer::PaintBorderAndBackground(nsIPresContext& aPresContext,
void
nsButtonFrameRenderer::GetButtonOutlineRect(const nsRect& aRect, nsRect& outlineRect)
{
outlineRect = aRect;
outlineRect.Inflate(GetButtonOutlineBorderAndPadding());
outlineRect = aRect;
outlineRect.Inflate(GetButtonOutlineBorderAndPadding());
}
void
nsButtonFrameRenderer::GetButtonOuterFocusRect(const nsRect& aRect, nsRect& focusRect)
{
focusRect = aRect;
focusRect = aRect;
}
void
nsButtonFrameRenderer::GetButtonRect(const nsRect& aRect, nsRect& r)
{
r = aRect;
r.Deflate(GetButtonOuterFocusBorderAndPadding());
r = aRect;
r.Deflate(GetButtonOuterFocusBorderAndPadding());
}
void
nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& focusRect)
{
GetButtonRect(aRect, focusRect);
focusRect.Deflate(GetButtonBorderAndPadding());
focusRect.Deflate(GetButtonInnerFocusMargin());
GetButtonRect(aRect, focusRect);
focusRect.Deflate(GetButtonBorderAndPadding());
focusRect.Deflate(GetButtonInnerFocusMargin());
}
void
nsButtonFrameRenderer::GetButtonContentRect(const nsRect& aRect, nsRect& r)
{
GetButtonInnerFocusRect(aRect, r);
r.Deflate(GetButtonInnerFocusBorderAndPadding());
GetButtonInnerFocusRect(aRect, r);
r.Deflate(GetButtonInnerFocusBorderAndPadding());
}
nsMargin
nsButtonFrameRenderer::GetButtonOuterFocusBorderAndPadding()
{
nsMargin focusBorderAndPadding(0,0,0,0);
nsMargin focusBorderAndPadding(0,0,0,0);
if (mOuterFocusStyle) {
// get the outer focus border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(focusBorderAndPadding)) {
if (mOuterFocusStyle) {
// get the outer focus border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOuterFocusStyle ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(focusBorderAndPadding)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
}
}
return focusBorderAndPadding;
return focusBorderAndPadding;
}
nsMargin
nsButtonFrameRenderer::GetButtonBorderAndPadding()
{
nsCOMPtr<nsIStyleContext> context;
mFrame->GetStyleContext(getter_AddRefs(context));
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;
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;
}
/**
@@ -275,47 +297,47 @@ nsButtonFrameRenderer::GetButtonBorderAndPadding()
nsMargin
nsButtonFrameRenderer::GetButtonInnerFocusMargin()
{
nsMargin innerFocusMargin(0,0,0,0);
nsMargin innerFocusMargin(0,0,0,0);
if (mInnerFocusStyle) {
// get the outer focus border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
spacing->GetMargin(innerFocusMargin);
}
if (mInnerFocusStyle) {
// get the outer focus border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
spacing->GetMargin(innerFocusMargin);
}
return innerFocusMargin;
return innerFocusMargin;
}
nsMargin
nsButtonFrameRenderer::GetButtonInnerFocusBorderAndPadding()
{
nsMargin innerFocusBorderAndPadding(0,0,0,0);
nsMargin innerFocusBorderAndPadding(0,0,0,0);
if (mInnerFocusStyle) {
// get the outer focus border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(innerFocusBorderAndPadding)) {
if (mInnerFocusStyle) {
// get the outer focus border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mInnerFocusStyle ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(innerFocusBorderAndPadding)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
}
}
return innerFocusBorderAndPadding;
return innerFocusBorderAndPadding;
}
nsMargin
nsButtonFrameRenderer::GetButtonOutlineBorderAndPadding()
{
nsMargin borderAndPadding(0,0,0,0);
nsMargin borderAndPadding(0,0,0,0);
if (mOutlineStyle) {
// get the outline border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOutlineStyle ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(borderAndPadding)) {
if (mOutlineStyle) {
// get the outline border and padding
const nsStyleSpacing* spacing = (const nsStyleSpacing*)mOutlineStyle ->GetStyleData(eStyleStruct_Spacing);
if (!spacing->GetBorderPadding(borderAndPadding)) {
NS_NOTYETIMPLEMENTED("percentage border");
}
}
}
return borderAndPadding;
return borderAndPadding;
}
// gets the full size of our border with all the focus borders
@@ -339,29 +361,29 @@ void
nsButtonFrameRenderer::ReResolveStyles(nsIPresContext& aPresContext)
{
// get all the styles
nsCOMPtr<nsIContent> content;
mFrame->GetContent(getter_AddRefs(content));
nsCOMPtr<nsIStyleContext> context;
mFrame->GetStyleContext(getter_AddRefs(context));
// get all the styles
nsCOMPtr<nsIContent> content;
mFrame->GetContent(getter_AddRefs(content));
nsCOMPtr<nsIStyleContext> context;
mFrame->GetStyleContext(getter_AddRefs(context));
// style that draw an outline around the button
nsCOMPtr<nsIAtom> atom ( getter_AddRefs(NS_NewAtom(":-moz-outline")) );
aPresContext.ProbePseudoStyleContextFor(content, atom, context,
PR_FALSE,
getter_AddRefs(mOutlineStyle));
nsCOMPtr<nsIAtom> atom ( getter_AddRefs(NS_NewAtom(":-moz-outline")) );
aPresContext.ProbePseudoStyleContextFor(content, atom, context,
PR_FALSE,
getter_AddRefs(mOutlineStyle));
// style for the inner such as a dotted line (Windows)
atom = getter_AddRefs(NS_NewAtom(":-moz-focus-inner"));
aPresContext.ProbePseudoStyleContextFor(content, atom, context,
PR_FALSE,
getter_AddRefs(mInnerFocusStyle));
// style for the inner such as a dotted line (Windows)
atom = getter_AddRefs(NS_NewAtom(":-moz-focus-inner"));
aPresContext.ProbePseudoStyleContextFor(content, atom, context,
PR_FALSE,
getter_AddRefs(mInnerFocusStyle));
// style for outer focus like a ridged border (MAC).
atom = getter_AddRefs(NS_NewAtom(":-moz-focus-outer"));
aPresContext.ProbePseudoStyleContextFor(content, atom, context,
PR_FALSE,
getter_AddRefs(mOuterFocusStyle));
// style for outer focus like a ridged border (MAC).
atom = getter_AddRefs(NS_NewAtom(":-moz-focus-outer"));
aPresContext.ProbePseudoStyleContextFor(content, atom, context,
PR_FALSE,
getter_AddRefs(mOuterFocusStyle));
}