| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.g
et()); | 694 collectMediaQueriesFromStyleSheet(styleSheet->pageStyleSheet(), medias.g
et()); |
| 695 const CSSRuleVector& flatRules = styleSheet->flatRules(); | 695 const CSSRuleVector& flatRules = styleSheet->flatRules(); |
| 696 for (unsigned i = 0; i < flatRules.size(); ++i) { | 696 for (unsigned i = 0; i < flatRules.size(); ++i) { |
| 697 CSSRule* rule = flatRules.at(i).get(); | 697 CSSRule* rule = flatRules.at(i).get(); |
| 698 if (rule->type() == CSSRule::MEDIA_RULE || rule->type() == CSSRule::
IMPORT_RULE) | 698 if (rule->type() == CSSRule::MEDIA_RULE || rule->type() == CSSRule::
IMPORT_RULE) |
| 699 collectMediaQueriesFromRule(rule, medias.get()); | 699 collectMediaQueriesFromRule(rule, medias.get()); |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 } | 702 } |
| 703 | 703 |
| 704 void InspectorCSSAgent::getMatchedStylesForNode(ErrorString* errorString, int no
deId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::RuleMatch>>& matchedCSSRules,
RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches>>& pseudoIdMatches,
RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>>& inheritedEntr
ies) | 704 void InspectorCSSAgent::getMatchedStylesForNode(ErrorString* errorString, int no
deId, RefPtr<TypeBuilder::CSS::CSSStyle>& inlineStyle, RefPtr<TypeBuilder::CSS::
CSSStyle>& attributesStyle, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::RuleMatc
h>>& matchedCSSRules, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatche
s>>& pseudoIdMatches, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyle
Entry>>& inheritedEntries) |
| 705 { | 705 { |
| 706 Element* element = elementForId(errorString, nodeId); | 706 Element* element = elementForId(errorString, nodeId); |
| 707 if (!element) { | 707 if (!element) { |
| 708 *errorString = "Node not found"; | 708 *errorString = "Node not found"; |
| 709 return; | 709 return; |
| 710 } | 710 } |
| 711 | 711 |
| 712 Element* originalElement = element; | 712 Element* originalElement = element; |
| 713 PseudoId elementPseudoId = element->pseudoId(); | 713 PseudoId elementPseudoId = element->pseudoId(); |
| 714 if (elementPseudoId) { | 714 if (elementPseudoId) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 729 // without grabbing at internal style classes! | 729 // without grabbing at internal style classes! |
| 730 | 730 |
| 731 // Matched rules. | 731 // Matched rules. |
| 732 StyleResolver& styleResolver = ownerDocument->ensureStyleResolver(); | 732 StyleResolver& styleResolver = ownerDocument->ensureStyleResolver(); |
| 733 | 733 |
| 734 element->updateDistribution(); | 734 element->updateDistribution(); |
| 735 RefPtrWillBeRawPtr<CSSRuleList> matchedRules = styleResolver.pseudoCSSRulesF
orElement(element, elementPseudoId, StyleResolver::AllCSSRules); | 735 RefPtrWillBeRawPtr<CSSRuleList> matchedRules = styleResolver.pseudoCSSRulesF
orElement(element, elementPseudoId, StyleResolver::AllCSSRules); |
| 736 matchedCSSRules = buildArrayForMatchedRuleList(matchedRules.get(), originalE
lement, NOPSEUDO); | 736 matchedCSSRules = buildArrayForMatchedRuleList(matchedRules.get(), originalE
lement, NOPSEUDO); |
| 737 | 737 |
| 738 // Pseudo elements. | 738 // Pseudo elements. |
| 739 if (!elementPseudoId) { | 739 if (elementPseudoId) |
| 740 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches> > pseudoEle
ments = TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches>::create(); | 740 return; |
| 741 for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_IN
TERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) { | 741 |
| 742 RefPtrWillBeRawPtr<CSSRuleList> matchedRules = styleResolver.pseudoC
SSRulesForElement(element, pseudoId, StyleResolver::AllCSSRules); | 742 InspectorStyleSheetForInlineStyle* inlineStyleSheet = asInspectorStyleSheet(
element); |
| 743 if (matchedRules && matchedRules->length()) { | 743 if (inlineStyleSheet) { |
| 744 RefPtr<TypeBuilder::CSS::PseudoIdMatches> matches = TypeBuilder:
:CSS::PseudoIdMatches::create() | 744 inlineStyle = inlineStyleSheet->buildObjectForStyle(element->style()); |
| 745 .setPseudoId(static_cast<int>(pseudoId)) | 745 RefPtr<TypeBuilder::CSS::CSSStyle> attributes = buildObjectForAttributes
Style(element); |
| 746 .setMatches(buildArrayForMatchedRuleList(matchedRules.get(),
element, pseudoId)); | 746 attributesStyle = attributes ? attributes.release() : nullptr; |
| 747 pseudoElements->addItem(matches.release()); | 747 } |
| 748 } | 748 |
| 749 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches>> pseudoElements
= TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches>::create(); |
| 750 for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_INTERN
AL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) { |
| 751 RefPtrWillBeRawPtr<CSSRuleList> matchedRules = styleResolver.pseudoCSSRu
lesForElement(element, pseudoId, StyleResolver::AllCSSRules); |
| 752 if (matchedRules && matchedRules->length()) { |
| 753 RefPtr<TypeBuilder::CSS::PseudoIdMatches> matches = TypeBuilder::CSS
::PseudoIdMatches::create() |
| 754 .setPseudoId(static_cast<int>(pseudoId)) |
| 755 .setMatches(buildArrayForMatchedRuleList(matchedRules.get(), ele
ment, pseudoId)); |
| 756 pseudoElements->addItem(matches.release()); |
| 749 } | 757 } |
| 750 pseudoIdMatches = pseudoElements.release(); | 758 } |
| 759 pseudoIdMatches = pseudoElements.release(); |
| 751 | 760 |
| 752 // Inherited styles. | 761 // Inherited styles. |
| 753 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> > entri
es = TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create(); | 762 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>> entries =
TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create(); |
| 754 Element* parentElement = element->parentOrShadowHostElement(); | 763 Element* parentElement = element->parentOrShadowHostElement(); |
| 755 while (parentElement) { | 764 while (parentElement) { |
| 756 StyleResolver& parentStyleResolver = parentElement->ownerDocument()-
>ensureStyleResolver(); | 765 StyleResolver& parentStyleResolver = parentElement->ownerDocument()->ens
ureStyleResolver(); |
| 757 RefPtrWillBeRawPtr<CSSRuleList> parentMatchedRules = parentStyleReso
lver.cssRulesForElement(parentElement, StyleResolver::AllCSSRules); | 766 RefPtrWillBeRawPtr<CSSRuleList> parentMatchedRules = parentStyleResolver
.cssRulesForElement(parentElement, StyleResolver::AllCSSRules); |
| 758 RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::C
SS::InheritedStyleEntry::create() | 767 RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::CSS::
InheritedStyleEntry::create() |
| 759 .setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRu
les.get(), parentElement, NOPSEUDO)); | 768 .setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRules.
get(), parentElement, NOPSEUDO)); |
| 760 if (parentElement->style() && parentElement->style()->length()) { | 769 if (parentElement->style() && parentElement->style()->length()) { |
| 761 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyle
Sheet(parentElement); | 770 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyleShee
t(parentElement); |
| 762 if (styleSheet) | 771 if (styleSheet) |
| 763 entry->setInlineStyle(styleSheet->buildObjectForStyle(styleS
heet->inlineStyle())); | 772 entry->setInlineStyle(styleSheet->buildObjectForStyle(styleSheet
->inlineStyle())); |
| 764 } | 773 } |
| 765 | 774 |
| 766 entries->addItem(entry.release()); | 775 entries->addItem(entry.release()); |
| 767 parentElement = parentElement->parentOrShadowHostElement(); | 776 parentElement = parentElement->parentOrShadowHostElement(); |
| 768 } | |
| 769 inheritedEntries = entries.release(); | |
| 770 } | 777 } |
| 778 inheritedEntries = entries.release(); |
| 771 } | 779 } |
| 772 | 780 |
| 773 void InspectorCSSAgent::getInlineStylesForNode(ErrorString* errorString, int nod
eId, RefPtr<TypeBuilder::CSS::CSSStyle>& inlineStyle, RefPtr<TypeBuilder::CSS::C
SSStyle>& attributesStyle) | 781 void InspectorCSSAgent::getInlineStylesForNode(ErrorString* errorString, int nod
eId, RefPtr<TypeBuilder::CSS::CSSStyle>& inlineStyle, RefPtr<TypeBuilder::CSS::C
SSStyle>& attributesStyle) |
| 774 { | 782 { |
| 775 Element* element = elementForId(errorString, nodeId); | 783 Element* element = elementForId(errorString, nodeId); |
| 776 if (!element) | 784 if (!element) |
| 777 return; | 785 return; |
| 778 | 786 |
| 779 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyleSheet(elemen
t); | 787 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyleSheet(elemen
t); |
| 780 if (!styleSheet) | 788 if (!styleSheet) |
| (...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1711 visitor->trace(m_documentToCSSStyleSheets); | 1719 visitor->trace(m_documentToCSSStyleSheets); |
| 1712 visitor->trace(m_invalidatedDocuments); | 1720 visitor->trace(m_invalidatedDocuments); |
| 1713 visitor->trace(m_nodeToInspectorStyleSheet); | 1721 visitor->trace(m_nodeToInspectorStyleSheet); |
| 1714 visitor->trace(m_documentToViaInspectorStyleSheet); | 1722 visitor->trace(m_documentToViaInspectorStyleSheet); |
| 1715 #endif | 1723 #endif |
| 1716 visitor->trace(m_inspectorUserAgentStyleSheet); | 1724 visitor->trace(m_inspectorUserAgentStyleSheet); |
| 1717 InspectorBaseAgent::trace(visitor); | 1725 InspectorBaseAgent::trace(visitor); |
| 1718 } | 1726 } |
| 1719 | 1727 |
| 1720 } // namespace blink | 1728 } // namespace blink |
| OLD | NEW |