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
[content-visibility] Support content-visibility for resize/intersection observer #6973
Conversation
EWS run on previous version of this PR (hash 2d844de) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments about style, none of them important.
Source/WebCore/dom/Document.cpp
Outdated
if (targetRenderer->isSkippedContent()) | ||
intersectionState.isIntersecting = false; | ||
else | ||
intersectionState.isIntersecting = rootLocalTargetRect && rootLocalIntersectionRect.edgeInclusiveIntersect(*rootLocalTargetRect); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might have just added to the boolean expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -52,24 +52,26 @@ void ResizeObservation::updateObservationSize(const BoxSizes& boxSizes) | |||
m_lastObservationSizes = boxSizes; | |||
} | |||
|
|||
auto ResizeObservation::computeObservedSizes() const -> BoxSizes | |||
std::optional<ResizeObservation::BoxSizes> ResizeObservation::computeObservedSizes() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can write this for greater brevity:
auto ResizeObservation::computeObservedSizes() const -> std::optional<BoxSizes>
I suppose itβs a matter of taste which one is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like that notation better.
{ | ||
if (m_target->isSVGElement()) { | ||
if (auto svgRect = downcast<SVGElement>(*m_target).getBoundingBox()) { | ||
auto size = LayoutSize(svgRect->width(), svgRect->height()); | ||
return { size, size, size }; | ||
return BoxSizes { size, size, size }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another alternative is:
return { { size, size, size } };
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
return { | ||
if (box->isSkippedContent()) | ||
return std::nullopt; | ||
return BoxSizes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use the two sets of braces here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
} | ||
} | ||
auto* box = m_target->renderBox(); | ||
if (box) { | ||
return { | ||
if (box->isSkippedContent()) | ||
return std::nullopt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Antti told me elsewhere that we use { }
in cases like this. Of course, here it is subtle and risky to do that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I kept it as-is.
adjustLayoutSizeForAbsoluteZoom(box->contentSize(), *box), | ||
adjustLayoutSizeForAbsoluteZoom(box->contentLogicalSize(), *box), | ||
adjustLayoutSizeForAbsoluteZoom(box->borderBoxLogicalSize(), *box) | ||
}; | ||
} | ||
|
||
return { }; | ||
return BoxSizes { }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably could even use the two sets of braces here, but probably not better!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept as-is.
if (!currentSizes) | ||
return currentSizes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think itβs better to return { }
or std::nullopt
rather than currentSizes
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like std::nullopt best to make it clear what is happening.
if (m_lastObservationSizes.borderBoxLogicalSize != currentSizes.borderBoxLogicalSize) | ||
return currentSizes; | ||
if (m_lastObservationSizes.borderBoxLogicalSize != currentSizes->borderBoxLogicalSize) | ||
return *currentSizes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change on this line isnβt needed.
if (m_lastObservationSizes.contentBoxLogicalSize != currentSizes.contentBoxLogicalSize) | ||
return currentSizes; | ||
if (m_lastObservationSizes.contentBoxLogicalSize != currentSizes->contentBoxLogicalSize) | ||
return *currentSizes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change on this line isnβt needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could have sworn it gave compile errors without the change at the time, but indeed now I try again it builds fine.
2d844de
to
30ba836
Compare
EWS run on current version of this PR (hash 30ba836) |
β¦on observer https://bugs.webkit.org/show_bug.cgi?id=245776 Reviewed by Darin Adler. Implement restrictions to resize and intersection observers as specified in the specification: https://w3c.github.io/csswg-drafts/css-contain/#cv-notes (Items 1 and 2) * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-030-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-031-expected.txt: * Source/WebCore/dom/Document.cpp: (WebCore::computeIntersectionState): * Source/WebCore/page/ResizeObservation.cpp: (WebCore::ResizeObservation::computeObservedSizes const): (WebCore::ResizeObservation::elementSizeChanged const): * Source/WebCore/page/ResizeObservation.h: Canonical link: https://commits.webkit.org/257256@main
30ba836
to
56fda58
Compare
Committed 257256@main (56fda58): https://commits.webkit.org/257256@main Reviewed commits have been landed. Closing PR #6973 and removing active labels. |
56fda58
30ba836
π§ͺ ios-wk2π§ͺ api-macπ§ͺ api-gtkπ§ͺ mac-wk1π§ͺ mac-wk2π§ͺ mac-AS-debug-wk2