Browse Source

Adding some WebView member comments

Josh Engebretson 10 years ago
parent
commit
b11b2ab748

+ 1 - 0
Source/AtomicWebView/AtomicWebView.h

@@ -4,6 +4,7 @@
 namespace Atomic
 {
 
+/// WebMain is called when starting up a AtomicWebView enabled process or subprocess
 int WebMain(int argc, char* argv[]);
 
 }

+ 3 - 0
Source/AtomicWebView/UIWebView.h

@@ -35,6 +35,7 @@ namespace Atomic
 class WebClient;
 class WebTexture2D;
 
+/// UI widget for WebViews
 class UIWebView : public UIWidget
 {
     friend class WebViewWidget;
@@ -46,8 +47,10 @@ public:
     UIWebView(Context* context, const String& initialURL = String::EMPTY);
     virtual ~UIWebView();
 
+    /// Get the widget's WebClient
     WebClient* GetWebClient() { return webClient_; }
 
+    /// Get the WebTexture in use by the WebView
     WebTexture2D* GetWebTexture2D() const;
 
 protected:

+ 15 - 13
Source/AtomicWebView/WebBrowserHost.cpp

@@ -27,22 +27,24 @@
 #include <unistd.h>
 #include <signal.h>
 
-static int XErrorHandlerImpl(Display *display, XErrorEvent *event) {
-  return 0;
+static int XErrorHandlerImpl(Display *display, XErrorEvent *event)
+{
+    return 0;
 }
 
-static int XIOErrorHandlerImpl(Display *display) {
-  return 0;
+static int XIOErrorHandlerImpl(Display *display)
+{
+    return 0;
 }
 
-static void TerminationSignalHandler(int signatl) {
+static void TerminationSignalHandler(int signatl)
+{
 
 }
 
 #endif
 
 
-
 namespace Atomic
 {
 
@@ -76,15 +78,15 @@ WebBrowserHost::WebBrowserHost(Context* context) : Object (context)
 
     const Vector<String>& arguments = GetArguments();
 
-    #ifdef ATOMIC_PLATFORM_LINUX
-      XSetErrorHandler(XErrorHandlerImpl);
-      XSetIOErrorHandler(XIOErrorHandlerImpl);
+#ifdef ATOMIC_PLATFORM_LINUX
+    XSetErrorHandler(XErrorHandlerImpl);
+    XSetIOErrorHandler(XIOErrorHandlerImpl);
 
-      // Install a signal handler so we clean up after ourselves.
-      signal(SIGINT, TerminationSignalHandler);
-      signal(SIGTERM, TerminationSignalHandler);
+    // Install a signal handler so we clean up after ourselves.
+    signal(SIGINT, TerminationSignalHandler);
+    signal(SIGTERM, TerminationSignalHandler);
 
-    #endif
+#endif
 
 
     // IMPORTANT: Cef::App contains virtual void OnBeforeCommandLineProcessing(), which should make it possible

+ 2 - 0
Source/AtomicWebView/WebBrowserHost.h

@@ -9,6 +9,8 @@ namespace Atomic
 class WebBrowserHostPrivate;
 class WebClient;
 
+
+/// Browser host subsystem, responsible for initializing CEF
 class ATOMIC_API WebBrowserHost : public Object
 {
     OBJECT(WebBrowserHost);

+ 34 - 3
Source/AtomicWebView/WebClient.h

@@ -12,6 +12,7 @@ namespace Atomic
 class WebClientPrivate;
 class WebMessageHandler;
 
+/// WebClient is the main interface for communicating with a browser instance
 class ATOMIC_API WebClient : public Object
 {
     friend class WebBrowserHost;
@@ -20,52 +21,82 @@ class ATOMIC_API WebClient : public Object
     OBJECT(WebClient)
 
 public:
+
     /// Construct.
     WebClient(Context* context);
 
     /// Destruct.
     virtual ~WebClient();
 
-    /// call once initialized with handlers
+    /// Create the browser, call only once initialized with handlers
     bool CreateBrowser(const String& initialURL, int width, int height);
 
+    /// Set the browser's width and height
     void SetSize(int width, int height);
 
-    void SetWebRenderHandler(WebRenderHandler* handler);
-
+    /// Send a mouse click event to the browser
     void SendMouseClickEvent(int x, int y, unsigned button, bool mouseUp, unsigned modifier) const;
+    /// Send a mouse press event to the browser
     void SendMousePressEvent(int x, int y, unsigned button = 0, unsigned modifier = 0) const;
+    /// Send a mouse move event to the browser
     void SendMouseMoveEvent(int x, int y, unsigned modifier, bool mouseLeave = false) const;
+    /// Send a mouse wheel event to the browser
     void SendMouseWheelEvent(int x, int y, unsigned modifier, int deltaX, int deltaY) const;
 
+    /// Send a focus event to the browser
     void SendFocusEvent(bool focus = true);
 
+    /// Send a TextInput event to the browser
     void SendTextInputEvent(const StringHash eventType, VariantMap& eventData);
+    /// Send a key event to the browser
     void SendKeyEvent(const StringHash eventType, VariantMap& eventData);
 
+    // Shortcuts, note that some web pages (notably some text editors)
+    // only work with key events and not all shorcuts
+
+    /// Invoke the Cut shortcut on the browser's main frame
     void ShortcutCut();
+    /// Invoke the Copy shortcut on the browser's main frame
     void ShortcutCopy();
+    /// Invoke the Paste shortcut on the browser's main frame
     void ShortcutPaste();
+    /// Invoke the SelectAll shortcut on the browser's main frame
     void ShortcutSelectAll();
+    /// Invoke the Undo shortcut on the browser's main frame
     void ShortcutUndo();
+    /// Invoke the Redo shortcut on the browser's main frame
     void ShortcutRedo();
+    /// Invoke the Delete shortcut on the browser's main frame
     void ShortcutDelete();
 
+    /// Add a message handler to the WebClient
     void AddMessageHandler(WebMessageHandler* handler, bool first = false);
+    /// Remove a message handler to the WebClient
     void RemoveMessageHandler(WebMessageHandler* handler);
+
+    /// Execute some JavaScript in the browser
     void ExecuteJavaScript(const String& script);
 
     // Navigation
 
+    /// Returns true if the page is currently loading
     bool IsLoading();
 
     /// Load the specified url into the main frame of the browser
     void LoadURL(const String& url);
+
+    /// Go back in page history
     void GoBack();
+    /// Go forward in page history
     void GoForward();
 
+    /// Reload the current page
     void Reload();
 
+    /// Set the render handler for this client
+    void SetWebRenderHandler(WebRenderHandler* handler);
+
+    /// Get the (internal) CefClient for this WebClient
     CefClient* GetCefClient();
 
 private:

+ 4 - 0
Source/AtomicWebView/WebKeyboard.h

@@ -8,9 +8,13 @@ namespace Atomic
 
 class Input;
 
+/// Convert an Atomic KeyEvent to a CefKeyEvent, returns true if processing should continue
 bool ConvertKeyEvent(Input* input, const StringHash eventType, VariantMap& eventData, CefKeyEvent& keyEvent);
+/// Convert an Atomic TextInput to a CefKeyEvent, returns true if processing should continue
 bool ConvertTextInputEvent(const StringHash eventType, VariantMap& eventData, CefKeyEvent& keyEvent);
 
+
+/// A convenience structure to "parse" a KeyUp/KeyDown event
 struct WebKeyEvent
 {
     bool repeat;

+ 5 - 0
Source/AtomicWebView/WebMessageHandler.h

@@ -21,10 +21,15 @@ public:
     /// Destruct.
     virtual ~WebMessageHandler();
 
+    /// Success callback
     void Success(const String& response = String::EMPTY);
+    /// Failure callback
     void Failure(int errorCode, const String& errorMessage);
 
+    /// Get the WebClient associated with this WebMessageHandler
     WebClient* GetWebClient() { return client_; }
+
+    /// Set the WebClient associated with this WebMessageHandler
     void SetWebClient(WebClient* client) { client_ = client; }
 
     /// Get the CefMessageRouterBrowserSide::Handler* as a opaque void*

+ 9 - 1
Source/AtomicWebView/WebRenderHandler.h

@@ -11,6 +11,8 @@ namespace Atomic
 
 class WebClient;
 
+
+/// Base class for various WebRenderHandlers
 class ATOMIC_API WebRenderHandler : public Object
 {
     OBJECT(WebRenderHandler);
@@ -22,14 +24,20 @@ public:
     /// Destruct.
     virtual ~WebRenderHandler();
 
+    /// Get the current renderer width
     virtual int GetWidth() const = 0;
+    /// Get the current renderer height
     virtual int GetHeight() const = 0;
+    /// Get the WebClient associated with the render handler
+    WebClient* GetWebClient() const;
 
+    /// Set the dimensions of the render handler
     virtual void SetSize(int width, int height) = 0;
 
+    /// Set the render handlers WebClient
     void SetWebClient(WebClient* webClient);
-    WebClient* GetWebClient() const;
 
+    /// Get the (internal) CEFRenderHandler
     virtual CefRenderHandler* GetCEFRenderHandler() = 0;
 
 protected:

+ 2 - 0
Source/AtomicWebView/WebSchemeHandler.h

@@ -5,6 +5,8 @@ namespace Atomic
 {
 
 class WebBrowserHost;
+
+/// Registers atomic scheme handlers
 void RegisterWebSchemeHandlers(WebBrowserHost* host);
 
 }

+ 1 - 0
Source/AtomicWebView/WebString.h

@@ -6,6 +6,7 @@
 namespace Atomic
 {
 
+/// Convert a CEF3 string to a UTF8 String
 bool ConvertCEFString(const CefString& cefString, String& output);
 
 }

+ 10 - 6
Source/AtomicWebView/WebTexture2D.h

@@ -11,11 +11,13 @@ namespace Atomic
 
 class WebTexture2DPrivate;
 
+
+/// A render handler which uses a Texture2D and can be used for UI, 2D, and 3D rendering
 class ATOMIC_API WebTexture2D : public WebRenderHandler
 {
     friend class WebTexture2DPrivate;
 
-    OBJECT(WebTexture2D);
+    OBJECT(WebTexture2D)
 
 public:
 
@@ -24,20 +26,22 @@ public:
     /// Destruct.
     virtual ~WebTexture2D();
 
-    int GetWidth() const;
+    /// Get the current width of the texture
+    int GetWidth() const;    
+    /// Get the current height of the texture
     int GetHeight() const;
+    /// Get the Texture2D associated with the WebTexture2D
+    Texture2D* GetTexture2D() const { return texture_; }
 
+    /// Set the dimensions of the texture
     void SetSize(int width, int height);
 
+    /// Get the (internal) CEFRenderHandler
     CefRenderHandler* GetCEFRenderHandler();
 
-    Texture2D* GetTexture2D() const { return texture_; }
-    Material* GetMaterial() const { return material_; }
-
 private:
 
     SharedPtr<Texture2D> texture_;
-    SharedPtr<Material> material_;
 
     WebTexture2DPrivate* d_;