Skip to content

Commit

Permalink
[embedlite] Fix scroll event pipeline. Fixes JB#37171
Browse files Browse the repository at this point in the history
  • Loading branch information
rainemak committed Dec 5, 2018
1 parent c4df861 commit fbd5227
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 27 deletions.
9 changes: 5 additions & 4 deletions embedding/embedlite/EmbedLiteContentController.h
Expand Up @@ -64,13 +64,14 @@ class EmbedLiteContentController
uint64_t aInputBlockId) = 0;

/**
* Requests sending a mozbrowserasyncscroll domevent to embedder.
* Requests handling a scroll event.
* |aIsRootScrollFrame| is root scroll frame
* |aContentRect| is in CSS pixels, relative to the current cssPage.
* |aScrollableSize| is the current content width/height in CSS pixels.
*/
virtual void SendAsyncScrollDOMEvent(bool aIsRoot,
const CSSRect &aContentRect,
const CSSSize &aScrollableSize) = 0;
virtual void HandleScrollEvent(bool aIsRootScrollFrame,
const CSSRect &aContentRect,
const CSSSize &aScrollableSize) = 0;

EmbedLiteContentController() {}

Expand Down
5 changes: 3 additions & 2 deletions embedding/embedlite/EmbedLiteView.h
Expand Up @@ -47,6 +47,9 @@ class EmbedLiteViewListener
virtual void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {}
virtual void OnWindowCloseRequested(void) {}

virtual bool HandleScrollEvent(bool aIsRootScrollFrame, const gfxRect& aContentRect,
const gfxSize& aScrollableSize) { return false; }

virtual void IMENotification(int aEnabled, bool aOpen, int aCause, int aFocusChange, const char16_t* inputType, const char16_t* inputMode) {}
virtual void GetIMEStatus(int32_t* aIMEEnabled, int32_t* aIMEOpen, intptr_t* aNativeIMEContext) {}

Expand All @@ -56,8 +59,6 @@ class EmbedLiteViewListener
virtual bool HandleSingleTap(const nsIntPoint& aPoint) { return false; }
virtual bool HandleLongTap(const nsIntPoint& aPoint) { return false; }
virtual bool AcknowledgeScrollUpdate(const uint32_t& aViewID, const uint32_t& aScrollGeneration) { return false; }
virtual bool SendAsyncScrollDOMEvent(const gfxRect& aContentRect,
const gfxSize& aScrollableSize) { return false; }
};

class EmbedLiteApp;
Expand Down
2 changes: 1 addition & 1 deletion embedding/embedlite/PEmbedLiteView.ipdl
Expand Up @@ -42,7 +42,7 @@ child:
SetMargins(int top, int right, int bottom, int left);
SuspendTimeouts();
ResumeTimeouts();
AsyncScrollDOMEvent(gfxRect contentRect, gfxSize scrollSize);
HandleScrollEvent(bool isRootScrollFrame, gfxRect contentRect, gfxSize scrollSize);

UpdateFrame(FrameMetrics frame) compress;
HandleDoubleTap(CSSPoint aPoint, Modifiers aModifiers, ScrollableLayerGuid aGuid);
Expand Down
7 changes: 4 additions & 3 deletions embedding/embedlite/embedshared/EmbedLiteViewBaseChild.cpp
Expand Up @@ -735,13 +735,14 @@ EmbedLiteViewBaseChild::RemoveGeckoContentListener(EmbedLiteContentController* l
}

bool
EmbedLiteViewBaseChild::RecvAsyncScrollDOMEvent(const gfxRect& contentRect,
const gfxSize& scrollSize)
EmbedLiteViewBaseChild::RecvHandleScrollEvent(const bool &isRootScrollFrame,
const gfxRect& contentRect,
const gfxSize& scrollSize)
{
mozilla::CSSRect rect(contentRect.x, contentRect.y, contentRect.width, contentRect.height);
mozilla::CSSSize size(scrollSize.width, scrollSize.height);
for (unsigned int i = 0; i < mControllerListeners.Length(); i++) {
mControllerListeners[i]->SendAsyncScrollDOMEvent(0, rect, size);
mControllerListeners[i]->HandleScrollEvent(isRootScrollFrame, rect, size);
}

if (sPostAZPCAsJson.scroll) {
Expand Down
4 changes: 2 additions & 2 deletions embedding/embedlite/embedshared/EmbedLiteViewBaseChild.h
Expand Up @@ -130,8 +130,8 @@ class EmbedLiteViewBaseChild : public PEmbedLiteViewChild,
virtual bool RecvSuspendTimeouts() override;
virtual bool RecvResumeTimeouts() override;
virtual bool RecvLoadFrameScript(const nsString&) override;
virtual bool RecvAsyncScrollDOMEvent(const gfxRect& contentRect,
const gfxSize& scrollSize) override;
virtual bool RecvHandleScrollEvent(const bool &isRootScrollFrame, const gfxRect& contentRect,
const gfxSize& scrollSize) override;

virtual bool RecvUpdateFrame(const mozilla::layers::FrameMetrics& aFrameMetrics) override;
virtual bool RecvHandleDoubleTap(const CSSPoint&, const Modifiers& aModifiers,
Expand Down
32 changes: 20 additions & 12 deletions embedding/embedlite/embedthread/EmbedContentController.cpp
Expand Up @@ -98,31 +98,34 @@ void EmbedContentController::HandleLongTap(const CSSPoint& aPoint,
}

/**
* Requests sending a mozbrowserasyncscroll domevent to embedder.
* Sends a scroll event to embedder.
* |aIsRootScrollFrame| is a root scroll frame
* |aContentRect| is in CSS pixels, relative to the current cssPage.
* |aScrollableSize| is the current content width/height in CSS pixels.
*/
void EmbedContentController::SendAsyncScrollDOMEvent(bool aIsRoot,
const CSSRect& aContentRect,
const CSSSize& aScrollableSize)
void EmbedContentController::DoSendScrollEvent(const FrameMetrics &aFrameMetrics)
{
if (MessageLoop::current() != mUILoop) {
// We have to send this message from the "UI thread" (main
// thread).
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &EmbedContentController::SendAsyncScrollDOMEvent,
aIsRoot, aContentRect, aScrollableSize));
NewRunnableMethod(this, &EmbedContentController::DoSendScrollEvent, aFrameMetrics));
return;
}

CSSRect contentRect = aFrameMetrics.CalculateCompositedRectInCssPixels();
contentRect.MoveTo(aFrameMetrics.GetScrollOffset());
CSSSize scrollableSize = aFrameMetrics.GetScrollableRect().Size();

LOGNI("contentR[%g,%g,%g,%g], scrSize[%g,%g]",
aContentRect.x, aContentRect.y, aContentRect.width, aContentRect.height,
aScrollableSize.width, aScrollableSize.height);
gfxRect rect(aContentRect.x, aContentRect.y, aContentRect.width, aContentRect.height);
gfxSize size(aScrollableSize.width, aScrollableSize.height);
contentRect.x, contentRect.y, contentRect.width, contentRect.height,
scrollableSize.width, scrollableSize.height);
gfxRect rect(contentRect.x, contentRect.y, contentRect.width, contentRect.height);
gfxSize size(scrollableSize.width, scrollableSize.height);

if (mRenderFrame && aIsRoot && !GetListener()->SendAsyncScrollDOMEvent(rect, size)) {
Unused << mRenderFrame->SendAsyncScrollDOMEvent(rect, size);
if (mRenderFrame && !GetListener()->HandleScrollEvent(aFrameMetrics.IsRootContent(), rect, size)) {
Unused << mRenderFrame->SendHandleScrollEvent(aFrameMetrics.IsRootContent(), rect, size);
}
}

Expand Down Expand Up @@ -164,7 +167,12 @@ EmbedLiteViewListener* const EmbedContentController::GetListener() const

void EmbedContentController::DoRequestContentRepaint(const FrameMetrics& aFrameMetrics)
{
LOGT("do request %p", mRenderFrame);
if (mRenderFrame && !GetListener()->RequestContentRepaint()) {
LOGT("sending request");

DoSendScrollEvent(aFrameMetrics);

Unused << mRenderFrame->SendUpdateFrame(aFrameMetrics);
}
}
Expand Down
4 changes: 1 addition & 3 deletions embedding/embedlite/embedthread/EmbedContentController.h
Expand Up @@ -38,9 +38,6 @@ class EmbedContentController : public mozilla::layers::GeckoContentController
virtual void HandleDoubleTap(const CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid) override;
virtual void HandleSingleTap(const CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid) override;
virtual void HandleLongTap(const CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId) override;
virtual void SendAsyncScrollDOMEvent(bool aIsRoot,
const CSSRect& aContentRect,
const CSSSize& aScrollableSize);
virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID&, const uint32_t&) override;
void ClearRenderFrame();
virtual void PostDelayedTask(Task* aTask, int aDelayMs) override;
Expand All @@ -55,6 +52,7 @@ class EmbedContentController : public mozilla::layers::GeckoContentController
private:
EmbedLiteViewListener* const GetListener() const;
void DoRequestContentRepaint(const FrameMetrics& aFrameMetrics);
void DoSendScrollEvent(const FrameMetrics& aFrameMetrics);

MessageLoop* mUILoop;
EmbedLiteViewBaseParent* mRenderFrame;
Expand Down

0 comments on commit fbd5227

Please sign in to comment.