Edgewall Software

Opened 12 years ago

Closed 9 years ago

Last modified 9 years ago

#10674 closed defect (fixed)

WorkFlow Macro displays "Enable JavaScript to display the workflow graph." — at Version 23

Reported by: Ryan J Ollos Owned by: Jun Omae
Priority: normal Milestone: 1.0.3
Component: wiki system Version: 0.13dev
Severity: normal Keywords:
Cc: Jun Omae Branch:
Release Notes:

Make [[Workflow]] macro work on auto-preview and prevent reflow when rendering workflow graph.

API Changes:
Internal Changes:

Description (last modified by Ryan J Ollos <ryano@…>)

To reproduce:

  • Go to ticket #7871.
  • Add the text comment:10 to Add a comment.
  • Wait for auto-preview to generate a preview.
  • Observe that Enable JavaScript to display the workflow graph. is displayed in comment:10.

Observed on t.e.o with Windows 7 and Firefox 12.0.

Change History (25)

by Ryan J Ollos <ryano@…>, 12 years ago

Attachment: comment_10_ticket_7871.png added

comment:1 by Ryan J Ollos <ryano@…>, 12 years ago

Description: modified (diff)

comment:2 by Remy Blank, 12 years ago

Milestone: next-major-0.1X

That's because we render the workflow graph only once at page render time. We currently don't have a mechanism to call processor- or macro-provided JavaScript at preview time. The same will probably happen in the automatic wiki preview.

in reply to:  2 ; comment:3 by Ryan J Ollos <ryano@…>, 12 years ago

Replying to rblank:

That's because we render the workflow graph only once at page render time. We currently don't have a mechanism to call processor- or macro-provided JavaScript at preview time. The same will probably happen in the automatic wiki preview.

I've also noticed in 0.12.3 that pygments syntax highlighting is not present when auto-previewing a ticket comment. Syntax highlighting is present after one explicitly invokes a preview. Is that possibly for the same reason? (although I thought Pygments was a pure-Python package, so maybe not …)

comment:4 by Remy Blank, 12 years ago

It's not exactly the same reason, but it's related. Syntax highlighting processors provide the CSS to be used after page rendering has already begun, so we can't add it as a <link> in the page header. Instead, it's loaded with JavaScript at the end of rendering. If you happen to already have a syntax highlighting processor on the ticket when you start adding a comment, rendering works fine, because the CSS is already loaded. Try adding a comment with a {{{#!python}}} block to e.g. #10644 if you want to see it in action.

in reply to:  3 comment:5 by Jun Omae, 12 years ago

Replying to Ryan J Ollos <ryano@…>:

I've also noticed in 0.12.3 that pygments syntax highlighting is not present when auto-previewing a ticket comment.

This issue has been reported as #10470.

comment:6 by Jun Omae, 12 years ago

Cc: Jun Omae added

comment:7 by framay <franz.mayer@…>, 12 years ago

Cc: franz.mayer@… added

When using Workflow macro in Wiki page, it always displays message Enable JavaScript to display the workflow graph. See demo-0.13/SandBoxWorkflowTest.

Tested with Firefox 12.0, Chrome 18.0 and IE 9.0 (all under Win7).

in reply to:  7 comment:8 by Christian Boos, 12 years ago

Replying to framay <franz.mayer@…>:

When using Workflow macro in Wiki page, it always displays message Enable JavaScript to display the workflow graph. See demo-0.13/SandBoxWorkflowTest.

Tested with Firefox 12.0, Chrome 18.0 and IE 9.0 (all under Win7).

Thanks for the report, but that problem was already fixed in r11033 and the 0.13-demo site was not yet updated.

comment:9 by Ryan J Ollos, 10 years ago

Reporter: changed from Ryan J Ollos <ryano@…> to Ryan J Ollos

comment:10 by Jun Omae, 10 years ago

Proof of concept can be found in jomae.git@t10674_1.0. After the patch, script data and script elements which are added by macros while rendering wiki append to response of XMLHttpResponse.

comment:11 by Jun Omae, 9 years ago

Milestone: next-major-releases1.0.3
Owner: set to Jun Omae
Status: newassigned

Updated jomae.git@t10674_1.0, targeting 1.0.3. Rather, should we retarget 1.1.3? Also, could someone please review it?

comment:12 by Ryan J Ollos, 9 years ago

The changes work well for me. I'll look at the code more closely tomorrow. I think it's good to target to 1.0.3 since it's a pretty significant defect in Trac. I can't see how it would negatively affect any plugins, do you? (On the other hand I'm reconsidering for some of the changes I've pushed to #11813 recently, which probably should have been targeted to the trunk because they are aesthetic issues only, and changing the structure of the page can negatively affect plugins).

comment:13 by Christian Boos, 9 years ago

Reviewing:

  • for [95943ba069/jomae.git] commit message, it feels like "prevent reflow by rendering workflow graph" is wrongly worded:
    • either "prevent reflow when rendering workflow graph"
    • or "prevent reflow by pre-setting placeholder size before rendering workflow graph"
  • for the change itself, it works but on Firefox I see that the system-message box is visible for quite some time before it gets replaced with the workflow graph; looking again, it's also there flickering in Chrome. I thought about adding a visibility:hidden rule on it with Javascript? → log:cboos.git@review/t10674_1.0
    With that the "red box" flicker is no longer there, but it seems that Firefox collapses the space allocated to the box even though I think it shouldn't. The only browser in which this seems to work flawlessly is IE, probably not a good sign ;-) Maybe you can improve upon my experiment?
  • for [732cc77619/jomae.git], looks good! (nitpick for the commit message, "make … macro work on auto-preview")

comment:14 by Jun Omae, 9 years ago

Thanks for the review! Reviewed commit messages will be used when I'll push the changes.

Another solution for the red box flicker can be found in [3adeb8dd/jomae.git]. noscript element is used in the changes.

in reply to:  14 ; comment:15 by Christian Boos, 9 years ago

Replying to jomae:

Another solution for the red box flicker can be found in [3adeb8dd/jomae.git]. noscript element is used in the changes.

Yes, nicer solution than mine! The red flicker is completely gone, but there's still some collapse/expand that can be seen with FF (33.1) and Chrome (38.0.2125.111). Only IE 11 seems able to avoid the reflow.

in reply to:  15 comment:16 by Jun Omae, 9 years ago

Replying to cboos:

Replying to jomae:

Another solution for the red box flicker can be found in [3adeb8dd/jomae.git]. noscript element is used in the changes.

Yes, nicer solution than mine! The red flicker is completely gone, but there's still some collapse/expand that can be seen with FF (33.1) and Chrome (38.0.2125.111). Only IE 11 seems able to avoid the reflow.

Hmm, I cannot still reproduce the collapse/expand problems.

Also, functional tests fail with that changes. XHTML1 strict DTD disallows the noscript element in head element. I'll rework it.

comment:17 by Jun Omae, 9 years ago

Updated jomae.git@t10674_1.0. Could you please try it?

by Christian Boos, 9 years ago

Attachment: t10674-overlap.png added

overlap issue with [b885614b03d3/jomae.git]

in reply to:  17 ; comment:18 by Christian Boos, 9 years ago

Replying to jomae:

Updated jomae.git@t10674_1.0. Could you please try it?

Nearly there! The collapse/expand issue is indeed gone (in FF, Chrome, still fine in IE) but there's now another glitch: in those 3 browsers, there's an unfortunate interaction when a float is around, like in the TracWorkflow page:

overlap issue with [b885614b03d3/jomae.git]

Looking for ways to prevent it, so far no luck except for a { display: inline !important } or (inline-block) which only works in FF and doesn't sound right anyway…

in reply to:  18 comment:19 by Christian Boos, 9 years ago

Replying to cboos:

Looking for ways to prevent it, so far no luck…

Ok, with this it seems to work:

  • trac/htdocs/js/workflow_graph.js

    diff --git a/trac/htdocs/js/workflow_graph.js b/trac/htdocs/js/workflow_graph.js
    index 4b14ce2..281edef 100644
    a b  
    223223                    source: nodes[sourceindex], target: nodes[targetindex]});
    224224      }
    225225
    226       var canvas = $('<canvas>').css({width: width, height: height})[0];
     226      var canvas = $('<canvas>').css({width: width, height: height,
     227                                      display: 'block'})[0];
    227228      canvas.width = $(canvas).width();
    228229      canvas.height = $(canvas).height();
    229230      if (typeof(G_vmlCanvasManager) != 'undefined')
  • trac/ticket/default_workflow.py

    diff --git a/trac/ticket/default_workflow.py b/trac/ticket/default_workflow.py
    index 9340278..b2b06e0 100644
    a b class WorkflowMacro(WikiMacroBase):  
    500500        return tag(
    501501            tag.div('', class_='trac-workflow-graph trac-noscript',
    502502                    id='trac-workflow-graph-%s' % graph_id,
    503                     style="height:%spx" % height),
     503                    style="display:inline-block;height:%spx" % height),
    504504            tag.noscript(
    505505                tag.div(_("Enable JavaScript to display the workflow graph."),
    506506                        class_='system-message')))

(inline would also do, but inline-block sounds better as we're dealing with a div…)

comment:20 by Jun Omae, 9 years ago

I just created patch similar to that, [bcf71c284/jomae.git]. The canvas element is defined as block element, but browsers practically render as inline-block.

in reply to:  20 comment:21 by Christian Boos, 9 years ago

Replying to jomae:

I just created patch similar to that, [bcf71c284/jomae.git].

Flawless behavior in all the browsers tested (FF, Chrome, IE on Windows). Great job!

comment:22 by Jun Omae, 9 years ago

Okay. Thanks for your reviewing and testing! I'm going to push the changes and close #10674,​10470.

comment:23 by Jun Omae, 9 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

Pushed in [13330-13331] and merged to trunk in [13332].

Note: See TracTickets for help on using tickets.