r10721 jmb - /trunk/netsurf/content/llcache.c
by netsurf@semichrome.net
Author: jmb
Date: Sun Aug 29 12:41:54 2010
New Revision: 10721
URL: http://source.netsurf-browser.org?rev=10721&view=rev
Log:
Fix bug #3055480: properly compare URLs, instead of erroneously assuming that strcasecmp is the correct answer.
Modified:
trunk/netsurf/content/llcache.c
Modified: trunk/netsurf/content/llcache.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/llcache.c?rev=107...
==============================================================================
--- trunk/netsurf/content/llcache.c (original)
+++ trunk/netsurf/content/llcache.c Sun Aug 29 12:41:54 2010
@@ -695,9 +695,13 @@
/* Search for the most recently fetched matching object */
for (obj = llcache_cached_objects; obj != NULL; obj = obj->next) {
- if (strcasecmp(obj->url, url) == 0 && (newest == NULL ||
- obj->cache.req_time > newest->cache.req_time))
+ bool match;
+
+ if (url_compare(obj->url, url, true, &match) == URL_FUNC_OK &&
+ match == true && (newest == NULL ||
+ obj->cache.req_time > newest->cache.req_time)) {
newest = obj;
+ }
}
if (newest != NULL && llcache_object_is_fresh(newest)) {
12 years, 9 months
r10720 chris_y - in /trunk/netsurf/amiga: arexx.c dist/NetSurf.guide
by netsurf@semichrome.net
Author: chris_y
Date: Sat Aug 28 18:48:33 2010
New Revision: 10720
URL: http://source.netsurf-browser.org?rev=10720&view=rev
Log:
Alias W for WINDOW and T for TAB.
Add documentation on ARexx startup/shutdown scripts
Modified:
trunk/netsurf/amiga/arexx.c
trunk/netsurf/amiga/dist/NetSurf.guide
Modified: trunk/netsurf/amiga/arexx.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/arexx.c?rev=10720&r...
==============================================================================
--- trunk/netsurf/amiga/arexx.c (original)
+++ trunk/netsurf/amiga/arexx.c Sat Aug 28 18:48:33 2010
@@ -77,21 +77,21 @@
STATIC struct ARexxCmd Commands[] =
{
- {"OPEN",RX_OPEN,rx_open,"URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"OPEN",RX_OPEN,rx_open,"URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
{"QUIT",RX_QUIT,rx_quit,NULL, 0, NULL, 0, 0, NULL },
{"TOFRONT",RX_TOFRONT,rx_tofront,NULL, 0, NULL, 0, 0, NULL },
- {"GETURL",RX_GETURL,rx_geturl, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
- {"GETTITLE",RX_GETTITLE,rx_gettitle, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"GETURL",RX_GETURL,rx_geturl, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"GETTITLE",RX_GETTITLE,rx_gettitle, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
{"VERSION",RX_VERSION,rx_version,"VERSION/N,SVN=REVISION/N,RELEASE/S", 0, NULL, 0, 0, NULL },
- {"SAVE",RX_SAVE,rx_save,"FILENAME/A,WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"SAVE",RX_SAVE,rx_save,"FILENAME/A,W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
{"GETSCREENNAME",RX_PUBSCREEN,rx_pubscreen,NULL, 0, NULL, 0, 0, NULL },
- {"BACK", RX_BACK, rx_back, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
- {"FORWARD", RX_FORWARD, rx_forward, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
- {"HOME", RX_HOME, rx_home, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
- {"RELOAD", RX_RELOAD, rx_reload, "FORCE/S,WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
- {"WINDOWS", RX_WINDOWS, rx_windows, "WINDOW/K/N", 0, NULL, 0, 0, NULL },
- {"ACTIVE", RX_ACTIVE, rx_active, "TAB/S", 0, NULL, 0, 0, NULL },
- {"CLOSE", RX_CLOSE, rx_close, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"BACK", RX_BACK, rx_back, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"FORWARD", RX_FORWARD, rx_forward, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"HOME", RX_HOME, rx_home, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"RELOAD", RX_RELOAD, rx_reload, "FORCE/S,W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
+ {"WINDOWS", RX_WINDOWS, rx_windows, "W=WINDOW/K/N", 0, NULL, 0, 0, NULL },
+ {"ACTIVE", RX_ACTIVE, rx_active, "T=TAB/S", 0, NULL, 0, 0, NULL },
+ {"CLOSE", RX_CLOSE, rx_close, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL },
{ NULL, 0, NULL, NULL, 0, NULL, 0, 0, NULL }
};
Modified: trunk/netsurf/amiga/dist/NetSurf.guide
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/dist/NetSurf.guide?...
==============================================================================
--- trunk/netsurf/amiga/dist/NetSurf.guide (original)
+++ trunk/netsurf/amiga/dist/NetSurf.guide Sat Aug 28 18:48:33 2010
@@ -46,6 +46,8 @@
@{b}url_file@{ub} Path to URL database file
@{b}hotlist_file@{ub} Path to Hotlist file
@{b}arexx_dir@{ub} Path to ARexx scripts dir
+@{b}arexx_startup@{ub} ARexx script to run at startup (in above dir)
+@{b}arexx_shutdown@{ub} ARexx script to run on quit (in above dir)
@endnode
@node Fonts
@@ -81,10 +83,10 @@
Commands are:
-@{b}OPEN URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,WINDOW/K/N,TAB/K/N@{ub}
+@{b}OPEN URL/A,NEW=NEWWINDOW/S,NEWTAB/S,SAVEAS/K,W=WINDOW/K/N,T=TAB/K/N@{ub}
Opens URL in current window or a new window/tab if NEWWINDOW/NEWTAB is specified. Saves the location without displaying if SAVEAS and a filename is specified (SAVEAS available in 2.6325)
-@{b}SAVE FILENAME/A,WINDOW/K/N,TAB/K/N@{ub} (2.6027)
+@{b}SAVE FILENAME/A,W=WINDOW/K/N,T=TAB/K/N@{ub} (2.6027)
Saves current page source to FILENAME
@{b}QUIT@{ub}
@@ -93,42 +95,44 @@
@{b}TOFRONT@{ub}
Brings NetSurf's screen to the front
-@{b}GETURL WINDOW/K/N,TAB/K/N@{ub}
+@{b}GETURL W=WINDOW/K/N,T=TAB/K/N@{ub}
Puts the URL displayed in the current window/tab into RESULT
-@{b}GETTITLE WINDOW/K/N,TAB/K/N@{ub}
+@{b}GETTITLE W=WINDOW/K/N,T=TAB/K/N@{ub}
Puts the title of the page displayed in the current window/tab into RESULT
@{b}GETSCREENNAME@{ub} (2.8303)
Puts the name of the screen NetSurf is running on into RESULT.
-@{b}BACK WINDOW/K/N,TAB/K/N@{ub} (2.10626)
+@{b}BACK W=WINDOW/K/N,T=TAB/K/N@{ub} (2.10626)
Move back one page in history.
-@{b}FORWARD WINDOW/K/N,TAB/K/N@{ub} (2.10626)
+@{b}FORWARD W=WINDOW/K/N,T=TAB/K/N@{ub} (2.10626)
Move forward one page in history.
-@{b}HOME WINDOW/K/N,TAB/K/N@{ub} (2.10626)
+@{b}HOME W=WINDOW/K/N,T=TAB/K/N@{ub} (2.10626)
Move back to the home page.
-@{b}RELOAD FORCE/S,WINDOW/K/N,TAB/K/N@{ub} (2.10626)
+@{b}RELOAD FORCE/S,W=WINDOW/K/N,T=TAB/K/N@{ub} (2.10626)
Reload the current page, FORCE will do a full reload.
-@{b}CLOSE WINDOW/K/N,TAB/K/N@{ub} (2.10718)
+@{b}CLOSE W=WINDOW/K/N,T=TAB/K/N@{ub} (2.10718)
Close the current page. A window or window and tab can be specified. Note that when a tab is closed, the tab number of tabs to the right of it will change, and the currently active tab may also change. If the last tab or window is closed, NetSurf will usually exit. Make sure you account for these situations in your code.
@{b}VERSION VERSION/N REVISION/N RELEASE/S@{ub}
Returns the current version of NetSurf in RESULT. You can also do version checking by supplying a VERSION and optional REVISION to check against. If the version of NetSurf is the same or higher 1 will be returned, if it is older 0. If RELEASE is specified, the command operates on the release version rather than the internal version number.
-@{b}ACTIVE TAB/S@{ub} (2.10718)
+@{b}ACTIVE T=TAB/S@{ub} (2.10718)
Returns the active window (or tab if TAB is specified). Commands automatically operate on the active window/tab so you do not normally need to use this.
-@{b}WINDOWS WINDOW/K/N@{ub} (2.10656)
+@{b}WINDOWS W=WINDOW/K/N@{ub} (2.10656)
Puts the number of windows into RESULT. If the WINDOW keyword is specified, will put the number of tabs in that window into RESULT.
-The WINDOW/K/N,TAB/K/N parameters were added in 2.10656 and allow targetting a window other than the current one. Both WINDOW and TAB must be specified (TAB=1 for tabless window) except in the special case of the CLOSE command.
-
-The ARexx menu will be populated with scripts named #?.nsrx in @{"arexx_dir" link options 9}, up to a maximum of 20 entries. The titles of these entries will be the comments field of the file (or the filename if comments field is empty).
+The W=WINDOW/K/N,T=TAB/K/N parameters were added in 2.10656 and allow targetting a window other than the current one. Both WINDOW and TAB must be specified (TAB=1 for tabless window) except in the special case of the CLOSE command.
+
+The ARexx menu will be populated with scripts named #?.nsrx in @{"arexx_dir" link options 12}, up to a maximum of 20 entries. The titles of these entries will be the comments field of the file (or the filename if comments field is empty).
+
+Special scripts @{"arexx_startup" link options 13} and @{"arexx_shutdown" link options 14} will be run at startup and shutdown of NetSurf. These will execute after NetSurf has fully initialised with the initial window and before NetSurf frees resources (ie. at the last stage of startup, and the first stage of shutdown)
@endnode
@node OpenURL
12 years, 9 months
r10719 chris_y - in /trunk/netsurf/amiga: gui.c menu.c options.h
by netsurf@semichrome.net
Author: chris_y
Date: Sat Aug 28 18:46:08 2010
New Revision: 10719
URL: http://source.netsurf-browser.org?rev=10719&view=rev
Log:
Add startup and shutdown ARexx scripts (default to startup.nsrx and shutdown.nsrx)
Remove PROGDIR: from arexx_dir default as AM_EXECUTE can't find files in PROGDIR:
Modified:
trunk/netsurf/amiga/gui.c
trunk/netsurf/amiga/menu.c
trunk/netsurf/amiga/options.h
Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=10719&r1=...
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Sat Aug 28 18:46:08 2010
@@ -388,7 +388,13 @@
option_theme = (char *)strdup("PROGDIR:Resources/Themes/Default");
if((!option_arexx_dir) || (option_arexx_dir[0] == '\0'))
- option_arexx_dir = (char *)strdup("PROGDIR:Rexx");
+ option_arexx_dir = (char *)strdup("Rexx");
+
+ if((!option_arexx_startup) || (option_arexx_startup[0] == '\0'))
+ option_arexx_startup = (char *)strdup("Startup.nsrx");
+
+ if((!option_arexx_shutdown) || (option_arexx_shutdown[0] == '\0'))
+ option_arexx_shutdown = (char *)strdup("Shutdown.nsrx");
if(!option_window_width) option_window_width = 800;
if(!option_window_height) option_window_height = 600;
@@ -703,16 +709,23 @@
{
setbuf(stderr, NULL);
char messages[100];
+ char script[1024];
ami_messages_load(messages);
-
netsurf_init(&argc, &argv, "PROGDIR:Resources/Options", messages);
gui_init(argc, argv);
-
gui_init2(argc, argv);
+ strncpy(script, option_arexx_dir, 1024);
+ AddPart(script, option_arexx_startup, 1024);
+ ami_arexx_execute(script);
+
netsurf_main_loop();
+
+ strncpy(script, option_arexx_dir, 1024);
+ AddPart(script, option_arexx_shutdown, 1024);
+ ami_arexx_execute(script);
netsurf_exit();
Modified: trunk/netsurf/amiga/menu.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/menu.c?rev=10719&r1...
==============================================================================
--- trunk/netsurf/amiga/menu.c (original)
+++ trunk/netsurf/amiga/menu.c Sat Aug 28 18:46:08 2010
@@ -323,6 +323,9 @@
for(ead = (struct ExAllData *)buffer; ead; ead = ead->ed_Next)
{
if(item >= AMI_MENU_AREXX_MAX) continue;
+ if(!strcasecmp(ead->ed_Name, option_arexx_startup)) continue;
+ if(!strcasecmp(ead->ed_Name, option_arexx_shutdown)) continue;
+
if(EAD_IS_FILE(ead))
{
menu[item].nm_Type = NM_ITEM;
Modified: trunk/netsurf/amiga/options.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/options.h?rev=10719...
==============================================================================
--- trunk/netsurf/amiga/options.h (original)
+++ trunk/netsurf/amiga/options.h Sat Aug 28 18:46:08 2010
@@ -38,6 +38,8 @@
extern char *option_search_engines_file;
extern char *option_search_ico_file;
extern char *option_arexx_dir;
+extern char *option_arexx_startup;
+extern char *option_arexx_shutdown;
extern char *option_download_dir;
extern bool option_download_notify;
extern bool option_faster_scroll;
@@ -70,6 +72,8 @@
char *option_search_engines_file = 0; \
char *option_search_ico_file = 0; \
char *option_arexx_dir = 0; \
+char *option_arexx_startup = 0; \
+char *option_arexx_shutdown = 0; \
char *option_download_dir = 0; \
bool option_download_notify = false; \
bool option_faster_scroll = true; \
@@ -102,6 +106,8 @@
{ "search_engines_file", OPTION_STRING, &option_search_engines_file }, \
{ "search_ico_file", OPTION_STRING, &option_search_ico_file }, \
{ "arexx_dir", OPTION_STRING, &option_arexx_dir }, \
+{ "arexx_startup", OPTION_STRING, &option_arexx_startup }, \
+{ "arexx_shutdown", OPTION_STRING, &option_arexx_shutdown }, \
{ "download_dir", OPTION_STRING, &option_download_dir }, \
{ "download_notify", OPTION_BOOL, &option_download_notify}, \
{ "faster_scroll", OPTION_BOOL, &option_faster_scroll}, \
12 years, 9 months
r10718 chris_y - in /trunk/netsurf/amiga: arexx.c dist/NetSurf.guide dist/Rexx/CloseTabs.nsrx
by netsurf@semichrome.net
Author: chris_y
Date: Sat Aug 28 17:44:35 2010
New Revision: 10718
URL: http://source.netsurf-browser.org?rev=10718&view=rev
Log:
Add ARexx commands CLOSE (close window/tab) and ACTIVE (current window/tab number to
pass to other ARexx commands)
Add CloseTabs.nsrx script to close all tabs in the current window except the active
one
Added:
trunk/netsurf/amiga/dist/Rexx/CloseTabs.nsrx (with props)
Modified:
trunk/netsurf/amiga/arexx.c
trunk/netsurf/amiga/dist/NetSurf.guide
Modified: trunk/netsurf/amiga/arexx.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/arexx.c?rev=10718&r...
==============================================================================
--- trunk/netsurf/amiga/arexx.c (original)
+++ trunk/netsurf/amiga/arexx.c Sat Aug 28 17:44:35 2010
@@ -52,7 +52,9 @@
RX_FORWARD,
RX_HOME,
RX_RELOAD,
- RX_WINDOWS
+ RX_WINDOWS,
+ RX_ACTIVE,
+ RX_CLOSE
};
STATIC char result[100];
@@ -70,6 +72,8 @@
STATIC VOID rx_home(struct ARexxCmd *, struct RexxMsg *);
STATIC VOID rx_reload(struct ARexxCmd *, struct RexxMsg *);
STATIC VOID rx_windows(struct ARexxCmd *, struct RexxMsg *);
+STATIC VOID rx_active(struct ARexxCmd *, struct RexxMsg *);
+STATIC VOID rx_close(struct ARexxCmd *, struct RexxMsg *);
STATIC struct ARexxCmd Commands[] =
{
@@ -86,6 +90,8 @@
{"HOME", RX_HOME, rx_home, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
{"RELOAD", RX_RELOAD, rx_reload, "FORCE/S,WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
{"WINDOWS", RX_WINDOWS, rx_windows, "WINDOW/K/N", 0, NULL, 0, 0, NULL },
+ {"ACTIVE", RX_ACTIVE, rx_active, "TAB/S", 0, NULL, 0, 0, NULL },
+ {"CLOSE", RX_CLOSE, rx_close, "WINDOW/K/N,TAB/K/N", 0, NULL, 0, 0, NULL },
{ NULL, 0, NULL, NULL, 0, NULL, 0, 0, NULL }
};
@@ -156,6 +162,30 @@
return NULL;
}
+int ami_find_tab_bw(struct gui_window_2 *gwin, struct browser_window *bw)
+{
+ int tabs = 0;
+ struct Node *ctab;
+ struct Node *ntab;
+ struct browser_window *tbw = NULL;
+
+ if((bw == NULL) || (gwin->tabs == 0)) return 1;
+
+ ctab = GetHead(&gwin->tab_list);
+
+ do
+ {
+ tabs++;
+ ntab=GetSucc(ctab);
+ GetClickTabNodeAttrs(ctab,
+ TNA_UserData, &tbw,
+ TAG_DONE);
+ if(tbw == bw) return tabs;
+ } while(ctab=ntab);
+
+ return NULL;
+}
+
struct browser_window *ami_find_tab(int window, int tab)
{
int windows = 0, tabs = 0;
@@ -490,3 +520,62 @@
else sprintf(result, "%ld", windows);
cmd->ac_Result = result;
}
+
+STATIC VOID rx_active(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+{
+ int windows = 0, tabs = 0;
+ int window = 0, tab = 0;
+ struct browser_window *bw = curbw;
+ struct nsObject *node, *nnode;
+ struct gui_window_2 *gwin;
+
+ cmd->ac_RC = 0;
+
+ if(!IsMinListEmpty(window_list))
+ {
+ node = (struct nsObject *)GetHead((struct List *)window_list);
+
+ do
+ {
+ nnode=(struct nsObject *)GetSucc((struct Node *)node);
+
+ gwin = node->objstruct;
+
+ if(node->Type == AMINS_WINDOW)
+ {
+ windows++;
+ if(gwin->bw == bw)
+ {
+ window = windows;
+ break;
+ }
+ }
+ } while(node = nnode);
+ }
+
+ if(cmd->ac_ArgList[0])
+ {
+ tab = ami_find_tab_bw(gwin, bw);
+ }
+
+ if(cmd->ac_ArgList[0]) sprintf(result, "%ld", tab);
+ else sprintf(result, "%ld", window);
+ cmd->ac_Result = result;
+}
+
+STATIC VOID rx_close(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unused)))
+{
+ struct browser_window *bw = curbw;
+
+ cmd->ac_RC = 0;
+
+ if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1]))
+ bw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]);
+ else if(cmd->ac_ArgList[0])
+ {
+ ami_close_all_tabs(bw->window->shared);
+ return;
+ }
+
+ if(bw) browser_window_destroy(bw);
+}
Modified: trunk/netsurf/amiga/dist/NetSurf.guide
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/dist/NetSurf.guide?...
==============================================================================
--- trunk/netsurf/amiga/dist/NetSurf.guide (original)
+++ trunk/netsurf/amiga/dist/NetSurf.guide Sat Aug 28 17:44:35 2010
@@ -114,13 +114,19 @@
@{b}RELOAD FORCE/S,WINDOW/K/N,TAB/K/N@{ub} (2.10626)
Reload the current page, FORCE will do a full reload.
+@{b}CLOSE WINDOW/K/N,TAB/K/N@{ub} (2.10718)
+Close the current page. A window or window and tab can be specified. Note that when a tab is closed, the tab number of tabs to the right of it will change, and the currently active tab may also change. If the last tab or window is closed, NetSurf will usually exit. Make sure you account for these situations in your code.
+
@{b}VERSION VERSION/N REVISION/N RELEASE/S@{ub}
Returns the current version of NetSurf in RESULT. You can also do version checking by supplying a VERSION and optional REVISION to check against. If the version of NetSurf is the same or higher 1 will be returned, if it is older 0. If RELEASE is specified, the command operates on the release version rather than the internal version number.
+@{b}ACTIVE TAB/S@{ub} (2.10718)
+Returns the active window (or tab if TAB is specified). Commands automatically operate on the active window/tab so you do not normally need to use this.
+
@{b}WINDOWS WINDOW/K/N@{ub} (2.10656)
Puts the number of windows into RESULT. If the WINDOW keyword is specified, will put the number of tabs in that window into RESULT.
-The WINDOW/K/N,TAB/K/N parameters were added in 2.10656 and allow targetting a window other than the current one. Both WINDOW and TAB must be specified (TAB=1 for tabless window)
+The WINDOW/K/N,TAB/K/N parameters were added in 2.10656 and allow targetting a window other than the current one. Both WINDOW and TAB must be specified (TAB=1 for tabless window) except in the special case of the CLOSE command.
The ARexx menu will be populated with scripts named #?.nsrx in @{"arexx_dir" link options 9}, up to a maximum of 20 entries. The titles of these entries will be the comments field of the file (or the filename if comments field is empty).
@endnode
Added: trunk/netsurf/amiga/dist/Rexx/CloseTabs.nsrx
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/dist/Rexx/CloseTabs...
==============================================================================
--- trunk/netsurf/amiga/dist/Rexx/CloseTabs.nsrx (added)
+++ trunk/netsurf/amiga/dist/Rexx/CloseTabs.nsrx Sat Aug 28 17:44:35 2010
@@ -1,0 +1,47 @@
+/*
+ * Copyright 2010 Chris Young <chris(a)unsatisfactorysoftware.co.uk>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* This script closes all tabs other than the current one */
+
+options results
+address netsurf
+
+/* Find the currently active window and tab */
+active
+awin = result
+active tab
+atab = result
+
+/* Find out how many tabs are in the active window */
+windows window awin
+tabs = result
+
+if tabs=1 then exit
+
+/* Close all tabs above the current one */
+do t=tabs to atab+1 by -1
+ close window awin tab t
+end
+
+/* Close all tabs below the current one
+ * NB: The active tab number will change when lower-numbered tabs are closed!
+ */
+
+do t=1 to atab-1
+ close window awin tab 1
+end
Propchange: trunk/netsurf/amiga/dist/Rexx/CloseTabs.nsrx
------------------------------------------------------------------------------
amiga:comment = Close other tabs
Propchange: trunk/netsurf/amiga/dist/Rexx/CloseTabs.nsrx
------------------------------------------------------------------------------
amiga:protection = ----rw-d ---- ----
12 years, 9 months
r10717 jmb - in /trunk/dom: bindings/hubbub/ bindings/xml/ include/dom/bootstrap/ include/dom/core/ include/dom/events/ src/bootstrap/ src/core/ src/events/ src/utils/ test/ test/testutils/
by netsurf@semichrome.net
Author: jmb
Date: Thu Aug 26 18:00:23 2010
New Revision: 10717
URL: http://source.netsurf-browser.org?rev=10717&view=rev
Log:
Sync with modified libwapcaplet API: 11 additional DOM Level1 testsuite failures. Most importantly, it actually compiles now.
Modified:
trunk/dom/bindings/hubbub/parser.c
trunk/dom/bindings/hubbub/parser.h
trunk/dom/bindings/xml/xmlparser.c
trunk/dom/bindings/xml/xmlparser.h
trunk/dom/include/dom/bootstrap/implpriv.h
trunk/dom/include/dom/core/implementation.h
trunk/dom/include/dom/core/string.h
trunk/dom/include/dom/events/document_event.h
trunk/dom/src/bootstrap/implementation.c
trunk/dom/src/core/document.c
trunk/dom/src/core/document.h
trunk/dom/src/core/document_type.c
trunk/dom/src/core/document_type.h
trunk/dom/src/core/element.c
trunk/dom/src/core/implementation.c
trunk/dom/src/core/node.c
trunk/dom/src/core/node.h
trunk/dom/src/core/nodelist.c
trunk/dom/src/core/string.c
trunk/dom/src/core/string.h
trunk/dom/src/core/text.h
trunk/dom/src/events/document_event.c
trunk/dom/src/events/event.c
trunk/dom/src/events/event_target.c
trunk/dom/src/utils/resource_mgr.c
trunk/dom/src/utils/resource_mgr.h
trunk/dom/test/DOMTSHandler.pm
trunk/dom/test/testutils/domts.h
trunk/dom/test/testutils/load.c
Modified: trunk/dom/bindings/hubbub/parser.c
URL: http://source.netsurf-browser.org/trunk/dom/bindings/hubbub/parser.c?rev=...
==============================================================================
--- trunk/dom/bindings/hubbub/parser.c (original)
+++ trunk/dom/bindings/hubbub/parser.c Thu Aug 26 18:00:23 2010
@@ -45,8 +45,6 @@
dom_msg msg; /**< Informational messaging function */
void *mctx; /**< Pointer to client data */
-
- struct lwc_context_s *ctx; /**< The string intern context */
};
@@ -117,8 +115,7 @@
*/
dom_hubbub_parser *dom_hubbub_parser_create(const char *aliases,
const char *enc, bool fix_enc,
- dom_alloc alloc, void *pw, dom_msg msg, void *mctx,
- lwc_context *ctx)
+ dom_alloc alloc, void *pw, dom_msg msg, void *mctx)
{
dom_hubbub_parser *parser;
hubbub_parser_optparams params;
@@ -157,7 +154,6 @@
parser->pw = pw;
parser->msg = msg;
parser->mctx = mctx;
- parser->ctx = ctx;
error = hubbub_parser_create(enc, fix_enc, alloc, pw, &parser->parser);
if (error != HUBBUB_OK) {
@@ -194,7 +190,7 @@
* we should pass the real function when we integrate libDOM with
* Netsurf */
err = dom_implementation_create_document(parser->impl, NULL, NULL, NULL,
- alloc, pw, ctx, NULL, &parser->doc);
+ alloc, pw, NULL, &parser->doc);
if (err != DOM_NO_ERR) {
hubbub_parser_destroy(parser->parser);
alloc(parser, 0, pw);
@@ -280,12 +276,12 @@
parser->complete = true;
- lerr = lwc_context_intern(parser->ctx, "id", strlen("id"), &name);
+ lerr = lwc_intern_string("id", strlen("id"), &name);
if (lerr != lwc_error_ok)
return HUBBUB_UNKNOWN;
_dom_document_set_id_name(parser->doc, name);
- lwc_context_string_unref(parser->ctx, name);
+ lwc_string_unref(name);
return DOM_HUBBUB_OK;
}
@@ -408,7 +404,7 @@
err = dom_implementation_create_document_type(dom_parser->impl, qname,
public_id, system_id, dom_parser->alloc,
- dom_parser->pw, dom_parser->ctx, &dtype);
+ dom_parser->pw, &dtype);
if (err != DOM_NO_ERR) {
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Can't create the document type");
Modified: trunk/dom/bindings/hubbub/parser.h
URL: http://source.netsurf-browser.org/trunk/dom/bindings/hubbub/parser.h?rev=...
==============================================================================
--- trunk/dom/bindings/hubbub/parser.h (original)
+++ trunk/dom/bindings/hubbub/parser.h Thu Aug 26 18:00:23 2010
@@ -16,7 +16,6 @@
#include "errors.h"
struct dom_document;
-struct lwc_context_s;
typedef struct dom_hubbub_parser dom_hubbub_parser;
@@ -51,8 +50,7 @@
/* Create a Hubbub parser instance */
dom_hubbub_parser *dom_hubbub_parser_create(const char *aliases,
const char *enc, bool fix_enc,
- dom_alloc alloc, void *pw, dom_msg msg, void *mctx,
- struct lwc_context_s *ctx);
+ dom_alloc alloc, void *pw, dom_msg msg, void *mctx);
/* Destroy a Hubbub parser instance */
void dom_hubbub_parser_destroy(dom_hubbub_parser *parser);
Modified: trunk/dom/bindings/xml/xmlparser.c
URL: http://source.netsurf-browser.org/trunk/dom/bindings/xml/xmlparser.c?rev=...
==============================================================================
--- trunk/dom/bindings/xml/xmlparser.c (original)
+++ trunk/dom/bindings/xml/xmlparser.c Thu Aug 26 18:00:23 2010
@@ -104,8 +104,6 @@
dom_msg msg; /**< Informational message function */
void *mctx; /**< Pointer to client data */
-
- struct lwc_context_s *ctx; /**< The lwc_context of the parser */
};
/**
@@ -162,8 +160,7 @@
* parser encoding is not yet implemented
*/
dom_xml_parser *dom_xml_parser_create(const char *enc, const char *int_enc,
- dom_alloc alloc, void *pw, dom_msg msg, void *mctx,
- lwc_context *ctx)
+ dom_alloc alloc, void *pw, dom_msg msg, void *mctx)
{
dom_xml_parser *parser;
struct dom_string *features;
@@ -239,8 +236,6 @@
parser->msg = msg;
parser->mctx = mctx;
- parser->ctx = ctx;
-
return parser;
}
@@ -311,12 +306,12 @@
/* TODO: In future, this string "id" should be extracted from the
* document schema file instead of just setting it as "id".
*/
- lerr = lwc_context_intern(parser->ctx, "id", SLEN("id"), &name);
+ lerr = lwc_intern_string("id", SLEN("id"), &name);
if (lerr != lwc_error_ok)
return _dom_exception_from_lwc_error(lerr);
_dom_document_set_id_name(parser->doc, name);
- lwc_context_string_unref(parser->ctx, name);
+ lwc_string_unref(name);
return DOM_XML_OK;
}
@@ -355,7 +350,7 @@
/* namespace */ NULL,
/* qname */ NULL,
/* doctype */ NULL,
- parser->alloc, parser->pw, parser->ctx, NULL,
+ parser->alloc, parser->pw, NULL,
&doc);
if (err != DOM_NO_ERR) {
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
@@ -1242,7 +1237,7 @@
/* Create doctype */
err = dom_implementation_create_document_type(parser->impl,
qname, public_id, system_id,
- parser->alloc, parser->pw, parser->ctx, &doctype);
+ parser->alloc, parser->pw, &doctype);
if (err != DOM_NO_ERR) {
dom_string_unref(system_id);
dom_string_unref(public_id);
Modified: trunk/dom/bindings/xml/xmlparser.h
URL: http://source.netsurf-browser.org/trunk/dom/bindings/xml/xmlparser.h?rev=...
==============================================================================
--- trunk/dom/bindings/xml/xmlparser.h (original)
+++ trunk/dom/bindings/xml/xmlparser.h Thu Aug 26 18:00:23 2010
@@ -16,14 +16,12 @@
#include "xmlerror.h"
struct dom_document;
-struct lwc_context_s;
typedef struct dom_xml_parser dom_xml_parser;
/* Create an XML parser instance */
dom_xml_parser *dom_xml_parser_create(const char *enc, const char *int_enc,
- dom_alloc alloc, void *pw, dom_msg msg, void *mctx,
- struct lwc_context_s *ctx);
+ dom_alloc alloc, void *pw, dom_msg msg, void *mctx);
/* Destroy an XML parser instance */
void dom_xml_parser_destroy(dom_xml_parser *parser);
Modified: trunk/dom/include/dom/bootstrap/implpriv.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/bootstrap/implpri...
==============================================================================
--- trunk/dom/include/dom/bootstrap/implpriv.h (original)
+++ trunk/dom/include/dom/bootstrap/implpriv.h Thu Aug 26 18:00:23 2010
@@ -34,7 +34,6 @@
struct dom_document;
struct dom_document_type;
-struct lwc_context_s;
/**
* DOM Implementation
@@ -83,7 +82,7 @@
struct dom_string *qname,
struct dom_string *public_id,
struct dom_string *system_id,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
struct dom_document_type **doctype);
/**
@@ -126,7 +125,7 @@
struct dom_string *namespace,
struct dom_string *qname,
struct dom_document_type *doctype,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
dom_events_default_action_fetcher daf,
struct dom_document **doc);
@@ -246,7 +245,7 @@
/* Create a DOM document */
dom_exception dom_document_create(struct dom_implementation *impl,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
dom_events_default_action_fetcher daf,
struct dom_document **doc);
@@ -258,7 +257,7 @@
dom_exception dom_document_type_create(struct dom_string *qname,
struct dom_string *public_id,
struct dom_string *system_id,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
struct dom_document_type **doctype);
#endif
Modified: trunk/dom/include/dom/core/implementation.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/implementati...
==============================================================================
--- trunk/dom/include/dom/core/implementation.h (original)
+++ trunk/dom/include/dom/core/implementation.h Thu Aug 26 18:00:23 2010
@@ -31,14 +31,14 @@
dom_exception dom_implementation_create_document_type(
struct dom_implementation *impl, struct dom_string *qname,
struct dom_string *public_id, struct dom_string *system_id,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
struct dom_document_type **doctype);
dom_exception dom_implementation_create_document(
struct dom_implementation *impl,
struct dom_string *namespace, struct dom_string *qname,
struct dom_document_type *doctype,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
dom_events_default_action_fetcher daf,
struct dom_document **doc);
Modified: trunk/dom/include/dom/core/string.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/core/string.h?rev...
==============================================================================
--- trunk/dom/include/dom/core/string.h (original)
+++ trunk/dom/include/dom/core/string.h Thu Aug 26 18:00:23 2010
@@ -33,7 +33,7 @@
/* Get the internal lwc_string */
dom_exception dom_string_get_intern(struct dom_string *str,
- struct lwc_context_s **ctx, struct lwc_string_s **lwcstr);
+ struct lwc_string_s **lwcstr);
/* Case sensitively compare two DOM strings */
int dom_string_cmp(struct dom_string *s1, struct dom_string *s2);
Modified: trunk/dom/include/dom/events/document_event.h
URL: http://source.netsurf-browser.org/trunk/dom/include/dom/events/document_e...
==============================================================================
--- trunk/dom/include/dom/events/document_event.h (original)
+++ trunk/dom/include/dom/events/document_event.h Thu Aug 26 18:00:23 2010
@@ -13,7 +13,6 @@
struct dom_string;
struct dom_event;
struct dom_document;
-struct lwc_context_s;
struct lwc_string_s;
typedef struct dom_document dom_document_event;
Modified: trunk/dom/src/bootstrap/implementation.c
URL: http://source.netsurf-browser.org/trunk/dom/src/bootstrap/implementation....
==============================================================================
--- trunk/dom/src/bootstrap/implementation.c (original)
+++ trunk/dom/src/bootstrap/implementation.c Thu Aug 26 18:00:23 2010
@@ -51,14 +51,14 @@
struct dom_string *qname,
struct dom_string *public_id,
struct dom_string *system_id,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
struct dom_document_type **doctype);
static dom_exception impl_implementation_create_document(
struct dom_implementation *impl,
struct dom_string *namespace,
struct dom_string *qname,
struct dom_document_type *doctype,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
dom_events_default_action_fetcher daf,
struct dom_document **doc);
static dom_exception impl_implementation_get_feature(
@@ -210,7 +210,7 @@
struct dom_string *qname,
struct dom_string *public_id,
struct dom_string *system_id,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
struct dom_document_type **doctype)
{
struct dom_document_type *d;
@@ -232,7 +232,7 @@
/* Create the doctype */
err = dom_document_type_create(qname, public_id, system_id,
- alloc, pw, ctx, &d);
+ alloc, pw, &d);
if (err != DOM_NO_ERR)
return err;
@@ -286,7 +286,7 @@
struct dom_string *namespace,
struct dom_string *qname,
struct dom_document_type *doctype,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
dom_events_default_action_fetcher daf,
struct dom_document **doc)
{
@@ -308,7 +308,7 @@
}
/* Create document object */
- err = dom_document_create(impl, alloc, pw, ctx, daf, &d);
+ err = dom_document_create(impl, alloc, pw, daf, &d);
if (err != DOM_NO_ERR)
return err;
Modified: trunk/dom/src/core/document.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/document.c?rev=10717...
==============================================================================
--- trunk/dom/src/core/document.c (original)
+++ trunk/dom/src/core/document.c Thu Aug 26 18:00:23 2010
@@ -75,7 +75,6 @@
* \param alloc Memory (de)allocation function
* \param pw Pointer to client-specific private data
* \param doc Pointer to location to receive created document
- * \param ctx The intern string context of this document
* \param daf The default action fetcher
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion.
*
@@ -84,7 +83,7 @@
* The returned document will already be referenced.
*/
dom_exception dom_document_create(struct dom_implementation *impl,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
dom_events_default_action_fetcher daf,
struct dom_document **doc)
{
@@ -105,7 +104,7 @@
* reaches zero. Documents own themselves (this simplifies the
* rest of the code, as it doesn't need to special case Documents)
*/
- err = _dom_document_initialise(d, impl, alloc, pw, ctx, daf);
+ err = _dom_document_initialise(d, impl, alloc, pw, daf);
if (err != DOM_NO_ERR) {
/* Clean up document */
alloc(d, 0, pw);
@@ -120,10 +119,8 @@
/* Initialise the document */
dom_exception _dom_document_initialise(struct dom_document *doc,
struct dom_implementation *impl, dom_alloc alloc, void *pw,
- struct lwc_context_s *ctx,
dom_events_default_action_fetcher daf)
{
- assert(ctx != NULL);
assert(alloc != NULL);
assert(impl != NULL);
@@ -131,7 +128,7 @@
lwc_string *name;
lwc_error lerr;
- lerr = lwc_context_intern(ctx, "#document", SLEN("#document"), &name);
+ lerr = lwc_intern_string("#document", SLEN("#document"), &name);
if (lerr != lwc_error_ok)
return _dom_exception_from_lwc_error(lerr);
@@ -143,11 +140,10 @@
/* Set up document allocation context - must be first */
doc->alloc = alloc;
doc->pw = pw;
- doc->context = lwc_context_ref(ctx);
err = _dom_node_initialise(&doc->base, doc, DOM_DOCUMENT_NODE,
name, NULL, NULL, NULL);
- lwc_context_string_unref(ctx, name);
+ lwc_string_unref(name);
list_init(&doc->pending_nodes);
@@ -187,8 +183,7 @@
doc->nodelists = NULL;
if (doc->id_name != NULL)
- lwc_context_string_unref(doc->context, doc->id_name);
- lwc_context_unref(doc->context);
+ lwc_string_unref(doc->id_name);
_dom_document_event_internal_finalise(doc, &doc->dei);
@@ -306,13 +301,12 @@
if (_dom_validate_name(tag_name) == false)
return DOM_INVALID_CHARACTER_ERR;
- assert(doc->context != NULL);
- err = _dom_string_intern(tag_name, doc->context, &name);
+ err = _dom_string_intern(tag_name, &name);
if (err != DOM_NO_ERR)
return err;
err = _dom_element_create(doc, name, NULL, NULL, result);
- lwc_context_string_unref(doc->context, name);
+ lwc_string_unref(name);
return err;
}
@@ -335,15 +329,13 @@
dom_exception err;
lwc_error lerr;
- assert(doc->context != NULL);
-
- lerr = lwc_context_intern(doc->context, "#document-fragment",
+ lerr = lwc_intern_string("#document-fragment",
SLEN("#document-fragment"), &name);
if (lerr != lwc_error_ok)
return _dom_exception_from_lwc_error(lerr);
err = _dom_document_fragment_create(doc, name, NULL, result);
- lwc_context_string_unref(doc->context, name);
+ lwc_string_unref(name);
return err;
}
@@ -367,14 +359,12 @@
dom_exception err;
lwc_error lerr;
- assert(doc->context != NULL);
-
- lerr = lwc_context_intern(doc->context, "#text", SLEN("#text"), &name);
+ lerr = lwc_intern_string("#text", SLEN("#text"), &name);
if (lerr != lwc_error_ok)
return _dom_exception_from_lwc_error(lerr);
err = _dom_text_create(doc, name, data, result);
- lwc_context_string_unref(doc->context, name);
+ lwc_string_unref(name);
return err;
}
@@ -398,15 +388,13 @@
dom_exception err;
lwc_error lerr;
- assert(doc->context != NULL);
-
- lerr = lwc_context_intern(doc->context, "#comment", SLEN("#comment"),
+ lerr = lwc_intern_string("#comment", SLEN("#comment"),
&name);
if (lerr != lwc_error_ok)
return _dom_exception_from_lwc_error(lerr);
err = _dom_comment_create(doc, name, data, result);
- lwc_context_string_unref(doc->context, name);
+ lwc_string_unref(name);
return err;
}
@@ -431,15 +419,13 @@
dom_exception err;
lwc_error lerr;
- assert(doc->context != NULL);
-
- lerr = lwc_context_intern(doc->context, "#cdata-section",
+ lerr = lwc_intern_string("#cdata-section",
SLEN("#cdata-section"), &name);
if (lerr != lwc_error_ok)
return _dom_exception_from_lwc_error(lerr);
err = _dom_cdata_section_create(doc, name, data, result);
- lwc_context_string_unref(doc->context, name);
+ lwc_string_unref(name);
return err;
}
@@ -470,13 +456,12 @@
if (_dom_validate_name(target) == false)
return DOM_INVALID_CHARACTER_ERR;
- assert(doc->context != NULL);
- err = _dom_string_intern(target, doc->context, &name);
+ err = _dom_string_intern(target, &name);
if (err != DOM_NO_ERR)
return err;
err = _dom_processing_instruction_create(doc, name, data, result);
- lwc_context_string_unref(doc->context, name);
+ lwc_string_unref(name);
return err;
}
@@ -503,13 +488,12 @@
if (_dom_validate_name(name) == false)
return DOM_INVALID_CHARACTER_ERR;
- assert(doc->context != NULL);
- err = _dom_string_intern(name, doc->context, &n);
+ err = _dom_string_intern(name, &n);
if (err != DOM_NO_ERR)
return err;
err = _dom_attr_create(doc, n, NULL, NULL, true, result);
- lwc_context_string_unref(doc->context, n);
+ lwc_string_unref(n);
return err;
}
@@ -537,13 +521,12 @@
if (_dom_validate_name(name) == false)
return DOM_INVALID_CHARACTER_ERR;
- assert(doc->context != NULL);
- err = _dom_string_intern(name, doc->context, &n);
+ err = _dom_string_intern(name, &n);
if (err != DOM_NO_ERR)
return err;
err = _dom_entity_reference_create(doc, n, NULL, result);
- lwc_context_string_unref(doc->context, n);
+ lwc_string_unref(n);
return err;
}
@@ -565,15 +548,14 @@
lwc_string *name;
dom_exception err;
- assert(doc->context != NULL);
- err = _dom_string_intern(tagname, doc->context, &name);
+ err = _dom_string_intern(tagname, &name);
if (err != DOM_NO_ERR)
return err;
err = _dom_document_get_nodelist(doc, DOM_NODELIST_BY_NAME,
(struct dom_node_internal *) doc, name, NULL, NULL,
result);
- lwc_context_string_unref(doc->context, name);
+ lwc_string_unref(name);
return err;
}
@@ -653,10 +635,9 @@
}
/* Get the interned string from the dom_string */
- assert(doc->context != NULL);
lwc_string *l = NULL, *n = NULL, *p = NULL;
if (localname != NULL) {
- err = _dom_string_intern(localname, doc->context, &l);
+ err = _dom_string_intern(localname, &l);
if (err != DOM_NO_ERR) {
dom_string_unref(localname);
if (prefix != NULL)
@@ -666,9 +647,9 @@
}
}
if (namespace != NULL) {
- err = _dom_string_intern(namespace, doc->context, &n);
+ err = _dom_string_intern(namespace, &n);
if (err != DOM_NO_ERR) {
- lwc_context_string_unref(doc->context, l);
+ lwc_string_unref(l);
dom_string_unref(localname);
if (prefix != NULL)
dom_string_unref(prefix);
@@ -677,10 +658,10 @@
}
}
if (prefix != NULL) {
- err = _dom_string_intern(prefix, doc->context, &p);
+ err = _dom_string_intern(prefix, &p);
if (err != DOM_NO_ERR) {
- lwc_context_string_unref(doc->context, l);
- lwc_context_string_unref(doc->context, n);
+ lwc_string_unref(l);
+ lwc_string_unref(n);
dom_string_unref(localname);
if (prefix != NULL)
dom_string_unref(prefix);
@@ -695,14 +676,14 @@
/* Tidy up */
if (localname != NULL) {
dom_string_unref(localname);
- lwc_context_string_unref(doc->context, l);
+ lwc_string_unref(l);
}
if (prefix != NULL) {
dom_string_unref(prefix);
- lwc_context_string_unref(doc->context, p);
+ lwc_string_unref(p);
}
if (namespace != NULL) {
- lwc_context_string_unref(doc->context, n);
+ lwc_string_unref(n);
}
return err;
@@ -759,10 +740,9 @@
}
/* Get the interned string from the dom_string */
- assert(doc->context != NULL);
lwc_string *l = NULL, *n = NULL, *p = NULL;
if (localname != NULL) {
- err = _dom_string_intern(localname, doc->context, &l);
+ err = _dom_string_intern(localname, &l);
if (err != DOM_NO_ERR) {
dom_string_unref(localname);
if (prefix != NULL)
@@ -772,9 +752,9 @@
}
}
if (namespace != NULL) {
- err = _dom_string_intern(namespace, doc->context, &n);
+ err = _dom_string_intern(namespace, &n);
if (err != DOM_NO_ERR) {
- lwc_context_string_unref(doc->context, l);
+ lwc_string_unref(l);
dom_string_unref(localname);
if (prefix != NULL)
dom_string_unref(prefix);
@@ -783,10 +763,10 @@
}
}
if (prefix != NULL) {
- err = _dom_string_intern(prefix, doc->context, &p);
+ err = _dom_string_intern(prefix, &p);
if (err != DOM_NO_ERR) {
- lwc_context_string_unref(doc->context, l);
- lwc_context_string_unref(doc->context, n);
+ lwc_string_unref(l);
+ lwc_string_unref(n);
dom_string_unref(localname);
if (prefix != NULL)
dom_string_unref(prefix);
@@ -800,14 +780,14 @@
/* Tidy up */
if (localname != NULL) {
dom_string_unref(localname);
- lwc_context_string_unref(doc->context, l);
+ lwc_string_unref(l);
}
if (prefix != NULL) {
dom_string_unref(prefix);
- lwc_context_string_unref(doc->context, p);
+ lwc_string_unref(p);
}
if (namespace != NULL) {
- lwc_context_string_unref(doc->context, n);
+ lwc_string_unref(n);
}
return err;
@@ -834,16 +814,15 @@
lwc_string *l = NULL, *n = NULL;
/* Get the interned string from the dom_string */
- assert(doc->context != NULL);
if (localname != NULL) {
- err = _dom_string_intern(localname, doc->context, &l);
+ err = _dom_string_intern(localname, &l);
if (err != DOM_NO_ERR)
return err;
}
if (namespace != NULL) {
- err = _dom_string_intern(namespace, doc->context, &n);
+ err = _dom_string_intern(namespace, &n);
if (err != DOM_NO_ERR) {
- lwc_context_string_unref(doc->context, l);
+ lwc_string_unref(l);
return err;
}
}
@@ -852,9 +831,9 @@
(struct dom_node_internal *) doc, NULL, n, l, result);
if (l != NULL)
- lwc_context_string_unref(doc->context, l);
+ lwc_string_unref(l);
if (n != NULL)
- lwc_context_string_unref(doc->context, n);
+ lwc_string_unref(n);
return err;
}
@@ -880,8 +859,7 @@
*result = NULL;
- assert(doc->context != NULL);
- err = _dom_string_intern(id, doc->context, &i);
+ err = _dom_string_intern(id, &i);
if (err != DOM_NO_ERR)
return err;
@@ -1322,10 +1300,9 @@
{
lwc_error lerr;
- assert(doc->context != NULL);
-
- lerr = lwc_context_intern(doc->context, (const char *) data, len,
- result);
+ UNUSED(doc);
+
+ lerr = lwc_intern_string((const char *) data, len, result);
return _dom_exception_from_lwc_error(lerr);
}
@@ -1334,14 +1311,9 @@
void _dom_document_unref_lwcstring(struct dom_document *doc,
struct lwc_string_s *str)
{
- lwc_context_string_unref(doc->context, str);
-}
-
-/* Simple accessor for lwc_context of this document */
-struct lwc_context_s *_dom_document_get_intern_context(
- struct dom_document *doc)
-{
- return doc->context;
+ UNUSED(doc);
+
+ lwc_string_unref(str);
}
/* Get the resource manager from the document */
@@ -1350,7 +1322,6 @@
{
rm->alloc = doc->alloc;
rm->pw = doc->pw;
- rm->ctx = doc->context;
}
/* Simple accessor for allocator data for this document */
@@ -1372,10 +1343,8 @@
struct dom_document *doc, struct lwc_string_s *str,
struct dom_string **result)
{
- assert(doc->context != NULL);
-
return _dom_string_create_from_lwcstring(doc->alloc, doc->pw,
- doc->context, str, result);
+ str, result);
}
/**
@@ -1680,14 +1649,11 @@
*
* \param doc The document object
* \param name The ID name of the elements in this document
- *
- * @note: The lwc_context of the param 'name' must be the same one with
- * document's, this should be assured by the client.
*/
void _dom_document_set_id_name(dom_document *doc, struct lwc_string_s *name)
{
if (doc->id_name != NULL)
- lwc_context_string_unref(doc->context, doc->id_name);
- doc->id_name = lwc_context_string_ref(doc->context, name);
-}
-
+ lwc_string_unref(doc->id_name);
+ doc->id_name = lwc_string_ref(name);
+}
+
Modified: trunk/dom/src/core/document.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/document.h?rev=10717...
==============================================================================
--- trunk/dom/src/core/document.h (original)
+++ trunk/dom/src/core/document.h Thu Aug 26 18:00:23 2010
@@ -54,8 +54,6 @@
struct dom_string *uri; /**< The uri of this document */
- struct lwc_context_s *context; /**< The internment context */
-
dom_alloc alloc; /**< Memory (de)allocation function */
void *pw; /**< Pointer to client data */
@@ -71,7 +69,6 @@
/* Initialise the document */
dom_exception _dom_document_initialise(struct dom_document *doc,
struct dom_implementation *impl, dom_alloc alloc, void *pw,
- struct lwc_context_s *ctx,
dom_events_default_action_fetcher daf);
/* Finalise the document */
@@ -220,10 +217,6 @@
/* (De)allocate memory */
void *_dom_document_alloc(struct dom_document *doc, void *ptr, size_t size);
-/* Get the internment context */
-struct lwc_context_s *_dom_document_get_intern_context(
- struct dom_document *doc);
-
/* Get the resource manager inside this document, a resource manager
* is an object which contain the memory allocator/intern string context,
* with which we can allocate strings or intern strings */
Modified: trunk/dom/src/core/document_type.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/document_type.c?rev=...
==============================================================================
--- trunk/dom/src/core/document_type.c (original)
+++ trunk/dom/src/core/document_type.c Thu Aug 26 18:00:23 2010
@@ -66,7 +66,7 @@
*/
dom_exception dom_document_type_create(struct dom_string *qname,
struct dom_string *public_id, struct dom_string *system_id,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
struct dom_document_type **doctype)
{
struct dom_document_type *result;
@@ -82,7 +82,7 @@
result->base.vtable = &dt_protect_vtable;
err = _dom_document_type_initialise(result, qname, public_id, system_id,
- alloc, pw, ctx);
+ alloc, pw);
*doctype = result;
@@ -111,8 +111,7 @@
/* Initialise this document_type */
dom_exception _dom_document_type_initialise(struct dom_document_type *doctype,
struct dom_string *qname, struct dom_string *public_id,
- struct dom_string *system_id, dom_alloc alloc, void *pw,
- struct lwc_context_s *ctx)
+ struct dom_string *system_id, dom_alloc alloc, void *pw)
{
dom_exception err;
@@ -125,7 +124,7 @@
lwc_string *lprefix = NULL, *lname = NULL;
if (prefix != NULL) {
- err = _dom_string_intern(prefix, ctx, &lprefix);
+ err = _dom_string_intern(prefix, &lprefix);
if (err != DOM_NO_ERR) {
dom_string_unref(prefix);
dom_string_unref(localname);
@@ -135,12 +134,12 @@
}
if (localname != NULL) {
- err = _dom_string_intern(localname, ctx, &lname);
+ err = _dom_string_intern(localname, &lname);
if (err != DOM_NO_ERR) {
dom_string_unref(prefix);
dom_string_unref(localname);
if (lprefix != NULL)
- lwc_context_string_unref(ctx, lprefix);
+ lwc_string_unref(lprefix);
alloc(doctype, 0, pw);
return err;
}
@@ -150,8 +149,7 @@
/* Initialise base node */
err = _dom_node_initialise_generic(&doctype->base, NULL, alloc, pw,
- ctx, DOM_DOCUMENT_TYPE_NODE, lname, NULL, NULL,
- lprefix);
+ DOM_DOCUMENT_TYPE_NODE, lname, NULL, NULL, lprefix);
if (err != DOM_NO_ERR) {
alloc(doctype, 0, pw);
return err;
@@ -174,7 +172,6 @@
/* Fill in allocation information */
doctype->res.alloc = alloc;
doctype->res.pw = pw;
- doctype->res.ctx = ctx;
return DOM_NO_ERR;
}
@@ -190,7 +187,7 @@
assert(doctype->base.owner != NULL || doctype->base.user_data == NULL);
_dom_node_finalise_generic(&doctype->base, doctype->res.alloc,
- doctype->res.pw, doctype->res.ctx);
+ doctype->res.pw);
}
@@ -383,7 +380,6 @@
{
rm->alloc = dt->res.alloc;
rm->pw = dt->res.pw;
- rm->ctx = dt->res.ctx;
}
/**
Modified: trunk/dom/src/core/document_type.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/document_type.h?rev=...
==============================================================================
--- trunk/dom/src/core/document_type.h (original)
+++ trunk/dom/src/core/document_type.h Thu Aug 26 18:00:23 2010
@@ -16,8 +16,7 @@
void _dom_document_type_destroy(struct dom_node_internal *doctypenode);
dom_exception _dom_document_type_initialise(struct dom_document_type *doctype,
struct dom_string *qname, struct dom_string *public_id,
- struct dom_string *system_id, dom_alloc alloc, void *pw,
- struct lwc_context_s *ctx);
+ struct dom_string *system_id, dom_alloc alloc, void *pw);
void _dom_document_type_finalise(struct dom_document_type *doctype);
/* The virtual functions of DocumentType */
Modified: trunk/dom/src/core/element.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/element.c?rev=10717&...
==============================================================================
--- trunk/dom/src/core/element.c (original)
+++ trunk/dom/src/core/element.c Thu Aug 26 18:00:23 2010
@@ -216,18 +216,15 @@
*/
void _dom_element_finalise(struct dom_document *doc, struct dom_element *ele)
{
- lwc_context *ctx = _dom_document_get_intern_context(doc);
- assert (ctx != NULL);
-
/* Destroy attributes attached to this node */
if (ele->attributes != NULL) {
- _dom_hash_destroy(ele->attributes, _key, ctx, _value, ctx);
+ _dom_hash_destroy(ele->attributes, _key, NULL, _value, doc);
ele->attributes = NULL;
}
if (ele->ns_attributes != NULL) {
- _dom_hash_destroy(ele->ns_attributes, _key, ctx,
- _nsattributes, ctx);
+ _dom_hash_destroy(ele->ns_attributes, _key, NULL,
+ _nsattributes, doc);
ele->ns_attributes = NULL;
}
@@ -411,14 +408,11 @@
{
dom_exception err;
lwc_string *n;
- lwc_context *ctx;
dom_node_internal *base = (dom_node_internal *) element;
assert(base->owner != NULL);
- ctx = _dom_document_get_intern_context(base->owner);
- assert(ctx != NULL);
-
- err = _dom_string_intern(name, ctx, &n);
+
+ err = _dom_string_intern(name, &n);
if (err != DOM_NO_ERR)
return err;
@@ -426,7 +420,7 @@
(struct dom_node_internal *) element, n, NULL,
NULL, result);
- lwc_context_string_unref(ctx, n);
+ lwc_string_unref(n);
return err;
}
@@ -738,17 +732,16 @@
/** \todo ensure XML feature is supported */
/* Get the interned string from the dom_string */
- assert(doc->context != NULL);
lwc_string *l = NULL, *n = NULL;
if (localname != NULL) {
- err = _dom_string_intern(localname, doc->context, &l);
+ err = _dom_string_intern(localname, &l);
if (err != DOM_NO_ERR)
return err;
}
if (namespace != NULL) {
- err = _dom_string_intern(namespace, doc->context, &n);
+ err = _dom_string_intern(namespace, &n);
if (err != DOM_NO_ERR) {
- lwc_context_string_unref(doc->context, l);
+ lwc_string_unref(l);
return err;
}
@@ -760,9 +753,9 @@
result);
if (localname != NULL)
- lwc_context_string_unref(doc->context, l);
+ lwc_string_unref(l);
if (namespace != NULL)
- lwc_context_string_unref(doc->context, n);
+ lwc_string_unref(n);
return err;
}
@@ -1023,20 +1016,15 @@
struct dom_element *ele = (struct dom_element *) node;
lwc_string *ns;
dom_string *value;
- dom_document *doc = node->owner;
- lwc_context *ctx;
- dom_exception err;
-
- assert(doc != NULL);
+ dom_exception err;
+
err = _dom_node_get_intern_string(node, namespace, &ns);
if (err != DOM_NO_ERR) {
return err;
}
- ctx = _dom_document_get_intern_context(doc);
- assert(ctx != NULL);
if (node->prefix == NULL) {
- lwc_context_string_isequal(ctx, node->namespace, ns, result);
- lwc_context_string_unref(ctx, ns);
+ lwc_string_isequal(node->namespace, ns, result);
+ lwc_string_unref(ns);
return DOM_NO_ERR;
}
@@ -1057,9 +1045,9 @@
}
if (ns2 != NULL) {
- lwc_context_string_isequal(ctx, ns2, ns, result);
- lwc_context_string_unref(ctx, ns);
- lwc_context_string_unref(ctx, ns2);
+ lwc_string_isequal(ns2, ns, result);
+ lwc_string_unref(ns);
+ lwc_string_unref(ns2);
dom_string_unref(value);
return DOM_NO_ERR;
}
@@ -1161,7 +1149,6 @@
dom_element *oe = (dom_element *) old;
dom_document *od, *nd;
struct dom_hash_table *ht;
- lwc_context *oc, *nc;
dom_exception err;
err = _dom_node_copy(new, old);
@@ -1173,23 +1160,18 @@
assert(od != NULL);
assert(nd != NULL);
- oc = _dom_document_get_intern_context(od);
- nc = _dom_document_get_intern_context(nd);
- assert(oc != NULL);
- assert(nc != NULL);
-
dom_alloc alloc;
void *pw;
_dom_document_get_allocator(nd, &alloc, &pw);
/* Copy the hash tables */
- ht = _dom_hash_clone(oe->attributes, alloc, pw, _key, nc,
+ ht = _dom_hash_clone(oe->attributes, alloc, pw, _key, NULL,
_value, nd);
if (ht == NULL)
return DOM_NO_MEM_ERR;
ne->attributes = ht;
- ht = _dom_hash_clone(oe->ns_attributes, alloc, pw, _key, nc,
+ ht = _dom_hash_clone(oe->ns_attributes, alloc, pw, _key, NULL,
_nsattributes, nd);
if (ht == NULL)
return DOM_NO_MEM_ERR;
@@ -2111,22 +2093,20 @@
bool clone)
{
assert(key != NULL);
- assert(key_pw != NULL);
-
+
+ UNUSED(key_pw);
UNUSED(alloc);
UNUSED(pw);
if (clone == false) {
- lwc_context_string_unref((lwc_context *) key_pw,
- (lwc_string *) key);
+ lwc_string_unref((lwc_string *) key);
return NULL;
} else {
lwc_error err;
lwc_string *ret;
const char *data = lwc_string_data((lwc_string *) key);
size_t len = lwc_string_length((lwc_string *) key);
- err = lwc_context_intern((lwc_context *) key_pw, data, len,
- &ret);
+ err = lwc_intern_string(data, len, &ret);
if (err != lwc_error_ok)
return NULL;
@@ -2143,7 +2123,6 @@
UNUSED(alloc);
UNUSED(pw);
- UNUSED(value_pw);
if (clone == false) {
dom_node_internal *a = (dom_node_internal *) value;
@@ -2179,15 +2158,13 @@
return NULL;
} else {
dom_document *doc = (dom_document *) value_pw;
- lwc_context *ctx = _dom_document_get_intern_context(doc);
- assert(ctx != NULL);
dom_alloc alloc;
void *pw;
struct dom_hash_table *ret = NULL;
_dom_document_get_allocator(doc, &alloc, &pw);
ret = _dom_hash_clone((struct dom_hash_table *) value, alloc,
- pw, _key, ctx, _value, doc);
+ pw, _key, NULL, _value, doc);
return ret;
}
Modified: trunk/dom/src/core/implementation.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/implementation.c?rev...
==============================================================================
--- trunk/dom/src/core/implementation.c (original)
+++ trunk/dom/src/core/implementation.c Thu Aug 26 18:00:23 2010
@@ -77,11 +77,11 @@
dom_exception dom_implementation_create_document_type(
struct dom_implementation *impl, struct dom_string *qname,
struct dom_string *public_id, struct dom_string *system_id,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
struct dom_document_type **doctype)
{
return impl->create_document_type(impl, qname, public_id, system_id,
- alloc, pw, ctx, doctype);
+ alloc, pw, doctype);
}
/**
@@ -121,12 +121,12 @@
struct dom_implementation *impl,
struct dom_string *namespace, struct dom_string *qname,
struct dom_document_type *doctype,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
dom_events_default_action_fetcher daf,
struct dom_document **doc)
{
return impl->create_document(impl, namespace, qname, doctype, alloc,
- pw, ctx, daf, doc);
+ pw, daf, doc);
}
/**
Modified: trunk/dom/src/core/node.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/node.c?rev=10717&r1=...
==============================================================================
--- trunk/dom/src/core/node.c (original)
+++ trunk/dom/src/core/node.c Thu Aug 26 18:00:23 2010
@@ -145,18 +145,13 @@
struct lwc_string_s *name, struct dom_string *value,
struct lwc_string_s *namespace, struct lwc_string_s *prefix)
{
- lwc_context *ctx;
dom_alloc alloc;
void *pw;
dom_exception err;
- ctx = _dom_document_get_intern_context(doc);
- /* The lwc_context for a document never can be NULL */
- assert(ctx != NULL);
-
_dom_document_get_allocator(doc, &alloc, &pw);
- err = _dom_node_initialise_generic(node, doc, alloc, pw, ctx, type,
+ err = _dom_node_initialise_generic(node, doc, alloc, pw, type,
name, value, namespace, prefix);
if (err != DOM_NO_ERR)
return err;
@@ -168,10 +163,9 @@
* Initialise a DOM node
*
* \param node The node to initialise
- * \param doc The document object
+ * \param doc The document object
* \param alloc The memory allocator
* \param pw The allocator private pointer data
- * \param ctx The intern context
* \param type The node type required
* \param name The node (local) name, or NULL
* \param value The node value, or NULL
@@ -184,7 +178,7 @@
*/
dom_exception _dom_node_initialise_generic(
struct dom_node_internal *node, struct dom_document *doc,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
dom_node_type type, struct lwc_string_s *name,
struct dom_string *value, struct lwc_string_s *namespace,
struct lwc_string_s *prefix)
@@ -192,11 +186,10 @@
UNUSED(alloc);
UNUSED(pw);
- assert(ctx != NULL);
node->owner = doc;
if (name != NULL)
- lwc_context_string_ref(ctx, name);
+ lwc_string_ref(name);
node->name = name;
if (value != NULL)
@@ -231,12 +224,12 @@
*/
if (namespace != NULL) {
- lwc_context_string_ref(ctx, namespace);
+ lwc_string_ref(namespace);
}
node->namespace = namespace;
if (prefix != NULL) {
- lwc_context_string_ref(ctx, prefix);
+ lwc_string_ref(prefix);
}
node->prefix = prefix;
@@ -264,17 +257,12 @@
*/
void _dom_node_finalise(struct dom_document *doc, dom_node_internal *node)
{
- lwc_context *ctx;
dom_alloc alloc;
void *pw;
- ctx = _dom_document_get_intern_context(doc);
- /* The lwc_context for a document never can be NULL */
- assert(ctx != NULL);
-
_dom_document_get_allocator(doc, &alloc, &pw);
- _dom_node_finalise_generic(node, alloc, pw, ctx);
+ _dom_node_finalise_generic(node, alloc, pw);
}
/**
@@ -283,17 +271,14 @@
* \param node The node to finalise
* \param alloc The allocator
* \param pw The allocator private data
- * \param ctx The intern string context
*/
void _dom_node_finalise_generic(dom_node_internal *node, dom_alloc alloc,
- void *pw, struct lwc_context_s *ctx)
+ void *pw)
{
struct dom_user_data *u, *v;
UNUSED(alloc);
UNUSED(pw);
-
- assert(ctx != NULL);
/* Destroy user data */
for (u = node->user_data; u != NULL; u = v) {
@@ -304,10 +289,10 @@
node->user_data = NULL;
if (node->prefix != NULL)
- lwc_context_string_unref(ctx, node->prefix);
+ lwc_string_unref(node->prefix);
if (node->namespace != NULL)
- lwc_context_string_unref(ctx, node->namespace);
+ lwc_string_unref(node->namespace);
/* Destroy all the child nodes of this node */
struct dom_node_internal *p = node->first_child;
@@ -330,7 +315,7 @@
dom_string_unref(node->value);
if (node->name != NULL)
- lwc_context_string_unref(ctx, node->name);
+ lwc_string_unref(node->name);
/* If the node has no owner document, we need not to finalise its
* dom_event_target_internal structure.
@@ -1339,15 +1324,11 @@
dom_exception _dom_node_get_namespace(dom_node_internal *node,
struct dom_string **result)
{
- lwc_context *ctx;
-
assert(node->owner != NULL);
- ctx = _dom_document_get_intern_context(node->owner);
- assert(ctx != NULL);
/* If there is a namespace, increase its reference count */
if (node->namespace != NULL)
- lwc_context_string_ref(ctx, node->namespace);
+ lwc_string_ref(node->namespace);
return _dom_document_create_string_from_lwcstring(node->owner,
node->namespace, result);
@@ -1367,15 +1348,11 @@
dom_exception _dom_node_get_prefix(dom_node_internal *node,
struct dom_string **result)
{
- lwc_context *ctx;
-
assert(node->owner != NULL);
- ctx = _dom_document_get_intern_context(node->owner);
- assert(ctx != NULL);
/* If there is a prefix, increase its reference count */
if (node->prefix != NULL)
- lwc_context_string_ref(ctx, node->prefix);
+ lwc_string_ref(node->prefix);
return _dom_document_create_string_from_lwcstring(node->owner,
node->prefix,
@@ -1410,10 +1387,6 @@
{
dom_exception err;
lwc_string *str;
- lwc_context *docctx;
-
- docctx = _dom_document_get_intern_context(node->owner);
- assert(docctx != NULL);
/* Only Element and Attribute nodes created using
* namespace-aware methods may have a prefix */
@@ -1432,7 +1405,7 @@
/* No longer want existing prefix */
if (node->prefix != NULL) {
- lwc_context_string_unref(docctx, node->prefix);
+ lwc_string_unref(node->prefix);
}
/* Set the prefix */
@@ -1468,11 +1441,7 @@
dom_exception _dom_node_get_local_name(dom_node_internal *node,
struct dom_string **result)
{
- lwc_context *ctx;
-
assert(node->owner != NULL);
- ctx = _dom_document_get_intern_context(node->owner);
- assert(ctx != NULL);
/* Only Element and Attribute nodes may have a local name */
if (node->type != DOM_ELEMENT_NODE &&
@@ -1483,7 +1452,7 @@
/* The node may have a local name, reference it if so */
if (node->name != NULL) {
- lwc_context_string_ref(ctx, node->name);
+ lwc_string_ref(node->name);
}
return _dom_document_create_string_from_lwcstring(node->owner,
@@ -1740,7 +1709,6 @@
{
dom_exception err;
dom_string *s1, *s2;
- lwc_context *c1, *c2;
dom_namednodemap *m1, *m2;
dom_nodelist *l1, *l2;
@@ -1765,36 +1733,11 @@
return DOM_NO_ERR;
}
- c1 = _dom_document_get_intern_context(node->owner);
- assert(c1 != NULL);
-
- c2 = _dom_document_get_intern_context(other->owner);
- assert(c2 != NULL);
-
- if (c1 == c2) {
- if (node->name != other->name ||
- node->namespace != other->namespace ||
- node->prefix != other->prefix) {
- *result = false;
- return DOM_NO_ERR;
- }
- } else {
- if (_dom_lwc_string_compare_raw(node->name, other->name) != 0){
- *result = false;
- return DOM_NO_ERR;
- }
-
- if (_dom_lwc_string_compare_raw(node->namespace,
- other->namespace) != 0){
- *result = false;
- return DOM_NO_ERR;
- }
-
- if (_dom_lwc_string_compare_raw(node->prefix,
- other->prefix) != 0){
- *result = false;
- return DOM_NO_ERR;
- }
+ if (node->name != other->name ||
+ node->namespace != other->namespace ||
+ node->prefix != other->prefix) {
+ *result = false;
+ return DOM_NO_ERR;
}
if (dom_string_cmp(node->value, other->value) != 0) {
@@ -1987,19 +1930,13 @@
/* Copy the internal attributes of a Node from old to new */
dom_exception _dom_node_copy(dom_node_internal *new, dom_node_internal *old)
{
- lwc_context *nctx, *octx;
dom_exception err;
new->vtable = old->vtable;
new->base.vtable = old->base.vtable;
assert(old->owner != NULL);
- octx = _dom_document_get_intern_context(old->owner);
- assert(octx != NULL);
-
assert(new->owner != NULL);
- nctx = _dom_document_get_intern_context(old->owner);
- assert(nctx != NULL);
new->type = old->type;
new->parent = NULL;
@@ -2009,51 +1946,13 @@
new->next = NULL;
new->owner = old->owner;
- if (octx == nctx) {
- lwc_context_string_ref(octx, old->name);
- new->name = old->name;
-
- if (old->namespace != NULL)
- lwc_context_string_ref(octx, old->namespace);
- new->namespace = old->namespace;
-
- if (old->prefix != NULL)
- lwc_context_string_ref(octx, old->prefix);
- new->prefix = old->prefix;
- } else {
- lwc_string *str;
- lwc_error lerr;
-
- lerr = lwc_context_intern(nctx, lwc_string_data(old->name),
- lwc_string_length(old->name), &str);
- if (lerr != lwc_error_ok)
- return _dom_exception_from_lwc_error(lerr);
-
- new->name = str;
-
- if (old->namespace != NULL) {
- lerr = lwc_context_intern(nctx,
- lwc_string_data(old->namespace),
- lwc_string_length(old->namespace),
- &str);
- if (lerr != lwc_error_ok)
- return _dom_exception_from_lwc_error(lerr);
-
- new->namespace = str;
- } else
- new->namespace = NULL;
-
- if (old->prefix != NULL) {
- lerr = lwc_context_intern(nctx,
- lwc_string_data(old->prefix),
- lwc_string_length(old->prefix), &str);
- if (lerr != lwc_error_ok)
- return _dom_exception_from_lwc_error(lerr);
-
- new->prefix = str;
- } else
- new->prefix = NULL;
- }
+ new->name = lwc_string_ref(old->name);
+
+ if (old->namespace != NULL)
+ new->namespace = lwc_string_ref(old->namespace);
+
+ if (old->prefix != NULL)
+ new->prefix = lwc_string_ref(old->prefix);
dom_alloc al;
void *pw;
@@ -2352,32 +2251,6 @@
}
/**
- * Migrate one lwc_string from one context to another, this function
- * may be used when we import/adopt a Node between documents.
- *
- * \param old The source context
- * \param new The new context
- * \param string The lwc_string to migrate
- * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
- */
-dom_exception _redocument_lwcstring(lwc_context *old, lwc_context *new,
- lwc_string **string)
-{
- lwc_string *str;
- lwc_error lerr;
-
- lerr = lwc_context_intern(new, lwc_string_data(*string),
- lwc_string_length(*string), &str);
- if (lerr != lwc_error_ok)
- return _dom_exception_from_lwc_error(lerr);
-
- lwc_context_string_unref(old, *string);
- *string = str;
-
- return DOM_NO_ERR;
-}
-
-/**
* Migrate one dom_string from one document to another, this function
* may be used when we import/adopt a Node between documents.
*
@@ -2437,7 +2310,7 @@
}
/**
- * Intern a dom_string using the node's owner document's lwc_context
+ * Intern a dom_string
*
* \param node The node
* \param str The dom_string to be interned
@@ -2448,24 +2321,19 @@
dom_string *str, lwc_string **intern)
{
dom_exception err;
- lwc_context *ctx, *docctx;
lwc_string *ret;
+ UNUSED(node);
+
assert(str != NULL);
- assert(node->owner != NULL);
-
- docctx = _dom_document_get_intern_context(node->owner);
- assert(docctx != NULL);
-
- err = dom_string_get_intern(str, &ctx, &ret);
+
+ err = dom_string_get_intern(str, &ret);
if (err != DOM_NO_ERR)
return err;
- if (ctx != docctx) {
- err = _dom_string_intern(str, docctx, &ret);
- if (err != DOM_NO_ERR)
- return err;
- }
+ err = _dom_string_intern(str, &ret);
+ if (err != DOM_NO_ERR)
+ return err;
*intern = ret;
@@ -2491,7 +2359,7 @@
(dom_document_type *) node, &rm);
}
- lwc_context_string_unref(rm.ctx, intern);
+ lwc_string_unref(intern);
}
/**
Modified: trunk/dom/src/core/node.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/node.h?rev=10717&r1=...
==============================================================================
--- trunk/dom/src/core/node.h (original)
+++ trunk/dom/src/core/node.h Thu Aug 26 18:00:23 2010
@@ -92,14 +92,14 @@
dom_exception _dom_node_initialise_generic(
struct dom_node_internal *node, struct dom_document *doc,
- dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_alloc alloc, void *pw,
dom_node_type type, struct lwc_string_s *name,
struct dom_string *value, struct lwc_string_s *namespace,
struct lwc_string_s *prefix);
void _dom_node_finalise(struct dom_document *doc, dom_node_internal *node);
void _dom_node_finalise_generic(dom_node_internal *node, dom_alloc alloc,
- void *pw, struct lwc_context_s *ctx);
+ void *pw);
bool _dom_node_readonly(const dom_node_internal *node);
@@ -275,8 +275,6 @@
#define dom_node_get_refcount(n) ((dom_node_internal *) (n))->refcnt
-dom_exception _redocument_lwcstring(lwc_context *old, lwc_context *new,
- lwc_string **string);
dom_exception _redocument_domstring(struct dom_document *old,
struct dom_document* new, struct dom_string **string);
dom_exception _dom_merge_adjacent_text(dom_node_internal *p,
Modified: trunk/dom/src/core/nodelist.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/nodelist.c?rev=10717...
==============================================================================
--- trunk/dom/src/core/nodelist.c (original)
+++ trunk/dom/src/core/nodelist.c Thu Aug 26 18:00:23 2010
@@ -71,10 +71,6 @@
struct dom_nodelist **list)
{
struct dom_nodelist *l;
- lwc_context *ctx;
-
- ctx = _dom_document_get_intern_context(doc);
- assert(ctx != NULL);
l = _dom_document_alloc(doc, NULL, sizeof(struct dom_nodelist));
if (l == NULL)
@@ -98,7 +94,7 @@
}
}
- lwc_context_string_ref(ctx, tagname);
+ lwc_string_ref(tagname);
l->data.n.name = tagname;
} else if (type == DOM_NODELIST_BY_NAMESPACE) {
l->data.ns.any_localname = false;
@@ -110,7 +106,7 @@
l->data.ns.any_localname = true;
}
}
- lwc_context_string_ref(ctx, localname);
+ lwc_string_ref(localname);
}
if (namespace != NULL) {
if (lwc_string_length(namespace) == 1) {
@@ -119,7 +115,7 @@
l->data.ns.any_namespace = true;
}
}
- lwc_context_string_ref(ctx, namespace);
+ lwc_string_ref(namespace);
}
l->data.ns.namespace = namespace;
@@ -160,25 +156,19 @@
if (--list->refcnt == 0) {
struct dom_node_internal *owner =
(struct dom_node_internal *) list->owner;
- lwc_context *ctx;
- ctx = _dom_document_get_intern_context((dom_document *) owner);
- assert(ctx != NULL);
-
switch (list->type) {
case DOM_NODELIST_CHILDREN:
/* Nothing to do */
break;
case DOM_NODELIST_BY_NAMESPACE:
if (list->data.ns.namespace != NULL)
- lwc_context_string_unref(ctx,
- list->data.ns.namespace);
+ lwc_string_unref(list->data.ns.namespace);
if (list->data.ns.localname != NULL)
- lwc_context_string_unref(ctx,
- list->data.ns.localname);
+ lwc_string_unref(list->data.ns.localname);
break;
case DOM_NODELIST_BY_NAME:
assert(list->data.n.name != NULL);
- lwc_context_string_unref(ctx, list->data.n.name);
+ lwc_string_unref(list->data.n.name);
break;
}
Modified: trunk/dom/src/core/string.c
URL: http://source.netsurf-browser.org/trunk/dom/src/core/string.c?rev=10717&r...
==============================================================================
--- trunk/dom/src/core/string.c (original)
+++ trunk/dom/src/core/string.c Thu Aug 26 18:00:23 2010
@@ -29,8 +29,6 @@
lwc_string *intern; /**< The lwc_string of this string */
- lwc_context *context; /**< The lwc_context for the lwc_string */
-
dom_alloc alloc; /**< Memory (de)allocation function */
void *pw; /**< Client-specific data */
@@ -41,7 +39,6 @@
.ptr = NULL,
.len = 0,
.intern = NULL,
- .context = NULL,
.alloc = NULL,
.pw = NULL,
.refcnt = 1
@@ -75,8 +72,7 @@
if (--str->refcnt == 0) {
if (str->intern != NULL) {
- lwc_context_unref(str->context);
- lwc_context_string_unref(str->context, str->intern);
+ lwc_string_unref(str->intern);
str->alloc(str, 0, str->pw);
} else if (str->alloc != NULL) {
str->alloc(str->ptr, 0, str->pw);
@@ -132,7 +128,6 @@
ret->pw = pw;
ret->intern = NULL;
- ret->context = NULL;
ret->refcnt = 1;
@@ -166,7 +161,7 @@
if (str->intern != NULL) {
return _dom_string_create_from_lwcstring(alloc, pw,
- str->context, str->intern, ret);
+ str->intern, ret);
} else {
return dom_string_create(alloc, pw, str->ptr, str->len, ret);
}
@@ -175,13 +170,12 @@
/**
* Create a dom_string from a lwc_string
*
- * \param ctx The lwc_context
* \param str The lwc_string
* \param ret The new dom_string
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
*/
dom_exception _dom_string_create_from_lwcstring(dom_alloc alloc, void *pw,
- lwc_context *ctx, lwc_string *str, struct dom_string **ret)
+ lwc_string *str, struct dom_string **ret)
{
dom_string *r;
@@ -200,7 +194,6 @@
return DOM_NO_ERR;
}
- r->context = ctx;
r->intern = str;
r->ptr = (uint8_t *)lwc_string_data(str);
r->len = lwc_string_length(str);
@@ -211,8 +204,7 @@
r->refcnt = 1;
/* Ref the lwc_string */
- lwc_context_ref(ctx);
- lwc_context_string_ref(ctx, str);
+ lwc_string_ref(str);
*ret = r;
return DOM_NO_ERR;
@@ -220,42 +212,30 @@
}
/**
- * Make the dom_string be interned in the lwc_context
+ * Make the dom_string be interned
*
* \param str The dom_string to be interned
- * \param ctx The lwc_context to intern this dom_string
* \param lwcstr The result lwc_string
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception _dom_string_intern(struct dom_string *str,
- struct lwc_context_s *ctx, struct lwc_string_s **lwcstr)
+ struct lwc_string_s **lwcstr)
{
lwc_string *ret;
lwc_error lerr;
- /* If this string is interned with the same context, do nothing */
- if (str->context != NULL && str->context == ctx) {
- *lwcstr = str->intern;
- lwc_context_ref(ctx);
- lwc_context_string_ref(ctx, *lwcstr);
+ /* If this string is already interned, do nothing */
+ if (str->intern != NULL) {
+ *lwcstr = lwc_string_ref(str->intern);
return DOM_NO_ERR;
}
- lerr = lwc_context_intern(ctx, (const char *)str->ptr, str->len, &ret);
+ lerr = lwc_intern_string((const char *)str->ptr, str->len, &ret);
if (lerr != lwc_error_ok) {
return _dom_exception_from_lwc_error(lerr);
}
- if (str->context != NULL) {
- lwc_context_unref(str->context);
- lwc_context_string_unref(str->context, str->intern);
- str->ptr = NULL;
- }
-
- str->context = ctx;
str->intern = ret;
- lwc_context_ref(ctx);
- lwc_context_string_ref(ctx, ret);
if (str->ptr != NULL) {
str->alloc(str->ptr, 0, str->pw);
@@ -263,7 +243,7 @@
str->ptr = (uint8_t *) lwc_string_data(ret);
- *lwcstr = ret;
+ *lwcstr = lwc_string_ref(ret);
return DOM_NO_ERR;
}
@@ -271,20 +251,16 @@
* Get the internal lwc_string
*
* \param str The dom_string object
- * \param ctx The lwc_context which intern this dom_string
* \param lwcstr The lwc_string of this dom-string
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception dom_string_get_intern(struct dom_string *str,
- struct lwc_context_s **ctx, struct lwc_string_s **lwcstr)
-{
- *ctx = str->context;
+ struct lwc_string_s **lwcstr)
+{
*lwcstr = str->intern;
- if (*ctx != NULL)
- lwc_context_ref(*ctx);
if (*lwcstr != NULL)
- lwc_context_string_ref(*ctx, *lwcstr);
+ lwc_string_ref(*lwcstr);
return DOM_NO_ERR;
}
@@ -308,11 +284,8 @@
if (s2 == NULL)
s2 = &empty_string;
- if (s1->context == s2->context && s1->context != NULL) {
- assert(s1->intern != NULL);
- assert(s2->intern != NULL);
- lwc_context_string_isequal(s1->context, s1->intern,
- s2->intern, &ret);
+ if (s1->intern != NULL && s2->intern != NULL) {
+ lwc_string_isequal(s1->intern, s2->intern, &ret);
if (ret == true) {
return 0;
} else {
@@ -347,11 +320,8 @@
s2 = &empty_string;
bool ret;
- if (s1->context == s2->context && s1->context != NULL) {
- assert(s1->intern != NULL);
- assert(s2->intern != NULL);
- lwc_context_string_caseless_isequal(s1->context, s1->intern,
- s2->intern, &ret);
+ if (s1->intern != NULL && s2->intern != NULL) {
+ lwc_string_caseless_isequal(s1->intern, s2->intern, &ret);
if (ret == true) {
return 0;
} else {
@@ -606,7 +576,6 @@
concat->alloc = alloc;
concat->pw = pw;
- concat->context = NULL;
concat->intern = NULL;
concat->refcnt = 1;
@@ -757,7 +726,6 @@
res->alloc = target->alloc;
res->pw = target->pw;
res->intern = NULL;
- res->context = NULL;
res->refcnt = 1;
@@ -864,7 +832,6 @@
res->alloc = target->alloc;
res->pw = target->pw;
res->intern = NULL;
- res->context = NULL;
res->refcnt = 1;
@@ -891,7 +858,7 @@
{
if (str->intern != NULL) {
return _dom_string_create_from_lwcstring(str->alloc, str->pw,
- str->context, str->intern, result);
+ str->intern, result);
} else {
return dom_string_create(str->alloc, str->pw, str->ptr,
str->len, result);
@@ -936,6 +903,8 @@
return DOM_NO_MEM_ERR;
case lwc_error_range:
return DOM_INDEX_SIZE_ERR;
+ case lwc_error_initialised:
+ return DOM_NO_ERR;
}
assert ("Unknow lwc_error, can't convert to dom_exception");
/* Suppress compile errors */
@@ -943,30 +912,6 @@
}
/**
- * Compare the raw data of two lwc_strings for equality when the two strings
- * belong to different lwc_context
- *
- * \param s1 The first lwc_string
- * \param s2 The second lwc_string
- * \return 0 for equal, non-zero otherwise
- */
-int _dom_lwc_string_compare_raw(struct lwc_string_s *s1,
- struct lwc_string_s *s2)
-{
- const char *rs1, *rs2;
- size_t len;
-
- if (lwc_string_length(s1) != lwc_string_length(s2))
- return -1;
-
- len = lwc_string_length(s1);
- rs1 = lwc_string_data(s1);
- rs2 = lwc_string_data(s2);
-
- return memcmp(rs1, rs2, len);
-}
-
-/**
* Get the raw character data of the dom_string.
*
* \param str The dom_string object
Modified: trunk/dom/src/core/string.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/string.h?rev=10717&r...
==============================================================================
--- trunk/dom/src/core/string.h (original)
+++ trunk/dom/src/core/string.h Thu Aug 26 18:00:23 2010
@@ -13,17 +13,11 @@
/* Create a DOM string from a lwc_string
* This function call mainly used for create a string from lwc_string */
dom_exception _dom_string_create_from_lwcstring(dom_alloc alloc, void *pw,
- struct lwc_context_s *ctx, struct lwc_string_s *str,
- struct dom_string **ret);
+ struct lwc_string_s *str, struct dom_string **ret);
-/* Make the dom_string be interned in the lwc_context */
+/* Make the dom_string be interned */
dom_exception _dom_string_intern(struct dom_string *str,
- struct lwc_context_s *ctx, struct lwc_string_s **lwcstr);
-
-/* Compare the raw data of two lwc_strings for equality when the two strings
- * belong to different lwc_context */
-int _dom_lwc_string_compare_raw(struct lwc_string_s *s1,
- struct lwc_string_s *s2);
+ struct lwc_string_s **lwcstr);
/* Map the lwc_error to dom_exception */
dom_exception _dom_exception_from_lwc_error(lwc_error err);
Modified: trunk/dom/src/core/text.h
URL: http://source.netsurf-browser.org/trunk/dom/src/core/text.h?rev=10717&r1=...
==============================================================================
--- trunk/dom/src/core/text.h (original)
+++ trunk/dom/src/core/text.h Thu Aug 26 18:00:23 2010
@@ -16,7 +16,6 @@
struct dom_document;
struct dom_string;
-struct lwc_context_s;
struct lwc_string_s;
/**
Modified: trunk/dom/src/events/document_event.c
URL: http://source.netsurf-browser.org/trunk/dom/src/events/document_event.c?r...
==============================================================================
--- trunk/dom/src/events/document_event.c (original)
+++ trunk/dom/src/events/document_event.c Thu Aug 26 18:00:23 2010
@@ -53,11 +53,12 @@
dom_events_default_action_fetcher actions)
{
lwc_error err;
- lwc_context *ctx = _dom_document_get_intern_context(doc);
int i = 0;
+ UNUSED(doc);
+
for (; i < DOM_EVENT_COUNT; i++) {
- err = lwc_context_intern(ctx, __event_types[i],
+ err = lwc_intern_string(__event_types[i],
SLEN(__event_types[i]), &dei->event_types[i]);
if (err != lwc_error_ok)
return _dom_exception_from_lwc_error(err);
@@ -92,15 +93,13 @@
dom_exception _dom_document_event_create_event(dom_document_event *de,
struct dom_string *type, struct dom_event **evt)
{
- lwc_context *ctx = NULL;
lwc_string *t = NULL;
dom_exception err;
struct dom_document *doc = de;
- dom_string_get_intern(type, &ctx, &t);
+ dom_string_get_intern(type, &t);
if (t == NULL) {
- ctx = _dom_document_get_intern_context(doc);
- err = _dom_string_intern(type, ctx, &t);
+ err = _dom_string_intern(type, &t);
if (err != DOM_NO_ERR)
return err;
}
@@ -115,7 +114,7 @@
break;
}
}
- lwc_context_string_unref(ctx, t);
+ lwc_string_unref(t);
switch (et) {
case DOM_EVENT:
Modified: trunk/dom/src/events/event.c
URL: http://source.netsurf-browser.org/trunk/dom/src/events/event.c?rev=10717&...
==============================================================================
--- trunk/dom/src/events/event.c (original)
+++ trunk/dom/src/events/event.c Thu Aug 26 18:00:23 2010
@@ -15,6 +15,7 @@
#include "core/string.h"
#include "core/node.h"
#include "core/document.h"
+#include "utils/utils.h"
static void _virtual_dom_event_destroy(struct dom_event *evt);
@@ -68,14 +69,12 @@
/* Finalise function */
void _dom_event_finalise(struct dom_document *doc, struct dom_event *evt)
{
- assert(doc != NULL);
- lwc_context *ctx = _dom_document_get_intern_context(doc);
- assert(ctx != NULL);
+ UNUSED(doc);
if (evt->type != NULL)
- lwc_context_string_unref(ctx, evt->type);
+ lwc_string_unref(evt->type);
if (evt->namespace != NULL)
- lwc_context_string_unref(ctx, evt->namespace);
+ lwc_string_unref(evt->namespace);
evt->stop = false;
evt->stop_now = false;
@@ -250,11 +249,10 @@
bool bubble, bool cancelable)
{
assert(evt->doc != NULL);
- lwc_context *ctx = _dom_document_get_intern_context(evt->doc);
lwc_string *str = NULL;
dom_exception err;
- err = _dom_string_intern(type, ctx, &str);
+ err = _dom_string_intern(type, &str);
if (err != DOM_NO_ERR)
return err;
@@ -343,16 +341,15 @@
struct dom_string *type, bool bubble, bool cancelable)
{
assert(evt->doc != NULL);
- lwc_context *ctx = _dom_document_get_intern_context(evt->doc);
lwc_string *str = NULL;
dom_exception err;
- err = _dom_string_intern(type, ctx, &str);
+ err = _dom_string_intern(type, &str);
if (err != DOM_NO_ERR)
return err;
evt->type = str;
- err = _dom_string_intern(namespace, ctx, &str);
+ err = _dom_string_intern(namespace, &str);
if (err != DOM_NO_ERR)
return err;
evt->namespace = str;
Modified: trunk/dom/src/events/event_target.c
URL: http://source.netsurf-browser.org/trunk/dom/src/events/event_target.c?rev...
==============================================================================
--- trunk/dom/src/events/event_target.c (original)
+++ trunk/dom/src/events/event_target.c Thu Aug 26 18:00:23 2010
@@ -51,10 +51,8 @@
void _dom_event_target_internal_finalise(struct dom_document *doc,
dom_event_target_internal *eti)
{
- lwc_context *ctx = _dom_document_get_intern_context(doc);
-
if (eti->listeners != NULL)
- _dom_hash_destroy(eti->listeners, _key, ctx, _value, doc);
+ _dom_hash_destroy(eti->listeners, _key, NULL, _value, doc);
/* TODO: Now, we did not support the EventListener with namespace,
* when we support it, we should deal with the ns_listeners hash
* table, too.
@@ -83,7 +81,6 @@
struct dom_event_target_internal *eti = &et->eti;
lwc_string *t = NULL;
- lwc_context *ctx = NULL;
dom_exception err;
/* If there is no hash table, we should create one firstly */
@@ -94,17 +91,16 @@
return err;
}
- err = dom_string_get_intern(type, &ctx, &t);
+ err = dom_string_get_intern(type, &t);
if (err != DOM_NO_ERR)
return err;
- ctx = _dom_document_get_intern_context(doc);
if (t == NULL) {
- err = _dom_string_intern(type, ctx, &t);
+ err = _dom_string_intern(type, &t);
if (err != DOM_NO_ERR)
return err;
} else {
- lwc_context_string_ref(ctx, t);
+ lwc_string_ref(t);
}
assert(t != NULL);
@@ -158,20 +154,18 @@
struct dom_event_target_internal *eti = &et->eti;
lwc_string *t = NULL;
- lwc_context *ctx = NULL;
dom_exception err;
- err = dom_string_get_intern(type, &ctx, &t);
+ err = dom_string_get_intern(type, &t);
if (err != DOM_NO_ERR)
return err;
- ctx = _dom_document_get_intern_context(doc);
if (t == NULL) {
- err = _dom_string_intern(type, ctx, &t);
+ err = _dom_string_intern(type, &t);
if (err != DOM_NO_ERR)
return err;
} else {
- lwc_context_string_ref(ctx, t);
+ lwc_string_ref(t);
}
assert(t != NULL);
@@ -181,7 +175,7 @@
eti->listeners, t);
if (item == NULL) {
/* There is no such event listener */
- lwc_context_string_unref(ctx, t);
+ lwc_string_unref(t);
return DOM_NO_ERR;
} else {
struct list_entry *i = item;
@@ -262,11 +256,9 @@
dom_string_unref(type);
lwc_string *t = evt->type;
- lwc_context *ctx = NULL;
dom_event_target_entry list;
dom_event_target *target = et;
- ctx = _dom_document_get_intern_context(doc);
assert(t != NULL);
*success = true;
@@ -349,8 +341,7 @@
goto cleanup;
}
lwc_string *lnodename = NULL;
- lwc_context *lctx = NULL;
- err = dom_string_get_intern(nodename, &lctx, &lnodename);
+ err = dom_string_get_intern(nodename, &lnodename);
if (err != DOM_NO_ERR) {
dom_string_unref(nodename);
ret = err;
@@ -363,8 +354,7 @@
}
dom_string_unref(nodename);
- lwc_context_string_unref(lctx, lnodename);
- lwc_context_unref(lctx);
+ lwc_string_unref(lnodename);
cleanup:
if (evt->prevent_default == true) {
@@ -441,6 +431,7 @@
static void *_key(void *key, void *key_pw, dom_alloc alloc, void *pw,
bool clone)
{
+ UNUSED(key_pw);
UNUSED(alloc);
UNUSED(pw);
/* There should never be the requirement of clone the event listener
@@ -448,8 +439,7 @@
assert(clone == false);
UNUSED(clone);
- lwc_context *ctx = (lwc_context *) key_pw;
- lwc_context_string_unref(ctx, (lwc_string *) key);
+ lwc_string_unref((lwc_string *) key);
return NULL;
}
Modified: trunk/dom/src/utils/resource_mgr.c
URL: http://source.netsurf-browser.org/trunk/dom/src/utils/resource_mgr.c?rev=...
==============================================================================
--- trunk/dom/src/utils/resource_mgr.c (original)
+++ trunk/dom/src/utils/resource_mgr.c Thu Aug 26 18:00:23 2010
@@ -12,6 +12,8 @@
#include <libwapcaplet/libwapcaplet.h>
#include "core/string.h"
+
+#include "utils/utils.h"
/**
* Allocate some memory with this allocator
@@ -55,10 +57,9 @@
{
lwc_error lerr;
- assert(res->ctx != NULL);
+ UNUSED(res);
- lerr = lwc_context_intern(res->ctx, (const char *) data, len,
- result);
+ lerr = lwc_intern_string((const char *) data, len, result);
return _dom_exception_from_lwc_error(lerr);
}
@@ -75,9 +76,7 @@
struct dom_resource_mgr *res, struct lwc_string_s *str,
struct dom_string **result)
{
- assert(res->ctx != NULL);
-
- return _dom_string_create_from_lwcstring(res->alloc, res->pw, res->ctx,
+ return _dom_string_create_from_lwcstring(res->alloc, res->pw,
str, result);
}
Modified: trunk/dom/src/utils/resource_mgr.h
URL: http://source.netsurf-browser.org/trunk/dom/src/utils/resource_mgr.h?rev=...
==============================================================================
--- trunk/dom/src/utils/resource_mgr.h (original)
+++ trunk/dom/src/utils/resource_mgr.h Thu Aug 26 18:00:23 2010
@@ -13,7 +13,6 @@
#include "hashtable.h"
-struct lwc_context_s;
struct lwc_string_s;
struct dom_string;
@@ -23,7 +22,6 @@
typedef struct dom_resource_mgr {
dom_alloc alloc;
void *pw;
- struct lwc_context_s *ctx;
} dom_resource_mgr;
void *_dom_resource_mgr_alloc(struct dom_resource_mgr *res, void *ptr,
Modified: trunk/dom/test/DOMTSHandler.pm
URL: http://source.netsurf-browser.org/trunk/dom/test/DOMTSHandler.pm?rev=1071...
==============================================================================
--- trunk/dom/test/DOMTSHandler.pm (original)
+++ trunk/dom/test/DOMTSHandler.pm Thu Aug 26 18:00:23 2010
@@ -363,7 +363,6 @@
#include <domts.h>
dom_implementation *doc_impl;
-lwc_context *ctx;
int main(int argc, char **argv)
{
@@ -375,7 +374,7 @@
if (exp != DOM_NO_ERR)
return exp;
- lerr = lwc_create_context(myrealloc, NULL, &ctx);
+ lerr = lwc_initialise(myrealloc, NULL, 0);
if (lerr != lwc_error_ok)
return -1;
@@ -701,9 +700,9 @@
# Add the bootstrap params
if (exists $bootstrap_api{$method}) {
if ($method eq "dom_implementation_create_document") {
- $params = $params.", myrealloc, NULL, ctx, NULL";
+ $params = $params.", myrealloc, NULL, NULL";
} else {
- $params = $params.", myrealloc, NULL, ctx";
+ $params = $params.", myrealloc, NULL";
}
}
# Deal with the situation like
Modified: trunk/dom/test/testutils/domts.h
URL: http://source.netsurf-browser.org/trunk/dom/test/testutils/domts.h?rev=10...
==============================================================================
--- trunk/dom/test/testutils/domts.h (original)
+++ trunk/dom/test/testutils/domts.h Thu Aug 26 18:00:23 2010
@@ -15,10 +15,6 @@
#include <utils.h>
#include <comparators.h>
-struct lwc_context_s;
-
-extern struct lwc_context_s *ctx;
-
dom_document *load_xml(char *file, bool willBeModified);
dom_document *load_html(char *file, bool willBeModified);
Modified: trunk/dom/test/testutils/load.c
URL: http://source.netsurf-browser.org/trunk/dom/test/testutils/load.c?rev=107...
==============================================================================
--- trunk/dom/test/testutils/load.c (original)
+++ trunk/dom/test/testutils/load.c Thu Aug 26 18:00:23 2010
@@ -24,8 +24,6 @@
#include "utils.h"
-extern lwc_context *ctx;
-
/**
* Load the file as it is a XML file
*
@@ -44,7 +42,7 @@
UNUSED(willBeModified);
parser = dom_xml_parser_create(NULL, NULL,
- myrealloc, NULL, mymsg, NULL, ctx);
+ myrealloc, NULL, mymsg, NULL);
if (parser == NULL) {
fprintf(stderr, "Can't create XMLParser\n");
return NULL;
@@ -105,8 +103,8 @@
UNUSED(willBeModified);
- parser = dom_hubbub_parser_create("data/Aliases", NULL, true,
- myrealloc, NULL, mymsg, NULL, ctx);
+ parser = dom_hubbub_parser_create("../data/Aliases", NULL, true,
+ myrealloc, NULL, mymsg, NULL);
if (parser == NULL) {
fprintf(stderr, "Can't create Hubbub Parser\n");
return NULL;
@@ -115,7 +113,7 @@
handle = open(file, O_RDONLY);
if (handle == -1) {
dom_hubbub_parser_destroy(parser);
- fprintf(stderr, "Can't open test input file: %s\n", file);
+ /* fprintf(stderr, "Can't open test input file: %s\n", file); */
return NULL;
}
12 years, 9 months
r10716 jmb - /trunk/netsurf/Makefile
by netsurf@semichrome.net
Author: jmb
Date: Thu Aug 26 14:05:24 2010
New Revision: 10716
URL: http://source.netsurf-browser.org?rev=10716&view=rev
Log:
Fix GTK install target (note: .svn directories end up in the installed tree. This needs fixing)
Modified:
trunk/netsurf/Makefile
Modified: trunk/netsurf/Makefile
URL: http://source.netsurf-browser.org/trunk/netsurf/Makefile?rev=10716&r1=107...
==============================================================================
--- trunk/netsurf/Makefile (original)
+++ trunk/netsurf/Makefile Thu Aug 26 14:05:24 2010
@@ -820,6 +820,7 @@
clean: $(CLEANS)
install-gtk: nsgtk
+ @# TODO: filter out .svn directories from install location
mkdir -p $(DESTDIR)$(NETSURF_GTK_RESOURCES)throbber
mkdir -p $(DESTDIR)$(NETSURF_GTK_BIN)
@cp nsgtk $(DESTDIR)$(NETSURF_GTK_BIN)netsurf
@@ -837,15 +838,23 @@
@cp -RL gtk/res/netsurf-16x16.xpm $(DESTDIR)$(NETSURF_GTK_RESOURCES)
@cp -RL gtk/res/quirks.css $(DESTDIR)$(NETSURF_GTK_RESOURCES)
@cp -RL gtk/res/themelist $(DESTDIR)$(NETSURF_GTK_RESOURCES)
- @cp -RL gtk/res/throbber/*.png $(DESTDIR)$(NETSURF_GTK_RESOURCES)/throbber
+ @cp -RL gtk/res/throbber/*.png $(DESTDIR)$(NETSURF_GTK_RESOURCES)throbber
@cp -RL gtk/res/toolbarIndices $(DESTDIR)$(NETSURF_GTK_RESOURCES)
@cp -RL gtk/res/Aliases $(DESTDIR)$(NETSURF_GTK_RESOURCES)
- @cp -RL gtk/res/docs $(DESTDIR)/$(NETSURF_GTK_RESOURCES)
- @cp -RL gtk/res/SearchEngines $(DESTDIR)$(NETSURF_GTK_RESOURCES)SearchEngines
+ @cp -RL gtk/res/SearchEngines $(DESTDIR)$(NETSURF_GTK_RESOURCES)
+ @cp -RL gtk/res/docs $(DESTDIR)$(NETSURF_GTK_RESOURCES)
+ @cp -RL gtk/res/themes $(DESTDIR)$(NETSURF_GTK_RESOURCES)
+ @# Install translations
+ @cp -RL gtk/res/C $(DESTDIR)$(NETSURF_GTK_RESOURCES)
+ @cp -RL gtk/res/de $(DESTDIR)$(NETSURF_GTK_RESOURCES)
+ @cp -RL gtk/res/en $(DESTDIR)$(NETSURF_GTK_RESOURCES)
+ @cp -RL gtk/res/fr $(DESTDIR)$(NETSURF_GTK_RESOURCES)
+ @cp -RL gtk/res/it $(DESTDIR)$(NETSURF_GTK_RESOURCES)
+ @cp -RL gtk/res/nl $(DESTDIR)$(NETSURF_GTK_RESOURCES)
+ @# Install glade templates
gzip -9v < gtk/res/downloads.glade > $(DESTDIR)$(NETSURF_GTK_RESOURCES)downloads.glade
gzip -9v < gtk/res/history.glade > $(DESTDIR)$(NETSURF_GTK_RESOURCES)history.glade
gzip -9v < gtk/res/login.glade > $(DESTDIR)$(NETSURF_GTK_RESOURCES)login.glade
- gzip -9v < gtk/res/messages > $(DESTDIR)$(NETSURF_GTK_RESOURCES)messages
gzip -9v < gtk/res/netsurf.glade > $(DESTDIR)$(NETSURF_GTK_RESOURCES)netsurf.glade
gzip -9v < gtk/res/options.glade > $(DESTDIR)$(NETSURF_GTK_RESOURCES)options.glade
gzip -9v < gtk/res/password.glade > $(DESTDIR)$(NETSURF_GTK_RESOURCES)password.glade
12 years, 9 months
r10715 tlsa - in /trunk/netsurf: Makefile.sources content/dirlist.c content/dirlist.h render/directory.c
by netsurf@semichrome.net
Author: tlsa
Date: Thu Aug 26 12:29:02 2010
New Revision: 10715
URL: http://source.netsurf-browser.org?rev=10715&view=rev
Log:
Move directory listing HTML generation functions into separate module.
Added:
trunk/netsurf/content/dirlist.c
trunk/netsurf/content/dirlist.h
Modified:
trunk/netsurf/Makefile.sources
trunk/netsurf/render/directory.c
Modified: trunk/netsurf/Makefile.sources
URL: http://source.netsurf-browser.org/trunk/netsurf/Makefile.sources?rev=1071...
==============================================================================
--- trunk/netsurf/Makefile.sources (original)
+++ trunk/netsurf/Makefile.sources Thu Aug 26 12:29:02 2010
@@ -5,7 +5,7 @@
# for each build.
#
-S_CONTENT := content.c fetch.c hlcache.c llcache.c urldb.c \
+S_CONTENT := content.c dirlist.c fetch.c hlcache.c llcache.c urldb.c \
fetchers/fetch_curl.c fetchers/fetch_data.c
S_CSS := css.c dump.c internal.c select.c utils.c
S_RENDER := box.c box_construct.c box_normalise.c directory.c favicon.c \
Added: trunk/netsurf/content/dirlist.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/dirlist.c?rev=107...
==============================================================================
--- trunk/netsurf/content/dirlist.c (added)
+++ trunk/netsurf/content/dirlist.c Thu Aug 26 12:29:02 2010
@@ -1,0 +1,378 @@
+/*
+ * Copyright 2010 Michael Drake <tlsa(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Generate HTML content for displaying directory listings (implementation).
+ */
+
+#include <stdbool.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "content/dirlist.h"
+#include "utils/messages.h"
+
+static const char footer[] = "</div>\n</body>\n</html>\n";
+
+static int dirlist_filesize_calculate(unsigned long *bytesize);
+static int dirlist_filesize_value(unsigned long bytesize);
+static char* dirlist_filesize_unit(unsigned long bytesize);
+
+
+/**
+ * Generates the top part of an HTML directory listing page
+ *
+ * \return Top of directory listing HTML
+ *
+ * This is part of a series of functions. To generate a complete page,
+ * call the following functions in order:
+ *
+ * dirlist_generate_top()
+ * dirlist_generate_hide_columns() -- optional
+ * dirlist_generate_title()
+ * dirlist_generate_parent_link() -- optional
+ * dirlist_generate_headings()
+ * dirlist_generate_row() -- call 'n' times for 'n' rows
+ * dirlist_generate_bottom()
+ */
+
+const char* dirlist_generate_top(void)
+{
+ return "<html>\n"
+ "<head>\n"
+ "<style>\n"
+ "html, body { margin: 0; padding: 0; }\n"
+ "body { background-color: #abf; }\n"
+ "h1 { padding: 5mm; margin: 0; "
+ "border-bottom: 2px solid #bcf; }\n"
+ "p { padding: 2px 5mm; margin: 0; }\n"
+ "div { display: table; width: 94%; margin: 5mm auto 0 auto; "
+ "padding: 0; }\n"
+ "a, strong { display: table-row; margin: 0; padding: 0; }\n"
+ "a.odd { background-color: #bcf; }\n"
+ "a.even { background-color: #b2c3ff; }\n"
+ "span { display: table-cell; }\n"
+ "em > span { padding-bottom: 1px; }\n"
+ "a + a>span { border-top: 1px solid #9af; }\n"
+ "span.name { padding-left: 22px; min-height: 19px;}\n"
+ "a.dir > span.name { font-weight: bold; }\n"
+ "a.dir > span.type { font-weight: bold; }\n"
+ "span.size { text-align: right; padding-right: 0.3em; }\n"
+ "span.size + span.size { text-align: left; "
+ "padding-right: 0; }\n";
+}
+
+
+/**
+ * Generates the part of an HTML directory listing page that can suppress
+ * particular columns
+ *
+ * \param flags flags for which cols to suppress. 0 to suppress none
+ * \param buffer buffer to fill with generated HTML
+ * \param buffer_length maximum size of buffer
+ * \return true iff buffer filled without error
+ *
+ * This is part of a series of functions. To generate a complete page,
+ * call the following functions in order:
+ *
+ * dirlist_generate_top()
+ * dirlist_generate_hide_columns() -- optional
+ * dirlist_generate_title()
+ * dirlist_generate_parent_link() -- optional
+ * dirlist_generate_headings()
+ * dirlist_generate_row() -- call 'n' times for 'n' rows
+ * dirlist_generate_bottom()
+ */
+
+bool dirlist_generate_hide_columns(int flags, char *buffer, int buffer_length)
+{
+ int error = snprintf(buffer, buffer_length,
+ "%s\n%s\n%s\n%s\n%s\n",
+ (flags & DIRLIST_NO_NAME_COLUMN) ?
+ "span.name { display: none; }\n" : "",
+ (flags & DIRLIST_NO_TYPE_COLUMN) ?
+ "span.type { display: none; }\n" : "",
+ (flags & DIRLIST_NO_SIZE_COLUMN) ?
+ "span.size { display: none; }\n" : "",
+ (flags & DIRLIST_NO_DATE_COLUMN) ?
+ "span.date { display: none; }\n" : "",
+ (flags & DIRLIST_NO_TIME_COLUMN) ?
+ "span.time { display: none; }\n" : "");
+ if (error < 0 || error >= buffer_length)
+ /* Error or buffer too small */
+ return false;
+ else
+ /* OK */
+ return true;
+}
+
+
+/**
+ * Generates the part of an HTML directory listing page that contains the title
+ *
+ * \param title title to use
+ * \param buffer buffer to fill with generated HTML
+ * \param buffer_length maximum size of buffer
+ * \return true iff buffer filled without error
+ *
+ * This is part of a series of functions. To generate a complete page,
+ * call the following functions in order:
+ *
+ * dirlist_generate_top()
+ * dirlist_generate_hide_columns() -- optional
+ * dirlist_generate_title()
+ * dirlist_generate_parent_link() -- optional
+ * dirlist_generate_headings()
+ * dirlist_generate_row() -- call 'n' times for 'n' rows
+ * dirlist_generate_bottom()
+ */
+
+bool dirlist_generate_title(char *title, char *buffer, int buffer_length)
+{
+ int error = snprintf(buffer, buffer_length,
+ "</style>\n"
+ "<title>%s</title>\n"
+ "</head>\n"
+ "<body>\n"
+ "<h1>%s</h1>\n",
+ title, title);
+ if (error < 0 || error >= buffer_length)
+ /* Error or buffer too small */
+ return false;
+ else
+ /* OK */
+ return true;
+}
+
+
+/**
+ * Generates the part of an HTML directory listing page that links to the parent
+ * directory
+ *
+ * \param parent url of parent directory
+ * \param buffer buffer to fill with generated HTML
+ * \param buffer_length maximum size of buffer
+ * \return true iff buffer filled without error
+ *
+ * This is part of a series of functions. To generate a complete page,
+ * call the following functions in order:
+ *
+ * dirlist_generate_top()
+ * dirlist_generate_hide_columns() -- optional
+ * dirlist_generate_title()
+ * dirlist_generate_parent_link() -- optional
+ * dirlist_generate_headings()
+ * dirlist_generate_row() -- call 'n' times for 'n' rows
+ * dirlist_generate_bottom()
+ */
+
+bool dirlist_generate_parent_link(char *parent, char *buffer, int buffer_length)
+{
+ int error = snprintf(buffer, buffer_length,
+ "<p><a href=\"%s\">%s</a></p>",
+ parent, messages_get("FileParent"));
+ if (error < 0 || error >= buffer_length)
+ /* Error or buffer too small */
+ return false;
+ else
+ /* OK */
+ return true;
+}
+
+
+/**
+ * Generates the part of an HTML directory listing page that displays the column
+ * headings
+ *
+ * \param buffer buffer to fill with generated HTML
+ * \param buffer_length maximum size of buffer
+ * \return true iff buffer filled without error
+ *
+ * This is part of a series of functions. To generate a complete page,
+ * call the following functions in order:
+ *
+ * dirlist_generate_top()
+ * dirlist_generate_hide_columns() -- optional
+ * dirlist_generate_title()
+ * dirlist_generate_parent_link() -- optional
+ * dirlist_generate_headings()
+ * dirlist_generate_row() -- call 'n' times for 'n' rows
+ * dirlist_generate_bottom()
+ */
+
+bool dirlist_generate_headings(char *buffer, int buffer_length)
+{
+ int error = snprintf(buffer, buffer_length,
+ "<div>\n<strong>"
+ "<span class=\"name\">%s</span> "
+ "<span class=\"type\">%s</span> "
+ "<span class=\"size\">%s</span>"
+ "<span class=\"size\"></span> "
+ "<span class=\"date\">%s</span> "
+ "<span class=\"time\">%s</span></strong>\n",
+ messages_get("FileName"), messages_get("FileType"),
+ messages_get("FileSize"), messages_get("FileDate"),
+ messages_get("FileTime"));
+ if (error < 0 || error >= buffer_length)
+ /* Error or buffer too small */
+ return false;
+ else
+ /* OK */
+ return true;
+}
+
+
+/**
+ * Generates the part of an HTML directory listing page that displays a row
+ * in the directory contents table
+ *
+ * \param even evenness of row number, for alternate row colouring
+ * \param directory whether this row is for a directory (or a file)
+ * \param url url for row entry
+ * \param name name of row entry
+ * \param type MIME type of row entry
+ * \param size size of row entry. If negative, size is left blank
+ * \param date date row entry was last modified
+ * \param time time row entry was last modified
+ * \param buffer buffer to fill with generated HTML
+ * \param buffer_length maximum size of buffer
+ * \return true iff buffer filled without error
+ *
+ * This is part of a series of functions. To generate a complete page,
+ * call the following functions in order:
+ *
+ * dirlist_generate_top()
+ * dirlist_generate_hide_columns() -- optional
+ * dirlist_generate_title()
+ * dirlist_generate_parent_link() -- optional
+ * dirlist_generate_headings()
+ * dirlist_generate_row() -- call 'n' times for 'n' rows
+ * dirlist_generate_bottom()
+ */
+
+bool dirlist_generate_row(bool even, bool directory, char *url, char *name,
+ char *type, long long size, char *date, char *time,
+ char *buffer, int buffer_length)
+{
+ const char *unit;
+ char size_string[100];
+ int error;
+
+ if (size < 0) {
+ unit = "";
+ strncpy(size_string, "", sizeof size_string);
+ } else {
+ unit = messages_get(dirlist_filesize_unit((unsigned long)size));
+ snprintf(size_string, sizeof size_string, "%d",
+ dirlist_filesize_value((unsigned long)size));
+ }
+
+ error = snprintf(buffer, buffer_length,
+ "<a href=\"%s\" class=\"%s %s\">"
+ "<span class=\"name\">%s</span> "
+ "<span class=\"type\">%s</span> "
+ "<span class=\"size\">%s</span>"
+ "<span class=\"size\">%s</span> "
+ "<span class=\"date\">%s</span> "
+ "<span class=\"time\">%s</span></a>\n",
+ url, even ? "even" : "odd",
+ directory ? "dir" : "file",
+ name, type, size_string, unit, date, time);
+ if (error < 0 || error >= buffer_length)
+ /* Error or buffer too small */
+ return false;
+ else
+ /* OK */
+ return true;
+}
+
+
+/**
+ * Generates the bottom part of an HTML directory listing page
+ *
+ * \return Bottom of directory listing HTML
+ *
+ * This is part of a series of functions. To generate a complete page,
+ * call the following functions in order:
+ *
+ * dirlist_generate_top()
+ * dirlist_generate_hide_columns() -- optional
+ * dirlist_generate_title()
+ * dirlist_generate_parent_link() -- optional
+ * dirlist_generate_headings()
+ * dirlist_generate_row() -- call 'n' times for 'n' rows
+ * dirlist_generate_bottom()
+ */
+
+const char* dirlist_generate_bottom(void)
+{
+ return "</div>\n"
+ "</body>\n"
+ "</html>\n";
+}
+
+
+/**
+ * Obtain display value and units for filesize after conversion to B/kB/MB/GB,
+ * as appropriate.
+ *
+ * \param bytesize file size in bytes, updated to filesize in output units
+ * \return number of times bytesize has been divided by 1024
+ */
+
+int dirlist_filesize_calculate(unsigned long *bytesize)
+{
+ int i = 0;
+ while (*bytesize > 1024 * 4) {
+ *bytesize /= 1024;
+ i++;
+ if (i == 3)
+ break;
+ }
+ return i;
+}
+
+
+/**
+ * Obtain display value for filesize after conversion to B/kB/MB/GB,
+ * as appropriate
+ *
+ * \param bytesize file size in bytes
+ * \return Value to display for file size, in units given by filesize_unit()
+ */
+
+int dirlist_filesize_value(unsigned long bytesize)
+{
+ dirlist_filesize_calculate(&bytesize);
+ return (int)bytesize;
+}
+
+
+/**
+ * Obtain display units for filesize after conversion to B/kB/MB/GB,
+ * as appropriate
+ *
+ * \param bytesize file size in bytes
+ * \return Units to display for file size, for value given by filesize_value()
+ */
+
+char* dirlist_filesize_unit(unsigned long bytesize)
+{
+ const char* units[] = { "Bytes", "kBytes", "MBytes", "GBytes" };
+ return (char*)units[dirlist_filesize_calculate(&bytesize)];
+}
Added: trunk/netsurf/content/dirlist.h
URL: http://source.netsurf-browser.org/trunk/netsurf/content/dirlist.h?rev=107...
==============================================================================
--- trunk/netsurf/content/dirlist.h (added)
+++ trunk/netsurf/content/dirlist.h Thu Aug 26 12:29:02 2010
@@ -1,0 +1,47 @@
+/*
+ * Copyright 2010 Michael Drake <tlsa(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \file
+ * Generate HTML content for displaying directory listings (interface).
+ *
+ * These functions should in general be called via the content interface.
+ */
+
+#ifndef _NETSURF_CONTENT_DIRLIST_H_
+#define _NETSURF_CONTENT_DIRLIST_H_
+
+#include <stdbool.h>
+
+#define DIRLIST_NO_NAME_COLUMN 1
+#define DIRLIST_NO_TYPE_COLUMN 1 << 1
+#define DIRLIST_NO_SIZE_COLUMN 1 << 2
+#define DIRLIST_NO_DATE_COLUMN 1 << 3
+#define DIRLIST_NO_TIME_COLUMN 1 << 4
+
+const char* dirlist_generate_top(void);
+bool dirlist_generate_hide_columns(int flags, char *buffer, int buffer_length);
+bool dirlist_generate_title(char *title, char *buffer, int buffer_length);
+bool dirlist_generate_parent_link(char *parent, char *buffer,
+ int buffer_length);
+bool dirlist_generate_headings(char *buffer, int buffer_length);
+bool dirlist_generate_row(bool even, bool directory, char *url, char *name,
+ char *type, long long size, char *date, char *time,
+ char *buffer, int buffer_length);
+const char* dirlist_generate_bottom(void);
+
+#endif
Modified: trunk/netsurf/render/directory.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/directory.c?rev=10...
==============================================================================
--- trunk/netsurf/render/directory.c (original)
+++ trunk/netsurf/render/directory.c Thu Aug 26 12:29:02 2010
@@ -31,6 +31,7 @@
#include <sys/stat.h>
#include <time.h>
#include "content/content_protected.h"
+#include "content/dirlist.h"
#include "content/fetch.h"
#include "render/directory.h"
#include "render/html.h"
@@ -39,376 +40,6 @@
#include "utils/utils.h"
#define MAX_LENGTH 2048
-
-#define NO_NAME_COLUMN 1
-#define NO_TYPE_COLUMN 1 << 1
-#define NO_SIZE_COLUMN 1 << 2
-#define NO_DATE_COLUMN 1 << 3
-#define NO_TIME_COLUMN 1 << 4
-
-static const char footer[] = "</div>\n</body>\n</html>\n";
-
-static const char* dirlist_generate_top(void);
-static bool dirlist_generate_hide_columns(int flags, char *buffer,
- int buffer_length);
-static bool dirlist_generate_title(char *title, char *buffer,
- int buffer_length);
-static bool dirlist_generate_parent_link(char *parent, char *buffer,
- int buffer_length);
-static bool dirlist_generate_headings(char *buffer, int buffer_length);
-static bool dirlist_generate_row(bool even, bool directory, char *url,
- char *name, char *type, long long size, char *date,
- char *time, char *buffer, int buffer_length);
-static const char* dirlist_generate_bottom(void);
-
-static int dirlist_filesize_calculate(unsigned long *bytesize);
-static int dirlist_filesize_value(unsigned long bytesize);
-static char* dirlist_filesize_unit(unsigned long bytesize);
-
-
-/**
- * Generates the top part of an HTML directroy listing page
- *
- * \return Top of directory listing HTML
- *
- * This is part of a series of functions. To generate a complete page,
- * call the following functions in order:
- *
- * dirlist_generate_top()
- * dirlist_generate_hide_columns() -- optional
- * dirlist_generate_title()
- * dirlist_generate_parent_link() -- optional
- * dirlist_generate_headings()
- * dirlist_generate_row() -- call 'n' times for 'n' rows
- * dirlist_generate_bottom()
- */
-
-const char* dirlist_generate_top(void)
-{
- return "<html>\n"
- "<head>\n"
- "<style>\n"
- "html, body { margin: 0; padding: 0; }\n"
- "body { background-color: #abf; }\n"
- "h1 { padding: 5mm; margin: 0; "
- "border-bottom: 2px solid #bcf; }\n"
- "p { padding: 2px 5mm; margin: 0; }\n"
- "div { display: table; width: 94%; margin: 5mm auto 0 auto; "
- "padding: 0; }\n"
- "a, strong { display: table-row; margin: 0; padding: 0; }\n"
- "a.odd { background-color: #bcf; }\n"
- "a.even { background-color: #b2c3ff; }\n"
- "span { display: table-cell; }\n"
- "em > span { padding-bottom: 1px; }\n"
- "a + a>span { border-top: 1px solid #9af; }\n"
- "span.name { padding-left: 22px; min-height: 19px;}\n"
- "a.dir > span.name { font-weight: bold; }\n"
- "a.dir > span.type { font-weight: bold; }\n"
- "span.size { text-align: right; padding-right: 0.3em; }\n"
- "span.size + span.size { text-align: left; "
- "padding-right: 0; }\n";
-}
-
-
-/**
- * Generates the part of an HTML directory listing page that can suppress
- * particular columns
- *
- * \param flags flags for which cols to suppress. 0 to suppress none
- * \param buffer buffer to fill with generated HTML
- * \param buffer_length maximum size of buffer
- * \return true iff buffer filled without error
- *
- * This is part of a series of functions. To generate a complete page,
- * call the following functions in order:
- *
- * dirlist_generate_top()
- * dirlist_generate_hide_columns() -- optional
- * dirlist_generate_title()
- * dirlist_generate_parent_link() -- optional
- * dirlist_generate_headings()
- * dirlist_generate_row() -- call 'n' times for 'n' rows
- * dirlist_generate_bottom()
- */
-
-bool dirlist_generate_hide_columns(int flags, char *buffer, int buffer_length)
-{
- int error = snprintf(buffer, buffer_length,
- "%s\n%s\n%s\n%s\n%s\n",
- (flags & NO_NAME_COLUMN) ?
- "span.name { display: none; }\n" : "",
- (flags & NO_TYPE_COLUMN) ?
- "span.type { display: none; }\n" : "",
- (flags & NO_SIZE_COLUMN) ?
- "span.size { display: none; }\n" : "",
- (flags & NO_DATE_COLUMN) ?
- "span.date { display: none; }\n" : "",
- (flags & NO_TIME_COLUMN) ?
- "span.time { display: none; }\n" : "");
- if (error < 0 || error >= buffer_length)
- /* Error or buffer too small */
- return false;
- else
- /* OK */
- return true;
-}
-
-
-/**
- * Generates the part of an HTML directory listing page that contains the title
- *
- * \param title title to use
- * \param buffer buffer to fill with generated HTML
- * \param buffer_length maximum size of buffer
- * \return true iff buffer filled without error
- *
- * This is part of a series of functions. To generate a complete page,
- * call the following functions in order:
- *
- * dirlist_generate_top()
- * dirlist_generate_hide_columns() -- optional
- * dirlist_generate_title()
- * dirlist_generate_parent_link() -- optional
- * dirlist_generate_headings()
- * dirlist_generate_row() -- call 'n' times for 'n' rows
- * dirlist_generate_bottom()
- */
-
-bool dirlist_generate_title(char *title, char *buffer, int buffer_length)
-{
- int error = snprintf(buffer, buffer_length,
- "</style>\n"
- "<title>%s</title>\n"
- "</head>\n"
- "<body>\n"
- "<h1>%s</h1>\n",
- title, title);
- if (error < 0 || error >= buffer_length)
- /* Error or buffer too small */
- return false;
- else
- /* OK */
- return true;
-}
-
-
-/**
- * Generates the part of an HTML directory listing page that links to the parent
- * directory
- *
- * \param parent url of parent directory
- * \param buffer buffer to fill with generated HTML
- * \param buffer_length maximum size of buffer
- * \return true iff buffer filled without error
- *
- * This is part of a series of functions. To generate a complete page,
- * call the following functions in order:
- *
- * dirlist_generate_top()
- * dirlist_generate_hide_columns() -- optional
- * dirlist_generate_title()
- * dirlist_generate_parent_link() -- optional
- * dirlist_generate_headings()
- * dirlist_generate_row() -- call 'n' times for 'n' rows
- * dirlist_generate_bottom()
- */
-
-bool dirlist_generate_parent_link(char *parent, char *buffer, int buffer_length)
-{
- int error = snprintf(buffer, buffer_length,
- "<p><a href=\"%s\">%s</a></p>",
- parent, messages_get("FileParent"));
- if (error < 0 || error >= buffer_length)
- /* Error or buffer too small */
- return false;
- else
- /* OK */
- return true;
-}
-
-
-/**
- * Generates the part of an HTML directory listing page that displays the column
- * headings
- *
- * \param buffer buffer to fill with generated HTML
- * \param buffer_length maximum size of buffer
- * \return true iff buffer filled without error
- *
- * This is part of a series of functions. To generate a complete page,
- * call the following functions in order:
- *
- * dirlist_generate_top()
- * dirlist_generate_hide_columns() -- optional
- * dirlist_generate_title()
- * dirlist_generate_parent_link() -- optional
- * dirlist_generate_headings()
- * dirlist_generate_row() -- call 'n' times for 'n' rows
- * dirlist_generate_bottom()
- */
-
-bool dirlist_generate_headings(char *buffer, int buffer_length)
-{
- int error = snprintf(buffer, buffer_length,
- "<div>\n<strong>"
- "<span class=\"name\">%s</span> "
- "<span class=\"type\">%s</span> "
- "<span class=\"size\">%s</span>"
- "<span class=\"size\"></span> "
- "<span class=\"date\">%s</span> "
- "<span class=\"time\">%s</span></strong>\n",
- messages_get("FileName"), messages_get("FileType"),
- messages_get("FileSize"), messages_get("FileDate"),
- messages_get("FileTime"));
- if (error < 0 || error >= buffer_length)
- /* Error or buffer too small */
- return false;
- else
- /* OK */
- return true;
-}
-
-
-/**
- * Generates the part of an HTML directory listing page that displays a row
- * in the directory contents table
- *
- * \param even evenness of row number, for alternate row colouring
- * \param directory whether this row is for a directory (or a file)
- * \param url url for row entry
- * \param name name of row entry
- * \param type MIME type of row entry
- * \param size size of row entry. If negative, size is left blank
- * \param date date row entry was last modified
- * \param time time row entry was last modified
- * \param buffer buffer to fill with generated HTML
- * \param buffer_length maximum size of buffer
- * \return true iff buffer filled without error
- *
- * This is part of a series of functions. To generate a complete page,
- * call the following functions in order:
- *
- * dirlist_generate_top()
- * dirlist_generate_hide_columns() -- optional
- * dirlist_generate_title()
- * dirlist_generate_parent_link() -- optional
- * dirlist_generate_headings()
- * dirlist_generate_row() -- call 'n' times for 'n' rows
- * dirlist_generate_bottom()
- */
-
-bool dirlist_generate_row(bool even, bool directory, char *url, char *name,
- char *type, long long size, char *date, char *time,
- char *buffer, int buffer_length)
-{
- const char *unit;
- char size_string[100];
- int error;
-
- if (size < 0) {
- unit = "";
- strncpy(size_string, "", sizeof size_string);
- } else {
- unit = messages_get(dirlist_filesize_unit((unsigned long)size));
- snprintf(size_string, sizeof size_string, "%d",
- dirlist_filesize_value((unsigned long)size));
- }
-
- error = snprintf(buffer, buffer_length,
- "<a href=\"%s\" class=\"%s %s\">"
- "<span class=\"name\">%s</span> "
- "<span class=\"type\">%s</span> "
- "<span class=\"size\">%s</span>"
- "<span class=\"size\">%s</span> "
- "<span class=\"date\">%s</span> "
- "<span class=\"time\">%s</span></a>\n",
- url, even ? "even" : "odd",
- directory ? "dir" : "file",
- name, type, size_string, unit, date, time);
- if (error < 0 || error >= buffer_length)
- /* Error or buffer too small */
- return false;
- else
- /* OK */
- return true;
-}
-
-
-/**
- * Generates the bottom part of an HTML directroy listing page
- *
- * \return Bottom of directory listing HTML
- *
- * This is part of a series of functions. To generate a complete page,
- * call the following functions in order:
- *
- * dirlist_generate_top()
- * dirlist_generate_hide_columns() -- optional
- * dirlist_generate_title()
- * dirlist_generate_parent_link() -- optional
- * dirlist_generate_headings()
- * dirlist_generate_row() -- call 'n' times for 'n' rows
- * dirlist_generate_bottom()
- */
-
-const char* dirlist_generate_bottom(void)
-{
- return "</div>\n"
- "</body>\n"
- "</html>\n";
-}
-
-
-/**
- * Obtain display value and units for filesize after conversion to B/kB/MB/GB,
- * as appropriate.
- *
- * \param bytesize file size in bytes, updated to filesize in output units
- * \return number of times bytesize has been divided by 1024
- */
-
-int dirlist_filesize_calculate(unsigned long *bytesize)
-{
- int i = 0;
- while (*bytesize > 1024 * 4) {
- *bytesize /= 1024;
- i++;
- if (i == 3)
- break;
- }
- return i;
-}
-
-
-/**
- * Obtain display value for filesize after conversion to B/kB/MB/GB,
- * as appropriate
- *
- * \param bytesize file size in bytes
- * \return Value to display for file size, in units given by filesize_unit()
- */
-
-int dirlist_filesize_value(unsigned long bytesize)
-{
- dirlist_filesize_calculate(&bytesize);
- return (int)bytesize;
-}
-
-
-/**
- * Obtain display units for filesize after conversion to B/kB/MB/GB,
- * as appropriate
- *
- * \param bytesize file size in bytes
- * \return Units to display for file size, for value given by filesize_value()
- */
-
-char* dirlist_filesize_unit(unsigned long bytesize)
-{
- const char* units[] = { "Bytes", "kBytes", "MBytes", "GBytes" };
- return (char*)units[dirlist_filesize_calculate(&bytesize)];
-}
-
bool directory_create(struct content *c, const struct http_parameter *params) {
if (!html_create(c, params))
12 years, 9 months
r10713 tlsa - /trunk/netsurf/render/html_redraw.c
by netsurf@semichrome.net
Author: tlsa
Date: Thu Aug 26 07:30:22 2010
New Revision: 10713
URL: http://source.netsurf-browser.org?rev=10713&view=rev
Log:
+ Don't even consider top and bottom borders when they
fall outside the clip rect. Should make scrolling up
and down slightly faster.
+ Clip borders plotted as rectangles to the current clip
rectangle. Fixes redraw issue with very tall borders.
Modified:
trunk/netsurf/render/html_redraw.c
Modified: trunk/netsurf/render/html_redraw.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html_redraw.c?rev=...
==============================================================================
--- trunk/netsurf/render/html_redraw.c (original)
+++ trunk/netsurf/render/html_redraw.c Thu Aug 26 07:30:22 2010
@@ -65,11 +65,12 @@
static bool html_redraw_caret(struct caret *caret,
colour current_background_color, float scale);
static bool html_redraw_borders(struct box *box, int x_parent, int y_parent,
- int p_width, int p_height, float scale);
-static bool html_redraw_inline_borders(struct box *box, int x0, int y0,
- int x1, int y1, float scale, bool first, bool last);
+ int p_width, int p_height, struct rect clip, float scale);
+static bool html_redraw_inline_borders(struct box *box, struct rect b,
+ struct rect clip, float scale, bool first, bool last);
static bool html_redraw_border_plot(const int side, const int *p, colour c,
- enum css_border_style_e style, int thickness, bool rectangular);
+ enum css_border_style_e style, int thickness, bool rectangular,
+ struct rect clip);
static bool html_redraw_checkbox(int x, int y, int width, int height,
bool selected);
static bool html_redraw_radio(int x, int y, int width, int height,
@@ -80,8 +81,7 @@
struct rect clip, colour *background_colour,
struct box *background);
static bool html_redraw_inline_background(int x, int y, struct box *box,
- float scale, struct rect clip,
- int px0, int py0, int px1, int py1,
+ float scale, struct rect clip, struct rect b,
bool first, bool last, colour *background_colour);
static bool html_redraw_text_decoration(struct box *box,
int x_parent, int y_parent, float scale,
@@ -481,11 +481,12 @@
box->type != BOX_INLINE_END &&
(box->type != BOX_INLINE || box->object) &&
(border_top || border_right ||
- border_bottom || border_left))
+ border_bottom || border_left)) {
if (!html_redraw_borders(box, x_parent, y_parent,
- padding_width, padding_height,
+ padding_width, padding_height, r,
scale))
return false;
+ }
/* backgrounds and borders for non-replaced inlines */
if (box->style && box->type == BOX_INLINE && box->inline_end &&
@@ -496,20 +497,23 @@
/* inline backgrounds and borders span other boxes and may
* wrap onto separate lines */
struct box *ib;
- struct rect p;
+ struct rect b; /* border edge rectangle */
+ struct rect p; /* clipped rect */
bool first = true;
int ib_x;
int ib_y = y;
int ib_p_width;
int ib_b_left, ib_b_right;
- int xmin = x - border_left;
- int xmax = x + padding_width + border_right;
- int ymin = y - border_top;
- int ymax = y + padding_height + border_bottom;
- p.x0 = xmin < r.x0 ? r.x0 : xmin;
- p.x1 = xmax < r.x1 ? xmax : r.x1;
- p.y0 = ymin < r.y0 ? r.y0 : ymin;
- p.y1 = ymax < r.y1 ? ymax : r.y1;
+
+ b.x0 = x - border_left;
+ b.x1 = x + padding_width + border_right;
+ b.y0 = y - border_top;
+ b.y1 = y + padding_height + border_bottom;
+
+ p.x0 = b.x0 < r.x0 ? r.x0 : b.x0;
+ p.x1 = b.x1 < r.x1 ? b.x1 : r.x1;
+ p.y0 = b.y0 < r.y0 ? r.y0 : b.y0;
+ p.y1 = b.y1 < r.y1 ? b.y1 : r.y1;
for (ib = box; ib; ib = ib->next) {
/* to get extents of rectangle(s) associated with
* inline, cycle though all boxes in inline, skipping
@@ -537,34 +541,32 @@
/* inline element has wrapped, plot background
* and borders */
if (!html_redraw_inline_background(
- x, y, box, scale, p,
- xmin, ymin, xmax, ymax,
+ x, y, box, scale, p, b,
first, false,
¤t_background_color))
return false;
/* restore previous graphics window */
if (!plot.clip(r.x0, r.y0, r.x1, r.y1))
return false;
- if (!html_redraw_inline_borders(box,
- xmin, ymin, xmax, ymax,
+ if (!html_redraw_inline_borders(box, b, r,
scale, first, false))
return false;
/* reset coords */
- xmin = ib_x - ib_b_left;
- ymin = ib_y - border_top - padding_top;
- ymax = ib_y + padding_height - padding_top +
+ b.x0 = ib_x - ib_b_left;
+ b.y0 = ib_y - border_top - padding_top;
+ b.y1 = ib_y + padding_height - padding_top +
border_bottom;
- p.x0 = xmin < r.x0 ? r.x0 : xmin;
- p.y0 = ymin < r.y0 ? r.y0 : ymin;
- p.y1 = ymax < r.y1 ? ymax : r.y1;
+ p.x0 = b.x0 < r.x0 ? r.x0 : b.x0;
+ p.y0 = b.y0 < r.y0 ? r.y0 : b.y0;
+ p.y1 = b.y1 < r.y1 ? b.y1 : r.y1;
first = false;
}
/* increase width for current box */
- xmax = ib_x + ib_p_width + ib_b_right;
- p.x1 = xmax < r.x1 ? xmax : r.x1;
+ b.x1 = ib_x + ib_p_width + ib_b_right;
+ p.x1 = b.x1 < r.x1 ? b.x1 : r.x1;
if (ib == box->inline_end)
/* reached end of BOX_INLINE span */
@@ -572,15 +574,13 @@
}
/* plot background and borders for last rectangle of
* the inline */
- if (!html_redraw_inline_background(x, ib_y, box, scale, p,
- xmin, ymin, xmax, ymax, first, true,
- ¤t_background_color))
+ if (!html_redraw_inline_background(x, ib_y, box, scale, p, b,
+ first, true, ¤t_background_color))
return false;
/* restore previous graphics window */
if (!plot.clip(r.x0, r.y0, r.x1, r.y1))
return false;
- if (!html_redraw_inline_borders(box, xmin, ymin, xmax, ymax,
- scale, first, true))
+ if (!html_redraw_inline_borders(box, b, r, scale, first, true))
return false;
}
@@ -1037,7 +1037,7 @@
*/
bool html_redraw_borders(struct box *box, int x_parent, int y_parent,
- int p_width, int p_height, float scale)
+ int p_width, int p_height, struct rect clip, float scale)
{
unsigned int sides[] = { LEFT, RIGHT, TOP, BOTTOM };
int top = box->border[TOP].width;
@@ -1116,6 +1116,14 @@
z[3] += bottom;
square_end_2 = true;
}
+
+ col = nscss_color_to_ns(box->border[side].c);
+
+ if (!html_redraw_border_plot(side, z, col,
+ box->border[side].style,
+ box->border[side].width * scale,
+ square_end_1 && square_end_2, clip))
+ return false;
break;
case RIGHT:
square_end_1 = (top == 0);
@@ -1144,8 +1152,21 @@
z[5] += bottom;
square_end_2 = true;
}
+
+ col = nscss_color_to_ns(box->border[side].c);
+
+ if (!html_redraw_border_plot(side, z, col,
+ box->border[side].style,
+ box->border[side].width * scale,
+ square_end_1 && square_end_2, clip))
+ return false;
break;
case TOP:
+ if (clip.y0 > p[3])
+ /* clip rectangle is below border; nothing to
+ * plot */
+ continue;
+
square_end_1 = (left == 0);
square_end_2 = (right == 0);
@@ -1172,8 +1193,21 @@
z[4] -= right;
square_end_2 = true;
}
+
+ col = nscss_color_to_ns(box->border[side].c);
+
+ if (!html_redraw_border_plot(side, z, col,
+ box->border[side].style,
+ box->border[side].width * scale,
+ square_end_1 && square_end_2, clip))
+ return false;
break;
case BOTTOM:
+ if (clip.y1 < p[5])
+ /* clip rectangle is above border; nothing to
+ * plot */
+ continue;
+
square_end_1 = (left == 0);
square_end_2 = (right == 0);
@@ -1200,20 +1234,20 @@
z[2] -= right;
square_end_2 = true;
}
+
+ col = nscss_color_to_ns(box->border[side].c);
+
+ if (!html_redraw_border_plot(side, z, col,
+ box->border[side].style,
+ box->border[side].width * scale,
+ square_end_1 && square_end_2, clip))
+ return false;
break;
default:
assert(side == TOP || side == BOTTOM ||
side == LEFT || side == RIGHT);
break;
}
-
- col = nscss_color_to_ns(box->border[side].c);
-
- if (!html_redraw_border_plot(side, z, col,
- box->border[side].style,
- box->border[side].width * scale,
- square_end_1 && square_end_2))
- return false;
}
return true;
@@ -1224,18 +1258,15 @@
* Draw an inline's borders.
*
* \param box BOX_INLINE which created the border
- * \param x0 coordinate of border edge rectangle
- * \param y0 coordinate of border edge rectangle
- * \param x1 coordinate of border edge rectangle
- * \param y1 coordinate of border edge rectangle
+ * \param b coordinates of border edge rectangle
* \param scale scale for redraw
* \param first true if this is the first rectangle associated with the inline
* \param last true if this is the last rectangle associated with the inline
* \return true if successful, false otherwise
*/
-bool html_redraw_inline_borders(struct box *box, int x0, int y0, int x1, int y1,
- float scale, bool first, bool last)
+bool html_redraw_inline_borders(struct box *box, struct rect b,
+ struct rect clip, float scale, bool first, bool last)
{
int top = box->border[TOP].width;
int right = box->border[RIGHT].width;
@@ -1264,10 +1295,10 @@
* | / \ |
* +----------------------D
*/
- p[0] = x0; p[1] = y0; /* A */
- p[2] = first ? x0 + left : x0; p[3] = y0 + top; /* B */
- p[4] = last ? x1 - right : x1; p[5] = y1 - bottom; /* C */
- p[6] = x1; p[7] = y1; /* D */
+ p[0] = b.x0; p[1] = b.y0; /* A */
+ p[2] = first ? b.x0 + left : b.x0; p[3] = b.y0 + top; /* B */
+ p[4] = last ? b.x1 - right : b.x1; p[5] = b.y1 - bottom; /* C */
+ p[6] = b.x1; p[7] = b.y1; /* D */
assert(box->style);
@@ -1304,7 +1335,7 @@
if (!html_redraw_border_plot(LEFT, z, col,
box->border[LEFT].style,
- left, square_end_1 && square_end_2))
+ left, square_end_1 && square_end_2, clip))
return false;
}
@@ -1341,7 +1372,7 @@
if (!html_redraw_border_plot(RIGHT, z, col,
box->border[RIGHT].style,
- right, square_end_1 && square_end_2))
+ right, square_end_1 && square_end_2, clip))
return false;
}
@@ -1378,7 +1409,7 @@
if (!html_redraw_border_plot(TOP, z, col,
box->border[TOP].style,
- top, square_end_1 && square_end_2))
+ top, square_end_1 && square_end_2, clip))
return false;
}
@@ -1415,7 +1446,7 @@
if (!html_redraw_border_plot(BOTTOM, z, col,
box->border[BOTTOM].style,
- bottom, square_end_1 && square_end_2))
+ bottom, square_end_1 && square_end_2, clip))
return false;
}
@@ -1454,7 +1485,8 @@
*/
bool html_redraw_border_plot(const int side, const int *p, colour c,
- enum css_border_style_e style, int thickness, bool rectangular)
+ enum css_border_style_e style, int thickness, bool rectangular,
+ struct rect clip)
{
int z[8]; /* Vertices of border part */
unsigned int light = side;
@@ -1502,9 +1534,17 @@
y1 = ((side == LEFT) && (p[1] - p[3] != 0)) ?
y1 + p[1] - p[3] : y1;
}
- if (!plot.rectangle(x0, y0, x1, y1,
- &plot_style_fillbdr))
- return false;
+ /* find intersection of clip rectangle and border */
+ x0 = (clip.x0 > x0) ? clip.x0 : x0;
+ y0 = (clip.y0 > y0) ? clip.y0 : y0;
+ x1 = (clip.x1 < x1) ? clip.x1 : x1;
+ y1 = (clip.y1 < y1) ? clip.y1 : y1;
+ if ((x0 < x1) && (y0 < y1)) {
+ /* valid clip rectangles only */
+ if (!plot.rectangle(x0, y0, x1, y1,
+ &plot_style_fillbdr))
+ return false;
+ }
} else {
if (!plot.polygon(p, 4, &plot_style_fillbdr))
return false;
@@ -1561,9 +1601,17 @@
x0 = p[6]; y0 = p[7];
x1 = (p[0] + p[2]) / 2; y1 = (p[1] + p[3]) / 2;
}
- if (!plot.rectangle(x0, y0, x1, y1,
- plot_style_bdr_in))
- return false;
+ /* find intersection of clip rectangle and border */
+ x0 = (clip.x0 > x0) ? clip.x0 : x0;
+ y0 = (clip.y0 > y0) ? clip.y0 : y0;
+ x1 = (clip.x1 < x1) ? clip.x1 : x1;
+ y1 = (clip.y1 < y1) ? clip.y1 : y1;
+ if ((x0 < x1) && (y0 < y1)) {
+ /* valid clip rectangles only */
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_in))
+ return false;
+ }
/* Second part */
if (side == TOP || side == RIGHT) {
@@ -1573,9 +1621,17 @@
x0 = (p[6] + p[4]) / 2; y0 = (p[7] + p[5]) / 2;
x1 = p[2]; y1 = p[3];
}
- if (!plot.rectangle(x0, y0, x1, y1,
- plot_style_bdr_out))
- return false;
+ /* find intersection of clip rectangle and border */
+ x0 = (clip.x0 > x0) ? clip.x0 : x0;
+ y0 = (clip.y0 > y0) ? clip.y0 : y0;
+ x1 = (clip.x1 < x1) ? clip.x1 : x1;
+ y1 = (clip.y1 < y1) ? clip.y1 : y1;
+ if ((x0 < x1) && (y0 < y1)) {
+ /* valid clip rectangles only */
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_out))
+ return false;
+ }
} else if (thickness == 1) {
/* Border made up from one part which can be plotted
* as a rectangle */
@@ -1585,17 +1641,35 @@
x1 = p[6]; y1 = p[7];
x1 = ((side == TOP) && (p[4] - p[6] != 0)) ?
x1 + p[4] - p[6] : x1;
- if (!plot.rectangle(x0, y0, x1, y1,
- plot_style_bdr_in))
- return false;
+ /* find intersection of clip rectangle and
+ * border */
+ x0 = (clip.x0 > x0) ? clip.x0 : x0;
+ y0 = (clip.y0 > y0) ? clip.y0 : y0;
+ x1 = (clip.x1 < x1) ? clip.x1 : x1;
+ y1 = (clip.y1 < y1) ? clip.y1 : y1;
+ if ((x0 < x1) && (y0 < y1)) {
+ /* valid clip rectangles only */
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_in))
+ return false;
+ }
} else {
x0 = p[6]; y0 = p[7];
x1 = p[2]; y1 = p[3];
y1 = ((side == LEFT) && (p[1] - p[3] != 0)) ?
y1 + p[1] - p[3] : y1;
- if (!plot.rectangle(x0, y0, x1, y1,
- plot_style_bdr_out))
- return false;
+ /* find intersection of clip rectangle and
+ * border */
+ x0 = (clip.x0 > x0) ? clip.x0 : x0;
+ y0 = (clip.y0 > y0) ? clip.y0 : y0;
+ x1 = (clip.x1 < x1) ? clip.x1 : x1;
+ y1 = (clip.y1 < y1) ? clip.y1 : y1;
+ if ((x0 < x1) && (y0 < y1)) {
+ /* valid clip rectangles only */
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_out))
+ return false;
+ }
}
} else {
/* Border made up from two parts and can't be plotted
@@ -1661,9 +1735,17 @@
x0 = p[6]; y0 = p[7];
x1 = (p[0] + p[2]) / 2; y1 = (p[1] + p[3]) / 2;
}
- if (!plot.rectangle(x0, y0, x1, y1,
- plot_style_bdr_in))
- return false;
+ /* find intersection of clip rectangle and border */
+ x0 = (clip.x0 > x0) ? clip.x0 : x0;
+ y0 = (clip.y0 > y0) ? clip.y0 : y0;
+ x1 = (clip.x1 < x1) ? clip.x1 : x1;
+ y1 = (clip.y1 < y1) ? clip.y1 : y1;
+ if ((x0 < x1) && (y0 < y1)) {
+ /* valid clip rectangles only */
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_in))
+ return false;
+ }
/* Second part */
if (side == TOP || side == RIGHT) {
@@ -1673,9 +1755,17 @@
x0 = (p[6] + p[4]) / 2; y0 = (p[7] + p[5]) / 2;
x1 = p[2]; y1 = p[3];
}
- if (!plot.rectangle(x0, y0, x1, y1,
- plot_style_bdr_out))
- return false;
+ /* find intersection of clip rectangle and border */
+ x0 = (clip.x0 > x0) ? clip.x0 : x0;
+ y0 = (clip.y0 > y0) ? clip.y0 : y0;
+ x1 = (clip.x1 < x1) ? clip.x1 : x1;
+ y1 = (clip.y1 < y1) ? clip.y1 : y1;
+ if ((x0 < x1) && (y0 < y1)) {
+ /* valid clip rectangles only */
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_out))
+ return false;
+ }
} else if (thickness == 1) {
/* Border made up from one part which can be plotted
* as a rectangle */
@@ -1685,17 +1775,35 @@
x1 = p[6]; y1 = p[7];
x1 = ((side == TOP) && (p[4] - p[6] != 0)) ?
x1 + p[4] - p[6] : x1;
- if (!plot.rectangle(x0, y0, x1, y1,
- plot_style_bdr_in))
- return false;
+ /* find intersection of clip rectangle and
+ * border */
+ x0 = (clip.x0 > x0) ? clip.x0 : x0;
+ y0 = (clip.y0 > y0) ? clip.y0 : y0;
+ x1 = (clip.x1 < x1) ? clip.x1 : x1;
+ y1 = (clip.y1 < y1) ? clip.y1 : y1;
+ if ((x0 < x1) && (y0 < y1)) {
+ /* valid clip rectangles only */
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_in))
+ return false;
+ }
} else {
x0 = p[6]; y0 = p[7];
x1 = p[2]; y1 = p[3];
y1 = ((side == LEFT) && (p[1] - p[3] != 0)) ?
y1 + p[1] - p[3] : y1;
- if (!plot.rectangle(x0, y0, x1, y1,
- plot_style_bdr_out))
- return false;
+ /* find intersection of clip rectangle and
+ * border */
+ x0 = (clip.x0 > x0) ? clip.x0 : x0;
+ y0 = (clip.y0 > y0) ? clip.y0 : y0;
+ x1 = (clip.x1 < x1) ? clip.x1 : x1;
+ y1 = (clip.y1 < y1) ? clip.y1 : y1;
+ if ((x0 < x1) && (y0 < y1)) {
+ /* valid clip rectangles only */
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_out))
+ return false;
+ }
}
} else {
/* Border made up from two parts and can't be plotted
@@ -2095,10 +2203,7 @@
* \param box BOX_INLINE which created the background
* \param scale scale for redraw
* \param clip coordinates of clip rectangle
- * \param px0 coordinate of border edge rectangle
- * \param py0 coordinate of border edge rectangle
- * \param px1 coordinate of border edge rectangle
- * \param py1 coordinate of border edge rectangle
+ * \param b coordinates of border edge rectangle
* \param first true if this is the first rectangle associated with the inline
* \param last true if this is the last rectangle associated with the inline
* \param background_colour updated to current background colour if plotted
@@ -2106,8 +2211,8 @@
*/
bool html_redraw_inline_background(int x, int y, struct box *box, float scale,
- struct rect clip, int px0, int py0, int px1, int py1,
- bool first, bool last, colour *background_colour)
+ struct rect clip, struct rect b, bool first, bool last,
+ colour *background_colour)
{
bool repeat_x = false;
bool repeat_y = false;
@@ -2156,7 +2261,8 @@
css_computed_background_position(box->style,
&hpos, &hunit, &vpos, &vunit);
if (hunit == CSS_UNIT_PCT) {
- x += (px1 - px0 - content_get_width(box->background) *
+ x += (b.x1 - b.x0 -
+ content_get_width(box->background) *
scale) * FIXTOFLT(hpos) / 100.;
if (!repeat_x && ((hpos < 2 && !first) ||
@@ -2169,7 +2275,8 @@
}
if (vunit == CSS_UNIT_PCT) {
- y += (py1 - py0 - content_get_height(box->background) *
+ y += (b.y1 - b.y0 -
+ content_get_height(box->background) *
scale) * FIXTOFLT(vpos) / 100.;
} else {
y += (int) (FIXTOFLT(nscss_len2px(vpos, vunit,
12 years, 9 months
r10712 tlsa - /trunk/netsurf/render/html_redraw.c
by netsurf@semichrome.net
Author: tlsa
Date: Thu Aug 26 05:01:26 2010
New Revision: 10712
URL: http://source.netsurf-browser.org?rev=10712&view=rev
Log:
+ Pass clip rectangle around html_redraw_* as a struct rect.
+ Reduce fp maths at 1:1 scale for boxes with overflow:visisble.
+ Simplfy border plots.
Modified:
trunk/netsurf/render/html_redraw.c
Modified: trunk/netsurf/render/html_redraw.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html_redraw.c?rev=...
==============================================================================
--- trunk/netsurf/render/html_redraw.c (original)
+++ trunk/netsurf/render/html_redraw.c Thu Aug 26 05:01:26 2010
@@ -54,27 +54,22 @@
#include "utils/utils.h"
-static bool html_redraw_box(struct box *box,
- int x, int y,
- int clip_x0, int clip_y0, int clip_x1, int clip_y1,
+static bool html_redraw_box(struct box *box, int x, int y, struct rect clip,
float scale, colour current_background_color);
static bool html_redraw_box_children(struct box *box,
- int x_parent, int y_parent,
- int clip_x0, int clip_y0, int clip_x1, int clip_y1,
+ int x_parent, int y_parent, struct rect clip,
float scale, colour current_background_color);
static bool html_redraw_text_box(struct box *box, int x, int y,
- int x0, int y0, int x1, int y1,
- float scale, colour current_background_color);
+ struct rect clip, float scale,
+ colour current_background_color);
static bool html_redraw_caret(struct caret *caret,
colour current_background_color, float scale);
static bool html_redraw_borders(struct box *box, int x_parent, int y_parent,
int p_width, int p_height, float scale);
static bool html_redraw_inline_borders(struct box *box, int x0, int y0,
int x1, int y1, float scale, bool first, bool last);
-static bool html_redraw_border_plot(const int i, const int *p, colour c,
- enum css_border_style_e style, int thickness);
-static bool html_redraw_plot_border_part(const int *p, unsigned int n,
- const plot_style_t *pstyle);
+static bool html_redraw_border_plot(const int side, const int *p, colour c,
+ enum css_border_style_e style, int thickness, bool rectangular);
static bool html_redraw_checkbox(int x, int y, int width, int height,
bool selected);
static bool html_redraw_radio(int x, int y, int width, int height,
@@ -82,11 +77,11 @@
static bool html_redraw_file(int x, int y, int width, int height,
struct box *box, float scale, colour background_colour);
static bool html_redraw_background(int x, int y, struct box *box, float scale,
- int clip_x0, int clip_y0, int clip_x1, int clip_y1,
- colour *background_colour, struct box *background);
+ struct rect clip, colour *background_colour,
+ struct box *background);
static bool html_redraw_inline_background(int x, int y, struct box *box,
- float scale, int clip_x0, int clip_y0,
- int clip_x1, int clip_y1, int px0, int py0, int px1, int py1,
+ float scale, struct rect clip,
+ int px0, int py0, int px1, int py1,
bool first, bool last, colour *background_colour);
static bool html_redraw_text_decoration(struct box *box,
int x_parent, int y_parent, float scale,
@@ -154,6 +149,11 @@
}
if (!select_only) {
+ struct rect clip;
+ clip.x0 = clip_x0;
+ clip.y0 = clip_y0;
+ clip.x1 = clip_x1;
+ clip.y1 = clip_y1;
/* clear to background colour */
result = plot.clip(clip_x0, clip_y0, clip_x1, clip_y1);
@@ -164,8 +164,7 @@
result &= plot.rectangle(clip_x0, clip_y0, clip_x1, clip_y1,
&pstyle_fill_bg);
- result &= html_redraw_box(box, x, y,
- clip_x0, clip_y0, clip_x1, clip_y1,
+ result &= html_redraw_box(box, x, y, clip,
scale, pstyle_fill_bg.fill_colour);
}
@@ -195,14 +194,11 @@
/**
* Recursively draw a box.
*
- * \param box box to draw
- * \param x_parent coordinate of parent box
- * \param y_parent coordinate of parent box
- * \param clip_x0 clip rectangle
- * \param clip_y0 clip rectangle
- * \param clip_x1 clip rectangle
- * \param clip_y1 clip rectangle
- * \param scale scale for redraw
+ * \param box box to draw
+ * \param x_parent coordinate of parent box
+ * \param y_parent coordinate of parent box
+ * \param clip clip rectangle
+ * \param scale scale for redraw
* \param current_background_color background colour under this box
* \param inline_depth depth of nested inlines inside an inline container
* \return true if successful, false otherwise
@@ -210,16 +206,14 @@
* x, y, clip_[xy][01] are in target coordinates.
*/
-bool html_redraw_box(struct box *box,
- int x_parent, int y_parent,
- int clip_x0, int clip_y0, int clip_x1, int clip_y1,
- float scale, colour current_background_color)
+bool html_redraw_box(struct box *box, int x_parent, int y_parent,
+ struct rect clip, float scale, colour current_background_color)
{
int x, y;
int width, height;
int padding_left, padding_top, padding_width, padding_height;
int border_left, border_top, border_right, border_bottom;
- int x0, y0, x1, y1;
+ struct rect r;
int x_scrolled, y_scrolled;
struct box *bg_box = NULL;
css_color bgcol = 0;
@@ -267,16 +261,26 @@
/* calculate rectangle covering this box and descendants */
if (box->style && css_computed_overflow(box->style) !=
CSS_OVERFLOW_VISIBLE) {
- x0 = x - border_left;
- y0 = y - border_top;
- x1 = x + padding_width + border_right;
- y1 = y + padding_height + border_bottom;
+ /* box contents clipped to box size */
+ r.x0 = x - border_left;
+ r.y0 = y - border_top;
+ r.x1 = x + padding_width + border_right;
+ r.y1 = y + padding_height + border_bottom;
} else {
- x0 = x + box->descendant_x0 * scale;
- y0 = y + box->descendant_y0 * scale;
- x1 = x + box->descendant_x1 * scale + 1;
- y1 = y + box->descendant_y1 * scale + 1;
+ /* box contents can hang out of the box; use descendant box */
+ if (scale == 1.0) {
+ r.x0 = x + box->descendant_x0;
+ r.y0 = y + box->descendant_y0;
+ r.x1 = x + box->descendant_x1 + 1;
+ r.y1 = y + box->descendant_y1 + 1;
+ } else {
+ r.x0 = x + box->descendant_x0 * scale;
+ r.y0 = y + box->descendant_y0 * scale;
+ r.x1 = x + box->descendant_x1 * scale + 1;
+ r.y1 = y + box->descendant_y1 * scale + 1;
+ }
if (!box->parent) {
+ /* root element */
int margin_left, margin_right;
int margin_top, margin_bottom;
if (scale == 1.0) {
@@ -290,37 +294,38 @@
margin_right = box->margin[RIGHT] * scale;
margin_bottom = box->margin[BOTTOM] * scale;
}
- x0 = x - border_left - margin_left < x0 ?
- x - border_left - margin_left : x0;
- y0 = y - border_top - margin_top < y0 ?
- y - border_top - margin_top : y0;
- x1 = x + padding_width + border_right +
- margin_right > x1 ?
+ r.x0 = x - border_left - margin_left < r.x0 ?
+ x - border_left - margin_left : r.x0;
+ r.y0 = y - border_top - margin_top < r.y0 ?
+ y - border_top - margin_top : r.y0;
+ r.x1 = x + padding_width + border_right +
+ margin_right > r.x1 ?
x + padding_width + border_right +
- margin_right : x1;
- y1 = y + padding_height + border_bottom +
- margin_bottom > y1 ?
+ margin_right : r.x1;
+ r.y1 = y + padding_height + border_bottom +
+ margin_bottom > r.y1 ?
y + padding_height + border_bottom +
- margin_bottom : y1;
+ margin_bottom : r.y1;
}
}
/* return if the rectangle is completely outside the clip rectangle */
- if (clip_y1 < y0 || y1 < clip_y0 || clip_x1 < x0 || x1 < clip_x0)
+ if (clip.y1 < r.y0 || r.y1 < clip.y0 ||
+ clip.x1 < r.x0 || r.x1 < clip.x0)
return true;
/*if the rectangle is under the page bottom but it can fit in a page,
don't print it now*/
if (html_redraw_printing) {
- if (y1 > html_redraw_printing_border) {
- if (y1 - y0 <= html_redraw_printing_border &&
+ if (r.y1 > html_redraw_printing_border) {
+ if (r.y1 - r.y0 <= html_redraw_printing_border &&
(box->type == BOX_TEXT ||
box->type == BOX_TABLE_CELL
|| box->object || box->gadget)) {
/*remember the highest of all points from the
not printed elements*/
- if (y0 < html_redraw_printing_top_cropped)
- html_redraw_printing_top_cropped = y0;
+ if (r.y0 < html_redraw_printing_top_cropped)
+ html_redraw_printing_top_cropped = r.y0;
return true;
}
}
@@ -333,8 +338,7 @@
if ((plot.group_start) && (!plot.group_start("hidden box")))
return false;
if (!html_redraw_box_children(box, x_parent, y_parent,
- x0, y0, x1, y1, scale,
- current_background_color))
+ r, scale, current_background_color))
return false;
return ((!plot.group_end) || (plot.group_end()));
}
@@ -345,23 +349,23 @@
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
box->type == BOX_TABLE_CELL || box->object) {
/* find intersection of clip rectangle and box */
- if (x0 < clip_x0) x0 = clip_x0;
- if (y0 < clip_y0) y0 = clip_y0;
- if (clip_x1 < x1) x1 = clip_x1;
- if (clip_y1 < y1) y1 = clip_y1;
+ if (r.x0 < clip.x0) r.x0 = clip.x0;
+ if (r.y0 < clip.y0) r.y0 = clip.y0;
+ if (clip.x1 < r.x1) r.x1 = clip.x1;
+ if (clip.y1 < r.y1) r.y1 = clip.y1;
/* no point trying to draw 0-width/height boxes */
- if (x0 == x1 || y0 == y1)
+ if (r.x0 == r.x1 || r.y0 == r.y1)
/* not an error */
return ((!plot.group_end) || (plot.group_end()));
/* clip to it */
- if (!plot.clip(x0, y0, x1, y1))
+ if (!plot.clip(r.x0, r.y0, r.x1, r.y1))
return false;
} else {
/* clip box unchanged */
- x0 = clip_x0;
- y0 = clip_y0;
- x1 = clip_x1;
- y1 = clip_y1;
+ r.x0 = clip.x0;
+ r.y0 = clip.y0;
+ r.x1 = clip.x1;
+ r.y1 = clip.y1;
}
/* background colour and image for block level content and replaced
@@ -433,13 +437,13 @@
&bgcol) != CSS_BACKGROUND_COLOR_TRANSPARENT ||
bg_box->background)) {
/* find intersection of clip box and border edge */
- int px0, py0, px1, py1;
- px0 = x - border_left < x0 ? x0 : x - border_left;
- py0 = y - border_top < y0 ? y0 : y - border_top;
- px1 = x + padding_width + border_right < x1 ?
- x + padding_width + border_right : x1;
- py1 = y + padding_height + border_bottom < y1 ?
- y + padding_height + border_bottom : y1;
+ struct rect p;
+ p.x0 = x - border_left < r.x0 ? r.x0 : x - border_left;
+ p.y0 = y - border_top < r.y0 ? r.y0 : y - border_top;
+ p.x1 = x + padding_width + border_right < r.x1 ?
+ x + padding_width + border_right : r.x1;
+ p.y1 = y + padding_height + border_bottom < r.y1 ?
+ y + padding_height + border_bottom : r.y1;
if (!box->parent) {
/* Root element, special case:
* background covers margins too */
@@ -455,20 +459,19 @@
m_right = box->margin[RIGHT] * scale;
m_bottom = box->margin[BOTTOM] * scale;
}
- px0 = px0 - m_left < x0 ? x0 : px0 - m_left;
- py0 = py0 - m_top < y0 ? y0 : py0 - m_top;
- px1 = px1 + m_right < x1 ? px1 + m_right : x1;
- py1 = py1 + m_bottom < y1 ? py1 + m_bottom : y1;
+ p.x0 = p.x0 - m_left < r.x0 ? r.x0 : p.x0 - m_left;
+ p.y0 = p.y0 - m_top < r.y0 ? r.y0 : p.y0 - m_top;
+ p.x1 = p.x1 + m_right < r.x1 ? p.x1 + m_right : r.x1;
+ p.y1 = p.y1 + m_bottom < r.y1 ? p.y1 + m_bottom : r.y1;
}
/* valid clipping rectangles only */
- if ((px0 < px1) && (py0 < py1)) {
+ if ((p.x0 < p.x1) && (p.y0 < p.y1)) {
/* plot background */
- if (!html_redraw_background(x, y, box, scale,
- px0, py0, px1, py1,
+ if (!html_redraw_background(x, y, box, scale, p,
¤t_background_color, bg_box))
return false;
/* restore previous graphics window */
- if (!plot.clip(x0, y0, x1, y1))
+ if (!plot.clip(r.x0, r.y0, r.x1, r.y1))
return false;
}
}
@@ -493,6 +496,7 @@
/* inline backgrounds and borders span other boxes and may
* wrap onto separate lines */
struct box *ib;
+ struct rect p;
bool first = true;
int ib_x;
int ib_y = y;
@@ -502,10 +506,10 @@
int xmax = x + padding_width + border_right;
int ymin = y - border_top;
int ymax = y + padding_height + border_bottom;
- int px0 = xmin < x0 ? x0 : xmin;
- int px1 = xmax < x1 ? xmax : x1;
- int py0 = ymin < y0 ? y0 : ymin;
- int py1 = ymax < y1 ? ymax : y1;
+ p.x0 = xmin < r.x0 ? r.x0 : xmin;
+ p.x1 = xmax < r.x1 ? xmax : r.x1;
+ p.y0 = ymin < r.y0 ? r.y0 : ymin;
+ p.y1 = ymax < r.y1 ? ymax : r.y1;
for (ib = box; ib; ib = ib->next) {
/* to get extents of rectangle(s) associated with
* inline, cycle though all boxes in inline, skipping
@@ -533,14 +537,13 @@
/* inline element has wrapped, plot background
* and borders */
if (!html_redraw_inline_background(
- x, y, box, scale,
- px0, py0, px1, py1,
+ x, y, box, scale, p,
xmin, ymin, xmax, ymax,
first, false,
¤t_background_color))
return false;
/* restore previous graphics window */
- if (!plot.clip(x0, y0, x1, y1))
+ if (!plot.clip(r.x0, r.y0, r.x1, r.y1))
return false;
if (!html_redraw_inline_borders(box,
xmin, ymin, xmax, ymax,
@@ -552,16 +555,16 @@
ymax = ib_y + padding_height - padding_top +
border_bottom;
- px0 = xmin < x0 ? x0 : xmin;
- py0 = ymin < y0 ? y0 : ymin;
- py1 = ymax < y1 ? ymax : y1;
+ p.x0 = xmin < r.x0 ? r.x0 : xmin;
+ p.y0 = ymin < r.y0 ? r.y0 : ymin;
+ p.y1 = ymax < r.y1 ? ymax : r.y1;
first = false;
}
/* increase width for current box */
xmax = ib_x + ib_p_width + ib_b_right;
- px1 = xmax < x1 ? xmax : x1;
+ p.x1 = xmax < r.x1 ? xmax : r.x1;
if (ib == box->inline_end)
/* reached end of BOX_INLINE span */
@@ -569,12 +572,12 @@
}
/* plot background and borders for last rectangle of
* the inline */
- if (!html_redraw_inline_background(x, ib_y, box, scale,
- px0, py0, px1, py1, xmin, ymin, xmax, ymax,
- first, true, ¤t_background_color))
+ if (!html_redraw_inline_background(x, ib_y, box, scale, p,
+ xmin, ymin, xmax, ymax, first, true,
+ ¤t_background_color))
return false;
/* restore previous graphics window */
- if (!plot.clip(x0, y0, x1, y1))
+ if (!plot.clip(r.x0, r.y0, r.x1, r.y1))
return false;
if (!html_redraw_inline_borders(box, xmin, ymin, xmax, ymax,
scale, first, true))
@@ -625,19 +628,19 @@
/* clip to the padding edge for boxes with overflow hidden or scroll */
if (box->style && css_computed_overflow(box->style) !=
CSS_OVERFLOW_VISIBLE) {
- x0 = x;
- y0 = y;
- x1 = x + padding_width;
- y1 = y + padding_height;
- if (x0 < clip_x0) x0 = clip_x0;
- if (y0 < clip_y0) y0 = clip_y0;
- if (clip_x1 < x1) x1 = clip_x1;
- if (clip_y1 < y1) y1 = clip_y1;
- if (x1 <= x0 || y1 <= y0)
+ r.x0 = x;
+ r.y0 = y;
+ r.x1 = x + padding_width;
+ r.y1 = y + padding_height;
+ if (r.x0 < clip.x0) r.x0 = clip.x0;
+ if (r.y0 < clip.y0) r.y0 = clip.y0;
+ if (clip.x1 < r.x1) r.x1 = clip.x1;
+ if (clip.y1 < r.y1) r.y1 = clip.y1;
+ if (r.x1 <= r.x0 || r.y1 <= r.y0)
return ((!plot.group_end) || (plot.group_end()));
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
box->type == BOX_TABLE_CELL || box->object) {
- if (!plot.clip(x0, y0, x1, y1))
+ if (!plot.clip(r.x0, r.y0, r.x1, r.y1))
return false;
}
}
@@ -656,7 +659,7 @@
if (!content_redraw(box->object,
x_scrolled + padding_left,
y_scrolled + padding_top,
- width, height, x0, y0, x1, y1, scale,
+ width, height, r.x0, r.y0, r.x1, r.y1, scale,
current_background_color))
return false;
@@ -679,14 +682,13 @@
return false;
} else if (box->text) {
- if (!html_redraw_text_box(box, x, y, x0, y0, x1, y1,
+ if (!html_redraw_text_box(box, x, y, r, scale,
+ current_background_color))
+ return false;
+
+ } else {
+ if (!html_redraw_box_children(box, x_parent, y_parent, r,
scale, current_background_color))
- return false;
-
- } else {
- if (!html_redraw_box_children(box, x_parent, y_parent,
- x0, y0, x1, y1, scale,
- current_background_color))
return false;
}
@@ -697,8 +699,7 @@
scroll_get_offset(box->scroll_x),
y_parent + box->y -
scroll_get_offset(box->scroll_y),
- clip_x0, clip_y0, clip_x1, clip_y1,
- scale, current_background_color))
+ clip, scale, current_background_color))
return false;
/* scrollbars */
@@ -721,8 +722,8 @@
x_parent + box->x,
y_parent + box->y + box->padding[TOP] +
box->height + box->padding[BOTTOM] -
- SCROLLBAR_WIDTH,
- clip_x0, clip_y0, clip_x1, clip_y1,
+ SCROLLBAR_WIDTH,
+ clip.x0, clip.y0, clip.x1, clip.y1,
scale);
if (box->scroll_y != NULL)
scroll_redraw(box->scroll_y,
@@ -730,14 +731,14 @@
box->width + box->padding[RIGHT] -
SCROLLBAR_WIDTH,
y_parent + box->y,
- clip_x0, clip_y0, clip_x1, clip_y1,
+ clip.x0, clip.y0, clip.x1, clip.y1,
scale);
}
if (box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK ||
box->type == BOX_TABLE_CELL || box->object)
- if (!plot.clip(clip_x0, clip_y0, clip_x1, clip_y1))
+ if (!plot.clip(clip.x0, clip.y0, clip.x1, clip.y1))
return false;
return ((!plot.group_end) || (plot.group_end()));
@@ -747,22 +748,18 @@
/**
* Draw the various children of a box.
*
- * \param box box to draw children of
- * \param x_parent coordinate of parent box
- * \param y_parent coordinate of parent box
- * \param clip_x0 clip rectangle
- * \param clip_y0 clip rectangle
- * \param clip_x1 clip rectangle
- * \param clip_y1 clip rectangle
- * \param scale scale for redraw
+ * \param box box to draw children of
+ * \param x_parent coordinate of parent box
+ * \param y_parent coordinate of parent box
+ * \param clip clip rectangle
+ * \param scale scale for redraw
* \param current_background_color background colour under this box
* \return true if successful, false otherwise
*/
-bool html_redraw_box_children(struct box *box,
- int x_parent, int y_parent,
- int clip_x0, int clip_y0, int clip_x1, int clip_y1,
- float scale, colour current_background_color)
+bool html_redraw_box_children(struct box *box, int x_parent, int y_parent,
+ struct rect clip, float scale,
+ colour current_background_color)
{
struct box *c;
@@ -774,8 +771,7 @@
scroll_get_offset(box->scroll_x),
y_parent + box->y -
scroll_get_offset(box->scroll_y),
- clip_x0, clip_y0, clip_x1, clip_y1,
- scale, current_background_color))
+ clip, scale, current_background_color))
return false;
}
for (c = box->float_children; c; c = c->next_float)
@@ -784,8 +780,7 @@
scroll_get_offset(box->scroll_x),
y_parent + box->y -
scroll_get_offset(box->scroll_y),
- clip_x0, clip_y0, clip_x1, clip_y1,
- scale, current_background_color))
+ clip, scale, current_background_color))
return false;
return true;
@@ -799,30 +794,21 @@
* \param box box with text content
* \param x x co-ord of box
* \param y y co-ord of box
- * \param x0 current clip rectangle
- * \param y0
- * \param x1
- * \param y1
+ * \param clip current clip rectangle
* \param scale current scale setting (1.0 = 100%)
* \param current_background_color
* \return true iff successful and redraw should proceed
*/
bool html_redraw_text_box(struct box *box, int x, int y,
- int x0, int y0, int x1, int y1,
- float scale, colour current_background_color)
+ struct rect clip, float scale,
+ colour current_background_color)
{
bool excluded = (box->object != NULL);
- struct rect clip;
plot_font_style_t fstyle;
font_plot_style_from_css(box->style, &fstyle);
fstyle.background = current_background_color;
-
- clip.x0 = x0;
- clip.y0 = y0;
- clip.x1 = x1;
- clip.y1 = y1;
if (!text_redraw(box->text, box->length, box->byte_offset,
box->space, &fstyle, x, y,
@@ -1062,6 +1048,8 @@
unsigned int i, side;
int p[8]; /* Box border vertices */
int z[8]; /* Border vertices */
+ bool square_end_1 = false;
+ bool square_end_2 = false;
x = x_parent + box->x;
y = y_parent + box->y;
@@ -1102,6 +1090,9 @@
switch (side) {
case LEFT:
+ square_end_1 = (top == 0);
+ square_end_2 = (bottom == 0);
+
z[0] = p[0]; z[1] = p[7];
z[2] = p[2]; z[3] = p[5];
z[4] = p[2]; z[5] = p[3];
@@ -1112,19 +1103,24 @@
box->border[TOP].style !=
CSS_BORDER_STYLE_DOUBLE) {
/* make border overhang top corner fully,
- * if top border is transparent */
+ * if top border is opaque */
z[5] -= top;
+ square_end_1 = true;
}
if (box->border[BOTTOM].color !=
CSS_BORDER_COLOR_TRANSPARENT &&
box->border[BOTTOM].style !=
CSS_BORDER_STYLE_DOUBLE) {
/* make border overhang bottom corner fully,
- * if bottom border is transparent */
+ * if bottom border is opaque */
z[3] += bottom;
+ square_end_2 = true;
}
break;
case RIGHT:
+ square_end_1 = (top == 0);
+ square_end_2 = (bottom == 0);
+
z[0] = p[6]; z[1] = p[1];
z[2] = p[4]; z[3] = p[3];
z[4] = p[4]; z[5] = p[5];
@@ -1135,19 +1131,24 @@
box->border[TOP].style !=
CSS_BORDER_STYLE_DOUBLE) {
/* make border overhang top corner fully,
- * if top border is transparent */
+ * if top border is opaque */
z[3] -= top;
+ square_end_1 = true;
}
if (box->border[BOTTOM].color !=
CSS_BORDER_COLOR_TRANSPARENT &&
box->border[BOTTOM].style !=
CSS_BORDER_STYLE_DOUBLE) {
/* make border overhang bottom corner fully,
- * if bottom border is transparent */
+ * if bottom border is opaque */
z[5] += bottom;
+ square_end_2 = true;
}
break;
case TOP:
+ square_end_1 = (left == 0);
+ square_end_2 = (right == 0);
+
z[0] = p[2]; z[1] = p[3];
z[2] = p[0]; z[3] = p[1];
z[4] = p[6]; z[5] = p[1];
@@ -1160,6 +1161,7 @@
/* don't bother overlapping left corner if
* it's the same colour anyway */
z[2] += left;
+ square_end_1 = true;
}
if (box->border[TOP].style ==
CSS_BORDER_STYLE_SOLID &&
@@ -1168,9 +1170,13 @@
/* don't bother overlapping right corner if
* it's the same colour anyway */
z[4] -= right;
+ square_end_2 = true;
}
break;
case BOTTOM:
+ square_end_1 = (left == 0);
+ square_end_2 = (right == 0);
+
z[0] = p[4]; z[1] = p[5];
z[2] = p[6]; z[3] = p[7];
z[4] = p[0]; z[5] = p[7];
@@ -1183,6 +1189,7 @@
/* don't bother overlapping left corner if
* it's the same colour anyway */
z[4] += left;
+ square_end_1 = true;
}
if (box->border[BOTTOM].style ==
CSS_BORDER_STYLE_SOLID &&
@@ -1191,6 +1198,7 @@
/* don't bother overlapping right corner if
* it's the same colour anyway */
z[2] -= right;
+ square_end_2 = true;
}
break;
default:
@@ -1203,7 +1211,8 @@
if (!html_redraw_border_plot(side, z, col,
box->border[side].style,
- box->border[side].width * scale))
+ box->border[side].width * scale,
+ square_end_1 && square_end_2))
return false;
}
@@ -1235,6 +1244,8 @@
colour col;
int p[8]; /* Box border vertices */
int z[8]; /* Border vertices */
+ bool square_end_1;
+ bool square_end_2;
if (scale != 1.0) {
top *= scale;
@@ -1261,6 +1272,8 @@
assert(box->style);
/* Left */
+ square_end_1 = (top == 0);
+ square_end_2 = (bottom == 0);
if (left != 0 && first && box->border[LEFT].color !=
CSS_BORDER_COLOR_TRANSPARENT) {
col = nscss_color_to_ns(box->border[LEFT].c);
@@ -1275,25 +1288,29 @@
box->border[TOP].style !=
CSS_BORDER_STYLE_DOUBLE) {
/* make border overhang top corner fully,
- * if top border is transparent */
+ * if top border is opaque */
z[5] -= top;
+ square_end_1 = true;
}
if (box->border[BOTTOM].color !=
CSS_BORDER_COLOR_TRANSPARENT &&
box->border[BOTTOM].style !=
CSS_BORDER_STYLE_DOUBLE) {
/* make border overhang bottom corner fully,
- * if bottom border is transparent */
+ * if bottom border is opaque */
z[3] += bottom;
+ square_end_2 = true;
}
if (!html_redraw_border_plot(LEFT, z, col,
box->border[LEFT].style,
- left))
+ left, square_end_1 && square_end_2))
return false;
}
/* Right */
+ square_end_1 = (top == 0);
+ square_end_2 = (bottom == 0);
if (right != 0 && last && box->border[RIGHT].color !=
CSS_BORDER_COLOR_TRANSPARENT) {
col = nscss_color_to_ns(box->border[RIGHT].c);
@@ -1308,25 +1325,29 @@
box->border[TOP].style !=
CSS_BORDER_STYLE_DOUBLE) {
/* make border overhang top corner fully,
- * if top border is transparent */
+ * if top border is opaque */
z[3] -= top;
+ square_end_1 = true;
}
if (box->border[BOTTOM].color !=
CSS_BORDER_COLOR_TRANSPARENT &&
box->border[BOTTOM].style !=
CSS_BORDER_STYLE_DOUBLE) {
/* make border overhang bottom corner fully,
- * if bottom border is transparent */
+ * if bottom border is opaque */
z[5] += bottom;
+ square_end_2 = true;
}
if (!html_redraw_border_plot(RIGHT, z, col,
box->border[RIGHT].style,
- right))
+ right, square_end_1 && square_end_2))
return false;
}
/* Top */
+ square_end_1 = (left == 0);
+ square_end_2 = (right == 0);
if (top != 0 && box->border[TOP].color !=
CSS_BORDER_COLOR_TRANSPARENT) {
col = nscss_color_to_ns(box->border[TOP].c);
@@ -1343,6 +1364,7 @@
/* don't bother overlapping left corner if
* it's the same colour anyway */
z[2] += left;
+ square_end_1 = true;
}
if (last && box->border[TOP].style ==
CSS_BORDER_STYLE_SOLID &&
@@ -1351,15 +1373,18 @@
/* don't bother overlapping right corner if
* it's the same colour anyway */
z[4] -= right;
+ square_end_2 = true;
}
if (!html_redraw_border_plot(TOP, z, col,
box->border[TOP].style,
- top))
+ top, square_end_1 && square_end_2))
return false;
}
/* Bottom */
+ square_end_1 = (left == 0);
+ square_end_2 = (right == 0);
if (bottom != 0 && box->border[BOTTOM].color !=
CSS_BORDER_COLOR_TRANSPARENT) {
col = nscss_color_to_ns(box->border[BOTTOM].c);
@@ -1376,6 +1401,7 @@
/* don't bother overlapping left corner if
* it's the same colour anyway */
z[4] += left;
+ square_end_1 = true;
}
if (last && box->border[BOTTOM].style ==
CSS_BORDER_STYLE_SOLID &&
@@ -1384,11 +1410,12 @@
/* don't bother overlapping right corner if
* it's the same colour anyway */
z[2] -= right;
+ square_end_2 = true;
}
if (!html_redraw_border_plot(BOTTOM, z, col,
box->border[BOTTOM].style,
- bottom))
+ bottom, square_end_1 && square_end_2))
return false;
}
@@ -1417,19 +1444,20 @@
/**
* Draw one border.
*
- * \param i index of border side (TOP, RIGHT, BOTTOM, LEFT)
- * \param p array of precomputed border vertices
- * \param c colour for border
- * \param style border line style
- * \param thickness border thickness
+ * \param side index of border side (TOP, RIGHT, BOTTOM, LEFT)
+ * \param p array of precomputed border vertices
+ * \param c colour for border
+ * \param style border line style
+ * \param thickness border thickness
+ * \param rectangular whether border is rectangular
* \return true if successful, false otherwise
*/
-bool html_redraw_border_plot(const int i, const int *p, colour c,
- enum css_border_style_e style, int thickness)
+bool html_redraw_border_plot(const int side, const int *p, colour c,
+ enum css_border_style_e style, int thickness, bool rectangular)
{
int z[8]; /* Vertices of border part */
- unsigned int light = i;
+ unsigned int light = side;
plot_style_t *plot_style_bdr_in;
plot_style_t *plot_style_bdr_out;
@@ -1461,8 +1489,26 @@
case CSS_BORDER_STYLE_SOLID:
/* fall through to default */
default:
- if (!html_redraw_plot_border_part(p, 4, &plot_style_fillbdr))
- return false;
+ if (rectangular || thickness == 1) {
+ int x0, y0, x1, y1;
+ if (side == TOP || side == RIGHT) {
+ x0 = p[2]; y0 = p[3];
+ x1 = p[6]; y1 = p[7];
+ x1 = ((side == TOP) && (p[4] - p[6] != 0)) ?
+ x1 + p[4] - p[6] : x1;
+ } else {
+ x0 = p[6]; y0 = p[7];
+ x1 = p[2]; y1 = p[3];
+ y1 = ((side == LEFT) && (p[1] - p[3] != 0)) ?
+ y1 + p[1] - p[3] : y1;
+ }
+ if (!plot.rectangle(x0, y0, x1, y1,
+ &plot_style_fillbdr))
+ return false;
+ } else {
+ if (!plot.polygon(p, 4, &plot_style_fillbdr))
+ return false;
+ }
break;
case CSS_BORDER_STYLE_DOUBLE:
@@ -1474,7 +1520,7 @@
z[5] = (p[7] * 2 + p[5]) / 3;
z[6] = p[6];
z[7] = p[7];
- if (!html_redraw_plot_border_part(z, 4, &plot_style_fillbdr))
+ if (!plot.polygon(z, 4, &plot_style_fillbdr))
return false;
z[0] = p[2];
z[1] = p[3];
@@ -1484,7 +1530,7 @@
z[5] = (p[5] * 2 + p[7]) / 3;
z[6] = p[4];
z[7] = p[5];
- if (!html_redraw_plot_border_part(z, 4, &plot_style_fillbdr))
+ if (!plot.polygon(z, 4, &plot_style_fillbdr))
return false;
break;
@@ -1500,22 +1546,77 @@
plot_style_bdr_in = &plot_style_fillbdr_light;
plot_style_bdr_out = &plot_style_fillbdr_dark;
}
- z[0] = p[0];
- z[1] = p[1];
- z[2] = (p[0] + p[2]) / 2;
- z[3] = (p[1] + p[3]) / 2;
- z[4] = (p[6] + p[4]) / 2;
- z[5] = (p[7] + p[5]) / 2;
- z[6] = p[6];
- z[7] = p[7];
- if (!html_redraw_plot_border_part(z, 4, plot_style_bdr_in))
- return false;
- z[0] = p[2];
- z[1] = p[3];
- z[6] = p[4];
- z[7] = p[5];
- if (!html_redraw_plot_border_part(z, 4, plot_style_bdr_out))
- return false;
+
+ /* Render border */
+ if ((rectangular || thickness == 2) && thickness != 1) {
+ /* Border made up from two parts and can be plotted
+ * with rectangles */
+ int x0, y0, x1, y1;
+
+ /* First part */
+ if (side == TOP || side == RIGHT) {
+ x0 = (p[0] + p[2]) / 2; y0 = (p[1] + p[3]) / 2;
+ x1 = p[6]; y1 = p[7];
+ } else {
+ x0 = p[6]; y0 = p[7];
+ x1 = (p[0] + p[2]) / 2; y1 = (p[1] + p[3]) / 2;
+ }
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_in))
+ return false;
+
+ /* Second part */
+ if (side == TOP || side == RIGHT) {
+ x0 = p[2]; y0 = p[3];
+ x1 = (p[6] + p[4]) / 2; y1 = (p[7] + p[5]) / 2;
+ } else {
+ x0 = (p[6] + p[4]) / 2; y0 = (p[7] + p[5]) / 2;
+ x1 = p[2]; y1 = p[3];
+ }
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_out))
+ return false;
+ } else if (thickness == 1) {
+ /* Border made up from one part which can be plotted
+ * as a rectangle */
+ int x0, y0, x1, y1;
+ if (side == TOP || side == RIGHT) {
+ x0 = p[2]; y0 = p[3];
+ x1 = p[6]; y1 = p[7];
+ x1 = ((side == TOP) && (p[4] - p[6] != 0)) ?
+ x1 + p[4] - p[6] : x1;
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_in))
+ return false;
+ } else {
+ x0 = p[6]; y0 = p[7];
+ x1 = p[2]; y1 = p[3];
+ y1 = ((side == LEFT) && (p[1] - p[3] != 0)) ?
+ y1 + p[1] - p[3] : y1;
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_out))
+ return false;
+ }
+ } else {
+ /* Border made up from two parts and can't be plotted
+ * with rectangles */
+ z[0] = p[0];
+ z[1] = p[1];
+ z[2] = (p[0] + p[2]) / 2;
+ z[3] = (p[1] + p[3]) / 2;
+ z[4] = (p[6] + p[4]) / 2;
+ z[5] = (p[7] + p[5]) / 2;
+ z[6] = p[6];
+ z[7] = p[7];
+ if (!plot.polygon(z, 4, plot_style_bdr_in))
+ return false;
+ z[0] = p[2];
+ z[1] = p[3];
+ z[6] = p[4];
+ z[7] = p[5];
+ if (!plot.polygon(z, 4, plot_style_bdr_out))
+ return false;
+ }
break;
case CSS_BORDER_STYLE_INSET:
@@ -1546,114 +1647,77 @@
break;
}
- z[0] = p[0];
- z[1] = p[1];
- z[2] = (p[0] + p[2]) / 2;
- z[3] = (p[1] + p[3]) / 2;
- z[4] = (p[6] + p[4]) / 2;
- z[5] = (p[7] + p[5]) / 2;
- z[6] = p[6];
- z[7] = p[7];
- if (!html_redraw_plot_border_part(z, 4, plot_style_bdr_in))
- return false;
- z[0] = p[2];
- z[1] = p[3];
- z[6] = p[4];
- z[7] = p[5];
- if (!html_redraw_plot_border_part(z, 4, plot_style_bdr_out))
- return false;
+ /* Render border */
+ if ((rectangular || thickness == 2) && thickness != 1) {
+ /* Border made up from two parts and can be plotted
+ * with rectangles */
+ int x0, y0, x1, y1;
+
+ /* First part */
+ if (side == TOP || side == RIGHT) {
+ x0 = (p[0] + p[2]) / 2; y0 = (p[1] + p[3]) / 2;
+ x1 = p[6]; y1 = p[7];
+ } else {
+ x0 = p[6]; y0 = p[7];
+ x1 = (p[0] + p[2]) / 2; y1 = (p[1] + p[3]) / 2;
+ }
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_in))
+ return false;
+
+ /* Second part */
+ if (side == TOP || side == RIGHT) {
+ x0 = p[2]; y0 = p[3];
+ x1 = (p[6] + p[4]) / 2; y1 = (p[7] + p[5]) / 2;
+ } else {
+ x0 = (p[6] + p[4]) / 2; y0 = (p[7] + p[5]) / 2;
+ x1 = p[2]; y1 = p[3];
+ }
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_out))
+ return false;
+ } else if (thickness == 1) {
+ /* Border made up from one part which can be plotted
+ * as a rectangle */
+ int x0, y0, x1, y1;
+ if (side == TOP || side == RIGHT) {
+ x0 = p[2]; y0 = p[3];
+ x1 = p[6]; y1 = p[7];
+ x1 = ((side == TOP) && (p[4] - p[6] != 0)) ?
+ x1 + p[4] - p[6] : x1;
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_in))
+ return false;
+ } else {
+ x0 = p[6]; y0 = p[7];
+ x1 = p[2]; y1 = p[3];
+ y1 = ((side == LEFT) && (p[1] - p[3] != 0)) ?
+ y1 + p[1] - p[3] : y1;
+ if (!plot.rectangle(x0, y0, x1, y1,
+ plot_style_bdr_out))
+ return false;
+ }
+ } else {
+ /* Border made up from two parts and can't be plotted
+ * with rectangles */
+ z[0] = p[0];
+ z[1] = p[1];
+ z[2] = (p[0] + p[2]) / 2;
+ z[3] = (p[1] + p[3]) / 2;
+ z[4] = (p[6] + p[4]) / 2;
+ z[5] = (p[7] + p[5]) / 2;
+ z[6] = p[6];
+ z[7] = p[7];
+ if (!plot.polygon(z, 4, plot_style_bdr_in))
+ return false;
+ z[0] = p[2];
+ z[1] = p[3];
+ z[6] = p[4];
+ z[7] = p[5];
+ if (!plot.polygon(z, 4, plot_style_bdr_out))
+ return false;
+ }
break;
- }
-
- return true;
-}
-
-
-/**
- * Plot a border part, using the most optimal plotter.
- *
- * \param p array of precomputed border vertices
- * \param n number of vertices
- * \param pstyle plot_style to plot with
- * \return true if successful, false otherwise
- */
-
-bool html_redraw_plot_border_part(const int *p, unsigned int n,
- const plot_style_t *pstyle)
-{
- bool is_v = false; /* vertical border */
- bool is_h = false; /* horizontal border */
- int i;
-
- assert(n == 4);
-
- if ((p[1] == p[7] && p[3] == p[5]) || (p[1] == p[3] && p[5] == p[7]))
- is_v = true;
-
- if ((p[0] == p[6] && p[2] == p[4]) || (p[0] == p[2] && p[4] == p[6]))
- is_h = true;
-
- if (is_v && is_h) {
- /* border is rectangular */
- int x0, y0, x1, y1;
- if (p[0] < p[4]) {
- x0 = p[0];
- x1 = p[4];
- } else {
- x0 = p[4];
- x1 = p[0];
- }
- if (p[1] < p[5]) {
- y0 = p[1];
- y1 = p[5];
- } else {
- y0 = p[5];
- y1 = p[1];
- }
- if (!plot.rectangle(x0, y0, x1, y1, pstyle))
- return false;
- } else if (is_v && abs(p[1] - p[3]) == 1) {
- /* 1px wide vertical border */
- int x0, y0, x1, y1;
- if (p[0] < p[4]) {
- x0 = p[0];
- x1 = p[4];
- } else {
- x0 = p[4];
- x1 = p[0];
- }
- y0 = p[1];
- y1 = p[1];
- for (i = 3; i < 8; i += 2) {
- y0 = y0 > p[i] ? p[i] : y0;
- y1 = y1 < p[i] ? p[i] : y1;
- }
- /* TODO: Use line plotter? */
- if (!plot.rectangle(x0, y0, x1, y1, pstyle))
- return false;
- } else if (is_h && abs(p[0] - p[2]) == 1) {
- /* 1px wide horizontal border */
- int x0, y0, x1, y1;
- if (p[1] < p[5]) {
- y0 = p[1];
- y1 = p[5];
- } else {
- y0 = p[5];
- y1 = p[1];
- }
- x0 = p[0];
- x1 = p[0];
- for (i = 2; i < 7; i += 2) {
- x0 = x0 > p[i] ? p[i] : x0;
- x1 = x1 < p[i] ? p[i] : x1;
- }
- /* TODO: Use line plotter? */
- if (!plot.rectangle(x0, y0, x1, y1, pstyle))
- return false;
- } else {
- /* have to plot as polygon */
- if (!plot.polygon(p, 4, pstyle))
- return false;
}
return true;
@@ -1815,6 +1879,7 @@
* \param y coordinate of box
* \param box box to draw background image of
* \param scale scale for redraw
+ * \param clip current clip rectangle
* \param background_colour current background colour
* \param background box containing background details (usually ::box)
* \return true if successful, false otherwise
@@ -1825,8 +1890,8 @@
*/
bool html_redraw_background(int x, int y, struct box *box, float scale,
- int clip_x0, int clip_y0, int clip_x1, int clip_y1,
- colour *background_colour, struct box *background)
+ struct rect clip, colour *background_colour,
+ struct box *background)
{
bool repeat_x = false;
bool repeat_y = false;
@@ -1834,7 +1899,7 @@
bool plot_content;
bool clip_to_children = false;
struct box *clip_box = box;
- int px0 = clip_x0, py0 = clip_y0, px1 = clip_x1, py1 = clip_y1;
+ int px0 = clip.x0, py0 = clip.y0, px1 = clip.x1, py1 = clip.y1;
int ox = x, oy = y;
int width, height;
css_fixed hpos = 0, vpos = 0;
@@ -1942,26 +2007,26 @@
assert(clip_box->type == BOX_TABLE_CELL);
- /* update clip_* to the child cell */
- clip_x0 = ox + (clip_box->x * scale);
- clip_y0 = oy + (clip_box->y * scale);
- clip_x1 = clip_x0 + (clip_box->padding[LEFT] +
+ /* update clip.* to the child cell */
+ clip.x0 = ox + (clip_box->x * scale);
+ clip.y0 = oy + (clip_box->y * scale);
+ clip.x1 = clip.x0 + (clip_box->padding[LEFT] +
clip_box->width +
clip_box->padding[RIGHT]) * scale;
- clip_y1 = clip_y0 + (clip_box->padding[TOP] +
+ clip.y1 = clip.y0 + (clip_box->padding[TOP] +
clip_box->height +
clip_box->padding[BOTTOM]) * scale;
- if (clip_x0 < px0) clip_x0 = px0;
- if (clip_y0 < py0) clip_y0 = py0;
- if (clip_x1 > px1) clip_x1 = px1;
- if (clip_y1 > py1) clip_y1 = py1;
+ if (clip.x0 < px0) clip.x0 = px0;
+ if (clip.y0 < py0) clip.y0 = py0;
+ if (clip.x1 > px1) clip.x1 = px1;
+ if (clip.y1 > py1) clip.y1 = py1;
if (clip_box->background != NULL)
bmp = content_get_bitmap(clip_box->background);
/* <td> attributes override <tr> */
- if ((clip_x0 >= clip_x1) || (clip_y0 >= clip_y1) ||
+ if ((clip.x0 >= clip.x1) || (clip.y0 >= clip.y1) ||
(css_computed_background_color(
clip_box->style, &bgcol) !=
CSS_BACKGROUND_COLOR_TRANSPARENT) ||
@@ -1975,8 +2040,8 @@
*background_colour = nscss_color_to_ns(bgcol);
pstyle_fill_bg.fill_colour = *background_colour;
if (plot_colour)
- if (!plot.rectangle(clip_x0, clip_y0,
- clip_x1, clip_y1,
+ if (!plot.rectangle(clip.x0, clip.y0,
+ clip.x1, clip.y1,
&pstyle_fill_bg))
return false;
}
@@ -1986,28 +2051,28 @@
height = content_get_height(background->background);
if (!repeat_x) {
- if (clip_x0 < x)
- clip_x0 = x;
- if (clip_x1 > x + width * scale)
- clip_x1 = x + width * scale;
+ if (clip.x0 < x)
+ clip.x0 = x;
+ if (clip.x1 > x + width * scale)
+ clip.x1 = x + width * scale;
}
if (!repeat_y) {
- if (clip_y0 < y)
- clip_y0 = y;
- if (clip_y1 > y + height * scale)
- clip_y1 = y + height * scale;
+ if (clip.y0 < y)
+ clip.y0 = y;
+ if (clip.y1 > y + height * scale)
+ clip.y1 = y + height * scale;
}
/* valid clipping rectangles only */
- if ((clip_x0 < clip_x1) && (clip_y0 < clip_y1)) {
- if (!plot.clip(clip_x0, clip_y0,
- clip_x1, clip_y1))
+ if ((clip.x0 < clip.x1) && (clip.y0 < clip.y1)) {
+ if (!plot.clip(clip.x0, clip.y0,
+ clip.x1, clip.y1))
return false;
if (!content_redraw_tiled(
background->background, x, y,
ceilf(width * scale),
ceilf(height * scale),
- clip_x0, clip_y0,
- clip_x1, clip_y1,
+ clip.x0, clip.y0,
+ clip.x1, clip.y1,
scale, *background_colour,
repeat_x, repeat_y))
return false;
@@ -2029,10 +2094,7 @@
* \param y coordinate of box
* \param box BOX_INLINE which created the background
* \param scale scale for redraw
- * \param clip_x0 coordinate of clip rectangle
- * \param clip_y0 coordinate of clip rectangle
- * \param clip_x1 coordinate of clip rectangle
- * \param clip_y1 coordinate of clip rectangle
+ * \param clip coordinates of clip rectangle
* \param px0 coordinate of border edge rectangle
* \param py0 coordinate of border edge rectangle
* \param px1 coordinate of border edge rectangle
@@ -2044,8 +2106,7 @@
*/
bool html_redraw_inline_background(int x, int y, struct box *box, float scale,
- int clip_x0, int clip_y0, int clip_x1, int clip_y1,
- int px0, int py0, int px1, int py1,
+ struct rect clip, int px0, int py0, int px1, int py1,
bool first, bool last, colour *background_colour)
{
bool repeat_x = false;
@@ -2123,8 +2184,8 @@
pstyle_fill_bg.fill_colour = *background_colour;
if (plot_colour)
- if (!plot.rectangle(clip_x0, clip_y0,
- clip_x1, clip_y1,
+ if (!plot.rectangle(clip.x0, clip.y0,
+ clip.x1, clip.y1,
&pstyle_fill_bg))
return false;
}
@@ -2134,27 +2195,27 @@
int height = content_get_height(box->background);
if (!repeat_x) {
- if (clip_x0 < x)
- clip_x0 = x;
- if (clip_x1 > x + width * scale)
- clip_x1 = x + width * scale;
+ if (clip.x0 < x)
+ clip.x0 = x;
+ if (clip.x1 > x + width * scale)
+ clip.x1 = x + width * scale;
}
if (!repeat_y) {
- if (clip_y0 < y)
- clip_y0 = y;
- if (clip_y1 > y + height * scale)
- clip_y1 = y + height * scale;
+ if (clip.y0 < y)
+ clip.y0 = y;
+ if (clip.y1 > y + height * scale)
+ clip.y1 = y + height * scale;
}
/* valid clipping rectangles only */
- if ((clip_x0 < clip_x1) && (clip_y0 < clip_y1)) {
- if (!plot.clip(clip_x0, clip_y0,
- clip_x1, clip_y1))
+ if ((clip.x0 < clip.x1) && (clip.y0 < clip.y1)) {
+ if (!plot.clip(clip.x0, clip.y0,
+ clip.x1, clip.y1))
return false;
if (!content_redraw_tiled(box->background, x, y,
ceilf(width * scale),
ceilf(height * scale),
- clip_x0, clip_y0,
- clip_x1, clip_y1,
+ clip.x0, clip.y0,
+ clip.x1, clip.y1,
scale, *background_colour,
repeat_x, repeat_y))
return false;
12 years, 9 months