OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Peter Kelly (pmk@post.com) | 4 * (C) 2001 Peter Kelly (pmk@post.com) |
5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
6 * (C) 2007 David Smith (catfish.man@gmail.com) | 6 * (C) 2007 David Smith (catfish.man@gmail.com) |
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. | 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
All rights reserved. |
8 * (C) 2007 Eric Seidel (eric@webkit.org) | 8 * (C) 2007 Eric Seidel (eric@webkit.org) |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #include "core/dom/MutationObserverInterestGroup.h" | 56 #include "core/dom/MutationObserverInterestGroup.h" |
57 #include "core/dom/MutationRecord.h" | 57 #include "core/dom/MutationRecord.h" |
58 #include "core/dom/NamedNodeMap.h" | 58 #include "core/dom/NamedNodeMap.h" |
59 #include "core/dom/NodeRenderStyle.h" | 59 #include "core/dom/NodeRenderStyle.h" |
60 #include "core/dom/PostAttachCallbacks.h" | 60 #include "core/dom/PostAttachCallbacks.h" |
61 #include "core/dom/PresentationAttributeStyle.h" | 61 #include "core/dom/PresentationAttributeStyle.h" |
62 #include "core/dom/PseudoElement.h" | 62 #include "core/dom/PseudoElement.h" |
63 #include "core/dom/RenderTreeBuilder.h" | 63 #include "core/dom/RenderTreeBuilder.h" |
64 #include "core/dom/ScriptableDocumentParser.h" | 64 #include "core/dom/ScriptableDocumentParser.h" |
65 #include "core/dom/SelectorQuery.h" | 65 #include "core/dom/SelectorQuery.h" |
66 #include "core/dom/SiblingRuleHelper.h" | |
67 #include "core/dom/Text.h" | 66 #include "core/dom/Text.h" |
68 #include "core/dom/custom/CustomElement.h" | 67 #include "core/dom/custom/CustomElement.h" |
69 #include "core/dom/custom/CustomElementRegistrationContext.h" | 68 #include "core/dom/custom/CustomElementRegistrationContext.h" |
70 #include "core/dom/shadow/InsertionPoint.h" | 69 #include "core/dom/shadow/InsertionPoint.h" |
71 #include "core/dom/shadow/ShadowRoot.h" | 70 #include "core/dom/shadow/ShadowRoot.h" |
72 #include "core/editing/FrameSelection.h" | 71 #include "core/editing/FrameSelection.h" |
73 #include "core/editing/TextIterator.h" | 72 #include "core/editing/TextIterator.h" |
74 #include "core/editing/htmlediting.h" | 73 #include "core/editing/htmlediting.h" |
75 #include "core/editing/markup.h" | 74 #include "core/editing/markup.h" |
76 #include "core/events/EventDispatcher.h" | 75 #include "core/events/EventDispatcher.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 return static_cast<ElementRareData*>(rareData()); | 222 return static_cast<ElementRareData*>(rareData()); |
224 } | 223 } |
225 | 224 |
226 inline ElementRareData& Element::ensureElementRareData() | 225 inline ElementRareData& Element::ensureElementRareData() |
227 { | 226 { |
228 return static_cast<ElementRareData&>(ensureRareData()); | 227 return static_cast<ElementRareData&>(ensureRareData()); |
229 } | 228 } |
230 | 229 |
231 bool Element::hasElementFlagInternal(ElementFlags mask) const | 230 bool Element::hasElementFlagInternal(ElementFlags mask) const |
232 { | 231 { |
233 ASSERT(hasRareData()); | 232 return elementRareData()->hasElementFlag(mask); |
234 return elementRareData()->hasFlag(mask); | |
235 } | 233 } |
236 | 234 |
237 void Element::setElementFlag(ElementFlags mask, bool value) | 235 void Element::setElementFlag(ElementFlags mask, bool value) |
238 { | 236 { |
239 if (!hasRareData() && !value) | 237 if (!hasRareData() && !value) |
240 return; | 238 return; |
241 ensureElementRareData().setFlag(mask, value); | 239 ensureElementRareData().setElementFlag(mask, value); |
242 } | 240 } |
243 | 241 |
244 void Element::clearElementFlag(ElementFlags mask) | 242 void Element::clearElementFlag(ElementFlags mask) |
245 { | 243 { |
246 if (!hasRareData()) | 244 if (!hasRareData()) |
247 return; | 245 return; |
248 elementRareData()->clearFlag(mask); | 246 elementRareData()->clearElementFlag(mask); |
249 } | 247 } |
250 | 248 |
251 void Element::clearTabIndexExplicitlyIfNeeded() | 249 void Element::clearTabIndexExplicitlyIfNeeded() |
252 { | 250 { |
253 if (hasRareData()) | 251 if (hasRareData()) |
254 elementRareData()->clearTabIndexExplicitly(); | 252 elementRareData()->clearTabIndexExplicitly(); |
255 } | 253 } |
256 | 254 |
257 void Element::setTabIndexExplicitly(short tabIndex) | 255 void Element::setTabIndexExplicitly(short tabIndex) |
258 { | 256 { |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 { | 1414 { |
1417 ASSERT(document().inStyleRecalc()); | 1415 ASSERT(document().inStyleRecalc()); |
1418 | 1416 |
1419 StyleResolverParentPusher parentPusher(*this); | 1417 StyleResolverParentPusher parentPusher(*this); |
1420 | 1418 |
1421 // We've already been through detach when doing an attach, but we might | 1419 // We've already been through detach when doing an attach, but we might |
1422 // need to clear any state that's been added since then. | 1420 // need to clear any state that's been added since then. |
1423 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { | 1421 if (hasRareData() && styleChangeType() == NeedsReattachStyleChange) { |
1424 ElementRareData* data = elementRareData(); | 1422 ElementRareData* data = elementRareData(); |
1425 data->clearComputedStyle(); | 1423 data->clearComputedStyle(); |
1426 data->resetDynamicRestyleObservations(); | 1424 data->clearRestyleFlags(); |
1427 // Only clear the style state if we're not going to reuse the style from
recalcStyle. | 1425 // Only clear the style state if we're not going to reuse the style from
recalcStyle. |
1428 if (!context.resolvedStyle) | 1426 if (!context.resolvedStyle) |
1429 data->resetStyleState(); | 1427 data->resetStyleState(); |
1430 } | 1428 } |
1431 | 1429 |
1432 RenderTreeBuilder(this, context.resolvedStyle).createRendererForElementIfNee
ded(); | 1430 RenderTreeBuilder(this, context.resolvedStyle).createRendererForElementIfNee
ded(); |
1433 | 1431 |
1434 addCallbackSelectors(); | 1432 addCallbackSelectors(); |
1435 | 1433 |
1436 createPseudoElementIfNeeded(BEFORE); | 1434 createPseudoElementIfNeeded(BEFORE); |
1437 | 1435 |
1438 // When a shadow root exists, it does the work of attaching the children. | 1436 // When a shadow root exists, it does the work of attaching the children. |
1439 if (ElementShadow* shadow = this->shadow()) { | 1437 if (ElementShadow* shadow = this->shadow()) { |
1440 parentPusher.push(); | 1438 parentPusher.push(); |
1441 shadow->attach(context); | 1439 shadow->attach(context); |
1442 } else if (firstChild()) { | 1440 } else if (firstChild()) { |
1443 parentPusher.push(); | 1441 parentPusher.push(); |
1444 } | 1442 } |
1445 | 1443 |
1446 ContainerNode::attach(context); | 1444 ContainerNode::attach(context); |
1447 | 1445 |
1448 createPseudoElementIfNeeded(AFTER); | 1446 createPseudoElementIfNeeded(AFTER); |
1449 createPseudoElementIfNeeded(BACKDROP); | 1447 createPseudoElementIfNeeded(BACKDROP); |
1450 | 1448 |
1451 if (hasRareData()) { | 1449 if (hasRareData()) { |
1452 ElementRareData* data = elementRareData(); | 1450 ElementRareData* data = elementRareData(); |
1453 if (data->hasFlag(NeedsFocusAppearanceUpdateSoonAfterAttach)) { | 1451 if (data->hasElementFlag(NeedsFocusAppearanceUpdateSoonAfterAttach)) { |
1454 if (isFocusable() && document().focusedElement() == this) | 1452 if (isFocusable() && document().focusedElement() == this) |
1455 document().updateFocusAppearanceSoon(false /* don't restore sele
ction */); | 1453 document().updateFocusAppearanceSoon(false /* don't restore sele
ction */); |
1456 data->clearFlag(NeedsFocusAppearanceUpdateSoonAfterAttach); | 1454 data->clearElementFlag(NeedsFocusAppearanceUpdateSoonAfterAttach); |
1457 } | 1455 } |
1458 if (!renderer()) { | 1456 if (!renderer()) { |
1459 if (ActiveAnimations* activeAnimations = data->activeAnimations()) { | 1457 if (ActiveAnimations* activeAnimations = data->activeAnimations()) { |
1460 activeAnimations->cssAnimations().cancel(); | 1458 activeAnimations->cssAnimations().cancel(); |
1461 activeAnimations->setAnimationStyleChange(false); | 1459 activeAnimations->setAnimationStyleChange(false); |
1462 } | 1460 } |
1463 } | 1461 } |
1464 } | 1462 } |
1465 | 1463 |
1466 InspectorInstrumentation::didRecalculateStyleForElement(this); | 1464 InspectorInstrumentation::didRecalculateStyleForElement(this); |
1467 } | 1465 } |
1468 | 1466 |
1469 void Element::detach(const AttachContext& context) | 1467 void Element::detach(const AttachContext& context) |
1470 { | 1468 { |
1471 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 1469 RenderWidget::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
1472 cancelFocusAppearanceUpdate(); | 1470 cancelFocusAppearanceUpdate(); |
1473 removeCallbackSelectors(); | 1471 removeCallbackSelectors(); |
1474 if (hasRareData()) { | 1472 if (hasRareData()) { |
1475 ElementRareData* data = elementRareData(); | 1473 ElementRareData* data = elementRareData(); |
1476 data->clearPseudoElements(); | 1474 data->clearPseudoElements(); |
1477 | 1475 |
1478 // attach() will perform the below steps for us when inside recalcStyle. | 1476 // attach() will perform the below steps for us when inside recalcStyle. |
1479 if (!document().inStyleRecalc()) { | 1477 if (!document().inStyleRecalc()) { |
1480 data->resetStyleState(); | 1478 data->resetStyleState(); |
1481 data->clearComputedStyle(); | 1479 data->clearComputedStyle(); |
1482 data->resetDynamicRestyleObservations(); | 1480 data->clearRestyleFlags(); |
1483 } | 1481 } |
1484 | 1482 |
1485 if (ActiveAnimations* activeAnimations = data->activeAnimations()) { | 1483 if (ActiveAnimations* activeAnimations = data->activeAnimations()) { |
1486 if (context.performingReattach) { | 1484 if (context.performingReattach) { |
1487 // FIXME: We call detach from withing style recalc, so compositi
ngState is not up to date. | 1485 // FIXME: We call detach from withing style recalc, so compositi
ngState is not up to date. |
1488 // https://code.google.com/p/chromium/issues/detail?id=339847 | 1486 // https://code.google.com/p/chromium/issues/detail?id=339847 |
1489 DisableCompositingQueryAsserts disabler; | 1487 DisableCompositingQueryAsserts disabler; |
1490 | 1488 |
1491 // FIXME: restart compositor animations rather than pull back to
the main thread | 1489 // FIXME: restart compositor animations rather than pull back to
the main thread |
1492 activeAnimations->cancelAnimationOnCompositor(); | 1490 activeAnimations->cancelAnimationOnCompositor(); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 if (root->shouldCallRecalcStyle(change)) { | 1672 if (root->shouldCallRecalcStyle(change)) { |
1675 parentPusher.push(); | 1673 parentPusher.push(); |
1676 root->recalcStyle(change); | 1674 root->recalcStyle(change); |
1677 } | 1675 } |
1678 } | 1676 } |
1679 } | 1677 } |
1680 | 1678 |
1681 updatePseudoElement(BEFORE, change); | 1679 updatePseudoElement(BEFORE, change); |
1682 | 1680 |
1683 if (change < Force && hasRareData() && childNeedsStyleRecalc()) | 1681 if (change < Force && hasRareData() && childNeedsStyleRecalc()) |
1684 SiblingRuleHelper(this).checkForChildrenAdjacentRuleChanges(); | 1682 checkForChildrenAdjacentRuleChanges(); |
1685 | 1683 |
1686 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { | 1684 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { |
1687 // This loop is deliberately backwards because we use insertBefore in th
e rendering tree, and want to avoid | 1685 // This loop is deliberately backwards because we use insertBefore in th
e rendering tree, and want to avoid |
1688 // a potentially n^2 loop to find the insertion point while resolving st
yle. Having us start from the last | 1686 // a potentially n^2 loop to find the insertion point while resolving st
yle. Having us start from the last |
1689 // child and work our way back means in the common case, we'll find the
insertion point in O(1) time. | 1687 // child and work our way back means in the common case, we'll find the
insertion point in O(1) time. |
1690 // See crbug.com/288225 | 1688 // See crbug.com/288225 |
1691 StyleResolver& styleResolver = document().ensureStyleResolver(); | 1689 StyleResolver& styleResolver = document().ensureStyleResolver(); |
1692 Text* lastTextNode = 0; | 1690 Text* lastTextNode = 0; |
1693 for (Node* child = lastChild(); child; child = child->previousSibling())
{ | 1691 for (Node* child = lastChild(); child; child = child->previousSibling())
{ |
1694 if (child->isTextNode()) { | 1692 if (child->isTextNode()) { |
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3421 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi
stItems | 3419 // Before doing so, we need to resolve issues in HTMLSelectElement::recalcLi
stItems |
3422 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg
i?id=88405 | 3420 // and RenderMenuList::setText. See also https://bugs.webkit.org/show_bug.cg
i?id=88405 |
3423 if (isHTMLOptionElement(*this) || isHTMLOptGroupElement(*this)) | 3421 if (isHTMLOptionElement(*this) || isHTMLOptGroupElement(*this)) |
3424 return false; | 3422 return false; |
3425 if (FullscreenElementStack::isActiveFullScreenElement(this)) | 3423 if (FullscreenElementStack::isActiveFullScreenElement(this)) |
3426 return false; | 3424 return false; |
3427 return true; | 3425 return true; |
3428 } | 3426 } |
3429 | 3427 |
3430 } // namespace WebCore | 3428 } // namespace WebCore |
OLD | NEW |