1 module awebview.wrapper.webcore; 2 3 import awebview.wrapper.cpp; 4 import awebview.wrapper.cpp.mmanager; 5 import awebview.wrapper.webconfig : WebConfig; 6 import awebview.wrapper.websession : WebSession; 7 import awebview.wrapper.webstring : WebString; 8 //import awebview.wrapper.websession : WebSession; 9 import awebview.wrapper.webview : WebView; 10 import awebview.wrapper.webpreferences : WebPreferences; 11 //import awebview.wrapper.surface; 12 import awebview.wrapper.resourceinterceptor : ResourceInterceptor; 13 import awebview.wrapper.cpp : WebViewType; 14 15 16 struct WebCore 17 { 18 static 19 WebCore initialize(const ref WebConfig config) nothrow 20 { 21 _instance = WebCore(config); 22 return _instance; 23 } 24 25 26 static initialize() nothrow 27 { 28 auto wc = WebConfig(); 29 _instance = WebCore(wc); 30 return _instance; 31 } 32 33 34 static 35 void shutdown() nothrow @nogc 36 { 37 WebCoreMember.Shutdown(); 38 } 39 40 41 static 42 WebCore instance() nothrow @safe @nogc @property 43 { 44 return _instance; 45 } 46 47 48 @property 49 inout(awebview.wrapper.cpp.WebCore) cppObj() inout pure nothrow @safe @nogc { return _cppObj; } 50 51 52 WebSession createWebSession(in WebString str, in WebPreferences prefs) 53 { 54 awebview.wrapper.cpp.WebSession co = WebCoreMember.CreateWebSession(this.cppObj, str.cppObj, prefs.cppObj); 55 return new WebSession(co); 56 } 57 58 59 WebView createWebView(int w, int h, WebSession session, WebViewType type) 60 { 61 awebview.wrapper.cpp.WebSession cppSession; 62 if(session !is null) 63 cppSession = session.cppObj; 64 65 awebview.wrapper.cpp.WebView co = WebCoreMember.CreateWebView(this.cppObj, w, h, cppSession, type); 66 return WebView(co); 67 } 68 69 70 //@property 71 //void surfaceFactory(ISurfaceFactory factory) 72 //{ 73 // WebCoreMember.set_surface_factory(this.cppObj, factory.cppObj); 74 //} 75 76 77 //@property 78 //ISurfaceFactory surfaceFactory() 79 //{ 80 // return new SurfaceFactoryCpp2D(WebCoreMember.surface_factory(this.cppObj)); 81 //} 82 83 84 @property 85 void resourceInterceptor(ResourceInterceptor ri) 86 { 87 WebCoreMember.set_resource_interceptor(this.cppObj, ri.cppObj); 88 } 89 90 91 //@property 92 //IResourceInterceptor resourceInterceptor() 93 //{ 94 // return new ResourceInterceptorCpp2D(WebCoreMember.resource_interceptor(this.cppObj)); 95 //} 96 97 98 void update() nothrow @nogc 99 { 100 WebCoreMember.Update(this.cppObj); 101 } 102 103 104 static @property 105 uint usedMemory() nothrow @nogc 106 { 107 return WebCoreMember.used_memory(); 108 } 109 110 111 static @property 112 uint allocatedMemory() nothrow @nogc 113 { 114 return WebCoreMember.allocated_memory(); 115 } 116 117 118 static 119 void releaseMemory() nothrow @nogc 120 { 121 WebCoreMember.release_memory(); 122 } 123 124 125 private: 126 awebview.wrapper.cpp.WebCore _cppObj; 127 128 static WebCore _instance; 129 130 this(const ref WebConfig config) nothrow @nogc 131 { 132 this(WebCoreMember.Initialize(config.cppObj)); 133 } 134 135 136 this(awebview.wrapper.cpp.WebCore cppObj) pure nothrow @nogc 137 { 138 _cppObj = cppObj; 139 } 140 }