Skip to content

Commit

Permalink
add Window class properties
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy committed Sep 14, 2018
1 parent 33ad442 commit 141331a
Show file tree
Hide file tree
Showing 11 changed files with 443 additions and 102 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ set(SOURCES src/array.cc
src/webgl_context_attributes.cc
src/webgl_extension.cc
src/xml_http_request.cc
src/application_cache.cc
src/external.cc
src/history.cc
src/bar_prop.cc
)

if ($ENV{ENABLE_EMSCRIPTEN})
Expand Down
32 changes: 32 additions & 0 deletions include/application_cache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include "event_target.h"

class ApplicationCache : public EventTarget {
public:
enum {
UNCACHED = 0,
IDLE = 1,
CHECKING = 2,
DOWNLOADING = 3,
UPDATEREADY = 4,
OBSOLETE = 5,
};

HTML5_EVENT_HANDLER_PROPERTY(ApplicationCache, EventHandler *, oncached);
HTML5_EVENT_HANDLER_PROPERTY(ApplicationCache, EventHandler *, onchecking);
HTML5_EVENT_HANDLER_PROPERTY(ApplicationCache, EventHandler *, ondownloading);
HTML5_EVENT_HANDLER_PROPERTY(ApplicationCache, EventHandler *, onerror);
HTML5_EVENT_HANDLER_PROPERTY(ApplicationCache, EventHandler *, onnoupdate);
HTML5_EVENT_HANDLER_PROPERTY(ApplicationCache, EventHandler *, onobsolete);
HTML5_EVENT_HANDLER_PROPERTY(ApplicationCache, EventHandler *, onprogress);
HTML5_EVENT_HANDLER_PROPERTY(ApplicationCache, EventHandler *, onupdateready);
HTML5_PROPERTY(ApplicationCache, unsigned short, status);

ApplicationCache(emscripten::val v);
virtual ~ApplicationCache();
static ApplicationCache *create(emscripten::val v);
void abort();
void swapCache();
void update();
};
13 changes: 13 additions & 0 deletions include/bar_prop.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include "libhtml5.h"

class BarProp : public Object {
public:
emscripten::val v;
HTML5_PROPERTY(BarProp, bool, visible);

BarProp(emscripten::val v);
virtual ~BarProp();
static BarProp *create(emscripten::val v);
};
14 changes: 14 additions & 0 deletions include/external.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include "libhtml5.h"

class External : public Object {
public:
emscripten::val v;

External(emscripten::val v);
virtual ~External();
static External *create(emscripten::val v);
void AddSearchProvider(std::string engineURL);
unsigned long IsSearchProviderInstalled(std::string engineURL);
};
19 changes: 19 additions & 0 deletions include/history.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include "libhtml5.h"

class History : public Object {
public:
emscripten::val v;
HTML5_READONLY_PROPERTY(History, long, length);
//HTML5_PROPERTY(History, void *, state);

History(emscripten::val v);
virtual ~History();
static History *create(emscripten::val v);
void back();
void forward();
void go(long delta = 0);
void pushState(void *data, std::string title, std::string url);
void replaceState(void *data, std::string title, std::string url);
};
214 changes: 112 additions & 102 deletions include/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class ApplicationCache;
class Document;
class External;
class Element;
class WindowProxy;
class History;
class IDBFactory;
class Storage;
Expand All @@ -26,110 +25,112 @@ class CanvasRenderingContext2D;
class ImageBitmap;
class Transferable;
class Performance;
class WindowProxy;

class Window : public EventTarget {
public:
ApplicationCache *_applicationCache;
bool _closed;
Document *_document;
External *_external;
Element *_frameElement;
WindowProxy *_frames;
History *_history;
IDBFactory *_indexedDB;
unsigned long _length;
Storage *_localStorage;
Location *_location;
BarProp *_locationbar;
BarProp *_menubar;
std::string _name;
Navigator *_navigator;
EventHandler *_onabort;
EventHandler *_onafterprint;
EventHandler *_onautocomplete;
EventHandler *_onautocompleteerror;
EventHandler *_onbeforeprint;
EventHandler *_onbeforeunload;
EventHandler *_onblur;
EventHandler *_oncancel;
EventHandler *_oncanplay;
EventHandler *_oncanplaythrough;
EventHandler *_onchange;
EventHandler *_onclick;
EventHandler *_onclose;
EventHandler *_oncontextmenu;
EventHandler *_oncuechange;
EventHandler *_ondblclick;
EventHandler *_ondrag;
EventHandler *_ondragend;
EventHandler *_ondragenter;
EventHandler *_ondragexit;
EventHandler *_ondragleave;
EventHandler *_ondragover;
EventHandler *_ondragstart;
EventHandler *_ondrop;
EventHandler *_ondurationchange;
EventHandler *_onemptied;
EventHandler *_onended;
OnErrorEventHandler *_onerror;
EventHandler *_onfocus;
EventHandler *_oninput;
EventHandler *_oninvalid;
EventHandler *_onkeydown;
EventHandler *_onkeypress;
EventHandler *_onkeyup;
EventHandler *_onlanguagechange;
EventHandler *_onload;
EventHandler *_onloadeddata;
EventHandler *_onloadedmetadata;
EventHandler *_onloadstart;
EventHandler *_onmessage;
EventHandler *_onmousedown;
EventHandler *_onmouseenter;
EventHandler *_onmouseleave;
EventHandler *_onmousemove;
EventHandler *_onmouseout;
EventHandler *_onmouseover;
EventHandler *_onmouseup;
EventHandler *_onmousewheel;
EventHandler *_onoffline;
EventHandler *_ononline;
EventHandler *_onpagehide;
EventHandler *_onpageshow;
EventHandler *_onpause;
EventHandler *_onplay;
EventHandler *_onplaying;
EventHandler *_onpopstate;
EventHandler *_onratechange;
EventHandler *_onreset;
EventHandler *_onresize;
EventHandler *_onscroll;
EventHandler *_onseeked;
EventHandler *_onseeking;
EventHandler *_onselect;
EventHandler *_onshow;
EventHandler *_onsort;
EventHandler *_onstalled;
EventHandler *_onstorage;
EventHandler *_onsubmit;
EventHandler *_onsuspend;
EventHandler *_ontimeupdate;
EventHandler *_ontoggle;
EventHandler *_onunload;
EventHandler *_onvolumechange;
EventHandler *_onwaiting;
WindowProxy *_opener;
WindowProxy *_parent;
BarProp *_personalbar;
BarProp *_scrollbars;
WindowProxy *_self;
Storage *_sessionStorage;
std::string _status;
BarProp *_statusbar;
BarProp *_toolbar;
WindowProxy *_top;
WindowProxy *_window;
Performance *_performance;

HTML5_PROPERTY(Window, ApplicationCache *, applicationCache);
HTML5_PROPERTY(Window, bool, closed);
HTML5_PROPERTY(Window, Document *, document);
HTML5_PROPERTY(Window, External *, external);
HTML5_PROPERTY(Window, Element *, frameElement);
HTML5_PROPERTY(Window, WindowProxy *, frames);
HTML5_PROPERTY(Window, History *, history);
HTML5_PROPERTY(Window, IDBFactory *, indexedDB);
HTML5_PROPERTY(Window, unsigned long, length);
HTML5_PROPERTY(Window, Storage *, localStorage);
HTML5_PROPERTY(Window, Location *, location);
HTML5_PROPERTY(Window, BarProp *, locationbar);
HTML5_PROPERTY(Window, BarProp *, menubar);
HTML5_PROPERTY(Window, std::string, name);
HTML5_PROPERTY(Window, Navigator *, navigator);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onabort);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onafterprint);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onautocomplete);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onautocompleteerror);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onbeforeprint);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onbeforeunload);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onblur);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, oncancel);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, oncanplay);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, oncanplaythrough);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onchange);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onclick);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onclose);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, oncontextmenu);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, oncuechange);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ondblclick);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ondrag);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ondragend);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ondragenter);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ondragexit);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ondragleave);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ondragover);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ondragstart);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ondrop);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ondurationchange);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onemptied);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onended);
HTML5_ERROR_HANDLER_PROPERTY(Window, OnErrorEventHandler *, onerror);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onfocus);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, oninput);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, oninvalid);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onkeydown);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onkeypress);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onkeyup);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onlanguagechange);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onload);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onloadeddata);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onloadedmetadata);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onloadstart);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onmessage);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onmousedown);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onmouseenter);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onmouseleave);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onmousemove);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onmouseout);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onmouseover);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onmouseup);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onmousewheel);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onoffline);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ononline);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onpagehide);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onpageshow);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onpause);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onplay);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onplaying);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onpopstate);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onratechange);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onreset);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onresize);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onscroll);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onseeked);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onseeking);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onselect);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onshow);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onsort);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onstalled);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onstorage);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onsubmit);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onsuspend);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ontimeupdate);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, ontoggle);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onunload);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onvolumechange);
HTML5_EVENT_HANDLER_PROPERTY(Window, EventHandler *, onwaiting);
HTML5_PROPERTY(Window, WindowProxy *, opener);
HTML5_PROPERTY(Window, WindowProxy *, parent);
HTML5_PROPERTY(Window, BarProp *, personalbar);
HTML5_PROPERTY(Window, BarProp *, scrollbars);
HTML5_PROPERTY(Window, WindowProxy *, self);
HTML5_PROPERTY(Window, Storage *, sessionStorage);
HTML5_PROPERTY(Window, std::string, status);
HTML5_PROPERTY(Window, BarProp *, statusbar);
HTML5_PROPERTY(Window, BarProp *, toolbar);
HTML5_PROPERTY(Window, WindowProxy *, top);
HTML5_PROPERTY(Window, WindowProxy *, window);
HTML5_PROPERTY(Window, Performance *, performance);

Window(emscripten::val v);
virtual ~Window();
Expand Down Expand Up @@ -163,3 +164,12 @@ class Window : public EventTarget {
long setTimeout(std::function<void(void)> handler, long timeout);
void stop();
};

class WindowProxy : public Window {
public:

WindowProxy(emscripten::val v);
virtual ~WindowProxy();
static WindowProxy *create(emscripten::val v);
};

44 changes: 44 additions & 0 deletions src/application_cache.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "application_cache.h"

ApplicationCache::ApplicationCache(emscripten::val v) :
EventTarget(v)
{

}

ApplicationCache::~ApplicationCache()
{

}

ApplicationCache *ApplicationCache::create(emscripten::val v)
{
auto cache = new ApplicationCache(v);
cache->autorelease();
return cache;
}

void ApplicationCache::abort()
{
HTML5_CALL(this->v, abort);
}

void ApplicationCache::swapCache()
{
HTML5_CALL(this->v, swapCache);
}

void ApplicationCache::update()
{
HTML5_CALL(this->v, update);
}

HTML5_EVENT_HANDLER_PROPERTY_IMPL(ApplicationCache, EventHandler *, oncached);
HTML5_EVENT_HANDLER_PROPERTY_IMPL(ApplicationCache, EventHandler *, onchecking);
HTML5_EVENT_HANDLER_PROPERTY_IMPL(ApplicationCache, EventHandler *, ondownloading);
HTML5_EVENT_HANDLER_PROPERTY_IMPL(ApplicationCache, EventHandler *, onerror);
HTML5_EVENT_HANDLER_PROPERTY_IMPL(ApplicationCache, EventHandler *, onnoupdate);
HTML5_EVENT_HANDLER_PROPERTY_IMPL(ApplicationCache, EventHandler *, onobsolete);
HTML5_EVENT_HANDLER_PROPERTY_IMPL(ApplicationCache, EventHandler *, onprogress);
HTML5_EVENT_HANDLER_PROPERTY_IMPL(ApplicationCache, EventHandler *, onupdateready);
HTML5_PROPERTY_IMPL(ApplicationCache, unsigned short, status);
22 changes: 22 additions & 0 deletions src/bar_prop.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "bar_prop.h"

BarProp::BarProp(emscripten::val v) :
Object(),
v(v)
{

}

BarProp::~BarProp()
{

}

BarProp *BarProp::create(emscripten::val v)
{
auto barProp = new BarProp(v);
barProp->autorelease();
return barProp;
}

HTML5_PROPERTY_IMPL(BarProp, bool, visible);
Loading

0 comments on commit 141331a

Please sign in to comment.