GithubHelp home page GithubHelp logo

Comments (2)

nicoburns avatar nicoburns commented on May 24, 2024

Not sure if you were intending to resolve percentages as part of this function (the ownerWidth/ownerHeight parameters suggest to me that you are), but it's worth noting that there can be cases where some percentages need to recompute and others don't (e.g. mid-way through laying out a node you want to recompute percentage gap but not percentage width). In which case such an "all or nothing" function may be awkward.

Taffy's solution to this is keep a struct of resolved styles on the stack of the equivalent function of calculateLayoutInternal, which we update incrementally throughout the layout process (and pass through to sub-functions by reference).


Also, as a point of terminology: "computed" values do not resolve percentages (and they couldn't because determining "computed" values is part of the style pass rather than the layout pass in browsers, and in the general case you don't have a value to resolve percentages against until you run layout). See: https://www.w3.org/TR/css-cascade-4/#stages-examples.

If you're not resolving percentages then this comment may not be relevant.

from yoga.

NickGerleman avatar NickGerleman commented on May 24, 2024

Also, as a point of terminology: "computed" values do not resolve percentages

That’s a good clarification. I missed the table, but saw “Computing a relative value generally absolutizes it” and reference to percentage computation against reference, and placed the phases together.

Computed style purely derived from style is convenient to work with because it’s only ever dirtied when the style changes, and we do already do repeated work for it during layout (e.g. all the “edgeValueForColumn” type of work.

I suspect we want to add caching for resolved absolute values from relative, given the same reference, if resolution can be more expensive (i.e. if Yoga or its user needs to evaluate a parser CSS math function) I’m not quite sure what lifetime and layering for that. E.g. measure cache is kept around after the layout, but I’m not sure if a more persistent cache makes sense here.

I was looking as having computed value accessor directly accept the reference value for a single value at once to be able to cache more granularity if we needed it.

from yoga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.