Skip to content

Commit

Permalink
Use Edge/WebView2 as the default browser on Windows eclipse-platform#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
HeikoKlare committed Dec 6, 2024
1 parent 7300cb4 commit 565a217
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@
</message_arguments>
</filter>
</resource>
<resource path="Eclipse SWT/common/org/eclipse/swt/SWT.java" type="org.eclipse.swt.SWT">
<filter id="336658481">
<message_arguments>
<message_argument value="org.eclipse.swt.SWT"/>
<message_argument value="IE"/>
</message_arguments>
</filter>
</resource>
<resource path="Eclipse SWT/common/org/eclipse/swt/events/ArmListener.java" type="org.eclipse.swt.events.ArmListener">
<filter id="576720909">
<message_arguments>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ static int checkStyle(int style) {
if (current.equalsIgnoreCase ("webkit")) { //$NON-NLS-1$
DefaultType = SWT.WEBKIT;
break;
} else if (current.equalsIgnoreCase ("edge") && "win32".equals (platform)) { //$NON-NLS-1$ //$NON-NLS-2$
DefaultType = SWT.EDGE;
} else if (current.equalsIgnoreCase ("ie") && "win32".equals (platform)) { //$NON-NLS-1$ //$NON-NLS-2$
DefaultType = SWT.IE;
} else if (current.equalsIgnoreCase ("edge") && "win32".equals (platform)) { //$NON-NLS-1$ //$NON-NLS-2$
DefaultType = SWT.NONE;
break;
}
Expand All @@ -196,7 +196,7 @@ static int checkStyle(int style) {
}
}
/* If particular backend isn't specified, use the value from the system property. */
if ((style & (SWT.WEBKIT | SWT.EDGE)) == 0) {
if ((style & (SWT.WEBKIT | SWT.IE)) == 0) {
style |= DefaultType;
}
if ("win32".equals (platform) && (style & SWT.EDGE) != 0) { //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class BrowserFactory {

WebBrowser createWebBrowser (int style) {
// This function can't throw, otherwise the Browser will be left in inconsistent state.
if ((style & SWT.EDGE) != 0) {
if ((style & SWT.IE) != 0) {
try {
return new Edge();
return new IE();
} catch (SWTError e) {
System.err.println(e);
}
}
return new IE ();
return new Edge ();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2564,8 +2564,6 @@ public class SWT {
/**
* Style constant specifying that a Browser should use Edge (WebView2)
* for rendering its content (value is 1&lt;&lt;18).
* <p>NOTE: Edge integration is experimental, it isn't a drop-in replacement
* for Internet Explorer.</p>
* <p><b>Used By:</b></p>
* <ul>
* <li><code>Browser</code></li>
Expand All @@ -2575,6 +2573,18 @@ public class SWT {
*/
public static final int EDGE = 1 << 18;

/**
* Style constant specifying that a Browser should use Internet Explorer
* for rendering its content (value is 1&lt;&lt;19).
* <p><b>Used By:</b></p>
* <ul>
* <li><code>Browser</code></li>
* </ul>
*
* @since 3.129
*/
public static final int IE = 1 << 19;

/**
* Style constant for balloon behavior (value is 1&lt;&lt;12).
* <p><b>Used By:</b></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class BrowserTab extends Tab {
/* Style widgets added to the "Style" group */
Button webKitButton;
Button edgeButton;
Button ieButton;

String errorMessage, lastText, lastUrl;

Expand Down Expand Up @@ -94,6 +95,7 @@ void createExampleWidgets () {
if (borderButton.getSelection ()) style |= SWT.BORDER;
if (webKitButton.getSelection ()) style |= SWT.WEBKIT;
if (edgeButton.getSelection ()) style |= SWT.EDGE;
if (ieButton.getSelection ()) style |= SWT.IE;

/* Create the example widgets */
try {
Expand Down Expand Up @@ -168,6 +170,8 @@ void createStyleGroup () {
webKitButton.setText ("SWT.WEBKIT");
edgeButton = new Button (styleGroup, SWT.RADIO);
edgeButton.setText ("SWT.EDGE");
ieButton = new Button (styleGroup, SWT.RADIO);
ieButton.setText ("SWT.IE");
borderButton = new Button (styleGroup, SWT.CHECK);
borderButton.setText ("SWT.BORDER");
}
Expand Down Expand Up @@ -345,6 +349,7 @@ void setExampleWidgetState () {
super.setExampleWidgetState ();
webKitButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.WEBKIT) != 0);
edgeButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.EDGE) != 0);
ieButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.IE) != 0);
borderButton.setSelection (browser == null ? false : (browser.getStyle () & SWT.BORDER) != 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ public static Collection<Object[]> browserFlagsToTest() {
// NOTE: This is currently disabled due to test issues in the CI
// Execute Edge tests first, because IE starts some OS timer that conflicts with Edge event handling
// browserFlags.add(0, new Object[] {SWT.EDGE});
browserFlags.add(new Object[] {SWT.IE});
} else {
browserFlags.add(new Object[] {SWT.NONE});
}
browserFlags.add(new Object[] {SWT.NONE});
return browserFlags;
}

Expand Down

0 comments on commit 565a217

Please sign in to comment.