SlideShare a Scribd company logo
1 of 69
Download to read offline
WebKit!
                 how the web is rendered




Levi Weintraub
me

Intel->Apple->Microsoft->Palm->HP->Google


     on and off on WebKit since 2006


          adventure motorcyclist
me

Intel->Apple->Microsoft->Palm->HP->Google


      on and off on WebKit since 2006


          adventure motorcyclist
adventure motorcyclist
Hi Dad!




          adventure motorcyclist
rendering engine
browser




rendering engine
3 primary rendering engines
primary rendering engines

Trident
primary rendering engines

Trident




Internet Explorer
primary rendering engines

Trident                Gecko




Internet Explorer
primary rendering engines

Trident                Gecko




Internet Explorer       Firefox
primary rendering engines

Trident                Gecko        WebKit




Internet Explorer       Firefox
primary rendering engines

Trident                Gecko           WebKit




Internet Explorer       Firefox     Chrome, Safari, iOS,
                                   Android, Qt, Blackberry,
                                    webOS, Kindle, etc.
Gecko           WebKit

        FREE!
Gecko              WebKit

           FREE!



 Firefox           Chromium
over 38%1




  1: StatCounter's Global March 2012 http://gs.statcounter.com
history
KHTML + Konquerer
19
     98
          KH
                TM
                      Lr
                            ele
                                   as
20                                    ed
     01
          W
               eb
                    Kit
20                        se
     02                      c  ret
          Ja                          ly
               va                          for
                    Sc                           ke
20                    rip                             db
     03                        tC                         yA
          W                        ore                             pp
               eb
                    Co                     rel                       le
                                               ea
                          re                        se
                               &                         d
                                    Sa
20                                     fa    ri r
     05                                           ele
          W                                             as
               eb                                            ed
                    Kit
                          op
                                en
                                     so
20                                         urc
     07                                           ed
          Sa
                far
                     i fo
20                         rW
     08                            ind
        G      oo                        ow
                 gle                          s
20                        Ch
     09                         rom
        C      hro                      er
                    me                    ele
20                          Be                      as
     10                        ta                       ed
          KD                          for                      for
                E                            Ma                      W
                     re-                            cO                  ind
                                                                              ow
                          int                            S                       s
                               eg
                                     rat                       X
                                         e                         an
20                                          sW                          dL
     12                                             eb                    inu
          W                                              Kit                    x
               eb                                              -W
??                  Kit
     ?                    do                                     eb
                                                                          Kit
                                mi
                                    na                                        2a
Pr                                       nt                                         nn
  ofi                                         we                                      ou
         t!!                                        bp                                   nc
                                                         lat                               ed
                                                             f  orm
anatomy of a WebKit browser
Embedding Application     pushes WebKit to do work
                           handles user input
   WebKit (component)


        WebCore



JavaScript
                Platform
 Engine
WebKit-based browser

  WebKit (component)       interface between
                           rendering engine and
                           embedding application
        WebCore



JavaScript
                Platform
 Engine
WebKit-based browser

   WebKit (component)


        WebCore                   application logic
                           loading            painting
                           parsing            event handling
JavaScript                 layout             editing
                Platform
 Engine                    style resolution   javascript bindings
WebKit-based browser

   WebKit (component)


        WebCore



JavaScript
               Platform   network stack
 Engine
                          graphics library
                          font engine
                          native widgets
                          abstraction of native components
WebKit-based browser

     WebKit (component)


          WebCore



 JavaScript
                   Platform
   Engine



V8 or JavaScriptCore
parses and executes page logic
allows DOM manipulation
WebCore
primary data structures

parsing & interface:
   DOM tree
layout and rendering:
   render object tree
   style tree
   layer tree
   line box tree
main flow
network engine



loading


              parser
loader



         parsing


                   DOM tree
parsing                            JavaScript
                               I
                            AP
                       M
                     DO




          DOM tree
                      att
                         ac
                           h




                                   render tree
DOM tree

representation of document
document API
shadow DOM
DOM tree
markup                   DOM representation
<html>                   HTMLDocument
 <body>                   HTMLHTMLElement
  <div>                    HTMLBodyElement
    foo                     HTMLDivElement
    <span>                   Text("foo")
    bar                      HTMLSpanElement
    </span>                   Text("bar")
  </div>
 </body>
</html>
DOM tree                       style
           att
              ac
                h




                 render tree
OK!
render forest

render object tree
layer tree
inline box tree
style tree
render object tree

owned by DOM tree
only exists for rendered content
responsible for layout and paint
answers DOM API measurement requests
12 paint phases!

block background          child outlines
child block background    self outline
child block backgrounds   selection
float                     collapsed table borders
foreground                text clip
outline                   mask
render object tree

owned by DOM tree
only exists for rendered content
responsible for layout and paint
answers DOM API measurement requests
render object tree
DOM representation         render objects
HTMLBodyElement             RenderBlock
 HTMLDivElement              RenderBlock
  Text("foo")                 RenderText("foo")
  HTMLSpanElement             RenderInline
   Text("bar")                 RenderText("bar")
anonymous blocks
DOM representation      render objects
HTMLBodyElement          RenderBlock
 HTMLDivElement           RenderBlock
  Text("foo")              RenderBlock(anonymous)
  HTMLSpanElement           RenderText("foo")
   Text("bar")              RenderInline
  HTMLDivElement             RenderText("bar")
    Text("baz")            RenderBlock
                            RenderText("baz")
style tree

contains all computed style values for renderers
owned by render object tree
RenderObjects share RenderStyles
RenderStyles share data members
render layer tree

like helper class for rendering
used for <video>, <canvas> with WebGL,
positioned, transformed, transparent, masked,
clipped, scrollable, or reflected elements
establishes coordinate space and z-ordering
at least one per document, sparsely maps to
renderers
render layer structure
                                 negative z-index list


                                   RenderLaye
                                    RenderLaye
                                       r
                                       Render
                                         r
                                        Layers



         RenderLayer
                                 positive z-index list


                                   RenderLaye
                                    RenderLaye
                                       r
                                       Render
                                         r
                                        Layers

         RenderObject



RenderObject      RenderObject
render layer painting
                                 negative z-index list


                                   RenderLaye
                                    RenderLaye
                                       r
                                       Render
                                         r
                                        Layers
                          1
         RenderLayer
                                 positive z-index list


                                   RenderLaye
                                    RenderLaye
                                       r
                                       Render
                                         r
                                        Layers

         RenderObject



RenderObject      RenderObject
render layer painting
                                  negative z-index list


                                    RenderLaye
                                     RenderLaye
                                        r
                                        Render
                                          r
                                         Layers
               2

         RenderLayer
                                  positive z-index list


                                    RenderLaye
                                     RenderLaye
                                        r
                                        Render
                                          r
                                         Layers

         RenderObject



RenderObject       RenderObject
render layer painting
                                 negative z-index list


                                   RenderLaye
                                    RenderLaye
                                       r
                                       Render
                                         r
                                        Layers



         RenderLayer      3
                                 positive z-index list


                                   RenderLaye
                                    RenderLaye
                                       r
                                       Render
                                         r
                                        Layers

         RenderObject



RenderObject      RenderObject
render layer painting, software

paint the intersection of the paint dirty rect with
all intersecting layers in order
all layers render into the same output buffer
render layer painting, hw accelerated

some RenderLayers have backing store GPU
texture
used for 3D transforms, <video>, <canvas>/
plugins with 3D, stacking contexts, or sub-
frames
dirtied RenderLayers paint to GPU texture
GPU composites textures onto final output
buffer
line box tree

owned by RenderBlock
one RootInlineBox per line
RootInlineBox has list of InlineBoxes in that line
each InlineBox has a RenderObject
a renderer may have many InlineBoxes
relies on RenderBlock for layout
line box tree
            Markup: <div>foo<b>bar</b><br>baz</div>

render tree                               line box tree
RenderBlock(div)                            RenderBlock(div)
 RenderText("foo")                           RootInlineBox
 RenderInline(b)                              InlineTextBox("foo")
  RenderText("bar")                           InlineFlowBox(b)
 RenderBR                                      InlineTextBox(b)
 RenderText("baz")                            InlineBox(br)
                                             RootInlineBox
                                              InlineTextBox("baz")
layout

changes to DOM marks renderers as dirty
layout before paint or measurement from JS
●   save old repaint rect
●   bring in updates from DOM
●   determine our preferred width
●   layout children to determine height
●   repaint difference between old and new rect
layout

changes to DOM marks renderers as dirty
layout before paint or measurement from JS
●   save old repaint rect
●   bring in updates from DOM
●   determine our preferred width
●   layout children to determine height
●   repaint difference between old and new rect
review of main flow

loader->parser->DOM tree->render tree
render tree:
●   RenderObject tree
●   RenderLayer tree
●   RenderStyle tree
●   InlineBoxTree
paint

animations, blinking carets, layout, etc. trigger
invalidations to embedder app
app collects rects, triggers paint
tree walk from root RenderLayer
RenderObjects and InlineBoxes paint
GraphicsContext abstraction
hit testing

constant during mouse move
multiple phases
tree walk from root RenderLayer
RenderLayer transforms into local coordinates
upcoming features

component model
sub-pixel layout
lots lots more
component model

based on shadow DOM
hides implementation
●   events re-targeted
●   shadow children inaccessible by regular
    DOM
defined interface
shadow DOM tree




                                       shadow boundary
   Do
     cu
        m
            en
              tt
                 re
                   e


             shadow host                                            shadow root




DOM child                  DOM child                     shadow child         shadow child
shadow render tree
       re
          nde
              rt
                re
                   e



                   shadow host




  shadow child               shadow child
integer layout

layout currently uses integers
fractional pixel values truncated
breaks at non-1:1 zoom
error accumulates
1.5x zoom is bad




150px * 1.5x = 225px
(15px * 1.5x) * 10 = 220px
sub-pixel layout

integers replaced by fixed-point unit
boxes snapped to pixel values
supports sub-pixel CSS values
error doesn't accumulate
multi-process browsers

centralized resources
●   networking
●   cache
●   compositor
●   plugins
safety through sandboxing
multiple main loops ≈ multi-core
chrome architecture
        network stack   browser process      file io




   GPU process


                         plugin process
                          plugin processes



 shared memory

gles2.0 instructions
                                                   render
     textures
                                                 processes
thanks!

     questions?


     http://webkit.org
     http://chromium.org
     leviw@chromium.org


Levi Weintraub

More Related Content

What's hot

Introduction to web development
Introduction to web developmentIntroduction to web development
Introduction to web development
Mohammed Safwat
 
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Simplilearn
 

What's hot (20)

Introduction to JavaScript (1).ppt
Introduction to JavaScript (1).pptIntroduction to JavaScript (1).ppt
Introduction to JavaScript (1).ppt
 
Front end development session1
Front end development session1Front end development session1
Front end development session1
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
HTML 5: Audio And Video
HTML 5: Audio And VideoHTML 5: Audio And Video
HTML 5: Audio And Video
 
Blazor web apps
Blazor web appsBlazor web apps
Blazor web apps
 
What Is An SDK?
What Is An SDK?What Is An SDK?
What Is An SDK?
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
 
Wireframes - presentation
Wireframes - presentationWireframes - presentation
Wireframes - presentation
 
The Future Of Web Frameworks
The Future Of Web FrameworksThe Future Of Web Frameworks
The Future Of Web Frameworks
 
Figma design tool - an alternative for windows users
Figma design tool - an alternative for windows usersFigma design tool - an alternative for windows users
Figma design tool - an alternative for windows users
 
Selenium-Locators
Selenium-LocatorsSelenium-Locators
Selenium-Locators
 
It ppt.pptx
It ppt.pptxIt ppt.pptx
It ppt.pptx
 
HTML and CSS Basics for SEO Professional
HTML and CSS Basics for SEO ProfessionalHTML and CSS Basics for SEO Professional
HTML and CSS Basics for SEO Professional
 
Locators in selenium - BNT 09
Locators in selenium - BNT 09Locators in selenium - BNT 09
Locators in selenium - BNT 09
 
Cognos Analytics v11: A Closer Look
Cognos Analytics v11: A Closer Look Cognos Analytics v11: A Closer Look
Cognos Analytics v11: A Closer Look
 
Web automation using selenium.ppt
Web automation using selenium.pptWeb automation using selenium.ppt
Web automation using selenium.ppt
 
Introduction to web development
Introduction to web developmentIntroduction to web development
Introduction to web development
 
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
 
Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1Front-end development introduction (HTML, CSS). Part 1
Front-end development introduction (HTML, CSS). Part 1
 

Viewers also liked

Pushing Python: Building a High Throughput, Low Latency System
Pushing Python: Building a High Throughput, Low Latency SystemPushing Python: Building a High Throughput, Low Latency System
Pushing Python: Building a High Throughput, Low Latency System
Kevin Ballard
 
Who's More Functional: Kotlin, Groovy, Scala, or Java?
Who's More Functional: Kotlin, Groovy, Scala, or Java?Who's More Functional: Kotlin, Groovy, Scala, or Java?
Who's More Functional: Kotlin, Groovy, Scala, or Java?
Andrey Breslav
 
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
Fwdays
 
gevent at TellApart
gevent at TellApartgevent at TellApart
gevent at TellApart
TellApart
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm
Chandler Huang
 
Etsy Activity Feeds Architecture
Etsy Activity Feeds ArchitectureEtsy Activity Feeds Architecture
Etsy Activity Feeds Architecture
Dan McKinley
 

Viewers also liked (20)

Pushing Python: Building a High Throughput, Low Latency System
Pushing Python: Building a High Throughput, Low Latency SystemPushing Python: Building a High Throughput, Low Latency System
Pushing Python: Building a High Throughput, Low Latency System
 
Intro to Functional Programming
Intro to Functional ProgrammingIntro to Functional Programming
Intro to Functional Programming
 
Анонимные записи в Haskell. Никита Волков
Анонимные записи в Haskell. Никита ВолковАнонимные записи в Haskell. Никита Волков
Анонимные записи в Haskell. Никита Волков
 
Category theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) DataCategory theory, Monads, and Duality in the world of (BIG) Data
Category theory, Monads, and Duality in the world of (BIG) Data
 
Монады для барабанщиков. Антон Холомьёв
Монады для барабанщиков. Антон ХоломьёвМонады для барабанщиков. Антон Холомьёв
Монады для барабанщиков. Антон Холомьёв
 
Who's More Functional: Kotlin, Groovy, Scala, or Java?
Who's More Functional: Kotlin, Groovy, Scala, or Java?Who's More Functional: Kotlin, Groovy, Scala, or Java?
Who's More Functional: Kotlin, Groovy, Scala, or Java?
 
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко"Немного о функциональном программирование в JavaScript" Алексей Коваленко
"Немного о функциональном программирование в JavaScript" Алексей Коваленко
 
gevent at TellApart
gevent at TellApartgevent at TellApart
gevent at TellApart
 
London React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor CharyparLondon React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor Charypar
 
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile FrameworkBuilding a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm
 
CSS/SVG Matrix Transforms
CSS/SVG Matrix TransformsCSS/SVG Matrix Transforms
CSS/SVG Matrix Transforms
 
DNS Security Presentation ISSA
DNS Security Presentation ISSADNS Security Presentation ISSA
DNS Security Presentation ISSA
 
Introduction to jQuery Mobile - Web Deliver for All
Introduction to jQuery Mobile - Web Deliver for AllIntroduction to jQuery Mobile - Web Deliver for All
Introduction to jQuery Mobile - Web Deliver for All
 
HTML5 Essentials
HTML5 EssentialsHTML5 Essentials
HTML5 Essentials
 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.
 
Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & Features
 
Etsy Activity Feeds Architecture
Etsy Activity Feeds ArchitectureEtsy Activity Feeds Architecture
Etsy Activity Feeds Architecture
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 

Similar to Airbnb tech talk: Levi Weintraub on webkit (9)

Redesigning The Library Experience
Redesigning The Library ExperienceRedesigning The Library Experience
Redesigning The Library Experience
 
Implementing OpenID
Implementing OpenIDImplementing OpenID
Implementing OpenID
 
Pp booklet 2
Pp booklet 2Pp booklet 2
Pp booklet 2
 
Open stack - Presenation by Thierry Carrez
Open stack - Presenation by Thierry CarrezOpen stack - Presenation by Thierry Carrez
Open stack - Presenation by Thierry Carrez
 
Unit2 Gear
Unit2 GearUnit2 Gear
Unit2 Gear
 
Unit2 Gear
Unit2 GearUnit2 Gear
Unit2 Gear
 
Unit1 Screw Thread
Unit1 Screw ThreadUnit1 Screw Thread
Unit1 Screw Thread
 
Unit1 Screw Thread
Unit1 Screw ThreadUnit1 Screw Thread
Unit1 Screw Thread
 
Implementing OpenID
Implementing OpenIDImplementing OpenID
Implementing OpenID
 

Recently uploaded

Recently uploaded (20)

What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 

Airbnb tech talk: Levi Weintraub on webkit

  • 1. WebKit! how the web is rendered Levi Weintraub
  • 2. me Intel->Apple->Microsoft->Palm->HP->Google on and off on WebKit since 2006 adventure motorcyclist
  • 3. me Intel->Apple->Microsoft->Palm->HP->Google on and off on WebKit since 2006 adventure motorcyclist
  • 5. Hi Dad! adventure motorcyclist
  • 11. primary rendering engines Trident Gecko Internet Explorer
  • 12. primary rendering engines Trident Gecko Internet Explorer Firefox
  • 13. primary rendering engines Trident Gecko WebKit Internet Explorer Firefox
  • 14. primary rendering engines Trident Gecko WebKit Internet Explorer Firefox Chrome, Safari, iOS, Android, Qt, Blackberry, webOS, Kindle, etc.
  • 15. Gecko WebKit FREE!
  • 16. Gecko WebKit FREE! Firefox Chromium
  • 17. over 38%1 1: StatCounter's Global March 2012 http://gs.statcounter.com
  • 20. 19 98 KH TM Lr ele as 20 ed 01 W eb Kit 20 se 02 c ret Ja ly va for Sc ke 20 rip db 03 tC yA W ore pp eb Co rel le ea re se & d Sa 20 fa ri r 05 ele W as eb ed Kit op en so 20 urc 07 ed Sa far i fo 20 rW 08 ind G oo ow gle s 20 Ch 09 rom C hro er me ele 20 Be as 10 ta ed KD for for E Ma W re- cO ind ow int S s eg rat X e an 20 sW dL 12 eb inu W Kit x eb -W ?? Kit ? do eb Kit mi na 2a Pr nt nn ofi we ou t!! bp nc lat ed f orm
  • 21. anatomy of a WebKit browser
  • 22. Embedding Application pushes WebKit to do work handles user input WebKit (component) WebCore JavaScript Platform Engine
  • 23. WebKit-based browser WebKit (component) interface between rendering engine and embedding application WebCore JavaScript Platform Engine
  • 24. WebKit-based browser WebKit (component) WebCore application logic loading painting parsing event handling JavaScript layout editing Platform Engine style resolution javascript bindings
  • 25. WebKit-based browser WebKit (component) WebCore JavaScript Platform network stack Engine graphics library font engine native widgets abstraction of native components
  • 26. WebKit-based browser WebKit (component) WebCore JavaScript Platform Engine V8 or JavaScriptCore parses and executes page logic allows DOM manipulation
  • 28. primary data structures parsing & interface: DOM tree layout and rendering: render object tree style tree layer tree line box tree
  • 31. loader parsing DOM tree
  • 32. parsing JavaScript I AP M DO DOM tree att ac h render tree
  • 33. DOM tree representation of document document API shadow DOM
  • 34. DOM tree markup DOM representation <html> HTMLDocument <body> HTMLHTMLElement <div> HTMLBodyElement foo HTMLDivElement <span> Text("foo") bar HTMLSpanElement </span> Text("bar") </div> </body> </html>
  • 35. DOM tree style att ac h render tree
  • 36.
  • 37.
  • 38. OK!
  • 39. render forest render object tree layer tree inline box tree style tree
  • 40. render object tree owned by DOM tree only exists for rendered content responsible for layout and paint answers DOM API measurement requests
  • 41. 12 paint phases! block background child outlines child block background self outline child block backgrounds selection float collapsed table borders foreground text clip outline mask
  • 42. render object tree owned by DOM tree only exists for rendered content responsible for layout and paint answers DOM API measurement requests
  • 43. render object tree DOM representation render objects HTMLBodyElement RenderBlock HTMLDivElement RenderBlock Text("foo") RenderText("foo") HTMLSpanElement RenderInline Text("bar") RenderText("bar")
  • 44. anonymous blocks DOM representation render objects HTMLBodyElement RenderBlock HTMLDivElement RenderBlock Text("foo") RenderBlock(anonymous) HTMLSpanElement RenderText("foo") Text("bar") RenderInline HTMLDivElement RenderText("bar") Text("baz") RenderBlock RenderText("baz")
  • 45. style tree contains all computed style values for renderers owned by render object tree RenderObjects share RenderStyles RenderStyles share data members
  • 46. render layer tree like helper class for rendering used for <video>, <canvas> with WebGL, positioned, transformed, transparent, masked, clipped, scrollable, or reflected elements establishes coordinate space and z-ordering at least one per document, sparsely maps to renderers
  • 47. render layer structure negative z-index list RenderLaye RenderLaye r Render r Layers RenderLayer positive z-index list RenderLaye RenderLaye r Render r Layers RenderObject RenderObject RenderObject
  • 48. render layer painting negative z-index list RenderLaye RenderLaye r Render r Layers 1 RenderLayer positive z-index list RenderLaye RenderLaye r Render r Layers RenderObject RenderObject RenderObject
  • 49. render layer painting negative z-index list RenderLaye RenderLaye r Render r Layers 2 RenderLayer positive z-index list RenderLaye RenderLaye r Render r Layers RenderObject RenderObject RenderObject
  • 50. render layer painting negative z-index list RenderLaye RenderLaye r Render r Layers RenderLayer 3 positive z-index list RenderLaye RenderLaye r Render r Layers RenderObject RenderObject RenderObject
  • 51. render layer painting, software paint the intersection of the paint dirty rect with all intersecting layers in order all layers render into the same output buffer
  • 52. render layer painting, hw accelerated some RenderLayers have backing store GPU texture used for 3D transforms, <video>, <canvas>/ plugins with 3D, stacking contexts, or sub- frames dirtied RenderLayers paint to GPU texture GPU composites textures onto final output buffer
  • 53. line box tree owned by RenderBlock one RootInlineBox per line RootInlineBox has list of InlineBoxes in that line each InlineBox has a RenderObject a renderer may have many InlineBoxes relies on RenderBlock for layout
  • 54. line box tree Markup: <div>foo<b>bar</b><br>baz</div> render tree line box tree RenderBlock(div) RenderBlock(div) RenderText("foo") RootInlineBox RenderInline(b) InlineTextBox("foo") RenderText("bar") InlineFlowBox(b) RenderBR InlineTextBox(b) RenderText("baz") InlineBox(br) RootInlineBox InlineTextBox("baz")
  • 55. layout changes to DOM marks renderers as dirty layout before paint or measurement from JS ● save old repaint rect ● bring in updates from DOM ● determine our preferred width ● layout children to determine height ● repaint difference between old and new rect
  • 56. layout changes to DOM marks renderers as dirty layout before paint or measurement from JS ● save old repaint rect ● bring in updates from DOM ● determine our preferred width ● layout children to determine height ● repaint difference between old and new rect
  • 57. review of main flow loader->parser->DOM tree->render tree render tree: ● RenderObject tree ● RenderLayer tree ● RenderStyle tree ● InlineBoxTree
  • 58. paint animations, blinking carets, layout, etc. trigger invalidations to embedder app app collects rects, triggers paint tree walk from root RenderLayer RenderObjects and InlineBoxes paint GraphicsContext abstraction
  • 59. hit testing constant during mouse move multiple phases tree walk from root RenderLayer RenderLayer transforms into local coordinates
  • 61. component model based on shadow DOM hides implementation ● events re-targeted ● shadow children inaccessible by regular DOM defined interface
  • 62. shadow DOM tree shadow boundary Do cu m en tt re e shadow host shadow root DOM child DOM child shadow child shadow child
  • 63. shadow render tree re nde rt re e shadow host shadow child shadow child
  • 64. integer layout layout currently uses integers fractional pixel values truncated breaks at non-1:1 zoom error accumulates
  • 65. 1.5x zoom is bad 150px * 1.5x = 225px (15px * 1.5x) * 10 = 220px
  • 66. sub-pixel layout integers replaced by fixed-point unit boxes snapped to pixel values supports sub-pixel CSS values error doesn't accumulate
  • 67. multi-process browsers centralized resources ● networking ● cache ● compositor ● plugins safety through sandboxing multiple main loops ≈ multi-core
  • 68. chrome architecture network stack browser process file io GPU process plugin process plugin processes shared memory gles2.0 instructions render textures processes
  • 69. thanks! questions? http://webkit.org http://chromium.org leviw@chromium.org Levi Weintraub