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

A Behind the Scenes Look at the Force.com Platform
A Behind the Scenes Look at the Force.com PlatformA Behind the Scenes Look at the Force.com Platform
A Behind the Scenes Look at the Force.com Platform
Salesforce Developers
 

What's hot (20)

Ride the database in JUnit tests with Database Rider
Ride the database in JUnit tests with Database RiderRide the database in JUnit tests with Database Rider
Ride the database in JUnit tests with Database Rider
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
JavaScript JQUERY AJAX
JavaScript JQUERY AJAXJavaScript JQUERY AJAX
JavaScript JQUERY AJAX
 
Microservice architecture case study
Microservice architecture case studyMicroservice architecture case study
Microservice architecture case study
 
A Behind the Scenes Look at the Force.com Platform
A Behind the Scenes Look at the Force.com PlatformA Behind the Scenes Look at the Force.com Platform
A Behind the Scenes Look at the Force.com Platform
 
Getting started with entity framework 6 code first using mvc 5
Getting started with entity framework 6 code first using mvc 5Getting started with entity framework 6 code first using mvc 5
Getting started with entity framework 6 code first using mvc 5
 
Web forms in ASP.net
Web forms in ASP.netWeb forms in ASP.net
Web forms in ASP.net
 
Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)
 
Arduino and the real time web
Arduino and the real time webArduino and the real time web
Arduino and the real time web
 
ASP.NET Web form
ASP.NET Web formASP.NET Web form
ASP.NET Web form
 
React / Redux Architectures
React / Redux ArchitecturesReact / Redux Architectures
React / Redux Architectures
 
Why GC is eating all my CPU?
Why GC is eating all my CPU?Why GC is eating all my CPU?
Why GC is eating all my CPU?
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
Imagecon 2019 - Jon Sneyers
Imagecon 2019 - Jon Sneyers Imagecon 2019 - Jon Sneyers
Imagecon 2019 - Jon Sneyers
 
Connection Pooling
Connection PoolingConnection Pooling
Connection Pooling
 
React js for beginners
React js for beginnersReact js for beginners
React js for beginners
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
jQuery
jQueryjQuery
jQuery
 
Spring Core
Spring CoreSpring Core
Spring Core
 

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

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

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