Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: Source/core/dom/shadow/ShadowRoot.cpp

Issue 58373002: Whitespace only text nodes need to be reattached when their siblings are reattached (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated js-test include Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/WhitespaceChildList.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 410
416 StyleSheetList* ShadowRoot::styleSheets() 411 StyleSheetList* ShadowRoot::styleSheets()
417 { 412 {
418 if (!ensureShadowRootRareData()->styleSheets()) 413 if (!ensureShadowRootRareData()->styleSheets())
419 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); 414 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this));
420 415
421 return m_shadowRootRareData->styleSheets(); 416 return m_shadowRootRareData->styleSheets();
422 } 417 }
423 418
424 } 419 }
OLDNEW
« no previous file with comments | « Source/core/dom/WhitespaceChildList.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698