Bug 1335895 - part 35: Remove ZoomedView.java specific code from ThumbnailHelper.h and AndroidContentController r=jchen,kats draft
authorRandall Barker <rbarker@mozilla.com>
Wed, 12 Apr 2017 11:09:09 -0700
changeset 563869 7f439e0fc556adb82a3801572b09487c83480c0d
parent 563868 33b64521c08f9fea87760610b6d38bb4c913ca83
child 563870 d98fc7a54858699d72ba8d64e6ee89ff45637863
push id54439
push userbmo:rbarker@mozilla.com
push dateMon, 17 Apr 2017 22:56:51 +0000
reviewersjchen, kats
bugs1335895
milestone55.0a1
Bug 1335895 - part 35: Remove ZoomedView.java specific code from ThumbnailHelper.h and AndroidContentController r=jchen,kats MozReview-Commit-ID: GoPdEoXnlNl
widget/android/AndroidContentController.cpp
widget/android/AndroidContentController.h
widget/android/fennec/ThumbnailHelper.h
--- a/widget/android/AndroidContentController.cpp
+++ b/widget/android/AndroidContentController.cpp
@@ -21,74 +21,16 @@ namespace widget {
 void
 AndroidContentController::Destroy()
 {
     mAndroidWindow = nullptr;
     ChromeProcessController::Destroy();
 }
 
 void
-AndroidContentController::DispatchSingleTapToObservers(const LayoutDevicePoint& aPoint,
-                                                       const ScrollableLayerGuid& aGuid) const
-{
-    nsIContent* content = nsLayoutUtils::FindContentFor(aGuid.mScrollId);
-    nsPresContext* context = content
-        ? mozilla::layers::APZCCallbackHelper::GetPresContextForContent(content)
-        : nullptr;
-
-    if (!context) {
-      return;
-    }
-
-    CSSPoint point = mozilla::layers::APZCCallbackHelper::ApplyCallbackTransform(
-        aPoint / context->CSSToDevPixelScale(), aGuid);
-
-    nsPresContext* rcdContext = context->GetToplevelContentDocumentPresContext();
-    if (rcdContext && rcdContext->PresShell()->ScaleToResolution()) {
-        // We need to convert from the root document to the root content document,
-        // by unapplying the resolution that's on the content document.
-        const float resolution = rcdContext->PresShell()->GetResolution();
-        point.x /= resolution;
-        point.y /= resolution;
-    }
-
-    CSSIntPoint rounded = RoundedToInt(point);
-    nsAppShell::PostEvent([rounded] {
-        nsCOMPtr<nsIObserverService> obsServ =
-            mozilla::services::GetObserverService();
-        if (!obsServ) {
-            return;
-        }
-
-        nsPrintfCString data("{\"x\":%d,\"y\":%d}", rounded.x, rounded.y);
-        obsServ->NotifyObservers(nullptr, "Gesture:SingleTap",
-                                 NS_ConvertASCIItoUTF16(data).get());
-    });
-}
-
-void
-AndroidContentController::HandleTap(TapType aType, const LayoutDevicePoint& aPoint,
-                                    Modifiers aModifiers,
-                                    const ScrollableLayerGuid& aGuid,
-                                    uint64_t aInputBlockId)
-{
-    // This function will get invoked first on the Java UI thread, and then
-    // again on the main thread (because of the code in ChromeProcessController::
-    // HandleTap). We want to post the SingleTap message once; it can be
-    // done from either thread but we need access to the callback transform
-    // so we do it from the main thread.
-    if (NS_IsMainThread() &&
-        (aType == TapType::eSingleTap || aType == TapType::eSecondTap)) {
-        DispatchSingleTapToObservers(aPoint, aGuid);
-    }
-
-    ChromeProcessController::HandleTap(aType, aPoint, aModifiers, aGuid, aInputBlockId);
-}
-
-void
 AndroidContentController::UpdateOverscrollVelocity(const float aX, const float aY, const bool aIsRootContent)
 {
   if (aIsRootContent && mAndroidWindow) {
     mAndroidWindow->UpdateOverscrollVelocity(aX, aY);
   }
 }
 
 void
--- a/widget/android/AndroidContentController.h
+++ b/widget/android/AndroidContentController.h
@@ -29,26 +29,21 @@ public:
                              mozilla::layers::APZEventState* aAPZEventState,
                              mozilla::layers::IAPZCTreeManager* aAPZCTreeManager)
       : mozilla::layers::ChromeProcessController(aWindow, aAPZEventState, aAPZCTreeManager)
       , mAndroidWindow(aWindow)
     {}
 
     // ChromeProcessController methods
     virtual void Destroy() override;
-    void HandleTap(TapType aType, const LayoutDevicePoint& aPoint, Modifiers aModifiers,
-                   const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId) override;
     void UpdateOverscrollVelocity(const float aX, const float aY, const bool aIsRootContent) override;
     void UpdateOverscrollOffset(const float aX, const float aY, const bool aIsRootContent) override;
     void NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
                               APZStateChange aChange,
                               int aArg) override;
 private:
     nsWindow* mAndroidWindow;
-
-    void DispatchSingleTapToObservers(const LayoutDevicePoint& aPoint,
-                                      const ScrollableLayerGuid& aGuid) const;
 };
 
 } // namespace widget
 } // namespace mozilla
 
 #endif
--- a/widget/android/fennec/ThumbnailHelper.h
+++ b/widget/android/fennec/ThumbnailHelper.h
@@ -23,17 +23,16 @@
 #include "nsPresContext.h"
 
 #include "mozilla/Preferences.h"
 
 namespace mozilla {
 
 class ThumbnailHelper final
     : public java::ThumbnailHelper::Natives<ThumbnailHelper>
-    , public java::ZoomedView::Natives<ThumbnailHelper>
 {
     ThumbnailHelper() = delete;
 
     static already_AddRefed<mozIDOMWindowProxy>
     GetWindowForTab(int32_t aTabId)
     {
         nsAppShell* const appShell = nsAppShell::Get();
         if (!appShell) {
@@ -185,17 +184,16 @@ class ThumbnailHelper final
 
         return docShell.forget();
     }
 
 public:
     static void Init()
     {
         java::ThumbnailHelper::Natives<ThumbnailHelper>::Init();
-        java::ZoomedView::Natives<ThumbnailHelper>::Init();
     }
 
     template<class Functor>
     static void OnNativeCall(Functor&& aCall)
     {
         class IdleEvent : public nsAppShell::LambdaEvent<Functor>
         {
             using Base = nsAppShell::LambdaEvent<Functor>;
@@ -256,47 +254,13 @@ public:
                 window, aData, aWidth, aHeight,
                 CSSRect(pageLeft, pageTop, pageWidth, pageHeight),
                 /* aZoomFactor */ 1.0f);
         const bool success = !!docShell;
         const bool store = success ? ShouldStoreThumbnail(docShell) : false;
 
         java::ThumbnailHelper::NotifyThumbnail(aData, aTab, success, store);
     }
-
-    static void
-    RequestZoomedViewData(jni::ByteBuffer::Param aData, int32_t aTabId,
-                          int32_t aX, int32_t aY,
-                          int32_t aWidth, int32_t aHeight, float aScale)
-    {
-        nsCOMPtr<mozIDOMWindowProxy> window = GetWindowForTab(aTabId);
-        if (!window || !aData) {
-            return;
-        }
-
-        nsCOMPtr<nsPIDOMWindowOuter> win = nsPIDOMWindowOuter::From(window);
-        nsCOMPtr<nsIDocShell> docShell = win->GetDocShell();
-        RefPtr<nsPresContext> presContext;
-
-        if (!docShell || NS_FAILED(docShell->GetPresContext(
-                getter_AddRefs(presContext))) || !presContext) {
-            return;
-        }
-
-        nsCOMPtr<nsIPresShell> presShell = presContext->PresShell();
-        LayoutDeviceRect rect = LayoutDeviceRect(aX, aY, aWidth, aHeight);
-        const float resolution = presShell->GetCumulativeResolution();
-        rect.Scale(1.0f / LayoutDeviceToLayerScale(resolution).scale);
-
-        docShell = GetThumbnailAndDocShell(
-                window, aData, aWidth, aHeight, CSSRect::FromAppUnits(
-                rect.ToAppUnits(rect, presContext->AppUnitsPerDevPixel())),
-                aScale);
-
-        if (docShell) {
-            java::LayerView::UpdateZoomedView(aData);
-        }
-    }
 };
 
 } // namespace mozilla
 
 #endif // ThumbnailHelper_h