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" |
37 #include "core/dom/shadow/ElementShadow.h" | 38 #include "core/dom/shadow/ElementShadow.h" |
38 #include "core/dom/shadow/InsertionPoint.h" | 39 #include "core/dom/shadow/InsertionPoint.h" |
39 #include "core/dom/shadow/ShadowRootRareData.h" | 40 #include "core/dom/shadow/ShadowRootRareData.h" |
40 #include "core/editing/markup.h" | 41 #include "core/editing/markup.h" |
41 #include "core/platform/HistogramSupport.h" | 42 #include "core/platform/HistogramSupport.h" |
42 | 43 |
43 namespace WebCore { | 44 namespace WebCore { |
44 | 45 |
45 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public
DoublyLinkedListNode<ShadowRoot> { | 46 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope, public
DoublyLinkedListNode<ShadowRoot> { |
46 void* pointers[3]; | 47 void* pointers[3]; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 return; | 176 return; |
176 } | 177 } |
177 | 178 |
178 // When we're set to lazyAttach we'll have a SubtreeStyleChange and we'll ne
ed | 179 // When we're set to lazyAttach we'll have a SubtreeStyleChange and we'll ne
ed |
179 // to promote the change to a Force for all our descendants so they get a | 180 // to promote the change to a Force for all our descendants so they get a |
180 // recalc and will attach. | 181 // recalc and will attach. |
181 if (styleChangeType() >= SubtreeStyleChange) | 182 if (styleChangeType() >= SubtreeStyleChange) |
182 change = Force; | 183 change = Force; |
183 | 184 |
184 // FIXME: This doesn't handle :hover + div properly like Element::recalcStyl
e does. | 185 // FIXME: This doesn't handle :hover + div properly like Element::recalcStyl
e does. |
185 bool forceReattachOfAnyWhitespaceSibling = false; | 186 WhitespaceChildList whitespaceChildList(change); |
186 for (Node* child = firstChild(); child; child = child->nextSibling()) { | 187 for (Node* child = lastChild(); child; child = child->previousSibling()) { |
187 bool didReattach = false; | 188 if (child->isTextNode()) { |
| 189 Text* textChild = toText(child); |
| 190 if (textChild->containsOnlyWhitespace()) |
| 191 whitespaceChildList.append(textChild); |
| 192 else |
| 193 textChild->recalcTextStyle(change); |
| 194 } else if (child->isElementNode() && shouldRecalcStyle(change, child)) { |
| 195 toElement(child)->recalcStyle(change); |
| 196 } |
| 197 } |
188 | 198 |
189 if (child->renderer()) | 199 whitespaceChildList.recalcStyle(); |
190 forceReattachOfAnyWhitespaceSibling = false; | |
191 | |
192 if (child->isTextNode()) { | |
193 if (forceReattachOfAnyWhitespaceSibling && toText(child)->containsOn
lyWhitespace()) | |
194 child->reattach(); | |
195 else | |
196 didReattach = toText(child)->recalcTextStyle(change); | |
197 } else if (child->isElementNode() && shouldRecalcStyle(change, child)) { | |
198 didReattach = toElement(child)->recalcStyle(change); | |
199 } | |
200 | |
201 forceReattachOfAnyWhitespaceSibling = didReattach || forceReattachOfAnyW
hitespaceSibling; | |
202 } | |
203 | 200 |
204 styleResolver->popParentShadowRoot(*this); | 201 styleResolver->popParentShadowRoot(*this); |
205 clearNeedsStyleRecalc(); | 202 clearNeedsStyleRecalc(); |
206 clearChildNeedsStyleRecalc(); | 203 clearChildNeedsStyleRecalc(); |
207 } | 204 } |
208 | 205 |
209 bool ShadowRoot::isActive() const | 206 bool ShadowRoot::isActive() const |
210 { | 207 { |
211 for (ShadowRoot* shadowRoot = youngerShadowRoot(); shadowRoot; shadowRoot =
shadowRoot->youngerShadowRoot()) | 208 for (ShadowRoot* shadowRoot = youngerShadowRoot(); shadowRoot; shadowRoot =
shadowRoot->youngerShadowRoot()) |
212 if (!shadowRoot->containsShadowElements()) | 209 if (!shadowRoot->containsShadowElements()) |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 414 |
418 StyleSheetList* ShadowRoot::styleSheets() | 415 StyleSheetList* ShadowRoot::styleSheets() |
419 { | 416 { |
420 if (!ensureShadowRootRareData()->styleSheets()) | 417 if (!ensureShadowRootRareData()->styleSheets()) |
421 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); | 418 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); |
422 | 419 |
423 return m_shadowRootRareData->styleSheets(); | 420 return m_shadowRootRareData->styleSheets(); |
424 } | 421 } |
425 | 422 |
426 } | 423 } |
OLD | NEW |