From ac81ab458cf26aa63b8a46906421e2ffba1c8f60 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Wed, 12 May 2010 18:41:14 -0700 Subject: [PATCH] Fix for same html appearing multiple times in CPWebView when using loadHTMLString: many times in succession. Reviewed by me. --- AppKit/CPWebView.j | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/AppKit/CPWebView.j b/AppKit/CPWebView.j index a198c0214..bf36a7773 100644 --- a/AppKit/CPWebView.j +++ b/AppKit/CPWebView.j @@ -69,11 +69,13 @@ CPWebViewScrollNative = 2; CPString _url; CPString _html; - + Function _loadCallback; - + int _scrollMode; CGSize _scrollSize; + + int _loadHTMLStringTimer; } - (id)initWithFrame:(CPRect)frameRect frameName:(CPString)frameName groupName:(CPString)groupName @@ -327,8 +329,15 @@ CPWebViewScrollNative = 2; // clear the iframe _iframe.src = ""; + if (_loadHTMLStringTimer !== nil) + { + window.clearTimeout(_loadHTMLStringTimer); + _loadHTMLStringTimer = nil; + } + // need to give the browser a chance to reset iframe, otherwise we'll be document.write()-ing the previous document - window.setTimeout(function() { + _loadHTMLStringTimer = window.setTimeout(function() + { var win = [self DOMWindow]; win.document.write(_html);