summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarv@google.com <arv@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-28 18:01:19 +0000
committerarv@google.com <arv@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-28 18:01:19 +0000
commit4c9ab62bfc9eace0c21944b0e82dad20b3614f0d (patch)
treeda8c6bca8366576b92ea1fdaf8e39e1598f81319
parent5b43a76ae2ceb056c32f208035cf61a1426836b3 (diff)
downloadchromium_src-4c9ab62bfc9eace0c21944b0e82dad20b3614f0d.zip
chromium_src-4c9ab62bfc9eace0c21944b0e82dad20b3614f0d.tar.gz
chromium_src-4c9ab62bfc9eace0c21944b0e82dad20b3614f0d.tar.bz2
Remove JSTemplate from NTP
This should reduce the time to show the NTP with about 5ms :-) Fix a bug with tips causing an exception when there are no tips. BUG=None TEST=None Review URL: http://codereview.chromium.org/178015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24751 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc1
-rw-r--r--chrome/browser/resources/new_new_tab.html11
-rw-r--r--chrome/browser/resources/new_new_tab.js46
3 files changed, 24 insertions, 34 deletions
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index ab9440b..e3d2182 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -382,7 +382,6 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path,
jstemplate_builder::AppendJsonHtml(&localized_strings, &full_html);
jstemplate_builder::AppendI18nTemplateSourceHtml(&full_html);
jstemplate_builder::AppendI18nTemplateProcessHtml(&full_html);
- jstemplate_builder::AppendJsTemplateSourceHtml(&full_html);
scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
html_bytes->data.resize(full_html.size());
diff --git a/chrome/browser/resources/new_new_tab.html b/chrome/browser/resources/new_new_tab.html
index 5266a88..4c1db94 100644
--- a/chrome/browser/resources/new_new_tab.html
+++ b/chrome/browser/resources/new_new_tab.html
@@ -235,15 +235,8 @@ document.write('<link id="themecss" rel="stylesheet" ' +
</div> <!-- main -->
-<div>
- <div class="window-menu" id="window-tooltip">
- <span class="item" jsselect="$this"
- jsvalues=".style.backgroundImage:'url(&quot;chrome://favicon/' + url +
- '&quot;)';
- dir:direction;"
- jscontent="title"></span>
- </div>
-</div>
+<div class="window-menu" id="window-tooltip"></div>
+
</body>
<script src="local_strings.js"></script>
<script src="new_new_tab.js"></script>
diff --git a/chrome/browser/resources/new_new_tab.js b/chrome/browser/resources/new_new_tab.js
index d7d78c1..7ba8af3 100644
--- a/chrome/browser/resources/new_new_tab.js
+++ b/chrome/browser/resources/new_new_tab.js
@@ -103,13 +103,15 @@ function tips(data) {
}
function createTip(data) {
- var parsedTips;
- try {
- parsedTips = parseHtmlSubset(data[0].tip_html_text);
- } catch (parseErr) {
- console.log('Error parsing tips: ' + parseErr.message);
+ if (data.length) {
+ try {
+ return parseHtmlSubset(data[0].tip_html_text);
+ } catch (parseErr) {
+ console.error('Error parsing tips: ' + parseErr.message);
+ }
}
- return parsedTips;
+ // Return an empty DF in case of failure.
+ return document.createDocumentFragment();
}
function renderTip() {
@@ -197,23 +199,6 @@ function saveShownSections() {
chrome.send('setShownSections', [String(shownSections)]);
}
-function processData(selector, data) {
- var output = document.querySelector(selector);
-
- // Wait until ready
- if (typeof JsEvalContext !== 'function' || !output) {
- logEvent('JsEvalContext is not yet available, ' + selector);
- document.addEventListener('DOMContentLoaded', function() {
- processData(selector, data);
- });
- } else {
- var d0 = Date.now();
- var input = new JsEvalContext(data);
- jstProcess(input, output);
- logEvent('processData: ' + selector + ', ' + (Date.now() - d0));
- }
-}
-
function getThumbnailClassName(data) {
return 'thumbnail-container' +
(data.pinned ? ' pinned' : '') +
@@ -1239,7 +1224,7 @@ WindowTooltip.prototype = {
WindowTooltip.trackMouseMove_);
clearTimeout(this.timer);
- processData('#window-tooltip', tabs);
+ this.renderItems(tabs);
var rect = linkEl.getBoundingClientRect();
var bodyRect = document.body.getBoundingClientRect();
var rtl = document.documentElement.dir == 'rtl';
@@ -1292,6 +1277,19 @@ WindowTooltip.prototype = {
this.linkEl_ = null;
this.tooltipEl.style.display = 'none';
+ },
+ renderItems: function(tabs) {
+ var tooltip = this.tooltipEl;
+ tooltip.textContent = '';
+
+ tabs.forEach(function(tab) {
+ var span = document.createElement('span');
+ span.className = 'item';
+ span.style.backgroundImage = url('chrome://favicon/' + tab.url);
+ span.dir = tab.direction;
+ span.textContent = tab.title;
+ tooltip.appendChild(span);
+ });
}
};