Skip to content

What is a reflow?

May 24, 2008

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:

Reflow of Google.co.jp:

Reflow of Wikipedia:

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

From → Uncategorized

55 Comments
  1. Dan permalink

    Someone totally needs to make that into a Firefox extension.

  2. Wow. That’s awesome.

  3. That’s awesome. I second post #1

  4. Interesting that it’s reflowing the whole thing twice for mozilla.org and wikipedia, but *not* google.

  5. Woah, it’s awesome, seriously. Who made these? Any chance for higher resolution ones? Or even better an interactive thingie (1st post, further seconded.)

  6. That is just spectacular. I am dying to find out who was responsible.

  7. 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.

  8. WizKid permalink

    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.

  9. Anonymous permalink

    Maybe that is because google doesn’t use CSS?

  10. pufone permalink

    f this s, Opera draws pages as soon as data comes in, does not hide the layout until it’s fully generated.

  11. Anonymous permalink

    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.

  12. David permalink

    Those are cool. A firefox extension would be pretty cool! :)

  13. Interesting. I completely agree with Dan above… it’d be great if this were a Firefox extension.

  14. Boris permalink

    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.

  15. Awesome visual demos. Thank you!

  16. This is awesome, seeing the process slowed down and outlined like this. A firefox extension would be great!

  17. Bill permalink

    @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).

  18. 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.

  19. I like it.

    That is all.
    (Apologies I’m not very tech savvy and there cannot make this comment more interesting)

  20. Looks cool! :)

  21. 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!

  22. baklavagirl permalink

    Thanks. I don’t know much about computers but I really thought that was so cool.

  23. > 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

  24. Doug- that was at our Mozilla 24 event, albeit in the Tokyo part of the event.

  25. Dave Newell permalink

    That was a lot of good info.

    dave, http://www.thehistorybluff.com

  26. I can’t see anything? Sorry!

  27. I want the tool that makes these animations, it would be SOOO helpfull when developing websites!

  28. I might finally understand floats if that was an extension. :)

  29. awesome posts

    thanks dear

  30. Fantastic rendering demonstration. Its only a matter of time before something like this gets pushed out into the open source domain.

  31. Boris permalink

    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_.

  32. Excellent! I didn’t get why on the first video (Mozilla.org reflow) it went over the whole thing two times?

  33. ese permalink

    That is just insane!!! Fantastic demo, should totally be made into a extension.

Trackbacks & Pingbacks

  1. Reflow Visualisation » randomosity » Blog Archive Reflow Visualisation »
  2. Browser rendering and web performance: Reflow | Bitcurrent
  3. Top Posts « WordPress.com
  4. Un gaditano en Silicon Valley » » Reflow
  5. kann hier jemand Polnisch? - XHTMLforum
  6. Giavasan » Special FX
  7. Create A Website » Blog Archive » Reflow
  8. O que é reflow? | fabioricotta - SEO, Blogs, Google e um pouco mais
  9. Comment les navigateurs chargent les pages des sites Internet
  10. schonleben mittendrin: subjektiv, subversiv! » Blog Archive » Google Reflow
  11. Como o navegador trabalha na internet? - Google Discovery
  12. ¿Cómo piensa un navegador?
  13. Mobimeet - Reflows
  14. » Reflow
  15. 形象化的reflow - 样式之美
  16. What is a reflow? « Science Notes
  17. gregs » Blog Archive » Reflow
  18. Something Unimportant » Blog Archive » What is a reflow?
  19. Weekly Links: ASP.NET MVC, .NET, ADO.NET Data Services, Silverlight, WPF… | Code-Inside Blog International
  20. Mozilla in Asia » Blog Archive » 3D in JavaScript and Canvas
  21. Mozilla in Asia » Blog Archive » how to make your own Gecko reflow video

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.