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

Bug 127422

Summary: Error in CSS shorthand expansion.
Product: [WebTools] WTP Source Editing Reporter: Yang Liu <yliu000>
Component: wst.cssAssignee: Sarika Sinha <sarika.sinha>
Status: RESOLVED WORKSFORME QA Contact: Nick Sandonato <nsand.dev>
Severity: major    
Priority: P3 CC: thatnitind
Version: 1.0Keywords: helpwanted
Target Milestone: 3.2 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Yang Liu CLA 2006-02-13 01:58:18 EST
To reproduce the bug, I created a simple HTML file "a.html", and the content is as following:

<div style="border: solid red">a</div>

Then I try to get the individual border styles, and use a program like the following:
---------------------------------------------------------------------
StructuredTextEditor sse = (StructuredTextEditor) _targetEditor;
IDOMModel model = (IDOMModel) sse.getModel();
IDOMElement ele = (IDOMElement) model.getDocument().getDocumentElement();

CSSQueryTraverser traverser = new CSSQueryTraverser();
traverser.setElement(ele, null);
ICSSStyleDeclaration decl = traverser.getDeclaration();
StringBuffer buffer = new StringBuffer();

buffer.append("decl.getPropertyCSSValue(\"border-left-style\"): " + decl.getPropertyValue("border-left-style") + "\n");
buffer.append("decl.getPropertyCSSValue(\"border-right-style\"): " + decl.getPropertyValue("border-right-style") + "\n");
buffer.append("decl.getPropertyCSSValue(\"border-top-style\"): " + decl.getPropertyValue("border-top-style") + "\n");
buffer.append("decl.getPropertyCSSValue(\"border-bottom-style\"): " + decl.getPropertyValue("border-bottom-style") + "\n");

System.out.println(buffer);

--------------------------------------------------------------------
The output is like following:

decl.getPropertyCSSValue("border-left-style"): solid
decl.getPropertyCSSValue("border-right-style"): null
decl.getPropertyCSSValue("border-top-style"): solid
decl.getPropertyCSSValue("border-bottom-style"): solid

--------------------------------------------------------------------

Notice that for the "border-right-style" the result is "null"!

If I remove the "red" to change the HTML source to: 
<div style="border: solid">a</div>

The output will be:

decl.getPropertyCSSValue("border-left-style"): null
decl.getPropertyCSSValue("border-right-style"): null
decl.getPropertyCSSValue("border-top-style"): null
decl.getPropertyCSSValue("border-bottom-style"): solid

****************************************************************************

After some investigation, I believe the problem is relation to the usage of "CSSStyleDeclItemImpl.java#sharedStructuredDocument". "sharedStructuredDocument" is shared, but seemed something wrong with it. If I comment out line 234 of CSSStyleDeclItemImpl to disable sharing, then everything works fine.

//	if (sharedStructuredDocument == null) {
		IDocumentLoader loader = new CSSDocumentLoader();
		sharedStructuredDocument = (IStructuredDocument) loader.createNewStructuredDocument();
		((CSSSourceParser) sharedStructuredDocument.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE);
		
//	}
Comment 1 David Williams CLA 2006-03-02 22:20:26 EST
thanks very much for your clear test case and analysis. 
We'll take a look .. I think there's another bug somewhere involving that 
sharedDocument (I think ... if that's the one that a class variable).

Comment 2 David Williams CLA 2006-06-01 13:52:19 EDT
no time this release, unless a case can be made this is blocking some usecase. 
Comment 3 David Williams CLA 2008-07-23 23:18:34 EDT
reassigning to you Nick, since you've handled some other CSS items ... maybe you'd know if a dup, or something, even though it's marked as 'helpwanted'. 
Comment 4 Sarika Sinha CLA 2009-11-17 10:30:27 EST
Looks like it has been fixed indirectly by #124835.