aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-12-08 16:32:27 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-12-08 16:32:27 +0100
commitc8b549abe1c85700c91e805e51b677a49ed5fd1d (patch)
treecd7c4053123335b3af203b6aaf6cdd99da5fa222 /src
parent9e9dd0866570bcded7a26f0cbf1c0134c35e81d6 (diff)
parent4e93afcf54baaa4d2b689357ec47fd3ec585e44f (diff)
merge
Diffstat (limited to 'src')
-rw-r--r--src/form.cc114
-rw-r--r--src/html.cc17
-rw-r--r--src/jpeg.c8
3 files changed, 71 insertions, 68 deletions
diff --git a/src/form.cc b/src/form.cc
index a61e4c73..d822f9e4 100644
--- a/src/form.cc
+++ b/src/form.cc
@@ -75,8 +75,8 @@ class DilloHtmlForm {
friend class DilloHtmlInput;
DilloHtml *html;
- void eventHandler(Resource *resource);
- void submit(DilloHtmlInput *active_input);
+ void eventHandler(Resource *resource, EventButton *event);
+ void submit(DilloHtmlInput *active_input, EventButton *event);
DilloUrl *buildQueryUrl(DilloHtmlInput *active_input);
Dstr *buildQueryData(DilloHtmlInput *active_submit);
char *makeMultipartBoundary(iconv_t char_encoder,
@@ -128,7 +128,7 @@ class DilloHtmlReceiver:
void activate (Resource *resource);
void enter (Resource *resource);
void leave (Resource *resource);
- void clicked (ButtonResource *resource, int buttonNo, int x, int y);
+ void clicked (ButtonResource *resource, EventButton *event);
};
class DilloHtmlInput {
@@ -150,7 +150,7 @@ public: //BUG: for now everything is public
private:
void connectTo(DilloHtmlReceiver *form_receiver);
- void activate(DilloHtmlForm *form, bool entry_input_submits);
+ void activate(DilloHtmlForm *form, int num_entry_fields,EventButton *event);
void readFile(BrowserWindow *bw);
public:
@@ -947,14 +947,12 @@ DilloHtmlForm::~DilloHtmlForm ()
delete(form_receiver);
}
-void DilloHtmlForm::eventHandler(Resource *resource)
+void DilloHtmlForm::eventHandler(Resource *resource, EventButton *event)
{
MSG("DilloHtmlForm::eventHandler\n");
DilloHtmlInput *input = getInput(resource);
if (input) {
- bool entry_input_submits = prefs.enterpress_forces_submit ||
- num_entry_fields == 1;
- input->activate (this, entry_input_submits);
+ input->activate (this, num_entry_fields, event);
} else {
MSG("DilloHtmlForm::eventHandler: ERROR, input not found!\n");
}
@@ -964,11 +962,21 @@ void DilloHtmlForm::eventHandler(Resource *resource)
* Submit.
* (Called by eventHandler())
*/
-void DilloHtmlForm::submit(DilloHtmlInput *active_input)
+void DilloHtmlForm::submit(DilloHtmlInput *active_input, EventButton *event)
{
DilloUrl *url = buildQueryUrl(active_input);
if (url) {
- a_Nav_push(html->bw, url);
+ if (event && event->button == 2) {
+ if (prefs.middle_click_opens_new_tab) {
+ int focus = prefs.focus_new_tab ? 1 : 0;
+ if (event->state == SHIFT_MASK) focus = !focus;
+ a_UIcmd_open_url_nt(html->bw, url, focus);
+ } else {
+ a_Nav_push_nw(html->bw, url);
+ }
+ } else {
+ a_Nav_push(html->bw, url);
+ }
a_Url_free(url);
}
// /* now, make the rendered area have its focus back */
@@ -1479,7 +1487,7 @@ DilloHtmlInput *DilloHtmlForm::getRadioInput (const char *name)
void DilloHtmlReceiver::activate (Resource *resource)
{
- form->eventHandler(resource);
+ form->eventHandler(resource, NULL);
}
/*
@@ -1515,9 +1523,9 @@ void DilloHtmlReceiver::leave (Resource *resource)
}
void DilloHtmlReceiver::clicked (ButtonResource *resource,
- int buttonNo, int x, int y)
+ EventButton *event)
{
-// form->eventHandler(resource, x, y);
+ form->eventHandler(resource, event);
}
/*
@@ -1566,56 +1574,52 @@ DilloHtmlInput::~DilloHtmlInput ()
*/
void DilloHtmlInput::connectTo(DilloHtmlReceiver *form_receiver)
{
- Resource *resource = NULL;
- if (embed)
- resource = embed->getResource ();
- switch (type) {
- case DILLO_HTML_INPUT_UNKNOWN:
- case DILLO_HTML_INPUT_HIDDEN:
- case DILLO_HTML_INPUT_CHECKBOX:
- case DILLO_HTML_INPUT_RADIO:
- case DILLO_HTML_INPUT_BUTTON:
- case DILLO_HTML_INPUT_TEXTAREA:
- case DILLO_HTML_INPUT_SELECT:
- case DILLO_HTML_INPUT_SEL_LIST:
- // do nothing
- break;
- case DILLO_HTML_INPUT_TEXT:
- case DILLO_HTML_INPUT_PASSWORD:
- case DILLO_HTML_INPUT_INDEX:
- case DILLO_HTML_INPUT_SUBMIT:
- case DILLO_HTML_INPUT_RESET:
- case DILLO_HTML_INPUT_BUTTON_SUBMIT:
- case DILLO_HTML_INPUT_BUTTON_RESET:
- case DILLO_HTML_INPUT_IMAGE:
- case DILLO_HTML_INPUT_FILE:
- if (resource)
- resource->connectActivate (form_receiver);
- break;
+ Resource *resource;
+ if (embed && (resource = embed->getResource())) {
+ switch (type) {
+ case DILLO_HTML_INPUT_UNKNOWN:
+ case DILLO_HTML_INPUT_HIDDEN:
+ case DILLO_HTML_INPUT_CHECKBOX:
+ case DILLO_HTML_INPUT_RADIO:
+ case DILLO_HTML_INPUT_BUTTON:
+ case DILLO_HTML_INPUT_TEXTAREA:
+ case DILLO_HTML_INPUT_SELECT:
+ case DILLO_HTML_INPUT_SEL_LIST:
+ // do nothing
+ break;
+ case DILLO_HTML_INPUT_SUBMIT:
+ case DILLO_HTML_INPUT_RESET:
+ case DILLO_HTML_INPUT_BUTTON_SUBMIT:
+ case DILLO_HTML_INPUT_BUTTON_RESET:
+ case DILLO_HTML_INPUT_IMAGE:
+ case DILLO_HTML_INPUT_FILE:
+ ((ButtonResource *)resource)->connectClicked (form_receiver);
+ case DILLO_HTML_INPUT_TEXT:
+ case DILLO_HTML_INPUT_PASSWORD:
+ case DILLO_HTML_INPUT_INDEX:
+ resource->connectActivate (form_receiver);
+ break;
+ break;
+ }
}
}
/*
* Activate a form
*/
-void DilloHtmlInput::activate(DilloHtmlForm *form, bool entry_input_submits)
+void DilloHtmlInput::activate(DilloHtmlForm *form, int num_entry_fields,
+ EventButton *event)
{
- switch (type) {
- case DILLO_HTML_INPUT_TEXT:
- case DILLO_HTML_INPUT_PASSWORD:
- if (entry_input_submits)
- form->submit (this);
- break;
- case DILLO_HTML_INPUT_FILE:
+ if (type == DILLO_HTML_INPUT_FILE) {
readFile (form->html->bw);
- break;
- case DILLO_HTML_INPUT_RESET:
- case DILLO_HTML_INPUT_BUTTON_RESET:
- form->reset ();
- break;
- default:
- form->submit (this);
- break;
+ } else if (type == DILLO_HTML_INPUT_RESET ||
+ type == DILLO_HTML_INPUT_BUTTON_RESET) {
+ form->reset();
+ } else if ((type != DILLO_HTML_INPUT_TEXT &&
+ type != DILLO_HTML_INPUT_PASSWORD) ||
+ prefs.enterpress_forces_submit ||
+ num_entry_fields == 1) {
+ form->submit(this, event);
}
}
diff --git a/src/html.cc b/src/html.cc
index 74039314..a59339cd 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -464,7 +464,6 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
pre_column = 0;
PreFirstChar = false;
PrevWasCR = false;
- PrevWasOpenTag = false;
PrevWasSPC = false;
InVisitedLink = false;
ReqTagClose = false;
@@ -1176,7 +1175,6 @@ static void Html_process_word(DilloHtml *html, const char *word, int size)
}
}
- html->PrevWasOpenTag = false;
html->PrevWasSPC = false;
if (html->InFlags & IN_LI)
html->WordAfterLI = true;
@@ -1310,6 +1308,7 @@ static void Html_tag_cleanup_at_close(DilloHtml *html, int TagIdx)
/* Close this and only this tag */
html->CloseOneTag = true;
+ MSG("Close: %*s%s\n", html->stack->size()," ",Tags[toptag_idx].name);
Tags[toptag_idx].close (html, toptag_idx);
}
@@ -3305,6 +3304,7 @@ static void Html_test_section(DilloHtml *html, int new_idx, int IsCloseTag)
if (tag_idx != new_idx || IsCloseTag) {
/* implicit open */
Html_force_push_tag(html, tag_idx);
+ MSG("Open : %*s%s\n", html->stack->size()," ",Tags[tag_idx].name);
Tags[tag_idx].open (html, tag, strlen(tag));
}
}
@@ -3317,6 +3317,7 @@ static void Html_test_section(DilloHtml *html, int new_idx, int IsCloseTag)
if (tag_idx != new_idx || IsCloseTag) {
/* implicit open of the head element */
Html_force_push_tag(html, tag_idx);
+ MSG("Open : %*s%s\n", html->stack->size()," ",Tags[tag_idx].name);
Tags[tag_idx].open (html, tag, strlen(tag));
}
}
@@ -3326,13 +3327,14 @@ static void Html_test_section(DilloHtml *html, int new_idx, int IsCloseTag)
if (html->InFlags & IN_HEAD) {
tag = "</head>";
tag_idx = a_Html_tag_index(tag + 2);
- Tags[tag_idx].close (html, tag_idx);
+ Html_tag_cleanup_at_close(html, tag_idx);
}
tag = "<body>";
tag_idx = a_Html_tag_index(tag + 1);
if (tag_idx != new_idx || IsCloseTag) {
/* implicit open */
Html_force_push_tag(html, tag_idx);
+ MSG("Open : %*s%s\n", html->stack->size()," ",Tags[tag_idx].name);
Tags[tag_idx].open (html, tag, strlen(tag));
}
}
@@ -3385,6 +3387,7 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
Html_push_tag(html, ni);
html->styleEngine->startElement (ni);
+ MSG("Open : %*s%s\n", html->stack->size(), " ", Tags[ni].name);
/* Now parse attributes that can appear on any tag */
if (tagsize >= 8 && /* length of "<t id=i>" */
@@ -3433,9 +3436,6 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
if (html->stop_parser)
break;
- /* let the parser know this was an open tag */
- html->PrevWasOpenTag = true;
-
/* Request inmediate close for elements with forbidden close tag. */
/* TODO: XHTML always requires close tags. A simple implementation
* of the commented clause below will make it work. */
@@ -3450,12 +3450,11 @@ static void Html_process_tag(DilloHtml *html, char *tag, int tagsize)
/* Test for </x>, ReqTagClose, <x /> and <x/> */
if (*start == '/' || /* </x> */
html->ReqTagClose || /* request */
- (tag[tagsize - 2] == '/')) { /* XML: */
+ tag[tagsize - 2] == '/') { /* XML */
- Tags[ni].close (html, ni);
+ Html_tag_cleanup_at_close(html, ni);
// html->styleEngine->endElement (ni);
/* This was a close tag */
- html->PrevWasOpenTag = false;
html->ReqTagClose = false;
}
}
diff --git a/src/jpeg.c b/src/jpeg.c
index 05e4f2d4..9e548a7c 100644
--- a/src/jpeg.c
+++ b/src/jpeg.c
@@ -278,14 +278,14 @@ static void Jpeg_write(DilloJpeg *jpeg, void *Buf, uint_t BufSize)
/* decompression step 3 (see libjpeg.doc) */
if (jpeg_read_header(&(jpeg->cinfo), TRUE) != JPEG_SUSPENDED) {
type = DILLO_IMG_TYPE_GRAY;
- if (jpeg->cinfo.num_components == 1)
+ if (jpeg->cinfo.num_components == 1) {
type = DILLO_IMG_TYPE_GRAY;
- else if (jpeg->cinfo.num_components == 3)
+ } else if (jpeg->cinfo.num_components == 3) {
type = DILLO_IMG_TYPE_RGB;
- else
+ } else {
_MSG("jpeg: can't handle %d component images\n",
jpeg->cinfo.num_components);
-
+ }
/*
* If a multiple-scan image is not completely in cache,
* use progressive display, updating as it arrives.