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

[css-sizing] Is the last remembered size recorded if there is size containment in a single axis? #7529

Open
Loirooriol opened this issue Jul 23, 2022 · 4 comments

Comments

@Loirooriol
Copy link
Contributor

From https://drafts.csswg.org/css-sizing-4/#last-remembered

At the time that ResizeObserver events are determined and delivered, if an element has contain-intrinsic-size: auto, is capable of being a ResizeObserver target, but does not have size containment, record the current inner dimensions of its principal box as its last remembered size.

What if the element has contain: inline-size?

  • The dimensions are recorded as the last remembered size, as would happen with no containment.
  • The dimensions are not recorded as the last remembered size, as would happen with full size containment.
  • Only the block dimension is recorded as the last remembered block size. This would imply that the dimensions are recorded independently, and probably it should be the same when contain-intrinsic-size has auto in a single axis ([css-sizing] Last remembered size relies on unclear contain-intrinsic-size: auto #7516).
@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed Is last-remembered size recorded if size containment in single axis?, and agreed to the following:

  • RESOLVED: "last remembered size" is tracked for the two axises independently (in case of containment in one axis), and can be invoked independently (with c-i-s:auto in one axis)
The full IRC log of that discussion <fantasai> Subtopic: Is last-remembered size recorded if size containment in single axis?
<fantasai> github: https://github.com//issues/7529
<fantasai> oriol: we are only storing last remembered size if there's not size containment
<fantasai> oriol: however, in newer specs of css-contain, we may have size containment in a single axis
<fantasai> oriol: what happens?
<fantasai> oriol: Are we still storing both width and height of last remembered size?
<fantasai> oriol: do we not update last remembered size in the uncontained axis?
<fantasai> oriol: shoudl we check at least one of the axes has size containment and then store both?
<fantasai> oriol: how should this work exactly?
<fantasai> TabAtkins: this is a very good question
<fantasai> Rossen_: do you have a proposal, Oriol?
<fantasai> oriol: maybe would feel more natural to me to do independently rather than together
<fantasai> oriol: right now Chromium stores together
<TabAtkins> q+
<flackr> q+
<fantasai> oriol: I don't have a strong opinion
<Rossen_> ack TabAtkins
<fantasai> TabAtkins: I think I lean toward tracking them together, just because say you have a set width and you have a contained block size
<fantasai> TabAtkins: whatever block size you want to remember, that depends on your width
<fantasai> TabAtkins: if you end up with a different width, your height is not going to be very meaningful
<fantasai> TabAtkins: it's weird to expect a different width also
<fantasai> TabAtkins: but I feel either record both or record neither
<fantasai> TabAtkins: and you need to have containment to get sizing to trigger
<fantasai> flackr: I was going to suggest the opposite
<Rossen_> ack flackr
<fantasai> flackr: reason beign that the only way that you have containment in one axis by it being an explicit style, whereas containment in both axes is because of content-visiblity and being off-screen
<fantasai> flackr: if the developer, while on screen, has containment in one axis
<fantasai> flackr: then it should ??? last remembered size when it goes off screen
<fantasai> Rossen_: that's a compelling argument
<fantasai> TabAtkins: that seems reasonable
<fantasai> Rossen_: sounds like we're approaching a resolution
<fantasai> Rossen_: proposed resolution is that we'll keep them separate, and store them separate
<fantasai> Rossen_: any objections?
<flackr> s/???/store the
<TabAtkins> RESOLVED: "last remembered size" is tracked for the two axises independently (in case of containment in one axis), and can be invoked independently (with c-i-s:auto in one axis)

@vmpstr
Copy link
Member

vmpstr commented Aug 2, 2022

To clarify, I think the minutes and the discussion don't quite match the resolution. I believe that we have decided that contain-intrinsic-size auto records last remembered size (both width and height) even if size containment is set in one of the two dimensions. Is my understanding correct?

The resolution seems to imply that we should not record it for one dimension size containment, since that would be the only reason to record the axes separately, but it doesn't explicitly say whether or not to record the dimension that is contained

@Loirooriol
Copy link
Contributor Author

My understanding is that we decided to only record the one that has contain-intrinsic-size: auto but not the other.

@Loirooriol
Copy link
Contributor Author

#7807 resolved to update the last remembered size if the element doesn't skip its contents, even if it has size containment. So contain: inline-size is no longer relevant, and it's not possible to only skip contents in one axis.

It's still possible to have contain-intrinsic-size set to auto in only one axis, though.

webkit-commit-queue pushed a commit to cathiechen/WebKit that referenced this issue Feb 28, 2023
https://bugs.webkit.org/show_bug.cgi?id=249919

Reviewed by Oriol Brufau.

According to [1], "last remembered size" is tracked for the two axises independently, and can be invoked independently.
This patch supports "last remembered size" in a single direction. It replaces the m_lastRememberedSize of
m_lastRememberedLogicalWidth and m_lastRememberedLogicalHeight in ElementRareData. The value -1 means there is
no last remembered width/height.

[1] w3c/csswg-drafts#7529

* LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-009-expected.txt:
* Source/WebCore/dom/ContainerNode.cpp:
(WebCore::ContainerNode::removeChild):
* Source/WebCore/dom/Document.cpp:
(WebCore::CallbackForContainIntrinsicSize):
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::lastRememberedLogicalWidth const):
(WebCore::Element::lastRememberedLogicalHeight const):
(WebCore::Element::setLastRememberedLogicalWidth):
(WebCore::Element::clearLastRememberedLogicalWidth):
(WebCore::Element::setLastRememberedLogicalHeight):
(WebCore::Element::clearLastRememberedLogicalHeight):
(WebCore::Element::lastRememberedSize const): Deleted.
(WebCore::Element::setLastRememberedSize): Deleted.
(WebCore::Element::clearLastRememberedSize): Deleted.
* Source/WebCore/dom/Element.h:
* Source/WebCore/dom/ElementRareData.cpp:
* Source/WebCore/dom/ElementRareData.h:
(WebCore::LayoutUnitMarkableTraits::isEmptyValue):
(WebCore::LayoutUnitMarkableTraits::emptyValue):
(WebCore::ElementRareData::lastRememberedLogicalWidth const):
(WebCore::ElementRareData::lastRememberedLogicalHeight const):
(WebCore::ElementRareData::setLastRememberedLogicalWidth):
(WebCore::ElementRareData::setLastRememberedLogicalHeight):
(WebCore::ElementRareData::clearLastRememberedLogicalWidth):
(WebCore::ElementRareData::clearLastRememberedLogicalHeight):
(WebCore::ElementRareData::useTypes const):
(WebCore::ElementRareData::lastRememberedSize const): Deleted.
(WebCore::ElementRareData::setLastRememberedSize): Deleted.
(WebCore::ElementRareData::clearLastRememberedSize): Deleted.
* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::explicitIntrinsicInnerWidth const):
(WebCore::RenderBox::explicitIntrinsicInnerHeight const):
* Source/WebCore/rendering/style/RenderStyle.h:
(WebCore::RenderStyle::containIntrinsicLogicalWidthType const):
(WebCore::RenderStyle::containIntrinsicLogicalHeightType const):
* Source/WebCore/rendering/updating/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::updateElementRenderer):

Canonical link: https://commits.webkit.org/260939@main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Tuesday
Development

No branches or pull requests

3 participants