r13131 tlsa - /trunk/libcss/src/select/select.c
by netsurf@semichrome.net
Author: tlsa
Date: Sun Nov 6 12:02:23 2011
New Revision: 13131
URL: http://source.netsurf-browser.org?rev=13131&view=rev
Log:
Avoid trying to add already-cached selectors to reject cache. Remove pre-insertion search.
Modified:
trunk/libcss/src/select/select.c
Modified: trunk/libcss/src/select/select.c
URL: http://source.netsurf-browser.org/trunk/libcss/src/select/select.c?rev=13...
==============================================================================
--- trunk/libcss/src/select/select.c (original)
+++ trunk/libcss/src/select/select.c Sun Nov 6 12:02:23 2011
@@ -95,7 +95,7 @@
static css_error match_universal_combinator(css_select_ctx *ctx,
css_combinator type, const css_selector *selector,
css_select_state *state, void *node, bool may_optimise,
- void **next_node);
+ bool *rejected_by_cache, void **next_node);
static css_error match_details(css_select_ctx *ctx, void *node,
const css_selector_detail *detail, css_select_state *state,
bool *match, css_pseudo_element *pseudo_element);
@@ -1135,8 +1135,6 @@
{
const css_selector_detail *detail = &s->data;
const css_selector_detail *next_detail = NULL;
- reject_item *reject = state->reject_cache;
- bool match = false;
if (detail->next)
next_detail = detail + 1;
@@ -1150,24 +1148,10 @@
next_detail->type != CSS_SELECTOR_ID))
return;
- /* Search cache for matching entry */
- while (reject != state->next_reject) {
- if (reject->type == next_detail->type &&
- lwc_string_isequal(reject->value,
- next_detail->qname.name,
- &match) == lwc_error_ok &&
- match)
- break;
-
- reject++;
- }
-
- /* None found: insert */
- if (reject == state->next_reject) {
- state->next_reject->type = next_detail->type;
- state->next_reject->value = next_detail->qname.name;
- state->next_reject++;
- }
+ /* Insert */
+ state->next_reject->type = next_detail->type;
+ state->next_reject->value = next_detail->qname.name;
+ state->next_reject++;
}
css_error match_selector_chain(css_select_ctx *ctx,
@@ -1177,6 +1161,7 @@
void *node = state->node;
const css_selector_detail *detail = &s->data;
bool match = false, may_optimise = true;
+ bool rejected_by_cache;
css_pseudo_element pseudo;
css_error error;
@@ -1230,13 +1215,15 @@
error = match_universal_combinator(ctx, s->data.comb,
s->combinator, state, node,
- may_optimise, &next_node);
+ may_optimise, &rejected_by_cache,
+ &next_node);
if (error != CSS_OK)
return error;
/* No match for combinator, so reject selector chain */
if (next_node == NULL) {
- if (may_optimise && s == selector) {
+ if (may_optimise && s == selector &&
+ !rejected_by_cache) {
update_reject_cache(state, s->data.comb,
s->combinator);
}
@@ -1340,7 +1327,8 @@
css_error match_universal_combinator(css_select_ctx *ctx, css_combinator type,
const css_selector *selector, css_select_state *state,
- void *node, bool may_optimise, void **next_node)
+ void *node, bool may_optimise, bool *rejected_by_cache,
+ void **next_node)
{
const css_selector_detail *detail = &selector->data;
const css_selector_detail *next_detail = NULL;
@@ -1349,6 +1337,8 @@
if (detail->next)
next_detail = detail + 1;
+
+ *rejected_by_cache = false;
/* Consult reject cache first */
if (may_optimise && (type == CSS_COMBINATOR_ANCESTOR ||
@@ -1368,6 +1358,7 @@
match) {
/* Found it: can't match */
*next_node = NULL;
+ *rejected_by_cache = true;
return CSS_OK;
}
11 years, 6 months
r13130 jmb - /trunk/netsurf/render/layout.c
by netsurf@semichrome.net
Author: jmb
Date: Sun Nov 6 05:26:52 2011
New Revision: 13130
URL: http://source.netsurf-browser.org?rev=13130&view=rev
Log:
Fix bug #3433954: make containing_block available to layout_table so it can resolve percentage height specified on an absolutely-positioned table.
Modified:
trunk/netsurf/render/layout.c
Modified: trunk/netsurf/render/layout.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/layout.c?rev=13130...
==============================================================================
--- trunk/netsurf/render/layout.c (original)
+++ trunk/netsurf/render/layout.c Sun Nov 6 05:26:52 2011
@@ -4677,9 +4677,13 @@
if (!layout_block_context(box, -1, content))
return false;
} else if (box->type == BOX_TABLE) {
+ /* layout_table also expects the containing block to be
+ * stored in the float_container field */
+ box->float_container = containing_block;
/* \todo layout_table considers margins etc. again */
if (!layout_table(box, width, content))
return false;
+ box->float_container = NULL;
layout_solve_width(box, box->parent->width, box->width, 0, 0,
-1, -1);
}
11 years, 6 months
r13129 jmb - /trunk/netsurf/content/fetchers/curl.c
by netsurf@semichrome.net
Author: jmb
Date: Sat Nov 5 17:10:46 2011
New Revision: 13129
URL: http://source.netsurf-browser.org?rev=13129&view=rev
Log:
Hack around curl complaining about junk gzip streams
Modified:
trunk/netsurf/content/fetchers/curl.c
Modified: trunk/netsurf/content/fetchers/curl.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/curl.c?r...
==============================================================================
--- trunk/netsurf/content/fetchers/curl.c (original)
+++ trunk/netsurf/content/fetchers/curl.c Sat Nov 5 17:10:46 2011
@@ -806,8 +806,16 @@
abort_fetch = f->abort;
LOG(("done %s", nsurl_access(f->url)));
- if (abort_fetch == false && result == CURLE_OK) {
- /* fetch completed normally */
+ if (abort_fetch == false && (result == CURLE_OK ||
+ (result == CURLE_WRITE_ERROR && f->stopped == false))) {
+ /* fetch completed normally or the server fed us a junk gzip
+ * stream (usually in the form of garbage at the end of the
+ * stream). Curl will have fed us all but the last chunk of
+ * decoded data, which is sad as, if we'd received the last
+ * chunk, too, we'd be able to render the whole object.
+ * As is, we'll just have to accept that the end of the
+ * object will be truncated in this case and leave it to
+ * the content handlers to cope. */
if (f->stopped ||
(!f->had_headers &&
fetch_curl_process_headers(f)))
11 years, 6 months
r13128 jmb - /trunk/netsurf/render/layout.c
by netsurf@semichrome.net
Author: jmb
Date: Sat Nov 5 16:03:52 2011
New Revision: 13128
URL: http://source.netsurf-browser.org?rev=13128&view=rev
Log:
Fix bug #3433840: <img style="display: table" src="..."> will crash if the image fetch completes before initial layout.
A number of things wrong here:
1) The BOX_TABLE generated for the img shouldn't ever have been associated with the object (it should have been associated with the implied BOX_TABLE_CELL)
2) The layout engine's decision to treat BOX_TABLE/BOX_INLINE_CONTAINER with associated objects differently from non-replaced TABLE/INLINE_CONTAINERs seems wrong (looking though SVN history, it appears that this was introduced as part of the very first frames implementation, since replaced (twice!))
3) Now we fetch objects in parallel with building the box tree, we're open to this kind of race condition.
Modified:
trunk/netsurf/render/layout.c
Modified: trunk/netsurf/render/layout.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/layout.c?rev=13128...
==============================================================================
--- trunk/netsurf/render/layout.c (original)
+++ trunk/netsurf/render/layout.c Sat Nov 5 16:03:52 2011
@@ -320,8 +320,7 @@
* left and right margins to avoid any floats. */
lm = rm = 0;
- if (box->type == BOX_BLOCK || box->object ||
- box->flags & IFRAME) {
+ if (box->type == BOX_BLOCK || box->flags & IFRAME) {
if (!box->object && !(box->flags & IFRAME) &&
!(box->flags & REPLACE_DIM) &&
box->style &&
11 years, 6 months
r13127 jmb - /trunk/netsurf/render/html.c
by netsurf@semichrome.net
Author: jmb
Date: Sat Nov 5 13:36:21 2011
New Revision: 13127
URL: http://source.netsurf-browser.org?rev=13127&view=rev
Log:
Fix bug #3433787: ignore empty meta refresh content attribute.
Squash memory leaks in error cases.
Modified:
trunk/netsurf/render/html.c
Modified: trunk/netsurf/render/html.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html.c?rev=13127&r...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Sat Nov 5 13:36:21 2011
@@ -933,13 +933,13 @@
nsurl *nsurl;
nserror error;
- for (n = head == 0 ? 0 : head->children; n; n = n->next) {
+ for (n = head == NULL ? NULL : head->children; n; n = n->next) {
if (n->type != XML_ELEMENT_NODE)
continue;
/* Recurse into noscript elements */
if (strcmp((const char *) n->name, "noscript") == 0) {
- if (!html_meta_refresh(c, n)) {
+ if (html_meta_refresh(c, n) == false) {
/* Some error occurred */
return false;
} else if (c->base.refresh) {
@@ -948,15 +948,15 @@
}
}
- if (strcmp((const char *) n->name, "meta")) {
+ if (strcmp((const char *) n->name, "meta") != 0) {
continue;
}
equiv = xmlGetProp(n, (const xmlChar *) "http-equiv");
- if (!equiv)
+ if (equiv == NULL)
continue;
- if (strcasecmp((const char *) equiv, "refresh")) {
+ if (strcasecmp((const char *) equiv, "refresh") != 0) {
xmlFree(equiv);
continue;
}
@@ -964,7 +964,7 @@
xmlFree(equiv);
content = xmlGetProp(n, (const xmlChar *) "content");
- if (!content)
+ if (content == NULL)
continue;
end = (char *) content + strlen((const char *) content);
@@ -980,8 +980,21 @@
* nonascii := [#x80-#xD7FF#xE000-#xFFFD#x10000-#x10FFFF]
*/
- /* *LWS intpart */
- msg_data.delay = (int)strtol((char *) content, &url, 10);
+ url = (char *) content;
+
+ /* *LWS */
+ while (url < end && isspace(*url)) {
+ url++;
+ }
+
+ /* intpart */
+ if (url == end || (*url < '0' || '9' < *url)) {
+ /* Empty content, or invalid timeval */
+ xmlFree(content);
+ continue;
+ }
+
+ msg_data.delay = (int) strtol(url, &url, 10);
/* a very small delay and self-referencing URL can cause a loop
* that grinds machines to a halt. To prevent this we set a
* minimum refresh delay of 1s. */
@@ -1026,10 +1039,12 @@
url += 3;
} else {
/* Unexpected input, ignore this header */
+ xmlFree(content);
continue;
}
} else {
/* Insufficient input, ignore this header */
+ xmlFree(content);
continue;
}
@@ -1044,10 +1059,12 @@
url++;
} else {
/* Unexpected input, ignore this header */
+ xmlFree(content);
continue;
}
} else {
/* Insufficient input, ignore this header */
+ xmlFree(content);
continue;
}
@@ -1081,9 +1098,12 @@
error = nsurl_join(c->base_url, refresh, &nsurl);
if (error != NSERROR_OK) {
+ xmlFree(content);
+
msg_data.error = messages_get("NoMemory");
content_broadcast(&c->base, CONTENT_MSG_ERROR,
msg_data);
+
return false;
}
11 years, 6 months
r13126 jmb - /trunk/libcss/src/select/select.c
by netsurf@semichrome.net
Author: jmb
Date: Sat Nov 5 10:24:50 2011
New Revision: 13126
URL: http://source.netsurf-browser.org?rev=13126&view=rev
Log:
Fix regression introduced by reject cache: do not cache failure to match multi-detailed selectors
Modified:
trunk/libcss/src/select/select.c
Modified: trunk/libcss/src/select/select.c
URL: http://source.netsurf-browser.org/trunk/libcss/src/select/select.c?rev=13...
==============================================================================
--- trunk/libcss/src/select/select.c (original)
+++ trunk/libcss/src/select/select.c Sat Nov 5 10:24:50 2011
@@ -1145,6 +1145,7 @@
N_ELEMENTS(state->reject_cache) ||
comb != CSS_COMBINATOR_ANCESTOR ||
next_detail == NULL ||
+ next_detail->next != 0 ||
(next_detail->type != CSS_SELECTOR_CLASS &&
next_detail->type != CSS_SELECTOR_ID))
return;
11 years, 6 months
r13125 mono - in /trunk/netsurf/atari: browser.c browser.h browser_win.c browser_win.h gui.c
by netsurf@semichrome.net
Author: mono
Date: Sat Nov 5 10:18:19 2011
New Revision: 13125
URL: http://source.netsurf-browser.org?rev=13125&view=rev
Log:
-Remove a bunch of code which was intended to handle framed-pages. It's better handled by the OS, because frames won't be handled within the frontend anymore.
- Clear window when no content is available
Modified:
trunk/netsurf/atari/browser.c
trunk/netsurf/atari/browser.h
trunk/netsurf/atari/browser_win.c
trunk/netsurf/atari/browser_win.h
trunk/netsurf/atari/gui.c
Modified: trunk/netsurf/atari/browser.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/browser.c?rev=13125...
==============================================================================
--- trunk/netsurf/atari/browser.c (original)
+++ trunk/netsurf/atari/browser.c Sat Nov 5 10:18:19 2011
@@ -78,7 +78,7 @@
/*
- Create an browser component window (undcomented WinDom structure).
+ Create an browser component.
Currently, this area is the area which is used to display HTML content.
However, it could also contains other areas, these need to be handled within
"browser_get_rect" function.
@@ -109,43 +109,33 @@
bw->scale = clone->scale;
else
bw->scale = 1;
- bnew->redraw.areas_used = 0;
- bnew->compwin = mt_WindCreate( &app, VSLIDE|HSLIDE, 1, 1, app.w, app.h);
- bnew->compwin->w_u = 1;
- bnew->compwin->h_u = 1;
- /* needs to be adjusted when content width is known: */
- bnew->compwin->ypos_max = w;
- bnew->compwin->xpos_max = w;
- mt_WindSlider( &app, bnew->compwin, HSLIDER|VSLIDER);
- bnew->comp = (COMPONENT*)comp_widget_create( (void*)&app, (WINDOW*)bnew->compwin, 1, 1 );
+ bnew->redraw.areas_used = 0;
+ bnew->comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL, 100, 1);
if( bnew->comp == NULL ) {
free(bnew);
return(NULL);
}
/* Attach events to the component: */
- mt_EvntDataAdd( &app, bnew->compwin, WM_XBUTTON,
- browser_evnt_mbutton, (void*)gw, EV_BOT );
+ mt_CompEvntDataAdd( &app, bnew->comp, WM_XBUTTON,
+ browser_evnt_mbutton, (void*)gw, EV_BOT
+ );
mt_CompEvntDataAttach( &app, bnew->comp, WM_REDRAW,
- browser_evnt_redraw, (void*)gw );
- mt_EvntDataAttach( &app, bnew->compwin , WM_REDRAW, browser_evnt_redraw_x, NULL );
- mt_EvntDataAttach( &app, bnew->compwin, WM_SLIDEXY,
- browser_evnt_slider, gw );
- mt_EvntDataAttach( &app, bnew->compwin, WM_ARROWED,
- browser_evnt_arrowed, gw );
+ browser_evnt_redraw, (void*)gw
+ );
mt_CompEvntDataAttach( &app, bnew->comp, WM_DESTROY,
- browser_evnt_destroy, (void*)bnew );
- /* just stub, as an reminder: */
- mt_EvntDataAttach( &app, bnew->compwin, WM_DESTROY,
- browser_evnt_wdestroy, (void*)bnew );
+ browser_evnt_destroy, (void*)bnew
+ );
/* Set the gui_window owner. */
/* it is an link to the netsurf window system */
mt_CompDataAttach( &app, bnew->comp, CDT_OWNER, gw );
+
bnew->scroll.requested.y = 0;
bnew->scroll.requested.x = 0;
bnew->scroll.current.x = 0;
- bnew->scroll.current.y = 0;
+ bnew->scroll.current.y = 0;
+
}
return( bnew );
}
@@ -153,20 +143,14 @@
bool browser_destroy( struct s_browser * b )
{
- LOG(("%s\n", b->bw->name ));
+ LOG(("%s\n", b->bw->name ));
+
assert( b != NULL );
assert( b->comp != NULL );
assert( b->bw != NULL );
-
- if( b->compwin != NULL ) {
- /* TODO: Only do this when it's the last browser viewport within the root win: */
- COMPONENT * old = b->comp;
- WINDOW * oldwin = b->compwin;
- b->comp = NULL;
- b->compwin = NULL;
- /* I'm not sure about the correct order of these 2 calls: */
- WindDelete( oldwin );
- mt_CompDelete(&app, old );
+
+ if( b->comp != NULL ){
+ mt_CompDelete(&app, b->comp );
}
return( true );
}
@@ -175,46 +159,22 @@
Query the browser component for widget rectangles.
*/
void browser_get_rect( struct gui_window * gw, enum browser_rect type, LGRECT * out)
-{
- GRECT work;
- assert( out != NULL);
- int slider_v_w = 20;
- int slider_v_h = 22;
- int slider_h_w = 20;
- int slider_h_h = 22;
+{
+ LGRECT cur;
/* Query component for it's current size: */
- WindGetGrect( gw->browser->compwin, WF_WORKXYWH, &work);
-
+
+ mt_CompGetLGrect(&app, gw->browser->comp, WF_WORKXYWH, &cur);
/* And extract the different widget dimensions: */
/* Redraw area of html content: */
if( type == BR_CONTENT ){
- out->g_w = work.g_w;
- out->g_h = work.g_h;
- out->g_x = work.g_x;
- out->g_y = work.g_y;
+ out->g_w = cur.g_w;
+ out->g_h = cur.g_h;
+ out->g_x = cur.g_x;
+ out->g_y = cur.g_y;
return;
}
-
- /* Horizontal scroller: */
- LGRECT cur;
- mt_CompGetLGrect(&app, gw->browser->comp, WF_WORKXYWH, &cur);
- if( type == BR_HSLIDER ){
- out->g_x = cur.g_x;
- out->g_y = cur.g_y + work.g_h;
- out->g_h = cur.g_h - work.g_h;
- out->g_w = cur.g_w;
- }
-
- /* Vertical scroller: */
- if( type == BR_VSLIDER ){
- out->g_x = cur.g_x + work.g_w;
- out->g_y = cur.g_y;
- out->g_w = cur.g_w - work.g_w;
- out->g_h = work.g_h;
- }
-
}
/* Report an resize to the COMPONENT interface */
@@ -233,9 +193,11 @@
{
CMP_BROWSER b = gw->browser;
LGRECT work;
- browser_get_rect( gw, BR_CONTENT, &work );
- b->compwin->ypos_max = h;
- b->compwin->xpos_max = w;
+ browser_get_rect( gw, BR_CONTENT, &work );
+
+ gw->root->handle->xpos_max = w;
+ gw->root->handle->ypos_max = h;
+
if( w < work.g_w + b->scroll.current.x || w < work.g_h + b->scroll.current.y ) {
/* let the scroll routine detect invalid scroll values... */
browser_scroll(gw, WA_LFLINE, b->scroll.current.x, true );
@@ -245,12 +207,6 @@
}
}
-static void __CDECL browser_evnt_wdestroy( WINDOW * c, short buff[8], void * data)
-{
- struct s_browser * b = (struct s_browser*)data;
- LOG((""));
-}
-
static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * data)
{
struct s_browser * b = (struct s_browser*)data;
@@ -259,75 +215,16 @@
assert( b != NULL );
assert( gw != NULL );
-
- assert( b->comp == NULL );
-
free( b );
gw->browser = NULL;
LOG(("evnt_destroy done!"));
}
-
-
-static void __CDECL browser_evnt_arrowed( WINDOW *win, short buff[8], void * data)
-{
- bool abs = false;
- int value = BROWSER_SCROLL_SVAL;
- struct gui_window * gw = data;
- LGRECT cwork;
-
- if( input_window == NULL || input_window != gw ) {
- return;
- }
- browser_get_rect( gw, BR_CONTENT, &cwork );
-
- switch( buff[4] ) {
- case WA_UPPAGE:
- case WA_DNPAGE:
- value = cwork.g_h;
- break;
-
- case WA_LFPAGE:
- case WA_RTPAGE:
- value = cwork.g_w;
- break;
-
- default:
- break;
- }
- browser_scroll( gw, buff[4], value, abs );
-}
-
-void __CDECL browser_evnt_slider( WINDOW *win, short buff[8], void * data)
-{
- int dx = buff[4];
- int dy = buff[5];
- GRECT work, screen;
- struct gui_window * gw = data;
-
- if (!dx && !dy) return;
-
- if( input_window == NULL || input_window != gw ) {
- return;
- }
-
- /* update the sliders _before_ we call redraw (which might depend on the slider possitions) */
- mt_WindSlider( &app, win, (dx?HSLIDER:0) | (dy?VSLIDER:0) );
-
- if( dy > 0 )
- browser_scroll( gw, WA_DNPAGE, abs(dy), false );
- else if ( dy < 0)
- browser_scroll( gw, WA_UPPAGE, abs(dy), false );
- if( dx > 0 )
- browser_scroll( gw, WA_RTPAGE, abs(dx), false );
- else if( dx < 0 )
- browser_scroll( gw, WA_LFPAGE, abs(dx), false );
-}
/*
Mouse Button handler for browser component.
*/
-static void __CDECL browser_evnt_mbutton( WINDOW * c, short buff[8], void * data)
+static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * data)
{
long lbuff[8];
short mx, my, dummy, mbut;
@@ -582,10 +479,11 @@
}
b->scroll.requested.y = 0;
b->scroll.requested.x = 0;
- gw->browser->compwin->xpos = b->scroll.current.x;
- gw->browser->compwin->ypos = b->scroll.current.y;
-
- mt_WindSlider( &app, gw->browser->compwin, HSLIDER|VSLIDER);
+
+ gw->root->handle->xpos = b->scroll.current.x;
+ gw->root->handle->ypos = b->scroll.current.y;
+
+ mt_WindSlider( &app, gw->root->handle, HSLIDER|VSLIDER );
}
/*
@@ -749,13 +647,6 @@
}
}
return( r );
-}
-
-static void __CDECL browser_evnt_redraw_x( WINDOW * c, short buf[8], void * data)
-{
- /* just an stub to prevent wndclear */
- /* Probably the browser redraw is better placed here? dunno! */
- return;
}
/* determines if a browser window needs redraw */
@@ -1031,7 +922,6 @@
static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * data)
{
short pxy[8];
- WINDOW * w;
struct gui_window * gw = (struct gui_window *) data;
CMP_BROWSER b = gw->browser;
LGRECT work, lclip, rwork;
@@ -1043,13 +933,23 @@
int xoff,yoff,width,heigth;
short cw, ch, cellw, cellh;
/* use that instead of browser_find_root() ? */
- w = (WINDOW*)mt_CompGetPtr( &app, c, CF_WINDOW );
browser_get_rect( gw, BR_CONTENT, &work );
lclip = work;
if ( !rc_lintersect( (LGRECT*)&buff[4], &lclip ) ) return;
-
- if( b->bw->current_content == NULL )
- return;
+
+ if( b->bw->current_content == NULL ){
+ short pxy[4];
+ pxy[0] = lclip.g_x;
+ pxy[1] = lclip.g_y;
+ pxy[2] = lclip.g_x + lclip.g_w - 1;
+ pxy[3] = lclip.g_y + lclip.g_h - 1;
+ vsf_color( gw->root->handle->graf->handle, WHITE );
+ vsf_perimeter( gw->root->handle->graf->handle, 0);
+ vsf_interior( gw->root->handle->graf->handle, FIS_SOLID );
+ vsf_style( gw->root->handle->graf->handle, 1);
+ v_bar( gw->root->handle->graf->handle, (short*)&pxy );
+ return;
+ }
/* convert redraw coords to framebuffer coords: */
lclip.g_x -= work.g_x;
@@ -1064,11 +964,12 @@
lclip.g_h = work.g_h + lclip.g_y;
lclip.g_y = 0;
}
-
- if( lclip.g_h > 0 && lclip.g_w > 0 ) {
+
+
+ if( lclip.g_h > 0 && lclip.g_w > 0 ) {
browser_schedule_redraw( gw, lclip.g_x, lclip.g_y,
lclip.g_x + lclip.g_w, lclip.g_y + lclip.g_h
- );
+ );
}
return;
Modified: trunk/netsurf/atari/browser.h
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/browser.h?rev=13125...
==============================================================================
--- trunk/netsurf/atari/browser.h (original)
+++ trunk/netsurf/atari/browser.h Sat Nov 5 10:18:19 2011
@@ -97,7 +97,6 @@
{
int type;
COMPONENT * comp;
- WINDOW * compwin;
struct browser_window * bw;
struct s_scroll_info scroll;
struct s_browser_redrw_info redraw;
@@ -137,9 +136,7 @@
static void __CDECL browser_evnt_resize( COMPONENT * c, long buff[8], void * data);
static void __CDECL browser_evnt_destroy( COMPONENT * c, long buff[8], void * data);
static void __CDECL browser_evnt_redraw( COMPONENT * c, long buff[8], void * data);
-static void __CDECL browser_evnt_mbutton( WINDOW * c, short buff[8], void * data);
-static void __CDECL browser_evnt_arrowed( WINDOW *win, short buff[8], void * data);
-static void __CDECL browser_evnt_slider( WINDOW *win, short buff[8], void * data);
-static void __CDECL browser_evnt_redraw_x( WINDOW * c, short buff[8], void * data);
+static void __CDECL browser_evnt_mbutton( COMPONENT * c, long buff[8], void * data);
+
#endif
Modified: trunk/netsurf/atari/browser_win.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/browser_win.c?rev=1...
==============================================================================
--- trunk/netsurf/atari/browser_win.c (original)
+++ trunk/netsurf/atari/browser_win.c Sat Nov 5 10:18:19 2011
@@ -74,36 +74,6 @@
/* -------------------------------------------------------------------------- */
-static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data )
-{
- bool abs = false;
- LGRECT cwork;
- int value = BROWSER_SCROLL_SVAL;
-
- if( input_window == NULL ) {
- return;
- }
-
- browser_get_rect( input_window, BR_CONTENT, &cwork );
-
- switch( buff[4] ) {
- case WA_UPPAGE:
- case WA_DNPAGE:
- value = cwork.g_h;
- break;
-
-
- case WA_LFPAGE:
- case WA_RTPAGE:
- value = cwork.g_w;
- break;
-
- default:
- break;
- }
- browser_scroll( input_window, buff[4], value, abs );
-}
-
/*
track the mouse state and
finally checks for released buttons.
@@ -175,6 +145,372 @@
}
}
+int window_create( struct gui_window * gw, struct browser_window * bw, unsigned long inflags)
+{
+ short buff[8];
+ OBJECT * tbtree;
+ int err = 0;
+ bool tb, sb;
+ short sc;
+ short w,h, wx, wy, wh, ww;
+ int flags;
+
+ tb = (inflags & WIDGET_TOOLBAR );
+ sb = (inflags & WIDGET_STATUSBAR );
+
+ flags = CLOSER | MOVER | NAME | FULLER | SMALLER;
+ if( inflags & WIDGET_SCROLL ){
+ flags |= (UPARROW | DNARROW | LFARROW | RTARROW | VSLIDE | HSLIDE);
+ }
+ if( inflags & WIDGET_RESIZE ){
+ flags |= ( SIZER );
+ }
+
+ gw->root = malloc( sizeof(struct s_gui_win_root) );
+ if( gw->root == NULL )
+ return( -1 );
+ memset( gw->root, 0, sizeof(struct s_gui_win_root) );
+ gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
+ gw->root->handle = WindCreate( flags,40, 40, app.w, app.h );
+ if( gw->root->handle == NULL ) {
+ free( gw->root->title );
+ free( gw->root );
+ return( -1 );
+ }
+
+ /* set scroll / content granularity ( 1 unit ) */
+ gw->root->handle->w_u = 1;
+ gw->root->handle->h_u = 1;
+
+ /* Create Root component: */
+ gw->root->cmproot = mt_CompCreate(&app, CLT_VERTICAL, 1, 1);
+ WindSetPtr( gw->root->handle, WF_COMPONENT, gw->root->cmproot, NULL);
+
+ /* create toolbar component: */
+ if( tb ) {
+ gw->root->toolbar = tb_create( gw );
+ assert( gw->root->toolbar );
+ mt_CompAttach( &app, gw->root->cmproot, gw->root->toolbar->comp );
+
+ } else {
+ gw->root->toolbar = NULL;
+ }
+
+ /* create browser component: */
+ gw->browser = browser_create( gw, bw, NULL, CLT_HORIZONTAL, 1, 1 );
+ mt_CompAttach( &app, gw->root->cmproot, gw->browser->comp );
+
+ /* create statusbar component: */
+ if( sb ) {
+ gw->root->statusbar = sb_create( gw );
+ mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp );
+ } else {
+ gw->root->statusbar = NULL;
+ }
+
+ WindSetStr(gw->root->handle, WF_ICONTITLE, (char*)"NetSurf");
+
+ /* Event Handlers: */
+ EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw );
+ /* capture resize/move events so we can handle that manually */
+ EvntDataAttach( gw->root->handle, WM_SIZED, evnt_window_resize, gw );
+ if( !option_atari_realtime_move ) {
+ EvntDataAttach( gw->root->handle, WM_MOVED, evnt_window_move, gw );
+ } else {
+ EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT );
+ }
+ EvntDataAttach( gw->root->handle, WM_FORCE_MOVE, evnt_window_rt_resize, gw );
+ EvntDataAttach( gw->root->handle, AP_DRAGDROP, evnt_window_dd, gw );
+ EvntDataAdd( gw->root->handle, WM_DESTROY,evnt_window_destroy, gw, EV_TOP );
+ EvntDataAdd( gw->root->handle, WM_ARROWED,evnt_window_arrowed, gw, EV_TOP );
+ EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, gw, EV_BOT);
+ EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT);
+ EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw);
+ EvntDataAttach( gw->root->handle, WM_XM1, evnt_window_m1, gw );
+ EvntDataAttach( gw->root->handle, WM_SLIDEXY, evnt_window_slider, gw );
+
+ /* TODO: check if window is openend as "foreground" window... */
+ window_set_focus( gw, BROWSER, gw->browser);
+
+ return (err);
+}
+
+int window_destroy( struct gui_window * gw)
+{
+ short buff[8];
+ int err = 0;
+
+ search_destroy( gw );
+ if( input_window == gw )
+ input_window = NULL;
+
+ if( gw->root ) {
+ if( gw->root->toolbar )
+ tb_destroy( gw->root->toolbar );
+
+ if( gw->root->statusbar )
+ sb_destroy( gw->root->statusbar );
+ }
+
+ search_destroy( gw );
+
+ if( gw->browser )
+ browser_destroy( gw->browser );
+
+ /* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */
+ if( gw->root ) {
+ /* TODO: check if no other browser is bound to this root window! */
+ if( gw->root->title )
+ free( gw->root->title );
+ if( gw->root->cmproot )
+ mt_CompDelete( &app, gw->root->cmproot );
+ ApplWrite( _AESapid, WM_DESTROY, gw->root->handle->handle, 0, 0, 0, 0);
+ EvntWindom( MU_MESAG );
+ gw->root->handle = NULL;
+ free( gw->root );
+ gw->root = NULL;
+ }
+ return( err );
+}
+
+
+
+void window_open( struct gui_window * gw)
+{
+ LGRECT br;
+ GRECT dim;
+
+ WindOpen(gw->root->handle, 20, 20, app.w/2, app.h/2 );
+ WindClear( gw->root->handle );
+ WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
+
+ /* apply focus to the root frame: */
+ long lfbuff[8] = { CM_GETFOCUS };
+ mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff );
+
+ /* recompute the nested component sizes and positions: */
+ browser_update_rects( gw );
+ mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
+ browser_get_rect( gw, BR_CONTENT, &br );
+ plotter->move( plotter, br.g_x, br.g_y );
+ plotter->resize( plotter, br.g_w, br.g_h );
+ gw->browser->attached = true;
+ if( gw->root->statusbar != NULL ){
+ gw->root->statusbar->attached = true;
+ }
+ /*TBD: get already present content and set size? */
+}
+
+
+
+/* update back forward buttons (see tb_update_buttons (bug) ) */
+void window_update_back_forward( struct gui_window * gw)
+{
+ tb_update_buttons( gw );
+}
+
+void window_set_stauts( struct gui_window * gw , char * text )
+{
+ if( gw->root == NULL )
+ return;
+
+ CMP_STATUSBAR sb = gw->root->statusbar;
+
+ if( sb == NULL || gw->browser->attached == false )
+ return;
+
+ sb_set_text( sb, text );
+}
+
+/* set focus to an arbitary element */
+void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element )
+{
+ if( gw->root->focus.type != type || gw->root->focus.element != element ) {
+ LOG(("Set focus: %p (%d)\n", element, type));
+ gw->root->focus.type = type;
+ gw->root->focus.element = element;
+ }
+}
+
+/* check if the url widget has focus */
+bool window_url_widget_has_focus( struct gui_window * gw )
+{
+ assert( gw );
+ assert( gw->root );
+ if( gw->root->focus.type == URL_WIDGET && gw->root->focus.element != NULL ) {
+ assert( ( &gw->root->toolbar->url == (struct s_url_widget*)gw->root->focus.element ) );
+ assert( GUIWIN_VISIBLE(gw) );
+ return true;
+ }
+ return false;
+}
+
+/* check if an arbitary window widget / or frame has the focus */
+bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element )
+{
+ if( gw == NULL )
+ return( false );
+ if( element == NULL ){
+ assert( 1 != 0 );
+ return( (gw->root->focus.type == t ) );
+ }
+ assert( gw->root != NULL );
+ return( ( element == gw->root->focus.element && t == gw->root->focus.type) );
+}
+
+/* -------------------------------------------------------------------------- */
+/* Event Handlers: */
+/* -------------------------------------------------------------------------- */
+
+static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data )
+{
+ bool abs = false;
+ LGRECT cwork;
+ int value = BROWSER_SCROLL_SVAL;
+
+ if( input_window == NULL ) {
+ return;
+ }
+
+ browser_get_rect( input_window, BR_CONTENT, &cwork );
+
+ switch( buff[4] ) {
+ case WA_UPPAGE:
+ case WA_DNPAGE:
+ value = cwork.g_h;
+ break;
+
+
+ case WA_LFPAGE:
+ case WA_RTPAGE:
+ value = cwork.g_w;
+ break;
+
+ default:
+ break;
+ }
+ browser_scroll( input_window, buff[4], value, abs );
+}
+
+static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
+{
+ struct gui_window * gw = (struct gui_window *)data;
+ char file[DD_NAMEMAX];
+ char name[DD_NAMEMAX];
+ char *buff=NULL;
+ int dd_hdl;
+ int dd_msg; /* pipe-handle */
+ long size;
+ char ext[32];
+ short mx,my,bmstat,mkstat;
+ graf_mkstate(&mx, &my, &bmstat, &mkstat);
+
+ if( gw == NULL )
+ return;
+ if( (win->status & WS_ICONIFY))
+ return;
+
+ dd_hdl = ddopen( wbuff[7], DD_OK);
+ if( dd_hdl<0)
+ return; /* pipe not open */
+ memset( ext, 0, 32);
+ strcpy( ext, "ARGS");
+ dd_msg = ddsexts( dd_hdl, ext);
+ if( dd_msg<0)
+ goto error;
+ dd_msg = ddrtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size);
+ if( size+1 >= PATH_MAX )
+ goto error;
+ if( !strncmp( ext, "ARGS", 4) && dd_msg > 0)
+ {
+ ddreply(dd_hdl, DD_OK);
+ buff = (char*)alloca(sizeof(char)*(size+1));
+ if( buff != NULL )
+ {
+ if( Fread(dd_hdl, size, buff ) == size)
+ {
+ buff[size] = 0;
+ }
+ LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
+ (char*)buff, (char*)&ext,
+ size, mx, my
+ ));
+ {
+ int posx, posy;
+ struct box *box;
+ struct box *file_box = 0;
+ hlcache_handle *h;
+ int box_x, box_y;
+ LGRECT bwrect;
+ struct browser_window * bw = gw->browser->bw;
+ h = bw->current_content;
+ if (!bw->current_content || content_get_type(h) != CONTENT_HTML)
+ return;
+ browser_get_rect( gw, BR_CONTENT, &bwrect );
+ mx = mx - bwrect.g_x;
+ my = my - bwrect.g_y;
+ if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) )
+ return;
+ box = html_get_box_tree(h);
+ box_x = box->margin[LEFT];
+ box_y = box->margin[TOP];
+
+ while ((box = box_at_point(box, mx+gw->browser->scroll.current.x, my+gw->browser->scroll.current.y, &box_x, &box_y, &h)))
+ {
+ if (box->style && css_computed_visibility(box->style) == CSS_VISIBILITY_HIDDEN)
+ continue;
+ if (box->gadget)
+ {
+ switch (box->gadget->type)
+ {
+ case GADGET_FILE:
+ file_box = box;
+ break;
+ /*
+ TODO: handle these
+ case GADGET_TEXTBOX:
+ case GADGET_TEXTAREA:
+ case GADGET_PASSWORD:
+ text_box = box;
+ break;
+ */
+ default:
+ break;
+ }
+ }
+ } /* end While */
+ if ( !file_box )
+ return;
+ if (file_box) {
+ utf8_convert_ret ret;
+ char *utf8_fn;
+
+ ret = local_encoding_to_utf8( buff, 0, &utf8_fn);
+ if (ret != UTF8_CONVERT_OK) {
+ /* A bad encoding should never happen */
+ LOG(("utf8_from_local_encoding failed"));
+ assert(ret != UTF8_CONVERT_BADENC);
+ /* Load was for us - just no memory */
+ return;
+ }
+ /* Found: update form input. */
+ free(file_box->gadget->value);
+ file_box->gadget->value = utf8_fn;
+ /* Redraw box. */
+ box_coords(file_box, &posx, &posy);
+ browser_schedule_redraw(bw->window,
+ posx - gw->browser->scroll.current.x,
+ posy - gw->browser->scroll.current.y,
+ posx - gw->browser->scroll.current.x + file_box->width,
+ posy - gw->browser->scroll.current.y + file_box->height);
+ }
+ }
+ }
+ }
+error:
+ ddclose( dd_hdl);
+}
+
static void __CDECL evnt_window_m1( WINDOW * win, short buff[8], void * data)
{
@@ -182,10 +518,10 @@
static bool prev_url = false;
static bool prev_sb = false;
short mx, my, mbut, mkstate;
- bool a = false; /* flags if mouse is within controls or browser canvas */
+ bool a = false; //flags if mouse is within controls or browser
bool within = false;
- LGRECT urlbox, bwbox, sbbox;
- int nx, ny; /* relative mouse position */
+ LGRECT urlbox, bwbox, sbbox;
+ int nx, ny; // relative mouse position
if( gw == NULL)
@@ -259,340 +595,6 @@
}
}
-int window_create( struct gui_window * gw, struct browser_window * bw, unsigned long inflags)
-{
- short buff[8];
- OBJECT * tbtree;
- int err = 0;
- bool tb, sb;
- tb = (inflags & WIDGET_TOOLBAR );
- sb = (inflags & WIDGET_STATUSBAR);
- short w,h, wx, wy, wh, ww;
- int flags = CLOSER | MOVER | NAME | FULLER | SMALLER ;
-
- gw->root = malloc( sizeof(struct s_gui_win_root) );
- if( gw->root == NULL )
- return( -1 );
- memset( gw->root, 0, sizeof(struct s_gui_win_root) );
- gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
- gw->root->handle = WindCreate( flags,40, 40, app.w, app.h );
- if( gw->root->handle == NULL ) {
- free( gw->root->title );
- free( gw->root );
- return( -1 );
- }
- gw->root->cmproot = mt_CompCreate(&app, CLT_VERTICAL, 1, 1);
- WindSetPtr( gw->root->handle, WF_COMPONENT, gw->root->cmproot, NULL);
-
- if( tb ) {
- gw->root->toolbar = tb_create( gw );
- assert( gw->root->toolbar );
- mt_CompAttach( &app, gw->root->cmproot, gw->root->toolbar->comp );
-
- } else {
- gw->root->toolbar = NULL;
- }
-
- gw->browser = browser_create( gw, bw, NULL, CLT_HORIZONTAL, 1, 1 );
- mt_CompAttach( &app, gw->root->cmproot, gw->browser->comp );
-
- if( sb ) {
- gw->root->statusbar = sb_create( gw );
- mt_CompAttach( &app, gw->root->cmproot, gw->root->statusbar->comp );
- } else {
- gw->root->statusbar = NULL;
- }
-
- WindSetStr(gw->root->handle, WF_ICONTITLE, (char*)"NetSurf");
-
- /* Event Handlers: */
- EvntDataAttach( gw->root->handle, WM_CLOSED, evnt_window_close, gw );
- /* capture resize/move events so we can handle that manually */
- EvntDataAttach( gw->root->handle, WM_SIZED, evnt_window_resize, gw );
- if( !option_atari_realtime_move ) {
- EvntDataAttach( gw->root->handle, WM_MOVED, evnt_window_move, gw );
- } else {
- EvntDataAdd( gw->root->handle, WM_MOVED, evnt_window_rt_resize, gw, EV_BOT );
- }
- EvntDataAttach( gw->root->handle, WM_FORCE_MOVE, evnt_window_rt_resize, gw );
- EvntDataAttach( gw->root->handle, AP_DRAGDROP, evnt_window_dd, gw );
- EvntDataAdd( gw->root->handle, WM_DESTROY,evnt_window_destroy, gw, EV_TOP );
- EvntDataAdd( gw->root->handle, WM_ARROWED,evnt_window_arrowed, gw, EV_TOP );
- EvntDataAdd( gw->root->handle, WM_NEWTOP, evnt_window_newtop, gw, EV_BOT);
- EvntDataAdd( gw->root->handle, WM_TOPPED, evnt_window_newtop, gw, EV_BOT);
- EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw);
- EvntDataAttach( gw->root->handle, WM_XM1, evnt_window_m1, gw );
-
- /* TODO: check if window is openend as "foreground" window... */
- window_set_focus( gw, BROWSER, gw->browser);
- return (err);
-}
-
-int window_destroy( struct gui_window * gw)
-{
- short buff[8];
- int err = 0;
-
- search_destroy( gw );
- if( input_window == gw )
- input_window = NULL;
-
- if( gw->root ) {
- if( gw->root->toolbar )
- tb_destroy( gw->root->toolbar );
-
- if( gw->root->statusbar )
- sb_destroy( gw->root->statusbar );
- }
-
- search_destroy( gw );
-
- LOG(("Freeing browser window"));
- if( gw->browser )
- browser_destroy( gw->browser );
-
- /* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */
- LOG(("Freeing root window"));
- if( gw->root ) {
- /* TODO: check if no other browser is bound to this root window! */
- if( gw->root->title )
- free( gw->root->title );
- if( gw->root->cmproot )
- mt_CompDelete( &app, gw->root->cmproot );
- ApplWrite( _AESapid, WM_DESTROY, gw->root->handle->handle, 0, 0, 0, 0);
- EvntWindom( MU_MESAG );
- gw->root->handle = NULL;
- free( gw->root );
- gw->root = NULL;
- }
- return( err );
-}
-
-
-
-void window_open( struct gui_window * gw)
-{
- LGRECT br;
- GRECT dim;
- WindOpen(gw->root->handle, 20, 20, app.w/2, app.h/2 );
- WindSetStr( gw->root->handle, WF_NAME, (char *)"" );
- /* apply focus to the root frame: */
- long lfbuff[8] = { CM_GETFOCUS };
- mt_CompEvntExec( gl_appvar, gw->browser->comp, lfbuff );
- /* recompute the nested component sizes and positions: */
- browser_update_rects( gw );
- mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
- browser_get_rect( gw, BR_CONTENT, &br );
- plotter->move( plotter, br.g_x, br.g_y );
- plotter->resize( plotter, br.g_w, br.g_h );
- gw->browser->attached = true;
- if( gw->root->statusbar != NULL ){
- gw->root->statusbar->attached = true;
- }
- snd_rdw( gw->root->handle );
-}
-
-
-
-/* update back forward buttons (see tb_update_buttons (bug) ) */
-void window_update_back_forward( struct gui_window * gw)
-{
- tb_update_buttons( gw );
-}
-
-static void window_redraw_controls(struct gui_window *gw, uint32_t flags)
-{
- LGRECT rect;
- /* redraw sliders manually, dunno why this is needed (mt_WindSlider should do the job anytime)!*/
-
- browser_get_rect( gw, BR_VSLIDER, &rect);
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- rect.g_x, rect.g_y, rect.g_w, rect.g_h );
-
- browser_get_rect( gw, BR_HSLIDER, &rect);
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- rect.g_x, rect.g_y, rect.g_w, rect.g_h );
-
- /* send redraw to toolbar & statusbar & scrollbars: */
- mt_CompGetLGrect(&app, gw->root->toolbar->comp, WF_WORKXYWH, &rect);
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- rect.g_x, rect.g_y, rect.g_w, rect.g_h );
- mt_CompGetLGrect(&app, gw->root->statusbar->comp, WF_WORKXYWH, &rect);
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- rect.g_x, rect.g_y, rect.g_w, rect.g_h );
-}
-
-void window_set_stauts( struct gui_window * gw , char * text )
-{
- if( gw->root == NULL )
- return;
-
- CMP_STATUSBAR sb = gw->root->statusbar;
-
- if( sb == NULL || gw->browser->attached == false )
- return;
-
- sb_set_text( sb, text );
-}
-
-/* set focus to an arbitary element */
-void window_set_focus( struct gui_window * gw, enum focus_element_type type, void * element )
-{
- if( gw->root->focus.type != type || gw->root->focus.element != element ) {
- LOG(("Set focus: %p (%d)\n", element, type));
- gw->root->focus.type = type;
- gw->root->focus.element = element;
- }
-}
-
-/* check if the url widget has focus */
-bool window_url_widget_has_focus( struct gui_window * gw )
-{
- assert( gw );
- assert( gw->root );
- if( gw->root->focus.type == URL_WIDGET && gw->root->focus.element != NULL ) {
- assert( ( &gw->root->toolbar->url == (struct s_url_widget*)gw->root->focus.element ) );
- assert( GUIWIN_VISIBLE(gw) );
- return true;
- }
- return false;
-}
-
-/* check if an arbitary window widget / or frame has the focus */
-bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t, void * element )
-{
- if( gw == NULL )
- return( false );
- if( element == NULL ){
- assert( 1 != 0 );
- return( (gw->root->focus.type == t ) );
- }
- assert( gw->root != NULL );
- return( ( element == gw->root->focus.element && t == gw->root->focus.type) );
-}
-
-static void __CDECL evnt_window_dd( WINDOW *win, short wbuff[8], void * data )
-{
- struct gui_window * gw = (struct gui_window *)data;
- char file[DD_NAMEMAX];
- char name[DD_NAMEMAX];
- char *buff=NULL;
- int dd_hdl;
- int dd_msg; /* pipe-handle */
- long size;
- char ext[32];
- short mx,my,bmstat,mkstat;
- graf_mkstate(&mx, &my, &bmstat, &mkstat);
-
- if( gw == NULL )
- return;
- if( (win->status & WS_ICONIFY))
- return;
-
- dd_hdl = ddopen( wbuff[7], DD_OK);
- if( dd_hdl<0)
- return; /* pipe not open */
- memset( ext, 0, 32);
- strcpy( ext, "ARGS");
- dd_msg = ddsexts( dd_hdl, ext);
- if( dd_msg<0)
- goto error;
- dd_msg = ddrtry( dd_hdl, (char*)&name[0], (char*)&file[0], (char*)&ext[0], &size);
- if( size+1 >= PATH_MAX )
- goto error;
- if( !strncmp( ext, "ARGS", 4) && dd_msg > 0)
- {
- ddreply(dd_hdl, DD_OK);
- buff = (char*)alloca(sizeof(char)*(size+1));
- if( buff != NULL )
- {
- if( Fread(dd_hdl, size, buff ) == size)
- {
- buff[size] = 0;
- }
- LOG(("file: %s, ext: %s, size: %d dropped at: %d,%d\n",
- (char*)buff, (char*)&ext,
- size, mx, my
- ));
- {
- int posx, posy;
- struct box *box;
- struct box *file_box = 0;
- hlcache_handle *h;
- int box_x, box_y;
- LGRECT bwrect;
- struct browser_window * bw = gw->browser->bw;
- h = bw->current_content;
- if (!bw->current_content || content_get_type(h) != CONTENT_HTML)
- return;
- browser_get_rect( gw, BR_CONTENT, &bwrect );
- mx = mx - bwrect.g_x;
- my = my - bwrect.g_y;
- if( (mx < 0 || mx > bwrect.g_w) || (my < 0 || my > bwrect.g_h) )
- return;
- box = html_get_box_tree(h);
- box_x = box->margin[LEFT];
- box_y = box->margin[TOP];
-
- while ((box = box_at_point(box, mx+gw->browser->scroll.current.x, my+gw->browser->scroll.current.y, &box_x, &box_y, &h)))
- {
- if (box->style && css_computed_visibility(box->style) == CSS_VISIBILITY_HIDDEN)
- continue;
- if (box->gadget)
- {
- switch (box->gadget->type)
- {
- case GADGET_FILE:
- file_box = box;
- break;
- /*
- TODO: handle these
- case GADGET_TEXTBOX:
- case GADGET_TEXTAREA:
- case GADGET_PASSWORD:
- text_box = box;
- break;
- */
- default:
- break;
- }
- }
- } /* end While */
- if ( !file_box )
- return;
- if (file_box) {
- utf8_convert_ret ret;
- char *utf8_fn;
-
- ret = local_encoding_to_utf8( buff, 0, &utf8_fn);
- if (ret != UTF8_CONVERT_OK) {
- /* A bad encoding should never happen */
- LOG(("utf8_from_local_encoding failed"));
- assert(ret != UTF8_CONVERT_BADENC);
- /* Load was for us - just no memory */
- return;
- }
- /* Found: update form input. */
- free(file_box->gadget->value);
- file_box->gadget->value = utf8_fn;
- /* Redraw box. */
- box_coords(file_box, &posx, &posy);
- browser_schedule_redraw(bw->window,
- posx - gw->browser->scroll.current.x,
- posy - gw->browser->scroll.current.y,
- posx - gw->browser->scroll.current.x + file_box->width,
- posy - gw->browser->scroll.current.y + file_box->height);
- }
- }
- }
- }
-error:
- ddclose( dd_hdl);
-}
-
-/* -------------------------------------------------------------------------- */
-/* Non Public Modul event handlers: */
-/* -------------------------------------------------------------------------- */
static void __CDECL evnt_window_destroy( WINDOW *win, short buff[8], void *data )
{
LOG(("%s\n", __FUNCTION__ ));
@@ -612,8 +614,6 @@
input_window = (struct gui_window *) data;
LOG(("newtop: iw: %p, win: %p", input_window, win ));
assert( input_window != NULL );
-
- /* window_redraw_controls(input_window, 0); */
}
static void __CDECL evnt_window_shaded( WINDOW *win, short buff[8], void *data )
@@ -624,15 +624,40 @@
if(buff[0] == WM_UNSHADED){
}
-}
+}
+
+static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data)
+{
+ int dx = buff[4];
+ int dy = buff[5];
+ GRECT work, screen;
+ struct gui_window * gw = data;
+
+ if (!dx && !dy) return;
+
+ if( input_window == NULL || input_window != gw ) {
+ return;
+ }
+
+ /* update the sliders _before_ we call redraw (which might depend on the slider possitions) */
+ WindSlider( win, (dx?HSLIDER:0) | (dy?VSLIDER:0) );
+
+ if( dy > 0 )
+ browser_scroll( gw, WA_DNPAGE, abs(dy), false );
+ else if ( dy < 0)
+ browser_scroll( gw, WA_UPPAGE, abs(dy), false );
+ if( dx > 0 )
+ browser_scroll( gw, WA_RTPAGE, abs(dx), false );
+ else if( dx < 0 )
+ browser_scroll( gw, WA_LFPAGE, abs(dx), false );
+}
+
static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void * data )
{
short x,y,w,h;
struct gui_window * gw = (struct gui_window*)data;
- LOG((""));
-
WindClear( win);
WindGet( win, WF_WORKXYWH, &x, &y, &w, &h);
if( gw->icon == NULL ) {
@@ -719,14 +744,26 @@
mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
browser_get_rect( gw, BR_CONTENT, &rect );
if( gw->browser->bw->current_content != NULL )
- browser_window_reformat(gw->browser->bw, false, rect.g_w, rect.g_h );
+ browser_window_reformat(gw->browser->bw, false, rect.g_w, rect.g_h );
+ else
+ WindClear( gw->root->handle );
gw->root->toolbar->url.scrollx = 0;
- window_redraw_controls(gw, 0);
+
+ /* send complete redraw to toolbar & statusbar: */
+ mt_CompGetLGrect(&app, gw->root->toolbar->comp, WF_WORKXYWH, &rect);
+ ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
+ rect.g_x, rect.g_y, rect.g_w, rect.g_h
+ );
+ mt_CompGetLGrect(&app, gw->root->statusbar->comp, WF_WORKXYWH, &rect);
+ ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
+ rect.g_x, rect.g_y, rect.g_w, rect.g_h
+ );
+
/* TODO: recalculate scroll position, instead of zeroing? */
} else {
if(gw->root->loc.g_x != x || gw->root->loc.g_y != y ){
- mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
+ mt_WindGetGrect( &app, gw->root->handle, WF_CURRXYWH, (GRECT*)&gw->root->loc);
browser_update_rects( gw );
- }
- }
-}
+ }
+ }
+}
Modified: trunk/netsurf/atari/browser_win.h
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/browser_win.h?rev=1...
==============================================================================
--- trunk/netsurf/atari/browser_win.h (original)
+++ trunk/netsurf/atari/browser_win.h Sat Nov 5 10:18:19 2011
@@ -24,6 +24,8 @@
#define WIDGET_STATUSBAR 0x1
#define WIDGET_TOOLBAR 0x2
+#define WIDGET_SCROLL 0x4
+#define WIDGET_RESIZE 0x8
/* WinDom & Custom bindings for gui window */
@@ -79,5 +81,6 @@
static void __CDECL evnt_window_keybd(WINDOW *win, short buff[8], void *data );
static void __CDECL evnt_window_mbutton(WINDOW *win, short buff[8], void *data );
static void __CDECL evnt_window_m1( WINDOW * win, short buff[8], void * data);
-
+static void __CDECL evnt_window_slider( WINDOW * win, short buff[8], void * data);
+static void __CDECL evnt_window_arrowed( WINDOW *win, short buff[8], void *data );
#endif
Modified: trunk/netsurf/atari/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/gui.c?rev=13125&r1=...
==============================================================================
--- trunk/netsurf/atari/gui.c (original)
+++ trunk/netsurf/atari/gui.c Sat Nov 5 10:18:19 2011
@@ -198,7 +198,7 @@
memset( gw, 0, sizeof(struct gui_window) );
LOG(("new window: %p, bw: %p\n", gw, bw));
- window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR );
+ window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE|WIDGET_SCROLL );
if( gw->root->handle ) {
window_open( gw );
/* Recalculate windows browser area now */
11 years, 6 months
r13124 mono - /trunk/netsurf/atari/gui.c
by netsurf@semichrome.net
Author: mono
Date: Fri Nov 4 20:49:55 2011
New Revision: 13124
URL: http://source.netsurf-browser.org?rev=13124&view=rev
Log:
Removed window_set_icon
Modified:
trunk/netsurf/atari/gui.c
Modified: trunk/netsurf/atari/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/gui.c?rev=13124&r1=...
==============================================================================
--- trunk/netsurf/atari/gui.c (original)
+++ trunk/netsurf/atari/gui.c Fri Nov 4 20:49:55 2011
@@ -578,12 +578,7 @@
gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
{
/* Untestet, favicon support has been dropped, so this is dead code. */
- LOG((""));
- struct bitmap *icon_bitmap;
- icon_bitmap = (icon != NULL) ? content_get_bitmap(icon) : NULL;
- if (icon_bitmap != NULL) {
- window_set_icon( g, icon_bitmap );
- }
+ g->icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
}
11 years, 6 months
r13123 mono - /trunk/netsurf/atari/browser_win.c
by netsurf@semichrome.net
Author: mono
Date: Fri Nov 4 20:48:53 2011
New Revision: 13123
URL: http://source.netsurf-browser.org?rev=13123&view=rev
Log:
Removed window_set_icon
Modified:
trunk/netsurf/atari/browser_win.c
Modified: trunk/netsurf/atari/browser_win.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/browser_win.c?rev=1...
==============================================================================
--- trunk/netsurf/atari/browser_win.c (original)
+++ trunk/netsurf/atari/browser_win.c Fri Nov 4 20:48:53 2011
@@ -323,11 +323,6 @@
EvntDataAttach( gw->root->handle, WM_ICONDRAW, evnt_window_icondraw, gw);
EvntDataAttach( gw->root->handle, WM_XM1, evnt_window_m1, gw );
- /*
- OBJECT * tbut;
- RsrcGaddr( h_gem_rsrc, R_TREE, FAVICO , &tbut );
- window_set_icon(gw, &tbut[]);
- */
/* TODO: check if window is openend as "foreground" window... */
window_set_focus( gw, BROWSER, gw->browser);
return (err);
@@ -342,8 +337,7 @@
if( input_window == gw )
input_window = NULL;
- if( gw->root ) {
- window_set_icon( gw, NULL );
+ if( gw->root ) {
if( gw->root->toolbar )
tb_destroy( gw->root->toolbar );
@@ -356,10 +350,6 @@
LOG(("Freeing browser window"));
if( gw->browser )
browser_destroy( gw->browser );
-
-
- /* destroy the icon: */
- /*window_set_icon(gw, NULL, false );*/
/* needed? */ /*listRemove( (LINKABLE*)gw->root->cmproot ); */
LOG(("Freeing root window"));
@@ -400,17 +390,6 @@
gw->root->statusbar->attached = true;
}
snd_rdw( gw->root->handle );
-}
-
-
-void window_set_icon(struct gui_window * gw, struct bitmap * bmp )
-{
- /*
- if( gw->icon != NULL ){
- bitmap_destroy( gw->icon );
- gw->icon = NULL;
- }*/
- gw->icon = bmp;
}
11 years, 6 months