Reflow is the process by which the geometry of the layout engine’s formatting objects are computed. Last week, I was searching around and stumbled on these really cool visuals of what a reflow looks like. If you’re a visual person, you will dig these:
Reflow of Mozilla.org:
[googlevideo=http://video.google.com/googleplayer.swf?docid=1020647662203348823]
Reflow of Google.co.jp:
[googlevideo=http://video.google.com/googleplayer.swf?docid=-1471976166301235697]
Reflow of Wikipedia:
[googlevideo=http://video.google.com/googleplayer.swf?docid=-5863446593724321515]
If you produced these, kudos! If you know how to produce such things, please drop a note!
Update:
Satoshi Ueyama is the author of this cool demo. He sent Gen a note on how he did it:
First, he builds Mozilla so that the layout portions (nsIFrame::SetRect, nsIFrame::SetSize, nsIFrame;;SetPosition, PresShell::DoReflow, etc) are set to output to the log file.
He then gives an example of the log of each of the frame movements from Reflow:
{"event": "MoveFrame", "frame": {"address": "0x04FE41A8", "type": "TextFrame", "content": {"address": "0x05014150", "type": "other"}, "rect": {"x": 0, "y": 0, "w": 0, "h": 0}}}, {"event": "MoveFrame", "frame": {"address": "0x04FE41A8", "type": "TextFrame", "content": {"address": "0x05014150", "type": "other"}, "rect": {"x": 0, "y": 0, "w": 0, "h": 0}}},Here is an example of dump from the termination of the tree structure.
{"event": "FinishReflow", frame: {"address": "0x04FE3E28", "type": "ViewportFrame", "content": null, "children":[ {"address": "0x04FE4000", "type": "ScrollFrame", "content": {"address": "0x04FD4858", "type": "element", "tagName": "HTML"}, "children":[ {"address": "0x04FE43EC", "type": "ScrollbarFrame", "content": {"address": "0x04FFEFF8", "type": "element", "tagName": "scrollbar"}, "children":[ {"address": "0x04FE4578", "type": "BoxFrame", "content": {"address": "0x04FFE0F8", "type": "element", "tagName": "xul:scrollbarbutton"} } , {"address": "0x04FE47BC", "type": "sliderFrame", "content": {"address": "0x04FFE278", "type": "element", "tagName": "xul:slider"}, "children":[ {"address": "0x05004E6C", "type": "BoxFrame", "content": {"address": "0x050030E8", "type": "element", "tagName": "xul:thumb"}, "children":[ {"address": "0x05004FDC", "type": "BoxFrame", "content": {"address": "0x050013F0", "type": "element", "tagName": "xul:gripper"} } ] }He then makes the video animation (for Google Video he suggests Ruby+Ruby/SDL, for the video from Mozilla 24 he used C+++Direct3d.) As memory address is outputted to the log each frame can be distinct.
The behavior of each frame in chronological order is reproducible as the log has each frame’s memory. (For instance, in tracking the frame “address”:”0x04FE41A8″, you can reproduce that frame’s behavior chronologically.
UPDATE:
New links for the videos (thanks Gen!):
http://www.youtube.com/watch?v=nJtBUHyNBxs
http://www.youtube.com/watch?v=ZTnIxIA5KGw
http://www.youtube.com/watch?v=dndeRnzkJDU
34 Comments
Someone totally needs to make that into a Firefox extension.
Wow. That’s awesome.
That’s awesome. I second post #1
Interesting that it’s reflowing the whole thing twice for mozilla.org and wikipedia, but *not* google.
Woah, it’s awesome, seriously. Who made these? Any chance for higher resolution ones? Or even better an interactive thingie (1st post, further seconded.)
That is just spectacular. I am dying to find out who was responsible.
Wow, someone please add that to Firebug or WebDeveloper extension! I’d love to see how the reflow unfolds on my website and if there’d be anyway I could then optimise it for faster rendering.
glandium: I think that is because Mozilla and Wikipedia becomes larger then fit on screen so the scrollbar needs to be placed on the right. And therefor there is a second reflow.
Maybe that is because google doesn’t use CSS?
f this s, Opera draws pages as soon as data comes in, does not hide the layout until it’s fully generated.
I think it’s animations related to this talk at Shibuya.js:
http://video.google.com/videoplay?docid=4146973749385284875
This seems to be the guy who made it:
http://gyu.que.jp/sjs2007/
Guessing it’s done in Processing, since he has some other stuff done in that too.
Those are cool. A firefox extension would be pretty cool!
Interesting. I completely agree with Dan above… it’d be great if this were a Firefox extension.
It looks like this animation captures all calls to SetRect/SetPosition/SetSize on frames or something along those lines. At least that’s what it looks like to me given how it’s handling the floats and the inline layout. Doing that from an extension would be quite difficult, actually, and any setup that _did_ do it would have a pretty hefty impact on layout performance.
Awesome visual demos. Thank you!
This is awesome, seeing the process slowed down and outlined like this. A firefox extension would be great!
@16:
You wouldn’t need to do it real time; you would just need to log the calls to those functions somewhere so that you can parse them and create an animation (that said it would still be difficult from an extension I think; you may want a custom build of the browser instead).
Seeing as almost all pages have vertical scrolling, it seems like a sensible optimisation to render assuming a scrollbar first, and then if it isn’t required, to reflow.
In fact I remember that Opera 6 or so always rendered with a scrollbar visible. At the time I assumed it was to avoid the content jumping around on sites where some pages have scrollbars and some don’t. But maybe it was an optimisation. Opera has always focused on speed more than the other browsers.
I like it.
That is all.
(Apologies I’m not very tech savvy and there cannot make this comment more interesting)
Looks cool!
I like the pretty colors… Just kidding. Seriously, I AM a visual person, and I LOVE watching technical things like this unfold visually before me. Great videos, thanks a lot for sharing!
Thanks. I don’t know much about computers but I really thought that was so cool.
Check out Timelapse CSS by Mattew Buchanan:
http://matthewbuchanan.name/post/33504871/timelapse-css
> Which makes you wonder why the entire mozilla
> page needs to be reflown for that since it has
> fixed margins.
Wow, from 3 small, lo rez videos we already have a possible bug.
Interesting how information presented in a new way helps us all understand a complex process.
monk.e.boy
Doug- that was at our Mozilla 24 event, albeit in the Tokyo part of the event.
That was a lot of good info.
dave, http://www.thehistorybluff.com
I can’t see anything? Sorry!
I want the tool that makes these animations, it would be SOOO helpfull when developing websites!
I might finally understand floats if that was an extension.
awesome posts
thanks dear
Fantastic rendering demonstration. Its only a matter of time before something like this gets pushed out into the open source domain.
Bill, you’d definitely need a custom build (not possible to hook into those layout guts from an extension). And I wasn’t talking about doing anything in realtime: just logging those function calls might be expensive enough to noticeably affect layout performance. Those functions are called a _lot_.
Excellent! I didn’t get why on the first video (Mozilla.org reflow) it went over the whole thing two times?
That is just insane!!! Fantastic demo, should totally be made into a extension.
21 Trackbacks
[...] Layout Engine Geometry You may also want to browse: A Fascinating Constellation, Candy, Pervasive Visualisation, [...]
[...] were found by DougT somewhere on Google Video. There are others (such as Wikipedia) that he shows on his blog.. He (and [...]
[...] What is a reflow? Reflow is the process by which the geometry of the layout engine’s formatting objects are computed. Last week, [...] [...]
[...] El vídeo muestra el modo en que gecko procesa la información del DOM y las hojas de estilo al montar una página tal y como la vemos. Las animaciones muestran como el motor renderiza la información de la página a visualizar conforme le va llegando y como cambios en la estructura de la misma (nuevas tablas o cambios en el CSS) afectan a determinadas partes de la visualización. Además de la wikipedia en japo, existen visualizaciones para google.co.jp y la página principal de mozilla. [...]
[...] keiner Polnisch, aber dafür ist dies für denjenigen interessant, der sich mit mir fragt, was ein Reflow in Gecko ist. __________________ Ingo Chao :: satzansatz :: dolphins [...]
[...] una pagina web a partire dai suoi componenti fondamentali, i frames. DougT ha raccolto sul suo blog tre video che mostrano in dettaglio i reflow di google.co.jp, mozilla.org e ja.wikipedia.org, ed è [...]
[...] across an article on “reflow”: the process by which the geometry of the layout engine’s formatting objects are [...]
[...] um processo chamado reflow, da página do Google. Investiguei mais a fundo e achei um artigo no DougT’s Blog, com mais alguns [...]
[...] ne sais pas comment on arrive à produire ce genre de vidéo, ni la source sur laquelle j’ai trouvé ces exemple d’ailleurs. A priori c’est une histoire de [...]
[...] (via: dougt.wordpress.com) [...]
[...] Via: Google Blogoscoped e Dougt [...]
[...] de la Wikipedia elemento a elemento. Dos vídeos más con reflows de Google y de Mozilla.org en dougt.wordpress.com/2008/05/24/what-is-a-reflow sin comentarios en: tecnología, software karma: 6 etiquetas: firefox, navegador, reflow votos [...]
[...] In any case, a couple of good examples cropped up on the net including this one below. Check out this post for a couple [...]
[...] dougT 的 Blog 裡面的回應裡有討論到,似乎是日本的 Gecko 所弄出來的 [...]
[...] 现在,我们能形象地看到这个reflow是怎样的一个过程了(via:What is a reflow?),先看一下Mozilla的首页; 看不到点这里看,再看不到就用代理来看,再再看不了的话就邮件给我发文件给你。。 [...]
[...] What is a reflow? 2008 May 28, Wednesday, 18:00 — monado On Doug T.’s blog, you can learn about reflows: what is a reflow and how are they calculated? [...]
[...] more appropriately what is it? [...]
[...] Have you ever heard of reflows in terms of browser rendering? I hadn’t but this short blog post has some neat videos of them in action. Check it out, let me know what you think. This entry [...]
[...] What is a reflow? [...]
[...] Ueyama-san, the programmer who made those 3D demos, is the same programmer who did those Gecko reflow videos (Japanese) that were widely blogged about and discussed at Doug Turner’s blog: What is a reflow? [...]
[...] Last May, my colleague Doug Turner happened across some videos showing how the Gecko engine does reflow: What is a reflow? < DougT’s Blog [...]