More ownership work.
This commit is contained in:
2
rebuild
2
rebuild
@ -3,5 +3,5 @@ make distclean
|
|||||||
pushd ..
|
pushd ..
|
||||||
./autogen.sh
|
./autogen.sh
|
||||||
popd
|
popd
|
||||||
../configure --prefix=/opt/local --enable-ipv6
|
../configure --prefix=/opt/local --enable-ipv6 CXXFLAGS="-O0 -g"
|
||||||
make -kj11
|
make -kj11
|
||||||
|
|||||||
37
src/bw.cc
37
src/bw.cc
@ -21,6 +21,8 @@
|
|||||||
#include "capi.hh"
|
#include "capi.hh"
|
||||||
#include "uicmd.hh"
|
#include "uicmd.hh"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Local Data
|
* Local Data
|
||||||
*/
|
*/
|
||||||
@ -67,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->PageUrls = dList_new(8);
|
|
||||||
bw->Docs = dList_new(8);
|
bw->Docs = dList_new(8);
|
||||||
|
|
||||||
bw->num_page_bugs = 0;
|
bw->num_page_bugs = 0;
|
||||||
@ -96,9 +97,9 @@ BrowserWindow::~BrowserWindow()
|
|||||||
dList_free(this->Docs);
|
dList_free(this->Docs);
|
||||||
|
|
||||||
delete this->nav_expect_url;
|
delete this->nav_expect_url;
|
||||||
for (j = 0; j < dList_length(this->PageUrls); ++j)
|
//for (j = 0; j < dList_length(this->PageUrls); ++j)
|
||||||
delete reinterpret_cast< DilloUrl * >( dList_nth_data(this->PageUrls, j) );
|
//delete reinterpret_cast< DilloUrl * >( dList_nth_data(this->PageUrls, j) );
|
||||||
dList_free(this->PageUrls);
|
//dList_free(this->PageUrls);
|
||||||
|
|
||||||
for (j = 0; j < dList_length(this->nav_stack); ++j)
|
for (j = 0; j < dList_length(this->nav_stack); ++j)
|
||||||
dFree(dList_nth_data(this->nav_stack, j));
|
dFree(dList_nth_data(this->nav_stack, j));
|
||||||
@ -201,13 +202,16 @@ void a_Bw_stop_clients(BrowserWindow *bw, int flags)
|
|||||||
* This helps us keep track of page-requested URLs so that it's
|
* This helps us keep track of page-requested URLs so that it's
|
||||||
* possible to stop, abort and reload them.
|
* possible to stop, abort and reload them.
|
||||||
*/
|
*/
|
||||||
void a_Bw_add_url(BrowserWindow *bw, const DilloUrl *Url)
|
void a_Bw_add_url(BrowserWindow *bw, std::unique_ptr< DilloUrl > Url)
|
||||||
{
|
{
|
||||||
dReturn_if_fail ( bw != NULL && Url != NULL );
|
dReturn_if_fail ( bw != NULL && Url != NULL );
|
||||||
|
|
||||||
if (!dList_find_custom(bw->PageUrls, Url, (dCompareFunc)a_Url_cmp)) {
|
auto found= std::find_if( begin( bw->PageUrls ), end( bw->PageUrls ),
|
||||||
dList_append(bw->PageUrls, a_Url_dup(Url).release());
|
[&Url]( const auto &url ) { return *url == *Url; } );
|
||||||
}
|
|
||||||
|
if( end( bw->PageUrls ) != found ) return;
|
||||||
|
|
||||||
|
bw->PageUrls.push_back( std::move( Url ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -242,14 +246,14 @@ void *a_Bw_get_current_doc(BrowserWindow *bw)
|
|||||||
* This is currently used by popup menus that need to ensure that the
|
* This is currently used by popup menus that need to ensure that the
|
||||||
* page has not changed while the menu was popped up.
|
* page has not changed while the menu was popped up.
|
||||||
*/
|
*/
|
||||||
void *a_Bw_get_url_doc(BrowserWindow *bw, const DilloUrl *url)
|
void *a_Bw_get_url_doc(BrowserWindow *bw, const DilloUrl *Url)
|
||||||
{
|
{
|
||||||
void *doc = NULL;
|
if( not Url ) return nullptr;
|
||||||
|
auto found= std::find_if( begin( bw->PageUrls ), end( bw->PageUrls ),
|
||||||
|
[&Url]( const auto &url ) { return *url == *Url; } );
|
||||||
|
|
||||||
if (url && dList_find_custom(bw->PageUrls, url, (dCompareFunc)a_Url_cmp)) {
|
if( end( bw->PageUrls ) != found ) return a_Bw_get_current_doc( bw );
|
||||||
doc = a_Bw_get_current_doc(bw);
|
return nullptr;
|
||||||
}
|
|
||||||
return doc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -282,10 +286,7 @@ void a_Bw_cleanup(BrowserWindow *bw)
|
|||||||
dList_remove_fast(bw->ImageClients, data);
|
dList_remove_fast(bw->ImageClients, data);
|
||||||
}
|
}
|
||||||
/* Remove PageUrls */
|
/* Remove PageUrls */
|
||||||
while ((data = dList_nth_data(bw->PageUrls, 0))) {
|
bw->PageUrls.clear();
|
||||||
delete reinterpret_cast< DilloUrl * >( data );
|
|
||||||
dList_remove_fast(bw->PageUrls, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Zero image-progress data */
|
/* Zero image-progress data */
|
||||||
bw->NumImages = 0;
|
bw->NumImages = 0;
|
||||||
|
|||||||
10
src/bw.hh
10
src/bw.hh
@ -15,6 +15,12 @@
|
|||||||
|
|
||||||
#include "url.hh" /* for DilloUrl */
|
#include "url.hh" /* for DilloUrl */
|
||||||
|
|
||||||
|
extern "C++"
|
||||||
|
{
|
||||||
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Flag Defines for a_Bw_stop_clients()
|
* Flag Defines for a_Bw_stop_clients()
|
||||||
*/
|
*/
|
||||||
@ -47,7 +53,7 @@ struct BrowserWindow {
|
|||||||
/** Number of not yet arrived style sheets */
|
/** Number of not yet arrived style sheets */
|
||||||
int NumPendingStyleSheets;
|
int NumPendingStyleSheets;
|
||||||
/** List of all Urls requested by this page (and its types) */
|
/** List of all Urls requested by this page (and its types) */
|
||||||
Dlist *PageUrls;
|
std::vector< std::unique_ptr< DilloUrl > > PageUrls;
|
||||||
|
|
||||||
/** The navigation stack (holds indexes to history list) */
|
/** The navigation stack (holds indexes to history list) */
|
||||||
Dlist *nav_stack;
|
Dlist *nav_stack;
|
||||||
@ -98,7 +104,7 @@ void a_Bw_add_doc(BrowserWindow *bw, void *vdoc);
|
|||||||
void *a_Bw_get_current_doc(BrowserWindow *bw);
|
void *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, void *vdoc);
|
||||||
void a_Bw_add_url(BrowserWindow *bw, const 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 */
|
||||||
void a_Bw_expect(BrowserWindow *bw, const DilloUrl *Url);
|
void a_Bw_expect(BrowserWindow *bw, const DilloUrl *Url);
|
||||||
|
|||||||
@ -2204,7 +2204,7 @@ static bool Html_load_image(BrowserWindow *bw, DilloUrl *url,
|
|||||||
/* Request image data from the cache */
|
/* Request image data from the cache */
|
||||||
if ((ClientKey = a_Capi_open_url(Web, NULL, NULL)) != 0) {
|
if ((ClientKey = a_Capi_open_url(Web, NULL, NULL)) != 0) {
|
||||||
a_Bw_add_client(bw, ClientKey, 0);
|
a_Bw_add_client(bw, ClientKey, 0);
|
||||||
a_Bw_add_url(bw, url);
|
a_Bw_add_url(bw, a_Url_dup( url ));
|
||||||
}
|
}
|
||||||
return ClientKey != 0;
|
return ClientKey != 0;
|
||||||
}
|
}
|
||||||
@ -3281,7 +3281,7 @@ void a_Html_load_stylesheet(DilloHtml *html, DilloUrl *url)
|
|||||||
if ((ClientKey = a_Capi_open_url(Web, Html_css_load_callback, NULL))) {
|
if ((ClientKey = a_Capi_open_url(Web, Html_css_load_callback, NULL))) {
|
||||||
++html->bw->NumPendingStyleSheets;
|
++html->bw->NumPendingStyleSheets;
|
||||||
a_Bw_add_client(html->bw, ClientKey, 0);
|
a_Bw_add_client(html->bw, ClientKey, 0);
|
||||||
a_Bw_add_url(html->bw, url);
|
a_Bw_add_url(html->bw, a_Url_dup( url ));
|
||||||
MSG("NumPendingStyleSheets=%d\n", html->bw->NumPendingStyleSheets);
|
MSG("NumPendingStyleSheets=%d\n", html->bw->NumPendingStyleSheets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -235,7 +235,7 @@ static void Nav_open_url(BrowserWindow *bw, const DilloUrl *url,
|
|||||||
Web->flags |= WEB_RootUrl;
|
Web->flags |= WEB_RootUrl;
|
||||||
if ((ClientKey = a_Capi_open_url(Web, NULL, NULL)) != 0) {
|
if ((ClientKey = a_Capi_open_url(Web, NULL, NULL)) != 0) {
|
||||||
a_Bw_add_client(bw, ClientKey, 1);
|
a_Bw_add_client(bw, ClientKey, 1);
|
||||||
a_Bw_add_url(bw, url);
|
a_Bw_add_url(bw, a_Url_dup( url ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -364,7 +364,7 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props,
|
|||||||
Font *parentFont = stack.at (i - 1).style->font;
|
Font *parentFont = stack.at (i - 1).style->font;
|
||||||
char *c, *fontName;
|
char *c, *fontName;
|
||||||
int lineHeight;
|
int lineHeight;
|
||||||
DilloUrl *imgUrl = NULL;
|
std::unique_ptr< DilloUrl > imgUrl;
|
||||||
|
|
||||||
/* Determine font first so it can be used to resolve relative lengths. */
|
/* Determine font first so it can be used to resolve relative lengths. */
|
||||||
for (int j = 0; j < props->size (); j++) {
|
for (int j = 0; j < props->size (); j++) {
|
||||||
@ -531,7 +531,7 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props,
|
|||||||
break;
|
break;
|
||||||
case CSS_PROPERTY_BACKGROUND_IMAGE:
|
case CSS_PROPERTY_BACKGROUND_IMAGE:
|
||||||
// p->value.strVal should be absolute, so baseUrl is not needed
|
// p->value.strVal should be absolute, so baseUrl is not needed
|
||||||
imgUrl = a_Url_new (p->value.strVal, NULL).release();
|
imgUrl = a_Url_new (p->value.strVal, NULL);
|
||||||
break;
|
break;
|
||||||
case CSS_PROPERTY_BACKGROUND_POSITION:
|
case CSS_PROPERTY_BACKGROUND_POSITION:
|
||||||
computeLength (&attrs->backgroundPositionX, p->value.posVal->posX,
|
computeLength (&attrs->backgroundPositionX, p->value.posVal->posX,
|
||||||
@ -766,7 +766,7 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props,
|
|||||||
|
|
||||||
// we use the pageUrl as requester to prevent cross
|
// we use the pageUrl as requester to prevent cross
|
||||||
// domain requests as specified in domainrc
|
// domain requests as specified in domainrc
|
||||||
DilloWeb *web = a_Web_new(bw, imgUrl, pageUrl);
|
DilloWeb *web = a_Web_new(bw, imgUrl.get(), pageUrl);
|
||||||
web->Image = image;
|
web->Image = image;
|
||||||
a_Image_ref(image);
|
a_Image_ref(image);
|
||||||
web->flags |= WEB_Image;
|
web->flags |= WEB_Image;
|
||||||
@ -774,12 +774,11 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props,
|
|||||||
int clientKey;
|
int clientKey;
|
||||||
if ((clientKey = a_Capi_open_url(web, NULL, NULL)) != 0) {
|
if ((clientKey = a_Capi_open_url(web, NULL, NULL)) != 0) {
|
||||||
a_Bw_add_client(bw, clientKey, 0);
|
a_Bw_add_client(bw, clientKey, 0);
|
||||||
a_Bw_add_url(bw, imgUrl);
|
a_Bw_add_url(bw, std::move( imgUrl ));
|
||||||
attrs->backgroundImage->connectDeletion
|
attrs->backgroundImage->connectDeletion
|
||||||
(new StyleImageDeletionReceiver (clientKey));
|
(new StyleImageDeletionReceiver (clientKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete imgUrl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -112,6 +112,8 @@ struct DilloUrl {
|
|||||||
int illegal_chars_spc; /**< number of illegal space chars */
|
int illegal_chars_spc; /**< number of illegal space chars */
|
||||||
|
|
||||||
~DilloUrl();
|
~DilloUrl();
|
||||||
|
|
||||||
|
friend bool operator == ( const DilloUrl &lhs, const DilloUrl &rhs );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -121,6 +123,12 @@ char *a_Url_str(const DilloUrl *url);
|
|||||||
const char *a_Url_hostname(const DilloUrl *u);
|
const char *a_Url_hostname(const DilloUrl *u);
|
||||||
std::unique_ptr< DilloUrl > a_Url_dup(const DilloUrl *u);
|
std::unique_ptr< DilloUrl > a_Url_dup(const DilloUrl *u);
|
||||||
int a_Url_cmp(const DilloUrl *A, const DilloUrl *B);
|
int a_Url_cmp(const DilloUrl *A, const DilloUrl *B);
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator == ( const DilloUrl &lhs, const DilloUrl &rhs )
|
||||||
|
{
|
||||||
|
return a_Url_cmp( &lhs, &rhs ) == 0;
|
||||||
|
}
|
||||||
void a_Url_set_flags(DilloUrl *u, int flags);
|
void a_Url_set_flags(DilloUrl *u, int flags);
|
||||||
void a_Url_set_data(DilloUrl *u, std::string_view data);
|
void a_Url_set_data(DilloUrl *u, std::string_view data);
|
||||||
void a_Url_set_ismap_coords(DilloUrl *u, char *coord_str);
|
void a_Url_set_ismap_coords(DilloUrl *u, char *coord_str);
|
||||||
|
|||||||
Reference in New Issue
Block a user