Is there a CSS parser in FPC?

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Is there a CSS parser in FPC?

Graeme Geldenhuys-6
Hi,

As the subject says, I would like to know if there is a CSS parser
included with FPC (2.6.4 or Trunk)? No issue if there isn't, as I might
not initially need one for the project I want to start - but looking
around in the mean time wouldn't hurt.

I'm thinking of writing a couple of articles documenting a pet project I
have been meaning to do for some time. Writing a "toy" web browser
engine. I don't think many people actually know what is involved in a
browser engine, or the rendering pipeline. So documenting the process
from scratch should be a good learning experience for many (myself
included). I want to initially limit as much dependencies as possible,
and obviously simplify it for the articles, but at the same time make it
so various rasterizers (AggPas, OpenGL, fpGUI Canvas, LCL Canvas, Image
file output etc) can be plugged in for the final output.

What's your thoughts? Who knows, this project might even grow to become
something useful for fpGUI or LCL based apps. But that is far down the
road for now.

Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Is there a CSS parser in FPC?

Michael Van Canneyt


On Tue, 3 Mar 2015, Graeme Geldenhuys wrote:

> Hi,
>
> As the subject says, I would like to know if there is a CSS parser
> included with FPC (2.6.4 or Trunk)? No issue if there isn't, as I might
> not initially need one for the project I want to start - but looking
> around in the mean time wouldn't hurt.

FPC doesn't contain one, but I would be glad to put one in the source tree.

> I'm thinking of writing a couple of articles documenting a pet project I
> have been meaning to do for some time. Writing a "toy" web browser
> engine. I don't think many people actually know what is involved in a
> browser engine, or the rendering pipeline. So documenting the process
> from scratch should be a good learning experience for many (myself
> included). I want to initially limit as much dependencies as possible,
> and obviously simplify it for the articles, but at the same time make it
> so various rasterizers (AggPas, OpenGL, fpGUI Canvas, LCL Canvas, Image
> file output etc) can be plugged in for the final output.
>
> What's your thoughts? Who knows, this project might even grow to become
> something useful for fpGUI or LCL based apps. But that is far down the
> road for now.

Presumably the HTML browser of TurboPower IP included in lazarus has a CSS parser.
Maybe you can have a look at it.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Is there a CSS parser in FPC?

dev.dliw
In reply to this post by Graeme Geldenhuys-6
Hi,

you might also want to take a look at https://code.google.com/p/thtmlviewer

It's still actively developed, so the CSS parser should be more advanced than
the one of TurboPower IP.

dliw
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Is there a CSS parser in FPC?

Graeme Geldenhuys-6
In reply to this post by Michael Van Canneyt
On 2015-03-03 14:33, Michael Van Canneyt wrote:
>
> FPC doesn't contain one, but I would be glad to put one in the source tree.

Thanks for the info. Closer to the time I'll let you know so you can
decide if the code is worthy of finding a home in FCL. ;-)


> Presumably the HTML browser of TurboPower IP included in lazarus has a CSS parser.
> Maybe you can have a look at it.

Thanks. CSS (1 & 2 at least) actually seem a lot easier to parse that
HTML. I'll take a look, but probably just roll my own.


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Is there a CSS parser in FPC?

Graeme Geldenhuys-6
In reply to this post by dev.dliw
On 2015-03-03 16:13, [hidden email] wrote:
>
> you might also want to take a look at https://code.google.com/p/thtmlviewer

Thanks for the info. I see it is a descendant of PBear.com code. I
remember using that back in 1998. :)


> It's still actively developed, so the CSS parser should be more advanced than
> the one of TurboPower IP.

I took a quick look at the code in general and was truly disappointed.
Quick examples:

===========[HtmlImages.pas]====================
uses
{$ifdef LCL}
  LclIntf, IntfGraphics, FpImage, LclType, LResources, LMessages, HtmlMisc,
{$else}
  Windows, Jpeg,
{$endif}
  SysUtils, Classes, Graphics, Forms,
  Controls,
===============================

...or...

===========[HTMLSubs.pas]====================
uses
 {$ifdef UseInline}
 HtmlCaches,
 {$endif}
{$ifdef VCL}
  Windows,
  {$ifndef Compiler28_Plus}
  EncdDecd,
  {$endif}
{$endif}
  Messages, Graphics, Controls, ExtCtrls, Classes, SysUtils, Variants,
Forms, Math, Contnrs, ComCtrls,
{$ifdef LCL}
  LclIntf, LclType, HtmlMisc, types,
{$endif}
  HtmlGlobals,
===============================

...or...

===========[ReadHTML.pas]====================
uses
{$ifdef LCL}
  LclIntf, LclType, HtmlMisc,
{$else}
  Windows,
{$endif}
  SysUtils, Math, Variants, Classes, Graphics, Controls, Contnrs,
  HtmlGlobals,
===============================


Those dependencies are crazy! LCLIntf, Forms, Graphics, Controls,
Windows (???) all in a unit that just reads and parses HTML. Wow.

Sadly TurboPower IP doesn't look any better - at least the version
included with Lazarus.

My plan is to develop a 100% non-GUI-toolkit-dependent browser engine,
which is 100% doable. The only (optional) GUI toolkit dependency would
be the rasterizer integration for LCL or fpGUI - the last step in the
engine pipeline. But if you render to an image file for example (via
FPImage or AggPas), their would be no GUI toolkit dependency.


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Is there a CSS parser in FPC?

dmitry boyarintsev
On Tue, Mar 3, 2015 at 12:55 PM, Graeme Geldenhuys <[hidden email]> wrote:
My plan is to develop a 100% non-GUI-toolkit-dependent browser engine,
which is 100% doable. The only (optional) GUI toolkit dependency would
be the rasterizer integration for LCL or fpGUI - the last step in the
engine pipeline.
Can it be the last step?  You need to get font information somehow for text measurements, which should come from the "underlying" GUI toolkit only.
I can understand that you'd create some sort of wrapper class (that would be implemented by a gui toolkit), but I doubt it could be done as the actual last step.

thanks,
Dmitry

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Is there a CSS parser in FPC?

Graeme Geldenhuys-6
On 2015-03-03 17:59, Dmitry Boyarintsev wrote:
> Can it be the last step?  You need to get font information somehow for text
> measurements, which should come from the "underlying" GUI toolkit only.

Yes, and no problem either. FreeType (library or Object Pascal
implementation) doesn't require a GUI toolkit. Well, the library for
sure, I'll have to double check the Object Pascal implementation. eg: I
use AggPas with the FreeType text renderer to generate images of graphs
with text via a CGI or console app. 100% non GUI.

For example:
  http://fpgui.sourceforge.net/images/full/fpgui_agg-powered.png

Other than displaying that image (one image the full size of the window)
via fpGUI - the actual content of the image can be done 100% via a
console app using AggPas.


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Is there a CSS parser in FPC?

dmitry boyarintsev
On Tue, Mar 3, 2015 at 1:09 PM, Graeme Geldenhuys <[hidden email]> wrote:
Yes, and no problem either. FreeType (library or Object Pascal
implementation) doesn't require a GUI toolkit.
Hmm. I didn't consider that as an option.
Ok, can it handle complex scripts languages such as Arabic or Hindi?

thanks,
Dmitry


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Is there a CSS parser in FPC?

Graeme Geldenhuys-6
On 2015-03-03 18:18, Dmitry Boyarintsev wrote:
> Ok, can it handle complex scripts languages such as Arabic or Hindi?

FreeText is the primary text renderer for X11. So if Linux can display
such text, then I guess it answers your question. ;-)

The primary goal of this project is to document how a browser engine
works. During the writing of the articles I'll implement basic block
layout and text rendering. CSS rules will be the primary method of
sizing, positioning. I'll also implement some CSS rules to manipulate
DIV and text attributes (font and color (including alpha support). I'll
probably use AggPas as the reference implementation of a rasterizer.
This should conclude what I want to accomplish.

What happens then... I don't know yet. :)  Maybe tackle the
http://css3test.com/ test suite. :-P

Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Is there a CSS parser in FPC?

Andrew Haines
In reply to this post by Graeme Geldenhuys-6
On 03/03/2015 07:41 AM, Graeme Geldenhuys wrote:

> Hi,
>
> As the subject says, I would like to know if there is a CSS parser
> included with FPC (2.6.4 or Trunk)? No issue if there isn't, as I might
> not initially need one for the project I want to start - but looking
> around in the mean time wouldn't hurt.
>
> I'm thinking of writing a couple of articles documenting a pet project I
> have been meaning to do for some time. Writing a "toy" web browser
> engine. I don't think many people actually know what is involved in a
> browser engine, or the rendering pipeline. So documenting the process
> from scratch should be a good learning experience for many (myself
> included). I want to initially limit as much dependencies as possible,
> and obviously simplify it for the articles, but at the same time make it
> so various rasterizers (AggPas, OpenGL, fpGUI Canvas, LCL Canvas, Image
> file output etc) can be plugged in for the final output.
>
> What's your thoughts? Who knows, this project might even grow to become
> something useful for fpGUI or LCL based apps. But that is far down the
> road for now.
>
> Regards,
>    - Graeme -
>
As Michael said the turbopower ipro component has a css parser. It was
added for lazarus/lhelp and wasn't part of the original ipro component
so it's mostly separated from ipro.
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/components/turbopower_ipro/ipcss.inc?view=markup&revision=44873&root=lazarus

Regards,

Andrew Haines
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Is there a CSS parser in FPC?

Graeme Geldenhuys-6
On 2015-03-05 14:47, Andrew Haines wrote:
> It was
> added for lazarus/lhelp and wasn't part of the original ipro component
> so it's mostly separated from ipro.

Thank you Andrew. I'll take a second look.


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal