Skip to content

Commit 8524eb2

Browse files
committed
Merge pull request livecode#3124 from livecodeian/feature-browser_property_names
Feature browser property names
2 parents f91851a + 0a90ec2 commit 8524eb2

File tree

12 files changed

+281
-116
lines changed

12 files changed

+281
-116
lines changed

engine/src/browser.lcb

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,16 @@ public constant kMCBrowserValueTypeDictionary is 6
126126

127127
--
128128

129-
public constant kMCBrowserPropertyScrollbars is 0
130-
public constant kMCBrowserPropertyAllowNewWindows is 1
131-
public constant kMCBrowserPropertyEnableContextMenu is 2
132-
public constant kMCBrowserPropertyUrl is 3
133-
public constant kMCBrowserPropertyHtmlText is 4
134-
public constant kMCBrowserPropertyUserAgent is 5
135-
public constant kMCBrowserPropertyJavaScriptHandlers is 6
129+
public constant kMCBrowserPropertyVerticalScrollbarEnabled is 0
130+
public constant kMCBrowserPropertyHorizontalScrollbarEnabled is 1
131+
public constant kMCBrowserPropertyAllowNewWindows is 2
132+
public constant kMCBrowserPropertyEnableContextMenu is 3
133+
public constant kMCBrowserPropertyUrl is 4
134+
public constant kMCBrowserPropertyHtmlText is 5
135+
public constant kMCBrowserPropertyUserAgent is 6
136+
public constant kMCBrowserPropertyJavaScriptHandlers is 7
136137

137-
public constant kMCBrowserPropertyMap is ["scrollbars", "allowNewWindows", "enableContextMenu", "url", "htmlText", "userAgent", "javaScriptHandlers"]
138+
public constant kMCBrowserPropertyMap is ["verticalScrollbarEnabled", "horizontalScrollbarEnabled", "allowNewWindows", "enableContextMenu", "url", "htmlText", "userAgent", "javaScriptHandlers"]
138139

139140
--
140141

@@ -155,11 +156,11 @@ public constant kMCBrowserRequestStateMap is ["begin", "complete", "failed"]
155156

156157
-- constant kStringProps is ["url", "htmlText", "userAgent", "javaScriptHandlers"]
157158
-- TODO - replace literal values with constants when possible
158-
constant kStringProps is [3, 4, 5, 6]
159+
constant kStringProps is [4, 5, 6, 7]
159160

160-
-- constant kBoolProps is ["scrollbars", "allowNewWindows", "enableContextMenu"]
161+
-- constant kBoolProps is ["verticalScrollbarEnabled", "horizontalScrollbarEnabled", "allowNewWindows", "enableContextMenu"]
161162
-- TODO - replace literal values with constants when possible
162-
constant kBoolProps is [0, 1, 2]
163+
constant kBoolProps is [0, 1, 2, 3]
163164

164165
--------------------------------------------------------------------------------
165166

engine/src/java/com/runrev/android/libraries/LibBrowser.java

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ class LibBrowserWebView extends WebView
150150
{
151151
public static final String TAG = "revandroid.LibBrowserWebView";
152152

153-
private boolean m_scrolling_enabled;
154-
155153
private VideoView m_custom_video_view;
156154
private FrameLayout m_custom_view_container;
157155
private WebChromeClient.CustomViewCallback m_custom_view_callback;
@@ -164,8 +162,6 @@ public LibBrowserWebView(Context p_context)
164162
{
165163
super(p_context);
166164

167-
m_scrolling_enabled = true;
168-
169165
setWebViewClient(new WebViewClient() {
170166
public boolean shouldOverrideUrlLoading(WebView p_view, String p_url)
171167
{
@@ -427,30 +423,24 @@ public void setUrl(String p_url)
427423
// return toAPKPath(super.getUrl());
428424
//}
429425

430-
public boolean getScrollingEnabled()
426+
public boolean getVerticalScrollbarEnabled()
431427
{
432-
return m_scrolling_enabled;
428+
return isVerticalScrollBarEnabled();
433429
}
434430

435-
public void setScrollingEnabled(boolean p_enabled)
431+
public void setVerticalScrollbarEnabled(boolean p_enabled)
436432
{
437-
if (m_scrolling_enabled == p_enabled)
438-
return;
439-
m_scrolling_enabled = p_enabled;
440-
setHorizontalScrollBarEnabled(p_enabled);
441433
setVerticalScrollBarEnabled(p_enabled);
442-
getSettings().setBuiltInZoomControls(p_enabled);
443-
if (!m_scrolling_enabled)
444-
{
445-
setOnTouchListener(new View.OnTouchListener() {
446-
@Override
447-
public boolean onTouch(View v, MotionEvent event) {
448-
return (event.getAction() == MotionEvent.ACTION_MOVE);
449-
}
450-
});
451-
}
452-
else
453-
setOnTouchListener(null);
434+
}
435+
436+
public boolean getHorizontalScrollbarEnabled()
437+
{
438+
return isHorizontalScrollBarEnabled();
439+
}
440+
441+
public void setHorizontalScrollbarEnabled(boolean p_enabled)
442+
{
443+
setHorizontalScrollBarEnabled(p_enabled);
454444
}
455445

456446
public String getUserAgent()

engine/src/property.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,42 @@ static bool MCPropertyInfoTableLookup(Properties p_which, Boolean p_effective, c
418418

419419
////////////////////////////////////////////////////////////////////////////////
420420

421+
struct Property_Override
422+
{
423+
LT lt;
424+
Properties property;
425+
};
426+
427+
// List of syntax marks that should be interpreted as properties (if preceded by "the")
428+
Property_Override property_overrides[] =
429+
{
430+
{{"url", TT_CHUNK, CT_URL}, P_URL},
431+
};
432+
extern const uint32_t property_overrides_size = ELEMENTS(property_overrides);
433+
434+
bool lookup_property_override(const LT&p_lt, Properties &r_property)
435+
{
436+
for (uint32_t i = 0; i < property_overrides_size; i++)
437+
if (p_lt.type == property_overrides[i].lt.type && p_lt.which == property_overrides[i].lt.which)
438+
{
439+
r_property = property_overrides[i].property;
440+
return true;
441+
}
442+
443+
return false;
444+
}
445+
446+
bool lookup_property_override_name(uint16_t p_property, MCNameRef &r_name)
447+
{
448+
for (uint32_t i = 0; i < property_overrides_size; i++)
449+
if (property_overrides[i].property == p_property)
450+
return MCNameCreateWithCString(property_overrides[i].lt.token, r_name);
451+
452+
return false;
453+
}
454+
455+
////////////////////////////////////////////////////////////////////////////////
456+
421457
MCProperty::MCProperty()
422458
{
423459
tocount = CT_UNDEFINED;
@@ -519,13 +555,19 @@ Parse_stat MCProperty::parse(MCScriptPoint &sp, Boolean the)
519555
}
520556
else
521557
if (te->type != TT_PROPERTY)
558+
{
559+
Properties t_override;
560+
522561
if (te->type == TT_CLASS && te->which == CT_MARKED)
523562
which = P_MARKED;
563+
else if (the && lookup_property_override(*te, t_override))
564+
which = t_override;
524565
else
525566
{
526567
MCperror->add(PE_PROPERTY_NOTAPROP, sp);
527568
return PS_ERROR;
528569
}
570+
}
529571
else
530572
which = (Properties)te->which;
531573

engine/src/scriptpt.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,16 @@ Parse_stat MCScriptPoint::parseexp(Boolean single, Boolean items,
16161616
default:
16171617
if (lookup(SP_FACTOR, te) == PS_NORMAL)
16181618
{
1619-
switch (te->type)
1619+
extern bool lookup_property_override(const LT&p_lt, Properties &r_property);
1620+
Properties t_property;
1621+
1622+
Token_type t_type;
1623+
t_type = te->type;
1624+
if (doingthe && lookup_property_override(*te, t_property))
1625+
{
1626+
t_type = TT_PROPERTY;
1627+
}
1628+
switch (t_type)
16201629
{
16211630
case TT_THE:
16221631
doingthe = True;

engine/src/widget.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,11 @@ static void lookup_name_for_prop(Properties p_which, MCNameRef& r_name)
378378
/* UNCHECKED */ MCNameCreateWithCString(factor_table[i] . token, r_name);
379379
return;
380380
}
381-
381+
382+
extern bool lookup_property_override_name(uint16_t p_property, MCNameRef &r_name);
383+
if (lookup_property_override_name(p_which, r_name))
384+
return;
385+
382386
assert(false);
383387
}
384388

0 commit comments

Comments
 (0)