OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 /** | 6 /** |
7 * @fileoverview The local InstantExtended NTP and suggestions dropdown. | 7 * @fileoverview The local InstantExtended NTP and suggestions dropdown. |
8 */ | 8 */ |
9 | 9 |
10 (function() { | 10 (function() { |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 // Make thumbnails tab-accessible. | 436 // Make thumbnails tab-accessible. |
437 tileElement.setAttribute('tabindex', '1'); | 437 tileElement.setAttribute('tabindex', '1'); |
438 registerKeyHandler(tileElement, KEYCODE.ENTER, navigateFunction); | 438 registerKeyHandler(tileElement, KEYCODE.ENTER, navigateFunction); |
439 | 439 |
440 // The iframe which renders the page title. | 440 // The iframe which renders the page title. |
441 var titleElement = document.createElement('iframe'); | 441 var titleElement = document.createElement('iframe'); |
442 titleElement.tabIndex = '-1'; | 442 titleElement.tabIndex = '-1'; |
443 var usingCustomTheme = document.body.classList.contains( | 443 var usingCustomTheme = document.body.classList.contains( |
444 CLASSES.CUSTOM_THEME); | 444 CLASSES.CUSTOM_THEME); |
445 | 445 |
| 446 // Why iframes have IDs: |
| 447 // |
| 448 // On navigating back to the NTP we see several onmostvisitedchange() events |
| 449 // in series with incrementing RIDs. After the first event, a set of iframes |
| 450 // begins loading RIDs n, n+1, ..., n+k-1; after the second event, these get |
| 451 // destroyed and a new set begins loading RIDs n+k, n+k+1, ..., n+2k-1. |
| 452 // Now due to crbug.com/68841, Chrome incorrectly loads the content for the |
| 453 // first set of iframes into the most recent set of iframes. |
| 454 // |
| 455 // Giving iframes distinct ids seems to cause some invalidation and prevent |
| 456 // associating the incorrect data. |
| 457 // |
| 458 // TODO(jered): Find and fix the root (probably Blink) bug. |
| 459 |
446 titleElement.src = getMostVisitedIframeUrl( | 460 titleElement.src = getMostVisitedIframeUrl( |
447 MOST_VISITED_TITLE_IFRAME, rid, | 461 MOST_VISITED_TITLE_IFRAME, rid, |
448 usingCustomTheme ? MOST_VISITED_THEME_TITLE_COLOR : MOST_VISITED_COLOR, | 462 usingCustomTheme ? MOST_VISITED_THEME_TITLE_COLOR : MOST_VISITED_COLOR, |
449 MOST_VISITED_FONT_FAMILY, MOST_VISITED_FONT_SIZE, usingCustomTheme, | 463 MOST_VISITED_FONT_FAMILY, MOST_VISITED_FONT_SIZE, usingCustomTheme, |
450 position); | 464 position); |
| 465 // Keep this id here. See comment above. |
| 466 titleElement.id = 'title-' + rid; |
451 titleElement.hidden = true; | 467 titleElement.hidden = true; |
452 titleElement.onload = function() { titleElement.hidden = false; }; | 468 titleElement.onload = function() { titleElement.hidden = false; }; |
453 titleElement.className = CLASSES.TITLE; | 469 titleElement.className = CLASSES.TITLE; |
454 tileElement.appendChild(titleElement); | 470 tileElement.appendChild(titleElement); |
455 | 471 |
456 // The iframe which renders either a thumbnail or domain element. | 472 // The iframe which renders either a thumbnail or domain element. |
457 var thumbnailElement = document.createElement('iframe'); | 473 var thumbnailElement = document.createElement('iframe'); |
458 thumbnailElement.tabIndex = '-1'; | 474 thumbnailElement.tabIndex = '-1'; |
459 thumbnailElement.src = getMostVisitedIframeUrl( | 475 thumbnailElement.src = getMostVisitedIframeUrl( |
460 MOST_VISITED_THUMBNAIL_IFRAME, rid, MOST_VISITED_COLOR, | 476 MOST_VISITED_THUMBNAIL_IFRAME, rid, MOST_VISITED_COLOR, |
461 MOST_VISITED_FONT_FAMILY, MOST_VISITED_FONT_SIZE, false, position); | 477 MOST_VISITED_FONT_FAMILY, MOST_VISITED_FONT_SIZE, false, position); |
| 478 // Keep this id here. See comment above. |
| 479 thumbnailElement.id = 'thumb-' + rid; |
462 thumbnailElement.hidden = true; | 480 thumbnailElement.hidden = true; |
463 thumbnailElement.onload = function() { | 481 thumbnailElement.onload = function() { |
464 thumbnailElement.hidden = false; | 482 thumbnailElement.hidden = false; |
465 tileElement.classList.add(CLASSES.PAGE_READY); | 483 tileElement.classList.add(CLASSES.PAGE_READY); |
466 }; | 484 }; |
467 thumbnailElement.className = CLASSES.THUMBNAIL; | 485 thumbnailElement.className = CLASSES.THUMBNAIL; |
468 tileElement.appendChild(thumbnailElement); | 486 tileElement.appendChild(thumbnailElement); |
469 | 487 |
470 // A mask to darken the thumbnail on focus. | 488 // A mask to darken the thumbnail on focus. |
471 var maskElement = createAndAppendElement( | 489 var maskElement = createAndAppendElement( |
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1739 } | 1757 } |
1740 } | 1758 } |
1741 | 1759 |
1742 document.addEventListener('DOMContentLoaded', init); | 1760 document.addEventListener('DOMContentLoaded', init); |
1743 window.addEventListener('message', handleMessage, false); | 1761 window.addEventListener('message', handleMessage, false); |
1744 window.addEventListener('blur', function() { | 1762 window.addEventListener('blur', function() { |
1745 if (activeBox) | 1763 if (activeBox) |
1746 activeBox.clearHover(); | 1764 activeBox.clearHover(); |
1747 }, false); | 1765 }, false); |
1748 })(); | 1766 })(); |
OLD | NEW |