Commit d745a954 authored by Ella Ge's avatar Ella Ge Committed by Commit Bot

fix video subtitle font size

font size property is set on CSS pixel, but it's calculated from
video size, which is in physical pixel after use-zoom-for-dsf enabled
on Android.
This CL applys the page zoom factor to the video track font size.

Bug: 870243
Change-Id: If597e115b8f77395bbd21ac90d0112c7a86ee62f
Reviewed-on: https://chromium-review.googlesource.com/1160775Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Commit-Queue: Ella Ge <eirage@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581289}
parent 6c71cc7b
<!DOCTYPE html>
<title>Test that default positioned TextTrack's cues are rendered correctly.</title>
<script src="../media-controls.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<video>
<track src="captions-webvtt/captions.vtt" kind="captions" default>
</video>
<script>
async_test(function(t) {
zoom_factor = 2.5;
eventSender.setPageZoomFactor(zoom_factor);
var video = document.querySelector("video");
var testTrack = document.querySelector("track");
video.src = "../content/test.ogv";
video.onseeked = t.step_func(function() {
assert_equals(window.devicePixelRatio, zoom_factor)
testFontSize([[2560, 1440], [1000, 300], [600, 450], [300, 150]]);
});
function testFontSize(subjects) {
var dimensions = subjects.shift();
video.width = dimensions[0];
video.height = dimensions[1];
runAfterLayoutAndPaint(t.step_func(function() {
assert_equals(getComputedStyle(textTrackContainerElement(video)).fontSize, video.height * 0.05 + "px");
if (subjects.length) {
testFontSize(subjects);
} else {
t.done();
}
}));
}
video.currentTime = 0.5;
});
</script>
......@@ -29,6 +29,7 @@
#include "third_party/blink/renderer/core/html/track/text_track_container.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/core/html/track/cue_timeline.h"
#include "third_party/blink/renderer/core/html/track/text_track.h"
......@@ -112,6 +113,8 @@ void TextTrackContainer::UpdateDefaultFontSize(
LayoutUnit smallest_dimension =
std::min(video_size.Height(), video_size.Width());
float font_size = smallest_dimension * 0.05f;
if (media_layout_object->GetFrame())
font_size /= media_layout_object->GetFrame()->PageZoomFactor();
// Avoid excessive FP precision issue.
// C11 5.2.4.2.2:9 requires assignment and cast to remove extra precision, but
......
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