Recent

Author Topic: Lazbro v0.1 (A new Lazarus only HTML Viewer)  (Read 15459 times)

derek.john.evans

  • Guest
Lazbro v0.1 (A new Lazarus only HTML Viewer)
« on: October 29, 2014, 05:05:28 pm »
For some reason, I felt like writing a new HTML viewer which is 100% Lazarus based. The result is about ~1300 lines of code, all in one unit file.

You can download the control + a demo app from here:
http://www.wascal.net/bin/lazbro0.1.zip

It handles just about everything needed for basic HTML viewing. At this stage, feel free to hack the code, since, I'm unsure what I will do with it.

Cheers

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #1 on: October 29, 2014, 06:02:02 pm »
Good work. Excelent library. Simple and easy to use.
Maybe more documentation would be better
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

benohb

  • Full Member
  • ***
  • Posts: 213
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #2 on: October 29, 2014, 06:17:59 pm »
Great work  :D

Quote
Project Lazbro - Portable HTML Browser raised exception class 'External: SIGSEGV'.


debian - gtk 32 bit


 

qdos

  • Full Member
  • ***
  • Posts: 112
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #3 on: October 29, 2014, 10:04:57 pm »
Nice!

Any chance for CSS and webkit transformation support?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #4 on: October 30, 2014, 05:39:56 am »
Nice. Have you tested how compliant it is with the standard?

esvignolo

  • Full Member
  • ***
  • Posts: 159
  • Using FPC in Windows, Linux, Macos
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #5 on: October 30, 2014, 06:20:10 am »
Great! Work on MacOS too, but have the same exception on debug.



Great work  :D

Quote
Project Lazbro - Portable HTML Browser raised exception class 'External: SIGSEGV'.


debian - gtk 32 bit

derek.john.evans

  • Guest
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #6 on: October 30, 2014, 08:22:12 am »
Quote
Any chance for CSS and webkit transformation support?

CSS, yes. webkit? Unsure what that is. But, I should have <STYLE> tags working in the next release. How this works is, in the function procedure ElementStandardize(const ANode: TDOMElement);  , I copy standard attributes to custom attributes, which then map to Lazarus control properties. eg: "style:font-family" is copied to "_Font.Name" onloading which then is assigned to the property using RTTI. So, to implement a STYLE tag, I would traverse back down the DOM tree, parsing each STYLE block, and coping values to the current node.

Quote
Nice. Have you tested how compliant it is with the standard?
I'd say its not very compliant. As described above, the design is tied to control properties, and currently im using the default Lazarus controls. The first stage will be to work on the ElementStandardize(), to try to get it as close as possible. The next stage would be to use extended controls with properties which implement missing features. eg: border styles for each edge of a control.

But, the main compliant  issue ATM is SAX_HTML & DOM_HTML, which is based on DOM. (Standard FreePascal libraries). Malformed HTML is not parsed at all, so, im unsure what todo about that. Either, wait for someone to update DOM_HTML, or try to fix it myself, or write my own HTML parser, or just ignore the issue.

Anyway. Im sure this will improve over time.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #7 on: October 30, 2014, 12:03:29 pm »
The Lazarus html help (CHM, which is archived and indexed html) viewer uses a IPRO for viewing, and any improvement there would be good.

The ipro layout is uglier than of a normal browser and it is nearly completely textual layout.  Seeing if LazBro would improve layout relative to ipro would be a great (and simple) test.

(if you don't want to patch the helpviewer to test, you can simply extract one of the CHM help files and use the generated html)
« Last Edit: October 30, 2014, 01:56:06 pm by marcov »

matthius

  • Full Member
  • ***
  • Posts: 155
  • Creating VRAD...
    • LIBERLOG - Développement rapide
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #8 on: November 11, 2014, 03:28:12 pm »
Your source need to add {$mode objfpc}{$H+} after unit lazbro;

It will be added to my entirely free LGPL project Ancestromania :
http://genealogie.liberlog.fr/Family-trees

Thank you !
M. GIROUX
13 rue Tanguy PRIGENT
35000 RENNES - France
(33)(0)2 23 46 06 54
http://liberlog.fr

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #9 on: November 12, 2014, 02:55:57 pm »
Works fine on MacOS.  One question.
Is it possible to only load a page until for example the last </table>?

Code: [Select]
.......
.......
</td>
</tr>
</table>
Only load until here, discard the rest

<!--
NewPP limit report
Parsed by mw1001
.......
.......


If I download the HTML I can parse the file, but then I loose the online pictures, but is it also possible to parse the stream before Lazbro parse it?
Be the difference that makes a difference

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #10 on: November 13, 2014, 05:05:54 pm »
One more question:

Is it possible to use Lazbro in a seperate thread?

Code: [Select]
procedure TWikiInfoThread.Execute;
begin
  Form1.FLazbro.LoadFromUrl('http://en.m.wikipedia.org/wiki/U2');
end;

crashes.

using:

Code: [Select]
procedure TWikiInfoThread.ShowMe;
begin
  Form1.FLazbro.LoadFromUrl('http://en.m.wikipedia.org/wiki/U2'));
end;

procedure TWikiInfoThread.Execute;
begin
  Synchronize(@ShowMe);
end;   

works, but it hangs while loading, just like running a not threaded procedure.
Wikipedia uses a lot of linked items, and that seems to take a lot of time.
Be the difference that makes a difference

Dibo

  • Hero Member
  • *****
  • Posts: 1048
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #11 on: November 13, 2014, 07:55:29 pm »
Great work! Tested on Kubuntu 14.04 64bit (Qt widgetset)

Few issues:
1. This html loaded by LoadFromString:
Code: Pascal  [Select][+][-]
  1. const
  2.   sHTML =
  3.     '<HTML>'+
  4.     '<HEAD>'+
  5.     '<TITLE>Lazbro v0.4 - A Portable HTML Viewer for Lazarus</TITLE>'+
  6.     '</HEAD>'+
  7.     '<BODY bgcolor="#ddffaa">'+
  8.     '<table border=1>'+
  9.     '<tr><td>Test1</td></tr>'+
  10.     '<tr><td>Test2</td></tr>'+
  11.     '<tr><td>Test3</td></tr>'+
  12.     '</table>'+
  13.     '</BODY>'+
  14.     '</HTML>';  
  15.  
... raise exception in my new empty project. When copy this HTML into your demo then it is working fine  :(
Exception is rised in line 1033 with message ""100%" is invalid integer". This is my simple code:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   FBro := TLazbro.Create(Self);
  4.   FBro.Align := alClient;
  5.   FBro.Parent := TabSheetBrowser;
  6. end;  
  7.  
  8. procedure TForm1.FormShow(Sender: TObject);
  9. begin
  10.   FBro.LoadFromString(sHTML,'');
  11. end;  
  12.  

2. How to add border in <TABLE> tag?
3. Can I change content in runtime without reparsing and rendering whole HTML? For example, I would like to add new <TR> row in table. Can I find table in THTMLDocument object and add TD object at runtime?

Regards

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #12 on: November 14, 2014, 09:58:50 am »
Hi,

&#8217;  -   &#8220;   -  &#8221;   do not render to " and '

So I have to add:
Code: [Select]
temp1:=StringReplace(temp1,'&#8217;','''',[rfReplaceAll, rfIgnoreCase]);
temp1:=StringReplace(temp1,'&#8220;','"',[rfReplaceAll, rfIgnoreCase]);
temp1:=StringReplace(temp1,'&#8221;','"',[rfReplaceAll, rfIgnoreCase]);


Any idea where these should be added to work in general ?

Thanks again for your great work and sharing it with us.
Be the difference that makes a difference

derek.john.evans

  • Guest
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #13 on: November 14, 2014, 03:24:37 pm »
Quote
Any idea where these should be added to work in general ?

Im unsure atm. Im currently working on the next version of Lazbro, which will be a big step forward. I now have a set of HTML style controls which support more advanced styles. I'll take note of comments posted here and fix issues over the next few weeks.

Cheers.

Zittergie

  • Full Member
  • ***
  • Posts: 114
    • XiX Music Player
Re: Lazbro v0.1 (A new Lazarus only HTML Viewer)
« Reply #14 on: August 07, 2015, 08:58:24 pm »
Hi,
I see you are back active in the forum.  Are there any changes coming for Lazbro?

Greetz,
Zittergie
Be the difference that makes a difference

 

TinyPortal © 2005-2018