| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/dom/shadow/ShadowRoot.h" | 28 #include "core/dom/shadow/ShadowRoot.h" |
| 29 | 29 |
| 30 #include "bindings/v8/ExceptionMessages.h" | 30 #include "bindings/v8/ExceptionMessages.h" |
| 31 #include "bindings/v8/ExceptionState.h" | 31 #include "bindings/v8/ExceptionState.h" |
| 32 #include "core/css/resolver/StyleResolver.h" | 32 #include "core/css/resolver/StyleResolver.h" |
| 33 #include "core/dom/ElementTraversal.h" | 33 #include "core/dom/ElementTraversal.h" |
| 34 #include "core/dom/StyleEngine.h" | 34 #include "core/dom/StyleEngine.h" |
| 35 #include "core/dom/Text.h" | 35 #include "core/dom/Text.h" |
| 36 #include "core/dom/WhitespaceChildList.h" |
| 36 #include "core/dom/shadow/ElementShadow.h" | 37 #include "core/dom/shadow/ElementShadow.h" |
| 37 #include "core/dom/shadow/InsertionPoint.h" | 38 #include "core/dom/shadow/InsertionPoint.h" |
| 38 #include "core/dom/shadow/ShadowRootRareData.h" | 39 #include "core/dom/shadow/ShadowRootRareData.h" |
| 39 #include "core/editing/markup.h" | 40 #include "core/editing/markup.h" |
| 40 #include "core/platform/HistogramSupport.h" | 41 #include "core/platform/HistogramSupport.h" |
| 41 | 42 |
| 42 namespace WebCore { | 43 namespace WebCore { |
| 43 | 44 |
| 44 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public
DoublyLinkedListNode<ShadowRoot> { | 45 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public
DoublyLinkedListNode<ShadowRoot> { |
| 45 void* pointers[3]; | 46 void* pointers[3]; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 return; | 172 return; |
| 172 } | 173 } |
| 173 | 174 |
| 174 // When we're set to lazyAttach we'll have a SubtreeStyleChange and we'll ne
ed | 175 // When we're set to lazyAttach we'll have a SubtreeStyleChange and we'll ne
ed |
| 175 // to promote the change to a Force for all our descendants so they get a | 176 // to promote the change to a Force for all our descendants so they get a |
| 176 // recalc and will attach. | 177 // recalc and will attach. |
| 177 if (styleChangeType() >= SubtreeStyleChange) | 178 if (styleChangeType() >= SubtreeStyleChange) |
| 178 change = Force; | 179 change = Force; |
| 179 | 180 |
| 180 // FIXME: This doesn't handle :hover + div properly like Element::recalcStyl
e does. | 181 // FIXME: This doesn't handle :hover + div properly like Element::recalcStyl
e does. |
| 181 bool forceReattachOfAnyWhitespaceSibling = false; | 182 WhitespaceChildList whitespaceChildList(change); |
| 182 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 183 for (Node* child = lastChild(); child; child = child->previousSibling()) { |
| 183 bool didReattach = false; | 184 if (child->isTextNode()) { |
| 185 Text* textChild = toText(child); |
| 186 if (textChild->containsOnlyWhitespace()) |
| 187 whitespaceChildList.append(textChild); |
| 188 else |
| 189 textChild->recalcTextStyle(change); |
| 190 } else if (child->isElementNode() && shouldRecalcStyle(change, child)) { |
| 191 toElement(child)->recalcStyle(change); |
| 192 } |
| 193 } |
| 184 | 194 |
| 185 if (child->renderer()) | 195 whitespaceChildList.recalcStyle(); |
| 186 forceReattachOfAnyWhitespaceSibling = false; | |
| 187 | |
| 188 if (child->isTextNode()) { | |
| 189 if (forceReattachOfAnyWhitespaceSibling && toText(child)->containsOn
lyWhitespace()) | |
| 190 child->reattach(); | |
| 191 else | |
| 192 didReattach = toText(child)->recalcTextStyle(change); | |
| 193 } else if (child->isElementNode() && shouldRecalcStyle(change, child)) { | |
| 194 didReattach = toElement(child)->recalcStyle(change); | |
| 195 } | |
| 196 | |
| 197 forceReattachOfAnyWhitespaceSibling = didReattach || forceReattachOfAnyW
hitespaceSibling; | |
| 198 } | |
| 199 | 196 |
| 200 styleResolver->popParentShadowRoot(*this); | 197 styleResolver->popParentShadowRoot(*this); |
| 201 clearNeedsStyleRecalc(); | 198 clearNeedsStyleRecalc(); |
| 202 clearChildNeedsStyleRecalc(); | 199 clearChildNeedsStyleRecalc(); |
| 203 } | 200 } |
| 204 | 201 |
| 205 bool ShadowRoot::isActive() const | 202 bool ShadowRoot::isActive() const |
| 206 { | 203 { |
| 207 for (ShadowRoot* shadowRoot = youngerShadowRoot(); shadowRoot; shadowRoot =
shadowRoot->youngerShadowRoot()) | 204 for (ShadowRoot* shadowRoot = youngerShadowRoot(); shadowRoot; shadowRoot =
shadowRoot->youngerShadowRoot()) |
| 208 if (!shadowRoot->containsShadowElements()) | 205 if (!shadowRoot->containsShadowElements()) |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 if (element->isInsertionPoint()) | 402 if (element->isInsertionPoint()) |
| 406 insertionPoints.append(toInsertionPoint(element)); | 403 insertionPoints.append(toInsertionPoint(element)); |
| 407 } | 404 } |
| 408 | 405 |
| 409 ensureShadowRootRareData()->setChildInsertionPoints(insertionPoints); | 406 ensureShadowRootRareData()->setChildInsertionPoints(insertionPoints); |
| 410 | 407 |
| 411 return m_shadowRootRareData->childInsertionPoints(); | 408 return m_shadowRootRareData->childInsertionPoints(); |
| 412 } | 409 } |
| 413 | 410 |
| 414 } | 411 } |
| OLD | NEW |