discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SimpleWebKit (was GNUstep Web browser (was Re: WebKit Bounty))


From: Dr . H . Nikolaus Schaller
Subject: Re: SimpleWebKit (was GNUstep Web browser (was Re: WebKit Bounty))
Date: Mon, 12 Mar 2007 07:55:04 +0100

Peter,

Am 07.03.2007 um 14:55 schrieb Peter Cooper:

Basically the approach is to parse HTML into a DOM tree (DOMHTML.h) -
exactly as KHTML/WebKit does. Then, rendering is done top down from
the WebHTMLView which has a single child, an NSTextView and the root
of the DOM tree. The NSTextView finally renders an attributedString
(well, an NSTextStorage), that is built from the DOM Tree. I.e.
building this attributedString does half of the work and the other
one is NSTextView.

Ok. And the rendering activity may create additional subviews? I can see this being useful for optimisations to make fast fluid-layout redrawing with the CSS box model possible. It'd be nice not to have to re- render the
entire document everytime the view is resized ;-)

It is pretty fast on a Mac. Apparently needs just some milliseconds to do
all that work.

View resizing does not need to re-render anything. Rendering geometry is currently done in the NSTextView. But I don't know if that changes by the CSS box model.

This allows the trick for NSAttributedString(Additions) to fetch the
attributedString out of the WebView to e.g. convert to RTF.

Yup.

Now, adding CSS would be a similar approach. Either, the CSS
description must load from a separate file first, or it is included
in the DOM tree as <style> tags. So, the first step would be to parse
the CSS into an DOMCSS tree. As soon as this is available, the DOM to
attributedString conversion can use it to return a well formatted
string. Finished loading of an external CSS must trigger the
rendering to be repeated since layout and style may have changed.
This is a bahaviour that you can see sometimes with Safari on a slow
connection - firstly, you get a page with raw text and then the
background, tables, images and formats come in.

Cool. Do you want me to do translation of the DOM level 2 IDL files into objc headers using the same approach (compatible names) as WebKit? Should
be achievable before the weekend.

That would be nice!

You can base the DOMCSSxxx.h files and classes by including DOMCore.h
And, you need to create a WebCSSDocumentRepresentation class that handles getting the file in NSData fragments when the CSS is loaded from an external source. It should try to parse it as good as possible since the file may be incomplete. You can take WebHTMLDocumentRepresentation as a sample.

The basic process for loading from external resources works as follows:
* a <link> element tells the HTML engine that it has to load an external CSS
* it creates a new WebDataSource for it
* that one opens an NSURLConnection
* as soon as it is clear that it is a CSS resource, a new WebCSSDocumentRepresentation is opened * that one receives the new data from the NSURLConnection through - (void) receivedData:(NSData *) data withDataSource:(WebDataSource *) source;

What the HTML parser also needs to have is some -initWithString: to directly handle the style attribute and <style> tag with inline CSS. Well, it could also create a WebDataSource with a given NSData source and go the standard way as described above but a shortcut would be nice IMHO.

Finally, there must be a query method to find the style attributes for a given tuple of (tag, tagpath, id, class).

Hope this works as you have intended...

Nikolaus




reply via email to

[Prev in Thread] Current Thread [Next in Thread]