W3C home > Mailing lists > Public > www-style@w3.org > January 2016

[css-size-adjust] Expose the adjusted font-size and adjustment percentage

From: Philip Rogers <pdr@chromium.org>
Date: Sat, 9 Jan 2016 15:46:09 -0800
Message-ID: <CAJgFLLsFbYdQeHENbUDnsTaeT98zFNbS0SvfPhWnb-FdDrwhYw@mail.gmail.com>
To: www-style <www-style@w3.org>
All engines that implement size-adjustment use roughly the following
formula:
  usedFontSize = computedFontSize * textSizeAdjustmentPercentage

Authors have no compatible way to read these values (any 2 of the 3 will
work). Two real-world usecases we are currently hitting are:
1) Sizing iframe contents (such as advertisements) to match the text
surrounding the iframe.
2) Recording the adjusted font size when taking a "snapshots" of the
dom+style. Google Feedback is a tool that snapshots a page for
user-submitted bug reports.

To address these usecases I'd like to propose two changes that expose the
text size adjustment values:
1) Spec getComputedStyle(...)["font-size"] to return the used font size
after adjustment.

It's almost arbitrary whether this should return the computed or used
font-size. WebKit and Blink return the used value whereas Trident and Gecko
return the computed value. I think the used value is the safest in terms of
web compatibility due to the prevalence of WebKit on mobile.

2) Spec getComputedStyle(...)["text-size-adjust"] to return the used
text-size-adjust percentage if text-size-adjust: auto or none is specified.

If text-size-adjust: none is
specified, getComputedStyle(...)["text-size-adjust"] would return 100%. If
text-size-adjust: auto is specified, getComputedStyle("text-size-adjust"]
would return the percentage calculated by the default size adjustment
algorithm of the user agent, or 100% if no adjustment occurs.


To make this proposal more concrete lets look at an example where the user
agent increases the font-size from 12px to 36px:
<span id="span" style="font-size: 12px; text-size-adjust: auto;">
    Hello world
</span>
window.getComputedStyle(span)["font-size"] would return 36px
window.getComputedStyle(span)["text-size-adjust"] would return 300%
Received on Saturday, 9 January 2016 23:46:58 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:56 UTC