Skip to content

Commit

Permalink
Merge pull request #339 from Zazo032/master
Browse files Browse the repository at this point in the history
Upgrade xml dependency
  • Loading branch information
dnfield committed May 5, 2020
2 parents 5aaf19b + fdefb2e commit 0e618ca
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 58 deletions.
17 changes: 1 addition & 16 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
Expand All @@ -28,8 +24,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -40,13 +34,11 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
Expand All @@ -60,8 +52,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -71,9 +61,7 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
Expand Down Expand Up @@ -206,7 +194,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -259,7 +247,6 @@
/* Begin XCBuildConfiguration section */
24247ED7217E8F7400BE4BD8 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -331,7 +318,6 @@
};
97C147031CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -385,7 +371,6 @@
};
97C147041CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
Expand Down

This file was deleted.

26 changes: 13 additions & 13 deletions lib/src/svg/parser_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import 'xml_parsers.dart';
final Set<String> _unhandledElements = <String>{'title', 'desc'};

typedef _ParseFunc = Future<void> Function(SvgParserState parserState);
typedef _PathFunc = Path Function(List<XmlElementAttribute> attributes);
typedef _PathFunc = Path Function(List<XmlEventAttribute> attributes);

const Map<String, _ParseFunc> _svgElementParsers = <String, _ParseFunc>{
'svg': _Elements.svg,
Expand Down Expand Up @@ -599,20 +599,20 @@ class _Elements {
}

class _Paths {
static Path circle(List<XmlElementAttribute> attributes) {
static Path circle(List<XmlEventAttribute> attributes) {
final double cx = parseDouble(getAttribute(attributes, 'cx', def: '0'));
final double cy = parseDouble(getAttribute(attributes, 'cy', def: '0'));
final double r = parseDouble(getAttribute(attributes, 'r', def: '0'));
final Rect oval = Rect.fromCircle(center: Offset(cx, cy), radius: r);
return Path()..addOval(oval);
}

static Path path(List<XmlElementAttribute> attributes) {
static Path path(List<XmlEventAttribute> attributes) {
final String d = getAttribute(attributes, 'd');
return parseSvgPathData(d);
}

static Path rect(List<XmlElementAttribute> attributes) {
static Path rect(List<XmlEventAttribute> attributes) {
final double x = parseDouble(getAttribute(attributes, 'x', def: '0'));
final double y = parseDouble(getAttribute(attributes, 'y', def: '0'));
final double w = parseDouble(getAttribute(attributes, 'width', def: '0'));
Expand All @@ -633,16 +633,16 @@ class _Paths {
return Path()..addRect(rect);
}

static Path polygon(List<XmlElementAttribute> attributes) {
static Path polygon(List<XmlEventAttribute> attributes) {
return parsePathFromPoints(attributes, true);
}

static Path polyline(List<XmlElementAttribute> attributes) {
static Path polyline(List<XmlEventAttribute> attributes) {
return parsePathFromPoints(attributes, false);
}

static Path parsePathFromPoints(
List<XmlElementAttribute> attributes, bool close) {
List<XmlEventAttribute> attributes, bool close) {
final String points = getAttribute(attributes, 'points');
if (points == '') {
return null;
Expand All @@ -652,7 +652,7 @@ class _Paths {
return parseSvgPathData(path);
}

static Path ellipse(List<XmlElementAttribute> attributes) {
static Path ellipse(List<XmlEventAttribute> attributes) {
final double cx = parseDouble(getAttribute(attributes, 'cx', def: '0'));
final double cy = parseDouble(getAttribute(attributes, 'cy', def: '0'));
final double rx = parseDouble(getAttribute(attributes, 'rx', def: '0'));
Expand All @@ -662,7 +662,7 @@ class _Paths {
return Path()..addOval(r);
}

static Path line(List<XmlElementAttribute> attributes) {
static Path line(List<XmlEventAttribute> attributes) {
final double x1 = parseDouble(getAttribute(attributes, 'x1', def: '0'));
final double x2 = parseDouble(getAttribute(attributes, 'x2', def: '0'));
final double y1 = parseDouble(getAttribute(attributes, 'y1', def: '0'));
Expand Down Expand Up @@ -696,7 +696,7 @@ class SvgParserState {
final Queue<_SvgGroupTuple> _parentDrawables = ListQueue<_SvgGroupTuple>(10);
DrawableRoot _root;
bool _inDefs = false;
List<XmlElementAttribute> _currentAttributes;
List<XmlEventAttribute> _currentAttributes;
XmlStartElementEvent _currentStartElement;

/// The current depth of the reader in the XML hierarchy.
Expand All @@ -715,7 +715,7 @@ class SvgParserState {
depth -= 1;
assert(depth >= 0);
}
_currentAttributes = <XmlElementAttribute>[];
_currentAttributes = <XmlEventAttribute>[];
_currentStartElement = null;
if (depth < subtreeStartDepth) {
return;
Expand Down Expand Up @@ -756,7 +756,7 @@ class SvgParserState {
if (isSelfClosing || event is XmlEndElementEvent) {
depth -= 1;
assert(depth >= 0);
_currentAttributes = <XmlElementAttribute>[];
_currentAttributes = <XmlEventAttribute>[];
_currentStartElement = null;
}
if (depth < subtreeStartDepth) {
Expand Down Expand Up @@ -791,7 +791,7 @@ class SvgParserState {
}

/// The XML Attributes of the current node in the tree.
List<XmlElementAttribute> get attributes => _currentAttributes;
List<XmlEventAttribute> get attributes => _currentAttributes;

/// Gets the attribute for the current position of the parser.
String attribute(String name, {String def, String namespace}) =>
Expand Down
32 changes: 16 additions & 16 deletions lib/src/svg/xml_parsers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ double _parseRawWidthHeight(String raw) {
/// The [respectWidthHeight] parameter specifies whether `width` and `height` attributes
/// on the root SVG element should be treated in accordance with the specification.
DrawableViewport parseViewBox(
List<XmlElementAttribute> svg, {
List<XmlEventAttribute> svg, {
bool nullOk = false,
}) {
final String viewBox = getAttribute(svg, 'viewBox');
Expand Down Expand Up @@ -86,14 +86,14 @@ DrawableViewport parseViewBox(
}

/// Builds an IRI in the form of `'url(#id)'`.
String buildUrlIri(List<XmlElementAttribute> attributes) =>
String buildUrlIri(List<XmlEventAttribute> attributes) =>
'url(#${getAttribute(attributes, 'id')})';

/// An empty IRI.
const String emptyUrlIri = 'url(#)';

/// Parses a `spreadMethod` attribute into a [TileMode].
TileMode parseTileMode(List<XmlElementAttribute> attributes) {
TileMode parseTileMode(List<XmlEventAttribute> attributes) {
final String spreadMethod =
getAttribute(attributes, 'spreadMethod', def: 'pad');
switch (spreadMethod) {
Expand All @@ -108,11 +108,11 @@ TileMode parseTileMode(List<XmlElementAttribute> attributes) {
}
}

/// Parses an @stroke-dasharray attribute into a [CircularIntervalList]
/// Parses an @stroke-dasharray attribute into a [CircularIntervalList].
///
/// Does not currently support percentages.
CircularIntervalList<double> parseDashArray(
List<XmlElementAttribute> attributes,
List<XmlEventAttribute> attributes,
) {
final String rawDashArray = getAttribute(attributes, 'stroke-dasharray');
if (rawDashArray == '') {
Expand All @@ -126,8 +126,8 @@ CircularIntervalList<double> parseDashArray(
parts.map((String part) => parseDouble(part)).toList());
}

/// Parses a @stroke-dashoffset into a [DashOffset]
DashOffset parseDashOffset(List<XmlElementAttribute> attributes) {
/// Parses a @stroke-dashoffset into a [DashOffset].
DashOffset parseDashOffset(List<XmlEventAttribute> attributes) {
final String rawDashOffset = getAttribute(attributes, 'stroke-dashoffset');
if (rawDashOffset == '') {
return null;
Expand All @@ -143,7 +143,7 @@ DashOffset parseDashOffset(List<XmlElementAttribute> attributes) {
}

/// Parses an @opacity value into a [double], clamped between 0..1.
double parseOpacity(List<XmlElementAttribute> attributes) {
double parseOpacity(List<XmlEventAttribute> attributes) {
final String rawOpacity = getAttribute(attributes, 'opacity', def: null);
if (rawOpacity != null) {
return parseDouble(rawOpacity).clamp(0.0, 1.0).toDouble();
Expand All @@ -168,7 +168,7 @@ DrawablePaint _getDefinitionPaint(PaintingStyle paintingStyle, String iri,

/// Parses a @stroke attribute into a [Paint].
DrawablePaint parseStroke(
List<XmlElementAttribute> attributes,
List<XmlEventAttribute> attributes,
Rect bounds,
DrawableDefinitionServer definitions,
DrawablePaint parentStroke,
Expand Down Expand Up @@ -235,7 +235,7 @@ DrawablePaint parseStroke(

/// Parses a `fill` attribute.
DrawablePaint parseFill(
List<XmlElementAttribute> el,
List<XmlEventAttribute> el,
Rect bounds,
DrawableDefinitionServer definitions,
DrawablePaint parentFill,
Expand Down Expand Up @@ -293,14 +293,14 @@ Color _determineFillColor(
}

/// Parses a `fill-rule` attribute into a [PathFillType].
PathFillType parseFillRule(List<XmlElementAttribute> attributes,
PathFillType parseFillRule(List<XmlEventAttribute> attributes,
[String attr = 'fill-rule', String def = 'nonzero']) {
final String rawFillRule = getAttribute(attributes, attr, def: def);
return parseRawFillRule(rawFillRule);
}

/// Applies a transform to a path if the [attributes] contain a `transform`.
Path applyTransformIfNeeded(Path path, List<XmlElementAttribute> attributes) {
Path applyTransformIfNeeded(Path path, List<XmlEventAttribute> attributes) {
final Matrix4 transform =
parseTransform(getAttribute(attributes, 'transform', def: null));

Expand All @@ -313,7 +313,7 @@ Path applyTransformIfNeeded(Path path, List<XmlElementAttribute> attributes) {

/// Parses a `clipPath` element into a list of [Path]s.
List<Path> parseClipPath(
List<XmlElementAttribute> attributes,
List<XmlEventAttribute> attributes,
DrawableDefinitionServer definitions,
) {
final String rawClipAttribute = getAttribute(attributes, 'clip-path');
Expand Down Expand Up @@ -342,9 +342,9 @@ const Map<String, BlendMode> _blendModes = <String, BlendMode>{
'luminosity': BlendMode.luminosity,
};

/// Lookup the mask if the attribute is present
/// Lookup the mask if the attribute is present.
DrawableStyleable parseMask(
List<XmlElementAttribute> attributes,
List<XmlEventAttribute> attributes,
DrawableDefinitionServer definitions,
) {
final String rawMaskAttribute = getAttribute(attributes, 'mask');
Expand Down Expand Up @@ -390,7 +390,7 @@ FontWeight parseFontWeight(String fontWeight) {
///
/// Remember that @style attribute takes precedence.
DrawableStyle parseStyle(
List<XmlElementAttribute> attributes,
List<XmlEventAttribute> attributes,
DrawableDefinitionServer definitions,
Rect bounds,
DrawableStyle parentStyle, {
Expand Down
8 changes: 4 additions & 4 deletions lib/src/utilities/xml.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const String kXlinkNamespace = 'http://www.w3.org/1999/xlink';
///
/// SVG 1.1 specifies that these attributes should be in the xlink namespace.
/// SVG 2 deprecates that namespace.
String getHrefAttribute(List<XmlElementAttribute> attributes) => getAttribute(
String getHrefAttribute(List<XmlEventAttribute> attributes) => getAttribute(
attributes,
'href',
namespace: kXlinkNamespace,
Expand All @@ -19,7 +19,7 @@ String getHrefAttribute(List<XmlElementAttribute> attributes) => getAttribute(
///
/// Will look to the style first if it can.
String getAttribute(
List<XmlElementAttribute> el,
List<XmlEventAttribute> el,
String name, {
String def = '',
String namespace,
Expand Down Expand Up @@ -53,14 +53,14 @@ String getAttribute(
}

String _getAttribute(
List<XmlElementAttribute> list,
List<XmlEventAttribute> list,
String localName, {
String def = '',
String namespace,
}) {
return list
.firstWhere(
(XmlElementAttribute attr) =>
(XmlEventAttribute attr) =>
attr.name.replaceFirst('${attr.namespacePrefix}:', '') ==
localName,
orElse: () => null)
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 0.17.3+1

dependencies:
path_drawing: ^0.4.1
xml: ^3.3.1
xml: ^4.1.0
vector_math: ^2.0.4
meta: ^1.1.2
flutter:
Expand Down

0 comments on commit 0e618ca

Please sign in to comment.