Bug 45522

Summary: Remove unnecessary constraint in WebCore of choosing either text zoom or full page zoom.
Product: WebKit Reporter: Sam Weinig <sam>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, bdakin, darin, dbates, eric, fishd, hausmann, hyatt, kling, mrobinson, tonikitoo, webkit.review.bot, xan.lopez
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Attachments:
Description Flags
Patch
fishd: review-
Updated patch
fishd: review-
Patch 3 darin: review+

Sam Weinig
Reported 2010-09-09 22:02:06 PDT
We should remove the unnecessary constraint in WebCore of having to choose between either using text zoom or full page zoom. There is no reason they can't both be used independently of each other. That behavior should be up to the port API layer.
Attachments
Patch (65.20 KB, patch)
2010-09-09 22:16 PDT, Sam Weinig
fishd: review-
Updated patch (56.74 KB, patch)
2010-09-10 13:50 PDT, Sam Weinig
fishd: review-
Patch 3 (56.71 KB, patch)
2010-09-10 17:55 PDT, Sam Weinig
darin: review+
Sam Weinig
Comment 1 2010-09-09 22:16:08 PDT
Sam Weinig
Comment 2 2010-09-09 22:20:45 PDT
It would be really great if people from the different ports could take a look at the changes I made to the WebKit layer, and make sure that it is all up to grade.
Xan Lopez
Comment 3 2010-09-10 02:08:11 PDT
(In reply to comment #2) > It would be really great if people from the different ports could take a look at the changes I made to the WebKit layer, and make sure that it is all up to grade. In GTK+ you just changed things so that they keep working as they are now right? ie, faking that full page zoom and text zoom are still mutually exclusive. In that case it looks good, although of course we should change the APIs to take into account the new situation. Thanks for taking care of things!
Darin Adler
Comment 4 2010-09-10 08:23:26 PDT
Comment on attachment 67153 [details] Patch > + float textZoomFactor() const { return m_textZoomFactor; } There's an extra space here. > + view->setPageZoomFactor(1.0f); I suggest just "1" here instead of "1.0f". > + view->setTextZoomFactor(1.0f); And here. > + if (m_zoomsTextOnly != isTextOnly) { > + m_zoomsTextOnly = isTextOnly; > + m_page->setNeedsRecalcStyleInAllFrames(); > + } WHy is this call to setNeedsRecalcStyleInAllFrames needed? The calls to setPageZoomFactor and setTextZoomFactor should handle everything. If that is not so, then we should consider optimizing the case where the multiplier is 1. I suspect at least some of the new calls you added to setNeedsRecalcStyleInAllFrames are unneeded, and I’m not sure you needed to move the function out of the Settings class at all. > + WKBundlePageSetPageZoomFactor(InjectedBundle::shared().page()->page(), 1.0f); Again, how about 1 instead of 1.0f? > + WKBundlePageSetPageZoomFactor(InjectedBundle::shared().page()->page(), 1.0f); Ditto. And more of the same.
Darin Fisher (:fishd, Google)
Comment 5 2010-09-10 09:00:46 PDT
Comment on attachment 67153 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=67153&action=prettypatch > WebKit/chromium/src/FrameLoaderClientImpl.cpp:1401 > + bool zoomTextOnly = m_webFrame->viewImpl(); viewImpl is of type WebViewImpl*, but you are storing it in a 'bool'. i think this is going to force zoomTextOnly to always be true. i think you meant to write m_webFrame->viewImpl()->zoomTextOnly(). > WebKit/chromium/src/WebViewImpl.cpp:1494 > + m_page->setNeedsRecalcStyleInAllFrames(); why isn't this a byproduct of calling set{Text,Page}ZoomFactor? isn't unfortunate for WebKit layers to need to understand when to call setNeedsRecalcStyleInAllFrames?
Darin Adler
Comment 6 2010-09-10 09:53:02 PDT
(In reply to comment #5) > > WebKit/chromium/src/FrameLoaderClientImpl.cpp:1401 > > + bool zoomTextOnly = m_webFrame->viewImpl(); > viewImpl is of type WebViewImpl*, but you are storing it in a 'bool'. i think this is going to force zoomTextOnly to always be true. > > i think you meant to write m_webFrame->viewImpl()->zoomTextOnly(). Good catch! I missed that one! > > WebKit/chromium/src/WebViewImpl.cpp:1494 > > + m_page->setNeedsRecalcStyleInAllFrames(); > why isn't this a byproduct of calling set{Text,Page}ZoomFactor? isn't unfortunate for WebKit layers to need to understand when to call setNeedsRecalcStyleInAllFrames? Not sure if you noticed, but I made the same comment.
Peter Kasting
Comment 7 2010-09-10 10:50:08 PDT
Comment on attachment 67153 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=67153&action=prettypatch > WebKit/chromium/src/WebViewImpl.cpp:1485 > + view->setPageZoomFactor(1.0f); It seems slightly strange to me that we're removing a constraint on "only use text zoom or page zoom at one time" and yet this still forces the other zoom level to 1 every time one zoom level is set. It seems like it would be better to either rely on the port to do this if it wants zooming one thing to reset the other, or make the APIs take both a text and page zoom value simultaneously (so that ports must specify what they mean, and we avoid doing two style recalcs in a row).
Darin Adler
Comment 8 2010-09-10 10:56:11 PDT
(In reply to comment #7) > It seems slightly strange to me that we're removing a constraint on "only use text zoom or page zoom at one time" and yet this still forces the other zoom level to 1 every time one zoom level is set. It seems like it would be better to either rely on the port to do this if it wants zooming one thing to reset the other, or make the APIs take both a text and page zoom value simultaneously (so that ports must specify what they mean, and we avoid doing two style recalcs in a row). The code you quoted is from inside the Chromium port, and we do rely on the port to do this! This patch preserves the WebKit API for the various ports. You suggestions point to a direction for improving Chromium’s WebKit API and could be done in a different patch.
Darin Adler
Comment 9 2010-09-10 10:56:46 PDT
(In reply to comment #7) > we avoid doing two style recalcs in a row There will only be one style recalc. The code sets a flag saying recalc is needed, and doing that twice is relatively inexpensive.
Sam Weinig
Comment 10 2010-09-10 13:50:38 PDT
Created attachment 67229 [details] Updated patch Thanks for the feedback. Here is an updated patch. It turns out the call to setNeedsRecalcStyleInAllFrames was unnecessary and that we would probably end up doing a little too much work if we called both setPageZoomFactor and setTextZoomFactor in a row, so I have added a function which can change both at once if that is what is wanted.
Darin Adler
Comment 11 2010-09-10 14:46:10 PDT
(In reply to comment #10) > we would probably end up doing a little too much work if we called both setPageZoomFactor and setTextZoomFactor in a row, so I have added a function which can change both at once if that is what is wanted. Really? Are you sure? There are other changes someone might make at the same time too, so I don’t see why we have to gang these two together. I think having a function to change both at once is not worthwhile, and poor factoring. Unless it’s measurably better for performance.
Darin Adler
Comment 12 2010-09-10 14:46:43 PDT
To put it another way: If setting both at once is really more efficient, then I suggest including that in WebKit2’s public API too.
Sam Weinig
Comment 13 2010-09-10 16:02:53 PDT
(In reply to comment #11) > (In reply to comment #10) > > we would probably end up doing a little too much work if we called both setPageZoomFactor and setTextZoomFactor in a row, so I have added a function which can change both at once if that is what is wanted. > > Really? Are you sure? > > There are other changes someone might make at the same time too, so I don’t see why we have to gang these two together. I think having a function to change both at once is not worthwhile, and poor factoring. Unless it’s measurably better for performance. Well, both end up calling document->recalcStyle(Node::Force);, which Dan tells me can be expensive.
Sam Weinig
Comment 14 2010-09-10 16:03:50 PDT
(In reply to comment #12) > To put it another way: If setting both at once is really more efficient, then I suggest including that in WebKit2’s public API too. I think for the UIProcess side, I will add something for that, for the bundle side (for the test runner) I don't see a compelling reason to optimize this at this point.
Darin Fisher (:fishd, Google)
Comment 15 2010-09-10 16:47:27 PDT
Comment on attachment 67229 [details] Updated patch View in context: https://bugs.webkit.org/attachment.cgi?id=67229&action=prettypatch > WebKit/chromium/src/WebViewImpl.cpp:1489 > + if (oldZoomFactor != zoomFactor && textOnly != m_zoomTextOnly) { shouldn't this be an OR? if either the zoom factor or the textOnly flag changes, we need to notify the plugin.
Sam Weinig
Comment 16 2010-09-10 17:53:28 PDT
(In reply to comment #15) > (From update of attachment 67229 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=67229&action=prettypatch > > > WebKit/chromium/src/WebViewImpl.cpp:1489 > > + if (oldZoomFactor != zoomFactor && textOnly != m_zoomTextOnly) { > shouldn't this be an OR? if either the zoom factor or the textOnly flag changes, we need to notify the plugin. (In reply to comment #15) > (From update of attachment 67229 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=67229&action=prettypatch > > > WebKit/chromium/src/WebViewImpl.cpp:1489 > > + if (oldZoomFactor != zoomFactor && textOnly != m_zoomTextOnly) { > shouldn't this be an OR? if either the zoom factor or the textOnly flag changes, we need to notify the plugin. Yeah. It should. Is the rest of the patch ok?
Sam Weinig
Comment 17 2010-09-10 17:55:59 PDT
Created attachment 67275 [details] Patch 3
Darin Adler
Comment 18 2010-09-10 18:14:59 PDT
Comment on attachment 67275 [details] Patch 3 > + float textZoomFactor() const { return m_textZoomFactor; } Extra space here after const. Longer term you should find a way to make it efficient to set both zoom factors separately, presumably by making sure the style recalculation is deferred, and eliminate the function to do both at once. r=me
WebKit Review Bot
Comment 19 2010-09-10 21:08:39 PDT
http://trac.webkit.org/changeset/67274 might have broken Qt Linux Release minimal
Sam Weinig
Comment 20 2010-09-10 21:17:18 PDT
Note You need to log in before you can comment on or make changes to this bug.