|
Lines 73-78
Link Here
|
| 73 |
return super.createPartition(offset, length, stype); |
73 |
return super.createPartition(offset, length, stype); |
| 74 |
} |
74 |
} |
| 75 |
} |
75 |
} |
|
|
76 |
else if (type == IHTMLPartitions.STYLE) { |
| 77 |
IStructuredDocumentRegion node = fStructuredDocument.getRegionAtCharacterOffset(offset); |
| 78 |
if (node != null) { |
| 79 |
String stype = getStylePartitionType(node); |
| 80 |
return super.createPartition(offset, length, stype); |
| 81 |
} |
| 82 |
} |
| 76 |
return super.createPartition(offset, length, type); |
83 |
return super.createPartition(offset, length, type); |
| 77 |
} |
84 |
} |
| 78 |
|
85 |
|
|
Lines 84-89
Link Here
|
| 84 |
localType = getScriptingPartitionType(node); |
91 |
localType = getScriptingPartitionType(node); |
| 85 |
} |
92 |
} |
| 86 |
} |
93 |
} |
|
|
94 |
else if (type == IHTMLPartitions.STYLE) { |
| 95 |
IStructuredDocumentRegion node = fStructuredDocument.getRegionAtCharacterOffset(offset); |
| 96 |
if (node != null) { |
| 97 |
localType = getStylePartitionType(node); |
| 98 |
} |
| 99 |
} |
| 87 |
super.setInternalPartition(offset, length, localType); |
100 |
super.setInternalPartition(offset, length, localType); |
| 88 |
} |
101 |
} |
| 89 |
|
102 |
|
|
Lines 136-141
Link Here
|
| 136 |
return result; |
149 |
return result; |
| 137 |
} |
150 |
} |
| 138 |
|
151 |
|
|
|
152 |
private String getStylePartitionType(IStructuredDocumentRegion coreNode) { |
| 153 |
String type = null; |
| 154 |
String result = IHTMLPartitions.STYLE; |
| 155 |
IStructuredDocumentRegion node = coreNode; |
| 156 |
ITextRegion attrNameRegion = null; |
| 157 |
while (node != null && isValidScriptingRegionType(node.getType())) { |
| 158 |
node = node.getPrevious(); |
| 159 |
} |
| 160 |
|
| 161 |
ITextRegionList regions = node.getRegions(); |
| 162 |
if (regions.size() > 4 && regions.get(1).getType() == DOMRegionContext.XML_TAG_NAME) { |
| 163 |
ITextRegion potentialTypeRegion = regions.get(1); |
| 164 |
String potentialTypeString = node.getText(potentialTypeRegion); |
| 165 |
if (potentialTypeString.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE)) { |
| 166 |
for (int i = 0; i < regions.size(); i++) { |
| 167 |
ITextRegion region = regions.get(i); |
| 168 |
String regionType = region.getType(); |
| 169 |
if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) |
| 170 |
attrNameRegion = region; |
| 171 |
else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) { |
| 172 |
String attrName = node.getText(attrNameRegion); |
| 173 |
if (attrName.equalsIgnoreCase(HTML40Namespace.ATTR_NAME_TYPE)) { |
| 174 |
type = StringUtils.strip(node.getText(region)); |
| 175 |
break; |
| 176 |
} |
| 177 |
attrNameRegion = null; |
| 178 |
} |
| 179 |
} |
| 180 |
} |
| 181 |
} |
| 182 |
result = lookupStyleType(type); |
| 183 |
return result; |
| 184 |
} |
| 185 |
|
| 139 |
private boolean isValidScriptingRegionType(String type) { |
186 |
private boolean isValidScriptingRegionType(String type) { |
| 140 |
return type == DOMRegionContext.BLOCK_TEXT || type == DOMRegionContext.XML_CDATA_OPEN || type == DOMRegionContext.XML_CDATA_TEXT || type == DOMRegionContext.XML_CDATA_CLOSE; |
187 |
return type == DOMRegionContext.BLOCK_TEXT || type == DOMRegionContext.XML_CDATA_OPEN || type == DOMRegionContext.XML_CDATA_TEXT || type == DOMRegionContext.XML_CDATA_CLOSE; |
| 141 |
} |
188 |
} |
|
Lines 144-149
Link Here
|
| 144 |
fSupportedTypes = getConfiguredContentTypes(); |
191 |
fSupportedTypes = getConfiguredContentTypes(); |
| 145 |
} |
192 |
} |
| 146 |
|
193 |
|
|
|
194 |
private String lookupStyleType(String type) { |
| 195 |
if (type == null || type.length() == 0 || "text/css".equalsIgnoreCase(type)) //$NON-NLS-1$ |
| 196 |
return ICSSPartitions.STYLE; |
| 197 |
return IHTMLPartitions.STYLE; |
| 198 |
} |
| 199 |
|
| 147 |
private String lookupScriptType(String type) { |
200 |
private String lookupScriptType(String type) { |
| 148 |
for (int i = 0; i < ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS.length; i++) |
201 |
for (int i = 0; i < ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS.length; i++) |
| 149 |
if (ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS[i].equalsIgnoreCase(type)) |
202 |
if (ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS[i].equalsIgnoreCase(type)) |
|
Lines 202-208
Link Here
|
| 202 |
// return ST_SCRIPT; |
255 |
// return ST_SCRIPT; |
| 203 |
return getScriptingPartitionType(fStructuredDocument.getRegionAtCharacterOffset(previousNode.getStartOffset(previousStartTagNameRegion))); |
256 |
return getScriptingPartitionType(fStructuredDocument.getRegionAtCharacterOffset(previousNode.getStartOffset(previousStartTagNameRegion))); |
| 204 |
else if (name1.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE) && name2.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE)) |
257 |
else if (name1.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE) && name2.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE)) |
| 205 |
return ICSSPartitions.STYLE; |
258 |
return getStylePartitionType(fStructuredDocument.getRegionAtCharacterOffset(previousNode.getStartOffset(previousStartTagNameRegion))); |
| 206 |
return super.getPartitionTypeBetween(previousNode, nextNode); |
259 |
return super.getPartitionTypeBetween(previousNode, nextNode); |
| 207 |
} |
260 |
} |
| 208 |
|
261 |
|
|
Lines 218-224
Link Here
|
| 218 |
else if (tagname.equalsIgnoreCase(HTML40Namespace.ElementName.SCRIPT)) |
271 |
else if (tagname.equalsIgnoreCase(HTML40Namespace.ElementName.SCRIPT)) |
| 219 |
result = IHTMLPartitions.SCRIPT; |
272 |
result = IHTMLPartitions.SCRIPT; |
| 220 |
else if (tagname.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE) || isStyleAttributeValue(region,offset)) |
273 |
else if (tagname.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE) || isStyleAttributeValue(region,offset)) |
| 221 |
result = ICSSPartitions.STYLE; |
274 |
result = IHTMLPartitions.STYLE; |
| 222 |
else if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE && isScriptAttributeValue(region, offset)) |
275 |
else if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE && isScriptAttributeValue(region, offset)) |
| 223 |
result = IHTMLPartitions.SCRIPT_EVENTHANDLER; |
276 |
result = IHTMLPartitions.SCRIPT_EVENTHANDLER; |
| 224 |
else |
277 |
else |