[Webkit-unassigned] [Bug 189397] New: Improvements to zooming helper functions
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Thu Sep 6 23:30:05 PDT 2018
https://bugs.webkit.org/show_bug.cgi?id=189397
Bug ID: 189397
Summary: Improvements to zooming helper functions
Product: WebKit
Version: WebKit Nightly Build
Hardware: Unspecified
OS: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: WebCore Misc.
Assignee: webkit-unassigned at lists.webkit.org
Reporter: fred.wang at free.fr
CC: simon.fraser at apple.com
We currently have at least three functions, with similar logic but different types of parameter. Maybe it would be possible to merge them into a single helper function. Some of them increment/decrement the value to workaround truncation and in bug 182230 Simon suggested to just floor/ceil after the division by zoomFactor. Not sure how that would impact accuracy.
RenderStyle.h:
inline int adjustForAbsoluteZoom(int value, const RenderStyle& style)
{
double zoomFactor = style.effectiveZoom();
if (zoomFactor == 1)
return value;
// Needed because computeLengthInt truncates (rather than rounds) when scaling up.
if (zoomFactor > 1) {
if (value < 0)
value--;
else
value++;
}
return roundForImpreciseConversion<int>(value / zoomFactor);
}
Element.cpp:
static double adjustForLocalZoom(LayoutUnit value, const RenderElement& renderer, double& zoomFactor)
{
zoomFactor = localZoomForRenderer(renderer);
if (zoomFactor == 1)
return value.toDouble();
return value.toDouble() / zoomFactor;
}
HTMLBodyElement.cpp
static int adjustForZoom(int value, const Frame& frame)
{
double zoomFactor = frame.pageZoomFactor() * frame.frameScaleFactor();
if (zoomFactor == 1)
return value;
// Needed because of truncation (rather than rounding) when scaling up.
if (zoomFactor > 1)
value++;
return static_cast<int>(value / zoomFactor);
}
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180907/f0643365/attachment-0001.html>
More information about the webkit-unassigned
mailing list