зеркало из https://github.com/mozilla/pjs.git
Bug 385686, No Focus indicator for radios/checkboxes/textboxes on Linux, Patch by Michael Ventnor, r+sr=roc
This commit is contained in:
Родитель
a290d344b5
Коммит
fb65aa79a9
|
@ -599,9 +599,6 @@ moz_gtk_toggle_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|||
GtkWidget *w;
|
||||
GtkStyle *style;
|
||||
|
||||
if (state->focused && state_type == GTK_STATE_NORMAL)
|
||||
state_type = GTK_STATE_PRELIGHT;
|
||||
|
||||
if (isradio) {
|
||||
moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
|
||||
w = gRadiobuttonWidget;
|
||||
|
@ -636,10 +633,20 @@ moz_gtk_toggle_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|||
gtk_paint_option(style, drawable, state_type, shadow_type, cliprect,
|
||||
gRadiobuttonWidget, "radiobutton", x, y,
|
||||
width, height);
|
||||
if (state->focused) {
|
||||
gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
|
||||
gRadiobuttonWidget, "radiobutton", rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
}
|
||||
}
|
||||
else {
|
||||
gtk_paint_check(style, drawable, state_type, shadow_type, cliprect,
|
||||
gCheckboxWidget, "checkbutton", x, y, width, height);
|
||||
if (state->focused) {
|
||||
gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
|
||||
gRadiobuttonWidget, "checkbutton", rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
}
|
||||
}
|
||||
|
||||
return MOZ_GTK_SUCCESS;
|
||||
|
|
|
@ -228,72 +228,77 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
|||
aState->isDefault = FALSE; // XXX fix me
|
||||
aState->canDefault = FALSE; // XXX fix me
|
||||
|
||||
// For these widget types, some element (either a child or parent)
|
||||
// actually has element focus, so we check the focused attribute
|
||||
// to see whether to draw in the focused state.
|
||||
if (aWidgetType == NS_THEME_TEXTFIELD ||
|
||||
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
|
||||
aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD ||
|
||||
aWidgetType == NS_THEME_RADIO_CONTAINER ||
|
||||
aWidgetType == NS_THEME_RADIO_LABEL ||
|
||||
IsRadioWidgetType(aWidgetType)) {
|
||||
aState->focused = IsFocused(aFrame);
|
||||
}
|
||||
|
||||
if (aWidgetType == NS_THEME_SCROLLBAR_THUMB_VERTICAL ||
|
||||
aWidgetType == NS_THEME_SCROLLBAR_THUMB_HORIZONTAL) {
|
||||
// for scrollbars we need to go up two to go from the thumb to
|
||||
// the slider to the actual scrollbar object
|
||||
nsIFrame *tmpFrame = aFrame->GetParent()->GetParent();
|
||||
|
||||
aState->curpos = CheckIntAttr(tmpFrame, nsWidgetAtoms::curpos);
|
||||
aState->maxpos = CheckIntAttr(tmpFrame, nsWidgetAtoms::maxpos);
|
||||
}
|
||||
|
||||
// In order to simulate native GTK scrollbar click behavior, we set the
|
||||
// active attribute on the element to true if it's pressed with any mouse
|
||||
// button. This allows us to show that it's active without setting :active
|
||||
if (aWidgetType == NS_THEME_SCROLLBAR_BUTTON_UP ||
|
||||
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_DOWN ||
|
||||
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_LEFT ||
|
||||
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_RIGHT) {
|
||||
if (CheckBooleanAttr(aFrame, nsWidgetAtoms::active))
|
||||
aState->active = PR_TRUE;
|
||||
}
|
||||
|
||||
// menu item state is determined by the attribute "_moz-menuactive",
|
||||
// and not by the mouse hovering (accessibility). as a special case,
|
||||
// menus which are children of a menu bar are only marked as prelight
|
||||
// if they are open, not on normal hover.
|
||||
|
||||
if (aWidgetType == NS_THEME_MENUITEM ||
|
||||
aWidgetType == NS_THEME_CHECKMENUITEM ||
|
||||
aWidgetType == NS_THEME_RADIOMENUITEM) {
|
||||
PRBool isTopLevel = PR_FALSE;
|
||||
nsIMenuFrame *menuFrame;
|
||||
CallQueryInterface(aFrame, &menuFrame);
|
||||
|
||||
if (menuFrame) {
|
||||
nsIMenuParent *menuParent = menuFrame->GetMenuParent();
|
||||
if (menuParent)
|
||||
menuParent->IsMenuBar(isTopLevel);
|
||||
if (aFrame && aFrame->GetContent()->IsNodeOfType(nsINode::eXUL)) {
|
||||
// For these widget types, some element (either a child or parent)
|
||||
// actually has element focus, so we check the focused attribute
|
||||
// to see whether to draw in the focused state.
|
||||
if (aWidgetType == NS_THEME_TEXTFIELD ||
|
||||
aWidgetType == NS_THEME_TEXTFIELD_MULTILINE ||
|
||||
aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD ||
|
||||
aWidgetType == NS_THEME_RADIO_CONTAINER ||
|
||||
aWidgetType == NS_THEME_RADIO_LABEL) {
|
||||
aState->focused = IsFocused(aFrame);
|
||||
} else if (IsRadioWidgetType(aWidgetType) ||
|
||||
IsCheckboxWidgetType(aWidgetType)) {
|
||||
// In XUL, checkboxes and radios shouldn't have focus rings, their labels do
|
||||
aState->focused = FALSE;
|
||||
}
|
||||
|
||||
if (isTopLevel) {
|
||||
PRBool isOpen;
|
||||
menuFrame->MenuIsOpen(isOpen);
|
||||
aState->inHover = isOpen;
|
||||
} else {
|
||||
aState->inHover = CheckBooleanAttr(aFrame, nsWidgetAtoms::mozmenuactive);
|
||||
if (aWidgetType == NS_THEME_SCROLLBAR_THUMB_VERTICAL ||
|
||||
aWidgetType == NS_THEME_SCROLLBAR_THUMB_HORIZONTAL) {
|
||||
// for scrollbars we need to go up two to go from the thumb to
|
||||
// the slider to the actual scrollbar object
|
||||
nsIFrame *tmpFrame = aFrame->GetParent()->GetParent();
|
||||
|
||||
aState->curpos = CheckIntAttr(tmpFrame, nsWidgetAtoms::curpos);
|
||||
aState->maxpos = CheckIntAttr(tmpFrame, nsWidgetAtoms::maxpos);
|
||||
}
|
||||
|
||||
aState->active = FALSE;
|
||||
|
||||
if (aWidgetType == NS_THEME_CHECKMENUITEM ||
|
||||
// In order to simulate native GTK scrollbar click behavior, we set the
|
||||
// active attribute on the element to true if it's pressed with any mouse
|
||||
// button. This allows us to show that it's active without setting :active
|
||||
if (aWidgetType == NS_THEME_SCROLLBAR_BUTTON_UP ||
|
||||
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_DOWN ||
|
||||
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_LEFT ||
|
||||
aWidgetType == NS_THEME_SCROLLBAR_BUTTON_RIGHT) {
|
||||
if (CheckBooleanAttr(aFrame, nsWidgetAtoms::active))
|
||||
aState->active = PR_TRUE;
|
||||
}
|
||||
|
||||
// menu item state is determined by the attribute "_moz-menuactive",
|
||||
// and not by the mouse hovering (accessibility). as a special case,
|
||||
// menus which are children of a menu bar are only marked as prelight
|
||||
// if they are open, not on normal hover.
|
||||
|
||||
if (aWidgetType == NS_THEME_MENUITEM ||
|
||||
aWidgetType == NS_THEME_CHECKMENUITEM ||
|
||||
aWidgetType == NS_THEME_RADIOMENUITEM) {
|
||||
*aWidgetFlags = aFrame && aFrame->GetContent()->
|
||||
AttrValueIs(kNameSpaceID_None, nsWidgetAtoms::checked,
|
||||
nsWidgetAtoms::_true, eIgnoreCase);
|
||||
PRBool isTopLevel = PR_FALSE;
|
||||
nsIMenuFrame *menuFrame;
|
||||
CallQueryInterface(aFrame, &menuFrame);
|
||||
|
||||
if (menuFrame) {
|
||||
nsIMenuParent *menuParent = menuFrame->GetMenuParent();
|
||||
if (menuParent)
|
||||
menuParent->IsMenuBar(isTopLevel);
|
||||
}
|
||||
|
||||
if (isTopLevel) {
|
||||
PRBool isOpen;
|
||||
menuFrame->MenuIsOpen(isOpen);
|
||||
aState->inHover = isOpen;
|
||||
} else {
|
||||
aState->inHover = CheckBooleanAttr(aFrame, nsWidgetAtoms::mozmenuactive);
|
||||
}
|
||||
|
||||
aState->active = FALSE;
|
||||
|
||||
if (aWidgetType == NS_THEME_CHECKMENUITEM ||
|
||||
aWidgetType == NS_THEME_RADIOMENUITEM) {
|
||||
*aWidgetFlags = aFrame && aFrame->GetContent()->
|
||||
AttrValueIs(kNameSpaceID_None, nsWidgetAtoms::checked,
|
||||
nsWidgetAtoms::_true, eIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче