Skip to content

Instantly share code, notes, and snippets.

@pcwalton
pcwalton / dom-strawman.rs
Created July 24, 2019 20:35
Strawman proposal
// The cardinal rule is to never borrow the inside of a DOM object.
// DOM objects don't look like Rust objects to Rust code; their fields are only accessed
// with getters and setters.
// By forbidding borrowing DOM objects, most of the problems disappear.
dom_defclass! {
class Node {
parent_node: NullableJS<Node>,
first_child: NullableJS<Node>,
last_child: NullableJS<Node>,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pcwalton
pcwalton / smoothstep-replacement.inc.glsl
Created March 20, 2019 21:48
smoothstep-replacement.inc.glsl
float aastep(float edge0, float edge1, float x) {
float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0) - 0.5;
return 1.14191 * t - 0.83570 * t * t * t;
}
struct LayoutObjectRef<T>(Arc<RwLock<LayoutObject<T>>>);
struct LayoutObject<T> {
style: Arc<ComputedValues>,
// position? borders? padding? margins?
contents: T,
}
struct BlockFormattingContext(BlockOrInline);
@pcwalton
pcwalton / webrender-benefits.md
Created January 17, 2019 00:18
WebRender benefits

WebRender benefits

Fundamentally, WebRender is designed to render CSS with better performance on modern hardware than what the traditional combination of a legacy painting API like Skia and a compositor can offer. It does so by merging the painting and compositing steps together into a single API, avoiding the performance pitfalls associated with CSS properties that don't run on the compositor. Instead of an immediate mode API in which objects are rendered back-to-front, WebRender uses a retained mode API that can render objects in any order. Ultimately, WebRender works more like a game engine than a legacy PostScript-like 2D API, which is

@pcwalton
pcwalton / ugly-wip-ca-patch.diff
Created September 11, 2018 22:35
ugly-wip-ca-patch.diff
diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -188,3 +188,7 @@ subinclude:servo/.hgignore
^testing/raptor/raptor-venv
^testing/raptor/raptor/tests/.*.json
^testing/raptor/webext/raptor/auto_gen_test_config.js
+
+^wr-capture
+wr-record.*\.bin
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Monument</title>
<style>
/*@keyframes spin {
from { transform: rotateY(0) scale(10); }
to { transform: rotateY(360deg) scale(30); }
// pathfinder/shaders/gles2/stencil-aaa.fs.glsl
//
// Copyright (c) 2018 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
position: absolute;
top: 0;
left: 0;