Bug 1139306: Fix margin sides for right-to-left scrollbars depending on the actual position of the scrollbar as determined by layout.scrollbar.side, r=tn

This commit is contained in:
Simon Montagu 2015-05-12 01:49:25 -07:00
parent d86f3dd45e
commit 9d7063633b
11 changed files with 45 additions and 26 deletions

View File

@ -30,19 +30,14 @@ html xul|scrollbar {
pointer-events: none;
}
/* Scrollbar code will reset the margin to the correct side depending on
where layout actually puts the scrollbar */
xul|scrollbar[orient="vertical"] {
-moz-margin-start: -8px;
margin-left: -8px;
min-width: 8px;
max-width: 8px;
}
/* workaround for bug 1119057: as -moz-margin-start may not work as expected,
* force a right margin value in RTL mode. */
[dir="rtl"] xul|scrollbar[root="true"][orient="vertical"] {
-moz-margin-start: unset;
margin-right: -8px;
}
xul|scrollbar[orient="vertical"] xul|thumb {
max-width: 6px !important;
min-width: 6px !important;

View File

@ -9,8 +9,10 @@ scrollbar {
padding: 2px;
}
/* Scrollbar code will reset the margin to the correct side depending on
where layout actually puts the scrollbar */
scrollbar[orient="vertical"] {
-moz-margin-start: -10px;
margin-left: -10px;
min-width: 10px;
max-width: 10px;
}

View File

@ -10,8 +10,10 @@ scrollbar {
padding: 2px;
}
/* Scrollbar code will reset the margin to the correct side depending on
where layout actually puts the scrollbar */
scrollbar[orient="vertical"] {
-moz-margin-start: -8px;
margin-left: -8px;
min-width: 8px;
max-width: 8px;
}

View File

@ -9,8 +9,10 @@ scrollbar {
padding: 2px;
}
/* Scrollbar code will reset the margin to the correct side depending on
where layout actually puts the scrollbar */
scrollbar[orient="vertical"] {
-moz-margin-start: -10px;
margin-left: -10px;
min-width: 10px;
max-width: 10px;
}

View File

@ -401,7 +401,7 @@ nsHTMLScrollFrame::TryLayout(ScrollReflowState* aState,
aState->mShowVScrollbar = aAssumeVScroll;
nsPoint scrollPortOrigin(aState->mComputedBorder.left,
aState->mComputedBorder.top);
if (!mHelper.IsScrollbarOnRight()) {
if (!IsScrollbarOnRight()) {
scrollPortOrigin.x += vScrollbarActualWidth;
}
mHelper.mScrollPort = nsRect(scrollPortOrigin, scrollPortSize);
@ -4275,7 +4275,7 @@ ScrollFrameHelper::IsScrollingActive(nsDisplayListBuilder* aBuilder) const
nsresult
nsXULScrollFrame::Layout(nsBoxLayoutState& aState)
{
bool scrollbarRight = mHelper.IsScrollbarOnRight();
bool scrollbarRight = IsScrollbarOnRight();
bool scrollbarBottom = true;
// get the content rect

View File

@ -898,6 +898,10 @@ public:
virtual void ScrollbarActivityStarted() const override;
virtual void ScrollbarActivityStopped() const override;
virtual bool IsScrollbarOnRight() const override {
return mHelper.IsScrollbarOnRight();
}
virtual void SetTransformingByAPZ(bool aTransforming) override {
mHelper.SetTransformingByAPZ(aTransforming);
}
@ -1295,6 +1299,10 @@ public:
virtual void ScrollbarActivityStarted() const override;
virtual void ScrollbarActivityStopped() const override;
virtual bool IsScrollbarOnRight() const override {
return mHelper.IsScrollbarOnRight();
}
virtual void SetTransformingByAPZ(bool aTransforming) override {
mHelper.SetTransformingByAPZ(aTransforming);
}

View File

@ -77,6 +77,8 @@ public:
*/
virtual void ScrollbarActivityStarted() const = 0;
virtual void ScrollbarActivityStopped() const = 0;
virtual bool IsScrollbarOnRight() const = 0;
};
#endif

View File

@ -72,6 +72,9 @@ public:
virtual nsIFrame* GetScrollbarBox(bool aVertical) override;
virtual void ScrollbarActivityStarted() const override {}
virtual void ScrollbarActivityStopped() const override {}
virtual bool IsScrollbarOnRight() const override {
return (StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR);
}
// nsIReflowCallback

View File

@ -169,6 +169,7 @@ nsScrollbarFrame::GetScrollbarMediator()
nsresult
nsScrollbarFrame::GetMargin(nsMargin& aMargin)
{
nsresult rv = NS_ERROR_FAILURE;
aMargin.SizeTo(0,0,0,0);
if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) {
@ -183,18 +184,24 @@ nsScrollbarFrame::GetMargin(nsMargin& aMargin)
aMargin.top = -presContext->DevPixelsToAppUnits(size.height);
}
else {
if (StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
aMargin.right = -presContext->DevPixelsToAppUnits(size.width);
}
else {
aMargin.left = -presContext->DevPixelsToAppUnits(size.width);
}
aMargin.left = -presContext->DevPixelsToAppUnits(size.width);
}
return NS_OK;
rv = NS_OK;
}
}
return nsBox::GetMargin(aMargin);
if (NS_FAILED(rv)) {
rv = nsBox::GetMargin(aMargin);
}
if (NS_SUCCEEDED(rv) && !IsHorizontal()) {
nsIScrollbarMediator* scrollFrame = GetScrollbarMediator();
if (scrollFrame && !scrollFrame->IsScrollbarOnRight()) {
Swap(aMargin.left, aMargin.right);
}
}
return rv;
}
void

View File

@ -154,6 +154,9 @@ public:
}
virtual void ScrollbarActivityStarted() const override;
virtual void ScrollbarActivityStopped() const override;
virtual bool IsScrollbarOnRight() const override {
return (StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR);
}
// Overridden from nsIFrame to cache our pres context.
virtual void Init(nsIContent* aContent,

View File

@ -33,11 +33,6 @@ xul|window xul|scrollbar[orient="vertical"] {
border: 0px solid transparent !important;
}
xul|window xul|scrollbar[orient="vertical"]:-moz-locale-dir(rtl) {
margin-left: 2px;
margin-right: -10px;
}
xul|window xul|scrollbar[orient="vertical"] xul|thumb {
max-width: 6px !important;
min-width: 6px !important;