A bit more RAII for DilloHtml...
This commit is contained in:
16
src/html.cc
16
src/html.cc
@ -475,8 +475,6 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
|
|||||||
|
|
||||||
styleEngine = std::make_unique< StyleEngine >(HT2LT (this), page_url, base_url, bw->zoom);
|
styleEngine = std::make_unique< StyleEngine >(HT2LT (this), page_url, base_url, bw->zoom);
|
||||||
|
|
||||||
cssUrls = new misc::SimpleVector <DilloUrl*> (1);
|
|
||||||
|
|
||||||
stack = new misc::SimpleVector <DilloHtmlState> (16);
|
stack = new misc::SimpleVector <DilloHtmlState> (16);
|
||||||
stack->increase();
|
stack->increase();
|
||||||
stack->getRef(0)->parse_mode = DILLO_HTML_PARSE_MODE_INIT;
|
stack->getRef(0)->parse_mode = DILLO_HTML_PARSE_MODE_INIT;
|
||||||
@ -554,10 +552,6 @@ DilloHtml::~DilloHtml()
|
|||||||
delete page_url;
|
delete page_url;
|
||||||
delete base_url;
|
delete base_url;
|
||||||
|
|
||||||
for (int i = 0; i < cssUrls->size(); i++)
|
|
||||||
delete cssUrls->get(i);
|
|
||||||
delete (cssUrls);
|
|
||||||
|
|
||||||
for (std::size_t i = 0; i < forms.size(); i++)
|
for (std::size_t i = 0; i < forms.size(); i++)
|
||||||
a_Html_form_delete (forms.at(i));
|
a_Html_form_delete (forms.at(i));
|
||||||
forms.clear();
|
forms.clear();
|
||||||
@ -729,9 +723,7 @@ void DilloHtml::loadImages (const DilloUrl *pattern)
|
|||||||
*/
|
*/
|
||||||
void DilloHtml::addCssUrl(const DilloUrl *url)
|
void DilloHtml::addCssUrl(const DilloUrl *url)
|
||||||
{
|
{
|
||||||
int nu = cssUrls->size();
|
cssUrls.push_back( a_Url_dup(url) );
|
||||||
cssUrls->increase();
|
|
||||||
cssUrls->set(nu, a_Url_dup(url).release());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DilloHtml::HtmlLinkReceiver::enter (Widget *widget, int link, int img,
|
bool DilloHtml::HtmlLinkReceiver::enter (Widget *widget, int link, int img,
|
||||||
@ -774,7 +766,7 @@ bool DilloHtml::HtmlLinkReceiver::press (Widget *widget, int link, int img,
|
|||||||
ret = true;
|
ret = true;
|
||||||
} else {
|
} else {
|
||||||
if (link == -1) {
|
if (link == -1) {
|
||||||
a_UIcmd_page_popup(bw, bw->num_page_bugs != 0, html->cssUrls);
|
a_UIcmd_page_popup(bw, bw->num_page_bugs != 0, &html->cssUrls);
|
||||||
ret = true;
|
ret = true;
|
||||||
} else {
|
} else {
|
||||||
a_UIcmd_link_popup(bw, html->links.at(link).get(), html->page_url);
|
a_UIcmd_link_popup(bw, html->links.at(link).get(), html->page_url);
|
||||||
@ -1666,8 +1658,8 @@ static void Html_tag_close_head(DilloHtml *html)
|
|||||||
html->InFlags &= ~IN_HEAD;
|
html->InFlags &= ~IN_HEAD;
|
||||||
|
|
||||||
/* charset is already set, load remote stylesheets now */
|
/* charset is already set, load remote stylesheets now */
|
||||||
for (int i = 0; i < html->cssUrls->size(); i++) {
|
for (int i = 0; i < html->cssUrls.size(); i++) {
|
||||||
a_Html_load_stylesheet(html, html->cssUrls->get(i));
|
a_Html_load_stylesheet(html, html->cssUrls.at(i).get());
|
||||||
}
|
}
|
||||||
} else if (html->Num_HEAD > 1) {
|
} else if (html->Num_HEAD > 1) {
|
||||||
--html->Num_HEAD;
|
--html->Num_HEAD;
|
||||||
|
|||||||
@ -185,7 +185,7 @@ public: //BUG: for now everything is public
|
|||||||
float DocTypeVersion; /* HTML or XHTML version number */
|
float DocTypeVersion; /* HTML or XHTML version number */
|
||||||
|
|
||||||
/* vector of remote CSS resources, as given by the LINK element */
|
/* vector of remote CSS resources, as given by the LINK element */
|
||||||
lout::misc::SimpleVector<DilloUrl*> *cssUrls;
|
std::vector< std::unique_ptr< DilloUrl > > cssUrls;
|
||||||
|
|
||||||
lout::misc::SimpleVector<DilloHtmlState> *stack;
|
lout::misc::SimpleVector<DilloHtmlState> *stack;
|
||||||
std::unique_ptr< StyleEngine > styleEngine;
|
std::unique_ptr< StyleEngine > styleEngine;
|
||||||
|
|||||||
@ -353,10 +353,8 @@ static void Menu_popup_cb(void *data)
|
|||||||
* Page popup menu (construction & popup)
|
* Page popup menu (construction & popup)
|
||||||
*/
|
*/
|
||||||
void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
|
void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
|
||||||
bool_t has_bugs, void *v_cssUrls)
|
bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls)
|
||||||
{
|
{
|
||||||
lout::misc::SimpleVector <DilloUrl*> *cssUrls =
|
|
||||||
(lout::misc::SimpleVector <DilloUrl*> *) v_cssUrls;
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
static Fl_Menu_Item *stylesheets = NULL;
|
static Fl_Menu_Item *stylesheets = NULL;
|
||||||
@ -402,7 +400,7 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
|
|||||||
memset(stylesheets, '\0', (cssUrls->size() + 1) * sizeof(Fl_Menu_Item));
|
memset(stylesheets, '\0', (cssUrls->size() + 1) * sizeof(Fl_Menu_Item));
|
||||||
|
|
||||||
for (j = 0; j < cssUrls->size(); j++) {
|
for (j = 0; j < cssUrls->size(); j++) {
|
||||||
DilloUrl *url = cssUrls->get(j);
|
DilloUrl *url = cssUrls->at(j).get();
|
||||||
const char *url_str = URL_STR(url);
|
const char *url_str = URL_STR(url);
|
||||||
const uint_t head_length = 30, tail_length = 40,
|
const uint_t head_length = 30, tail_length = 40,
|
||||||
url_len = strlen(url_str);
|
url_len = strlen(url_str);
|
||||||
|
|||||||
@ -8,7 +8,7 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
|
void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
|
||||||
bool_t has_bugs, void *v_cssUrls);
|
bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls);
|
||||||
void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url,
|
void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url,
|
||||||
const DilloUrl *page_url);
|
const DilloUrl *page_url);
|
||||||
void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
|
void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
|
||||||
|
|||||||
@ -1253,11 +1253,11 @@ void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url)
|
|||||||
/*
|
/*
|
||||||
* Popup the page menu
|
* Popup the page menu
|
||||||
*/
|
*/
|
||||||
void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, void *v_cssUrls)
|
void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls)
|
||||||
{
|
{
|
||||||
BrowserWindow *bw = (BrowserWindow*)vbw;
|
BrowserWindow *bw = (BrowserWindow*)vbw;
|
||||||
const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
|
const DilloUrl *url = a_History_get_url(NAV_TOP_UIDX(bw));
|
||||||
a_Menu_page_popup(bw, url, has_bugs, v_cssUrls);
|
a_Menu_page_popup(bw, url, has_bugs, cssUrls);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -58,7 +58,7 @@ void a_UIcmd_findtext_reset(BrowserWindow *bw);
|
|||||||
void a_UIcmd_findbar_toggle(BrowserWindow *bw, int on);
|
void a_UIcmd_findbar_toggle(BrowserWindow *bw, int on);
|
||||||
void a_UIcmd_focus_main_area(BrowserWindow *bw);
|
void a_UIcmd_focus_main_area(BrowserWindow *bw);
|
||||||
void a_UIcmd_focus_location(void *vbw);
|
void a_UIcmd_focus_location(void *vbw);
|
||||||
void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, void *v_cssUrls);
|
void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, std::vector< std::unique_ptr< DilloUrl > > *cssUrls);
|
||||||
void a_UIcmd_link_popup(void *vbw, const DilloUrl *url, const DilloUrl *page_url);
|
void a_UIcmd_link_popup(void *vbw, const DilloUrl *url, const DilloUrl *page_url);
|
||||||
void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img,
|
void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img,
|
||||||
DilloUrl *page_url, DilloUrl *link_url);
|
DilloUrl *page_url, DilloUrl *link_url);
|
||||||
|
|||||||
Reference in New Issue
Block a user