EmbedTouchListener.h 2.67 KB
Newer Older
Tatiana Meshkova's avatar
Tatiana Meshkova committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * 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 EmbedTouchListener_H_
#define EmbedTouchListener_H_

#include "nsWeakReference.h"
#include "nsIObserver.h"
#include "nsIDOMEventListener.h"
#include "nsIEmbedAppService.h"
#include "nsIDOMWindow.h"
15
#include "gfxRect.h"
Tatiana Meshkova's avatar
Tatiana Meshkova committed
16 17 18 19 20 21 22 23 24

#define MOZ_DOMTitleChanged "DOMTitleChanged"
#define MOZ_DOMContentLoaded "DOMContentLoaded"
#define MOZ_DOMLinkAdded "DOMLinkAdded"
#define MOZ_DOMWillOpenModalDialog "DOMWillOpenModalDialog"
#define MOZ_DOMModalDialogClosed "DOMModalDialogClosed"
#define MOZ_DOMWindowClose "DOMWindowClose"
#define MOZ_DOMMetaAdded "DOMMetaAdded"

25
class EmbedTouchListener : public nsIDOMEventListener,
26
                           public mozilla::embedlite::EmbedLiteContentController
Tatiana Meshkova's avatar
Tatiana Meshkova committed
27 28 29 30 31 32
{
public:
    EmbedTouchListener(nsIDOMWindow* aWin);
    NS_DECL_ISUPPORTS
    NS_DECL_NSIDOMEVENTLISTENER

33
    virtual void RequestContentRepaint(const mozilla::layers::FrameMetrics&);
34 35
    virtual void HandleDoubleTap(const mozilla::CSSPoint&, int32_t, const mozilla::layers::ScrollableLayerGuid&);
    virtual void HandleSingleTap(const mozilla::CSSPoint&, int32_t, const mozilla::layers::ScrollableLayerGuid&);
36
    virtual void HandleLongTap(const mozilla::CSSPoint&, int32_t, const mozilla::layers::ScrollableLayerGuid&, uint64_t);
37
    virtual void HandleLongTapUp(const mozilla::CSSPoint&, int32_t, const mozilla::layers::ScrollableLayerGuid&);
38
    virtual void SendAsyncScrollDOMEvent(bool aIsRoot, const mozilla::CSSRect&, const mozilla::CSSSize&);
39
    virtual void ScrollUpdate(const mozilla::CSSPoint&, float);
40
    virtual void AcknowledgeScrollUpdate(const mozilla::layers::FrameMetrics::ViewID&, const uint32_t&) {};
41

Tatiana Meshkova's avatar
Tatiana Meshkova committed
42 43
    nsCOMPtr<nsIDOMWindow> DOMWindow;
private:
44 45
    virtual ~EmbedTouchListener();

46 47 48 49 50 51 52 53 54
    void AnyElementFromPoint(nsIDOMWindow* aWindow, double aX, double aY, nsIDOMElement* *aElem);
    bool ShouldZoomToElement(nsIDOMElement* aElement);
    void ZoomToElement(nsIDOMElement* aElement,
                       int aClickY = -1,
                       bool aCanZoomOut = true,
                       bool aCanZoomIn = true);
    mozilla::gfx::Rect GetBoundingContentRect(nsIDOMElement* aElement);
    bool IsRectZoomedIn(mozilla::gfx::Rect aRect, mozilla::gfx::Rect aViewport);

Tatiana Meshkova's avatar
Tatiana Meshkova committed
55
    nsCOMPtr<nsIEmbedAppService> mService;
56 57 58 59 60
    bool mGotViewPortUpdate;
    mozilla::gfx::Rect mViewport;
    mozilla::gfx::Rect mCssCompositedRect;
    mozilla::gfx::Rect mCssPageRect;
    uint32_t mTopWinid;
Tatiana Meshkova's avatar
Tatiana Meshkova committed
61 62 63
};

#endif /*EmbedTouchListener_H_*/