Make BrowserWindow own more of its resources.
This commit is contained in:
24
src/bw.cc
24
src/bw.cc
@ -69,7 +69,6 @@ BrowserWindow *a_Bw_new(void)
|
|||||||
bw->NumImages = 0;
|
bw->NumImages = 0;
|
||||||
bw->NumImagesGot = 0;
|
bw->NumImagesGot = 0;
|
||||||
bw->NumPendingStyleSheets = 0;
|
bw->NumPendingStyleSheets = 0;
|
||||||
bw->Docs = dList_new(8);
|
|
||||||
|
|
||||||
bw->num_page_bugs = 0;
|
bw->num_page_bugs = 0;
|
||||||
|
|
||||||
@ -86,7 +85,7 @@ BrowserWindow *a_Bw_new(void)
|
|||||||
*/
|
*/
|
||||||
BrowserWindow::~BrowserWindow()
|
BrowserWindow::~BrowserWindow()
|
||||||
{
|
{
|
||||||
int i, j;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < num_bws; i++) {
|
for (i = 0; i < num_bws; i++) {
|
||||||
if (bws[i] == this) {
|
if (bws[i] == this) {
|
||||||
@ -94,7 +93,6 @@ BrowserWindow::~BrowserWindow()
|
|||||||
|
|
||||||
dList_free(this->RootClients);
|
dList_free(this->RootClients);
|
||||||
dList_free(this->ImageClients);
|
dList_free(this->ImageClients);
|
||||||
dList_free(this->Docs);
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -207,23 +205,23 @@ void a_Bw_add_url(BrowserWindow *bw, std::unique_ptr< DilloUrl > Url)
|
|||||||
/**
|
/**
|
||||||
* Add a document to the browser window's list.
|
* Add a document to the browser window's list.
|
||||||
*/
|
*/
|
||||||
void a_Bw_add_doc(BrowserWindow *bw, void *vdoc)
|
void a_Bw_add_doc(BrowserWindow *bw, DilloHtml *vdoc)
|
||||||
{
|
{
|
||||||
dReturn_if_fail ( bw != NULL && vdoc != NULL);
|
dReturn_if_fail ( bw != NULL && vdoc != NULL);
|
||||||
|
|
||||||
dList_append(bw->Docs, vdoc);
|
bw->Docs.push_back( vdoc );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current document.
|
* Get current document.
|
||||||
*/
|
*/
|
||||||
void *a_Bw_get_current_doc(BrowserWindow *bw)
|
DilloHtml *a_Bw_get_current_doc(BrowserWindow *bw)
|
||||||
{
|
{
|
||||||
void *doc = NULL;
|
DilloHtml *doc = NULL;
|
||||||
int len = dList_length(bw->Docs);
|
int len = bw->Docs.size();
|
||||||
|
|
||||||
if (len == 1)
|
if (len == 1)
|
||||||
doc = dList_nth_data(bw->Docs, 0);
|
doc = bw->Docs.at(0);
|
||||||
else if (len > 1)
|
else if (len > 1)
|
||||||
MSG("a_Bw_get_current_doc() multiple docs not implemented\n");
|
MSG("a_Bw_get_current_doc() multiple docs not implemented\n");
|
||||||
|
|
||||||
@ -249,12 +247,12 @@ void *a_Bw_get_url_doc(BrowserWindow *bw, const DilloUrl *Url)
|
|||||||
/**
|
/**
|
||||||
* Remove a document from the bw's list
|
* Remove a document from the bw's list
|
||||||
*/
|
*/
|
||||||
void a_Bw_remove_doc(BrowserWindow *bw, void *vdoc)
|
void a_Bw_remove_doc(BrowserWindow *bw, DilloHtml *vdoc)
|
||||||
{
|
{
|
||||||
void *data;
|
auto where= std::find( begin( bw->Docs ), end( bw->Docs ), vdoc );
|
||||||
|
|
||||||
if ((data = dList_find(bw->Docs, vdoc))) {
|
if (end( bw->Docs ) != where) {
|
||||||
dList_remove_fast(bw->Docs, data);
|
bw->Docs.erase( where );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
src/bw.hh
10
src/bw.hh
@ -21,6 +21,8 @@ extern "C++"
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct DilloHtml;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flag Defines for a_Bw_stop_clients()
|
* Flag Defines for a_Bw_stop_clients()
|
||||||
*/
|
*/
|
||||||
@ -50,7 +52,7 @@ struct BrowserWindow {
|
|||||||
void *render_layout;
|
void *render_layout;
|
||||||
|
|
||||||
/** Root document(s). Currently only used by DilloHtml */
|
/** Root document(s). Currently only used by DilloHtml */
|
||||||
Dlist *Docs;
|
std::vector< DilloHtml * > Docs;
|
||||||
|
|
||||||
/** A list of active cache clients in the window (The primary Key) */
|
/** A list of active cache clients in the window (The primary Key) */
|
||||||
Dlist *RootClients;
|
Dlist *RootClients;
|
||||||
@ -110,10 +112,10 @@ void a_Bw_add_client(BrowserWindow *bw, int Key, int Root);
|
|||||||
int a_Bw_remove_client(BrowserWindow *bw, int ClientKey);
|
int a_Bw_remove_client(BrowserWindow *bw, int ClientKey);
|
||||||
void a_Bw_close_client(BrowserWindow *bw, int ClientKey);
|
void a_Bw_close_client(BrowserWindow *bw, int ClientKey);
|
||||||
void a_Bw_stop_clients(BrowserWindow *bw, int flags);
|
void a_Bw_stop_clients(BrowserWindow *bw, int flags);
|
||||||
void a_Bw_add_doc(BrowserWindow *bw, void *vdoc);
|
void a_Bw_add_doc(BrowserWindow *bw, DilloHtml *vdoc);
|
||||||
void *a_Bw_get_current_doc(BrowserWindow *bw);
|
DilloHtml *a_Bw_get_current_doc(BrowserWindow *bw);
|
||||||
void *a_Bw_get_url_doc(BrowserWindow *bw, const DilloUrl *Url);
|
void *a_Bw_get_url_doc(BrowserWindow *bw, const DilloUrl *Url);
|
||||||
void a_Bw_remove_doc(BrowserWindow *bw, void *vdoc);
|
void a_Bw_remove_doc(BrowserWindow *bw, DilloHtml *vdoc);
|
||||||
void a_Bw_add_url(BrowserWindow *bw, std::unique_ptr< DilloUrl > Url);
|
void a_Bw_add_url(BrowserWindow *bw, std::unique_ptr< DilloUrl > Url);
|
||||||
void a_Bw_cleanup(BrowserWindow *bw);
|
void a_Bw_cleanup(BrowserWindow *bw);
|
||||||
/* expect API */
|
/* expect API */
|
||||||
|
|||||||
Reference in New Issue
Block a user