-
Notifications
You must be signed in to change notification settings - Fork 16
/
EmbedLiteView.h
147 lines (119 loc) · 5.86 KB
/
EmbedLiteView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* -*- 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 MOZ_VIEW_EMBED_H
#define MOZ_VIEW_EMBED_H
#include "mozilla/RefPtr.h"
#include "mozilla/WidgetUtils.h"
#include "nsStringGlue.h"
#include "gfxMatrix.h"
#include "nsRect.h"
class EmbedLiteViewIface;
namespace mozilla {
class InputData;
namespace embedlite {
class EmbedLiteViewThreadParent;
class PEmbedLiteViewParent;
class EmbedLiteView;
class EmbedLiteWindow;
class EmbedLiteViewListener
{
public:
// View intialized and ready for API calls
virtual void ViewInitialized() {}
// View finally destroyed and deleted
virtual void ViewDestroyed() {}
// Messaging interface, allow to receive json messages from content child scripts
virtual void RecvAsyncMessage(const char16_t* aMessage, const char16_t* aData) {}
virtual char* RecvSyncMessage(const char16_t* aMessage, const char16_t* aData) { return NULL; }
virtual void OnLocationChanged(const char* aLocation, bool aCanGoBack, bool aCanGoForward) {}
virtual void OnLoadStarted(const char* aLocation) {}
virtual void OnLoadFinished(void) {}
virtual void OnLoadRedirect(void) {}
virtual void OnLoadProgress(int32_t aProgress, int32_t aCurTotal, int32_t aMaxTotal) {}
virtual void OnSecurityChanged(const char* aStatus, unsigned int aState) {}
virtual void OnFirstPaint(int32_t aX, int32_t aY) {}
virtual void OnScrolledAreaChanged(unsigned int aWidth, unsigned int aHeight) {}
virtual void OnScrollChanged(int32_t offSetX, int32_t offSetY) {}
virtual void OnTitleChanged(const char16_t* aTitle) {}
virtual void SetBackgroundColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {}
virtual void OnWindowCloseRequested(void) {}
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) {}
// AZPC Interface, return true in order to prevent default behavior
virtual bool RequestContentRepaint() { return false; }
virtual bool HandleDoubleTap(const nsIntPoint& aPoint) { return false; }
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;
class EmbedLiteView
{
public:
EmbedLiteView(EmbedLiteApp* aApp, EmbedLiteWindow* aWindow, PEmbedLiteViewParent* aViewImpl, uint32_t aViewId);
// Listener setup, call this with null pointer if listener destroyed before EmbedLiteView
virtual void SetListener(EmbedLiteViewListener* aListener);
virtual EmbedLiteViewListener* const GetListener() const;
// Embed Interface
virtual void LoadURL(const char* aUrl);
virtual void SetIsActive(bool);
virtual void SetIsFocused(bool);
virtual void SetThrottlePainting(bool);
virtual void SuspendTimeouts();
virtual void ResumeTimeouts();
virtual void GoBack();
virtual void GoForward();
virtual void StopLoad();
virtual void Reload(bool hard);
// Input Interface
virtual void SendTextEvent(const char* composite, const char* preEdit);
virtual void SendKeyPress(int domKeyCode, int gmodifiers, int charCode);
virtual void SendKeyRelease(int domKeyCode, int gmodifiers, int charCode);
virtual void ReceiveInputEvent(const mozilla::InputData& aEvent);
virtual void MousePress(int x, int y, int mstime, unsigned int buttons, unsigned int modifiers);
virtual void MouseRelease(int x, int y, int mstime, unsigned int buttons, unsigned int modifiers);
virtual void MouseMove(int x, int y, int mstime, unsigned int buttons, unsigned int modifiers);
virtual void PinchStart(int x, int y);
virtual void PinchUpdate(int x, int y, float scale);
virtual void PinchEnd(int x, int y, float scale);
virtual void SetMargins(int top, int right, int bottom, int left);
// Scripting Interface, allow to extend embedding API by creating
// child js scripts and messaging interface.
// and do communication between UI and Content child via json messages.
// See RecvAsyncMessage, RecvSyncMessage, SendAsyncMessage
// For more detailed info see https://developer.mozilla.org/en-US/docs/The_message_manager
// https://wiki.mozilla.org/Content_Process_Event_Handlers
virtual void LoadFrameScript(const char* aURI);
virtual void AddMessageListener(const char* aMessageName);
virtual void RemoveMessageListener(const char* aMessageName);
virtual void AddMessageListeners(const nsTArray<nsString>& aMessageNames);
virtual void RemoveMessageListeners(const nsTArray<nsString>& aMessageNames);
virtual void SendAsyncMessage(const char16_t* aMessageName, const char16_t* aMessage);
virtual uint32_t GetUniqueID();
protected:
friend class EmbedLiteApp; // Needs to destroy the view.
virtual ~EmbedLiteView();
// Request the view to be destroyed. Once this async process is done
// EmbedLiteViewListener::ViewDestroyed will be called. This interface
// should only be used by EmbedLiteApp. EmbedLite users should destroy
// EmbedLiteViews by calling EmbedLiteApp::DestroyView.
void Destroy();
private:
friend class EmbedLiteViewBaseParent;
friend class EmbedLiteViewThreadParent;
void Destroyed();
EmbedLiteViewIface* GetImpl();
EmbedLiteApp* mApp;
EmbedLiteWindow* mWindow;
EmbedLiteViewListener* mListener;
EmbedLiteViewIface* mViewImpl;
PEmbedLiteViewParent* mViewParent;
const uint32_t mUniqueID;
};
} // namespace embedlite
} // namespace mozilla
#endif