Skip to content

Implement Element.currentCSSZoom #46925

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

Conversation

Ahmad-S792
Copy link
Contributor

@Ahmad-S792 Ahmad-S792 commented Jun 18, 2025

b762099

Implement `Element.currentCSSZoom`

https://bugs.webkit.org/show_bug.cgi?id=279881
rdar://136662584

Reviewed by Anne van Kesteren.

This patch implements `currentCSSZoom` as per web specification [1] and
aligns with Gecko / Firefox and Blink / Chrome.

[1] https://drafts.csswg.org/cssom-view/#dom-element-currentcsszoom

This is implemented behind flag while being enabled on 'Safari Technology Preview'.

* Source/WebCore/dom/Element+CSSOMView.idl:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::currentCSSZoom):
* Source/WebCore/dom/Element.h:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: Enabled in `preview`
* LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/Element-currentCSSZoom-expected.txt: Progression
* LayoutTests/fast/zooming/currentCSSZoom-body-fixed-regression-test.html:
* LayoutTests/fast/zooming/currentCSSZoom-body-fixed-regression-test-expected.txt:

Canonical link: https://commits.webkit.org/296856@main

d7d1c83

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ❌ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp ✅ 🛠 jsc-armv7
✅ 🛠 tv-sim ✅ 🧪 jsc-armv7-tests
✅ 🛠 watch
✅ 🛠 watch-sim

@Ahmad-S792 Ahmad-S792 requested review from rniwa and cdumez as code owners June 18, 2025 20:25
@Ahmad-S792 Ahmad-S792 self-assigned this Jun 18, 2025
@Ahmad-S792 Ahmad-S792 added the DOM For bugs specific to XML/HTML DOM elements (including parsing). label Jun 18, 2025
@webkit-early-warning-system

This comment was marked as outdated.

@Ahmad-S792 Ahmad-S792 force-pushed the eng/Implement-Element-currentCSSZoom branch from 6f5929a to f77668a Compare June 18, 2025 21:54
@webkit-early-warning-system

This comment was marked as outdated.

@Ahmad-S792 Ahmad-S792 requested review from smfr and nt1m June 19, 2025 01:18
Copy link
Contributor

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is adding a new feature, could you please add it behind a preference, enabled for preview for now?

@Ahmad-S792 Ahmad-S792 force-pushed the eng/Implement-Element-currentCSSZoom branch from f77668a to e69f85e Compare June 25, 2025 01:38
@Ahmad-S792 Ahmad-S792 force-pushed the eng/Implement-Element-currentCSSZoom branch from e69f85e to 1338bae Compare June 25, 2025 21:04
@Ahmad-S792
Copy link
Contributor Author

@annevk - Can you review this now?

@@ -1583,6 +1583,23 @@ int Element::clientHeight()
return 0;
}

double Element::currentCSSZoom()
{
protectedDocument()->updateStyleIfNeeded();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want

Ref document = this->document() here as you also use document below to get the resolver. But then from that resolver you get a document again? Is that going to be a different document? Seems unlikely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My interpretation is -> that whenever we come across this 'currentCSSZoom' function, if there is any pending document or anything then just go ahead and update Style and then later apply whatever is below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't really answer the question. I don't think obtaining a resolver has any side effects. Updating style obviously does, but that's already done at that point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@annevk - I updated this to more cleaner version now.

@Ahmad-S792 Ahmad-S792 force-pushed the eng/Implement-Element-currentCSSZoom branch from 1338bae to d7d1c83 Compare July 1, 2025 03:34
Copy link
Contributor

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks! I think we should create a couple more tests with mixed zoom levels across elements before eventually enabling.

@Ahmad-S792 Ahmad-S792 added the merge-queue Applied to send a pull request to merge-queue label Jul 1, 2025
@Ahmad-S792
Copy link
Contributor Author

Looks good! Thanks! I think we should create a couple more tests with mixed zoom levels across elements before eventually enabling.

Good idea! I would do it over weekend and directly on WPT.

https://bugs.webkit.org/show_bug.cgi?id=279881
rdar://136662584

Reviewed by Anne van Kesteren.

This patch implements `currentCSSZoom` as per web specification [1] and
aligns with Gecko / Firefox and Blink / Chrome.

[1] https://drafts.csswg.org/cssom-view/#dom-element-currentcsszoom

This is implemented behind flag while being enabled on 'Safari Technology Preview'.

* Source/WebCore/dom/Element+CSSOMView.idl:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::currentCSSZoom):
* Source/WebCore/dom/Element.h:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: Enabled in `preview`
* LayoutTests/imported/w3c/web-platform-tests/css/cssom-view/Element-currentCSSZoom-expected.txt: Progression
* LayoutTests/fast/zooming/currentCSSZoom-body-fixed-regression-test.html:
* LayoutTests/fast/zooming/currentCSSZoom-body-fixed-regression-test-expected.txt:

Canonical link: https://commits.webkit.org/296856@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Implement-Element-currentCSSZoom branch from d7d1c83 to b762099 Compare July 1, 2025 07:10
@webkit-commit-queue
Copy link
Collaborator

Committed 296856@main (b762099): https://commits.webkit.org/296856@main

Reviewed commits have been landed. Closing PR #46925 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit b762099 into WebKit:main Jul 1, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DOM For bugs specific to XML/HTML DOM elements (including parsing).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants