Questions and Answers

The html pages are stored in my local database together with the images. This has been solved by using a special img attribute value: <img src="db:image1.jpg">. Is it possible to get a callback called when the HTMLayout detects this image resource type?

When htmlayout needs some resource referred by HTML or CSS it first sends notification HLN_LOAD_DATA with url and data type to the host application. Host can provide its own data by calling HTMLayoutDataReady with pointer to data buffer.

Or application may delegate downloading data to builtin HTTP/FTP client. In this case host will receive also HLN_DATA_LOADED notification with loaded data. You may store data in local cache or DB at this moment. Host also may choose to discard lading data at all.

See OnLoadData function in wtl_htmlayouthost.h for an example of custom data loading. Default WTL wrapper handles request to data placed in resources.

Is it possible to search for text in the html page (like pressing Ctrl-F in a browser window)?
No such builtin function as different applications have different requirements.
Typical procedure to implement this is:
  • navigate through all element having text and no child elements (a.k.a terminal nodes) and do text search in their text - dom::element::get_text().
  • If element with the text was found then update its content by wrappin the text in <span class=highlight>some word</span> by using dom::element::set_html(, REPLACE_CONTENT);
  • navigation on found fragments - dom::element::find_all( "span.highlight" ) + dom::element::set_state(STATE_CURRENT) + dom::element::scroll_to_view + some CSS styling like: span.highligh:current { color:red }

How to enable keyboard PageUp/Down for scrollable containers (elements having overflow: auto or scroll)?

Such elements shall be "focusable" to be able to accept keyboard input. To declare any element to be focusable it is enough to define attribute tabindex="0" for it. Thus if element has style overflow: auto or scroll and tabindex="0" then it will accept focus and will be scrollable by pressing PageUp/Down, Home/End keys.


Answer: No.

Reason: The question is deeper than we may think. In fact the question is as: does emebeddable HTML/CSS engine need <frame>s at all?

In my opinion full <frameset> functionality is a part of universal browser as <frameset>s also implies support of view stacks with GoBack/GoNext, etc.

I am trying to avoid transformation of htmlayout into full scale browser. Full scale browser based on htmlayout is feasible but does anybody need yet another browser really?

I see niche on the market for embeddable engine but for one more browser? There are plenty of them there. In contrary there are no HTML/CSS components except of HTMLayout, at least I am not aware of anything else. Yes there are HTML controls e.g. IE based ActiveX control but it is not a component - you cannot package it into distribution of your application. And if you are using such control you need to test your application against each its version or service pack. Not good from application maintainability point of view.

And now goes practical question: do you think that <frameset> is a must for htmlayout? What kind of tasks they may solve for applications?

I can see use cases when htmlayout is used for browsing let's say HTML help files residing in some special storage like chm. Sort of specialised browser application with special window layout - separate index and content (htmlayout per se) areas.

But I am pretty sure that if someone wants to have just another browser it is better to use Gecko or IE controls - they are designed for *internet browsing*. And from user perspective: if application use case requires broad Internet browsing at some point it is better to use uesr's favorite browsing application for that. History, cookies, security settings, all that stuff.

If I do need frames-alike functionality what should I do?

There are two options for IFRAMEs or IFRAME alike functionality:

  1. To use existing dom::element::set_html( frameHtmlText ) ( you need to load frameHtmlText first from somewhere, e.g. from resources)
  2. To use another instance of HTMLayout embedded in the page and to load document there.

In all cases loading of the document shall be done by behavior: hyperlink (See: sdk/include/behaviors/behavior_hyperlink.cpp.) using policies most suitable for the application.

Implementation is pretty strightforward:we need to get target attribute of the <a> element and load document in the element identified by target attr. value. In cases #1 and #2 any element can serve <iframe> purposes.

Benefit of case #1 - you don't need to separate CSS styles as new content will be part of contained page thus accessible from the root of the DOM, will inherit all behavior implementations and overall solution will be much lighter than having separate frame (case #2)

Case #1 and #2 is pretty much implementation of Compound HTML Documents, see: http://www.w3.org/2004/04/webapps-cdf-ws/papers/opera.html

How can I add datetime control or any other custom control to HTMLayout ?
There are two types of controls: hwnd based and behavior based.
To create standard DateTime picker Windows Common Control go to _tWinMain in browser.cpp and update line:
After that you can use it in html as:
datetime: <input type="datetime" style="width:100px; height:2em">
Creation of datetime window happens in CreateControl() in wtl_htmlayouthost.h and this way you can add creation of your own HWND based controls.
To create styleable lightweight control you need to design correspondent behavior.
Limitation of HWND based controls: they cannot be scrolled by scrollable containers (e.g. overflow:auto) other than document itself.





HTMLayout Wrappers