Skip to content

Commit b166956

Browse files
committed
Use Edge/WebView2 as the default browser on Windows eclipse-platform#1466
- Introduce SWT flag SWT.IE to be used for Browser to create an Internet Explorer instance - Adapt mapping of existing VM argument for default browser to map "ie" to new Internet Explorer flag and use Edge as default - Make SWT Browser instantiate Edge on Windows by default, i.e., unless the flag SWT.IE is specified - Adapt the SWT ControlExample to represent the SWT.IE flag and properly switch between Edge, Internet Explorer and default - Adapt Browser tests to consider to new default configuration Contributes to eclipse-platform#1466
1 parent 2ce8542 commit b166956

File tree

6 files changed

+34
-9
lines changed

6 files changed

+34
-9
lines changed

binaries/org.eclipse.swt.win32.win32.x86_64/.settings/.api_filters

+8
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,14 @@
375375
</message_arguments>
376376
</filter>
377377
</resource>
378+
<resource path="Eclipse SWT/common/org/eclipse/swt/SWT.java" type="org.eclipse.swt.SWT">
379+
<filter id="336658481">
380+
<message_arguments>
381+
<message_argument value="org.eclipse.swt.SWT"/>
382+
<message_argument value="IE"/>
383+
</message_arguments>
384+
</filter>
385+
</resource>
378386
<resource path="Eclipse SWT/common/org/eclipse/swt/events/ArmListener.java" type="org.eclipse.swt.events.ArmListener">
379387
<filter id="576720909">
380388
<message_arguments>

bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ static int checkStyle(int style) {
182182
if (current.equalsIgnoreCase ("webkit")) { //$NON-NLS-1$
183183
DefaultType = SWT.WEBKIT;
184184
break;
185-
} else if (current.equalsIgnoreCase ("edge") && "win32".equals (platform)) { //$NON-NLS-1$ //$NON-NLS-2$
186-
DefaultType = SWT.EDGE;
187185
} else if (current.equalsIgnoreCase ("ie") && "win32".equals (platform)) { //$NON-NLS-1$ //$NON-NLS-2$
186+
DefaultType = SWT.IE;
187+
} else if (current.equalsIgnoreCase ("edge") && "win32".equals (platform)) { //$NON-NLS-1$ //$NON-NLS-2$
188188
DefaultType = SWT.NONE;
189189
break;
190190
}
@@ -196,7 +196,7 @@ static int checkStyle(int style) {
196196
}
197197
}
198198
/* If particular backend isn't specified, use the value from the system property. */
199-
if ((style & (SWT.WEBKIT | SWT.EDGE)) == 0) {
199+
if ((style & (SWT.WEBKIT | SWT.IE)) == 0) {
200200
style |= DefaultType;
201201
}
202202
if ("win32".equals (platform) && (style & SWT.EDGE) != 0) { //$NON-NLS-1$

bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/BrowserFactory.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ class BrowserFactory {
1919

2020
WebBrowser createWebBrowser (int style) {
2121
// This function can't throw, otherwise the Browser will be left in inconsistent state.
22-
if ((style & SWT.EDGE) != 0) {
22+
if ((style & SWT.IE) != 0) {
2323
try {
24-
return new Edge();
24+
return new IE();
2525
} catch (SWTError e) {
2626
System.err.println(e);
2727
}
2828
}
29-
return new IE ();
29+
return new Edge ();
3030
}
3131
}

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -2564,8 +2564,6 @@ public class SWT {
25642564
/**
25652565
* Style constant specifying that a Browser should use Edge (WebView2)
25662566
* for rendering its content (value is 1&lt;&lt;18).
2567-
* <p>NOTE: Edge integration is experimental, it isn't a drop-in replacement
2568-
* for Internet Explorer.</p>
25692567
* <p><b>Used By:</b></p>
25702568
* <ul>
25712569
* <li><code>Browser</code></li>
@@ -2575,6 +2573,18 @@ public class SWT {
25752573
*/
25762574
public static final int EDGE = 1 << 18;
25772575

2576+
/**
2577+
* Style constant specifying that a Browser should use Internet Explorer
2578+
* for rendering its content (value is 1&lt;&lt;19).
2579+
* <p><b>Used By:</b></p>
2580+
* <ul>
2581+
* <li><code>Browser</code></li>
2582+
* </ul>
2583+
*
2584+
* @since 3.129
2585+
*/
2586+
public static final int IE = 1 << 19;
2587+
25782588
/**
25792589
* Style constant for balloon behavior (value is 1&lt;&lt;12).
25802590
* <p><b>Used By:</b></p>

examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class BrowserTab extends Tab {
4949
/* Style widgets added to the "Style" group */
5050
Button webKitButton;
5151
Button edgeButton;
52+
Button ieButton;
5253

5354
String errorMessage, lastText, lastUrl;
5455

@@ -94,6 +95,7 @@ void createExampleWidgets () {
9495
if (borderButton.getSelection ()) style |= SWT.BORDER;
9596
if (webKitButton.getSelection ()) style |= SWT.WEBKIT;
9697
if (edgeButton.getSelection ()) style |= SWT.EDGE;
98+
if (ieButton.getSelection ()) style |= SWT.IE;
9799

98100
/* Create the example widgets */
99101
try {
@@ -168,6 +170,8 @@ void createStyleGroup () {
168170
webKitButton.setText ("SWT.WEBKIT");
169171
edgeButton = new Button (styleGroup, SWT.RADIO);
170172
edgeButton.setText ("SWT.EDGE");
173+
ieButton = new Button (styleGroup, SWT.RADIO);
174+
ieButton.setText ("SWT.IE");
171175
borderButton = new Button (styleGroup, SWT.CHECK);
172176
borderButton.setText ("SWT.BORDER");
173177
}
@@ -345,6 +349,7 @@ void setExampleWidgetState () {
345349
super.setExampleWidgetState ();
346350
webKitButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.WEBKIT) != 0);
347351
edgeButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.EDGE) != 0);
352+
ieButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.IE) != 0);
348353
borderButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.BORDER) != 0);
349354
}
350355
}

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ public static Collection<Object[]> browserFlagsToTest() {
146146
// NOTE: This is currently disabled due to test issues in the CI
147147
// Execute Edge tests first, because IE starts some OS timer that conflicts with Edge event handling
148148
// browserFlags.add(0, new Object[] {SWT.EDGE});
149+
browserFlags.add(new Object[] {SWT.IE});
150+
} else {
151+
browserFlags.add(new Object[] {SWT.NONE});
149152
}
150-
browserFlags.add(new Object[] {SWT.NONE});
151153
return browserFlags;
152154
}
153155

0 commit comments

Comments
 (0)