-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.short.html
690 lines (609 loc) · 19.7 KB
/
index.short.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>It's Not Dark Magic - Pulling Back the Curtains From Your Stylesheets</title>
<meta name="description" content="It's Not Dark Magic - Pulling Back the Curtains From Your Stylesheets">
<meta name="author" content="Aimee Knight">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css" id="theme">
<link rel="stylesheet" href="css/custom.css">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>It's Not Dark Magic</h1>
<h3>Pulling Back the Curtains From Your Stylesheets</h3>
<p>
<small>Created by
<a href="http://aimeemarieknight.com">Aimee Knight</a> /
<a href="http://twitter.com/Aimee_Knight">@Aimee_Knight</a>
</small>
</p>
<aside class="notes">
</aside>
</section>
<section>
<blockquote>A language that doesn't affect the way you think about programming is not worth knowing. - Alan J. Perlis</blockquote>
<aside class="notes">
dismiss as markup lang
<br>
does affect our thinking
</aside>
</section>
<section>
<img src="img/amk_skate.gif" style="width: 370px;">
<ul>
<li>Work For: Built Technologies</li>
<li>Hobbies: JavaScript Jabber, ⛸, 🏋, running</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<ul>
<li>Knowledge of internals can be useful for advanced debugging and performance tuning</li>
<li>In the future, we'll be able to modify the browsers rendering engine ourselves!</li>
</ul>
<aside class="notes">
my story - front end
<br>
guessing vs systematic
<br>
Houdini
</aside>
</section>
<section>
<h3>Can't I just use component based styling?<h3>
<aside class="notes">
gain specificty, lose the cascade
</aside>
</section>
<section>
<ul>
<li>Browser Internals</li>
<li>Parsing Process</li>
<li>Common Issues: specificity, positioning, z-index</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3>Rendering Engine Main Flow</h3>
<img src="img/dom_diagram.jpg">
<aside class="notes">
</aside>
</section>
<section>
<img src="img/bytes.jpg">
<aside class="notes">
</aside>
</section>
<section>
<h1>Conversion</h1>
<ul>
<li>Reading raw bytes of HTML & CSS off of disk/network</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<img src="img/characters.jpg">
<aside class="notes">
translates bytes to individual chars based on file encoding
</aside>
</section>
<section>
<img src="img/tokens.jpg">
<aside class="notes">
</aside>
</section>
<section>
<h1>Tokenizer</h1>
<ul>
<li>Breaks input into valid tokens.</li>
<li>HTML tokens: start tags, end tags, attribute names, attribute values</li>
<li>Strips irrelevant characters: white space, line breaks.</li>
</ul>
<aside class="notes">
often combined with lexing
</aside>
</section>
<section>
<h1>Tokenizer Output</h1>
<pre><code>["<", "html", ">",
"<", "head", ">",
"<", "title", ">", "My HTML Page", "</", "title", ">",
"</", "head", ">",
"<", "body", ">",
"<", "p", "style", "=", "\"", "special", "\"", ">",
"This paragraph has special style",
"</", "p", ">",
"<", "p", ">",
"This paragraph is not special",
"</", "p", ">",
"</", "body", ">",
"</", "html", ">"
]</code></pre>
<aside class="notes">
</aside>
</section>
<section>
<img src="img/syntax_analysis.jpg">
<aside class="notes">
emitted tokens from tokenization are converted into objects
</aside>
</section>
<section>
<h1>Parser</h1>
<ul>
<li>Reads the stream of tokens.</li>
<li>Analyzes the document structure according to the language grammar.</li>
</ul>
<aside class="notes">
grammer = vocabulary + syntax rules
</aside>
</section>
<section>
<img src="img/dom.jpg">
<aside class="notes">
Compiler parses source code into a tree structure
</aside>
</section>
<section>
<h1>DOM</h1>
<ul>
<li>Not context free</li>
<li>Never get a syntax error</li>
</ul>
<aside class="notes">
when parsing, have to take into account surrounding chars, what came before or after
<br>
edge cases
</aside>
</section>
<section>
<img src="img/fall_ice.gif">
<aside class="notes">
HTML = unconventional parser
</aside>
</section>
<section>
<img src="img/jump.gif">
<aside class="notes">
CSS = conventional parser
</aside>
</section>
<section>
<h3>Rendering Engine Main Flow</h3>
<img src="img/cssom_diagram.jpg">
<aside class="notes">
</aside>
</section>
<section>
<img src="img/confused.gif" >
<aside class="notes">
DOM and CSSOM are independent data structures
<br>
</aside>
</section>
<section>
<img src="img/cssom.jpg">
<aside class="notes">
AST/tree structure
<br>
Like HTML, need to convert CSS rules into something browser can understand.
<br>
Repeat HTML process for CSS
</aside>
</section>
<section>
<h1>CSSOM</h1>
<ul>
<li>Not 1 to 1 with the DOM</li>
<li>By default CSS is treated as a render blocking resource</li>
<li>Display none, script tags, meta tags, head element, etc. are omitted since they're not reflected in the rendered output</li>
</ul>
<aside class="notes">
DOM tree captures properties + relationship to doc markup
<br>
Doesn't tell how element look rendered. That’s responsibility of CSSOM
</aside>
</section>
<section>
<h3>Rendering Engine Main Flow</h3>
<img src="img/render_tree_diagram.jpg">
<aside class="notes">
</aside>
</section>
<section>
<img src="img/render_tree_construction.jpg">
<aside class="notes">
tree is of visual elements in order in which displayed
</aside>
</section>
<section>
<h1>Render Tree</h1>
<h4>DOM + CSSOM</h4>
<ul>
<li>Visual representation of the document</li>
<li>Enable painting the contents in their correct order</li>
<li>CSSOM can have drastic effects on the render tree but none on the DOM tree</li>
</ul>
<aside class="notes">
since CSSOM can reorder nodes
</aside>
</section>
<section>
<h1>Render Tree</h1>
<ul>
<li>Each node in the DOM tree that produces visual output has a corresponding render object in the render tree</li>
<li>Each render object knows how to layout and paint itself and its children</li>
<li>Includes geometric information like width, height and position</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Construction</h1>
<ul>
<li>Starting at the root of the DOM tree, traverse each node</li>
<li>Omit non visible nodes</li>
<li>For each visible node find the matching CSSOM rules and apply it</li>
<li>Emit visible nodes with content and computed styles</li>
<li>Output a render tree that contains both the content and style information of all visible content on the screen</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Rendering Phases</h1>
<ul>
<li>Layout ↓</li>
<li>Paint ↓</li>
<li>Composite ↓</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3>Rendering Engine Main Flow</h3>
<img src="img/layout_diagram.jpg">
<aside class="notes">
perf tab
</aside>
</section>
<section>
<img src="img/dev_tools_layout.png" style="width: 80%">
<aside class="notes">
</aside>
</section>
<section>
<h1>Layout</h1>
<h4>(AKA Reflow)</h4>
<ul>
<li>Calculating the position and size of the tree's render objects</li>
<li>The output of the layout process is a box model that contains the position and size of every element within the viewport</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3>Rendering Engine Main Flow</h3>
<img src="img/paint_diagram.jpg">
<aside class="notes">
</aside>
</section>
<section>
<img src="img/dev_tools_paint.png" style="width: 80%">
<aside class="notes">
</aside>
</section>
<section>
<h1>Paint</h1>
<h4>(AKA Rasterizing)</h4>
<ul>
<li>Converts each node in the render tree to actual pixels on the screen</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Painting Time</h1>
<ul>
<li>The bigger the width and height of the element, the longer the painting time</li>
<li>Adding different effects also increases painting time</li>
<li>Paint is usually the most expensive component of the render pipeline</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Painting Time</h1>
<ul>
<li>Float: 14ms</li>
<li>Flexbox: 3.5ms</li>
</ul>
<aside class="notes">
keep up with css skills
</aside>
</section>
<section>
<h1>Painting Order</h1>
<ul>
<li>Follows order that elements are stacked in their stacking contexts (back to front)</li>
<li>Can be global or incremental</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<img src="img/repaint.gif">
<aside class="notes">
Incremental: when styles change render obj becomes invalid = dirty region = generate paint
</aside>
</section>
<section>
<h3>Rendering Engine Main Flow</h3>
<img src="img/composite_diagram.jpg">
<aside class="notes">
</aside>
</section>
<section>
<img src="img/composite_dev_tools.png">
<aside class="notes">
layers tab
</aside>
</section>
<section>
<h1>Composite</h1>
<ul>
<li>Render different elements of a web page in different layers</li>
<li>Action of flattening all layers into the final image that is visible on the screen</li>
</ul>
<aside class="notes">
hardware acceleration = compositing
<br>
GPU
</aside>
</section>
<section>
<h3>Rendering performance</h3>
<ul>
<li>Adding a DOM node will cause relayout and repaint of the parent node</li>
<li>Increasing font size of the html element will cause relayout and repaint of the entire tree</li>
<li>Changes to an element's color will only repaint that element</li>
<li>Transforms and opacity are the only properties which trigger composite</li>
<li>Layout always triggers paint since changing the geometry of element means the pixels need to be fixed</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Specificity</h1>
<pre><code><div class="container">
<div id="main">
<p>
<a href="#">Link</a>
</p>
</div>
</div></code></pre>
<pre><code>#main a {
color: green;
}
p a {
color: yellow;
}
.container #main a {
color: pink;
}
div #main p a {
color: orange;
}
a {
color: red;
}</code></pre>
<aside class="notes">
</aside>
</section>
<section>
<img src="img/sponge_bob.gif">
<h1 class="fragment fade-in">Answer: <span style="color:#FF69B4;">Pink!</span></h1>
</section>
<section>
<h1>Specificity</h1>
<ul>
<li>You can read values as if they were a number. 0,1,1,1 = 111.</li>
<li>Commas are there to remind us that it's not a base 10 system.</li>
<li>Can have a specificity value of 0,1,13,4 and 13 won't spill over like a base 10 system.</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<table style="font-size: 70%">
<tr>
<th>
<h5>Selector</h5>
</th>
<th>
<h5>Specificity Value (<span style="color: #9932CC">A</span>,<span style="color: #00BFFF">B</span>,<span style="color: #7CFC00">C</span>,<span style="color: #EE82EE">D</span>)</h5>
</th>
</tr>
<tr>
<td>.container #main a</td>
<td><span style="color: #EE82EE">0</span>,<span style="color: #9932CC">1</span>,<span style="color: #00BFFF">1</span>,<span style="color: #7CFC00">1</span></td>
</tr>
<tr>
<td>div #main p a</td>
<td><span style="color: #EE82EE">0</span>,<span style="color: #9932CC">1</span>,<span style="color: #00BFFF">0</span>,<span style="color: #7CFC00">3</span></td>
</tr>
<tr>
<td>#main a</td>
<td><span style="color: #EE82EE">0</span>,<span style="color: #9932CC">1</span>,<span style="color: #00BFFF">0</span>,<span style="color: #7CFC00">1</span></td>
</tr>
<tr>
<td>p a</td>
<td><span style="color: #EE82EE">0</span>,<span style="color: #9932CC">0</span>,<span style="color: #00BFFF">0</span>,<span style="color: #7CFC00">2</span></td>
</tr>
<tr>
<td>a</td>
<td><span style="color: #EE82EE">0</span>,<span style="color: #9932CC">0</span>,<span style="color: #00BFFF">0</span>,<span style="color: #7CFC00">1</span></td>
</tr>
</table>
<p class="fragment fade-in" style="color: #EE82EE; font-size: 40px !important">A: Styles attribute (1,0,0,0 points)</p>
<p class="fragment fade-in" style="color: #9932CC; font-size: 40px !important">B: Number of ID selectors (0,1,0,0 points)</p>
<p class="fragment fade-in" style="color: #00BFFF; font-size: 40px !important">C: Number of class selectors, attribute selectors, pseudo-classes (0,0,1,0 points)</p>
<p class="fragment fade-in" style="color: #7CFC00; font-size: 40px !important">D: Number of type selectors, pseudo-elements (0,0,0,1 points)</p>
<aside class="notes">
</aside>
</section>
<section>
<h3>Positioning and Layout</h3>
<img src="img/css_is_awesome.jpg">
<aside class="notes">
Layout is a recursive process
</aside>
</section>
<section>
<h1>Positioning and Layout</h1>
<ul>
<li>Width: Computed by the current render object</li>
<li>Height: For each child, the current render object determines the position of the child, asks the child to compute its dimensions, then the current render object can compute its height</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Z -Index</h1>
<img src="img/so_hard.gif" >
<aside class="notes">
appears so simple, so most devs don’t dig deeper
</aside>
</section>
<section>
<h1>Stacking Context</h1>
<ul>
<li>A three-dimensional representation of HTML elements along an imaginary z-axis</li>
<li>Groups of elements with a common parent that move forward or backward together</li>
</ul>
<aside class="notes">
stacking contexts is key
</aside>
</section>
<section>
<h1>Stacking Context</h1>
<ul>
<li>Root Stacking Context: created by an html element</li>
<li>Local Stacking Context: created by specific properties and values</li>
<li>Within a local stacking context, the z-index values of children are relative to the root element rather than to the document root</li>
<li>Layers outside of a context (sibling elements of a local stacking context) can't sit between layers within another context</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Stacking Context Rules</h1>
<ul>
<li>Higher values are stacked in front of lower values</li>
<li>Auto z-index values and elements with the same value are stacked according to appearance in the HTML</li>
<li>Max value: 2,147,483,647</li>
</ul>
<aside class="notes">
billion, million, thousand, hundred
<br>
max signed value of 32 bit int. limitation from browser prog lang
</aside>
</section>
<section>
<h1>Surprise</h1>
<img src="img/shock.gif" >
<aside class="notes">
where things get complicated
</aside>
</section>
<section>
<h3>z-index isn't the only way to create a stacking context!</h3>
<aside class="notes">
</aside>
</section>
<section>
<h1>New Stacking Contexts</h1>
<ul>
<li>opacity: less than 1</li>
<li>filter: values besides none</li>
<li>mix-blend-mode: values besides normal</li>
<li>transform values besides none. Examples: scale(1), translate3d(0,0,0)</li>
</ul>
<aside class="notes">
BLEND MODE: how px interact px layer below
<br>
SCALE: size
<br>
translate3D: GPU transitions smoother
</aside>
</section>
<section>
<blockquote>Computers are good at following instructions, but not at reading your mind. - Donald Knuth</blockquote>
<aside class="notes">
debug systematic like JS
</aside>
</section>
<section style="text-align: left;">
<h1>Thank you!</h1>
<ul>
<li><a href="https://twitter.com/Aimee_Knight">@Aimee_Knight</a></li>
<li><a href="https://github.com/AimeeKnight">GitHub: AimeeKnight</a></li>
</ul>
</section>
<section>
<ul>
<li>
<a href="https://gist.github.com/AimeeKnight/77b36738ec876965c6db5c6d39f4ef4f">References</a>
</li>
</ul>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true }
]
});
</script>
</body>
</html>