Skip to content

Commit

Permalink
Cleaning browser closing
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed Jul 23, 2020
1 parent 6a7b563 commit b73a78a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,17 @@ private void setCurrentBrowser(Browser newCurrentBrowser, boolean visibility)
currentBrowser.setVisibility(visibility);
}

public boolean closeBrowser(Browser browser)
public void closeBrowser(Browser browser)
{
NullCheck.notNull(browser, "browser");
final int pos = browsers.indexOf(browser);
if (pos < 0)
return false;
browsers.remove(this);
//FIXME:choosing another current browser
return true;
Utils.runInFxThreadSync(()->{
final int pos = browsers.indexOf(browser);
if (pos < 0)
return;
browsers.remove(this);
app.remove(browser.webView);
//FIXME:choosing another current browser
});
}

void registerCanvas(ResizableCanvas canvas)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void runInjection()
}
}

protected void rescanDom()
protected void update()
{
InvalidThreadException.checkThread("BrowserBase.rescanDom()");
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ public Browser(JavaFxInteraction interaction, BrowserEvents events) throws IOExc
this.interaction = interaction;
}

@Override public void rescanDom()
@Override public void update()
{
Utils.runInFxThreadSync(()->super.rescanDom());
Utils.runInFxThreadSync(()->super.update());
}

@Override public void close()
{
Utils.runInFxThreadSync(()->interaction.closeBrowser(this));
interaction.closeBrowser(this);
}

@Override public void setVisibility(boolean enable)
@Override public void setVisibility(boolean visible)
{
if(enable)
if(visible)
{
interaction.enableGraphicalMode();
Utils.runInFxThreadSync(()->{
Expand Down Expand Up @@ -132,7 +132,7 @@ public Browser(JavaFxInteraction interaction, BrowserEvents events) throws IOExc
return new IteratorImpl(this);
}

@Override public int numElements()
@Override public int getElementCount()
{
if (domScanRes == null)
return 0;
Expand Down

0 comments on commit b73a78a

Please sign in to comment.