Skip to content

Commit

Permalink
Added embedlite specific content controller, which would not require …
Browse files Browse the repository at this point in the history
…changes in embedding clients when GeckoContentController is changed
  • Loading branch information
tmeshkova committed Nov 4, 2014
1 parent c197658 commit d289926
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 14 deletions.
97 changes: 97 additions & 0 deletions embedding/embedlite/EmbedLiteContentController.h
@@ -0,0 +1,97 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=4 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_embedlite_EmbedLiteContentController_h
#define mozilla_embedlite_EmbedLiteContentController_h

#include "FrameMetrics.h" // for FrameMetrics, etc
#include "Units.h" // for CSSPoint, CSSRect, etc
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2
#include "nsISupportsImpl.h"

namespace mozilla {
namespace embedlite {

class EmbedLiteContentController
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(EmbedLiteContentController)

/**
* Requests a paint of the given FrameMetrics |aFrameMetrics| from Gecko.
* Implementations per-platform are responsible for actually handling this.
* This method will always be called on the Gecko main thread.
*/
virtual void RequestContentRepaint(const mozilla::layers::FrameMetrics& aFrameMetrics) = 0;

/**
* Acknowledges the recipt of a scroll offset update for the scrollable
* frame with the given scroll id. This is used to maintain consistency
* between APZ and other sources of scroll changes.
*/
virtual void AcknowledgeScrollUpdate(const mozilla::layers::FrameMetrics::ViewID& aScrollId,
const uint32_t& aScrollGeneration) = 0;

/**
* Requests handling of a double tap. |aPoint| is in CSS pixels, relative to
* the current scroll offset. This should eventually round-trip back to
* AsyncPanZoomController::ZoomToRect with the dimensions that we want to zoom
* to.
*/
virtual void HandleDoubleTap(const CSSPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid) = 0;

/**
* Requests handling a single tap. |aPoint| is in CSS pixels, relative to the
* current scroll offset. This should simulate and send to content a mouse
* button down, then mouse button up at |aPoint|.
*/
virtual void HandleSingleTap(const CSSPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid) = 0;

/**
* Requests handling a long tap. |aPoint| is in CSS pixels, relative to the
* current scroll offset.
*/
virtual void HandleLongTap(const CSSPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid,
uint64_t aInputBlockId) = 0;

/**
* Requests handling of releasing a long tap. |aPoint| is in CSS pixels,
* relative to the current scroll offset. HandleLongTapUp will always be
* preceeded by HandleLongTap. However not all calls to HandleLongTap will
* be followed by a HandleLongTapUp (for example, if the user drags
* around between the long-tap and lifting their finger, or if content
* notifies the APZ that the long-tap event was prevent-defaulted).
*/
virtual void HandleLongTapUp(const CSSPoint& aPoint,
int32_t aModifiers,
const mozilla::layers::ScrollableLayerGuid& aGuid) = 0;

/**
* Requests sending a mozbrowserasyncscroll domevent to embedder.
* |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;

EmbedLiteContentController() {}

protected:
// Protected destructor, to discourage deletion outside of Release():
virtual ~EmbedLiteContentController() {}
};

}
}

#endif // mozilla_embedlite_EmbedLiteContentController_h
4 changes: 2 additions & 2 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadChild.cpp
Expand Up @@ -541,13 +541,13 @@ EmbedLiteViewThreadChild::RecvSetGLViewSize(const gfxSize& aSize)
}

void
EmbedLiteViewThreadChild::AddGeckoContentListener(mozilla::layers::GeckoContentController* listener)
EmbedLiteViewThreadChild::AddGeckoContentListener(EmbedLiteContentController* listener)
{
mControllerListeners.AppendElement(listener);
}

void
EmbedLiteViewThreadChild::RemoveGeckoContentListener(mozilla::layers::GeckoContentController* listener)
EmbedLiteViewThreadChild::RemoveGeckoContentListener(EmbedLiteContentController* listener)
{
mControllerListeners.RemoveElement(listener);
}
Expand Down
10 changes: 4 additions & 6 deletions embedding/embedlite/embedthread/EmbedLiteViewThreadChild.h
Expand Up @@ -16,11 +16,9 @@
#include "TabChildHelper.h"

namespace mozilla {
namespace layers {
class GeckoContentController;
}
namespace embedlite {

class EmbedLiteContentController;
class EmbedLitePuppetWidget;
class EmbedLiteAppThreadChild;

Expand All @@ -46,8 +44,8 @@ class EmbedLiteViewThreadChild : public PEmbedLiteViewChild,
const char16_t* aMessage,
InfallibleTArray<nsString>* aJSONRetVal);
bool HasMessageListener(const nsAString& aMessageName);
void AddGeckoContentListener(mozilla::layers::GeckoContentController* listener);
void RemoveGeckoContentListener(mozilla::layers::GeckoContentController* listener);
void AddGeckoContentListener(EmbedLiteContentController* listener);
void RemoveGeckoContentListener(EmbedLiteContentController* listener);

nsresult GetBrowserChrome(nsIWebBrowserChrome** outChrome);
nsresult GetBrowser(nsIWebBrowser** outBrowser);
Expand Down Expand Up @@ -144,7 +142,7 @@ class EmbedLiteViewThreadChild : public PEmbedLiteViewChild,
CancelableTask* mInitWindowTask;

nsDataHashtable<nsStringHashKey, bool/*start with key*/> mRegisteredMessages;
nsTArray<mozilla::layers::GeckoContentController*> mControllerListeners;
nsTArray<EmbedLiteContentController*> mControllerListeners;

DISALLOW_EVIL_CONSTRUCTORS(EmbedLiteViewThreadChild);
};
Expand Down
4 changes: 2 additions & 2 deletions embedding/embedlite/modules/EmbedLiteAppService.cpp
Expand Up @@ -246,7 +246,7 @@ NS_IMETHODIMP EmbedLiteAppService::LeaveSecureJSContext()
}

NS_IMETHODIMP
EmbedLiteAppService::AddContentListener(uint32_t aWinId, mozilla::layers::GeckoContentController* listener)
EmbedLiteAppService::AddContentListener(uint32_t aWinId, EmbedLiteContentController* listener)
{
EmbedLiteViewThreadChild* view = sGetViewById(aWinId);
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
Expand All @@ -255,7 +255,7 @@ EmbedLiteAppService::AddContentListener(uint32_t aWinId, mozilla::layers::GeckoC
}

NS_IMETHODIMP
EmbedLiteAppService::RemoveContentListener(uint32_t aWinId, mozilla::layers::GeckoContentController* listener)
EmbedLiteAppService::RemoveContentListener(uint32_t aWinId, EmbedLiteContentController* listener)
{
EmbedLiteViewThreadChild* view = sGetViewById(aWinId);
NS_ENSURE_TRUE(view, NS_ERROR_FAILURE);
Expand Down
8 changes: 4 additions & 4 deletions embedding/embedlite/modules/nsIEmbedAppService.idl
Expand Up @@ -21,12 +21,12 @@

%{C++
#include "nsStringGlue.h" // needed for AString -> nsAString, unfortunately
#include "mozilla/layers/GeckoContentController.h"
#include "mozilla/embedlite/EmbedLiteContentController.h"
#include "FrameMetrics.h"
%}

[ref] native nsConstFrameMetrics(const mozilla::layers::FrameMetrics);
[ptr] native GeckoContentController(mozilla::layers::GeckoContentController);
[ptr] native EmbedLiteContentController(mozilla::embedlite::EmbedLiteContentController);

[scriptable, uuid(99d60536-e1a7-11e2-b76e-ff454ce9029f)]
interface nsIEmbedMessageListener : nsISupports
Expand All @@ -52,8 +52,8 @@ interface nsIEmbedAppService : nsISupports
void enterSecureJSContext();
void leaveSecureJSContext();
// Add listener for AZPC Gecko notifications (single/long/double tap..)
[noscript] void addContentListener(in uint32_t aId, in GeckoContentController listener);
[noscript] void removeContentListener(in uint32_t aId, in GeckoContentController listener);
[noscript] void addContentListener(in uint32_t aId, in EmbedLiteContentController listener);
[noscript] void removeContentListener(in uint32_t aId, in EmbedLiteContentController listener);
// Get EmbedLite nsIWebBrowser by unique ID C++ only
void getBrowserByID(in uint32_t aId, out nsIWebBrowser outBrowser);
void getContentWindowByID(in uint32_t aId, [retval] out nsIDOMWindow outWindow);
Expand Down
1 change: 1 addition & 0 deletions embedding/embedlite/moz.build
Expand Up @@ -25,6 +25,7 @@ EXPORTS.mozilla.embedlite += [
'EmbedInitGlue.h',
'EmbedLiteAPI.h',
'EmbedLiteApp.h',
'EmbedLiteContentController.h',
'EmbedLiteMessagePump.h',
'EmbedLiteView.h',
'utils/EmbedLog.h',
Expand Down

0 comments on commit d289926

Please sign in to comment.