[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Fw: using KHTML without display
From: Jason K <fungmeista () gmail ! com>
Date: 2005-04-27 19:04:28
Message-ID: 1c3eeca805042712041c4093ff () mail ! gmail ! com
[Download RAW message or body]
I've asked about this before, and still gotten no response :( It
sounds like you can't do it, but still, I haven't gotten anyone to
tell me even that much.
To get just the height (not a Rect), as a hack, Krecipes writes a
single element to a KHTMLPart, and then calls:
part->view()->show(); //worked fine without this until KDE 3.4
part->view()->layout();
and then gets the height with
part->view() ->contentsHeight();
It's not a pretty solution, but I'm stumped :-P
-Jason K
On 4/27/05, Nom Declavier <achats@blarg.net> wrote:
> The message below appeared on kde-devel for a few days. No one responded.
> It's recently been removed. Would it be possible to put it back on the list,
> on the chance that someone will respond?
>
> Thanks.
>
> ----- Original Message -----
> From: Nom Declavier
> To: kde-devel@mail.kde.org
> Sent: Wednesday, April 20, 2005 10:48 AM
> Subject: using KHTML without display
>
> I'd like to use KHTML to parse HTML/CSS/Javascript, and to deduce the
> sizes and positions of Web page constituents when the page is rendered
> by a KHTML-based browser. But I want to do this without actually
> rendering to any screen, and without invoking more browser functionality
> than I need. My planned application has no graphical user interface. It
> brings about no display. It's all about trees whose nodes may be
> annotated with size and position information. I expect to call getRect()
> frequently.
>
> So what I really need is DOM::Document and so on. I'll use KApplication,
> KHTMLPart, KHTMLView, and so on, only as I need them to invoke the
> functionality of DOM, CSS, and KJS classes.
>
> I'm aware of two ways to get a DOM::HTMLDocument from an HTML file, without
> getting into windows and widgets.
>
> Technique 1 looks like this:
>
> DOM::HTMLDocument doc;
> doc.setAsync(false);
> doc.load(url);
>
> Technique 1 has two serious problems. First, when getRect() is called on
> nodes, it produces no useful information. Second, when the program
> exits, either the automatically-invoked destructors bomb, or if I invoke
> destructors myself, they still bomb.
>
> Technique 2 looks like this, where inputHTMLQString is a QString that's
> read from the HTML file, it doesn't matter how.
>
> KHTMLPart * pPart = new KHTMLPart();
> pPart->begin();
> pPart->write(inputHTMLQString);
> pPart->end();
> DOM::Document doc = pPart->document();
>
> Technique 2 has two serious problems. First, when getRect() is called on
> nodes, it produces no useful information, so there's nothing to choose
> between Technique 1 and Technique 2 here. Technique 2 leads to graceful
> destruction, but it brings along by default a very fussy version of the
> HTML parser which wreaks havoc with scripts, among other constituents. I
> can get around the fussy parser, but the way I've done it so far isn't
> pretty.
>
> If I want to have all of the following:
>
> calls to getRect() produce useful results
> tolerant parser
> effective destruction
>
> and I want to have them to the extent possible without without windows
> and widgets, I'm guessing the best technique isn't either of the ones
> I've tried. Best aside, what's a good technique?
>
>
>
> >> Visit
> http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> unsubscribe <<
>
>
>
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic