Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[qtmozembed] Provide a separate method for setting toolbar height. Contributes to JB#55896 #13

Merged
merged 2 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/qmozview_defined_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ Q_DECLARE_METATYPE(QMozReturnValue) \
void setChrome(bool value); \
qreal chromeGestureThreshold() const; \
void setChromeGestureThreshold(qreal value); \
int dynamicToolbarHeight() const; \
void setDynamicToolbarHeight(int height); \
QMargins margins() const; \
void setMargins(QMargins); \
Q_INVOKABLE void scrollTo(int x, int y); \
Expand Down Expand Up @@ -204,6 +206,7 @@ Q_DECLARE_METATYPE(QMozReturnValue) \
void chromeGestureEnabledChanged(); \
void chromeChanged(); \
void chromeGestureThresholdChanged(); \
void dynamicToolbarHeightChanged(); \
void marginsChanged(); \
void desktopModeChanged(); \
void parentIdChanged(); \
Expand Down
31 changes: 24 additions & 7 deletions src/qmozview_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ QMozViewPrivate::QMozViewPrivate(IMozQViewIface *aViewIface, QObject *publicPtr)
, mBackgroundColor(Qt::white)
, mTopMargin(0.0)
, mBottomMargin(0.0)
, mDynamicToolbarHeight(0)
, mTempTexture(nullptr)
, mEnabled(true)
, mChromeGestureEnabled(true)
Expand Down Expand Up @@ -789,6 +790,11 @@ void QMozViewPrivate::ViewInitialized()
mSize = mMozWindow->size();
}

if (mDirtyState & DirtyDynamicToolbarHeight) {
mView->SetDynamicToolbarHeight(mDynamicToolbarHeight);
mDirtyState &= ~DirtyDynamicToolbarHeight;
}

if (mDirtyState & DirtyMargin) {
mView->SetMargins(mMargins.top(), mMargins.right(), mMargins.bottom(), mMargins.left());
mViewIface->marginsChanged();
Expand All @@ -811,6 +817,19 @@ void QMozViewPrivate::SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, uint8_
mViewIface->backgroundColorChanged();
}

void QMozViewPrivate::setDynamicToolbarHeight(const int height)
{
if (height != mDynamicToolbarHeight) {
mDynamicToolbarHeight = height;

if (mViewInitialized) {
mView->SetDynamicToolbarHeight(height);
} else {
mDirtyState |= DirtyDynamicToolbarHeight;
}
}
}

void QMozViewPrivate::setMargins(const QMargins &margins, bool updateTopBottom)
{
if (margins != mMargins) {
Expand Down Expand Up @@ -1026,13 +1045,6 @@ void QMozViewPrivate::setThrottlePainting(bool aThrottle)
}
}

void QMozViewPrivate::SetVirtualKeyboardHeight(int aHeight)
{
if (mViewInitialized) {
mView->SetVirtualKeyboardHeight(aHeight);
}
}

void QMozViewPrivate::IMENotification(int aIstate, bool aOpen, int aCause, int aFocusChange,
const char16_t *inputType, const char16_t *inputMode)
{
Expand Down Expand Up @@ -1096,6 +1108,11 @@ void QMozViewPrivate::OnTitleChanged(const char16_t *aTitle)
mViewIface->titleChanged();
}

void QMozViewPrivate::OnDynamicToolbarHeightChanged()
{
mViewIface->dynamicToolbarHeightChanged();
}

bool QMozViewPrivate::HandleScrollEvent(bool aIsRootScrollFrame, const gfxRect &aContentRect, const gfxSize &aScrollableSize)
{
// aIsRootScrollFrame makes it possible to handle chrome gesture also in case that we have
Expand Down
9 changes: 6 additions & 3 deletions src/qmozview_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ class QMozViewPrivate : public QObject,
enum DirtyStateBit {
DirtySize = 0x0001,
DirtyMargin = 0x0002,
DirtyDotsPerInch = 0x0004,
DirtyActive = 0x0008,
DirtyDynamicToolbarHeight = 0x0004,
DirtyDotsPerInch = 0x0008,
DirtyActive = 0x0010,
};

Q_DECLARE_FLAGS(DirtyState, DirtyStateBit)
Expand All @@ -78,18 +79,19 @@ class QMozViewPrivate : public QObject,
void IMENotification(int aIstate, bool aOpen, int aCause, int aFocusChange,
const char16_t *inputType, const char16_t *inputMode) override;
void OnTitleChanged(const char16_t *aTitle) override;
void OnDynamicToolbarHeightChanged() override;
bool HandleLongTap(const nsIntPoint &aPoint) override;
bool HandleSingleTap(const nsIntPoint &aPoint) override;
bool HandleDoubleTap(const nsIntPoint &aPoint) override;
bool HandleScrollEvent(bool aIsRootScrollFrame, const gfxRect &aContentRect, const gfxSize &aScrollableSize) override;
void OnHttpUserAgentUsed(const char16_t *aHttpUserAgent);

// Starting from here these are QMozViewPrivate methods.
void setDynamicToolbarHeight(const int height);
void setMargins(const QMargins &margins, bool updateTopBottom);
void setIsFocused(bool aIsFocused);
void setDesktopMode(bool aDesktopMode);
void setThrottlePainting(bool aThrottle);
void SetVirtualKeyboardHeight(int aHeight);
void updateScrollArea(unsigned int aWidth, unsigned int aHeight, float aPosX, float aPosY);
void testFlickingMode(QTouchEvent *event);
void handleTouchEnd(bool &draggingChanged, bool &pinchingChanged);
Expand Down Expand Up @@ -171,6 +173,7 @@ public Q_SLOTS:
QColor mBackgroundColor;
qreal mTopMargin;
qreal mBottomMargin;
int mDynamicToolbarHeight;
QMargins mMargins;
QImage mTempBufferImage;
QSGTexture *mTempTexture;
Expand Down
6 changes: 6 additions & 0 deletions src/qmozview_templated_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class IMozQViewIface
virtual void draggingChanged() = 0;
virtual void movingChanged() = 0;
virtual void pinchingChanged() = 0;
virtual void dynamicToolbarHeightChanged() = 0;
virtual void marginsChanged() = 0;
virtual void scrollableSizeChanged() = 0;

Expand Down Expand Up @@ -226,6 +227,11 @@ class IMozQView : public IMozQViewIface
Q_EMIT view.pinchingChanged();
}

void dynamicToolbarHeightChanged()
{
Q_EMIT view.dynamicToolbarHeightChanged();
}

void marginsChanged()
{
Q_EMIT view.marginsChanged();
Expand Down
11 changes: 10 additions & 1 deletion src/qopenglwebpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ void QOpenGLWebPage::setVirtualKeyboardHeight(int height)
{
if (height != m_virtualKeyboardHeight) {
m_virtualKeyboardHeight = height;
d->SetVirtualKeyboardHeight(height);
Q_EMIT virtualKeyboardHeightChanged();
}
}
Expand Down Expand Up @@ -490,6 +489,16 @@ qreal QOpenGLWebPage::contentHeight() const
return d->mScrollableSize.height();
}

int QOpenGLWebPage::dynamicToolbarHeight() const
{
return d->mDynamicToolbarHeight;
}

void QOpenGLWebPage::setDynamicToolbarHeight(int height)
{
d->setDynamicToolbarHeight(height);
}

QMargins QOpenGLWebPage::margins() const
{
return d->mMargins;
Expand Down