| Index: Source/WebCore/css/StyleResolver.cpp
 | 
| ===================================================================
 | 
| --- Source/WebCore/css/StyleResolver.cpp	(revision 141894)
 | 
| +++ Source/WebCore/css/StyleResolver.cpp	(working copy)
 | 
| @@ -1000,6 +1000,13 @@
 | 
|  static const unsigned cStyleSearchThreshold = 10;
 | 
|  static const unsigned cStyleSearchLevelThreshold = 10;
 | 
|  
 | 
| +static inline bool parentElementPreventsSharing(const Element* parentElement)
 | 
| +{
 | 
| +    if (!parentElement)
 | 
| +        return false;
 | 
| +    return parentElement->hasFlagsSetDuringStylingOfChildren();
 | 
| +}
 | 
| +
 | 
|  Node* StyleResolver::locateCousinList(Element* parent, unsigned& visitedNodeCount) const
 | 
|  {
 | 
|      if (visitedNodeCount >= cStyleSearchThreshold * cStyleSearchLevelThreshold)
 | 
| @@ -1029,7 +1036,8 @@
 | 
|      while (thisCousin) {
 | 
|          while (currentNode) {
 | 
|              ++subcount;
 | 
| -            if (currentNode->renderStyle() == parentStyle && currentNode->lastChild()) {
 | 
| +            if (currentNode->renderStyle() == parentStyle && currentNode->lastChild()
 | 
| +                && currentNode->isElementNode() && !parentElementPreventsSharing(toElement(currentNode))) {
 | 
|                  // Adjust for unused reserved tries.
 | 
|                  visitedNodeCount -= cStyleSearchThreshold - subcount;
 | 
|                  return currentNode->lastChild();
 | 
| @@ -1248,16 +1256,6 @@
 | 
|      return static_cast<StyledElement*>(node);
 | 
|  }
 | 
|  
 | 
| -static inline bool parentElementPreventsSharing(const Element* parentElement)
 | 
| -{
 | 
| -    if (!parentElement)
 | 
| -        return false;
 | 
| -    return parentElement->childrenAffectedByPositionalRules()
 | 
| -        || parentElement->childrenAffectedByFirstChildRules()
 | 
| -        || parentElement->childrenAffectedByLastChildRules()
 | 
| -        || parentElement->childrenAffectedByDirectAdjacentRules();
 | 
| -}
 | 
| -
 | 
|  RenderStyle* StyleResolver::locateSharedStyle()
 | 
|  {
 | 
|      if (!m_styledElement || !m_parentStyle)
 | 
| 
 |