| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 bool InsertionPoint::canBeActive() const | 130 bool InsertionPoint::canBeActive() const |
| 131 { | 131 { |
| 132 if (!isInShadowTree()) | 132 if (!isInShadowTree()) |
| 133 return false; | 133 return false; |
| 134 return !Traversal<InsertionPoint>::firstAncestor(*this); | 134 return !Traversal<InsertionPoint>::firstAncestor(*this); |
| 135 } | 135 } |
| 136 | 136 |
| 137 bool InsertionPoint::isActive() const | 137 bool InsertionPoint::isActive() const |
| 138 { | 138 { |
| 139 if (!canBeActive()) | 139 // FIXME(sky): Remove this. |
| 140 return false; | 140 return canBeActive(); |
| 141 ShadowRoot* shadowRoot = containingShadowRoot(); | |
| 142 if (!shadowRoot) | |
| 143 return false; | |
| 144 if (!isHTMLShadowElement(*this) || shadowRoot->descendantShadowElementCount(
) <= 1) | |
| 145 return true; | |
| 146 | |
| 147 // Slow path only when there are more than one shadow elements in a shadow t
ree. That should be a rare case. | |
| 148 const Vector<RefPtr<InsertionPoint> >& insertionPoints = shadowRoot->descend
antInsertionPoints(); | |
| 149 for (size_t i = 0; i < insertionPoints.size(); ++i) { | |
| 150 InsertionPoint* point = insertionPoints[i].get(); | |
| 151 if (isHTMLShadowElement(*point)) | |
| 152 return point == this; | |
| 153 } | |
| 154 return true; | |
| 155 } | |
| 156 | |
| 157 bool InsertionPoint::isShadowInsertionPoint() const | |
| 158 { | |
| 159 return isHTMLShadowElement(*this) && isActive(); | |
| 160 } | 141 } |
| 161 | 142 |
| 162 bool InsertionPoint::isContentInsertionPoint() const | 143 bool InsertionPoint::isContentInsertionPoint() const |
| 163 { | 144 { |
| 164 return isHTMLContentElement(*this) && isActive(); | 145 return isHTMLContentElement(*this) && isActive(); |
| 165 } | 146 } |
| 166 | 147 |
| 167 PassRefPtr<StaticNodeList> InsertionPoint::getDistributedNodes() | 148 PassRefPtr<StaticNodeList> InsertionPoint::getDistributedNodes() |
| 168 { | 149 { |
| 169 document().updateDistributionForNodeIfNeeded(this); | 150 document().updateDistributionForNodeIfNeeded(this); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 if (!insertionPoints) | 248 if (!insertionPoints) |
| 268 return; | 249 return; |
| 269 for (size_t i = 0; i < insertionPoints->size(); ++i) | 250 for (size_t i = 0; i < insertionPoints->size(); ++i) |
| 270 results.append(insertionPoints->at(i).get()); | 251 results.append(insertionPoints->at(i).get()); |
| 271 ASSERT(current != insertionPoints->last().get()); | 252 ASSERT(current != insertionPoints->last().get()); |
| 272 current = insertionPoints->last().get(); | 253 current = insertionPoints->last().get(); |
| 273 } | 254 } |
| 274 } | 255 } |
| 275 | 256 |
| 276 } // namespace blink | 257 } // namespace blink |
| OLD | NEW |