In article <[EMAIL PROTECTED]>, Boris Zbarsky <[EMAIL PROTECTED]> wrote:
> Henri Sivonen wrote: > > I need to get the following layout data for an element > > Who is "I"? That is, where does this code live? nsIFrame is not exactly a > public API... Right now the code lives (for my convenience) in my private copy of layout/inspector/src/inDOMUtils.cpp. I wouldn't be too surprised if it was eventually placed somewhere else. The idea is to implement the algorithm from https://bugzilla.mozilla.org/show_bug.cgi?id=31961 in C++. > Furthermore, how do you want to handle elements that are rendered in multiple > places at once (eg <area> elements). Getting some reasonably sane data for <area> without crashing is good enough, because there usually aren't significant subtrees rooted at <area>. > > and I think getting it directly off the primary nsIFrame of the element is > > probably > > the way to go. > > What if there is no frame? But there are for (at least non-SVG) elements that are being rendered, right? > > * Whether the element is being rendered (display: none; or visibility: > > hidden;) > > Those are two very different things, for what it's worth.... I realize that. I just don't walk into subtrees that don't render. > > * The rendering width and height of the element's box in CSS px. > > This is assuming this box exists, right? What if it doesn't? I am assuming it always exists for elements that have a defined and non-null contentDocument property and are neither display: none; nor visibility: hidden;. Is that a wrong assumption? > > * The font size in px. > > Is this conditional on the CSS box existing? I am only interested in the font size for elements that aren't in non-rendering (display: none; nor visibility: hidden;) subtrees. > > For font size, I see code like this around the codebase: > > const nsStyleText* styleText = frame->GetStyleText(); > > > > Yet, by searching LXR and grepping my CVS sandbox I can't find the > > definition of the GetStyleText() method. What am I missing? > > It's defined by a macro. See > http://lxr.mozilla.org/seamonkey/source/layout/generic/nsIFrame.h#598 Thanks. > > For the width and height, I suppose I should use GetSize(). Am I right? > > This is conditional to the answers to my question above. The idea is to check if an element that has a contentDocument is "small" in the sense that its width or height is less than 130px. (This heuristic should catch most ad <iframe>s.) > > What's the right way to convert twips into CSS px or vice versa? > > NSTwipsToFloatPixels or NSTwipsToIntPixels, both of which need a scaling > factor > off the prescontext. Also see NSFloatPixelsToTwips and NSIntPixelsToTwips. > For > CSS px you want the ScaledPixels thing on prescontext. Thanks. > > Does an element even have a primary nsIFrame if it has display: none;? > > No. That's a sufficient test then? -- Henri Sivonen [EMAIL PROTECTED] http://hsivonen.iki.fi/ _______________________________________________ dev-tech-layout mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-layout

