All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
WebBrowserCef::WebPage Class Reference

Off-screen web browser window showing one web page. More...

#include <WebBrowserCef/WebPage.hpp>

Inheritance diagram for WebBrowserCef::WebPage:
Valuable::Node Valuable::Attribute Patterns::NotCopyable Valuable::Serializable

Node Events

[OUT] address-changed (QString url)
 
[OUT] console-message (QString message, QString src, int line)
 
[OUT] editable-node-touched (Nimble::Vector2f boundsLow, Nimble::Vector2f boundsHigh, Nimble::Vector2f location)
 
[OUT] favicon-urls-changed (QString url...)
 
[OUT] focused-node-changed (bool editable, Nimble::Vector2f boundsLow, Nimble::Vector2f boundsHigh)
 
[OUT] load-error (long frameId, int errorCode, QString errorText, QString failedUrl)
 
[OUT] loading-state-changed (bool isLoading, bool canGoBack, bool canGoForward)
 
[OUT] plugin-crashed (QString pluginPath)
 naming convention: url vs address?
 
[OUT] title-changed (QString title)
 

Public Member Functions

CefRefPtr< CefBrowser > browser () const
 Low level access to CefBrowser. More...
 
CefRefPtr< CefBrowserHost > browserHost () const
 
const CefBrowserSettings & browserSettings () const
 Read-only access to CefBrowserSettings used in this browser.
 
bool canGoBack () const
 Returns true if the browser can navigate backwards, thread-safe.
 
bool canGoForward () const
 Returns true if the browser can navigate forwards, thread-safe.
 
WebPagePtr clone (bool copyUrl) const
 Makes a new WebPage using the same settings as this one.
 
std::shared_ptr< Luminous::ImagecontentImage () const
 Web page off-screen image buffer. More...
 
DownloadHandlerPtr downloadHandler () const
 
QList< QUrl > faviconUrls () const
 Favicon urls, thread-safe.
 
QString frameName () const
 
void goBack ()
 Navigate backwards, thread-safe.
 
void goForward ()
 Navigate forwards, thread-safe.
 
CefRefPtr< WebPageHandlerhandler () const
 WebPageHandler used in this browser. More...
 
int instanceId () const
 Browser instance id, different WebPage instances sharing the same session (like popup windows) share the same instanceId. More...
 
bool isLoading () const
 Returns true if the browser is currently loading, thread-safe.
 
bool isPopupVisible () const
 Should the popupImage be visible.
 
std::shared_ptr< Luminous::ImagepopupImage () const
 Web page consists of content image and then optional popup image that is drawn on top of the content image. More...
 
Nimble::Recti popupRect () const
 The location and size of the popup image, relative to the contentImage top-left corner. More...
 
void reload (bool ignoreCache)
 Reload the current page, thread-safe. More...
 
RequestHandlerPtr requestHandler () const
 Active request handler.
 
void sendKeyEvent (const Radiant::KeyEvent &event)
 Send key event to the browser.
 
void setDownloadHandler (DownloadHandlerPtr downloadHandler)
 Download handler setter and getter.
 
void setFrameName (const QString &frameName)
 
void setRequestHandler (RequestHandlerPtr requestHandler)
 Sets new request handler. More...
 
void setSize (Nimble::SizeI size)
 Sends a resize request to the browser engine. More...
 
void setUrl (const QUrl &url)
 Loads web page with the given url.
 
Nimble::SizeI size () const
 Browser window size in pixels.
 
void stopLoad ()
 Stop loading the page, thread-safe.
 
QString title () const
 Web page title, thread-safe.
 
QUrl url () const
 Current URL, thread-safe.
 
WebEnginePtr webEngine () const
 Every WebPage belongs to one WebEngine. More...
 
const CefWindowInfo & windowInfo () const
 Read-only access to CefWindowInfo used to create this web page.
 
- Public Member Functions inherited from Valuable::Node
bool acceptsEvent (const QByteArray &messageId) const
 Returns true if this object accepts event 'id' in eventProcess.
 
bool addAttribute (Attribute *const attribute)
 Adds a new Attribute to the list of attribute objects. More...
 
bool addAttribute (const QByteArray &name, Attribute *const attribute)
 Adds a new Attribute to the list of attribute objects.
 
template<typename Widget >
bool addAttribute (const QByteArray &name, const Radiant::IntrusivePtr< Widget > &attribute)
 Adds a new Attribute to the list of attribute objects. More...
 
long addListener (const QByteArray &attribute, v8::Persistent< v8::Function > func, int role=Attribute::CHANGE_ROLE)
 Add a JavaScript attribute listener to attribute belonging this Node. More...
 
virtual Attributeattribute (const QByteArray &name) const
 Gets an Attribute with the given name. More...
 
template<typename T >
AttributeT< T > * attribute (const QByteArray &name) const
 Gets an Attribute with the given name. More...
 
const containerattributes () const
 
void clearValues (Layer layer)
 Clears all Attribute values of the given layer. More...
 
void debugDump ()
 Prints the contents of this Attribute to the terminal.
 
virtual bool deserialize (const ArchiveElement &element)
 De-serializes this object (and its children) from a DOM node.
 
void eventAddDeprecated (const QByteArray &deprecatedId, const QByteArray &newId)
 Register a deprecated event that is automatically converted to new event id and a warning is issued when it is used. More...
 
void eventAddIn (const QByteArray &messageId)
 Registers a new event that this class handles in eventProcess.
 
template<typename Widget >
long eventAddListener (const QByteArray &eventId, const QByteArray &messageId, Radiant::IntrusivePtr< Widget > &listener, ListenerType listenerType=DIRECT, const Radiant::BinaryData *defaultData=0)
 Add an event listener to this object. More...
 
long eventAddListener (const QByteArray &eventId, const QByteArray &messageId, Valuable::Node *listener, ListenerType listenerType=DIRECT, const Radiant::BinaryData *defaultData=0)
 Add an event listener to this object. More...
 
long eventAddListener (const QByteArray &eventId, ListenerFuncVoid func, ListenerType listenerType=DIRECT)
 Add an event listener to this object. More...
 
long eventAddListener (const QByteArray &eventId, Node *dstNode, ListenerFuncVoid func, ListenerType listenerType=DIRECT)
 
long eventAddListenerBd (const QByteArray &eventId, Node *dstNode, ListenerFuncBd func, ListenerType listenerType=DIRECT)
 
long eventAddListenerBd (const QByteArray &eventId, ListenerFuncBd func, ListenerType listenerType=DIRECT)
 Add an event listener to this object. More...
 
void eventAddOut (const QByteArray &eventId)
 Registers a new event this class can send with eventSend.
 
const QSet< QByteArray > & eventInNames () const
 Returns set of all registered IN events.
 
unsigned eventListenerCount () const
 Returns the number of event listeners.
 
const QSet< QByteArray > & eventOutNames () const
 Returns set of all registered OUT events.
 
void eventPassingEnable (bool enable)
 Control whether events are passed.
 
template<typename Widget >
int eventRemoveListener (Radiant::IntrusivePtr< Widget > &listener)
 Removes all events from this object to given listener. More...
 
template<typename Widget >
int eventRemoveListener (const QByteArray &eventId=QByteArray(), const QByteArray &messageId=QByteArray(), Radiant::IntrusivePtr< Widget > &listener=Radiant::IntrusivePtr< Widget >())
 Removes events from this object that match the parameters. More...
 
int eventRemoveListener (const QByteArray &eventId=QByteArray(), const QByteArray &messageId=QByteArray(), Valuable::Node *listener=0)
 Removes event listeners from this object. More...
 
int eventRemoveListener (Valuable::Node *listener)
 Removes all events from this object to given listener. More...
 
bool eventRemoveListener (long listenerId)
 Removes event listener with given id. More...
 
void eventSend (const QByteArray &eventId, Radiant::BinaryData &bd)
 Sends an event and bd to all listeners on this eventId.
 
void eventSend (const QByteArray &eventId)
 Sends an event to all listeners on this eventId.
 
template<typename P1 >
void eventSend (const QByteArray &eventId, const P1 &p1)
 Sends an event to all listeners on this eventId. More...
 
template<typename P1 , typename P2 >
void eventSend (const QByteArray &eventId, const P1 &p1, const P2 &p2)
 Sends an event to all listeners on this eventId. More...
 
template<typename P1 , typename P2 , typename P3 >
void eventSend (const QByteArray &eventId, const P1 &p1, const P2 &p2, const P3 &p3)
 Sends an event to all listeners on this eventId. More...
 
template<typename P1 , typename P2 , typename P3 , typename P4 >
void eventSend (const QByteArray &eventId, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4)
 Sends an event to all listeners on this eventId. More...
 
template<typename P1 , typename P2 , typename P3 , typename P4 , typename P5 >
void eventSend (const QByteArray &eventId, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5)
 Sends an event to all listeners on this eventId. More...
 
unsigned eventSourceCount () const
 Returns the number of event sources.
 
Uuid id () const
 Returns the unique id.
 
bool isBeingDestroyed () const
 Returns true if we are about to delete this object. More...
 
bool loadFromFileXML (const QString &filename)
 Reads this object (and its children) from an XML file.
 
bool loadFromMemoryXML (const QByteArray &buffer)
 Reads this object (and its children) from a memory buffer.
 
 Node (Node *host, const QByteArray &name="", bool transit=false)
 Constructs a new Node and adds it under the given host. More...
 
 Node (Node &&node)
 Moves a node, including all its attributes, events etc. More...
 
Nodeoperator= (Node &&node)
 Moves a node, replacing this. More...
 
virtual bool readElement (const ArchiveElement &element)
 Handles a serialization element that lacks automatic handlers. More...
 
void removeAttribute (Attribute *const attribute)
 Removes an Attribute from the list of attribute objects.
 
bool saveToFileXML (const QString &filename, unsigned int opts=SerializationOptions::DEFAULTS) const
 Saves this object (and its children) to an XML file.
 
bool saveToMemoryXML (QByteArray &buffer, unsigned int opts=SerializationOptions::DEFAULTS) const
 Saves this object (and its children) to binary data buffer.
 
virtual ArchiveElement serialize (Archive &doc) const
 Serializes this object (and its children) to a DOM node.
 
virtual void setAsDefaults ()
 Sets the current USER attribute value as the default value and clears the USER value. More...
 
void setId (Uuid newId)
 Sets the unique id. More...
 
template<class T >
bool setValue (const QByteArray &name, const T &v)
 Uses a query string to find a Attribute, and sets a new value to that if found. More...
 
bool setValue (const QByteArray &name, v8::Handle< v8::Value > v)
 Set attribute value from JavaScript. More...
 
- Public Member Functions inherited from Valuable::Attribute
long addListener (ListenerFunc func, int role=CHANGE_ROLE)
 Adds a listener that is invoked whenever the value is changed. More...
 
long addListener (Node *listener, ListenerFunc func, int role=CHANGE_ROLE)
 Adds a listener that is invoked whenever the value is changed. More...
 
long addListener (v8::Persistent< v8::Function > func, int role=CHANGE_ROLE)
 Adds a JavaScript listener that is invoked whenever the value is changed. More...
 
virtual float asFloat (bool *const ok=0, Layer layer=LAYER_CURRENT) const
 Converts the value object in a floating point number. More...
 
virtual int asInt (bool *const ok=0, Layer layer=LAYER_CURRENT) const
 Converts the value object in an integer. More...
 
virtual QString asString (bool *const ok=0, Layer layer=LAYER_CURRENT) const
 Converts the value object to a string. More...
 
 Attribute (const Attribute &o)
 Create a copy of the given Attribute WITHOUT the link to host, listeners, or the attribute name. More...
 
 Attribute (Node *host, const QByteArray &name, bool transit=false)
 Constructs a new value object and attaches it to its host. More...
 
virtual void clearValue (Layer layer)
 Unsets the value from a specific layer. More...
 
virtual void emitChange ()
 Invokes the change valueChanged function of all listeners.
 
virtual void eventProcess (const QByteArray &id, Radiant::BinaryData &data)
 Process a message. More...
 
void eventProcessFloat (const char *id, float v)
 Utility function for sending a float message to the object.
 
void eventProcessInt (const char *id, int v)
 Utility function for sending an int message to the object.
 
void eventProcessString (const char *id, const QString &str)
 Utility function for sending string message to the object.
 
void eventProcessString (const char *id, const char *str)
 Utility function for sending string message to the object.
 
void eventProcessVector2 (const char *id, Nimble::Vector2)
 Utility function for sending a Nimble::Vector2f message to the object.
 
void eventProcessVector3 (const char *id, Nimble::Vector3)
 Utility function for sending a Vector3 message to the object.
 
void eventProcessVector4 (const char *id, Nimble::Vector4)
 Utility function for sending a Vector4 message to the object.
 
virtual bool handleShorthand (const Valuable::StyleValue &value, Radiant::ArrayMap< Valuable::Attribute *, Valuable::StyleValue > &expanded)
 If attribute supports shorthand properties, this should be used to parse those. More...
 
Nodehost () const
 The host object of the value object (is any). More...
 
virtual bool isChanged () const
 
virtual bool isValueDefinedOnLayer (Layer layer) const
 Check if the given layer defines a value. More...
 
bool layerForSerialization (SerializationOptions flags, Layer &layer) const
 
const QByteArray & name () const
 Returns the name of the object.
 
const Attributeoperator= (const Attribute &)
 Create a copy of the given Attribute WITHOUT the link to host, listeners, or the attribute name. More...
 
AttributeownerShorthand () const
 
QByteArray path () const
 Returns the path (separated by '/'s) from the root.
 
void removeHost ()
 Sets the host pointer to zero and removes this object from the host. More...
 
bool removeListener (Node *listener, int role=ALL_ROLES)
 Removes a listener from the listener list. More...
 
bool removeListener (long id)
 Removes a listener from the listener list. More...
 
void removeListeners (int role=ALL_ROLES)
 Removes listeners from the listener list.
 
virtual bool set (float v, Layer layer=USER, ValueUnit unit=VU_UNKNOWN)
 Sets the value of the object.
 
virtual bool set (int v, Layer layer=USER, ValueUnit unit=VU_UNKNOWN)
 Sets the value of the object.
 
virtual bool set (const QString &v, Layer layer=USER, ValueUnit unit=VU_UNKNOWN)
 Sets the value of the object.
 
virtual bool set (const Nimble::Vector2f &v, Layer layer=USER, QList< ValueUnit > units=QList< ValueUnit >())
 Sets the value of the object.
 
virtual bool set (const Nimble::Vector3f &v, Layer layer=USER, QList< ValueUnit > units=QList< ValueUnit >())
 Sets the value of the object.
 
virtual bool set (const Nimble::Vector4f &v, Layer layer=USER, QList< ValueUnit > units=QList< ValueUnit >())
 Sets the value of the object.
 
virtual bool set (const StyleValue &value, Layer layer=USER)
 Sets the value of the object.
 
void setName (const QByteArray &s)
 Sets the name of the object.
 
void setOwnerShorthand (Attribute *owner)
 
virtual QByteArray type () const
 Get the type id of the attribute. More...
 
- Public Member Functions inherited from Valuable::Serializable
virtual bool deserializeXML (const DOMElement &element)
 Deserializes (reads) this object from an XML element. More...
 
bool isSerializable () const
 
void setSerializable (bool v)
 

Static Public Member Functions

static WebPagePtr create (const WebPageSettings &settings=WebPageSettings(), const QUrl &url=QUrl())
 Create a new WebPage instance. More...
 
- Static Public Member Functions inherited from Valuable::Node
static bool copyValues (const Node &from, Node &to)
 Copies attribute values from one node to another. More...
 
static void disableQueue ()
 Disables all AFTER_UPDATE event processing, no new events will be accepted and the current queue will be cleared. More...
 
static Uuid generateId ()
 Generates a unique identifier. More...
 
static void invokeAfterUpdate (ListenerFuncVoid function)
 Queue function to be called in the main thread after the next update() More...
 
static int processQueue ()
 Triggers any pending AFTER_UPDATE-events. More...
 
static void reEnableQueue ()
 Enables queue after calling disableQueue. More...
 
static void setFatalOnEventMismatch (bool haltApplication)
 Controls what to do when an event mismatch is detected The default behavior is to output a warning to the terminal (haltApplication = false). More...
 

Friends

class DefaultHandler
 Private API, used by DefaultHandler and other handlers.
 
class WebPageHandler
 

Additional Inherited Members

- Public Types inherited from Valuable::Node
typedef container::const_iterator const_iterator
 
typedef Radiant::ArrayMap
< QByteArray, Attribute * > 
container
 Container for attributes, key is the attribute name.
 
typedef container::iterator iterator
 Iterator for the container.
 
typedef std::function< void(Radiant::BinaryData &)> ListenerFuncBd
 Listener function type that takes a BinaryData reference as a parameter, similar to eventProcess.
 
typedef std::function< void()> ListenerFuncVoid
 Default listener function type.
 
enum  ListenerType { DIRECT =1, AFTER_UPDATE =2, AFTER_UPDATE_ONCE =4 }
 Types of event listeners. More...
 
typedef int64_t Uuid
 Unique identifier type.
 
- Valuable Attributes inherited from Valuable::Node
Node::Uuid id = generateId()
 Returns the unique id. More...
 
- Protected Member Functions inherited from Valuable::Node
virtual void attributeAdded (Attribute *attribute)
 This is called when new attribute is added to Node. More...
 
virtual void attributeRemoved (Attribute *attribute)
 This is called when attribute is removed from Node. More...
 
Nodesender ()
 Get the sender of the event, only valid in DIRECT events. More...
 
void setBeingDestroyed ()
 Sets 'isBeginDestroyed' flag to true and removes all event listeners to this object. More...
 

Detailed Description

Off-screen web browser window showing one web page.

This can be displayed with WebPageWidget.

All of these events are sent from the browser UI thread, in most cases you want to use AFTER_UPDATE listeners with these.

Member Function Documentation

CefRefPtr<CefBrowser> WebBrowserCef::WebPage::browser ( ) const

Low level access to CefBrowser.

Use this and browserHost to send various commands to the browser.

CefRefPtr<CefBrowserHost> WebBrowserCef::WebPage::browserHost ( ) const
See Also
browser
std::shared_ptr<Luminous::Image> WebBrowserCef::WebPage::contentImage ( ) const

Web page off-screen image buffer.

This is thread-safe function, but the image data could be modified in browser UI thread at any time. However, the dirty rects in the texture will be updated in the main thread. Also the image size will never change nor will the data be reallocated. In those cases WebPage will just create another Luminous::Image.

static WebPagePtr WebBrowserCef::WebPage::create ( const WebPageSettings settings = WebPageSettings(),
const QUrl &  url = QUrl() 
)
static

Create a new WebPage instance.

WebPages are always used as shared pointers, so the normal constructor is not exposed.

Parameters given in WebPageSettings can't be changed on-fly in WebPage, create a new instance if you later need to change something.

Parameters
settingsInitialization settings for this web page
urlOptional url. The browser engine will be started only after the url becomes non-empty.
CefRefPtr<WebPageHandler> WebBrowserCef::WebPage::handler ( ) const

WebPageHandler used in this browser.

Use this class to inject your own CEF handlers for various callbacks and other features.

int WebBrowserCef::WebPage::instanceId ( ) const

Browser instance id, different WebPage instances sharing the same session (like popup windows) share the same instanceId.

std::shared_ptr<Luminous::Image> WebBrowserCef::WebPage::popupImage ( ) const

Web page consists of content image and then optional popup image that is drawn on top of the content image.

This is used for drop-down boxes, tooltips etc.

See Also
isPopupVisible
popupRect
Nimble::Recti WebBrowserCef::WebPage::popupRect ( ) const

The location and size of the popup image, relative to the contentImage top-left corner.

void WebBrowserCef::WebPage::reload ( bool  ignoreCache)

Reload the current page, thread-safe.

Parameters
ignoreCacheif true, ignores any cached data
void WebBrowserCef::WebPage::setRequestHandler ( RequestHandlerPtr  requestHandler)

Sets new request handler.

See Also
BrowserWidgetRequestHandler
void WebBrowserCef::WebPage::setSize ( Nimble::SizeI  size)

Sends a resize request to the browser engine.

After next repaints contentImage() will have this same size.

WebEnginePtr WebBrowserCef::WebPage::webEngine ( ) const

Every WebPage belongs to one WebEngine.

All browsers inside one WebEngine share the same message loop and other resources.