Bug 28235 - Using QWebFrame::evaluateJavaScript does not relayout
Summary: Using QWebFrame::evaluateJavaScript does not relayout
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-12 15:31 PDT by Richard Moore
Modified: 2009-09-02 05:40 PDT (History)
1 user (show)

See Also:


Attachments
Patch to fix the bug (696 bytes, patch)
2009-08-12 15:31 PDT, Richard Moore
hausmann: review-
Details | Formatted Diff | Diff
A patch that changes how evaluateJavaScript works (2.51 KB, patch)
2009-08-13 14:11 PDT, Richard Moore
no flags Details | Formatted Diff | Diff
Patch against 4.5.1 to fix the issue (3.11 KB, patch)
2009-08-15 09:00 PDT, Richard Moore
no flags Details | Formatted Diff | Diff
Patch against master for the same issue (3.13 KB, patch)
2009-08-15 09:01 PDT, Richard Moore
no flags Details | Formatted Diff | Diff
Patch against Qt git repo (3.10 KB, patch)
2009-08-28 07:40 PDT, Richard Moore
no flags Details | Formatted Diff | Diff
Patch against Qt git repo including changelog (2.98 KB, patch)
2009-08-28 07:46 PDT, Richard Moore
no flags Details | Formatted Diff | Diff
Patch against qtwebkit git repo including changelog no tabs (402.18 KB, patch)
2009-08-28 07:54 PDT, Richard Moore
no flags Details | Formatted Diff | Diff
Patch against qtwebkit git repo including changelog no tabs (2.85 KB, patch)
2009-08-28 07:58 PDT, Richard Moore
vestbo: review+
vestbo: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Moore 2009-08-12 15:31:17 PDT
Created attachment 34700 [details]
Patch to fix the bug

It seems that executing javascript code using evaluateJavaScript that changes the visibility of some divs in a page does not cause an immediate relayout of the page. The page instead remains unchanged until the user moves the mouse over it. The problem was found by using js like this:

function toggleVisibility(id)
{
    el = document.getElementById(id);
    if (el.style.display == 'none')
    {
        el.style.display = '';
        window.silk.GM_log('showing');
    } else {
        el.style.display = 'none';
        window.silk.GM_log('hiding');
    }
}

toggleVisibility('sidebar');
toggleVisibility('header');
toggleVisibility('footer');

Executed against a gitorious repository. The same code executed in the inspector functions as expected. I've included what I think should be a patch to fix this issue in master, though since my code has kde dependencies against 4.5 I have been unable to test it so far.
Comment 1 Simon Hausmann 2009-08-13 02:02:05 PDT
Comment on attachment 34700 [details]
Patch to fix the bug

This patch is missing a ChangeLog.

I'm not convinced it's the correct fix though. Why do the other ports appear not to need this?

For example the Mac API has stringByEvaluatingJavaScriptFromString, which can be called to evaluate javascript and the view will be updated afterwards. (A quick google search suggests that it works).

However I notice one important difference:

We are calling evaluate() on the ScriptController directly, whereas the mac port calls FrameLoader::executeScript, which calls Document::updateStyleForAllDocuments() after evaluation.

I think the correct fix involves calling executeScript instead of evaluate on the ScriptController.
Comment 2 Richard Moore 2009-08-13 14:10:19 PDT
Ok, another patch that is closer to what Simon suggested.
Comment 3 Richard Moore 2009-08-13 14:11:42 PDT
Created attachment 34786 [details]
A patch that changes how evaluateJavaScript works
Comment 4 Richard Moore 2009-08-15 09:00:16 PDT
Created attachment 34897 [details]
Patch against 4.5.1 to fix the issue

This patch changes the way evaluateJavaScript works in QWebFrame  to use the FrameProxy. This fixes the bug. It also adds a test case for this issue.
Comment 5 Richard Moore 2009-08-15 09:01:52 PDT
Created attachment 34898 [details]
Patch against master for the same issue

This patch makes the same change as the other one, but is for qt/master. The bug does not currently occur there, but using the frameproxy seems safer anyway. Either way the test case should be included to prevent the issue being reintroduced.
Comment 6 Richard Moore 2009-08-15 09:02:53 PDT
I think the two patches I've attached are now suitable for inclusion to 4.5 branch of qt and master respectively.
Comment 7 Richard Moore 2009-08-28 07:40:44 PDT
Created attachment 38735 [details]
Patch against Qt git repo
Comment 8 Richard Moore 2009-08-28 07:46:55 PDT
Created attachment 38737 [details]
Patch against Qt git repo including changelog
Comment 9 Richard Moore 2009-08-28 07:54:54 PDT
Created attachment 38738 [details]
Patch against qtwebkit git repo including changelog no tabs
Comment 10 Richard Moore 2009-08-28 07:58:33 PDT
Created attachment 38739 [details]
Patch against qtwebkit git repo including changelog no tabs
Comment 11 Tor Arne Vestbø 2009-09-02 04:58:40 PDT
Comment on attachment 34898 [details]
Patch against master for the same issue

Marking as obsolete, as patches should be made against webkit trunk (like the last one)
Comment 12 Tor Arne Vestbø 2009-09-02 05:40:24 PDT
Landed in r47963