| 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 13 matching lines...) Expand all Loading... |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 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/ExceptionState.h" | 30 #include "bindings/v8/ExceptionState.h" |
| 31 #include "core/css/StyleSheetList.h" | 31 #include "core/css/StyleSheetList.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/SiblingRuleHelper.h" | |
| 35 #include "core/dom/StyleEngine.h" | 34 #include "core/dom/StyleEngine.h" |
| 36 #include "core/dom/Text.h" | 35 #include "core/dom/Text.h" |
| 37 #include "core/dom/shadow/ElementShadow.h" | 36 #include "core/dom/shadow/ElementShadow.h" |
| 38 #include "core/dom/shadow/InsertionPoint.h" | 37 #include "core/dom/shadow/InsertionPoint.h" |
| 39 #include "core/dom/shadow/ShadowRootRareData.h" | 38 #include "core/dom/shadow/ShadowRootRareData.h" |
| 40 #include "core/editing/markup.h" | 39 #include "core/editing/markup.h" |
| 41 #include "core/html/HTMLShadowElement.h" | 40 #include "core/html/HTMLShadowElement.h" |
| 42 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
| 43 | 42 |
| 44 namespace WebCore { | 43 namespace WebCore { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 { | 139 { |
| 141 // ShadowRoot doesn't support custom callbacks. | 140 // ShadowRoot doesn't support custom callbacks. |
| 142 ASSERT(!hasCustomStyleCallbacks()); | 141 ASSERT(!hasCustomStyleCallbacks()); |
| 143 | 142 |
| 144 StyleResolver& styleResolver = document().ensureStyleResolver(); | 143 StyleResolver& styleResolver = document().ensureStyleResolver(); |
| 145 styleResolver.pushParentShadowRoot(*this); | 144 styleResolver.pushParentShadowRoot(*this); |
| 146 | 145 |
| 147 if (styleChangeType() >= SubtreeStyleChange) | 146 if (styleChangeType() >= SubtreeStyleChange) |
| 148 change = Force; | 147 change = Force; |
| 149 | 148 |
| 150 if (change < Force && childNeedsStyleRecalc()) | 149 if (change < Force && hasRareData() && childNeedsStyleRecalc()) |
| 151 SiblingRuleHelper(this).checkForChildrenAdjacentRuleChanges(); | 150 checkForChildrenAdjacentRuleChanges(); |
| 152 | 151 |
| 153 // There's no style to update so just calling recalcStyle means we're update
d. | 152 // There's no style to update so just calling recalcStyle means we're update
d. |
| 154 clearNeedsStyleRecalc(); | 153 clearNeedsStyleRecalc(); |
| 155 | 154 |
| 156 // FIXME: This doesn't handle :hover + div properly like Element::recalcStyl
e does. | 155 // FIXME: This doesn't handle :hover + div properly like Element::recalcStyl
e does. |
| 157 Text* lastTextNode = 0; | 156 Text* lastTextNode = 0; |
| 158 for (Node* child = lastChild(); child; child = child->previousSibling()) { | 157 for (Node* child = lastChild(); child; child = child->previousSibling()) { |
| 159 if (child->isTextNode()) { | 158 if (child->isTextNode()) { |
| 160 toText(child)->recalcTextStyle(change, lastTextNode); | 159 toText(child)->recalcTextStyle(change, lastTextNode); |
| 161 lastTextNode = toText(child); | 160 lastTextNode = toText(child); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 } | 375 } |
| 377 | 376 |
| 378 StyleSheetList* ShadowRoot::styleSheets() | 377 StyleSheetList* ShadowRoot::styleSheets() |
| 379 { | 378 { |
| 380 if (!ensureShadowRootRareData()->styleSheets()) | 379 if (!ensureShadowRootRareData()->styleSheets()) |
| 381 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); | 380 m_shadowRootRareData->setStyleSheets(StyleSheetList::create(this)); |
| 382 | 381 |
| 383 return m_shadowRootRareData->styleSheets(); | 382 return m_shadowRootRareData->styleSheets(); |
| 384 } | 383 } |
| 385 | 384 |
| 386 bool ShadowRoot::childrenSupportStyleSharing() const | |
| 387 { | |
| 388 if (!m_shadowRootRareData) | |
| 389 return false; | |
| 390 return !m_shadowRootRareData->childrenAffectedByFirstChildRules() | |
| 391 && !m_shadowRootRareData->childrenAffectedByLastChildRules() | |
| 392 && !m_shadowRootRareData->childrenAffectedByDirectAdjacentRules() | |
| 393 && !m_shadowRootRareData->childrenAffectedByIndirectAdjacentRules() | |
| 394 && !m_shadowRootRareData->childrenAffectedByForwardPositionalRules() | |
| 395 && !m_shadowRootRareData->childrenAffectedByBackwardPositionalRules(); | |
| 396 } | 385 } |
| 397 | |
| 398 bool ShadowRoot::childrenAffectedByPositionalRules() const | |
| 399 { | |
| 400 return m_shadowRootRareData && (m_shadowRootRareData->childrenAffectedByForw
ardPositionalRules() || m_shadowRootRareData->childrenAffectedByBackwardPosition
alRules()); | |
| 401 } | |
| 402 | |
| 403 bool ShadowRoot::childrenAffectedByFirstChildRules() const | |
| 404 { | |
| 405 return m_shadowRootRareData && m_shadowRootRareData->childrenAffectedByFirst
ChildRules(); | |
| 406 } | |
| 407 | |
| 408 bool ShadowRoot::childrenAffectedByLastChildRules() const | |
| 409 { | |
| 410 return m_shadowRootRareData && m_shadowRootRareData->childrenAffectedByLastC
hildRules(); | |
| 411 } | |
| 412 | |
| 413 bool ShadowRoot::childrenAffectedByDirectAdjacentRules() const | |
| 414 { | |
| 415 return m_shadowRootRareData && m_shadowRootRareData->childrenAffectedByDirec
tAdjacentRules(); | |
| 416 } | |
| 417 | |
| 418 bool ShadowRoot::childrenAffectedByIndirectAdjacentRules() const | |
| 419 { | |
| 420 return m_shadowRootRareData && m_shadowRootRareData->childrenAffectedByIndir
ectAdjacentRules(); | |
| 421 } | |
| 422 | |
| 423 bool ShadowRoot::childrenAffectedByForwardPositionalRules() const | |
| 424 { | |
| 425 return m_shadowRootRareData && m_shadowRootRareData->childrenAffectedByForwa
rdPositionalRules(); | |
| 426 } | |
| 427 | |
| 428 bool ShadowRoot::childrenAffectedByBackwardPositionalRules() const | |
| 429 { | |
| 430 return m_shadowRootRareData && m_shadowRootRareData->childrenAffectedByBackw
ardPositionalRules(); | |
| 431 } | |
| 432 | |
| 433 void ShadowRoot::setChildrenAffectedByForwardPositionalRules() | |
| 434 { | |
| 435 ensureShadowRootRareData()->setChildrenAffectedByForwardPositionalRules(true
); | |
| 436 } | |
| 437 | |
| 438 void ShadowRoot::setChildrenAffectedByDirectAdjacentRules() | |
| 439 { | |
| 440 ensureShadowRootRareData()->setChildrenAffectedByDirectAdjacentRules(true); | |
| 441 } | |
| 442 | |
| 443 void ShadowRoot::setChildrenAffectedByIndirectAdjacentRules() | |
| 444 { | |
| 445 ensureShadowRootRareData()->setChildrenAffectedByIndirectAdjacentRules(true)
; | |
| 446 } | |
| 447 | |
| 448 void ShadowRoot::setChildrenAffectedByBackwardPositionalRules() | |
| 449 { | |
| 450 ensureShadowRootRareData()->setChildrenAffectedByBackwardPositionalRules(tru
e); | |
| 451 } | |
| 452 | |
| 453 void ShadowRoot::setChildrenAffectedByFirstChildRules() | |
| 454 { | |
| 455 ensureShadowRootRareData()->setChildrenAffectedByFirstChildRules(true); | |
| 456 } | |
| 457 | |
| 458 void ShadowRoot::setChildrenAffectedByLastChildRules() | |
| 459 { | |
| 460 ensureShadowRootRareData()->setChildrenAffectedByLastChildRules(true); | |
| 461 } | |
| 462 | |
| 463 } | |
| OLD | NEW |