-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.cp.html
1183 lines (1063 loc) · 33.9 KB
/
index.cp.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
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!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/blinds.gif" >
<aside class="notes">
Trying to fix someone else's CSS
</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>
<li>Likes: 😻😻, 🍵, kombucha</li>
</ul>
<aside class="notes">
NSS
</aside>
</section>
<section>
<ul>
<li>Software developers spend more time reading than writing source code</li>
<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">
why it’s important
<br>
my story - front end
<br>
guessing vs systematic
</aside>
</section>
<section>
<h3>Houdini</h3>
<ul>
<li>Normalize cross-browser differences</li>
<li>Invent or polyfill new features</li>
</ul>
<aside class="notes">
APIs to extend CSS/hook into rendering engine
<br>
bootstrap: just avoids
<br>
jQuery for CSS
</aside>
</section>
<section>
<blockquote>Low-level programming is good for the programmer’s soul. – John Carmack</blockquote>
<aside class="notes">
</aside>
</section>
<section>
<h3>Can't I just use component based styling?<h3>
<aside class="notes">
</aside>
</section>
<section>
<ul>
<li>No longer able to change one variable to update all colors</li>
<li>Unable to affect children by parent classes</li>
</ul>
<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>Vocabulary</h3>
<table style="font-size: 80%">
<tr>
<td>Browsers</td>
<td>
<ul>
<li>Chromium</li>
<li>Chrome</li>
</ul>
</td>
</tr>
<tr>
<td>Rendering Engines</td>
<td>
<ul>
<li>Webkit <i>(Safari)</i></li>
<li>Blink <i>(Chrome, Opera)</i></li>
<li>Gecko <i>(Firefox)</i></li>
<li>Trident <i>(IE)</i></li>
<li>EdgeHTML <i>(Edge)</i></li>
</ul>
</td>
</tr>
<tr>
<td>JavaScript Engines</td>
<td>
<ul>
<li>Nitro <i>(Safari)</i></li>
<li>V8 <i>(Chrome)</i></li>
<li>SpiderMonkey <i>(Firefox)</i></li>
<li>Chakra <i>(IE)</i></li>
<li>Chakra <i>(Edge)</i></li>
</ul>
</td>
</tr>
</table>
<aside class="notes">
Open source browser vs rendering/layout engine
<br>
Webkit (apple) forked into blink, EdgeHTML = fork of trident
<br>
2m loc
<br>
each tab = own rendering engine
</aside>
</section>
<section>
<h1>So, how do browsers actually work? 🤔</h1>
<aside class="notes">
</aside>
</section>
<section>
<img src="img/custom_layers.jpg">
<aside class="notes">
UI: address bar, back/fwd btn, bookmarking menu, All seen minus window.
BROWSER ENGINE: mediator.
RENDERING ENGINE: parse & display HTML CSS.
NETWORKING: HTTP requests.
UI BACKEND: drawing = OS.
JS INTERPRETER. Parse & execute JS.
DATA STORAGE: cookies, localStorage.
</aside>
</section>
<section>
<h3>Rendering Engine Main Flow</h3>
<img src="img/pipeline_diagram.jpg">
<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/html_parser.jpg">
<aside class="notes">
</aside>
</section>
<section>
<img src="img/how_browsers_work_breakdown.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>
<h1>Recap</h1>
<ul>
<li>Browser sends HTTP request for page</li>
<li>Web server sends response</li>
<li>Browser converts response data (bytes) into tokens, via tokenization</li>
<li>Browser turns tokens into nodes</li>
<li>Browser turns nodes into the DOM tree</li>
<li>DOM tree construction finished</li>
<li>Pause for CSSOM tree construction</li>
</ul>
<aside class="notes">
</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>By default CSS is treated as a render blocking resource</li>
<li>Browser will hold rendering of any process until the CSSOM is constructed</li>
</ul>
<aside class="notes">
encounter link tag in head for sheet. dispatches req
<br>
STOP? scripts asking for style information during doc parsing. If style not loaded & parsed, script = wrong answers
<br>
incremental = because of cascade. RED => BLUE: jarring
</aside>
</section>
<section>
<img src="img/css_parser.jpg">
<aside class="notes">
</aside>
</section>
<section>
<h1>CSSOM</h1>
<ul>
<li>CSS files are parsed into <strong style="color: #42affa">stylesheet objects</strong></li>
<li>Each stylesheet object contains a CSS <strong style="color: #42affa">rules object</strong></li>
<li>Each rules object contains <strong style="color: #42affa">selector and declaration objects</strong> and <strong style="color: #42affa">other objects corresponding to CSS grammar</strong></li>
</ul>
<aside class="notes">
to compute final styles for obj on pg, browser starts with most general rule for a node (body element) then recursively computed styles by applying more specific rules (cascade)
</aside>
</section>
<section>
<h1>CSSOM</h1>
<ul>
<li>Not 1 to 1 with the DOM</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
<br>
hidden visibility WILL appear
</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>Purpose</h1>
<ul>
<li>Knows how to layout and paint itself and its children</li>
<li>Includes geometric information like width, height and position</li>
<li>Each node in the DOM tree that produces visual output has a corresponding render object in the render tree</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">
Chrome DevTools perf tab capture
</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</h1>
<ul>
<li>Multiple rounds of painting can be caused by JS being loaded that changes the DOM</li>
<li>Includes: text, colors, shadows, background images, etc.</li>
<li>Changing any property besides transform or opacity will always trigger paint</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Painting Time</h1>
<ul>
<li>Time varies based on render tree construction</li>
<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">
(2) first thing to look for is the area of the element
</aside>
</section>
<section>
<h1>Painting Time</h1>
<ul>
<li>Float: 14ms</li>
<li>Flexbox: 3.5ms</li>
</ul>
<aside class="notes">
<br>
flexbox is great from a usability standpoint
<br>
experiment
<br>
keep up with css skills
</aside>
</section>
<section>
<h1>Painting Order</h1>
<ul>
<li>Follows order that elements are stacked in their stacking contexts</li>
<li>Painted from 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">
</aside>
</section>
<section>
<h1>Composite</h1>
<ul>
<li>Render different elements of a web page in different layers (think photoshop 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 = speed up vs old CPU
<br>
cache & group chunks of render tree
<br>
painted parts put together
</aside>
</section>
<section>
<h3>Rendering performance</h3>
<ul>
<li>Changes to the element's position will cause relayout and repaint of that element, its children and possibly siblings</li>
<li>Adding a DOM node will cause relayout and repaint of the parent node</li>
<li>Major changes, like 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 currently the only properties which only trigger composite</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Summary</h1>
<ul>
<li>Browsers try to do the minimal possible actions in response to a change</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>
<img src="img/delete.gif" >
<aside class="notes">
ever moved something around only to see another part of page break?
</aside>
</section>
<section>
<img src="img/tweet.png" >
<aside class="notes">
me!
</aside>
</section>
<section>
<blockquote>The amateur software engineer is always in search of magic. - Grady Booch</blockquote>
<aside class="notes">
</aside>
</section>
<section>
<h1>Specificity</h1>
<ul>
<li>Many ways to target a specific tag using CSS selectors</li>
<li>Applying rules in correct cascade order</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Specificity</h1>
<ul>
<li>If multiple CSS selectors are targeting the same set of HTML elements, and if the CSS selectors are trying to assign the same property/properties to the HTML elements, the selector with the highest specificity value will win</li>
<li>Browser needs a way to negotiate which style it should give to a specific tag</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Specificity</h1>
<ul>
<li>Browser makes a decision by first calculating each selectors' specificity value</li>
<li>Second, it checks which selector has the highest value to determine the winner</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h3>Selector Prerequisite Refresher</h3>
<table>
<tr>
<th>
<h4>Type</h4>
</th>
<th>
<h4>Examples</h4>
</th>
</tr>
<tr>
<td>Attribute selectors</td>
<td>
<ul>
<li>[target="blank"]</li>
<li>[type="text"]</li>
</ul>
</td>
</tr>
<tr>
<td>Pseudo-classes</td>
<td>
<ul>
<li>:hover</li>
<li>:visited</li>
</ul>
</td>
</tr>
<tr>
<td>Pseudo-elements</td>
<td>
<ul>
<li>::before</li>
<li>::after</li>
</ul>
</td>
</tr>
</table>
<aside class="notes">
all know type (div)
</aside>
</section>
<section>
<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">
had to write down my calculations on a piece of paper
</aside>
</section>
<section>
<h4>Specificity value: 0,1,2,2</h4>
<pre><code>#header .navbar li a:visited</code></pre>
<table>
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
</tr>
<tr>
<td>0</td>
<td>1</td>
<td>2</td>
<td>2</td>
</tr>
</table>
<aside class="notes">
0 style attrs, 1 id, 1 class + 1 pseudo-class, 2 type selectors (li, a)
</aside>
</section>
<section>
<h1>Positioning</h1>
<img src="img/css_is_awesome.jpg">
<aside class="notes">
process of determining the position and size of all boxes = going back to layout
</aside>
</section>
<section>
<h1>Positioning</h1>
<h4>Normal & Relative</h4>
<ul>
<li>Normal: The object is positioned according to its place in the document, box type, and dimensions</li>
<li>Relative: Positioned like usual and then moved by the required delta</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Positioning</h1>
<h4>Float</h4>
<ul>
<li>The object is first laid out in normal flow, then moved as far left or right as possible</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Positioning</h1>
<h4>Absolute</h4>
<ul>
<li>The object is put in the render tree in a different place than in the DOM tree</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Positioning Phases</h1>
<ul>
<li>Layout is a recursive process</li>
<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>
<img src="img/layout.jpg" style="width: 80%">
<aside class="notes">
parent tells child to fit into it’s width
<br>
1. Width, 2. Height
</aside>
</section>
<section>
<h1>Global Layout</h1>
<ul>
<li>Layout can be triggered on the entire render tree as a result of a global style change that affects all render objects</li>
<li>Triggered synchronously</li>
<li>Example: font size change, screen being resized</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Incremental layout</h1>
<ul>
<li>Only dirty render objects will be laid out</li>
<li>Triggered asynchronously</li>
<li>Example: new render objects are appended to the render tree after extra content came from the network and was added to the DOM tree</li>
</ul>
<aside class="notes">
</aside>
</section>
<section>
<h1>Z -Index</h1>
<p>Every element in an HTML document can be either in front of or behind every other element in the document</p>
<aside class="notes">
elements with higher z-index are stacked in front of elements with lower z-index
</aside>
</section>
<section>
<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 relative to the user facing the viewport</li>
<li>An element that contains a set of layers</li>
<li>Groups of elements with a common parent that move forward or backward together</li>
</ul>
<aside class="notes">
understanding of stacking contexts is key
</aside>
</section>
<section>
<h1>Stacking Order</h1>
<ul>
<li>Every stacking context has a single HTML element as its root element</li>
<li>When z-index and position properties aren’t involved, the rules are simple: the stacking order is the same as the order of appearance in the HTML</li>
</ul>
<aside class="notes">
POSITIONED: relative, absolute, etc. (value other than static)
</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</h1>
<ul>
<li>When a new stacking context is formed on an element, that stacking context confines all of its child elements to a particular place in the stacking order</li>
<li>If an element is contained in a stacking context at the bottom of the stacking order, there is no way to get it to appear in front of another element in a different stacking context</li>
</ul>
<aside class="notes">
<br>
diff contexts ? can't even change even with a z-index of billion!