back out bug 54488, behavioral problems.

This commit is contained in:
joshmoz@gmail.com 2007-08-27 21:05:12 -07:00
Родитель 252632c6ac
Коммит 59db92a505
3 изменённых файлов: 70 добавлений и 127 удалений

Просмотреть файл

@ -4094,9 +4094,6 @@ static PRBool IsSpecialGeckoKey(UInt32 macKeyCode)
if (isMozWindow)
[[self window] setSuppressMakeKeyFront:NO];
// invalidate so that things with a different appearance in background windows will redraw
mGeckoChild->Invalidate(PR_FALSE);
}
@ -4109,9 +4106,6 @@ static PRBool IsSpecialGeckoKey(UInt32 macKeyCode)
[self sendFocusEvent:NS_DEACTIVATE];
[self sendFocusEvent:NS_LOSTFOCUS];
// invalidate so that things with a different appearance in background windows will redraw
mGeckoChild->Invalidate(PR_FALSE);
}

Просмотреть файл

@ -92,34 +92,33 @@ protected:
nsresult GetSystemFont(PRUint8 aWidgetType, nsSystemFontID& aFont);
// HITheme drawing routines
void DrawFrame(CGContextRef context, HIThemeFrameKind inKind,
const HIRect& inBoxRect, PRBool inIsDisabled,
PRInt32 inState);
void DrawFrame (CGContextRef context, HIThemeFrameKind inKind,
const HIRect& inBoxRect, PRBool inIsDisabled,
PRInt32 inState);
void DrawProgress(CGContextRef context, const HIRect& inBoxRect,
PRBool inIsIndeterminate, PRBool inIsHorizontal,
PRInt32 inValue, nsIFrame* aFrame);
void DrawTab(CGContextRef context, const HIRect& inBoxRect,
PRBool inIsDisabled, PRBool inIsFrontmost,
PRBool inIsHorizontal, PRBool inTabBottom,
PRInt32 inState, nsIFrame* aFrame);
void DrawTabPanel(CGContextRef context, const HIRect& inBoxRect, nsIFrame* aFrame);
void DrawScale(CGContextRef context, const HIRect& inBoxRect,
PRBool inIsDisabled, PRInt32 inState,
PRBool inDirection, PRBool inIsReverse,
PRInt32 inCurrentValue, PRInt32 inMinValue,
PRInt32 inMaxValue, nsIFrame* aFrame);
void DrawButton(CGContextRef context, ThemeButtonKind inKind,
const HIRect& inBoxRect, PRBool inIsDefault,
PRBool inDisabled, ThemeButtonValue inValue,
ThemeButtonAdornment inAdornment, PRInt32 inState,
nsIFrame* aFrame);
void DrawSpinButtons(CGContextRef context, ThemeButtonKind inKind,
const HIRect& inBoxRect, PRBool inDisabled,
ThemeDrawState inDrawState, ThemeButtonAdornment inAdornment,
PRInt32 inState, nsIFrame* aFrame);
void DrawCheckboxRadio(CGContextRef context, ThemeButtonKind inKind,
const HIRect& inBoxRect, PRBool inChecked,
PRBool inDisabled, PRInt32 inState, nsIFrame* aFrame);
PRInt32 inValue);
void DrawTab (CGContextRef context, const HIRect& inBoxRect,
PRBool inIsDisabled, PRBool inIsFrontmost,
PRBool inIsHorizontal, PRBool inTabBottom,
PRInt32 inState);
void DrawTabPanel (CGContextRef context, const HIRect& inBoxRect);
void DrawScale (CGContextRef context, const HIRect& inBoxRect,
PRBool inIsDisabled, PRInt32 inState,
PRBool inDirection, PRBool inIsReverse,
PRInt32 inCurrentValue,
PRInt32 inMinValue, PRInt32 inMaxValue);
void DrawButton (CGContextRef context, ThemeButtonKind inKind,
const HIRect& inBoxRect, PRBool inIsDefault,
PRBool inDisabled, ThemeButtonValue inValue,
ThemeButtonAdornment inAdornment, PRInt32 inState);
void DrawSpinButtons (CGContextRef context, ThemeButtonKind inKind,
const HIRect& inBoxRect,
PRBool inDisabled, ThemeDrawState inDrawState,
ThemeButtonAdornment inAdornment, PRInt32 inState);
void DrawCheckboxRadio (CGContextRef context, ThemeButtonKind inKind,
const HIRect& inBoxRect, PRBool inChecked,
PRBool inDisabled, PRInt32 inState);
// Scrollbars
void DrawScrollbar(CGContextRef aCGContext, const HIRect& aBoxRect, nsIFrame *aFrame);
void GetScrollbarPressStates (nsIFrame *aFrame, PRInt32 aButtonStates[]);

Просмотреть файл

@ -54,7 +54,6 @@
#include "nsPresContext.h"
#include "nsILookAndFeel.h"
#include "nsWidgetAtoms.h"
#include "nsIWidget.h"
#include "gfxContext.h"
#include "gfxQuartzSurface.h"
@ -104,37 +103,10 @@ nsNativeThemeCocoa::~nsNativeThemeCocoa()
}
static BOOL frameIsInActiveWindow(nsIFrame* aFrame)
{
// default return value should be YES here, so things are painted as active by default
if (!aFrame) return YES;
nsIWidget* widget = aFrame->GetWindow();
if (!widget) return YES;
// get the top-level widget
nsIWidget* topLevelWidget = widget;
while (PR_TRUE) {
widget = topLevelWidget->GetParent();
if (widget)
topLevelWidget = widget;
else
break;
}
NSWindow* nativeWindow = (NSWindow*)topLevelWidget->GetNativeData(NS_NATIVE_WINDOW);
if (!nativeWindow) return YES;
nsWindowType windowType;
topLevelWidget->GetWindowType(windowType);
return [nativeWindow isKeyWindow] || (windowType == eWindowType_popup);
}
void
nsNativeThemeCocoa::DrawCheckboxRadio(CGContextRef cgContext, ThemeButtonKind inKind,
const HIRect& inBoxRect, PRBool inChecked,
PRBool inDisabled, PRInt32 inState, nsIFrame* aFrame)
PRBool inDisabled, PRInt32 inState)
{
HIThemeButtonDrawInfo bdi;
bdi.version = 0;
@ -145,7 +117,7 @@ nsNativeThemeCocoa::DrawCheckboxRadio(CGContextRef cgContext, ThemeButtonKind in
else if ((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER))
bdi.state = kThemeStatePressed;
else
bdi.state = frameIsInActiveWindow(aFrame) ? kThemeStateActive : kThemeStateInactive;
bdi.state = kThemeStateActive;
bdi.value = inChecked ? kThemeButtonOn : kThemeButtonOff;
bdi.adornment = (inState & NS_EVENT_STATE_FOCUS) ? kThemeAdornmentFocus : kThemeAdornmentNone;
@ -167,7 +139,7 @@ void
nsNativeThemeCocoa::DrawButton(CGContextRef cgContext, ThemeButtonKind inKind,
const HIRect& inBoxRect, PRBool inIsDefault, PRBool inDisabled,
ThemeButtonValue inValue, ThemeButtonAdornment inAdornment,
PRInt32 inState, nsIFrame* aFrame)
PRInt32 inState)
{
HIThemeButtonDrawInfo bdi;
bdi.version = 0;
@ -175,18 +147,12 @@ nsNativeThemeCocoa::DrawButton(CGContextRef cgContext, ThemeButtonKind inKind,
bdi.value = inValue;
bdi.adornment = inAdornment;
if (inDisabled) {
if (inDisabled)
bdi.state = kThemeStateUnavailable;
}
else if ((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER)) {
else if ((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER))
bdi.state = kThemeStatePressed;
}
else {
if (inKind == kThemeArrowButton)
bdi.state = kThemeStateUnavailable; // these are always drawn as unavailable
else
bdi.state = frameIsInActiveWindow(aFrame) ? kThemeStateActive : kThemeStateInactive;
}
else
bdi.state = (inKind == kThemeArrowButton) ? kThemeStateUnavailable : kThemeStateActive;
if (inState & NS_EVENT_STATE_FOCUS)
bdi.adornment |= kThemeAdornmentFocus;
@ -250,8 +216,9 @@ nsNativeThemeCocoa::DrawButton(CGContextRef cgContext, ThemeButtonKind inKind,
void
nsNativeThemeCocoa::DrawSpinButtons(CGContextRef cgContext, ThemeButtonKind inKind,
const HIRect& inBoxRect, PRBool inDisabled,
ThemeDrawState inDrawState, ThemeButtonAdornment inAdornment,
PRInt32 inState, nsIFrame* aFrame)
ThemeDrawState inDrawState,
ThemeButtonAdornment inAdornment,
PRInt32 inState)
{
HIThemeButtonDrawInfo bdi;
bdi.version = 0;
@ -262,8 +229,6 @@ nsNativeThemeCocoa::DrawSpinButtons(CGContextRef cgContext, ThemeButtonKind inKi
if (inDisabled)
bdi.state = kThemeStateUnavailable;
else
bdi.state = frameIsInActiveWindow(aFrame) ? kThemeStateActive : kThemeStateInactive;
HIThemeDrawButton(&inBoxRect, &bdi, cgContext, HITHEME_ORIENTATION, NULL);
}
@ -271,17 +236,12 @@ nsNativeThemeCocoa::DrawSpinButtons(CGContextRef cgContext, ThemeButtonKind inKi
void
nsNativeThemeCocoa::DrawFrame(CGContextRef cgContext, HIThemeFrameKind inKind,
const HIRect& inBoxRect, PRBool inIsDisabled,
PRInt32 inState)
const HIRect& inBoxRect, PRBool inIsDisabled, PRInt32 inState)
{
HIThemeFrameDrawInfo fdi;
fdi.version = 0;
fdi.kind = inKind;
// We don't ever set an inactive state for this because it doesn't
// look right(see other apps).
fdi.state = inIsDisabled ? kThemeStateUnavailable : kThemeStateActive;
// We do not draw focus rings for frame widgets because their complex layout has nasty
// drawing bugs and it looks terrible.
// fdi.isFocused = (inState & NS_EVENT_STATE_FOCUS) != 0;
@ -310,9 +270,9 @@ nsNativeThemeCocoa::DrawFrame(CGContextRef cgContext, HIThemeFrameKind inKind,
void
nsNativeThemeCocoa::DrawProgress(CGContextRef cgContext, const HIRect& inBoxRect,
PRBool inIsIndeterminate, PRBool inIsHorizontal,
PRInt32 inValue, nsIFrame* aFrame)
nsNativeThemeCocoa::DrawProgress(CGContextRef cgContext,
const HIRect& inBoxRect, PRBool inIsIndeterminate,
PRBool inIsHorizontal, PRInt32 inValue)
{
HIThemeTrackDrawInfo tdi;
static SInt32 sPhase = 0;
@ -324,7 +284,7 @@ nsNativeThemeCocoa::DrawProgress(CGContextRef cgContext, const HIRect& inBoxRect
tdi.max = 100;
tdi.value = inValue;
tdi.attributes = inIsHorizontal ? kThemeTrackHorizontal : 0;
tdi.enableState = frameIsInActiveWindow(aFrame) ? kThemeTrackActive : kThemeTrackInactive;
tdi.enableState = kThemeTrackActive;
tdi.trackInfo.progress.phase = sPhase++; // animate for the next time we're called
HIThemeDrawTrack(&tdi, NULL, cgContext, HITHEME_ORIENTATION);
@ -332,12 +292,12 @@ nsNativeThemeCocoa::DrawProgress(CGContextRef cgContext, const HIRect& inBoxRect
void
nsNativeThemeCocoa::DrawTabPanel(CGContextRef cgContext, const HIRect& inBoxRect, nsIFrame* aFrame)
nsNativeThemeCocoa::DrawTabPanel(CGContextRef cgContext, const HIRect& inBoxRect)
{
HIThemeTabPaneDrawInfo tpdi;
tpdi.version = 0;
tpdi.state = frameIsInActiveWindow(aFrame) ? kThemeStateActive : kThemeStateInactive;
tpdi.state = kThemeStateActive;
tpdi.direction = kThemeTabNorth;
tpdi.size = kHIThemeTabSizeNormal;
@ -349,8 +309,8 @@ void
nsNativeThemeCocoa::DrawScale(CGContextRef cgContext, const HIRect& inBoxRect,
PRBool inIsDisabled, PRInt32 inState,
PRBool inIsVertical, PRBool inIsReverse,
PRInt32 inCurrentValue, PRInt32 inMinValue,
PRInt32 inMaxValue, nsIFrame* aFrame)
PRInt32 inCurrentValue,
PRInt32 inMinValue, PRInt32 inMaxValue)
{
HIThemeTrackDrawInfo tdi;
@ -367,10 +327,7 @@ nsNativeThemeCocoa::DrawScale(CGContextRef cgContext, const HIRect& inBoxRect,
tdi.attributes |= kThemeTrackRightToLeft;
if (inState & NS_EVENT_STATE_FOCUS)
tdi.attributes |= kThemeTrackHasFocus;
if (inIsDisabled)
tdi.enableState = kThemeTrackDisabled;
else
tdi.enableState = frameIsInActiveWindow(aFrame) ? kThemeTrackActive : kThemeTrackInactive;
tdi.enableState = inIsDisabled ? kThemeTrackDisabled : kThemeTrackActive;
tdi.trackInfo.slider.thumbDir = kThemeThumbPlain;
tdi.trackInfo.slider.pressState = 0;
@ -382,7 +339,7 @@ void
nsNativeThemeCocoa::DrawTab(CGContextRef cgContext, const HIRect& inBoxRect,
PRBool inIsDisabled, PRBool inIsFrontmost,
PRBool inIsHorizontal, PRBool inTabBottom,
PRInt32 inState, nsIFrame* aFrame)
PRInt32 inState)
{
HIThemeTabDrawInfo tdi;
@ -392,14 +349,14 @@ nsNativeThemeCocoa::DrawTab(CGContextRef cgContext, const HIRect& inBoxRect,
if (inIsDisabled)
tdi.style = kThemeTabFrontUnavailable;
else
tdi.style = frameIsInActiveWindow(aFrame) ? kThemeTabFront : kThemeTabFrontInactive;
tdi.style = kThemeTabFront;
} else {
if (inIsDisabled)
tdi.style = kThemeTabNonFrontUnavailable;
else if ((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER))
tdi.style = kThemeTabNonFrontPressed;
else
tdi.style = frameIsInActiveWindow(aFrame) ? kThemeTabNonFront : kThemeTabNonFrontInactive;
tdi.style = kThemeTabNonFront;
}
// don't yet support vertical tabs
@ -482,13 +439,6 @@ nsNativeThemeCocoa::GetScrollbarDrawInfo(HIThemeTrackDrawInfo& aTdi, nsIFrame *a
PRInt32 longSideLength = (PRInt32)(isHorizontal ? (aRect.size.width) : (aRect.size.height));
aTdi.trackInfo.scrollbar.viewsize = (SInt32)longSideLength;
// This should be done early on so things like "kThemeTrackNothingToScroll" can
// override the active enable state.
if (frameIsInActiveWindow(aFrame))
aTdi.enableState = kThemeTrackActive;
else
aTdi.enableState = kThemeTrackInactive;
// Only display the thumb if we have room for it to display. Note that this doesn't
// affect the actual tracking rects Gecko maintains -- this is a purely cosmetic
// change. See bmo bug 380185 for more info.
@ -699,32 +649,32 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
break;
case NS_THEME_CHECKBOX:
DrawCheckboxRadio(cgContext, kThemeCheckBox, macRect, IsChecked(aFrame), IsDisabled(aFrame), eventState, aFrame);
DrawCheckboxRadio(cgContext, kThemeCheckBox, macRect, IsChecked(aFrame), IsDisabled(aFrame), eventState);
break;
case NS_THEME_CHECKBOX_SMALL:
DrawCheckboxRadio(cgContext, kThemeSmallCheckBox, macRect, IsChecked(aFrame), IsDisabled(aFrame), eventState, aFrame);
DrawCheckboxRadio(cgContext, kThemeSmallCheckBox, macRect, IsChecked(aFrame), IsDisabled(aFrame), eventState);
break;
case NS_THEME_RADIO:
DrawCheckboxRadio(cgContext, kThemeRadioButton, macRect, IsSelected(aFrame), IsDisabled(aFrame), eventState, aFrame);
DrawCheckboxRadio(cgContext, kThemeRadioButton, macRect, IsSelected(aFrame), IsDisabled(aFrame), eventState);
break;
case NS_THEME_RADIO_SMALL:
DrawCheckboxRadio(cgContext, kThemeSmallRadioButton, macRect,
IsSelected(aFrame), IsDisabled(aFrame), eventState, aFrame);
IsSelected(aFrame), IsDisabled(aFrame), eventState);
break;
case NS_THEME_BUTTON:
DrawButton(cgContext, kThemePushButton, macRect,
IsDefaultButton(aFrame), IsDisabled(aFrame),
kThemeButtonOn, kThemeAdornmentNone, eventState, aFrame);
kThemeButtonOn, kThemeAdornmentNone, eventState);
break;
case NS_THEME_BUTTON_BEVEL:
DrawButton(cgContext, kThemeMediumBevelButton, macRect,
IsDefaultButton(aFrame), IsDisabled(aFrame),
kThemeButtonOff, kThemeAdornmentNone, eventState, aFrame);
kThemeButtonOff, kThemeAdornmentNone, eventState);
break;
case NS_THEME_SPINNER: {
@ -740,14 +690,14 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
}
DrawSpinButtons(cgContext, kThemeIncDecButton, macRect, IsDisabled(aFrame),
state, kThemeAdornmentNone, eventState, aFrame);
state, kThemeAdornmentNone, eventState);
}
break;
case NS_THEME_TOOLBAR_BUTTON:
DrawButton(cgContext, kThemePushButton, macRect,
IsDefaultButton(aFrame), IsDisabled(aFrame),
kThemeButtonOn, kThemeAdornmentNone, eventState, aFrame);
kThemeButtonOn, kThemeAdornmentNone, eventState);
break;
case NS_THEME_TOOLBAR_SEPARATOR: {
@ -767,13 +717,13 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
case NS_THEME_DROPDOWN:
DrawButton(cgContext, kThemePopupButton, macRect,
IsDefaultButton(aFrame), IsDisabled(aFrame),
kThemeButtonOn, kThemeAdornmentNone, eventState, aFrame);
kThemeButtonOn, kThemeAdornmentNone, eventState);
break;
case NS_THEME_DROPDOWN_BUTTON:
DrawButton(cgContext, kThemeArrowButton, macRect, PR_FALSE,
IsDisabled(aFrame), kThemeButtonOn,
kThemeAdornmentArrowDownArrow, eventState, aFrame);
DrawButton (cgContext, kThemeArrowButton, macRect, PR_FALSE,
IsDisabled(aFrame), kThemeButtonOn,
kThemeAdornmentArrowDownArrow, eventState);
break;
case NS_THEME_TEXTFIELD:
@ -786,12 +736,12 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
case NS_THEME_PROGRESSBAR:
DrawProgress(cgContext, macRect, IsIndeterminateProgress(aFrame),
PR_TRUE, GetProgressValue(aFrame), aFrame);
PR_TRUE, GetProgressValue(aFrame));
break;
case NS_THEME_PROGRESSBAR_VERTICAL:
DrawProgress(cgContext, macRect, IsIndeterminateProgress(aFrame),
PR_FALSE, GetProgressValue(aFrame), aFrame);
PR_FALSE, GetProgressValue(aFrame));
break;
case NS_THEME_PROGRESSBAR_CHUNK:
@ -801,12 +751,12 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
case NS_THEME_TREEVIEW_TWISTY:
DrawButton(cgContext, kThemeDisclosureButton, macRect, PR_FALSE, IsDisabled(aFrame),
kThemeDisclosureRight, kThemeAdornmentNone, eventState, aFrame);
kThemeDisclosureRight, kThemeAdornmentNone, eventState);
break;
case NS_THEME_TREEVIEW_TWISTY_OPEN:
DrawButton(cgContext, kThemeDisclosureButton, macRect, PR_FALSE, IsDisabled(aFrame),
kThemeDisclosureDown, kThemeAdornmentNone, eventState, aFrame);
kThemeDisclosureDown, kThemeAdornmentNone, eventState);
break;
case NS_THEME_TREEVIEW_HEADER_CELL: {
@ -814,7 +764,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
DrawButton(cgContext, kThemeListHeaderButton, macRect, PR_FALSE, IsDisabled(aFrame),
sortDirection == eTreeSortDirection_Natural ? kThemeButtonOff : kThemeButtonOn,
sortDirection == eTreeSortDirection_Descending ?
kThemeAdornmentHeaderButtonSortUp : kThemeAdornmentNone, eventState, aFrame);
kThemeAdornmentHeaderButtonSortUp : kThemeAdornmentNone, eventState);
}
break;
@ -847,7 +797,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
NS_LITERAL_STRING("reverse"), eCaseMatters);
DrawScale(cgContext, macRect, IsDisabled(aFrame), eventState,
(aWidgetType == NS_THEME_SCALE_VERTICAL), reverse,
curpos, minpos, maxpos, aFrame);
curpos, minpos, maxpos);
}
break;
@ -918,20 +868,20 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
// HIThemeSetFill is not available on 10.3
CGContextSetRGBFillColor(cgContext, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(cgContext, macRect);
DrawFrame(cgContext, kHIThemeFrameListBox, macRect,
(IsDisabled(aFrame) || IsReadOnly(aFrame)), eventState);
DrawFrame(cgContext, kHIThemeFrameListBox,
macRect, (IsDisabled(aFrame) || IsReadOnly(aFrame)), eventState);
break;
case NS_THEME_TAB: {
DrawTab(cgContext, macRect,
IsDisabled(aFrame), IsSelectedTab(aFrame),
PR_TRUE, IsBottomTab(aFrame),
eventState, aFrame);
eventState);
}
break;
case NS_THEME_TAB_PANELS:
DrawTabPanel(cgContext, macRect, aFrame);
DrawTabPanel(cgContext, macRect);
break;
}