servo: Rename WebView::pinch_zoom to adjust_pinch_zoom and add pinch zoom getter#43228
Conversation
| .get(&webview_id) | ||
| .map(|webview_renderer| webview_renderer.page_zoom.get()) | ||
| .unwrap_or_default() | ||
| .unwrap_or(1.) |
There was a problem hiding this comment.
I changed this because it looks wrong to me. From what I understand page zoom of 0 would be invalid, so defaulting to 0 doesn't make sense, right?
There was a problem hiding this comment.
It's an error for this code to receive a request for a WebView that does not exist. Still, it's a recoverable error. I think that 0 is better return value given this.
There was a problem hiding this comment.
In which way is 0 better here? If the goal is to indicate an invalid value, None should be returned (imo). If the goal is to have a value that is as uncontroversial as possible, then 1 should be picked because 0 as a scale is likely to cause issues in the embedder if not handled explicitly.
If you're confident that 0 is the best value here please let me know, but I'm struggling to fathom why one would think that using a value that is technically the right type but likely to cause issues (like div by zero) would be better than a return value that is clearly indicating an issue None or one that is just using the default and avoiding issues (1).
There was a problem hiding this comment.
If this fails and 0 is returned, it's quite likely that something is really wrong with the internals of Servo.
There was a problem hiding this comment.
Well the web view ID just might not exist anymore, so I don't think something is necessarily 'very wrong with servo' (which might justify a panic).
A return value of 0 isn't standing out more than a value of 1, it's just going to cause confusing behavior when encountered.
If you insist I can change that back, but I feel like this should either be None or 1. A value of 0 is like None, but the consumer isn't forced to deal with it, thus likely to cause issues.
There was a problem hiding this comment.
WebViewId is not exposed to the the embedding API and as long as a WebView is alive, it should have a valid WebViewRenderer in the Painter. That means that the situation where we return the default value shouldn't happen and represents a logic error in the implementation of Servo. Likely these should all be expect("...") but we opted for not panicking in this case. Perhaps that was the wrong choice.
I've sent this to the merge queue anyway.
There was a problem hiding this comment.
I'd be happy to panic too, but I don't think an error here is important enough to fail here. Trying to recover as well as possible for an extremely unlikely scenario by returning 1 seems fine to me. Chances are things will likely fail in a different place anyway.
ca20b5f to
4a46dd2
Compare
mrobinson
left a comment
There was a problem hiding this comment.
Looks good, but with two small changes:
| .get(&webview_id) | ||
| .map(|webview_renderer| webview_renderer.page_zoom.get()) | ||
| .unwrap_or_default() | ||
| .unwrap_or(1.) |
There was a problem hiding this comment.
It's an error for this code to receive a request for a WebView that does not exist. Still, it's a recoverable error. I think that 0 is better return value given this.
| self.webview_renderers | ||
| .get(&webview_id) | ||
| .map(|webview_renderer| webview_renderer.pinch_zoom().zoom_factor().0) | ||
| .unwrap_or(1.) |
There was a problem hiding this comment.
For consistency with the page_zoom getter:
| .unwrap_or(1.) | |
| .unwrap_or_default() |
WebView::pinch_zoom to adjust_pinch_zoom and add pinch zoom getter
Head branch was pushed to by a user without write access
|
Previously the `pinch_zoom` method on `WebView` would be used to update the page's pinch zoom level, however there was no way for the embedder to retrieve the current pinch zoom. This patch renames the existing `pinch_zoom` method to `adjust_pinch_zoom` and changes the `pinch_zoom` method to instead return the current pinch zoom level. Signed-off-by: Christian Duerr <contact@christianduerr.com>
|
I'm uncertain why this failed? CI runs all tests automatically, right? So if CI is green then merge queue should work? I rebased it just to make sure. |
|
Build failure in the OpenHarmony port: https://github.com/servo/servo/actions/runs/23214339818/job/67471126130 |
|
And no, the checks that run by default in the PR are a subset of the full checks that run when attempting to merge. |
Signed-off-by: Christian Duerr <contact@christianduerr.com>
|
@jdm Is there a way to manually trigger these builds on PRs? |
|
By applying the T- labels to trigger "try" builds: https://book.servo.org/contributing/making-a-pull-request.html#running-tests-in-pull-requests . They can be applied by anybody in the Contributors or Maintainers groups. |
|
🔨 Triggering try run (#23228214389) for OpenHarmony |
|
🔨 Triggering try run (#23228216497) for Android |
|
| Branch | 43228/PR |
| Testbed | HUAWEI Mate 60 Pro |
⚠️ WARNING: Truncated view!The full continuous benchmarking report exceeds the maximum length allowed on this platform.
🐰 View full continuous benchmarking report in Bencher
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
|
✨ Try run (#23228214389) succeeded. |
|
✨ Try run (#23228216497) succeeded. |
…nch zoom getter (servo#43228) Previously the `pinch_zoom` method on `WebView` would be used to update the page's pinch zoom level, however there was no way for the embedder to retrieve the current pinch zoom. This patch renames the existing `pinch_zoom` method to `adjust_pinch_zoom` and changes the `pinch_zoom` method to instead return the current pinch zoom level. --- Decided to go for the breaking change since I'd find `pinch_zoom` combined with `get_pinch_zoom` to be confusing, however I'm happy to change that if a non-breaking change is preferred. Motivation for this patch is just that I'd like to display the zoom level in my UI while rendering. Testing: Since this change adds a simple getter to the API, we can probably avoid a unit test in this case. --------- Signed-off-by: Christian Duerr <contact@christianduerr.com>
Previously the
pinch_zoommethod onWebViewwould be used to update the page's pinch zoom level, however there was no way for the embedder to retrieve the current pinch zoom.This patch renames the existing
pinch_zoommethod toadjust_pinch_zoomand changes thepinch_zoommethod to instead return the current pinch zoom level.Decided to go for the breaking change since I'd find
pinch_zoomcombined withget_pinch_zoomto be confusing, however I'm happy to change that if a non-breaking change is preferred.Motivation for this patch is just that I'd like to display the zoom level in my UI while rendering.
Testing: Since this change adds a simple getter to the API, we can probably avoid a unit test in this case.