Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 425425

Summary: TextView can fail to send LineStyle events for newly-rendered lines
Product: [ECD] Orion Reporter: Grant Gayed <grant_gayed>
Component: EditorAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Silenio_Quarti
Version: 5.0   
Target Milestone: 5.0 RC1   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
screenshot none

Description Grant Gayed CLA 2014-01-10 11:53:52 EST
Created attachment 238875 [details]
screenshot

- happens in Chrome and Firefox

- open a .js editor on the content pasted at the bottom
- select the full block comment at the top and press Delete
- problem: note that several lines of regular javascript at the bottom of the viewport are left with the green comment style (screenshot is attached)

I investigated and noticed:
- these are lines that were not previously visible in the viewport
- after deleting the comment at the top a few LineStyle events come in to the TextStyler, but none for these newly-shown lines (seems to be the issue)
- identical problem happens with the old and new TextStylers


The content to start with:
/*******************************************************************************
 * @license
 * Copyright (c) 2010, 2013 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials are made 
 * available under the terms of the Eclipse Public License v1.0 
 * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution 
 * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
 * 
 * TODO asdf
 * 
 *  * Contributors: 
 *		Felipe Heidrich (IBM Corporation) - initial API and implementation
 *		Silenio Quarti (IBM Corporation) - initial API and implementation
 *		Mihai Sucan (Mozilla Foundation) - fix for Bug#334583 Bug#348471 Bug#349485 Bug#350595 Bug#360726 Bug#361180 Bug#362835 Bug#362428 Bug#362286 Bug#354270 Bug#361474 Bug#363945 Bug#366312 Bug#370584
 * <p>
 ******************************************************************************/


	/** @private */
	function getWindow(document) {
		return document.defaultView || document.parentWindow;
	}
	var addHandler = textUtil.addEventListener;
	var removeHandler = textUtil.removeEventListener;
	/** @private */
	function applyStyle(style, node, reset) {
		if (reset) {
			node.className = "";
			var attrs = node.attributes;
			for (var i= attrs.length; i-->0;) {
				if (!util.isIE || util.isIE >= 9 || (util.isIE < 9 && attrs[i].specified)) {
					node.removeAttribute(attrs[i].name); 
				}
			}
		}
		if (!style) {
			return;
		}
		if (style.styleClass) {
			node.className = style.styleClass;
		}
		var properties = style.style;
		if (properties) {
			for (var s in properties) {
				if (properties.hasOwnProperty(s)) {
					node.style[s] = properties[s];
				}
			}
		}
		var attributes = style.attributes;
		if (attributes) {
			for (var a in attributes) {
				if (attributes.hasOwnProperty(a)) {
					node.setAttribute(a, attributes[a]);
				}
			}
		}
	}
Comment 1 Silenio Quarti CLA 2014-01-29 12:09:56 EST
This is a event ordering problem cause by the changes to support the split editor [1].  The problem happens because the "Changed" event for the base text model is sent after the "Changed" event for the projection text model which causes the "LineStyle" event to be sent before the styler has had a chance to update its internal structure (block comments).

[1] http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/bundles/org.eclipse.orion.client.editor/web/orion/editor/projectionTextModel.js?id=56efa2a2e4c2c629b660ce37db112de44565f21a

Here is the fix:

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=56f87f3afeb40dbcba1bd0df8269f25471490998