Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update rust crate taffy to 0.7 #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Feb 14, 2024

This PR contains the following updates:

Package Type Update Change
taffy dependencies minor 0.3 -> 0.7

Release Notes

DioxusLabs/taffy (taffy)

v0.7.0

Compare Source

Changed
  • BREAKING: The cache_mut method on the LayoutPartialTree trait has been replaced with a separate CacheTree trait. This allows
    Taffy to be more easily used without caching or with a custom cache implementation.
  • BREAKING: the TaffyTree::set_children method now removes the children from their previous parent (if they have one).
Added
  • Helper methods to retrieve content-box sizes were added to Layout

v0.6.3

Compare Source

Fixes
  • Block: ignore margin collapsing when computing static position of abspos items (#​747)

v0.6.2

Compare Source

Fixes
  • Fix: clamp indefinite available space by min- and max- size as appropriate (#​742)

v0.6.1

Compare Source

Fixes
  • Fix calculation of auto-fill/auto-fit repetition count when container has a definite percentage size (#​722)
  • Fix min-size style not affecting intrinsic sizes (#​723)
  • Fix documentation of dirty and mark_dirty functions (#​724)
  • Fix intrinsic size of scroll containers that have a small explicit flex-basis (#​728)

v0.6.0

Compare Source

Highlights
  • The Style struct has been "traitified". This supports Taffy's integration in Servo and generally makes Taffy more flexible. The
    Style struct still exists and implements the new traits so existing uses of Taffy will continue to work as before.
  • The box-sizing style is supported
  • Computed margins are output in Layout
Fixes
  • Fix print_tree() when rounding is disabled (#​680)
  • Absolute Insets should be resolved against the container size minus border (#​666)
  • Fix flooring hypothetical_main_size by computed min size (#​689)
  • Fix flex line cross-size determination (#​690)
  • Fix panics in the grid algorithm (#​691)
  • Fix resolving flexible lengths (WPT css/flexbox-multiline-min-max test) (#​692)
  • Fix wrapping when a max main size style is present (#​694)
  • Fix case where Taffy allowed margins to collapse through an element when it shouldn't have (#​695)
Added
  • Legacy text align (for laying out <center> and <div align="..">) is supported
  • Add is_table for block items (#​701)
  • Impl Debug and Clone for Cache (#​688)
  • Implement Debug and PartialEq for tree types (#​697)

v0.5.2

Compare Source

  • Fix block stretch sizing (don't always apply stretch sizing to block containers) (#​674)
  • Fix computation of intrinsic main size when it depends on a child's known cross size (#​673)
  • Fix panic when GridLine 0 is specified (#​671)
  • Docs: Document feature flags and scrape examples (#​672)
  • Docs: Update cosmic-text example to cosmic-text 0.12 (#​670)

v0.5.1

Compare Source

  • Fix: Clamp block item stretch widths by their min and max width (#​664)
  • Fix: Auto margin computation in block layout (#​663)

v0.5.0

Compare Source

The changes in 0.5 are relatively small but the new measure function parameter is a breaking change so it requires a minor version bump.

  • Added: A style: &Style parameter has been added to measure functions.
  • Added: The MaybeMath, MaybeResolve, and ResolveOrZero traits have been made public.
  • Fix: use SizingMode::Inherent when sizing absolute children of flexbox nodes.

v0.4.4

Compare Source

Fixes
  • Content alignment (align-content/justify-content) behaviour was updated to match the latest spec (and Chrome 123+) (#​635)
  • Ensure that root Flexbox nodes are floored by their padding-border (#​651, #​655)
  • Use grid area size not available space when applying aspect ratio to grid containers (#​656)

v0.4.3

Compare Source

Fixes
  • Fix compilation error in evenly_sized_tracks style helper in recent versions of rustc caused by a change/regression in type
    inference (#​643). Note that 3rd-party code that call style helpers that take an Into<f32> parameter may still be affected by this issue,
    but they should be able to fix on their side by clarifying the type passed in

v0.4.2

Compare Source

  • Fixed: single-line flex-container should clamp the line's cross-size (#​638)
  • Reduced binary footprint of Taffy from around 300kb to around 150kb (#​636)

v0.4.1

Compare Source

  • Fixed: CSS Grid track sizing not respecting growth limits in some circumstances (#​624)

v0.4.0

Compare Source

Highlights
  • Support for CSS Block layout (display: block)
  • Support for the overflow property (+ scrollbar_width for overflow: scroll)
  • Improved measure function API
  • Completely refactored low-level API
  • Simplified module hierarchy (+ most types/functions are now exported from the crate root)
  • Expanded set of examples which better document integration with other layout systems (e.g. text layout)
  • Computed values for padding and border are now output into the Layout struct
Block layout

Support for CSS Block layout has been added. This can be used via the new Display::Block variant of the Display enum. Note that full flow layout: inline, inline-block and float layout have not been implemented. The use case supported is block container nodes which contain block-level children.

Overflow property

Support has been added for a new overflow style property with Visible, Clip, Hidden, and Scroll values (Auto is not currently implemented). Additionally a scrollbar_width property has been added to control the size of scrollbars for nodes with Overflow::Scroll set.

  • Overflow is settable indpendently in each axis.
  • Visible and Clip will produce layouts equivalent to the Taffy 0.3. Clip will affect the new content_size output by restricting it to the available space.
  • Hidden and Scroll affect layout by changing the automatic minimum size of Flexbox and Grid children
  • Scroll additionally reserves scrollbar_width pixels for a scrollbar in the opposite axis to which scrolling is enabled. Scroll with scrollbar_width set to zero is equivalent to Hidden.
Measure function changes

The "measure function" API for integrating Taffy with other measurement systems (such as text layout) has been changed to be more flexible
and to interact better with borrow checking (you can now borrow external data in your measure function!).

  • There are no longer per-node measure functions.
  • There is now a single "global" measure function, and a per-node "context" of a user-defined type
  • The Taffy tree is now a generic TaffyTree<T> where T is the "context" type.
  • The measure function is now called for all leaf nodes (nodes without children). If you wish to maintain compatibility with the previous
    behaviour then your measure function should return Size::ZERO for leaf nodes whose context is None.

If you are not using measure functions, then the only change you will need to make is from:

let mut tree = Taffy::new();

to

let mut tree : TaffyTree<()> = TaffyTree::new();

And generally update any uses of Taffy in your codebase to TaffyTree<()>.

If you are using measure functions then you will need to make some bigger (but straightforward) changes. The following Taffy 0.3 code:

let mut tree = Taffy::new();
let leaf = tree.new_leaf_with_measure(
  Style::DEFAULT,
  |known_dimensions: Size<Option<f32>>, available_space: Size<AvailableSpace>| Size { width: 100.0, height: 200.0 }
);
tree.compute_layout(leaf, Size::MAX_CONTENT);

Should become something like the following with Taffy 0.4:

let mut tree : TaffyTree<Size> = TaffyTree::new();
let leaf = tree.new_leaf_with_context(Style::DEFAULT, Size { width: 100.0, height: 200.0 });
tree.compute_layout_with_measure(
  leaf,
  Size::MAX_CONTENT,
  |known_dimensions: Size<Option<f32>>, available_space: Size<AvailableSpace>, node_id: NodeId, node_context: Option<Size>| {
    node_context.unwrap_or(Size::ZERO)
  }
);

Note that:

  • You can choose any type instead of Size in the above example. This includes your own custom type (which can be an enum or a trait object).
  • If you don't need a context then you can use () for the context type
  • As the single "global" measure function passed to compute_layout_with_measure only needs to exist for the duration of a single layout run,
    it can (mutably) borrow data from it's environment
Low-level API (LayoutTree trait) refactor

The low-level API has been completely reworked:

  • The LayoutTree trait has been split into 5 smaller traits which live in the taffy::tree:traits module (along with their associated documentation)
  • The following methods have been removed from split LayoutTree traits entirely: parent, is_childless, measure_node, needs_measure, and mark_dirty.
  • taffy::node::Node has been replaced with taffy::NodeId. This should make it much easier to implement the low-level traits as the underlying type backing the node id now a u64 rather than a slotmap::DefaultKey.
  • Support for running each layout algorithm individually on a single node via the following top-level functions:
    • compute_flexbox_layout
    • compute_grid_layout
    • compute_block_layout
    • compute_leaf_layout
    • compute_root_layout
    • compute_hidden_layout

It is believed that nobody was previously using the low-level API so we are not providing a migration guide. However, along with the refactor we have greatly
improved both the documentation and have added examples using the new API, both of which are linked to from the main documentation page.

Module hierarchy changes

The specific changes are detailed below. However for most users the most significant change will be that almost all types are now re-exported from the root module. This means that module specific imports like use taffy::layout::Layout can now in almost all cases be replaced with the simpler use taffy::Layout.

Specific changes:

  • The math module has been made private
  • The axis module has been merged into the geometry module
  • The debug module is no longer public. The print_tree function is now accessible under util.
  • All types from the node, data, layout, error and cache modules have been moved to the the tree module.
  • The layout_flexbox() function has been removed from the prelude. Use taffy::compute_flexbox_layout instead.
Many APIs have been renamed to replace points or Points with length or Length

This new name better describes one-dimensional measure of space in some unspecified unit
which is often unrelated to the PostScript point or the CSS pt unit.

This also removes a misleading similarity with the 2D Point,
whose components can have any unit and are not even necessarily absolute lengths.

Example usage change:

 use taffy::prelude::*;

 // …

 let header_node = taffy
     .new_leaf(
         Style {
-            size: Size { width: points(800.0), height: points(100.0) },
+            size: Size { width: length(800.0), height: length(100.0) },
             ..Default::default()
         },
     ).unwrap();
Other Changes
  • The Taffy type was renamed to TaffyTree and made generic of a context parameter
  • The Flexbox algorithm has now been moved behind the flexbox feature. The flexbox feature is enabled by default.
  • The justify_self property has been moved behind the grid feature.
  • Fixed misspelling: RunMode::PeformLayout renamed into RunMode::PerformLayout (added missing r).
  • serde dependency has been made compatible with no_std environments
  • slotmap dependency has been made compatible with no_std environments
  • Added insert_child_at_index() method to the TaffyTree. This can be used to insert a child node at any position instead of just the end.
  • Added total_node_count() method to the TaffyTree which returns the total number of nodes in the tree.
  • Added get_disjoint_node_context_mut() method to the TaffyTree. This can be used to safely get multiple mutable borrows at the same time.

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

Copy link
Contributor Author

renovate bot commented Feb 14, 2024

Branch automerge failure

This PR was configured for branch automerge. However, this is not possible, so it has been raised as a PR instead.


  • Branch has one or more failed status checks

@renovate renovate bot force-pushed the renovate/taffy-0.x branch from 86047d3 to 23f3f0f Compare May 1, 2024 11:04
@renovate renovate bot changed the title fix(deps): update rust crate taffy to 0.4 fix(deps): update rust crate taffy to 0.4.3 May 1, 2024
@renovate renovate bot force-pushed the renovate/taffy-0.x branch from 23f3f0f to fd8a226 Compare May 5, 2024 09:12
@renovate renovate bot changed the title fix(deps): update rust crate taffy to 0.4.3 fix(deps): update rust crate taffy to 0.4 May 5, 2024
@renovate renovate bot force-pushed the renovate/taffy-0.x branch from fd8a226 to 4fa1077 Compare May 30, 2024 23:18
@renovate renovate bot changed the title fix(deps): update rust crate taffy to 0.4 fix(deps): update rust crate taffy to 0.5 May 30, 2024
@renovate renovate bot force-pushed the renovate/taffy-0.x branch from 4fa1077 to 726fafa Compare October 11, 2024 02:45
@renovate renovate bot changed the title fix(deps): update rust crate taffy to 0.5 fix(deps): update rust crate taffy to 0.6 Oct 11, 2024
@renovate renovate bot force-pushed the renovate/taffy-0.x branch from 726fafa to e67b34a Compare December 12, 2024 06:55
@renovate renovate bot changed the title fix(deps): update rust crate taffy to 0.6 fix(deps): update rust crate taffy to 0.7 Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants