Skip to content

pcwalton/buoyancy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

buoyancy

This is a small crate that implements a fast algorithm for float placement according to the rules in CSS 2.1 § 9.5.1.

The cornerstone of the technique is a splay tree, which effectively accelerates the common case of placing an object right next to the most recent floats that were placed. Randomized testing suggests that, in practice, the algorithm places n floats in O(n) time. Even when an object ends up placed in more distant positions, the splay tree achieves O(log n) randomized performance. In the worst case, this algorithm is O(n²); however, this seems to be very rare in practice.

On my MacBook Pro with a 2.8 GHz Intel Core i7, this implementation places each float in 6 µs, approximately 160,000 floats per second.

The splay tree implementation is a modified version of splay-rs.

License

Licensed under the same terms as Rust itself.

About

A fast CSS float placement algorithm for Servo

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages