bug 1311604 consider block flow direction in vertical writing mode native 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
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -144,29 +144,25 @@ static bool IsWidgetStateSafe(uint8_t* a
static void SetWidgetStateSafe(uint8_t *aSafeVector,
uint8_t aWidgetType,
GtkWidgetState *aWidgetState)
{
uint8_t key = GetWidgetStateKey(aWidgetType, aWidgetState);
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).
gint
nsNativeThemeGTK::GetTabMarginPixels(nsIFrame* aFrame)
{
nscoord margin =
IsBottomTab(aFrame) ? aFrame->GetUsedMargin().top
@@ -1114,24 +1110,17 @@ NS_IMETHODIMP
nsNativeThemeGTK::DrawWidgetBackground(nsRenderingContext* aContext,
nsIFrame* aFrame,
uint8_t aWidgetType,
const nsRect& aRect,
const nsRect& aDirtyRect)
{
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))
return NS_OK;
gfxContext* ctx = aContext->ThebesContext();
nsPresContext *presContext = aFrame->PresContext();
--- a/widget/gtk/nsNativeThemeGTK.h
+++ b/widget/gtk/nsNativeThemeGTK.h
@@ -69,16 +69,17 @@ public:
uint8_t aWidgetType) override;
nsNativeThemeGTK();
protected:
virtual ~nsNativeThemeGTK();
private:
+ GtkTextDirection GetTextDirection(nsIFrame* aFrame);
gint GetTabMarginPixels(nsIFrame* aFrame);
bool GetGtkWidgetAndState(uint8_t aWidgetType, nsIFrame* aFrame,
WidgetNodeType& aGtkWidgetType,
GtkWidgetState* aState, gint* aWidgetFlags);
bool GetExtraSizeForWidget(nsIFrame* aFrame, uint8_t aWidgetType,
nsIntMargin* aExtra);
void RefreshWidgetWindow(nsIFrame* aFrame);
--- a/widget/nsNativeTheme.cpp
+++ b/widget/nsNativeTheme.cpp
@@ -371,17 +371,17 @@ nsNativeTheme::IsDisabled(nsIFrame* aFra
// For XML/XUL elements, an attribute must be equal to the literal
// string "true" to be counted as true. An empty string should _not_
// be counted as true.
return content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
NS_LITERAL_STRING("true"), eCaseMatters);
}
-bool
+/* static */ bool
nsNativeTheme::IsFrameRTL(nsIFrame* aFrame)
{
if (!aFrame) {
return false;
}
WritingMode wm = aFrame->GetWritingMode();
return !(wm.IsVertical() ? wm.IsVerticalLR() : wm.IsBidiLTR());
}
--- a/widget/nsNativeTheme.h
+++ b/widget/nsNativeTheme.h
@@ -55,17 +55,17 @@ class nsNativeTheme : public nsITimerCal
bool IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame,
uint8_t aWidgetType);
// Accessors to widget-specific state information
bool IsDisabled(nsIFrame* aFrame, mozilla::EventStates aEventStates);
// RTL chrome direction
- bool IsFrameRTL(nsIFrame* aFrame);
+ static bool IsFrameRTL(nsIFrame* aFrame);
bool IsHTMLContent(nsIFrame *aFrame);
// button:
bool IsDefaultButton(nsIFrame* aFrame) {
return CheckBooleanAttr(aFrame, nsGkAtoms::_default);
}