Skip to content

Commit

Permalink
Don't rely exclusively on scroll events to determine content resolution.
Browse files Browse the repository at this point in the history
Default to 1 rather 0 so there's a reasonable default in the abscense of
any events and update the resolution when the scroll area is update as
scroll events are not always received (or accurate it seems but those
come later and scroll area updates are infrequent so this doesn't help
with that).
  • Loading branch information
adenexter committed Mar 16, 2020
1 parent 64340fd commit 5d8a41d
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/qmozview_p.cpp
Expand Up @@ -809,6 +809,17 @@ void QMozViewPrivate::OnFirstPaint(int32_t aX, int32_t aY)

void QMozViewPrivate::OnScrolledAreaChanged(unsigned int aWidth, unsigned int aHeight)
{
// Normally these come from HandleScrollEvent but for some documents no such event is generated.

const float contentResoution = contentWindowSize(mMozWindow).width() / aWidth;
if (qFuzzyIsNull(mContentResolution) && !qFuzzyIsNull(contentResoution)) {
mContentResolution = contentResoution;
}

if (mContentRect.isEmpty()) {
mContentRect.setSize(QSizeF(aWidth, aHeight));
}

UpdateScrollArea(aWidth * mContentResolution, aHeight * mContentResolution,
mScrollableOffset.x(), mScrollableOffset.y());
}
Expand Down Expand Up @@ -898,17 +909,23 @@ bool QMozViewPrivate::HandleScrollEvent(bool aIsRootScrollFrame, const gfxRect &
if (!aIsRootScrollFrame)
return false;

mContentResolution = contentWindowSize(mMozWindow).width() / aContentRect.width;

if (mContentRect.x() != aContentRect.x || mContentRect.y() != aContentRect.y ||
mContentRect.width() != aContentRect.width ||
mContentRect.height() != aContentRect.height) {
mContentRect.setRect(aContentRect.x, aContentRect.y, aContentRect.width, aContentRect.height);
mViewIface->viewAreaChanged();
}

UpdateScrollArea(aScrollableSize.width * mContentResolution, aScrollableSize.height * mContentResolution,
aContentRect.x * mContentResolution, aContentRect.y * mContentResolution);
float contentResoution = contentWindowSize(mMozWindow).width() / aContentRect.width;
if (!qFuzzyIsNull(contentResoution)) {
mContentResolution = contentResoution;
UpdateScrollArea(
aScrollableSize.width * mContentResolution,
aScrollableSize.height * mContentResolution,
aContentRect.x * mContentResolution,
aContentRect.y * mContentResolution);
}

return false;
}

Expand Down

0 comments on commit 5d8a41d

Please sign in to comment.