Commit 09fa6a54 authored by Czirkos Zoltan's avatar Czirkos Zoltan Committed by Chromium LUCI CQ

Properly hide pageNumber/totalPages in printing when intersects margin

When printing, the footer template for showing page number is:

  <span class='pageNumber'></span>/<span class='totalPages'></span>

When the footer intersects the bottom margin, it is hidden. However,
previously only the two spans were hidden, and the slash character
stayed at the bottom of the page. This patch fixes that by hiding
the div.text containers instead, whenever they intersect the margins.

Bug: 1069445
Change-Id: Ia41d58fe146188ad4819075319f0655240e65908
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2144141Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Denis Kuznetsov [CET] <antrim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834218}
parent 0dd59657
...@@ -108,13 +108,15 @@ function setupHeaderFooterTemplate(options) { ...@@ -108,13 +108,15 @@ function setupHeaderFooterTemplate(options) {
for (const cssClass of ['date', 'title', 'url', 'pageNumber', 'totalPages']) { for (const cssClass of ['date', 'title', 'url', 'pageNumber', 'totalPages']) {
for (const element of document.querySelectorAll(`.${cssClass}`)) { for (const element of document.querySelectorAll(`.${cssClass}`)) {
element.textContent = options[cssClass]; element.textContent = options[cssClass];
if (options.isRtl) }
element.dir = 'rtl'; }
for (const element of document.querySelectorAll(`.text`)) {
if (elementIntersects(element, topMargin, bottomMargin, leftMargin, if (options.isRtl) {
rightMargin)) { element.dir = 'rtl';
element.style.visibility = 'hidden'; }
} if (elementIntersects(element, topMargin, bottomMargin, leftMargin,
rightMargin)) {
element.style.visibility = 'hidden';
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment