OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 11 matching lines...) Expand all Loading... |
22 #if ENABLE(SVG) | 22 #if ENABLE(SVG) |
23 #include "SVGPathSegListPropertyTearOff.h" | 23 #include "SVGPathSegListPropertyTearOff.h" |
24 | 24 |
25 #include "SVGAnimatedPathSegListPropertyTearOff.h" | 25 #include "SVGAnimatedPathSegListPropertyTearOff.h" |
26 #include "SVGNames.h" | 26 #include "SVGNames.h" |
27 #include "SVGPathElement.h" | 27 #include "SVGPathElement.h" |
28 #include "SVGPathSegWithContext.h" | 28 #include "SVGPathSegWithContext.h" |
29 | 29 |
30 namespace WebCore { | 30 namespace WebCore { |
31 | 31 |
| 32 void SVGPathSegListPropertyTearOff::clearContextAndRoles() |
| 33 { |
| 34 ASSERT(m_values); |
| 35 unsigned size = m_values->size(); |
| 36 for (unsigned i = 0; i < size; ++i) { |
| 37 ListItemType item = m_values->at(i); |
| 38 static_cast<SVGPathSegWithContext*>(item.get())->setContextAndRole(0, Pa
thSegUndefinedRole); |
| 39 } |
| 40 } |
| 41 |
32 void SVGPathSegListPropertyTearOff::clear(ExceptionCode& ec) | 42 void SVGPathSegListPropertyTearOff::clear(ExceptionCode& ec) |
33 { | 43 { |
34 ASSERT(m_values); | 44 ASSERT(m_values); |
35 if (m_values->isEmpty()) | 45 if (m_values->isEmpty()) |
36 return; | 46 return; |
37 | 47 |
38 unsigned size = m_values->size(); | 48 clearContextAndRoles(); |
39 for (unsigned i = 0; i < size; ++i) { | |
40 ListItemType item = m_values->at(i); | |
41 static_cast<SVGPathSegWithContext*>(item.get())->setContextAndRole(0, Pa
thSegUndefinedRole); | |
42 } | |
43 | |
44 SVGPathSegListPropertyTearOff::Base::clearValues(ec); | 49 SVGPathSegListPropertyTearOff::Base::clearValues(ec); |
45 } | 50 } |
46 | 51 |
47 SVGPathSegListPropertyTearOff::PassListItemType SVGPathSegListPropertyTearOff::g
etItem(unsigned index, ExceptionCode& ec) | 52 SVGPathSegListPropertyTearOff::PassListItemType SVGPathSegListPropertyTearOff::g
etItem(unsigned index, ExceptionCode& ec) |
48 { | 53 { |
49 ListItemType returnedItem = Base::getItemValues(index, ec); | 54 ListItemType returnedItem = Base::getItemValues(index, ec); |
50 if (returnedItem) { | 55 if (returnedItem) { |
51 ASSERT(static_cast<SVGPathSegWithContext*>(returnedItem.get())->contextE
lement() == contextElement()); | 56 ASSERT(static_cast<SVGPathSegWithContext*>(returnedItem.get())->contextE
lement() == contextElement()); |
52 ASSERT(static_cast<SVGPathSegWithContext*>(returnedItem.get())->role() =
= m_pathSegRole); | 57 ASSERT(static_cast<SVGPathSegWithContext*>(returnedItem.get())->role() =
= m_pathSegRole); |
53 } | 58 } |
54 return returnedItem.release(); | 59 return returnedItem.release(); |
55 } | 60 } |
56 | 61 |
| 62 SVGPathSegListPropertyTearOff::PassListItemType SVGPathSegListPropertyTearOff::r
eplaceItem(PassListItemType passNewItem, unsigned index, ExceptionCode& ec) |
| 63 { |
| 64 // Not specified, but FF/Opera do it this way, and it's just sane. |
| 65 if (!passNewItem) { |
| 66 ec = SVGException::SVG_WRONG_TYPE_ERR; |
| 67 return 0; |
| 68 } |
| 69 |
| 70 if (index < m_values->size()) { |
| 71 ListItemType replacedItem = m_values->at(index); |
| 72 ASSERT(replacedItem); |
| 73 static_cast<SVGPathSegWithContext*>(replacedItem.get())->setContextAndRo
le(0, PathSegUndefinedRole); |
| 74 } |
| 75 |
| 76 ListItemType newItem = passNewItem; |
| 77 return Base::replaceItemValues(newItem, index, ec); |
| 78 } |
| 79 |
57 SVGPathSegListPropertyTearOff::PassListItemType SVGPathSegListPropertyTearOff::r
emoveItem(unsigned index, ExceptionCode& ec) | 80 SVGPathSegListPropertyTearOff::PassListItemType SVGPathSegListPropertyTearOff::r
emoveItem(unsigned index, ExceptionCode& ec) |
58 { | 81 { |
59 SVGPathSegListPropertyTearOff::ListItemType removedItem = SVGPathSegListProp
ertyTearOff::Base::removeItemValues(index, ec); | 82 SVGPathSegListPropertyTearOff::ListItemType removedItem = SVGPathSegListProp
ertyTearOff::Base::removeItemValues(index, ec); |
60 if (removedItem) | 83 if (removedItem) |
61 static_cast<SVGPathSegWithContext*>(removedItem.get())->setContextAndRol
e(0, PathSegUndefinedRole); | 84 static_cast<SVGPathSegWithContext*>(removedItem.get())->setContextAndRol
e(0, PathSegUndefinedRole); |
62 return removedItem.release(); | 85 return removedItem.release(); |
63 } | 86 } |
64 | 87 |
65 SVGPathElement* SVGPathSegListPropertyTearOff::contextElement() const | 88 SVGPathElement* SVGPathSegListPropertyTearOff::contextElement() const |
66 { | 89 { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 if (static_cast<unsigned>(indexToRemove) < index) | 132 if (static_cast<unsigned>(indexToRemove) < index) |
110 --index; | 133 --index; |
111 } | 134 } |
112 | 135 |
113 return true; | 136 return true; |
114 } | 137 } |
115 | 138 |
116 } | 139 } |
117 | 140 |
118 #endif // ENABLE(SVG) | 141 #endif // ENABLE(SVG) |
OLD | NEW |