Bug 1012231

Summary: Make inline history more efficient when inserting elements
Product: [Community] Bugzilla Reporter: Simon Green <sgreen>
Component: User InterfaceAssignee: Simon Green <sgreen>
Status: CLOSED CURRENTRELEASE QA Contact: tools-bugs <tools-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.4CC: ebaak, rjoost
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 4.4.0009 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-10-04 00:46:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Simon Green 2013-09-26 04:25:16 UTC
(another bmo side port)

Now that I've looked into the Bugzilla code (https://bugzilla.mozilla.org/extensions/InlineHistory/web/inline-history.js) my suspicion in comment 8 seems correct:

>          var itemHtml =  '<div class="ih_history_item ' + containerClass + '" '
>                          + 'id="h' + i + '">'
>                          + item[3]
>                          + '<div class="ih_history_change">' + item[2] + '</div>'
>                          + '</div>';
>
>          if (ih_activity_sort_order == 'oldest_to_newest') {
>            currentDiv.innerHTML = currentDiv.innerHTML + itemHtml;
>          } else {
>            currentDiv.innerHTML = itemHtml + currentDiv.innerHTML;
>          }

This is being done for each single history item and in case of bug 705294 currentDiv is always the same element (there is only one comment so all history items are being inserted into the same place). Each time an item is being added the HTML code for the entire block (including all the previously added items) has to be reparsed. The most trivial way to avoid this issue would be replacing the code above by one that doesn't touch already existing elements:

>          var item = document.createElement("div");
>          item.className = "ih_history_item " + containerClass;
>          item.id = "h' + i;
>          item.innerHTML = item[3] + '<div class="ih_history_change">' + item[2] + '</div>';
>
>          if (ih_activity_sort_order == 'oldest_to_newest') {
>            currentDiv.appendChild(item);
>          } else {
>            currentDiv.insertChild(item, currentDiv.firstChild);
>          }

Comment 3 Simon Green 2013-10-04 00:46:23 UTC
This change is now live. If there are any issues, do not reopen this bug.
Instead, you should create a new bug and reference this bug.

  -- simon