Skip to content

Conversation

@rubenporras
Copy link
Contributor

No description provided.

Import-Package: com.google.common.base,
com.google.gson;version="2.7.0"
com.google.gson;version="2.7.0",
org.apache.commons.lang;version="[2.6.0,3.0.0)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should rather be a require-plugin, and the plugin should be added to the target file by referencing Orbit.

setSize(hint.x, hint.y);

if (!"complete".equals(safeEvaluate(browser, "return document.readyState"))) { //$NON-NLS-1$ //$NON-NLS-2$
if (!"complete".equals(safeEvaluate(browser, "if (document.documentElement === null) {return 'no content';} return document.readyState;"))) { //$NON-NLS-1$ //$NON-NLS-2$
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This I think should not be needed with this approach.


public void setTextInBrowser(final Browser browser, final String text) {
String escapedHtmlBody = StringEscapeUtils.escapeJavaScript(text);
safeExecute(browser, "document.body.innerHTML = \"" + escapedHtmlBody + "\";"); //$NON-NLS-1$//$NON-NLS-2$
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should work but I was not able to see the updated content on the hover. I did not have time to check if the problem is that the javascript is not correct (I think it is because we have this very same code in production for months without issues), or if it is that I would need to also do something in the internals on the base class (for example override the fInput field as well), or that my Language Server was having problems (I found many of those in my LS, but I did not had time to go back and this PR to double check).

if (html != null && !html.isBlank()) {
super.setInput(styleHtml(html));
try {
Field f = BrowserInformationControl.class.getDeclaredField("fBrowser"); //$NON-NLS-1$
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like to do this, but the base class we are using is not good for customizability. Indeed the documentation clearly says it should not be subclassed, which we are ignoring.

I have another test where I do not use that class at all, but we would need to replicate some code which is a bit scary. I can submit that PR as well if you think it is useful.

Objects.requireNonNull(browser);
setTextInBrowser(browser, html);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
super.setInput(html);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should never happen, but it is just a safety net. We should add some logging in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant