Commit 8edccce7 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Correctly display RTL dates in Print Preview.

Use the locale's RTL direction in Print Preview's header/footer template.

Bug: 906521
Change-Id: I97d2f8d30be8bfe26f4260df05fe26138655c487
Reviewed-on: https://chromium-review.googlesource.com/c/1354568
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613370}
parent 9c124df5
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <utility> #include <utility>
#include "base/auto_reset.h" #include "base/auto_reset.h"
#include "base/i18n/rtl.h"
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -721,6 +722,7 @@ void PrintRenderFrameHelper::PrintHeaderAndFooter( ...@@ -721,6 +722,7 @@ void PrintRenderFrameHelper::PrintHeaderAndFooter(
options->SetString("title", title.empty() ? params.title : title); options->SetString("title", title.empty() ? params.title : title);
options->SetString("headerTemplate", params.header_template); options->SetString("headerTemplate", params.header_template);
options->SetString("footerTemplate", params.footer_template); options->SetString("footerTemplate", params.footer_template);
options->SetBoolean("isRtl", base::i18n::IsRTL());
ExecuteScript(frame, kPageSetupScriptFormat, *options); ExecuteScript(frame, kPageSetupScriptFormat, *options);
......
...@@ -82,8 +82,11 @@ function setupHeaderFooterTemplate(options) { ...@@ -82,8 +82,11 @@ function setupHeaderFooterTemplate(options) {
options.date = new Date(options.date).toLocaleDateString(); options.date = new Date(options.date).toLocaleDateString();
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';
}
} }
} }
......
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