From 19eb5fe1eec1497b6a1b55ceb488c55e0c243aef Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Thu, 15 Sep 2016 10:41:36 +0100 Subject: [PATCH] Bug 1302389 - patch 2 - Add ScrollFrameHelper::IsBidiLTR to return the inline-bidi direction, as opposed to physical LTR-ness, and use this in GetScrolledFrameDir(). r=dholbert --- layout/generic/nsGfxScrollFrame.cpp | 11 ++++------- layout/generic/nsGfxScrollFrame.h | 14 +++++++++++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index af065c2906f8..e14d2a8f633f 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -4918,11 +4918,9 @@ void ScrollFrameHelper::PostOverflowEvent() rpc->AddWillPaintObserver(mAsyncScrollPortEvent.get()); } -bool -ScrollFrameHelper::IsPhysicalLTR() const +nsIFrame* +ScrollFrameHelper::GetFrameForDir() const { - //TODO make bidi code set these from preferences - nsIFrame *frame = mOuter; // XXX This is a bit on the slow side. if (mIsRoot) { @@ -4946,8 +4944,7 @@ ScrollFrameHelper::IsPhysicalLTR() const } } - WritingMode wm = frame->GetWritingMode(); - return wm.IsVertical() ? wm.IsVerticalLR() : wm.IsBidiLTR(); + return frame; } bool @@ -5822,7 +5819,7 @@ ScrollFrameHelper::GetScrolledFrameDir() const } } - return IsPhysicalLTR() ? NS_STYLE_DIRECTION_LTR : NS_STYLE_DIRECTION_RTL; + return IsBidiLTR() ? NS_STYLE_DIRECTION_LTR : NS_STYLE_DIRECTION_RTL; } nsRect diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index d32e7ae162b3..cf3bff41533e 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -329,7 +329,19 @@ public: nsMargin GetDesiredScrollbarSizes(nsBoxLayoutState* aState); nscoord GetNondisappearingScrollbarWidth(nsBoxLayoutState* aState, mozilla::WritingMode aVerticalWM); - bool IsPhysicalLTR() const; + bool IsPhysicalLTR() const { + WritingMode wm = GetFrameForDir()->GetWritingMode(); + return wm.IsVertical() ? wm.IsVerticalLR() : wm.IsBidiLTR(); + } + bool IsBidiLTR() const { + nsIFrame* frame = GetFrameForDir(); + return frame->StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR; + } +private: + nsIFrame* GetFrameForDir() const; // helper for Is{Physical,Bidi}LTR to find + // the frame whose directionality we use + +public: bool IsScrollbarOnRight() const; bool IsScrollingActive(nsDisplayListBuilder* aBuilder) const; bool IsMaybeScrollingActive() const;