| 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 16 matching lines...) Expand all Loading... |
| 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/StyleSheetList.h" | 32 #include "core/css/StyleSheetList.h" |
| 33 #include "core/css/resolver/StyleResolver.h" | 33 #include "core/css/resolver/StyleResolver.h" |
| 34 #include "core/dom/ElementTraversal.h" | 34 #include "core/dom/ElementTraversal.h" |
| 35 #include "core/dom/StyleEngine.h" | 35 #include "core/dom/StyleEngine.h" |
| 36 #include "core/dom/Text.h" | 36 #include "core/dom/Text.h" |
| 37 #include "core/dom/WhitespaceChildList.h" | |
| 38 #include "core/dom/shadow/ElementShadow.h" | 37 #include "core/dom/shadow/ElementShadow.h" |
| 39 #include "core/dom/shadow/InsertionPoint.h" | 38 #include "core/dom/shadow/InsertionPoint.h" |
| 40 #include "core/dom/shadow/ShadowRootRareData.h" | 39 #include "core/dom/shadow/ShadowRootRareData.h" |
| 41 #include "core/editing/markup.h" | 40 #include "core/editing/markup.h" |
| 42 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
| 43 | 42 |
| 44 namespace WebCore { | 43 namespace WebCore { |
| 45 | 44 |
| 46 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public
DoublyLinkedListNode<ShadowRoot> { | 45 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public
DoublyLinkedListNode<ShadowRoot> { |
| 47 void* pointers[3]; | 46 void* pointers[3]; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 StyleResolver* styleResolver = document().styleResolver(); | 170 StyleResolver* styleResolver = document().styleResolver(); |
| 172 styleResolver->pushParentShadowRoot(*this); | 171 styleResolver->pushParentShadowRoot(*this); |
| 173 | 172 |
| 174 // When we're set to lazyAttach we'll have a SubtreeStyleChange and we'll ne
ed | 173 // 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 | 174 // to promote the change to a Force for all our descendants so they get a |
| 176 // recalc and will attach. | 175 // recalc and will attach. |
| 177 if (styleChangeType() >= SubtreeStyleChange) | 176 if (styleChangeType() >= SubtreeStyleChange) |
| 178 change = Force; | 177 change = Force; |
| 179 | 178 |
| 180 // FIXME: This doesn't handle :hover + div properly like Element::recalcStyl
e does. | 179 // FIXME: This doesn't handle :hover + div properly like Element::recalcStyl
e does. |
| 181 WhitespaceChildList whitespaceChildList(change); | |
| 182 for (Node* child = lastChild(); child; child = child->previousSibling()) { | 180 for (Node* child = lastChild(); child; child = child->previousSibling()) { |
| 183 if (child->isTextNode()) { | 181 bool didReattach = false; |
| 184 Text* textChild = toText(child); | 182 if (child->isTextNode()) |
| 185 if (textChild->containsOnlyWhitespace()) | 183 didReattach = toText(child)->recalcTextStyle(change); |
| 186 whitespaceChildList.append(textChild); | 184 else if (child->isElementNode() && shouldRecalcStyle(change, child)) |
| 187 else | 185 didReattach = toElement(child)->recalcStyle(change); |
| 188 textChild->recalcTextStyle(change); | 186 |
| 189 } else if (child->isElementNode() && shouldRecalcStyle(change, child)) { | 187 if (didReattach) |
| 190 toElement(child)->recalcStyle(change); | 188 child->reattachWhitespaceSiblings(); |
| 191 } | |
| 192 } | 189 } |
| 193 | 190 |
| 194 whitespaceChildList.recalcStyle(); | |
| 195 | |
| 196 styleResolver->popParentShadowRoot(*this); | 191 styleResolver->popParentShadowRoot(*this); |
| 197 clearNeedsStyleRecalc(); | 192 clearNeedsStyleRecalc(); |
| 198 clearChildNeedsStyleRecalc(); | 193 clearChildNeedsStyleRecalc(); |
| 199 setAttached(); | 194 setAttached(); |
| 200 } | 195 } |
| 201 | 196 |
| 202 bool ShadowRoot::isActive() const | 197 bool ShadowRoot::isActive() const |
| 203 { | 198 { |
| 204 for (ShadowRoot* shadowRoot = youngerShadowRoot(); shadowRoot; shadowRoot =
shadowRoot->youngerShadowRoot()) | 199 for (ShadowRoot* shadowRoot = youngerShadowRoot(); shadowRoot; shadowRoot =
shadowRoot->youngerShadowRoot()) |
| 205 if (!shadowRoot->containsShadowElements()) | 200 if (!shadowRoot->containsShadowElements()) |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 405 |
| 411 StyleSheetList* ShadowRoot::styleSheets() | 406 StyleSheetList* ShadowRoot::styleSheets() |
| 412 { | 407 { |
| 413 if (!ensureShadowRootRareData()->styleSheets()) | 408 if (!ensureShadowRootRareData()->styleSheets()) |
| 414 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); | 409 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); |
| 415 | 410 |
| 416 return m_shadowRootRareData->styleSheets(); | 411 return m_shadowRootRareData->styleSheets(); |
| 417 } | 412 } |
| 418 | 413 |
| 419 } | 414 } |
| OLD | NEW |