Bug 1376756 - gtk: while drawing nsTreeBodyFrame, fetch current row attributes for proper style rendering. r=karlt

This commit is contained in:
Samuel Thibault 2018-06-27 05:11:00 +03:00
parent c1c1de7ce8
commit 01084d60d8
5 changed files with 30 additions and 1 deletions

View File

@ -197,6 +197,13 @@ public:
bool GetVerticalOverflow() const { return mVerticalOverflow; }
bool GetHorizontalOverflow() const {return mHorizontalOverflow; }
// This returns the property array where atoms are stored for style during
// draw, whether the row currently being drawn is selected, hovered, etc.
const mozilla::AtomArray& GetPropertyArrayForCurrentDrawingItem()
{
return mScratchArray;
}
protected:
friend class nsOverflowChecker;

View File

@ -1820,7 +1820,10 @@ moz_gtk_treeview_expander_paint(GdkDrawable* drawable, GdkRectangle* rect,
/* Because the frame we get is of the entire treeview, we can't get the precise
* event state of one expander, thus rendering hover and active feedback useless. */
state_type = state->disabled ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
state_type = state->disabled ? GTK_STATE_INSENSITIVE :
state->inHover ? GTK_STATE_PRELIGHT :
state->selected ? GTK_STATE_SELECTED :
GTK_STATE_NORMAL;
TSOffsetStyleGCs(style, rect->x, rect->y);
gtk_paint_expander(style, drawable, state_type, cliprect, gTreeViewWidget, "treeview",

View File

@ -1390,6 +1390,13 @@ moz_gtk_treeview_expander_paint(cairo_t *cr, GdkRectangle* rect,
GtkStateFlags state_flags = state->disabled ? GTK_STATE_FLAG_INSENSITIVE :
GTK_STATE_FLAG_NORMAL;
if (state->inHover)
state_flags =
static_cast<GtkStateFlags>(state_flags|GTK_STATE_FLAG_PRELIGHT);
if (state->selected)
state_flags =
static_cast<GtkStateFlags>(state_flags|GTK_STATE_FLAG_SELECTED);
/* GTK_STATE_FLAG_ACTIVE controls expanded/colapsed state rendering
* in gtk_render_expander()
*/

View File

@ -23,6 +23,7 @@
typedef struct {
guint8 active;
guint8 focused;
guint8 selected;
guint8 inHover;
guint8 disabled;
guint8 isDefault;

View File

@ -19,6 +19,7 @@
#include "nsGfxCIID.h"
#include "nsTransform2D.h"
#include "nsMenuFrame.h"
#include "tree/nsTreeBodyFrame.h"
#include "prlink.h"
#include "nsGkAtoms.h"
#include "nsAttrValueInlines.h"
@ -281,6 +282,7 @@ nsNativeThemeGTK::GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame,
aState->disabled = IsDisabled(aFrame, eventState) || IsReadOnly(aFrame);
aState->active = eventState.HasState(NS_EVENT_STATE_ACTIVE);
aState->focused = eventState.HasState(NS_EVENT_STATE_FOCUS);
aState->selected = FALSE;
aState->inHover = eventState.HasState(NS_EVENT_STATE_HOVER);
aState->isDefault = IsDefaultButton(aFrame);
aState->canDefault = FALSE; // XXX fix me
@ -302,6 +304,15 @@ nsNativeThemeGTK::GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame,
aWidgetType == NS_THEME_MENULIST ||
aWidgetType == NS_THEME_MENULIST_BUTTON) {
aState->active &= aState->inHover;
} else if (aWidgetType == NS_THEME_TREETWISTY ||
aWidgetType == NS_THEME_TREETWISTYOPEN) {
nsTreeBodyFrame *treeBodyFrame = do_QueryFrame(aFrame);
if (treeBodyFrame) {
const mozilla::AtomArray& atoms =
treeBodyFrame->GetPropertyArrayForCurrentDrawingItem();
aState->selected = atoms.Contains(nsGkAtoms::selected);
aState->inHover = atoms.Contains(nsGkAtoms::hover);
}
}
if (IsFrameContentNodeInNamespace(aFrame, kNameSpaceID_XUL)) {