Skip to content

Commit

Permalink
Increase the margin of error the scroll boundary properties.
Browse files Browse the repository at this point in the history
The x and y position after zooming in and out again often falls not
quite on zero by a margin greater the the scroll epsilon which meant
a scroll position which by all appearances was at a boundary reported
otherwise.

The ScrollOffset reported by gecko is an integer and will return exactly
0 in the same circumstances, but without a corresponding width and
height it's only good for the top and left edges.
  • Loading branch information
adenexter committed Mar 16, 2020
1 parent 8c0e5d9 commit 64340fd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/qmozview_p.cpp
Expand Up @@ -37,6 +37,7 @@
#endif

#define SCROLL_EPSILON 0.001
#define SCROLL_BOUNDARY_EPSILON 0.05

using namespace mozilla;
using namespace mozilla::embedlite;
Expand Down Expand Up @@ -210,10 +211,10 @@ void QMozViewPrivate::UpdateScrollArea(unsigned int aWidth, unsigned int aHeight
bool oldAXE = mAtXEnd;
bool oldAYB = mAtYBeginning;
bool oldAYE = mAtYEnd;
mAtXBeginning = aPosX == 0 || gfx::FuzzyEqual(0+1.0, aPosX+1.0, SCROLL_EPSILON);
mAtXEnd = (aPosX + (mContentResolution * mContentRect.width()) + SCROLL_EPSILON) >= mScrollableSize.width();
mAtYBeginning = aPosY == 0 || gfx::FuzzyEqual(0+1.0, aPosY+1.0, SCROLL_EPSILON);
mAtYEnd = (aPosY + (mContentResolution * mContentRect.height()) + SCROLL_EPSILON) >= mScrollableSize.height();
mAtXBeginning = aPosX == 0 || gfx::FuzzyEqual(0+1.0, aPosX+1.0, SCROLL_BOUNDARY_EPSILON);
mAtXEnd = (aPosX + (mContentResolution * mContentRect.width()) + SCROLL_BOUNDARY_EPSILON) >= mScrollableSize.width();
mAtYBeginning = aPosY == 0 || gfx::FuzzyEqual(0+1.0, aPosY+1.0, SCROLL_BOUNDARY_EPSILON);
mAtYEnd = (aPosY + (mContentResolution * mContentRect.height()) + SCROLL_BOUNDARY_EPSILON) >= mScrollableSize.height();
if (oldAXB != mAtXBeginning) mViewIface->atXBeginningChanged();
if (oldAXE != mAtXEnd) mViewIface->atXEndChanged();
if (oldAYB != mAtYBeginning) mViewIface->atYBeginningChanged();
Expand Down

0 comments on commit 64340fd

Please sign in to comment.