Skip to content

Commit

Permalink
Restrict AVD and VD parsing to the current element instead of the who…
Browse files Browse the repository at this point in the history
…le document

This CL changes the AVD xml parsing to parsing only within the current
element, which prevents AVD parsing from always skipping to the end of
the doucment. So things that are defined after AVD in the same document
can be picked up by the xml parser.

The same fix has been applied to VD as well.

BUG: 31865175
Test: Manually following comment zsol#1 in the bug above

Change-Id: I4ebdce1eb2e92d6f6e2c37caed9607253d24602f
  • Loading branch information
doris4lt committed Oct 3, 2016
1 parent 20cf001 commit 1f85971
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,11 @@ public void inflate(Resources res, XmlPullParser parser, AttributeSet attrs, The

int eventType = parser.getEventType();
float pathErrorScale = 1;
while (eventType != XmlPullParser.END_DOCUMENT) {
final int innerDepth = parser.getDepth() + 1;

// Parse everything until the end of the animated-vector element.
while (eventType != XmlPullParser.END_DOCUMENT
&& (parser.getDepth() >= innerDepth || eventType != XmlPullParser.END_TAG)) {
if (eventType == XmlPullParser.START_TAG) {
final String tagName = parser.getName();
if (ANIMATED_VECTOR.equals(tagName)) {
Expand Down
6 changes: 5 additions & 1 deletion graphics/java/android/graphics/drawable/VectorDrawable.java
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,11 @@ private void inflateChildElements(Resources res, XmlPullParser parser, Attribute
groupStack.push(state.mRootGroup);

int eventType = parser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
final int innerDepth = parser.getDepth() + 1;

// Parse everything until the end of the vector element.
while (eventType != XmlPullParser.END_DOCUMENT
&& (parser.getDepth() >= innerDepth || eventType != XmlPullParser.END_TAG)) {
if (eventType == XmlPullParser.START_TAG) {
final String tagName = parser.getName();
final VGroup currentGroup = groupStack.peek();
Expand Down

0 comments on commit 1f85971

Please sign in to comment.