Skip to content

Commit 6af762b

Browse files
authored
Merge pull request pojala#5 from frankhale/master
Clean up JSBrowserWindowInstance constructor
2 parents eeba270 + 6115653 commit 6af762b

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

Electrino/win10/Electrino/JS/JSBrowserWindow.cs

+7-16
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,24 @@ protected override JavaScriptValue Main(JavaScriptValue callee, bool isConstruct
3838
class JSBrowserWindowInstance : AbstractJSModule
3939
{
4040
private JToken options;
41-
// I don't really like putting this here, I think we should probably have a class that contains all our constants
42-
private const int defaultWindowWidth = 800, defaultWindowHeight = 600;
4341
private Dictionary<string, List<Tuple<JavaScriptValue, JavaScriptValue>>> listeners = new Dictionary<string, List<Tuple<JavaScriptValue, JavaScriptValue>>>();
4442

4543
public JSBrowserWindowInstance(JToken options) : base("BrowserWindowInstance")
4644
{
45+
const int defaultWindowWidth = 800, defaultWindowHeight = 600;
46+
int width = 0, height = 0;
4747
this.options = options;
4848

4949
AttachMethod(LoadURL, "loadURL");
5050
AttachMethod(On, "on");
5151

52-
if (this.options != null)
53-
{
54-
int width = 0, height = 0;
55-
56-
Int32.TryParse(options["width"].ToString(), out width);
57-
Int32.TryParse(options["height"].ToString(), out height);
52+
Int32.TryParse(options["width"].ToString(), out width);
53+
Int32.TryParse(options["height"].ToString(), out height);
5854

59-
if (width <= 0) width = defaultWindowWidth;
60-
if (height <= 0) height = defaultWindowHeight;
55+
if (width <= 0) width = defaultWindowWidth;
56+
if (height <= 0) height = defaultWindowHeight;
6157

62-
App.NewWindow(width, height);
63-
}
64-
else
65-
{
66-
App.NewWindow(defaultWindowWidth, defaultWindowHeight);
67-
}
58+
App.NewWindow(width, height);
6859
}
6960
protected JavaScriptValue LoadURL(JavaScriptValue callee, bool isConstructCall, JavaScriptValue[] arguments, ushort argumentCount, IntPtr callbackData)
7061
{

0 commit comments

Comments
 (0)