Commit 78e363c4 authored by Weilun Shi's avatar Weilun Shi Committed by Commit Bot

[NTP] Wait for chromium logo loaded before adjusting width

The logoImg.complete event was not working as intended on Mac's chromium
chrome://apps. Directly using onload event to adjust the width for the
footer menu and the logo instead.

Screencast:
https://screencast.googleplex.com/cast/NTY2NzA1MTk2ODM5NzMxMnw1ZDVjMjU5NS1jYQ

Bug: 864267
Change-Id: I614d44c9377e276f6d3084c299ab9ced98ed831d
Reviewed-on: https://chromium-review.googlesource.com/c/1257676Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: Weilun Shi <sweilun@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596368}
parent 608b2a89
......@@ -221,14 +221,16 @@ cr.define('ntp', function() {
*/
function layoutFooter() {
// We need the image to be loaded.
var logo = $('logo-img');
var logoImg = logo.querySelector('img');
if (!logoImg.complete) {
let logo = $('logo-img');
let logoImg = logo.querySelector('img');
// Only compare the width after the footer image successfully loaded.
if (!logoImg.complete || logoImg.width === 0) {
logoImg.onload = layoutFooter;
return;
}
var menu = $('footer-menu-container');
let menu = $('footer-menu-container');
if (menu.clientWidth > logoImg.width)
logo.style.WebkitFlex = '0 1 ' + menu.clientWidth + 'px';
else
......
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