r12432 swdr - /trunk/netsurf/cocoa/apple_image.m
by netsurf@semichrome.net
Author: swdr
Date: Thu May 19 08:17:58 2011
New Revision: 12432
URL: http://source.netsurf-browser.org?rev=12432&view=rev
Log:
Reverting r12367, cannot get incremental image loading to work correctly.
Modified:
trunk/netsurf/cocoa/apple_image.m
Modified: trunk/netsurf/cocoa/apple_image.m
URL: http://source.netsurf-browser.org/trunk/netsurf/cocoa/apple_image.m?rev=1...
==============================================================================
--- trunk/netsurf/cocoa/apple_image.m (original)
+++ trunk/netsurf/cocoa/apple_image.m Thu May 19 08:17:58 2011
@@ -44,21 +44,16 @@
static nserror apple_image_clone(const struct content *old,
struct content **newc);
static content_type apple_image_content_type(lwc_string *mime_type);
-static bool apple_image_process_data(struct content *c, const char *data, unsigned int size);
static const content_handler apple_image_content_handler = {
.create = apple_image_create,
.data_complete = apple_image_convert,
- .process_data = apple_image_process_data,
.destroy = apple_image_destroy,
.redraw = apple_image_redraw,
.clone = apple_image_clone,
.type = apple_image_content_type,
.no_share = false
};
-
-static NSBitmapImageRep *ImageRepForContent( struct content *c );
-static NSData *DataForContent( struct content * c);
static nserror register_for_type( NSString *mime )
{
@@ -137,21 +132,22 @@
bool apple_image_convert(struct content *c)
{
- NSBitmapImageRep *image = ImageRepForContent( c );
- if (image == nil) return false;
-
- NSData *data = DataForContent( c );
-
- NSInteger rc = [image incrementalLoadFromData: data complete: YES];
- if (rc != NSImageRepLoadStatusCompleted) {
+ unsigned long size;
+ const char *bytes = content__get_source_data(c, &size);
+
+ NSData *data = [NSData dataWithBytesNoCopy: (char *)bytes length: size freeWhenDone: NO];
+ NSBitmapImageRep *image = [[NSBitmapImageRep imageRepWithData: data] retain];
+
+ if (image == nil) {
union content_msg_data msg_data;
- msg_data.error = "invalid image data";
+ msg_data.error = "cannot decode image";
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
return false;
}
c->width = [image pixelsWide];
c->height = [image pixelsHigh];
+ c->bitmap = (void *)image;
NSString *url = [NSString stringWithUTF8String: llcache_handle_get_url( content_get_llcache_handle( c ) )];
NSString *title = [NSString stringWithFormat: @"%@ (%dx%d)", [url lastPathComponent], c->width, c->height];
@@ -225,45 +221,4 @@
flags);
}
-bool apple_image_process_data(struct content *c, const char *newData, unsigned int newSize)
-{
- NSBitmapImageRep *image = ImageRepForContent( c );
- if (image == nil) return false;
-
- NSData *data = DataForContent( c );
-
- NSInteger rc = [image incrementalLoadFromData: data complete: NO];
- if (rc == NSImageRepLoadStatusInvalidData) {
- union content_msg_data msg_data;
- msg_data.error = "invalid data";
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- return false;
- }
-
- return true;
-}
-
-NSData *DataForContent( struct content * c)
-{
- unsigned long sz = 0;
- const char *bytes = content__get_source_data(c, &sz );
- return [NSData dataWithBytesNoCopy: (char *)bytes length: sz freeWhenDone: NO];
-}
-
-NSBitmapImageRep *ImageRepForContent( struct content *c )
-{
- NSBitmapImageRep *image = (NSBitmapImageRep *)c->bitmap;
- if (image == nil) {
- image = [[NSBitmapImageRep alloc] initForIncrementalLoad];
- if (image == nil) {
- union content_msg_data msg_data;
- msg_data.error = "not enough memory for image";
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- }
- c->bitmap = (void *)image;
- }
- return image;
-}
-
-
#endif /* WITH_APPLE_IMAGE */
11 years, 8 months
r12430 swdr - /trunk/netsurf/cocoa/NetsurfApp.m
by netsurf@semichrome.net
Author: swdr
Date: Thu May 19 06:47:53 2011
New Revision: 12430
URL: http://source.netsurf-browser.org?rev=12430&view=rev
Log:
Replacing deprecated method createDirectoryAtPath:attributes: with non-deprecated version createDirectoryAtPath:withIntermediateDirectories:attributes:error:
Modified:
trunk/netsurf/cocoa/NetsurfApp.m
Modified: trunk/netsurf/cocoa/NetsurfApp.m
URL: http://source.netsurf-browser.org/trunk/netsurf/cocoa/NetsurfApp.m?rev=12...
==============================================================================
--- trunk/netsurf/cocoa/NetsurfApp.m (original)
+++ trunk/netsurf/cocoa/NetsurfApp.m Thu May 19 06:47:53 2011
@@ -121,7 +121,7 @@
BOOL exists = [fm fileExistsAtPath: netsurfPath isDirectory: &isDirectory];
if (!exists) {
- exists = [fm createDirectoryAtPath: netsurfPath attributes: nil];
+ exists = [fm createDirectoryAtPath: netsurfPath withIntermediateDirectories: YES attributes: nil error: NULL];
isDirectory = YES;
}
if (!(exists && isDirectory)) {
11 years, 8 months
r12429 swdr - /trunk/netsurf/cocoa/DownloadWindowController.m
by netsurf@semichrome.net
Author: swdr
Date: Thu May 19 02:27:21 2011
New Revision: 12429
URL: http://source.netsurf-browser.org?rev=12429&view=rev
Log:
Adding quarantine attributes to downloaded files.
Modified:
trunk/netsurf/cocoa/DownloadWindowController.m
Modified: trunk/netsurf/cocoa/DownloadWindowController.m
URL: http://source.netsurf-browser.org/trunk/netsurf/cocoa/DownloadWindowContr...
==============================================================================
--- trunk/netsurf/cocoa/DownloadWindowController.m (original)
+++ trunk/netsurf/cocoa/DownloadWindowController.m Thu May 19 02:27:21 2011
@@ -21,6 +21,7 @@
#import "desktop/download.h"
#import "desktop/gui.h"
+#import "utils/log.h"
@interface DownloadWindowController ()
@@ -103,6 +104,17 @@
NSString *path = [targetURL path];
[[NSFileManager defaultManager] createFileAtPath: path contents: nil attributes: nil];
+
+ FSRef ref;
+ if (CFURLGetFSRef( (CFURLRef)targetURL, &ref )) {
+ NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
+ url, (NSString *)kLSQuarantineDataURLKey,
+ (NSString *)kLSQuarantineTypeWebDownload, (NSString *)kLSQuarantineTypeKey,
+ nil];
+ LSSetItemAttribute( &ref, kLSRolesAll, kLSItemQuarantineProperties, (CFDictionaryRef)attributes );
+ LOG(("Set quarantine attributes on file %s", [path UTF8String]));
+ }
+
[self setOutputFile: [NSFileHandle fileHandleForWritingAtPath: path]];
[self setSaveURL: targetURL];
11 years, 8 months
r12428 mmu_man - in /branches/mmu_man/netsurf-gopher-support-v2/content: gopher.c gopher.h
by netsurf@semichrome.net
Author: mmu_man
Date: Wed May 18 18:25:48 2011
New Revision: 12428
URL: http://source.netsurf-browser.org?rev=12428&view=rev
Log:
Add a gopher item type 'M' for MIME encoded data, not widely used though.
Fix warnings. Comment out debug output. Fix remaining magic chars.
Modified:
branches/mmu_man/netsurf-gopher-support-v2/content/gopher.c
branches/mmu_man/netsurf-gopher-support-v2/content/gopher.h
Modified: branches/mmu_man/netsurf-gopher-support-v2/content/gopher.c
URL: http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support-v2/content/gopher.c (original)
+++ branches/mmu_man/netsurf-gopher-support-v2/content/gopher.c Wed May 18 18:25:48 2011
@@ -108,10 +108,10 @@
size_t gopher_fetch_data(struct gopher_state *s, char *data, size_t size)
{
char buffer[1024];
- char *p = data;
+ const char *p = data;
size_t remaining = size;
size_t left;
- fprintf(stderr, "%s(,, %d)\n", __FUNCTION__, size);
+ /*fprintf(stderr, "%s(,, %d)\n", __FUNCTION__, size);*/
/* actually called when done getting it all */
if (size == 0)
@@ -133,7 +133,7 @@
* than the input buffer...
*/
-fprintf(stderr, "iteration: cached %d remaining %d\n", s->cached, remaining);
+ /*fprintf(stderr, "iteration: cached %d remaining %d\n", s->cached, remaining);*/
p = s->input;
left = MIN(sizeof(s->input) - s->cached, remaining);
@@ -143,7 +143,7 @@
s->cached += left;
left = s->cached;
-fprintf(stderr, "copied: cached %d remaining %d\n", s->cached, remaining);
+ /*fprintf(stderr, "copied: cached %d remaining %d\n", s->cached, remaining);*/
if (!s->head_done)
{
@@ -172,13 +172,13 @@
while (gopher_generate_row(&p, &left, buffer, sizeof(buffer)))
{
-//fprintf(stderr, "done row, left %d\n", left);
+ /*fprintf(stderr, "done row, left %d\n", left);*/
/* send data to the caller */
/*LOG(("FETCH_DATA"));*/
fetch_send_callback(FETCH_DATA, s->fetch_handle, buffer,
strlen(buffer), FETCH_ERROR_NO_ERROR);
}
-fprintf(stderr, "last row, left %d\n", left);
+ /*fprintf(stderr, "last row, left %d\n", left);*/
/* move the remainder to the beginning of the buffer */
if (left)
@@ -190,9 +190,10 @@
}
-static char *html_escape_string(char *str)
-{
- char *nice_str, *cnv, *tmp;
+static char *html_escape_string(const char *str)
+{
+ char *nice_str, *cnv;
+ const char *tmp;
if (str == NULL) {
return NULL;
@@ -234,7 +235,6 @@
static char *gen_nice_title(const char *path)
{
- const char *tmp;
char *nice_path;
char *title;
int title_length;
@@ -269,7 +269,7 @@
* \return MIME type string
*/
-const char *gopher_type_to_mime(char type)
+const char *gopher_type_to_mime(gopher_item_type type)
{
int i;
@@ -287,11 +287,11 @@
*
*/
-bool gopher_need_generate(char type)
+bool gopher_need_generate(gopher_item_type type)
{
switch (type) {
- case '1':
- case '7':
+ case GOPHER_TYPE_DIRECTORY:
+ case GOPHER_TYPE_QUERY:
return true;
default:
return false;
Modified: branches/mmu_man/netsurf-gopher-support-v2/content/gopher.h
URL: http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support-v2/content/gopher.h (original)
+++ branches/mmu_man/netsurf-gopher-support-v2/content/gopher.h Wed May 18 18:25:48 2011
@@ -53,6 +53,9 @@
/* not standardized, some servers use them */
GOPHER_TYPE_PDF = 'd', /* seems to be only for PDF files */
GOPHER_TYPE_PNG = 'p' /* cf. gopher://namcub.accelera-labs.com/1/pics */
+ GOPHER_TYPE_MIME = 'M' /* multipart/mixed MIME data */
+ /* cf. http://www.pms.ifi.lmu.de/mitarbeiter/ohlbach/multimedia/IT/IBMtutorial/3... */
+ /* cf. http://nofixedpoint.motd.org/2011/02/22/an-introduction-to-the-gopher-pro... */
} gopher_item_type;
struct gopher_state {
@@ -70,8 +73,8 @@
size_t gopher_fetch_data(struct gopher_state *s, char *data, size_t size);
-const char *gopher_type_to_mime(char type);
-bool gopher_need_generate(char type);
+const char *gopher_type_to_mime(gopher_item_type type);
+bool gopher_need_generate(gopher_item_type type);
#endif
11 years, 8 months
r12427 tlsa - /trunk/netsurf/render/box_construct.c
by netsurf@semichrome.net
Author: tlsa
Date: Wed May 18 11:01:02 2011
New Revision: 12427
URL: http://source.netsurf-browser.org?rev=12427&view=rev
Log:
Remove box_applet.
Modified:
trunk/netsurf/render/box_construct.c
Modified: trunk/netsurf/render/box_construct.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/box_construct.c?re...
==============================================================================
--- trunk/netsurf/render/box_construct.c (original)
+++ trunk/netsurf/render/box_construct.c Wed May 18 11:01:02 2011
@@ -96,7 +96,6 @@
static bool box_object(BOX_SPECIAL_PARAMS);
static bool box_embed(BOX_SPECIAL_PARAMS);
static bool box_pre(BOX_SPECIAL_PARAMS);
-/*static bool box_applet(BOX_SPECIAL_PARAMS);*/
static bool box_iframe(BOX_SPECIAL_PARAMS);
static bool box_get_attribute(xmlNode *n, const char *attribute,
void *context, char **value);
@@ -110,7 +109,6 @@
};
static const struct element_entry element_table[] = {
{"a", box_a},
-/* {"applet", box_applet},*/
{"body", box_body},
{"br", box_br},
{"button", box_button},
@@ -1320,144 +1318,6 @@
*convert_children = false;
return true;
}
-
-
-#if 0 /**
- * "Java applet" [13.4].
- *
- * \todo This needs reworking to be compliant to the spec
- * For now, we simply ignore all applet tags.
- */
-
-struct box_result box_applet(xmlNode *n, struct box_status *status,
- struct css_style *style)
-{
- struct box *box;
- struct object_params *po;
- struct object_param *pp = NULL;
- char *s;
- xmlNode *c;
-
- po = calloc(1, sizeof(struct object_params));
- if (!po)
- return (struct box_result) {0, false, true};
-
- box = box_create(style, false, status->href, 0, status->id,
- status->content->data.html.box_pool);
- if (!box) {
- free(po);
- return (struct box_result) {0, false, true};
- }
-
- /* archive */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "archive")) != NULL) {
- /** \todo tokenise this comma separated list */
- LOG(("archive '%s'", s));
- po->data = strdup(s);
- xmlFree(s);
- if (!po->data)
- goto no_memory;
- }
- /* code */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "code")) != NULL) {
- LOG(("applet '%s'", s));
- po->classid = strdup(s);
- xmlFree(s);
- if (!po->classid)
- goto no_memory;
- }
-
- /* object codebase */
- if ((s = (char *) xmlGetProp(n, (const xmlChar *) "codebase")) != NULL) {
- po->codebase = strdup(s);
- LOG(("codebase: %s", s));
- xmlFree(s);
- if (!po->codebase)
- goto no_memory;
- }
-
- /* parameters
- * parameter data is stored in a singly linked list.
- * po->params points to the head of the list.
- * new parameters are added to the head of the list.
- */
- for (c = n->children; c != 0; c = c->next) {
- if (c->type != XML_ELEMENT_NODE)
- continue;
-
- if (strcmp((const char *) c->name, "param") == 0) {
- pp = calloc(1, sizeof(struct object_param));
- if (!pp)
- goto no_memory;
-
- if ((s = (char *) xmlGetProp(c,
- (const xmlChar *) "name")) != NULL) {
- pp->name = strdup(s);
- xmlFree(s);
- if (!pp->name)
- goto no_memory;
- }
- if ((s = (char *) xmlGetProp(c,
- (const xmlChar *) "value")) != NULL) {
- pp->value = strdup(s);
- xmlFree(s);
- if (!pp->value)
- goto no_memory;
- }
- if ((s = (char *) xmlGetProp(c,
- (const xmlChar *) "type")) != NULL) {
- pp->type = strdup(s);
- xmlFree(s);
- if (!pp->type)
- goto no_memory;
- }
- if ((s = (char *) xmlGetProp(c, (const xmlChar *)
- "valuetype")) != NULL) {
- pp->valuetype = strdup(s);
- xmlFree(s);
- if (!pp->valuetype)
- goto no_memory;
- } else {
- pp->valuetype = strdup("data");
- if (!pp->valuetype)
- goto no_memory;
- }
-
- pp->next = po->params;
- po->params = pp;
- } else {
- /* The first non-param child is the start
- * of the alt html. Therefore, we should
- * break out of this loop.
- */
- break;
- }
- }
-
- box->object_params = po;
-
- /* start fetch */
- if (plugin_decode(status->content, box))
- return (struct box_result) {box, false, false};
-
- return (struct box_result) {box, true, false};
-
-no_memory:
- if (pp && pp != po->params) {
- /* ran out of memory creating parameter struct */
- free(pp->name);
- free(pp->value);
- free(pp->type);
- free(pp->valuetype);
- free(pp);
- }
-
- box_free_object_params(po);
- box_free_box(box);
-
- return (struct box_result) {0, false, true};
-}
-#endif
/**
11 years, 8 months
r12425 tlsa - /trunk/netsurf/desktop/scrollbar.c
by netsurf@semichrome.net
Author: tlsa
Date: Tue May 17 04:05:49 2011
New Revision: 12425
URL: http://source.netsurf-browser.org?rev=12425&view=rev
Log:
Purge unused variable.
Modified:
trunk/netsurf/desktop/scrollbar.c
Modified: trunk/netsurf/desktop/scrollbar.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/scrollbar.c?rev=1...
==============================================================================
--- trunk/netsurf/desktop/scrollbar.c (original)
+++ trunk/netsurf/desktop/scrollbar.c Tue May 17 04:05:49 2011
@@ -189,7 +189,7 @@
const struct rect *clip, float scale)
{
int w = SCROLLBAR_WIDTH;
- int well_length, bar_pos, bar_c0, bar_c1;
+ int bar_pos, bar_c0, bar_c1;
int v[6]; /* array of triangle vertices */
int x0, y0, x1, y1;
@@ -206,7 +206,6 @@
.fill_colour = scrollbar_widget_arrow_colour,
};
- well_length = s->length - 2 * SCROLLBAR_WIDTH;
x0 = x;
y0 = y;
x1 = x + (s->horizontal ? s->length : SCROLLBAR_WIDTH) - 1;
@@ -217,7 +216,6 @@
if (scale != 1.0) {
w *= scale;
- well_length *= scale;
x0 *= scale;
y0 *= scale;
x1 *= scale;
11 years, 8 months
r12423 jmb - /trunk/netsurf/render/hubbub_binding.c
by netsurf@semichrome.net
Author: jmb
Date: Mon May 16 17:30:27 2011
New Revision: 12423
URL: http://source.netsurf-browser.org?rev=12423&view=rev
Log:
Add some parentheses
Modified:
trunk/netsurf/render/hubbub_binding.c
Modified: trunk/netsurf/render/hubbub_binding.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/hubbub_binding.c?r...
==============================================================================
--- trunk/netsurf/render/hubbub_binding.c (original)
+++ trunk/netsurf/render/hubbub_binding.c Mon May 16 17:30:27 2011
@@ -468,12 +468,12 @@
xmlDoc *n = (xmlDoc *) node;
uintptr_t count = (uintptr_t) n->_private;
- n->_private = (void *) ++count;
+ n->_private = (void *) (++count);
} else {
xmlNode *n = (xmlNode *) node;
uintptr_t count = (uintptr_t) n->_private;
- n->_private = (void *) ++count;
+ n->_private = (void *) (++count);
}
return HUBBUB_OK;
@@ -489,14 +489,14 @@
assert(count != 0 && "Node has refcount of zero");
- n->_private = (void *) --count;
+ n->_private = (void *) (--count);
} else {
xmlNode *n = (xmlNode *) node;
uintptr_t count = (uintptr_t) n->_private;
assert(count != 0 && "Node has refcount of zero");
- n->_private = (void *) --count;
+ n->_private = (void *) (--count);
if (count == 0 && n->parent == NULL) {
xmlFreeNode(n);
11 years, 8 months