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

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 1765933003: style: Rename the PseudoId enum values to CamelCase and prefix them. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enum-clash-PseudoId: none Created 4 years, 9 months 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
OLDNEW
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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 if (hasRareData() && !layoutObject()) { 1532 if (hasRareData() && !layoutObject()) {
1533 if (ElementAnimations* elementAnimations = elementRareData()->elementAni mations()) { 1533 if (ElementAnimations* elementAnimations = elementRareData()->elementAni mations()) {
1534 elementAnimations->cssAnimations().cancel(); 1534 elementAnimations->cssAnimations().cancel();
1535 elementAnimations->setAnimationStyleChange(false); 1535 elementAnimations->setAnimationStyleChange(false);
1536 } 1536 }
1537 } 1537 }
1538 1538
1539 SelectorFilterParentScope filterScope(*this); 1539 SelectorFilterParentScope filterScope(*this);
1540 StyleSharingDepthScope sharingScope(*this); 1540 StyleSharingDepthScope sharingScope(*this);
1541 1541
1542 createPseudoElementIfNeeded(BEFORE); 1542 createPseudoElementIfNeeded(PseudoIdBefore);
1543 1543
1544 // When a shadow root exists, it does the work of attaching the children. 1544 // When a shadow root exists, it does the work of attaching the children.
1545 if (ElementShadow* shadow = this->shadow()) 1545 if (ElementShadow* shadow = this->shadow())
1546 shadow->attach(context); 1546 shadow->attach(context);
1547 1547
1548 ContainerNode::attach(context); 1548 ContainerNode::attach(context);
1549 1549
1550 createPseudoElementIfNeeded(AFTER); 1550 createPseudoElementIfNeeded(PseudoIdAfter);
1551 createPseudoElementIfNeeded(BACKDROP); 1551 createPseudoElementIfNeeded(PseudoIdBackdrop);
1552 1552
1553 // We create the first-letter element after the :before, :after and 1553 // We create the first-letter element after the :before, :after and
1554 // children are attached because the first letter text could come 1554 // children are attached because the first letter text could come
1555 // from any of them. 1555 // from any of them.
1556 createPseudoElementIfNeeded(FIRST_LETTER); 1556 createPseudoElementIfNeeded(PseudoIdFirstLetter);
1557 } 1557 }
1558 1558
1559 void Element::detach(const AttachContext& context) 1559 void Element::detach(const AttachContext& context)
1560 { 1560 {
1561 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; 1561 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
1562 cancelFocusAppearanceUpdate(); 1562 cancelFocusAppearanceUpdate();
1563 removeCallbackSelectors(); 1563 removeCallbackSelectors();
1564 if (hasRareData()) { 1564 if (hasRareData()) {
1565 ElementRareData* data = elementRareData(); 1565 ElementRareData* data = elementRareData();
1566 data->clearPseudoElements(); 1566 data->clearPseudoElements();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 1617
1618 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles( ); 1618 const PseudoStyleCache* pseudoStyleCache = currentStyle->cachedPseudoStyles( );
1619 if (!pseudoStyleCache) 1619 if (!pseudoStyleCache)
1620 return false; 1620 return false;
1621 1621
1622 size_t cacheSize = pseudoStyleCache->size(); 1622 size_t cacheSize = pseudoStyleCache->size();
1623 for (size_t i = 0; i < cacheSize; ++i) { 1623 for (size_t i = 0; i < cacheSize; ++i) {
1624 RefPtr<ComputedStyle> newPseudoStyle; 1624 RefPtr<ComputedStyle> newPseudoStyle;
1625 RefPtr<ComputedStyle> oldPseudoStyle = pseudoStyleCache->at(i); 1625 RefPtr<ComputedStyle> oldPseudoStyle = pseudoStyleCache->at(i);
1626 PseudoId pseudoId = oldPseudoStyle->styleType(); 1626 PseudoId pseudoId = oldPseudoStyle->styleType();
1627 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) 1627 if (pseudoId == PseudoIdFirstLine || pseudoId == PseudoIdFirstLineInheri ted)
1628 newPseudoStyle = layoutObject()->uncachedFirstLineStyle(newStyle); 1628 newPseudoStyle = layoutObject()->uncachedFirstLineStyle(newStyle);
1629 else 1629 else
1630 newPseudoStyle = layoutObject()->getUncachedPseudoStyle(PseudoStyleR equest(pseudoId), newStyle, newStyle); 1630 newPseudoStyle = layoutObject()->getUncachedPseudoStyle(PseudoStyleR equest(pseudoId), newStyle, newStyle);
1631 if (!newPseudoStyle) 1631 if (!newPseudoStyle)
1632 return true; 1632 return true;
1633 if (*oldPseudoStyle != *newPseudoStyle || oldPseudoStyle->font().loading CustomFonts() != newPseudoStyle->font().loadingCustomFonts()) { 1633 if (*oldPseudoStyle != *newPseudoStyle || oldPseudoStyle->font().loading CustomFonts() != newPseudoStyle->font().loadingCustomFonts()) {
1634 if (pseudoId < FIRST_INTERNAL_PSEUDOID) 1634 if (pseudoId < FirstInternalPseudoId)
1635 newStyle->setHasPseudoStyle(pseudoId); 1635 newStyle->setHasPseudoStyle(pseudoId);
1636 newStyle->addCachedPseudoStyle(newPseudoStyle); 1636 newStyle->addCachedPseudoStyle(newPseudoStyle);
1637 if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED) 1637 if (pseudoId == PseudoIdFirstLine || pseudoId == PseudoIdFirstLineIn herited)
1638 layoutObject()->firstLineStyleDidChange(*oldPseudoStyle, *newPse udoStyle); 1638 layoutObject()->firstLineStyleDidChange(*oldPseudoStyle, *newPse udoStyle);
1639 return true; 1639 return true;
1640 } 1640 }
1641 } 1641 }
1642 return false; 1642 return false;
1643 } 1643 }
1644 1644
1645 PassRefPtr<ComputedStyle> Element::styleForLayoutObject() 1645 PassRefPtr<ComputedStyle> Element::styleForLayoutObject()
1646 { 1646 {
1647 ASSERT(document().inStyleRecalc()); 1647 ASSERT(document().inStyleRecalc());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 if (parentComputedStyle()) 1702 if (parentComputedStyle())
1703 change = recalcOwnStyle(change); 1703 change = recalcOwnStyle(change);
1704 clearNeedsStyleRecalc(); 1704 clearNeedsStyleRecalc();
1705 } 1705 }
1706 1706
1707 // If we reattached we don't need to recalc the style of our descendants any more. 1707 // If we reattached we don't need to recalc the style of our descendants any more.
1708 if ((change >= UpdatePseudoElements && change < Reattach) || childNeedsStyle Recalc()) { 1708 if ((change >= UpdatePseudoElements && change < Reattach) || childNeedsStyle Recalc()) {
1709 SelectorFilterParentScope filterScope(*this); 1709 SelectorFilterParentScope filterScope(*this);
1710 StyleSharingDepthScope sharingScope(*this); 1710 StyleSharingDepthScope sharingScope(*this);
1711 1711
1712 updatePseudoElement(BEFORE, change); 1712 updatePseudoElement(PseudoIdBefore, change);
1713 1713
1714 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { 1714 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) {
1715 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->old erShadowRoot()) { 1715 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->old erShadowRoot()) {
1716 if (root->shouldCallRecalcStyle(change)) 1716 if (root->shouldCallRecalcStyle(change))
1717 root->recalcStyle(change); 1717 root->recalcStyle(change);
1718 } 1718 }
1719 recalcChildStyle(change); 1719 recalcChildStyle(change);
1720 } 1720 }
1721 1721
1722 updatePseudoElement(AFTER, change); 1722 updatePseudoElement(PseudoIdAfter, change);
1723 updatePseudoElement(BACKDROP, change); 1723 updatePseudoElement(PseudoIdBackdrop, change);
1724 1724
1725 // If our children have changed then we need to force the first-letter 1725 // If our children have changed then we need to force the first-letter
1726 // checks as we don't know if they effected the first letter or not. 1726 // checks as we don't know if they effected the first letter or not.
1727 // This can be seen when a child transitions from floating to 1727 // This can be seen when a child transitions from floating to
1728 // non-floating we have to take it into account for the first letter. 1728 // non-floating we have to take it into account for the first letter.
1729 updatePseudoElement(FIRST_LETTER, childNeedsStyleRecalc() ? Force : chan ge); 1729 updatePseudoElement(PseudoIdFirstLetter, childNeedsStyleRecalc() ? Force : change);
1730 1730
1731 clearChildNeedsStyleRecalc(); 1731 clearChildNeedsStyleRecalc();
1732 } 1732 }
1733 1733
1734 if (hasCustomStyleCallbacks()) 1734 if (hasCustomStyleCallbacks())
1735 didRecalcStyle(change); 1735 didRecalcStyle(change);
1736 1736
1737 if (change == Reattach) 1737 if (change == Reattach)
1738 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); 1738 reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
1739 } 1739 }
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2840 if (document().focusedElement() == this) 2840 if (document().focusedElement() == this)
2841 document().cancelFocusAppearanceUpdate(); 2841 document().cancelFocusAppearanceUpdate();
2842 } 2842 }
2843 2843
2844 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change) 2844 void Element::updatePseudoElement(PseudoId pseudoId, StyleRecalcChange change)
2845 { 2845 {
2846 ASSERT(!needsStyleRecalc()); 2846 ASSERT(!needsStyleRecalc());
2847 PseudoElement* element = pseudoElement(pseudoId); 2847 PseudoElement* element = pseudoElement(pseudoId);
2848 2848
2849 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) { 2849 if (element && (change == UpdatePseudoElements || element->shouldCallRecalcS tyle(change))) {
2850 if (pseudoId == FIRST_LETTER && updateFirstLetter(element)) 2850 if (pseudoId == PseudoIdFirstLetter && updateFirstLetter(element))
2851 return; 2851 return;
2852 2852
2853 // Need to clear the cached style if the PseudoElement wants a recalc so it 2853 // Need to clear the cached style if the PseudoElement wants a recalc so it
2854 // computes a new style. 2854 // computes a new style.
2855 if (element->needsStyleRecalc()) 2855 if (element->needsStyleRecalc())
2856 layoutObject()->mutableStyle()->removeCachedPseudoStyle(pseudoId); 2856 layoutObject()->mutableStyle()->removeCachedPseudoStyle(pseudoId);
2857 2857
2858 // PseudoElement styles hang off their parent element's style so if we n eeded 2858 // PseudoElement styles hang off their parent element's style so if we n eeded
2859 // a style recalc we should Force one on the pseudo. 2859 // a style recalc we should Force one on the pseudo.
2860 // FIXME: We should figure out the right text sibling to pass. 2860 // FIXME: We should figure out the right text sibling to pass.
2861 element->recalcStyle(change == UpdatePseudoElements ? Force : change); 2861 element->recalcStyle(change == UpdatePseudoElements ? Force : change);
2862 2862
2863 // Wait until our parent is not displayed or pseudoElementLayoutObjectIs Needed 2863 // Wait until our parent is not displayed or pseudoElementLayoutObjectIs Needed
2864 // is false, otherwise we could continuously create and destroy PseudoEl ements 2864 // is false, otherwise we could continuously create and destroy PseudoEl ements
2865 // when LayoutObject::isChildAllowed on our parent returns false for the 2865 // when LayoutObject::isChildAllowed on our parent returns false for the
2866 // PseudoElement's layoutObject for each style recalc. 2866 // PseudoElement's layoutObject for each style recalc.
2867 if (!layoutObject() || !pseudoElementLayoutObjectIsNeeded(layoutObject() ->getCachedPseudoStyle(pseudoId))) 2867 if (!layoutObject() || !pseudoElementLayoutObjectIsNeeded(layoutObject() ->getCachedPseudoStyle(pseudoId)))
2868 elementRareData()->setPseudoElement(pseudoId, nullptr); 2868 elementRareData()->setPseudoElement(pseudoId, nullptr);
2869 } else if (pseudoId == FIRST_LETTER && element && change >= UpdatePseudoElem ents && !FirstLetterPseudoElement::firstLetterTextLayoutObject(*element)) { 2869 } else if (pseudoId == PseudoIdFirstLetter && element && change >= UpdatePse udoElements && !FirstLetterPseudoElement::firstLetterTextLayoutObject(*element)) {
2870 // This can happen if we change to a float, for example. We need to clea nup the 2870 // This can happen if we change to a float, for example. We need to clea nup the
2871 // first-letter pseudoElement and then fix the text of the original rema ining 2871 // first-letter pseudoElement and then fix the text of the original rema ining
2872 // text layoutObject. 2872 // text layoutObject.
2873 // This can be seen in Test 7 of fast/css/first-letter-removed-added.htm l 2873 // This can be seen in Test 7 of fast/css/first-letter-removed-added.htm l
2874 elementRareData()->setPseudoElement(pseudoId, nullptr); 2874 elementRareData()->setPseudoElement(pseudoId, nullptr);
2875 } else if (change >= UpdatePseudoElements) { 2875 } else if (change >= UpdatePseudoElements) {
2876 createPseudoElementIfNeeded(pseudoId); 2876 createPseudoElementIfNeeded(pseudoId);
2877 } 2877 }
2878 } 2878 }
2879 2879
2880 // If we're updating first letter, and the current first letter layoutObject 2880 // If we're updating first letter, and the current first letter layoutObject
2881 // is not the same as the one we're currently using we need to re-create 2881 // is not the same as the one we're currently using we need to re-create
2882 // the first letter layoutObject. 2882 // the first letter layoutObject.
2883 bool Element::updateFirstLetter(Element* element) 2883 bool Element::updateFirstLetter(Element* element)
2884 { 2884 {
2885 LayoutObject* remainingTextLayoutObject = FirstLetterPseudoElement::firstLet terTextLayoutObject(*element); 2885 LayoutObject* remainingTextLayoutObject = FirstLetterPseudoElement::firstLet terTextLayoutObject(*element);
2886 if (!remainingTextLayoutObject || remainingTextLayoutObject != toFirstLetter PseudoElement(element)->remainingTextLayoutObject()) { 2886 if (!remainingTextLayoutObject || remainingTextLayoutObject != toFirstLetter PseudoElement(element)->remainingTextLayoutObject()) {
2887 // We have to clear out the old first letter here because when it is 2887 // We have to clear out the old first letter here because when it is
2888 // disposed it will set the original text back on the remaining text 2888 // disposed it will set the original text back on the remaining text
2889 // layoutObject. If we dispose after creating the new one we will get 2889 // layoutObject. If we dispose after creating the new one we will get
2890 // incorrect results due to setting the first letter back. 2890 // incorrect results due to setting the first letter back.
2891 if (remainingTextLayoutObject) 2891 if (remainingTextLayoutObject)
2892 element->reattach(); 2892 element->reattach();
2893 else 2893 else
2894 elementRareData()->setPseudoElement(FIRST_LETTER, nullptr); 2894 elementRareData()->setPseudoElement(PseudoIdFirstLetter, nullptr);
2895 return true; 2895 return true;
2896 } 2896 }
2897 return false; 2897 return false;
2898 } 2898 }
2899 2899
2900 void Element::createPseudoElementIfNeeded(PseudoId pseudoId) 2900 void Element::createPseudoElementIfNeeded(PseudoId pseudoId)
2901 { 2901 {
2902 if (isPseudoElement()) 2902 if (isPseudoElement())
2903 return; 2903 return;
2904 2904
2905 // Document::ensureStyleResolver is not inlined and shows up on profiles, av oid it here. 2905 // Document::ensureStyleResolver is not inlined and shows up on profiles, av oid it here.
2906 RefPtrWillBeRawPtr<PseudoElement> element = document().styleEngine().ensureR esolver().createPseudoElementIfNeeded(*this, pseudoId); 2906 RefPtrWillBeRawPtr<PseudoElement> element = document().styleEngine().ensureR esolver().createPseudoElementIfNeeded(*this, pseudoId);
2907 if (!element) 2907 if (!element)
2908 return; 2908 return;
2909 2909
2910 if (pseudoId == BACKDROP) 2910 if (pseudoId == PseudoIdBackdrop)
2911 document().addToTopLayer(element.get(), this); 2911 document().addToTopLayer(element.get(), this);
2912 element->insertedInto(this); 2912 element->insertedInto(this);
2913 element->attach(); 2913 element->attach();
2914 2914
2915 InspectorInstrumentation::pseudoElementCreated(element.get()); 2915 InspectorInstrumentation::pseudoElementCreated(element.get());
2916 2916
2917 ensureElementRareData().setPseudoElement(pseudoId, element.release()); 2917 ensureElementRareData().setPseudoElement(pseudoId, element.release());
2918 } 2918 }
2919 2919
2920 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const 2920 PseudoElement* Element::pseudoElement(PseudoId pseudoId) const
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
3670 { 3670 {
3671 #if ENABLE(OILPAN) 3671 #if ENABLE(OILPAN)
3672 if (hasRareData()) 3672 if (hasRareData())
3673 visitor->trace(elementRareData()); 3673 visitor->trace(elementRareData());
3674 visitor->trace(m_elementData); 3674 visitor->trace(m_elementData);
3675 #endif 3675 #endif
3676 ContainerNode::trace(visitor); 3676 ContainerNode::trace(visitor);
3677 } 3677 }
3678 3678
3679 } // namespace blink 3679 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/ElementRareData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698