Skip to content

Commit

Permalink
bug 1311604 consider block flow direction in vertical writing mode na…
Browse files Browse the repository at this point in the history
…tive widget layout r=jfkthame

This follows the same approach of considering block flow for all widgets
(in addition to resizers) as done for other toolkits in
https://hg.mozilla.org/mozilla-central/rev/4a65cacf8a37#l3.10

MozReview-Commit-ID: Ca3SMs1k2Tj
  • Loading branch information
karlt committed Oct 20, 2016
1 parent 0b9b9a7 commit ba4cded
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
29 changes: 9 additions & 20 deletions widget/gtk/nsNativeThemeGTK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,15 @@ static void SetWidgetStateSafe(uint8_t *aSafeVector,
aSafeVector[key >> 3] |= (1 << (key & 7));
}

static GtkTextDirection GetTextDirection(nsIFrame* aFrame)
/* static */ GtkTextDirection
nsNativeThemeGTK::GetTextDirection(nsIFrame* aFrame)
{
if (!aFrame)
return GTK_TEXT_DIR_NONE;

switch (aFrame->StyleVisibility()->mDirection) {
case NS_STYLE_DIRECTION_RTL:
return GTK_TEXT_DIR_RTL;
case NS_STYLE_DIRECTION_LTR:
return GTK_TEXT_DIR_LTR;
}

return GTK_TEXT_DIR_NONE;
// IsFrameRTL() treats vertical-rl modes as right-to-left (in addition to
// horizontal text with direction=RTL), rather than just considering the
// text direction. GtkTextDirection does not have distinct values for
// vertical writing modes, but considering the block flow direction is
// important for resizers and scrollbar elements, at least.
return IsFrameRTL(aFrame) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
}

// Returns positive for negative margins (otherwise 0).
Expand Down Expand Up @@ -1119,14 +1115,7 @@ nsNativeThemeGTK::DrawWidgetBackground(nsRenderingContext* aContext,
{
GtkWidgetState state;
WidgetNodeType gtkWidgetType;
// For resizer drawing, we want IsFrameRTL, which treats vertical-rl modes
// as right-to-left (in addition to horizontal text with direction=RTL),
// rather than just considering the text direction.
// This will make resizers on vertically-oriented elements render properly.
GtkTextDirection direction =
aWidgetType == NS_THEME_RESIZER
? (IsFrameRTL(aFrame) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR)
: GetTextDirection(aFrame);
GtkTextDirection direction = GetTextDirection(aFrame);
gint flags;
if (!GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, &state,
&flags))
Expand Down
1 change: 1 addition & 0 deletions widget/gtk/nsNativeThemeGTK.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class nsNativeThemeGTK: private nsNativeTheme,
virtual ~nsNativeThemeGTK();

private:
GtkTextDirection GetTextDirection(nsIFrame* aFrame);
gint GetTabMarginPixels(nsIFrame* aFrame);
bool GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame,
WidgetNodeType& aGtkWidgetType,
Expand Down
2 changes: 1 addition & 1 deletion widget/nsNativeTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ nsNativeTheme::IsDisabled(nsIFrame* aFrame, EventStates aEventStates)
NS_LITERAL_STRING("true"), eCaseMatters);
}

bool
/* static */ bool
nsNativeTheme::IsFrameRTL(nsIFrame* aFrame)
{
if (!aFrame) {
Expand Down
2 changes: 1 addition & 1 deletion widget/nsNativeTheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class nsNativeTheme : public nsITimerCallback
bool IsDisabled(nsIFrame* aFrame, mozilla::EventStates aEventStates);

// RTL chrome direction
bool IsFrameRTL(nsIFrame* aFrame);
static bool IsFrameRTL(nsIFrame* aFrame);

bool IsHTMLContent(nsIFrame *aFrame);

Expand Down

0 comments on commit ba4cded

Please sign in to comment.