CSSStyleDeclItemImpl setupDeclarationItem(IStructuredDocumentRegion flatNode) { if (flatNode == null) { return null; } if (!hasColonSeparator(flatNode)) { return null; } fParentRegion = flatNode; ITextRegionList nodeRegions = new TextRegionListImpl(flatNode.getRegions()); // make // copy CSSStyleDeclItemImpl newItem = createDeclarationItem(nodeRegions); if (newItem == null) { return null; } if (!fTempStructuredDocument && flatNode != null) { newItem.setRangeStructuredDocumentRegion(flatNode, flatNode); } CSSUtil.stripSurroundingSpace(nodeRegions); // Now, nodeRegions just has regions for value. setupValues(newItem, nodeRegions, null); return newItem; }
private String getPropertyName(ITextRegionList nodeRegions) { ITextRegionList nameRegions = new TextRegionListImpl(); String name = null; while (!nodeRegions.isEmpty()) { ITextRegion region = nodeRegions.remove(0); if (region == null) { continue; } String type = region.getType(); if (type == CSSRegionContexts.CSS_DECLARATION_SEPARATOR) { CSSUtil.stripSurroundingSpace(nameRegions); name = makeString(nameRegions); break; } else { nameRegions.add(region); } } return name; }
private CSSPrimitiveValueImpl createPrimitiveValue(ITextRegionList regions) { CSSPrimitiveValueImpl value = null; CSSUtil.stripSurroundingSpace(regions); if (regions.isEmpty()) { return null; } ITextRegion region = regions.get(0); if (region == null) { return null; } String type = region.getType(); if (type == CSSRegionContexts.CSS_DECLARATION_VALUE_FUNCTION) { String text = getText(region).toLowerCase(); if (text.equals("rgb(")) { // $NON-NLS-1$ value = createRgbValue(regions); } else if (text.equals("counter(")) { // $NON-NLS-1$ value = createCounterValue(regions); } else if (text.equals("counters(")) { // $NON-NLS-1$ value = createCountersValue(regions); } else if (text.equals("attr(")) { // $NON-NLS-1$ value = createAttrValue(regions); } else if (text.equals("format(")) { // $NON-NLS-1$ value = createFormatValue(regions); } else if (text.equals("local(")) { // $NON-NLS-1$ value = createLocalValue(regions); } else if (text.equals("rect(")) { // $NON-NLS-1$ value = createRectValue(regions); } if (value == null) { value = createStringValue(regions); } } else { value = createStringValue(regions); } if (!fTempStructuredDocument && value != null) { value.setRangeRegion(fParentRegion, regions.get(0), regions.get(regions.size() - 1)); } return value; }