Skip to content

Commit

Permalink
Align EmbedContentController to new GeckoContentController API
Browse files Browse the repository at this point in the history
  • Loading branch information
rainemak committed Apr 8, 2020
1 parent 9615502 commit 3c12a66
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 52 deletions.
2 changes: 2 additions & 0 deletions embedding/embedlite/EmbedLiteView.h
Expand Up @@ -58,7 +58,9 @@ class EmbedLiteViewListener
virtual bool HandleDoubleTap(const nsIntPoint& aPoint) { return false; }
virtual bool HandleSingleTap(const nsIntPoint& aPoint) { return false; }
virtual bool HandleLongTap(const nsIntPoint& aPoint) { return false; }
#if 0 // sha1 6afa98a3ea0ba814b77f7aeb162624433e427ccf3e427ccf
virtual bool AcknowledgeScrollUpdate(const uint32_t& aViewID, const uint32_t& aScrollGeneration) { return false; }
#endif
};

class EmbedLiteApp;
Expand Down
4 changes: 2 additions & 2 deletions embedding/embedlite/PEmbedLiteView.ipdl
Expand Up @@ -61,8 +61,8 @@ child:
async HandleDoubleTap(CSSPoint aPoint, Modifiers aModifiers, ScrollableLayerGuid aGuid);
async HandleSingleTap(CSSPoint aPoint, Modifiers aModifiers, ScrollableLayerGuid aGuid);
async HandleLongTap(CSSPoint aPoint, ScrollableLayerGuid aGuid, uint64_t aInputBlockId);
async AcknowledgeScrollUpdate(ViewID aScrollId, uint32_t aScrollGeneration);
async RequestFlingSnap(ViewID aScrollId, CSSPoint aDestination);
// async AcknowledgeScrollUpdate(ViewID aScrollId, uint32_t aScrollGeneration);
// async RequestFlingSnap(ViewID aScrollId, CSSPoint aDestination);
async HandleTextEvent(nsString commit, nsString preEdit);
async HandleKeyPressEvent(int domKeyCode, int gmodifiers, int charCode);
async HandleKeyReleaseEvent(int domKeyCode, int gmodifiers, int charCode);
Expand Down
4 changes: 4 additions & 0 deletions embedding/embedlite/embedshared/EmbedLiteViewBaseChild.cpp
Expand Up @@ -833,6 +833,7 @@ EmbedLiteViewBaseChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
return true;
}

#if 0 // sha1 6afa98a3ea0ba814b77f7aeb162624433e427ccf
bool
EmbedLiteViewBaseChild::RecvAcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId,
const uint32_t& aScrollGeneration)
Expand All @@ -841,7 +842,9 @@ EmbedLiteViewBaseChild::RecvAcknowledgeScrollUpdate(const FrameMetrics::ViewID&
APZCCallbackHelper::AcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
return true;
}
#endif

#if 0 // sha1 5753e3da8314bb0522bdbf92819beb6d89faeb06
bool
EmbedLiteViewBaseChild::RecvRequestFlingSnap(const FrameMetrics::ViewID& aScrollId,
const CSSPoint& aDestination)
Expand All @@ -850,6 +853,7 @@ EmbedLiteViewBaseChild::RecvRequestFlingSnap(const FrameMetrics::ViewID& aScroll
APZCCallbackHelper::RequestFlingSnap(aScrollId, aDestination);
return true;
}
#endif

void
EmbedLiteViewBaseChild::InitEvent(WidgetGUIEvent& event, nsIntPoint* aPoint)
Expand Down
4 changes: 4 additions & 0 deletions embedding/embedlite/embedshared/EmbedLiteViewBaseChild.h
Expand Up @@ -164,8 +164,12 @@ class EmbedLiteViewBaseChild : public PEmbedLiteViewChild,
virtual bool RecvHandleLongTap(const CSSPoint& aPoint,
const mozilla::layers::ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId) override;
#if 0 // sha1 6afa98a3ea0ba814b77f7aeb162624433e427ccf
virtual bool RecvAcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, const uint32_t& aScrollGeneration) override;
#endif
#if 0 // sha1 5753e3da8314bb0522bdbf92819beb6d89faeb06
virtual bool RecvRequestFlingSnap(const FrameMetrics::ViewID& aScrollId, const CSSPoint& aDestination) override;
#endif
virtual bool RecvMouseEvent(const nsString& aType,
const float& aX,
const float& aY,
Expand Down
128 changes: 81 additions & 47 deletions embedding/embedlite/embedthread/EmbedContentController.cpp
Expand Up @@ -14,6 +14,7 @@
using namespace mozilla::embedlite;
using namespace mozilla::gfx;
using namespace mozilla::layers;
using mozilla::layers::GeckoContentController;

class FakeListener : public EmbedLiteViewListener {};

Expand All @@ -33,17 +34,40 @@ void EmbedContentController::RequestContentRepaint(const FrameMetrics& aFrameMet
// We always need to post requests into the "UI thread" otherwise the
// requests may get processed out of order.
LOGT();
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &EmbedContentController::DoRequestContentRepaint, aFrameMetrics));
// nsThreadUtils version
mUILoop->PostTask(NewRunnableMethod<const FrameMetrics&>(this,
&EmbedContentController::DoRequestContentRepaint,
aFrameMetrics));
}

#if 0 // sha1 5753e3da8314bb0522bdbf92819beb6d89faeb06
void EmbedContentController::RequestFlingSnap(const FrameMetrics::ViewID &aScrollId, const mozilla::CSSPoint &aDestination)
{
LOGT();
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &EmbedContentController::DoRequestFlingSnap, aScrollId, aDestination));
mUILoop->PostTask(NewRunnableMethod(this, &EmbedContentController::DoRequestFlingSnap, aScrollId, aDestination));
}
#endif

void EmbedContentController::HandleTap(TapType aType, const LayoutDevicePoint &aPoint, Modifiers aModifiers, const EmbedContentController::ScrollableLayerGuid &aGuid, uint64_t aInputBlockId)
{
CSSPoint cssPoint(aPoint.x, aPoint.y);
switch (aType) {
case GeckoContentController::TapType::eSingleTap:
HandleSingleTap(cssPoint, aModifiers, aGuid);
break;
case GeckoContentController::TapType::eDoubleTap:
HandleDoubleTap(cssPoint, aModifiers, aGuid);
break;
case GeckoContentController::TapType::eLongTap:
HandleLongTap(cssPoint, aModifiers, aGuid, aInputBlockId);
break;
case GeckoContentController::TapType::eSecondTap:
case GeckoContentController::TapType::eLongTapUp:
case GeckoContentController::TapType::eSentinel:
// What to do with these?
MOZ_FALLTHROUGH;
break;
}
}

void EmbedContentController::HandleDoubleTap(const CSSPoint& aPoint,
Expand All @@ -53,12 +77,12 @@ void EmbedContentController::HandleDoubleTap(const CSSPoint& aPoint,
if (MessageLoop::current() != mUILoop) {
// We have to send this message from the "UI thread" (main
// thread).
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &EmbedContentController::HandleDoubleTap, aPoint, aModifiers, aGuid));
return;
}
if (mRenderFrame && !GetListener()->HandleDoubleTap(nsIntPoint(aPoint.x, aPoint.y))) {
mUILoop->PostTask(NewRunnableMethod<const CSSPoint &, Modifiers, const ScrollableLayerGuid &>(this,
&EmbedContentController::HandleDoubleTap,
aPoint,
aModifiers,
aGuid));
} else if (mRenderFrame && !GetListener()->HandleDoubleTap(convertIntPoint(aPoint))) {
Unused << mRenderFrame->SendHandleDoubleTap(aPoint, aModifiers, aGuid);
}
}
Expand All @@ -70,12 +94,12 @@ void EmbedContentController::HandleSingleTap(const CSSPoint& aPoint,
if (MessageLoop::current() != mUILoop) {
// We have to send this message from the "UI thread" (main
// thread).
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &EmbedContentController::HandleSingleTap, aPoint, aModifiers, aGuid));
return;
}
if (mRenderFrame && !GetListener()->HandleSingleTap(nsIntPoint(aPoint.x, aPoint.y))) {
mUILoop->PostTask(NewRunnableMethod<const CSSPoint &, Modifiers, const ScrollableLayerGuid &>(this,
&EmbedContentController::HandleSingleTap,
aPoint,
aModifiers,
aGuid));
} else if (mRenderFrame && !GetListener()->HandleSingleTap(convertIntPoint(aPoint))) {
Unused << mRenderFrame->SendHandleSingleTap(aPoint, aModifiers, aGuid);
}
}
Expand All @@ -88,12 +112,13 @@ void EmbedContentController::HandleLongTap(const CSSPoint& aPoint,
if (MessageLoop::current() != mUILoop) {
// We have to send this message from the "UI thread" (main
// thread).
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &EmbedContentController::HandleLongTap, aPoint, aModifiers, aGuid, aInputBlockId));
return;
}
if (mRenderFrame && !GetListener()->HandleLongTap(nsIntPoint(aPoint.x, aPoint.y))) {
mUILoop->PostTask(NewRunnableMethod<const CSSPoint &, Modifiers, const ScrollableLayerGuid &, uint64_t>(this,
&EmbedContentController::HandleLongTap,
aPoint,
aModifiers,
aGuid,
aInputBlockId));
} else if (mRenderFrame && !GetListener()->HandleLongTap(convertIntPoint(aPoint))) {
Unused << mRenderFrame->SendHandleLongTap(aPoint, aGuid, aInputBlockId);
}
}
Expand All @@ -109,33 +134,35 @@ 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::DoSendScrollEvent, aFrameMetrics));
mUILoop->PostTask(NewRunnableMethod<const FrameMetrics &>(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]",
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 && !GetListener()->HandleScrollEvent(aFrameMetrics.IsRootContent(), rect, size)) {
Unused << mRenderFrame->SendHandleScrollEvent(aFrameMetrics.IsRootContent(), rect, size);
} else {
CSSRect contentRect = aFrameMetrics.CalculateCompositedRectInCssPixels();
contentRect.MoveTo(aFrameMetrics.GetScrollOffset());
CSSSize scrollableSize = aFrameMetrics.GetScrollableRect().Size();

LOGNI("contentR[%g,%g,%g,%g], scrSize[%g,%g]",
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 && !GetListener()->HandleScrollEvent(aFrameMetrics.IsRootContent(), rect, size)) {
Unused << mRenderFrame->SendHandleScrollEvent(aFrameMetrics.IsRootContent(), rect, size);
}
}
}

#if 0 // sha1 5753e3da8314bb0522bdbf92819beb6d89faeb06
void EmbedContentController::DoRequestFlingSnap(const FrameMetrics::ViewID &aScrollId, const mozilla::CSSPoint &aDestination)
{
if (mRenderFrame) {
Unused << mRenderFrame->SendRequestFlingSnap(aScrollId, aDestination);
}
}
#endif

void EmbedContentController::DoNotifyAPZStateChange(const mozilla::layers::ScrollableLayerGuid &aGuid, APZStateChange aChange, int aArg)
{
Expand All @@ -151,6 +178,12 @@ void EmbedContentController::DoNotifyFlushComplete()
}
}

nsIntPoint EmbedContentController::convertIntPoint(const CSSPoint &aPoint)
{
return nsIntPoint((int)nearbyint(aPoint.x), (int)nearbyint(aPoint.y));
}

#if 0 // sha1 6afa98a3ea0ba814b77f7aeb162624433e427ccf
void EmbedContentController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID& aScrollId, const uint32_t& aScrollGeneration)
{
if (MessageLoop::current() != mUILoop) {
Expand All @@ -165,6 +198,7 @@ void EmbedContentController::AcknowledgeScrollUpdate(const FrameMetrics::ViewID&
Unused << mRenderFrame->SendAcknowledgeScrollUpdate(aScrollId, aScrollGeneration);
}
}
#endif

void EmbedContentController::ClearRenderFrame()
{
Expand Down Expand Up @@ -199,15 +233,15 @@ void EmbedContentController::DoRequestContentRepaint(const FrameMetrics& aFrameM
void EmbedContentController::NotifyAPZStateChange(const mozilla::layers::ScrollableLayerGuid &aGuid, APZStateChange aChange, int aArg)
{
LOGT();
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &EmbedContentController::DoNotifyAPZStateChange, aGuid, aChange, aArg));
mUILoop->PostTask(NewRunnableMethod<const mozilla::layers::ScrollableLayerGuid &, APZStateChange, int>(this,
&EmbedContentController::DoNotifyAPZStateChange,
aGuid,
aChange,
aArg));
}

void EmbedContentController::NotifyFlushComplete()
{
LOGT();
mUILoop->PostTask(
FROM_HERE,
NewRunnableMethod(this, &EmbedContentController::DoNotifyFlushComplete));
mUILoop->PostTask(NewRunnableMethod(this, &EmbedContentController::DoNotifyFlushComplete));
}
22 changes: 19 additions & 3 deletions embedding/embedlite/embedthread/EmbedContentController.h
Expand Up @@ -28,13 +28,20 @@ class EmbedContentController : public mozilla::layers::GeckoContentController

// GeckoContentController interface
virtual void RequestContentRepaint(const FrameMetrics& aFrameMetrics) override;
#if 0 // sha1 5753e3da8314bb0522bdbf92819beb6d89faeb06
virtual void RequestFlingSnap(const FrameMetrics::ViewID& aScrollId,
const mozilla::CSSPoint& aDestination) override;
#endif

virtual void HandleTap(TapType aType,
const LayoutDevicePoint& aPoint,
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid,
uint64_t aInputBlockId) override;

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;
#if 0 // sha1 6afa98a3ea0ba814b77f7aeb162624433e427ccf
virtual void AcknowledgeScrollUpdate(const FrameMetrics::ViewID&, const uint32_t&) override;
#endif
void ClearRenderFrame();
virtual void PostDelayedTask(already_AddRefed<Runnable> aTask, int aDelayMs) override;
bool HitTestAPZC(mozilla::ScreenIntPoint& aPoint);
Expand All @@ -46,12 +53,21 @@ class EmbedContentController : public mozilla::layers::GeckoContentController

private:
EmbedLiteViewListener *GetListener() const;

void HandleDoubleTap(const CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid);
void HandleSingleTap(const CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid);
void HandleLongTap(const CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId);

void DoRequestContentRepaint(const FrameMetrics& aFrameMetrics);
void DoSendScrollEvent(const FrameMetrics& aFrameMetrics);
#if 0 // sha1 5753e3da8314bb0522bdbf92819beb6d89faeb06
void DoRequestFlingSnap(const FrameMetrics::ViewID &aScrollId, const mozilla::CSSPoint &aDestination);
#endif
void DoNotifyAPZStateChange(const mozilla::layers::ScrollableLayerGuid &aGuid, APZStateChange aChange, int aArg);
void DoNotifyFlushComplete();

nsIntPoint convertIntPoint(const CSSPoint &aPoint);

MessageLoop* mUILoop;
EmbedLiteViewBaseParent* mRenderFrame;
};
Expand Down

0 comments on commit 3c12a66

Please sign in to comment.