SVGElement.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. SVGElement
  3. http://www.w3.org/TR/SVG/types.html#InterfaceSVGElement
  4. NB: "id" is illegal in Objective-C language, so we use "identifier" instead
  5. */
  6. #import <QuartzCore/QuartzCore.h>
  7. #import "Element.h"
  8. #import "Node+Mutable.h"
  9. #import "SVGStylable.h"
  10. #import "SVGLength.h"
  11. #define DEBUG_SVG_ELEMENT_PARSING 0
  12. @class SVGSVGElement;
  13. //obj-c's compiler sucks, and doesn't allow this line: #import "SVGSVGElement.h"
  14. @interface SVGElement : Element <SVGStylable>
  15. @property (nonatomic, readwrite, strong) NSString *identifier; // 'id' is reserved in Obj-C, so we have to break SVG Spec here, slightly
  16. @property (nonatomic, strong) NSString* xmlbase;
  17. /*!
  18. http://www.w3.org/TR/SVG/intro.html#TermSVGDocumentFragment
  19. SVG document fragment
  20. The XML document sub-tree which starts with an ‘svg’ element. An SVG document fragment can consist of a stand-alone SVG document, or a fragment of a parent XML document enclosed by an ‘svg’ element. When an ‘svg’ element is a descendant of another ‘svg’ element, there are two SVG document fragments, one for each ‘svg’ element. (One SVG document fragment is contained within another SVG document fragment.)
  21. */
  22. @property (nonatomic, weak) SVGSVGElement* rootOfCurrentDocumentFragment;
  23. /*! The viewport is set / re-set whenever an SVG node specifies a "width" (and optionally: a "height") attribute,
  24. assuming that SVG node is one of: svg, symbol, image, foreignobject
  25. The spec isn't clear what happens if this element redefines the viewport itself, but IMHO it implies that the
  26. viewportElement becomes a reference to "self" */
  27. @property (nonatomic, weak) SVGElement* viewportElement;
  28. #pragma mark - NON-STANDARD features of class (these are things that are NOT in the SVG spec, and should NOT be in SVGKit's implementation - they should be moved to a different class, although WE DO STILL NEED THESE in order to implement the spec, and to provide SVGKit features!)
  29. /*! This is used when generating CALayer objects, to store the id of the SVGElement that created the CALayer */
  30. #define kSVGElementIdentifier @"SVGElementIdentifier"
  31. #pragma mark - SVG-spec supporting methods that aren't in the Spec itself
  32. - (id)initWithLocalName:(NSString*) n attributes:(NSMutableDictionary*) attributes;
  33. - (id)initWithQualifiedName:(NSString*) n inNameSpaceURI:(NSString*) nsURI attributes:(NSMutableDictionary*) attributes;
  34. -(void) reCalculateAndSetViewportElementReferenceUsingFirstSVGAncestor:(SVGElement*) firstAncestor;
  35. /**
  36. Convenience method for reading an attribute (SVG defines all as strings), converting it into an SVGLength object
  37. */
  38. -(SVGLength*) getAttributeAsSVGLength:(NSString*) attributeName;
  39. #pragma mark - CSS cascading special attributes. c.f. full list here: http://www.w3.org/TR/SVG/propidx.html
  40. -(NSString*) cascadedValueForStylableProperty:(NSString*) stylableProperty;
  41. -(NSString*) cascadedValueForStylableProperty:(NSString*) stylableProperty inherit:(BOOL)inherit;
  42. @end