Bug 1525075 - Use the ICB size for Element.{clientWidth, clientHeight} instead of expanded the layout viewport size. r=botond

This is what Chrome does.

documentElement-clientWidth-on-minimum-scale-size.tentative.html was the test
case for this but unfortunately it was disabled in bug 1515043. And it seems
that the test case failed on Android in the first place.

Differential Revision: https://phabricator.services.mozilla.com/D19461

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Hiroyuki Ikezoe 2019-02-13 23:47:32 +00:00
Родитель 719b50bee3
Коммит ff820309e3
5 изменённых файлов: 36 добавлений и 7 удалений

Просмотреть файл

@ -977,7 +977,11 @@ nsRect Element::GetClientAreaRect() {
nsIScrollableFrame* sf = GetScrollFrame(&frame);
if (sf) {
return sf->GetScrollPortRect();
nsRect scrollPort = sf->GetScrollPortRect();
// The scroll port value might be expanded to the minimum scale size, we
// should limit the size to the ICB in such cases.
scrollPort.SizeTo(sf->GetLayoutSize());
return scrollPort;
}
if (frame &&

Просмотреть файл

@ -380,9 +380,14 @@ bool nsHTMLScrollFrame::TryLayout(ScrollReflowInput* aState,
? mHelper.mMinimumScaleSize
: aState->mInsideBorderSize;
nsSize scrollPortSize =
const nsSize scrollPortSize =
nsSize(std::max(0, layoutSize.width - vScrollbarDesiredWidth),
std::max(0, layoutSize.height - hScrollbarDesiredHeight));
if (mHelper.mIsUsingMinimumScaleSize) {
mHelper.mICBSize =
nsSize(std::max(0, aState->mInsideBorderSize.width - vScrollbarDesiredWidth),
std::max(0, aState->mInsideBorderSize.height - hScrollbarDesiredHeight));
}
nsSize visualViewportSize = scrollPortSize;
nsIPresShell* presShell = PresShell();

Просмотреть файл

@ -195,6 +195,12 @@ class ScrollFrameHelper : public nsIReflowCallback {
*/
void UpdateScrollbarPosition();
nsSize GetLayoutSize() const {
if (mIsUsingMinimumScaleSize) {
return mICBSize;
}
return mScrollPort.Size();
}
nsRect GetScrollPortRect() const { return mScrollPort; }
nsPoint GetScrollPosition() const {
return mScrollPort.TopLeft() - mScrolledFrame->GetPosition();
@ -563,6 +569,10 @@ class ScrollFrameHelper : public nsIReflowCallback {
nsRect mScrollPort;
nsSize mMinimumScaleSize;
// Stores the ICB size for the root document if this frame is using the
// minimum scale size for |mScrollPort|.
nsSize mICBSize;
// Where we're currently scrolling to, if we're scrolling asynchronously.
// If we're not in the middle of an asynchronous scroll then this is
// just the current scroll position. ScrollBy will choose its
@ -888,6 +898,9 @@ class nsHTMLScrollFrame : public nsContainerFrame,
nsBoxLayoutState bls(aPresContext, aRC, 0);
return mHelper.GetNondisappearingScrollbarWidth(&bls, aWM);
}
virtual nsSize GetLayoutSize() const override {
return mHelper.GetLayoutSize();
}
virtual nsRect GetScrolledRect() const override {
return mHelper.GetScrolledRect();
}
@ -1362,6 +1375,9 @@ class nsXULScrollFrame final : public nsBoxFrame,
nsBoxLayoutState bls(aPresContext, aRC, 0);
return mHelper.GetNondisappearingScrollbarWidth(&bls, aWM);
}
virtual nsSize GetLayoutSize() const override {
return mHelper.GetLayoutSize();
}
virtual nsRect GetScrolledRect() const override {
return mHelper.GetScrolledRect();
}

Просмотреть файл

@ -110,6 +110,15 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
virtual nscoord GetNondisappearingScrollbarWidth(
nsPresContext* aPresContext, gfxContext* aRC,
mozilla::WritingMode aWM) = 0;
/**
* Get the layout size of this frame.
* Note that this is a value which is not expanded by the minimum scale size.
* For scroll frames other than the root content document's scroll frame, this
* value will be the same as GetScrollPortRect().Size().
*
* This value is used for Element.clientWidth and clientHeight.
*/
virtual nsSize GetLayoutSize() const = 0;
/**
* GetScrolledRect is designed to encapsulate deciding which
* directions of overflow should be reachable by scrolling and which

Просмотреть файл

@ -1,5 +0,0 @@
[documentElement-clientWidth-on-minimum-scale-size.tentative.html]
[documentElement clientWidth should be equal to device-width even if overflow:hidden region is visible]
expected:
if (os == "android"): FAIL