>>>>> "SC" == Samuel Cheung <[EMAIL PROTECTED]> writes:
SC> As a start, I am going to do something even simpler. I create a
SC> BridgeContext SVG, parse a simple CSS, and retrieve a property
SC> e.g. font-size (defined both in HTML CSS and SVG CSS).
Ok, so for CSS to make much sense you need to have document to
give context for the question you are asking. This is required as you
can write rules that talk about the structure of the document.
SC> I understand BridgeContext is for SVG CSS, but I can still use
SC> that to parse a HTML CSS and retrieve properties defined in SVG
SC> CSS (e.g. font-size). Am I correct?
In most cases yes. However if the font size were defined using
percentages (which it can be, I doubt you will get the right answer).
Also for the BridgeContext to be happy it will have to think that it
is working with an SVG document.
SC> But my questions are: 1. How can i parse a stylesheet after I
SC> create a BridgeContext? I can't find any parse function for
SC> stylesheet? 2. How can I retrieve specified property in the
SC> parsed CSS thru BridgeContext?
There are parse methods on the CSSEngine (Which you can get from
an SVGOMDocument (see Bridgecontext.initializeDocument)). The tricky
thing is getting the CSSEngine to apply your rules when you call
getComputedStyle. It's fairly easy if you can just use the User Agent
Stylesheet or the Alternate Stylesheet (initializeDocument will show
all you need to do). But if you need many stylesheets you can have
them parsed and included in the cascade by adding a <style> element to
the document before you build the engine (you might be able to add it
later but I don't know the details here.).
One other gotcha comes to mind which is that be default the Batik
DOM will not style elements it doesn't know about. In order for the
CSS cascade to be applied to elements that aren't in SVG you need to
register an implementation of Element that provides the hooks needed
for styling. If you look at the svg extensions stuff
(batik.extensions.svg) this shows how this is done.
SC> Thank you for your help again. Sam
SC> -----Original Message----- From: Thomas E Deweese
SC> [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 28, 2002
SC> 3:38 PM To: Batik Users Subject: [RE] RE: Using Batik as a HTML
SC> CSS engine
>>>>> "SC" == Sam Cheung <[EMAIL PROTECTED]> writes:
SC> Thomas, Thanks a lot for your feedback. So what I need to do
SC> implement a HTML css engine based on the abstract CSS engine in
SC> Batik?
SC> 1. come up a ValueManager for HTML CSS. 2. come up a
SC> ShortHandManager for HTML css.
SC> Just to be 100% clear it will most likely be a set of
SC> ValueManager's and ShorthandManagers (in the worst case one for
SC> each HTML CSS property, many can probably be mostly borrowed from
SC> the SVG CSS properties already in Batik).
SC> anything else?
SC> You will likely need to implement batik.css.engine.CSSContext.
SC> Most of the methods here are pretty simple (or can be stolen from
SC> Batik's implementation in batik.bridge.BridgeContext). However
SC> the two hard one's to implement are 'getBlockWidth' and
SC> 'getBlockHeight').
SC> Remember while Batik has a CSS Parser and CSS Cascade engine
SC> it does not have a CSS Block Layout engine. So if you want to
SC> calculate the proper size of HTML tables for example you are in
SC> for a lot of work (in fact I'm thinking that the Batik CSS
SC> structure isn't sufficent for this case). If you just want to
SC> know the bg color for the table then it should be pretty easy.
SC> Perhaps I/we didn't make this as clear as it should have been
SC> at the start.
SC> ---------------------------------------------------------------------
SC> To unsubscribe, e-mail: [EMAIL PROTECTED] For
SC> additional commands, e-mail: [EMAIL PROTECTED]
SC> ---------------------------------------------------------------------
SC> To unsubscribe, e-mail: [EMAIL PROTECTED] For
SC> additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]