I would like to have this API to enable gesture-based zooming
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
It's not exactly what the original request was for, but here's a patch that
exposes
the tab zoom functions for use by extensions:
http://codereview.chromium.org/570048
No unit tests, but I can work on them if there's traction.
Here's a fork of smoothgestures that implements the API (see zoomapi
branch):
git://github.com/brson/smoothgestures-chromium.git
I use this to zoom on right click+scrollwheel.
I support this addition to the extension api. There have been many requests
for this
feature to be added to Smooth Gestures, but I don't have access to a zoom
api to add
it.
There have also been requests for many other features that extensions don't
have
access to. Is posting a bug in this issue tracker the best way to address
it? Or are
patches to the extension system reasonable to get accepted? (I have not
been involved
in large-scale open source before)
Hi,
despite the fact that zoom in Chrome 5 is much better, there is still no
such thing as a suitable GUI (necessary for tablets),
or text only zoom. In my opinion this can be done by extension writers.
I wrote the extension for AutoZoom Chrome 4 (~6500 users, shortlink:
http://go.szsz.pl/autozoom).
Unfortunately, without proper api's functionality is limited to tricks with
CSS.
Hi,
despite the fact that zoom in Chrome 5 is much better, there is still no
such thing as a suitable GUI (necessary for tablets),
or text only zoom. In my opinion this can be done by extension writers.
I wrote the extension AutoZoom for Chrome 4 (~6500 users, shortlink:
http://go.szsz.pl/autozoom).
Unfortunately, without proper api's its functionality is limited to tricks
with CSS.
It would be great if extensions will have ability to interact with chrome
zoom and/or override it.
Ability to catch/cancel event from page will be even greater (think about
maps or image hosting)..
(sorry for doubleposting)
Couldn't you just use the "zoom" property of CSS with a content script?
@aa css zoom isn't very good.
I'm using this css trick in AutoZoom extension and it's very problematic in
practice.
It doesn't work on iframes, there are also multiple problems with drag&drop.
I've checked this patch and it's look like good solution, even if its not
complete.
(for example it will require ability to register to "onZoomChanged" events)
@GrreenZZ - I see. Out of curiosity can you give some examples of the
problems with
drag&drop?
@aa You can easily check on every page using Drag&Drop
(Google Reader, and Google Calendar are the best examples of multiple
problems when using css zoom)
For simple test try this page
http://jqueryui.com/demos/draggable/default.html
You can change zoom level by entering javascript:document.body.style.zoom=2
in address bar
When you start dragging, you'll notice that the MouseMove event returns
coordinates using a screen resolution without
taking scaling into account.
Apart from this problem, using CSS in the extensions is also confusing to
the user, because it means introducing two
independent scaling mechanisms.
I would not call the example above a bug. It is more the result of web
applications
that assume that the scale of their elements are consistent. This is
reasonable,
since usually websites have full control of their elements.
javascript:document.body.style.webkitTransform="scale(1.3)" also zooms and
works on
that page. But it has it's own problems. -webkit-transform transforms the
coordinates
of event.pageX, but it still doesn't transform event.clientX,
window.innerWidth,
document.width, etc. All of which could easily break things if set by an
extension.
And I see no way around this from a webkit design point of view.
Additionally, it doesn't make sense for an extension to create a whole new
zoom
control domain when one already exists -- probably confusing the user in
the process.
I can understand ignoring this bug if you think extension controlled zoom
isn't
important -- but I believe that it is _very_ important because it is one of
the most
requested features for my extension. And I think that an extension
dedicated to
actual browser-level zoom control could be awesome.
I agree with @scottfujan, creating whole new zoom by extensions is _very_
confusing for the user.
Having perfect CSS, does not solve problem here... it is only one piece of
the puzzle.
Some users want to scale pages using ctrl +/- keys, other want to use GUI /
gestures because their Tablets simply have no
keyboard. Chrome5 remember zoom level for domains only (for unspecified
amount of time) and sometimes it is not sufficient.
Here are maybe my final thoughts on this issue. If an extension's zoom
doesn't behave
identically to the browser's zoom it defies user expectations.
These are the things I can think of that must behave like the browser:
*Page rendering - from what the posters above say this is a big concern
*Page behavior - not sure about how these zoom hacks might affect
scripting
*The zoom increment - extensions should zoom in and out by the same
amount as the
browser zoom
*The min and max zoom
*Zoom persistence - when the browser saves the zoom level we also need
to save
the extension's zoom level
It's absolutely necessary to access the current user set zoom level via
javascript,
setting it is also kind of a nice feature but less of a must. An event
when this
changes is a must. There is no other suitable method for detecting this
that works
reliably or consistently. The example here breaks if you resize the
window, plus
relies on polling, and also breaks if you start the page at anything other
than the
default zoom level, so it's essentially useless, and only detects changes
from
default. Take the instance of using captureVisibleTab and trying to figure
out which
pixel the mouse pointer is over, without knowing the current page zoom this
becomes
impossible.
http://tests.novemberborn.net/browsers/gecko/fullzoom/percentages.html
CSS zoom is useless when what needs to be done is detecting the current
zoom of the
page that the user set. Also extension popup seem to get zoomed randomly
and there
is no way to control this. This is ESPECIALLY furstrating when they don't
size
themselves properly in the first place, and hard-coding a specific size is
required,
and then they get zoomed somehow and cease to function properly because the
auto
adjustment of size doesn't account for zoom.
I think that closing this bug isn't right. As qufighter said, we need this
functionality to be able to work with captureVisibleTab
It's the best news I have read today.
I'm going to update AutoZoom extension to use this api ASAP ;)
http://codereview.chromium.org/570048
I updated the previous patch to work with the latest source. This patch
only adds zoomIn(tabId) and zoomOut(tabId) functions. I'm looking at how to
implement get/set now.
I'll be away for a week, but I've experimented with getting and setting the
zoom level. Set is implemented, get only partially. My git repo is:
git://github.com/brson/chromium.git
And my test extension:
Comment #33 on issue 30583 by a...@chromium.org: Zoom level get/set API
http://code.google.com/p/chromium/issues/detail?id=30583
(No comment was entered for this change.)
Anders, can we change this to be more like getZoomLevel(), setZoomLevel()?
I think that would be more useful than zoomIn(), zoomOut().
Yes. Do you have any other suggestions?
I've uploaded another patch to http://codereview.chromium.org/570048, but
it's not close to finished. This patch eliminates zoomIn/Out methods in
favor of get/setZoomLevel. A negative zoom level indicates zoom percentages
less than 100%, and positive are greater than 100%.
I have some concerns.
* Should the zoom extension API be browser-oriented, tab-oriented, or
domain-oriented, or a mixture? The chrome internals have a bit of
everything: there are browser-level and tab-level zoom in/out/reset
commands, but the zoom level is also set on a per-domain basis, so zooming
one tab can trigger events in multiple tabs. My inclination is to make all
the extension methods tab-oriented.
* Setting the zoom level directly is a capability that the browser itself
doesn't have. The browser just does in/out/reset. This required adding a
new IPC message (ViewMsg_SetZoomLevel).
* Just being able to get and set the zoom level isn't enough to use zoom
correctly. Extensions also need to be able to know the minimum and maximum
zoom level and the zoom percentage. We can expose more extension functions
to provide that information, maybe getZoomPercent and getZoomLimits.
* I'm not sure the best way to provide a tabs.onZoomed callback. It's a
little tricky because zooming one tab may zoom multiple tabs, based on the
domain. There's already an IPC message, ViewHostMsg_DidZoomURL, that can be
used for this, but I'm not exactly sure how to get to each TabContents
object from the handler in resource_message_filter.cc.
Here's what's currently implemented:
chrome.tabs.getZoomLevel(tabId, function(tabId, zoomLevel) {...});
chrome.tabs.setZoomLevel(tabId, zoomLevel);
Other things that may be needed:
chrome.tabs.onZoomed(function(tabId, zoomLevel) {...});
chrome.tabs.getZoomPercent(tabId, function(tabId, zoomPercent) {...});
chrome.tabs.getZoomLimits(function(minZoomLevel, maxZoomLevel) {...});
My suggestion is to have text only zoom work like the full page zoom. That
is:
1. Check if there is a user zoom level for the domain.
2. If not, set to user default text zoom level.
Personally, I think zoom level per tab sounds confusing and a bit overkill.
Cheers
M.
Ah, I didn't think of percentage! That seems like a much simpler
format to think in, right? Why don't we just make the API
setZoomPercentage/getZoomPercentage? It seems like the lowest-level
primitive, and therefore most flexible.
I think tab-oriented makes most sense. Browser and domain-level can be
implemented by extension developers in JavaScript.
That seems fine.
If we change the API to getZoomPercentage and setZoomPercentage, would
we need anything else? It seems like the limits can just be in the
documentation.
Yeah, providing an onZoom event looks more complex. You may want to do
that in a separate change.
ViewHostMsg_DidZoomURL() eventually ends up at ZoomHostMap
(chrome/browser/zoom_host_map.*) and that sends out a notificaiton
(ZOOM_LEVEL_CHANGED). Currently it doesn't send any details, but it
could send the URL and render_view_id. The extension system could
catch that. In the case of "temporary" zoom levels, you can just use
the render_view_id to get the associated tab contents.
(RenderViewHost::FromID(),
RenderViewHost::delegate()::AsTabContents()). In the case of
"permanent" zoom levels, you'll need to iterate through open tabs and
fire extension events in each that matches the specified URL.
One other question I thought of while looking at this code. The
internals have support for SetZoomLevelForCurrentURL() as well as
SetZoomLevelForLoadingURL(). This seems like something you may need to
take into account. It will be common for extension developers to call
setZoom() directly after getting a url change event. We don't want
them to have to wait until the page has loaded to set the zoom, as
that would lead to annoying flickering.
- a
+pkasting, who appears to be owner of the zoom functionality in Chrome.
Peter, please verify my suggestions are not crazy.
It looks like the code already deals with this because Plugins can
already set the zoom to arbitrary values. For example, see this
comment:
The 20% stepping logic seems pretty simple. I'm not too concerned
about developers who want to emulate it reimplementing it. It's like 3
lines of JavaScript, right?
That was the use case I had in mind. I don't think we should expose
the concept of zoom for a particular URL or anything (like I said
earlier, I think per-tab zoom is fine). I just meant that it should be
possible to call chrome.tabs.setZoom(tabId) when the tab is loading
and have it take effect once the load is complete.
HTH,
- a
Thanks for working this through with me, Aaron.
The only code that can handle arbitrary zoom percentages is inside the
render process. Inside the browser process everything is done in terms of
zoom level. So we could do like the RenderView::OnZoom method is doing and
accept arbitrary zoom percentages, but report back to the HostZoomMap the
closest zoom level.
I'm not sure what all the consequences of that are, but at the very least
the HostZoomMap won't preserve the correct zoom level - the extension might
request 125%, but HostZoomMap would remember 120%. This doesn't apply to
plugins because they are special-cased to not remember the zoom level.
Also, setting the zoom for google.com to 125% in one tab would result in
other google.com tabs zooming to 120%.
It still looks to me that, to really be correct, allowing anything on the
browser side of the process boundary to use zoom percentages would require
changing all the zoom-related IPC and the HostZoomMap.
Np, sorry for being slow to respond.
I'm sorry to be obstinate here, but are you sure that zoomlevel can't
be non-integral? I haven't tried it, but looking at the code, I don't
see what would stop it. In fact, I thought I saw somewhere in the code
that plugins could already cause this to happen.
- a
mknart,
Remembering the text zoom level sounds like a reasonable feature to me. I
think it deserves its own bug ticket.
We need to keep in mind that any zoom extension api might need to support
text zoom as well. So far I've just been considering page zoom.
mknart again,
If per tab zoom is overkill, is there an alternative that you prefer?
andersrb, that's a lot more data to store! If each domain you ever visit
has a float value stored with the 'exact' zoom percent that's a lot of data.
re window.devicePixelRatio it's interesting if a script reacts to these
values because it could create an infinite zoom conflict that keeps
resetting the zoom as the page also keeps resetting it's zoom to correct
for the user's specified zoom, then the float value will loop at some
point, and the user will have to scroll a lot to see anything since it's
zoomed to an insane amount.
The nice thing about the settings now is that at least there are a finite
number of zoom possibilities enforced that are also rather tiny to store
the most common ones.
aa, I think you're right. Zoom levels are handled as doubles even though
they appear to almost always be integral, so maybe allowing fractional zoom
levels is ok.
qufighter, the mechanism to store zoom level looks like it already uses
doubles, so I don't know if storage space is a concern. I do agree that
keeping zoom limited to a few levels is attractive.
I posted a new patch. In this one the extension functions are defined:
chrome.tabs.getZoomPercent(tabId, function(tabId, zoomPercent) {...});
chrome.tabs.setZoomPercent(tabId, zoomLevel);
When setting the zoom to less than 50 or greater than 300 it is silently
limited. Setting the zoom to a negative value does nothing.
Did you expose chrome.tabs.getZoomPercent to all extensions? Does it
require tabs permissions? It doesn't seem like a security risk to allow an
untrusted site to get the current zoom level on its window. But that said,
privacy concerns have come up before with a11y.
It currently requires tab permissions.
Aaron,
Not sure if you saw the most recent patch I posted two weeks ago, but it's
there.
I'm not feeling so confident about the direction it's going though. Most of
my concerns are about how complicated the asynchronous interactions are
getting and whether they are correct. The current patch seems to work for
getting and setting the zoom percentage, though I think it potentially
generates a fair amount of new zoom-related IPC traffic on page load. Also,
correctly duplicating zoom in/out in an extension by explicitly setting the
zoom percentage requires duplicating much of chrome's zoom logic (90 lines
of verbose JavaScript).
I also suspect that it reports the wrong zoom level for full-page plugins,
though I haven't tested it because I don't know how to get such a plugin
(on Linux).
The Flash crashes I reported in the code review were just typical Flash
suckage, not a regression.
I've taken a stab at exposing a per-tab zoom event but haven't succeeded
yet. What makes it difficult is that the UI can only request a page zoom,
but doesn't know if it actually succeeds until the render process responds.
If the zoom did succeed then the UI moves forward with zooming all the
other tabs for that same URL, and we have to wait again to know if they
succeeded. My first attempt sometimes resulted in infinite message loops. I
fear that it will require even more extensive restructuring to get
something that works correctly and preserves existing behavior, but so far
I haven't thought of anything that isn't full of ugly.
This patch has gotten a lot more complicated than my original zoom in/out
use case and I admit I've lost some motivation.
Any suggestions?
Regards,
Brian
getZoomPercent is something that should be made available through the DOM.
http://msdn.microsoft.com/en-us/library/ms533721(VS.85).aspx
Things considered, setZoom is something that's already available in
practice.
document.body.style.zoom = 2
With that in mind: How about implementing the .screen extensions that MS
has proposed, and getting rid of this .tabs extension?
http://msdn.microsoft.com/en-us/library/ms535868(v=VS.85).aspx
Logical/device DPI always allow me to test the zoom ratio relative to the
device pixels.
They're very quick to implement into window.screen, already present in IE9
PR, and being proposed in the w3c process as fix to an accessibility
issue/defect.
Thoughts?
Here's how Mozilla is handling it in 3.6. No good:
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils).screenPixelsPerCSSPixel
Keep in mind that the MS proposal exposes logical/device and system, as x
and y.
This isn't technically a "zoom" issue: body.zoom = is already a setter.
It's not a getter, but it doesn't need to be. We just need to expose the
device scale.
target-DpiDensity and dpiPixelRatio are related APIs, handy for mobile
devices and css, but unused by the desktop distributions (it seems). They
don't expose as much info as the window.screen proposal.
Is this an issue to be sent upstream to the webkit for discussion?
Good work, downchuck. You definitely know more about this issue than I, and
I'll have to let somebody else weigh in on what you've suggested. The idea
of zeroing in on a common DOM solution sounds attractive.
downchuck,
Comment 14 and a few subsequent comments describe some problems
body.style.zoom.
I'm still think it's compelling to have a simple zoom API exposed to
extensions. The problem with document.body.style.zoom described in comment
#14 seems real to me, and it would stink if these kinds of extensions
weren't as reliable as they could be.
I agree, that a simple zoom API should be exposed to extensions. I feel
like it's not necessary to have "tab" permissions. Zoom is set and
remembered on a per-domain basis: needing "tab" permissions is overkill.
Sorry if I caused confusion there. I do understand that body.zoom has a
collection of issues, and I do think the getZoom/setZoom semantics are fine
as they relate to browser extensions.
I'm still pushing within the WHATWG mailing list, to see if there's room
for agreement on the DPI issues I'm facing. Mozilla has come out saying
that they've implemented pixel ratio / dpi density in FF4, and that it's
sufficient. I haven't tested this yet. MS is pretty firm about their
window.screen object.
One item that again, I couldn't quite clear up is the behavior of
window.innerWidth vs window.outerWidth. That's how I currently grab zoom in
Chrome (which breaks of course, if there's a side bar). I compare
innerWidth, which gets smaller with zoom, as it's in css pixels, to
outerWidth, which is measured in screen pixels.
I still believe MS has covered all the bases, by exposing so much data. Moz
sees following suit as a liability. I can't get them to budge on that end.
I haven't contacted Apple nor WebKit upstream.
So, that's the current status on my end.
Thanks for keeping up on this.
-Charles
I agree, that a simple zoom API should be exposed to extensions. I feel
like it's not necessary to have "tab" permissions. Zoom is set and
remembered on a per-domain basis: needing "tab" permissions is overkill.
Sorry if I caused confusion there. I do understand that body.zoom has a
collection of issues, and I do think the getZoom/setZoom semantics are fine
as they relate to browser extensions.
I'm still pushing within the WHATWG mailing list, to see if there's room
for agreement on the DPI issues I'm facing. Mozilla insists that they've
implemented window.devicePixelRatio in FF4 during a CSS zoom. I haven't
tested this yet. MS is pretty firm about their window.screen object. The MS
method allows different X and Y scaling, which may make some sense in the
long term.
One item that again, I couldn't quite clear up is the behavior of
window.innerWidth vs window.outerWidth. That's how I currently grab zoom in
Chrome (which breaks of course, if there's a side bar). I compare
innerWidth, which gets smaller with zoom, as it's in css pixels, to
outerWidth, which is measured in screen pixels.
I still believe MS has covered all the bases, by exposing so much data. Moz
sees following suit as a liability. I can't get them to budge on that end.
I haven't contacted Apple nor WebKit upstream.
So, that's the current status on my end.
Would one of you be willing to file a bug report with WebKit upstream
bringing up the question as to whether a "zoom" event should alter
window.devicePixelRatio ? They seem like a reasonable bunch, and may have
good input on the issue.
I agree, that a simple zoom API should be exposed to extensions. I feel
like it's not necessary to have "tab" permissions. Zoom is set and
remembered on a per-domain basis: needing "tab" permissions is overkill.
Sorry if I caused confusion there. I do understand that body.zoom has a
collection of issues, and I do think the getZoom/setZoom semantics are fine
as they relate to browser extensions.
I'm still pushing within the WHATWG mailing list, to see if there's room
for agreement on the DPI issues I'm facing. Mozilla insists that they've
implemented and change window.devicePixelRatio during zoom in FF4. I
haven't tested this yet. MS is pretty firm about their window.screen
object. The MS method allows different X and Y scaling, which may make some
sense in the long term.
One item that again, I couldn't quite clear up is the behavior of
window.innerWidth vs window.outerWidth. That's how I currently grab zoom in
Chrome (which breaks of course, if there's a side bar). I compare
innerWidth, which gets smaller with zoom, as it's in css pixels, to
outerWidth, which is measured in screen pixels.
I still believe MS has covered all the bases, by exposing so much data. Moz
sees following suit as a liability. I can't get them to budge on that end.
I haven't contacted Apple nor WebKit upstream.
So, that's the current status on my end.
Would one of you be willing to file a bug report with WebKit upstream
bringing up the question as to whether a "zoom" event should alter
window.devicePixelRatio ? They seem like a reasonable bunch, and may have
good input on the issue.
Thanks for keeping up on this.
-Charles
(sorry if my posts caused dupes/email notices; had some editing issues).
Following up:
The current getZoomPercent/setZoomPercent proposal looks good to me. This
thread has gotten a bit lengthy, and I regrettably didn't read through it
before posting. Having done that, in a more responsible way, I'd say that
the main issue here is documentation. As long as we have due documentation
(regarding the "20%" increments, and so forth), I think it's good to go.
I've hit a dead end with the WHATWG mailing list on trying to expose the
current zoom level via a public getter. Mozilla has refused to expose the
data to an untrusted scripting context: that is, they only allow access to
it from browser extensions. Because of that, the WebKit development group
is going to have to wait and see what comes of the w3c process.
Sharing that information to let you know, that my concerns are best left to
a future bug report, which I'll file when there's a change in the
specs/standards.
What's the status on getting this Zoom set/get API patch into a milestone
schedule?
Patch 7 is up for code review. I think this one is nearly ready for
inclusion. The functions are now defined:
chrome.tabs.getZoomPercent(tabId, function(zoomPercent) {...});
chrome.tabs.setZoomPercent(tabId, zoomPercent, function(zoomPercent) {...});
With setZoomPercent returning the resulting zoom percentage in a callback.
Are there any plugins which can make the zoom level tab dependent? I really
don't like the zoom level to be depending of what I look at, but rather
what screen I view it on (dual screen setup).
Issue #31763 (side tabs) will break the hack I currently use to get css
pixel ratios: ((window.outerWidth-16) / window.innerWidth)
Issue #66656 brings something of a fix for detecting ratios properly.
I am visually impaired with macular degeneration in both eyes. Without a
choice of fixed fonts or stable zoom for Chrome it is useless for me to set
every time.
There needs to be an easy fix for visual options for Americans with
Disabilities for computing with Chrome. Google you are smarter than this.
George
Really want per-tab zoom. I don't need the zoom to be remembered after the
tab closes, so any arguments about storage shouldn't be there. There's
apparently no extensions that add support for it (yet!?!), if that's the
way you devs are going with it.
chrome.tabs.getZoomPercent() api is not exposed yet in chrome 10.x. What is
expected time to expose it for extensions? Please include it.
It's simple just make like "NoSquint" for Firefox. A No brainer.
Is possible to have a zoom management with default zoom for all web site
and a default zoom for selected web site?
This feature is the only reason chrome is not my primary browser. It is
annoying to use chrome on a 1920x1200 screen without auto zooming. NoSquint
for Firefox rules.
I have a Samsung NF310 with 1366x768 on a 10 inch screen. I set Windows
Font size to 125% and only IE9 obeys that. I use NoSquint for Firefox and
it doesn't have the consistency of IE9's 125% rendering. I hope this basic
feature becomes part of Chrome soon.
@arnold5771, I think you'd better file a separate bug on your issue (the
default zoom level should be inferred from the OS settings). You can file a
bug and refer to that bug here so that those interested in that can track
the bug.
Thank you.
Web pages are typically written by people who have no idea what it is like
to be middle aged and have presbyopia (age related far sightedness).
Yes when I was young I could see 1024/768 and a 14" monitor (a really big
monitor back in the late 1980s), but now at age 57 I'm constantly zooming.
So we need a simple zoom tool that remembers on a site-by-site basis,
independent of tabs.
Weird fixes, I've been in IT for 35 years and I suppose I could figure them
out. But I'm a rarity. You need something that works for completely
non-technical people without the need for them to go searching high and
low, without the need for them messing around with configuration files.
Sadly applications are the same way, but that is beyond the scope of your
project, except to say that if you use Windows7's (or WindowsXP's) DPI
scaling the applications won't work, the tags will overflow and be
truncated, which rules what could be part of the problem out. (Of course
no zooming by Windows is going to be customizable to web page anyways.)
That is my 2 cents worth as a fairly new Chrome user.
Firefox has "no squint" and it works well. It is what Chrome has to
compete with.
I don't know anything about Chrome. I'm just looking at it. But my
favorite feature about Opera is the zoom slider bar that's available on the
toolbar. If Chrome doesn't have something similar it's a fail.