Skip to content
This repository was archived by the owner on Sep 7, 2021. It is now read-only.

Commit 9f2da2c

Browse files
committed
[[ libbrowser ]] Update engine LCB browser module
This patch adds new properties and foreign handlers to the engine browser LCB module, bringing it up to date with changes to the libbrowser C API
1 parent c0a2d80 commit 9f2da2c

File tree

1 file changed

+97
-16
lines changed

1 file changed

+97
-16
lines changed

engine/src/browser.lcb

Lines changed: 97 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@ metadata version is "1.0.0"
4343
-- foreign types
4444
public type MCBrowserFactoryRef is Pointer
4545
public type MCBrowserRef is Pointer
46+
public type MCBrowserNavigationRequestRef is Pointer
4647

4748
public type MCBrowserListRef is Pointer
4849
public type MCBrowserDictionaryRef is Pointer
4950

5051
public type MCBrowserProperty is CInt
5152
public type MCBrowserValueType is CInt
52-
public type MCBrowserRequestType is CInt
53-
public type MCBrowserRequestState is CInt
53+
public type MCBrowserNavigationEventType is CInt
54+
public type MCBrowserNavigationState is CInt
55+
public type MCBrowserNavigationType is CInt
5456

5557
--
5658

@@ -74,17 +76,31 @@ public foreign handler MCBrowserGetNativeLayer(in pBrowser as MCBrowserRef) retu
7476

7577
public foreign handler MCBrowserGetBoolProperty(in pBrowser as MCBrowserRef, in pProperty as MCBrowserProperty, out rValue as CBool) returns CBool binds to "<builtin>"
7678
public foreign handler MCBrowserSetBoolProperty(in pBrowser as MCBrowserRef, in pProperty as MCBrowserProperty, in pValue as CBool) returns CBool binds to "<builtin>"
77-
7879
public foreign handler MCBrowserGetStringProperty(in pBrowser as MCBrowserRef, in pProperty as MCBrowserProperty, out rValue as ZStringUTF8) returns CBool binds to "<builtin>"
7980
public foreign handler MCBrowserSetStringProperty(in pBrowser as MCBrowserRef, in pProperty as MCBrowserProperty, in pValue as ZStringUTF8) returns CBool binds to "<builtin>"
81+
public foreign handler MCBrowserGetIntegerProperty(in pBrowser as MCBrowserRef, in pProperty as MCBrowserProperty, out rValue as Int32) returns CBool binds to "<builtin>"
82+
public foreign handler MCBrowserSetIntegerProperty(in pBrowser as MCBrowserRef, in pProperty as MCBrowserProperty, in pValue as Int32) returns CBool binds to "<builtin>"
8083

8184
public foreign handler MCBrowserGoBack(in pBrowser as MCBrowserRef) returns CBool binds to "<builtin>"
8285
public foreign handler MCBrowserGoForward(in pBrowser as MCBrowserRef) returns CBool binds to "<builtin>"
8386
public foreign handler MCBrowserGoToURL(in pBrowser as MCBrowserRef, in pURL as ZStringUTF8) returns CBool binds to "<builtin>"
87+
public foreign handler MCBrowserLoadHTMLText(in pBrowser as MCBrowserRef, in pHTMLText as ZStringUTF8, in pBaseURL as ZStringUTF8) returns CBool binds to "<builtin>"
88+
public foreign handler MCBrowserStopLoading(in pBrowser as MCBrowserRef) returns CBool binds to "<builtin>"
89+
public foreign handler MCBrowserReload(in pBrowser as MCBrowserRef) returns CBool binds to "<builtin>"
8490
public foreign handler MCBrowserEvaluateJavaScript(in pBrowser as MCBrowserRef, in pScript as ZStringUTF8, out rResult as ZStringUTF8) returns CBool binds to "<builtin>"
8591

8692
----------
8793

94+
public foreign handler MCBrowserNavigationRequestRetain(in pBrowserNavigationRequestRef as MCBrowserNavigationRequestRef) returns MCBrowserNavigationRequestRef binds to "<builtin>"
95+
public foreign handler MCBrowserNavigationRequestRelease(in pBrowserNavigationRequestRef as MCBrowserNavigationRequestRef) returns nothing binds to "<builtin>"
96+
public foreign handler MCBrowserNavigationRequestGetURL(in pBrowserNavigationRequestRef as MCBrowserNavigationRequestRef, out rURL as ZStringUTF8) returns CBool binds to "<builtin>"
97+
public foreign handler MCBrowserNavigationRequestGetNavigationType(in pBrowserNavigationRequestRef as MCBrowserNavigationRequestRef, out rType as MCBrowserNavigationType) returns CBool binds to "<builtin>"
98+
public foreign handler MCBrowserNavigationRequestIsFrame(in pBrowserNavigationRequestRef as MCBrowserNavigationRequestRef, out rIsFrame as CBool) returns CBool binds to "<builtin>"
99+
public foreign handler MCBrowserNavigationRequestContinue(in pBrowserNavigationRequestRef as MCBrowserNavigationRequestRef) returns CBool binds to "<builtin>"
100+
public foreign handler MCBrowserNavigationRequestCancel(in pBrowserNavigationRequestRef as MCBrowserNavigationRequestRef) returns CBool binds to "<builtin>"
101+
102+
----------
103+
88104
public foreign handler MCBrowserListGetSize(in pList as MCBrowserListRef, out rSize as UInt32) returns CBool binds to "<builtin>"
89105
public foreign handler MCBrowserListGetType(in pList as MCBrowserListRef, in pIndex as UInt32, out rType as MCBrowserValueType) returns CBool binds to "<builtin>"
90106
public foreign handler MCBrowserListGetBoolean(in pList as MCBrowserListRef, in pIndex as UInt32, out rValue as CBool) returns CBool binds to "<builtin>"
@@ -108,11 +124,13 @@ public foreign handler MCBrowserDictionaryGetUTF8String(in pDictionary as MCBrow
108124
public foreign handler MCBrowserDictionaryGetList(in pDictionary as MCBrowserDictionaryRef, in pKey as ZStringUTF8, out rValue as MCBrowserListRef) returns CBool binds to "<builtin>"
109125
public foreign handler MCBrowserDictionaryGetDictionary(in pDictionary as MCBrowserDictionaryRef, in pKey as ZStringUTF8, out rValue as MCBrowserDictionaryRef) returns CBool binds to "<builtin>"
110126

111-
public foreign handler type MCBrowserRequestCallback(in pContext as optional Pointer, in pBrowser as MCBrowserRef, in pType as MCBrowserRequestType, in pState as MCBrowserRequestState, in pFrame as CBool, in pUrl as ZStringUTF8, in pError as optional ZStringUTF8) returns nothing
127+
public foreign handler type MCBrowserNavigationRequestCallback(in pContext as optional Pointer, in pBrowser as MCBrowserRef, in pRequest as MCBrowserNavigationRequestRef) returns CBool
128+
public foreign handler type MCBrowserNavigationCallback(in pContext as optional Pointer, in pBrowser as MCBrowserRef, in pType as MCBrowserNavigationEventType, in pState as MCBrowserNavigationState, in pFrame as CBool, in pUrl as ZStringUTF8, in pError as optional ZStringUTF8) returns nothing
112129
public foreign handler type MCBrowserJavaScriptCallback(in pContext as optional Pointer, in pBrowser as MCBrowserRef, in pHandler as ZStringUTF8, in pParams as MCBrowserListRef) returns nothing
113130
public foreign handler type MCBrowserProgressCallback(in pContext as optional Pointer, in pBrowser as MCBrowserRef, in pUrl as ZStringUTF8, in pProgress as UInt32) returns nothing
114131

115-
public foreign handler MCBrowserSetRequestHandler(in pBrowser as MCBrowserRef, in pCallback as optional MCBrowserRequestCallback, in pContext as optional Pointer) returns CBool binds to "<builtin>"
132+
public foreign handler MCBrowserSetNavigationRequestHandler(in pBrowser as MCBrowserRef, in pCallback as optional MCBrowserNavigationRequestCallback, in pContext as optional Pointer) returns CBool binds to "<builtin>"
133+
public foreign handler MCBrowserSetNavigationHandler(in pBrowser as MCBrowserRef, in pCallback as optional MCBrowserNavigationCallback, in pContext as optional Pointer) returns CBool binds to "<builtin>"
116134
public foreign handler MCBrowserSetJavaScriptHandler(in pBrowser as MCBrowserRef, in pCallback as optional MCBrowserJavaScriptCallback, in pContext as optional Pointer) returns CBool binds to "<builtin>"
117135
public foreign handler MCBrowserSetProgressHandler(in pBrowser as MCBrowserRef, in pCallback as optional MCBrowserProgressCallback, in pContext as optional Pointer) returns CBool binds to "<builtin>"
118136

@@ -138,34 +156,93 @@ public constant kMCBrowserPropertyUrl is 6
138156
public constant kMCBrowserPropertyHtmlText is 7
139157
public constant kMCBrowserPropertyUserAgent is 8
140158
public constant kMCBrowserPropertyJavaScriptHandlers is 9
159+
public constant kMCBrowserPropertyiOSDelayRequests is 10
160+
public constant kMCBrowserPropertyiOSAllowsInlineMediaPlayback is 11
161+
public constant kMCBrowserPropertyiOSMediaPlaybackRequiresUserAction is 12
162+
public constant kMCBrowserPropertyiOSAutoFit is 13
163+
public constant kMCBrowserPropertyCanGoForward is 14
164+
public constant kMCBrowserPropertyCanGoBack is 15
165+
public constant kMCBrowserPropertyDataDetectorTypes is 16
166+
public constant kMCBrowserPropertyScrollEnabled is 17
167+
public constant kMCBrowserPropertyScrollCanBounce is 18
168+
169+
public constant kMCBrowserPropertyMap is [ \
170+
"verticalScrollbarEnabled", \
171+
"horizontalScrollbarEnabled", \
172+
"allowNewWindows", \
173+
"enableContextMenu", \
174+
"allowUserInteraction", \
175+
"isSecure", \
176+
"url", \
177+
"htmlText", \
178+
"userAgent", \
179+
"javaScriptHandlers", \
180+
"delayRequests", \
181+
"allowsInlineMediaPlayback", \
182+
"mediaPlaybackRequiresUserAction", \
183+
"autoFit", \
184+
"canGoForward", \
185+
"canGoBack", \
186+
"dataDetectorTypes", \
187+
"scrollEnabled", \
188+
"scrollCanBounce" \
189+
]
141190

142-
public constant kMCBrowserPropertyMap is ["verticalScrollbarEnabled", "horizontalScrollbarEnabled", "allowNewWindows", "enableContextMenu", "allowUserInteraction", "isSecure", "url", "htmlText", "userAgent", "javaScriptHandlers"]
191+
--
192+
193+
public constant kMCBrowserNavigationTypeFollowLink is 0
194+
public constant kMCBrowserNavigationTypeSubmitForm is 1
195+
public constant kMCBrowserNavigationTypeBackForward is 2
196+
public constant kMCBrowserNavigationTypeReload is 3
197+
public constant kMCBrowserNavigationTypeResubmitForm is 4
198+
public constant kMCBrowserNavigationTypeOther is 5
199+
200+
public constant kMCBrowserNavigationTypeMap is ["followLink", "submitForm", "backForward", "reload", "resubmitForm", "other"]
143201

144202
--
145203

146-
public constant kMCBrowserRequestTypeNavigate is 0
147-
public constant kMCBrowserRequestTypeDocumentLoad is 1
204+
public constant kMCBrowserNavigationEventTypeNavigate is 0
205+
public constant kMCBrowserNavigationEventTypeDocumentLoad is 1
148206

149-
public constant kMCBrowserRequestTypeMap is ["navigate", "documentLoad"]
207+
public constant kMCBrowserNavigationEventTypeMap is ["navigate", "documentLoad"]
150208

151209
--
152210

153-
public constant kMCBrowserRequestStateBegin is 0
154-
public constant kMCBrowserRequestStateComplete is 1
155-
public constant kMCBrowserRequestStateFailed is 2
156-
public constant kMCBrowserRequestStateUnhandled is 3
211+
public constant kMCBrowserNavigationStateBegin is 0
212+
public constant kMCBrowserNavigationStateComplete is 1
213+
public constant kMCBrowserNavigationStateFailed is 2
214+
public constant kMCBrowserNavigationStateUnhandled is 3
157215

158-
public constant kMCBrowserRequestStateMap is ["begin", "complete", "failed", "unhandled"]
216+
public constant kMCBrowserNavigationStateMap is ["begin", "complete", "failed", "unhandled"]
159217

160218
--
161219

162220
-- constant kStringProps is ["url", "htmlText", "userAgent", "javaScriptHandlers"]
163221
-- TODO - replace literal values with constants when possible
164222
constant kStringProps is [6, 7, 8, 9]
165223

166-
-- constant kBoolProps is ["verticalScrollbarEnabled", "horizontalScrollbarEnabled", "allowNewWindows", "enableContextMenu", "allowUserInteraction", "isSecure"]
224+
-- constant kBoolProps is [ \
225+
-- "verticalScrollbarEnabled", \
226+
-- "horizontalScrollbarEnabled", \
227+
-- "allowNewWindows", \
228+
-- "enableContextMenu", \
229+
-- "allowUserInteraction", \
230+
-- "isSecure", \
231+
-- "delayRequests", \
232+
-- "allowsInlineMediaPlayback", \
233+
-- "mediaPlaybackRequiresUserAction", \
234+
-- "autoFit", \
235+
-- "canGoForward", \
236+
-- "canGoBack", \
237+
-- "scrollEnabled", \
238+
-- "scrollCanBounce", \
239+
--]
240+
-- TODO - replace literal values with constants when possible
241+
constant kBoolProps is [0, 1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 17, 18]
242+
243+
-- constant kIntProps is [ "dataDetectorTypes" ]
167244
-- TODO - replace literal values with constants when possible
168-
constant kBoolProps is [0, 1, 2, 3, 4, 5]
245+
constant kIntProps is [ 16 ]
169246

170247
--------------------------------------------------------------------------------
171248

@@ -392,6 +469,8 @@ public handler browserGetEnumProperty(in pBrowser as MCBrowserRef, in pProperty
392469
return MCBrowserGetStringProperty(pBrowser, pProperty, rValue)
393470
else if pProperty is in kBoolProps then
394471
return MCBrowserGetBoolProperty(pBrowser, pProperty, rValue)
472+
else if pProperty is in kIntProps then
473+
return MCBrowserGetIntegerProperty(pBrowser, pProperty, rValue)
395474
end if
396475
end unsafe
397476

@@ -413,6 +492,8 @@ public handler browserSetEnumProperty(in pBrowser as MCBrowserRef, in pProperty
413492
return MCBrowserSetStringProperty(pBrowser, pProperty, pValue)
414493
else if pProperty is in kBoolProps then
415494
return MCBrowserSetBoolProperty(pBrowser, pProperty, pValue)
495+
else if pProperty is in kIntProps then
496+
return MCbrowserSetIntegerProperty(pBrowser, pProperty, pValue)
416497
end if
417498
end unsafe
418499

0 commit comments

Comments
 (0)