| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #include "core/dom/ElementDataCache.h" | 55 #include "core/dom/ElementDataCache.h" |
| 56 #include "core/dom/ElementRareData.h" | 56 #include "core/dom/ElementRareData.h" |
| 57 #include "core/dom/ElementTraversal.h" | 57 #include "core/dom/ElementTraversal.h" |
| 58 #include "core/dom/ExceptionCode.h" | 58 #include "core/dom/ExceptionCode.h" |
| 59 #include "core/dom/FirstLetterPseudoElement.h" | 59 #include "core/dom/FirstLetterPseudoElement.h" |
| 60 #include "core/dom/Fullscreen.h" | 60 #include "core/dom/Fullscreen.h" |
| 61 #include "core/dom/LayoutTreeBuilder.h" | 61 #include "core/dom/LayoutTreeBuilder.h" |
| 62 #include "core/dom/MutationObserverInterestGroup.h" | 62 #include "core/dom/MutationObserverInterestGroup.h" |
| 63 #include "core/dom/MutationRecord.h" | 63 #include "core/dom/MutationRecord.h" |
| 64 #include "core/dom/NamedNodeMap.h" | 64 #include "core/dom/NamedNodeMap.h" |
| 65 #include "core/dom/NodeLayoutStyle.h" | 65 #include "core/dom/NodeComputedStyle.h" |
| 66 #include "core/dom/PresentationAttributeStyle.h" | 66 #include "core/dom/PresentationAttributeStyle.h" |
| 67 #include "core/dom/PseudoElement.h" | 67 #include "core/dom/PseudoElement.h" |
| 68 #include "core/dom/ScriptableDocumentParser.h" | 68 #include "core/dom/ScriptableDocumentParser.h" |
| 69 #include "core/dom/SelectorQuery.h" | 69 #include "core/dom/SelectorQuery.h" |
| 70 #include "core/dom/StyleChangeReason.h" | 70 #include "core/dom/StyleChangeReason.h" |
| 71 #include "core/dom/StyleEngine.h" | 71 #include "core/dom/StyleEngine.h" |
| 72 #include "core/dom/Text.h" | 72 #include "core/dom/Text.h" |
| 73 #include "core/dom/custom/CustomElement.h" | 73 #include "core/dom/custom/CustomElement.h" |
| 74 #include "core/dom/custom/CustomElementRegistrationContext.h" | 74 #include "core/dom/custom/CustomElementRegistrationContext.h" |
| 75 #include "core/dom/shadow/InsertionPoint.h" | 75 #include "core/dom/shadow/InsertionPoint.h" |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 // other, this bookkeeping remains accurate. | 551 // other, this bookkeeping remains accurate. |
| 552 scrollState.setCurrentNativeScrollingElement(this); | 552 scrollState.setCurrentNativeScrollingElement(this); |
| 553 if (scrollState.fromUserInput()) | 553 if (scrollState.fromUserInput()) |
| 554 document().frame()->view()->setWasScrolledByUser(true); | 554 document().frame()->view()->setWasScrolledByUser(true); |
| 555 }; | 555 }; |
| 556 | 556 |
| 557 static float localZoomForRenderer(LayoutObject& renderer) | 557 static float localZoomForRenderer(LayoutObject& renderer) |
| 558 { | 558 { |
| 559 // FIXME: This does the wrong thing if two opposing zooms are in effect and
canceled each | 559 // FIXME: This does the wrong thing if two opposing zooms are in effect and
canceled each |
| 560 // other out, but the alternative is that we'd have to crawl up the whole re
nder tree every | 560 // other out, but the alternative is that we'd have to crawl up the whole re
nder tree every |
| 561 // time (or store an additional bit in the LayoutStyle to indicate that a zo
om was specified). | 561 // time (or store an additional bit in the ComputedStyle to indicate that a
zoom was specified). |
| 562 float zoomFactor = 1; | 562 float zoomFactor = 1; |
| 563 if (renderer.style()->effectiveZoom() != 1) { | 563 if (renderer.style()->effectiveZoom() != 1) { |
| 564 // Need to find the nearest enclosing LayoutObject that set up | 564 // Need to find the nearest enclosing LayoutObject that set up |
| 565 // a differing zoom, and then we divide our result by it to eliminate th
e zoom. | 565 // a differing zoom, and then we divide our result by it to eliminate th
e zoom. |
| 566 LayoutObject* prev = &renderer; | 566 LayoutObject* prev = &renderer; |
| 567 for (LayoutObject* curr = prev->parent(); curr; curr = curr->parent()) { | 567 for (LayoutObject* curr = prev->parent(); curr; curr = curr->parent()) { |
| 568 if (curr->style()->effectiveZoom() != prev->style()->effectiveZoom()
) { | 568 if (curr->style()->effectiveZoom() != prev->style()->effectiveZoom()
) { |
| 569 zoomFactor = prev->style()->zoom(); | 569 zoomFactor = prev->style()->zoom(); |
| 570 break; | 570 break; |
| 571 } | 571 } |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 return base; | 1384 return base; |
| 1385 | 1385 |
| 1386 return KURL(parentBase, baseAttribute); | 1386 return KURL(parentBase, baseAttribute); |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 const AtomicString Element::imageSourceURL() const | 1389 const AtomicString Element::imageSourceURL() const |
| 1390 { | 1390 { |
| 1391 return getAttribute(srcAttr); | 1391 return getAttribute(srcAttr); |
| 1392 } | 1392 } |
| 1393 | 1393 |
| 1394 bool Element::layoutObjectIsNeeded(const LayoutStyle& style) | 1394 bool Element::layoutObjectIsNeeded(const ComputedStyle& style) |
| 1395 { | 1395 { |
| 1396 return style.display() != NONE; | 1396 return style.display() != NONE; |
| 1397 } | 1397 } |
| 1398 | 1398 |
| 1399 LayoutObject* Element::createLayoutObject(const LayoutStyle& style) | 1399 LayoutObject* Element::createLayoutObject(const ComputedStyle& style) |
| 1400 { | 1400 { |
| 1401 return LayoutObject::createObject(this, style); | 1401 return LayoutObject::createObject(this, style); |
| 1402 } | 1402 } |
| 1403 | 1403 |
| 1404 Node::InsertionNotificationRequest Element::insertedInto(ContainerNode* insertio
nPoint) | 1404 Node::InsertionNotificationRequest Element::insertedInto(ContainerNode* insertio
nPoint) |
| 1405 { | 1405 { |
| 1406 // need to do superclass processing first so inDocument() is true | 1406 // need to do superclass processing first so inDocument() is true |
| 1407 // by the time we reach updateId | 1407 // by the time we reach updateId |
| 1408 ContainerNode::insertedInto(insertionPoint); | 1408 ContainerNode::insertedInto(insertionPoint); |
| 1409 | 1409 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1547 // FIXME: We call detach from within style recalc, so compositin
gState is not up to date. | 1547 // FIXME: We call detach from within style recalc, so compositin
gState is not up to date. |
| 1548 // https://code.google.com/p/chromium/issues/detail?id=339847 | 1548 // https://code.google.com/p/chromium/issues/detail?id=339847 |
| 1549 DisableCompositingQueryAsserts disabler; | 1549 DisableCompositingQueryAsserts disabler; |
| 1550 | 1550 |
| 1551 // FIXME: restart compositor animations rather than pull back to
the main thread | 1551 // FIXME: restart compositor animations rather than pull back to
the main thread |
| 1552 elementAnimations->restartAnimationOnCompositor(); | 1552 elementAnimations->restartAnimationOnCompositor(); |
| 1553 } else { | 1553 } else { |
| 1554 elementAnimations->cssAnimations().cancel(); | 1554 elementAnimations->cssAnimations().cancel(); |
| 1555 elementAnimations->setAnimationStyleChange(false); | 1555 elementAnimations->setAnimationStyleChange(false); |
| 1556 } | 1556 } |
| 1557 elementAnimations->clearBaseLayoutStyle(); | 1557 elementAnimations->clearBaseComputedStyle(); |
| 1558 } | 1558 } |
| 1559 | 1559 |
| 1560 if (ElementShadow* shadow = data->shadow()) | 1560 if (ElementShadow* shadow = data->shadow()) |
| 1561 shadow->detach(context); | 1561 shadow->detach(context); |
| 1562 } | 1562 } |
| 1563 | 1563 |
| 1564 ContainerNode::detach(context); | 1564 ContainerNode::detach(context); |
| 1565 | 1565 |
| 1566 ASSERT(needsAttach()); | 1566 ASSERT(needsAttach()); |
| 1567 if (svgFilterNeedsLayerUpdate()) | 1567 if (svgFilterNeedsLayerUpdate()) |
| 1568 document().unscheduleSVGFilterLayerUpdateHack(*this); | 1568 document().unscheduleSVGFilterLayerUpdateHack(*this); |
| 1569 } | 1569 } |
| 1570 | 1570 |
| 1571 bool Element::pseudoStyleCacheIsInvalid(const LayoutStyle* currentStyle, LayoutS
tyle* newStyle) | 1571 bool Element::pseudoStyleCacheIsInvalid(const ComputedStyle* currentStyle, Compu
tedStyle* newStyle) |
| 1572 { | 1572 { |
| 1573 ASSERT(currentStyle == layoutStyle()); | 1573 ASSERT(currentStyle == computedStyle()); |
| 1574 ASSERT(layoutObject()); | 1574 ASSERT(layoutObject()); |
| 1575 | 1575 |
| 1576 if (!currentStyle) | 1576 if (!currentStyle) |
| 1577 return false; | 1577 return false; |
| 1578 | 1578 |
| 1579 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles(
); | 1579 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles(
); |
| 1580 if (!pseudoStyleCache) | 1580 if (!pseudoStyleCache) |
| 1581 return false; | 1581 return false; |
| 1582 | 1582 |
| 1583 size_t cacheSize = pseudoStyleCache->size(); | 1583 size_t cacheSize = pseudoStyleCache->size(); |
| 1584 for (size_t i = 0; i < cacheSize; ++i) { | 1584 for (size_t i = 0; i < cacheSize; ++i) { |
| 1585 RefPtr<LayoutStyle> newPseudoStyle; | 1585 RefPtr<ComputedStyle> newPseudoStyle; |
| 1586 PseudoId pseudoId = pseudoStyleCache->at(i)->styleType(); | 1586 PseudoId pseudoId = pseudoStyleCache->at(i)->styleType(); |
| 1587 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) | 1587 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) |
| 1588 newPseudoStyle = layoutObject()->uncachedFirstLineStyle(newStyle); | 1588 newPseudoStyle = layoutObject()->uncachedFirstLineStyle(newStyle); |
| 1589 else | 1589 else |
| 1590 newPseudoStyle = layoutObject()->getUncachedPseudoStyle(PseudoStyleR
equest(pseudoId), newStyle, newStyle); | 1590 newPseudoStyle = layoutObject()->getUncachedPseudoStyle(PseudoStyleR
equest(pseudoId), newStyle, newStyle); |
| 1591 if (!newPseudoStyle) | 1591 if (!newPseudoStyle) |
| 1592 return true; | 1592 return true; |
| 1593 if (*newPseudoStyle != *pseudoStyleCache->at(i)) { | 1593 if (*newPseudoStyle != *pseudoStyleCache->at(i)) { |
| 1594 if (pseudoId < FIRST_INTERNAL_PSEUDOID) | 1594 if (pseudoId < FIRST_INTERNAL_PSEUDOID) |
| 1595 newStyle->setHasPseudoStyle(pseudoId); | 1595 newStyle->setHasPseudoStyle(pseudoId); |
| 1596 newStyle->addCachedPseudoStyle(newPseudoStyle); | 1596 newStyle->addCachedPseudoStyle(newPseudoStyle); |
| 1597 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) { | 1597 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) { |
| 1598 // FIXME: We should do an actual diff to determine whether a rep
aint vs. layout | 1598 // FIXME: We should do an actual diff to determine whether a rep
aint vs. layout |
| 1599 // is needed, but for now just assume a layout will be required.
The diff code | 1599 // is needed, but for now just assume a layout will be required.
The diff code |
| 1600 // in LayoutObject::setStyle would need to be factored out so th
at it could be reused. | 1600 // in LayoutObject::setStyle would need to be factored out so th
at it could be reused. |
| 1601 layoutObject()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInv
alidation(); | 1601 layoutObject()->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInv
alidation(); |
| 1602 } | 1602 } |
| 1603 return true; | 1603 return true; |
| 1604 } | 1604 } |
| 1605 } | 1605 } |
| 1606 return false; | 1606 return false; |
| 1607 } | 1607 } |
| 1608 | 1608 |
| 1609 PassRefPtr<LayoutStyle> Element::styleForLayoutObject() | 1609 PassRefPtr<ComputedStyle> Element::styleForLayoutObject() |
| 1610 { | 1610 { |
| 1611 ASSERT(document().inStyleRecalc()); | 1611 ASSERT(document().inStyleRecalc()); |
| 1612 | 1612 |
| 1613 RefPtr<LayoutStyle> style; | 1613 RefPtr<ComputedStyle> style; |
| 1614 | 1614 |
| 1615 // FIXME: Instead of clearing updates that may have been added from calls to
styleForElement | 1615 // FIXME: Instead of clearing updates that may have been added from calls to
styleForElement |
| 1616 // outside recalcStyle, we should just never set them if we're not inside re
calcStyle. | 1616 // outside recalcStyle, we should just never set them if we're not inside re
calcStyle. |
| 1617 if (ElementAnimations* elementAnimations = this->elementAnimations()) | 1617 if (ElementAnimations* elementAnimations = this->elementAnimations()) |
| 1618 elementAnimations->cssAnimations().setPendingUpdate(nullptr); | 1618 elementAnimations->cssAnimations().setPendingUpdate(nullptr); |
| 1619 | 1619 |
| 1620 if (hasCustomStyleCallbacks()) | 1620 if (hasCustomStyleCallbacks()) |
| 1621 style = customStyleForLayoutObject(); | 1621 style = customStyleForLayoutObject(); |
| 1622 if (!style) | 1622 if (!style) |
| 1623 style = originalStyleForLayoutObject(); | 1623 style = originalStyleForLayoutObject(); |
| 1624 ASSERT(style); | 1624 ASSERT(style); |
| 1625 | 1625 |
| 1626 // styleForElement() might add active animations so we need to get it again. | 1626 // styleForElement() might add active animations so we need to get it again. |
| 1627 if (ElementAnimations* elementAnimations = this->elementAnimations()) { | 1627 if (ElementAnimations* elementAnimations = this->elementAnimations()) { |
| 1628 elementAnimations->cssAnimations().maybeApplyPendingUpdate(this); | 1628 elementAnimations->cssAnimations().maybeApplyPendingUpdate(this); |
| 1629 elementAnimations->updateAnimationFlags(*style); | 1629 elementAnimations->updateAnimationFlags(*style); |
| 1630 } | 1630 } |
| 1631 | 1631 |
| 1632 if (style->hasTransform()) { | 1632 if (style->hasTransform()) { |
| 1633 if (const StylePropertySet* inlineStyle = this->inlineStyle()) | 1633 if (const StylePropertySet* inlineStyle = this->inlineStyle()) |
| 1634 style->setHasInlineTransform(inlineStyle->hasProperty(CSSPropertyTra
nsform) || inlineStyle->hasProperty(CSSPropertyWebkitTransform)); | 1634 style->setHasInlineTransform(inlineStyle->hasProperty(CSSPropertyTra
nsform) || inlineStyle->hasProperty(CSSPropertyWebkitTransform)); |
| 1635 } | 1635 } |
| 1636 | 1636 |
| 1637 document().didRecalculateStyleForElement(); | 1637 document().didRecalculateStyleForElement(); |
| 1638 return style.release(); | 1638 return style.release(); |
| 1639 } | 1639 } |
| 1640 | 1640 |
| 1641 PassRefPtr<LayoutStyle> Element::originalStyleForLayoutObject() | 1641 PassRefPtr<ComputedStyle> Element::originalStyleForLayoutObject() |
| 1642 { | 1642 { |
| 1643 ASSERT(document().inStyleRecalc()); | 1643 ASSERT(document().inStyleRecalc()); |
| 1644 return document().ensureStyleResolver().styleForElement(this); | 1644 return document().ensureStyleResolver().styleForElement(this); |
| 1645 } | 1645 } |
| 1646 | 1646 |
| 1647 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) | 1647 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) |
| 1648 { | 1648 { |
| 1649 ASSERT(document().inStyleRecalc()); | 1649 ASSERT(document().inStyleRecalc()); |
| 1650 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); | 1650 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); |
| 1651 ASSERT(inActiveDocument()); | 1651 ASSERT(inActiveDocument()); |
| 1652 | 1652 |
| 1653 if (hasCustomStyleCallbacks()) | 1653 if (hasCustomStyleCallbacks()) |
| 1654 willRecalcStyle(change); | 1654 willRecalcStyle(change); |
| 1655 | 1655 |
| 1656 if (change >= Inherit || needsStyleRecalc()) { | 1656 if (change >= Inherit || needsStyleRecalc()) { |
| 1657 if (hasRareData()) { | 1657 if (hasRareData()) { |
| 1658 ElementRareData* data = elementRareData(); | 1658 ElementRareData* data = elementRareData(); |
| 1659 data->clearComputedStyle(); | 1659 data->clearComputedStyle(); |
| 1660 | 1660 |
| 1661 if (change >= Inherit) { | 1661 if (change >= Inherit) { |
| 1662 if (ElementAnimations* elementAnimations = data->elementAnimatio
ns()) | 1662 if (ElementAnimations* elementAnimations = data->elementAnimatio
ns()) |
| 1663 elementAnimations->setAnimationStyleChange(false); | 1663 elementAnimations->setAnimationStyleChange(false); |
| 1664 } | 1664 } |
| 1665 } | 1665 } |
| 1666 if (parentLayoutStyle()) | 1666 if (parentComputedStyle()) |
| 1667 change = recalcOwnStyle(change); | 1667 change = recalcOwnStyle(change); |
| 1668 clearNeedsStyleRecalc(); | 1668 clearNeedsStyleRecalc(); |
| 1669 } | 1669 } |
| 1670 | 1670 |
| 1671 // If we reattached we don't need to recalc the style of our descendants any
more. | 1671 // If we reattached we don't need to recalc the style of our descendants any
more. |
| 1672 if ((change >= UpdatePseudoElements && change < Reattach) || childNeedsStyle
Recalc()) { | 1672 if ((change >= UpdatePseudoElements && change < Reattach) || childNeedsStyle
Recalc()) { |
| 1673 StyleResolverParentScope parentScope(*this); | 1673 StyleResolverParentScope parentScope(*this); |
| 1674 | 1674 |
| 1675 updatePseudoElement(BEFORE, change); | 1675 updatePseudoElement(BEFORE, change); |
| 1676 | 1676 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1699 | 1699 |
| 1700 if (change == Reattach) | 1700 if (change == Reattach) |
| 1701 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); | 1701 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); |
| 1702 } | 1702 } |
| 1703 | 1703 |
| 1704 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) | 1704 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) |
| 1705 { | 1705 { |
| 1706 ASSERT(document().inStyleRecalc()); | 1706 ASSERT(document().inStyleRecalc()); |
| 1707 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); | 1707 ASSERT(!parentOrShadowHostNode()->needsStyleRecalc()); |
| 1708 ASSERT(change >= Inherit || needsStyleRecalc()); | 1708 ASSERT(change >= Inherit || needsStyleRecalc()); |
| 1709 ASSERT(parentLayoutStyle()); | 1709 ASSERT(parentComputedStyle()); |
| 1710 | 1710 |
| 1711 RefPtr<LayoutStyle> oldStyle = mutableLayoutStyle(); | 1711 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); |
| 1712 RefPtr<LayoutStyle> newStyle = styleForLayoutObject(); | 1712 RefPtr<ComputedStyle> newStyle = styleForLayoutObject(); |
| 1713 StyleRecalcChange localChange = LayoutStyle::stylePropagationDiff(oldStyle.g
et(), newStyle.get()); | 1713 StyleRecalcChange localChange = ComputedStyle::stylePropagationDiff(oldStyle
.get(), newStyle.get()); |
| 1714 | 1714 |
| 1715 ASSERT(newStyle); | 1715 ASSERT(newStyle); |
| 1716 | 1716 |
| 1717 if (localChange == Reattach) { | 1717 if (localChange == Reattach) { |
| 1718 AttachContext reattachContext; | 1718 AttachContext reattachContext; |
| 1719 reattachContext.resolvedStyle = newStyle.get(); | 1719 reattachContext.resolvedStyle = newStyle.get(); |
| 1720 bool rendererWillChange = needsAttach() || layoutObject(); | 1720 bool rendererWillChange = needsAttach() || layoutObject(); |
| 1721 reattach(reattachContext); | 1721 reattach(reattachContext); |
| 1722 if (rendererWillChange || layoutObject()) | 1722 if (rendererWillChange || layoutObject()) |
| 1723 return Reattach; | 1723 return Reattach; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1746 | 1746 |
| 1747 if (change > Inherit || localChange > Inherit) | 1747 if (change > Inherit || localChange > Inherit) |
| 1748 return max(localChange, change); | 1748 return max(localChange, change); |
| 1749 | 1749 |
| 1750 if (localChange < Inherit && (oldStyle->hasPseudoElementStyle() || newStyle-
>hasPseudoElementStyle())) | 1750 if (localChange < Inherit && (oldStyle->hasPseudoElementStyle() || newStyle-
>hasPseudoElementStyle())) |
| 1751 return UpdatePseudoElements; | 1751 return UpdatePseudoElements; |
| 1752 | 1752 |
| 1753 return localChange; | 1753 return localChange; |
| 1754 } | 1754 } |
| 1755 | 1755 |
| 1756 void Element::updateCallbackSelectors(const LayoutStyle* oldStyle, const LayoutS
tyle* newStyle) | 1756 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, const Compu
tedStyle* newStyle) |
| 1757 { | 1757 { |
| 1758 Vector<String> emptyVector; | 1758 Vector<String> emptyVector; |
| 1759 const Vector<String>& oldCallbackSelectors = oldStyle ? oldStyle->callbackSe
lectors() : emptyVector; | 1759 const Vector<String>& oldCallbackSelectors = oldStyle ? oldStyle->callbackSe
lectors() : emptyVector; |
| 1760 const Vector<String>& newCallbackSelectors = newStyle ? newStyle->callbackSe
lectors() : emptyVector; | 1760 const Vector<String>& newCallbackSelectors = newStyle ? newStyle->callbackSe
lectors() : emptyVector; |
| 1761 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) | 1761 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) |
| 1762 return; | 1762 return; |
| 1763 if (oldCallbackSelectors != newCallbackSelectors) | 1763 if (oldCallbackSelectors != newCallbackSelectors) |
| 1764 CSSSelectorWatch::from(document()).updateSelectorMatches(oldCallbackSele
ctors, newCallbackSelectors); | 1764 CSSSelectorWatch::from(document()).updateSelectorMatches(oldCallbackSele
ctors, newCallbackSelectors); |
| 1765 } | 1765 } |
| 1766 | 1766 |
| 1767 void Element::addCallbackSelectors() | 1767 void Element::addCallbackSelectors() |
| 1768 { | 1768 { |
| 1769 updateCallbackSelectors(0, layoutStyle()); | 1769 updateCallbackSelectors(0, computedStyle()); |
| 1770 } | 1770 } |
| 1771 | 1771 |
| 1772 void Element::removeCallbackSelectors() | 1772 void Element::removeCallbackSelectors() |
| 1773 { | 1773 { |
| 1774 updateCallbackSelectors(layoutStyle(), 0); | 1774 updateCallbackSelectors(computedStyle(), 0); |
| 1775 } | 1775 } |
| 1776 | 1776 |
| 1777 ElementShadow* Element::shadow() const | 1777 ElementShadow* Element::shadow() const |
| 1778 { | 1778 { |
| 1779 return hasRareData() ? elementRareData()->shadow() : nullptr; | 1779 return hasRareData() ? elementRareData()->shadow() : nullptr; |
| 1780 } | 1780 } |
| 1781 | 1781 |
| 1782 ElementShadow& Element::ensureShadow() | 1782 ElementShadow& Element::ensureShadow() |
| 1783 { | 1783 { |
| 1784 return ensureElementRareData().ensureShadow(); | 1784 return ensureElementRareData().ensureShadow(); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 case CDATA_SECTION_NODE: | 1913 case CDATA_SECTION_NODE: |
| 1914 return true; | 1914 return true; |
| 1915 default: | 1915 default: |
| 1916 break; | 1916 break; |
| 1917 } | 1917 } |
| 1918 return false; | 1918 return false; |
| 1919 } | 1919 } |
| 1920 | 1920 |
| 1921 void Element::checkForEmptyStyleChange() | 1921 void Element::checkForEmptyStyleChange() |
| 1922 { | 1922 { |
| 1923 const LayoutStyle* style = layoutStyle(); | 1923 const ComputedStyle* style = computedStyle(); |
| 1924 | 1924 |
| 1925 if (!style && !styleAffectedByEmpty()) | 1925 if (!style && !styleAffectedByEmpty()) |
| 1926 return; | 1926 return; |
| 1927 if (styleChangeType() >= SubtreeStyleChange) | 1927 if (styleChangeType() >= SubtreeStyleChange) |
| 1928 return; | 1928 return; |
| 1929 if (!inActiveDocument()) | 1929 if (!inActiveDocument()) |
| 1930 return; | 1930 return; |
| 1931 if (!document().styleResolver()) | 1931 if (!document().styleResolver()) |
| 1932 return; | 1932 return; |
| 1933 | 1933 |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2591 return hasRareData() ? elementRareData()->minimumSizeForResizing() : default
MinimumSizeForResizing(); | 2591 return hasRareData() ? elementRareData()->minimumSizeForResizing() : default
MinimumSizeForResizing(); |
| 2592 } | 2592 } |
| 2593 | 2593 |
| 2594 void Element::setMinimumSizeForResizing(const LayoutSize& size) | 2594 void Element::setMinimumSizeForResizing(const LayoutSize& size) |
| 2595 { | 2595 { |
| 2596 if (!hasRareData() && size == defaultMinimumSizeForResizing()) | 2596 if (!hasRareData() && size == defaultMinimumSizeForResizing()) |
| 2597 return; | 2597 return; |
| 2598 ensureElementRareData().setMinimumSizeForResizing(size); | 2598 ensureElementRareData().setMinimumSizeForResizing(size); |
| 2599 } | 2599 } |
| 2600 | 2600 |
| 2601 const LayoutStyle* Element::computedStyle(PseudoId pseudoElementSpecifier) | 2601 const ComputedStyle* Element::ensureComputedStyle(PseudoId pseudoElementSpecifie
r) |
| 2602 { | 2602 { |
| 2603 if (PseudoElement* element = pseudoElement(pseudoElementSpecifier)) | 2603 if (PseudoElement* element = pseudoElement(pseudoElementSpecifier)) |
| 2604 return element->computedStyle(); | 2604 return element->ensureComputedStyle(); |
| 2605 | 2605 |
| 2606 if (!inActiveDocument()) { | 2606 if (!inActiveDocument()) { |
| 2607 // FIXME: Try to do better than this. Ensure that styleForElement() work
s for elements that are not in the | 2607 // FIXME: Try to do better than this. Ensure that styleForElement() work
s for elements that are not in the |
| 2608 // document tree and figure out when to destroy the computed style for s
uch elements. | 2608 // document tree and figure out when to destroy the computed style for s
uch elements. |
| 2609 return nullptr; | 2609 return nullptr; |
| 2610 } | 2610 } |
| 2611 | 2611 |
| 2612 // FIXME: Find and use the renderer from the pseudo element instead of the a
ctual element so that the 'length' | 2612 // FIXME: Find and use the renderer from the pseudo element instead of the a
ctual element so that the 'length' |
| 2613 // properties, which are only known by the renderer because it did the layou
t, will be correct and so that the | 2613 // properties, which are only known by the renderer because it did the layou
t, will be correct and so that the |
| 2614 // values returned for the ":selection" pseudo-element will be correct. | 2614 // values returned for the ":selection" pseudo-element will be correct. |
| 2615 LayoutStyle* elementStyle = mutableLayoutStyle(); | 2615 ComputedStyle* elementStyle = mutableComputedStyle(); |
| 2616 if (!elementStyle) { | 2616 if (!elementStyle) { |
| 2617 ElementRareData& rareData = ensureElementRareData(); | 2617 ElementRareData& rareData = ensureElementRareData(); |
| 2618 if (!rareData.computedStyle()) | 2618 if (!rareData.ensureComputedStyle()) |
| 2619 rareData.setComputedStyle(document().styleForElementIgnoringPendingS
tylesheets(this)); | 2619 rareData.setComputedStyle(document().styleForElementIgnoringPendingS
tylesheets(this)); |
| 2620 elementStyle = rareData.computedStyle(); | 2620 elementStyle = rareData.ensureComputedStyle(); |
| 2621 } | 2621 } |
| 2622 | 2622 |
| 2623 if (!pseudoElementSpecifier) | 2623 if (!pseudoElementSpecifier) |
| 2624 return elementStyle; | 2624 return elementStyle; |
| 2625 | 2625 |
| 2626 if (LayoutStyle* pseudoElementStyle = elementStyle->getCachedPseudoStyle(pse
udoElementSpecifier)) | 2626 if (ComputedStyle* pseudoElementStyle = elementStyle->getCachedPseudoStyle(p
seudoElementSpecifier)) |
| 2627 return pseudoElementStyle; | 2627 return pseudoElementStyle; |
| 2628 | 2628 |
| 2629 RefPtr<LayoutStyle> result = document().ensureStyleResolver().pseudoStyleFor
Element(this, PseudoStyleRequest(pseudoElementSpecifier, PseudoStyleRequest::For
ComputedStyle), elementStyle); | 2629 RefPtr<ComputedStyle> result = document().ensureStyleResolver().pseudoStyleF
orElement(this, PseudoStyleRequest(pseudoElementSpecifier, PseudoStyleRequest::F
orComputedStyle), elementStyle); |
| 2630 ASSERT(result); | 2630 ASSERT(result); |
| 2631 return elementStyle->addCachedPseudoStyle(result.release()); | 2631 return elementStyle->addCachedPseudoStyle(result.release()); |
| 2632 } | 2632 } |
| 2633 | 2633 |
| 2634 AtomicString Element::computeInheritedLanguage() const | 2634 AtomicString Element::computeInheritedLanguage() const |
| 2635 { | 2635 { |
| 2636 const Node* n = this; | 2636 const Node* n = this; |
| 2637 AtomicString value; | 2637 AtomicString value; |
| 2638 // The language property is inherited, so we iterate over the parents to fin
d the first language. | 2638 // The language property is inherited, so we iterate over the parents to fin
d the first language. |
| 2639 do { | 2639 do { |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3175 { | 3175 { |
| 3176 ASSERT(hasCustomStyleCallbacks()); | 3176 ASSERT(hasCustomStyleCallbacks()); |
| 3177 } | 3177 } |
| 3178 | 3178 |
| 3179 void Element::didRecalcStyle(StyleRecalcChange) | 3179 void Element::didRecalcStyle(StyleRecalcChange) |
| 3180 { | 3180 { |
| 3181 ASSERT(hasCustomStyleCallbacks()); | 3181 ASSERT(hasCustomStyleCallbacks()); |
| 3182 } | 3182 } |
| 3183 | 3183 |
| 3184 | 3184 |
| 3185 PassRefPtr<LayoutStyle> Element::customStyleForLayoutObject() | 3185 PassRefPtr<ComputedStyle> Element::customStyleForLayoutObject() |
| 3186 { | 3186 { |
| 3187 ASSERT(hasCustomStyleCallbacks()); | 3187 ASSERT(hasCustomStyleCallbacks()); |
| 3188 return nullptr; | 3188 return nullptr; |
| 3189 } | 3189 } |
| 3190 | 3190 |
| 3191 void Element::cloneAttributesFromElement(const Element& other) | 3191 void Element::cloneAttributesFromElement(const Element& other) |
| 3192 { | 3192 { |
| 3193 if (hasSyntheticAttrChildNodes()) | 3193 if (hasSyntheticAttrChildNodes()) |
| 3194 detachAllAttrNodesFromElement(); | 3194 detachAllAttrNodesFromElement(); |
| 3195 | 3195 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3459 { | 3459 { |
| 3460 #if ENABLE(OILPAN) | 3460 #if ENABLE(OILPAN) |
| 3461 if (hasRareData()) | 3461 if (hasRareData()) |
| 3462 visitor->trace(elementRareData()); | 3462 visitor->trace(elementRareData()); |
| 3463 visitor->trace(m_elementData); | 3463 visitor->trace(m_elementData); |
| 3464 #endif | 3464 #endif |
| 3465 ContainerNode::trace(visitor); | 3465 ContainerNode::trace(visitor); |
| 3466 } | 3466 } |
| 3467 | 3467 |
| 3468 } // namespace blink | 3468 } // namespace blink |
| OLD | NEW |