On Thursday 2012-10-04 15:17 -0700, Seth Fowler wrote:
> Just bringing myself up to speed on the layout subsystem of Gecko and there's 
> something that's not immediately clear to me. The docs suggest that styles 
> are computed lazily. What I'm curious about is: why this is preferable to 
> doing it eagerly?

I'm assuming that you're talking about nsStyleContext lazily
computing the results of GetStyle*() when those functions are called
rather than computing it at the time the style context is created
(which is itself buffered up in ways that are very important).

Off the top of my head, I think the biggest reason for this is that
it's probably a bit of a savings in memory use, since there are a
bunch of structs that we won't create for many elements -- though as
bz said, I'm not sure how true that is anymore.  It's no longer true
for nsStyleUserInterface since we eagerly create it to trigger
cursor loading.  (Probably that was the wrong fix and we should have
moved the cursor property to nsStyleVisibility instead.)

It may well be true for nsStyleUIReset, nsStyleTable,
nsStyleTableBorder, nsStyleQuotes, nsStyleContent, nsStyleXUL,
nsStyleColumn, and nsStyleList.  But we don't have any tests to
check that we're not creating them in the cases where we think we
ought not to be creating them, so odds are we're creating them in a
bunch of cases where we need not.

> Certainly there are cases where we don't need the value of certain properties 
> - for example, we don't care about anything under a DOM node with "display: 
> none", and we can ignore certain properties when a node has "visibility: 
> hidden". But it seems to me like these cases could easily be taken into 
> account when evaluating styles eagerly.

What would the advantage of computing them eagerly be?

-David

-- 
𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                           http://www.mozilla.org/   𝄂
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout

Reply via email to