Images list in DilloHtml is now a vector.
Next to put in unique_ptrs.
This commit is contained in:
32
src/html.cc
32
src/html.cc
@ -516,7 +516,6 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
|
|||||||
/* Init page-handling variables */
|
/* Init page-handling variables */
|
||||||
forms.reserve(1);
|
forms.reserve(1);
|
||||||
links.reserve(64);
|
links.reserve(64);
|
||||||
images = new misc::SimpleVector <DilloHtmlImage*> (16);
|
|
||||||
|
|
||||||
/* Initialize the main widget */
|
/* Initialize the main widget */
|
||||||
initDw();
|
initDw();
|
||||||
@ -552,13 +551,13 @@ DilloHtml::~DilloHtml()
|
|||||||
delete page_url;
|
delete page_url;
|
||||||
delete base_url;
|
delete base_url;
|
||||||
|
|
||||||
for (int i = 0; i < images->size(); i++) {
|
for (int i = 0; i < images.size(); i++) {
|
||||||
DilloHtmlImage *img = images->get(i);
|
DilloHtmlImage *img = images.at(i);
|
||||||
img->url.reset(); // Was: delete img->url;
|
img->url.reset(); // Was: delete img->url;
|
||||||
img->image.reset(); // Was: a_Image_unref(img->image);
|
img->image.reset(); // Was: a_Image_unref(img->image);
|
||||||
dFree(img);
|
dFree(img);
|
||||||
}
|
}
|
||||||
delete (images);
|
images.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -676,8 +675,8 @@ DilloHtmlForm *DilloHtml::getCurrentForm ()
|
|||||||
|
|
||||||
bool_t DilloHtml::unloadedImages()
|
bool_t DilloHtml::unloadedImages()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < images->size(); i++) {
|
for (int i = 0; i < images.size(); i++) {
|
||||||
if (images->get(i)->image != NULL) {
|
if (images.at(i)->image != NULL) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -700,8 +699,8 @@ void DilloHtml::loadImages (const DilloUrl *pattern)
|
|||||||
*/
|
*/
|
||||||
const DilloUrl *requester = pattern ? NULL : this->page_url;
|
const DilloUrl *requester = pattern ? NULL : this->page_url;
|
||||||
|
|
||||||
for (int i = 0; i < images->size(); i++) {
|
for (int i = 0; i < images.size(); i++) {
|
||||||
DilloHtmlImage *hi = images->get(i);
|
DilloHtmlImage *hi = images.at(i);
|
||||||
|
|
||||||
if (hi->image) {
|
if (hi->image) {
|
||||||
assert(hi->url);
|
assert(hi->url);
|
||||||
@ -756,8 +755,8 @@ bool DilloHtml::HtmlLinkReceiver::press (Widget *widget, int link, int img,
|
|||||||
// image menu
|
// image menu
|
||||||
if (link != -1)
|
if (link != -1)
|
||||||
linkurl = html->links.at(link).get();
|
linkurl = html->links.at(link).get();
|
||||||
const bool_t loaded_img = (html->images->get(img)->image == NULL);
|
const bool_t loaded_img = (html->images.at(img)->image == NULL);
|
||||||
a_UIcmd_image_popup(bw, html->images->get(img)->url.get(), loaded_img,
|
a_UIcmd_image_popup(bw, html->images.at(img)->url.get(), loaded_img,
|
||||||
html->page_url, linkurl);
|
html->page_url, linkurl);
|
||||||
ret = true;
|
ret = true;
|
||||||
} else {
|
} else {
|
||||||
@ -781,11 +780,11 @@ bool DilloHtml::HtmlLinkReceiver::click (Widget *widget, int link, int img,
|
|||||||
{
|
{
|
||||||
BrowserWindow *bw = html->bw;
|
BrowserWindow *bw = html->bw;
|
||||||
|
|
||||||
if ((img != -1) && (html->images->get(img)->image)) {
|
if ((img != -1) && (html->images.at(img)->image)) {
|
||||||
// clicked an image that has not already been loaded
|
// clicked an image that has not already been loaded
|
||||||
if (event->button == 1){
|
if (event->button == 1){
|
||||||
// load all instances of this image
|
// load all instances of this image
|
||||||
DilloUrl *pattern = html->images->get(img)->url.get();
|
DilloUrl *pattern = html->images.at(img)->url.get();
|
||||||
html->loadImages(pattern);
|
html->loadImages(pattern);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2101,7 +2100,7 @@ void a_Html_common_image_attrs(DilloHtml *html, const char *tag, int tagsize)
|
|||||||
/* x_img is an index to a list of {url,image} pairs.
|
/* x_img is an index to a list of {url,image} pairs.
|
||||||
* We know a_Html_image_new() will use size() as its next index */
|
* We know a_Html_image_new() will use size() as its next index */
|
||||||
html->styleEngine->setNonCssHint (PROPERTY_X_IMG, CSS_TYPE_INTEGER,
|
html->styleEngine->setNonCssHint (PROPERTY_X_IMG, CSS_TYPE_INTEGER,
|
||||||
html->images->size());
|
html->images.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr< DilloImage > a_Html_image_new(DilloHtml *html, const char *tag, int tagsize)
|
std::shared_ptr< DilloImage > a_Html_image_new(DilloHtml *html, const char *tag, int tagsize)
|
||||||
@ -2133,8 +2132,7 @@ std::shared_ptr< DilloImage > a_Html_image_new(DilloHtml *html, const char *tag,
|
|||||||
|
|
||||||
DilloHtmlImage *hi = new DilloHtmlImage{};
|
DilloHtmlImage *hi = new DilloHtmlImage{};
|
||||||
hi->url = std::move( url );
|
hi->url = std::move( url );
|
||||||
html->images->increase();
|
html->images.push_back(hi);
|
||||||
html->images->set(html->images->size() - 1, hi);
|
|
||||||
|
|
||||||
load_now = prefs.load_images ||
|
load_now = prefs.load_images ||
|
||||||
!dStrAsciiCasecmp(URL_SCHEME(hi->url.get()), "data") ||
|
!dStrAsciiCasecmp(URL_SCHEME(hi->url.get()), "data") ||
|
||||||
@ -2308,8 +2306,8 @@ static void Html_tag_close_map(DilloHtml *html)
|
|||||||
* an image that has not been loaded (img != NULL), tell the image to
|
* an image that has not been loaded (img != NULL), tell the image to
|
||||||
* redraw. (It will only do so if it uses a map.)
|
* redraw. (It will only do so if it uses a map.)
|
||||||
*/
|
*/
|
||||||
for (int i = 0; i < html->images->size(); i++) {
|
for (int i = 0; i < html->images.size(); i++) {
|
||||||
std::shared_ptr< DilloImage > img = html->images->get(i)->image;
|
std::shared_ptr< DilloImage > img = html->images.at(i)->image;
|
||||||
|
|
||||||
if (img) {
|
if (img) {
|
||||||
// At this point, we know that img->ir represents an image
|
// At this point, we know that img->ir represents an image
|
||||||
|
|||||||
@ -222,7 +222,7 @@ public: //BUG: for now everything is public
|
|||||||
std::vector< std::unique_ptr< DilloHtmlForm > > forms;
|
std::vector< std::unique_ptr< DilloHtmlForm > > forms;
|
||||||
std::vector< std::shared_ptr< DilloHtmlInput > > inputs_outside_form;
|
std::vector< std::shared_ptr< DilloHtmlInput > > inputs_outside_form;
|
||||||
std::vector< std::unique_ptr< DilloUrl > > links;
|
std::vector< std::unique_ptr< DilloUrl > > links;
|
||||||
lout::misc::SimpleVector<DilloHtmlImage*> *images;
|
std::vector< DilloHtmlImage * > images;
|
||||||
dw::ImageMapsList maps;
|
dw::ImageMapsList maps;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user