Bug 127422 - Error in CSS shorthand expansion.
Summary: Error in CSS shorthand expansion.
Status: RESOLVED WORKSFORME
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.css (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows 2000
: P3 major (vote)
Target Milestone: 3.2 M4   Edit
Assignee: Sarika Sinha CLA
QA Contact: Nick Sandonato CLA
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2006-02-13 01:58 EST by Yang Liu CLA
Modified: 2009-11-17 10:30 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.