+2011-02-08 Ojan Vafai <ojan@chromium.org>
+
+ Reviewed by Adam Barth.
+
+ fix toolbar anchoring in the code review tool
+ https://bugs.webkit.org/show_bug.cgi?id=54058
+
+ Avoid the anchoring cycle of doom when on the cusp
+ of whether the toolbar needs to be anchored and
+ speculatively avoid the Firefox crash when resizing.
+
+ * PrettyPatch/PrettyPatch.rb:
+ * code-review.js:
+
2011-02-07 Ojan Vafai <ojan@chromium.org>
Reviewed by Adam Barth.
}
function updateToolbarAnchorState() {
- var has_scrollbar = window.innerWidth > document.documentElement.offsetWidth;
- $('#toolbar').toggleClass('anchored', has_scrollbar);
+ var toolbar = $('#toolbar');
+ // Unanchor the toolbar and then see if it's bottom is below the body's bottom.
+ toolbar.toggleClass('anchored', false);
+ var toolbar_bottom = toolbar.offset().top + toolbar.outerHeight();
+ var should_anchor = toolbar_bottom >= document.body.clientHeight;
+ toolbar.toggleClass('anchored', should_anchor);
}
function diffLinksHtml() {
'<span id="flagContainer"></span>' +
'<button id="preview_comments">Preview</button>' +
'<button id="post_comments">Publish</button> ' +
- '</span></div>' +
+ '</span>' +
'</div>' +
'</div>');
// FIXME: Should we setTimeout throttle these?
var resize_iframe = $('<iframe class="pseudo_resize_event_iframe"></iframe>');
$(document.body).append(resize_iframe);
- $(resize_iframe[0].contentWindow).bind('resize', onBodyResize);
+ // Handle the event on a timeout to avoid crashing Firefox.
+ $(resize_iframe[0].contentWindow).bind('resize', function() { setTimeout(onBodyResize, 0)});
updateToolbarAnchorState();
loadDiffState();