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 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 if (!element) | 911 if (!element) |
912 return; | 912 return; |
913 | 913 |
914 Element* originalElement = element; | 914 Element* originalElement = element; |
915 PseudoId elementPseudoId = element->pseudoId(); | 915 PseudoId elementPseudoId = element->pseudoId(); |
916 if (elementPseudoId) | 916 if (elementPseudoId) |
917 element = element->parentOrShadowHostElement(); | 917 element = element->parentOrShadowHostElement(); |
918 | 918 |
919 // Matched rules. | 919 // Matched rules. |
920 StyleResolver* styleResolver = element->ownerDocument()->styleResolver(); | 920 StyleResolver* styleResolver = element->ownerDocument()->styleResolver(); |
| 921 appendPendingStyleSheetsIfNeeded(styleResolver); |
921 // FIXME: This code should not pass DoNotIncludeStyleSheetInCSSOMWrapper. Al
l CSSOMWrappers should always have a parent sheet or rule. | 922 // FIXME: This code should not pass DoNotIncludeStyleSheetInCSSOMWrapper. Al
l CSSOMWrappers should always have a parent sheet or rule. |
922 RefPtr<CSSRuleList> matchedRules = styleResolver->pseudoCSSRulesForElement(e
lement, elementPseudoId, StyleResolver::AllCSSRules, DoNotIncludeStyleSheetInCSS
OMWrapper); | 923 RefPtr<CSSRuleList> matchedRules = styleResolver->pseudoCSSRulesForElement(e
lement, elementPseudoId, StyleResolver::AllCSSRules, DoNotIncludeStyleSheetInCSS
OMWrapper); |
923 matchedCSSRules = buildArrayForMatchedRuleList(matchedRules.get(), styleReso
lver, originalElement); | 924 matchedCSSRules = buildArrayForMatchedRuleList(matchedRules.get(), styleReso
lver, originalElement); |
924 | 925 |
925 // Pseudo elements. | 926 // Pseudo elements. |
926 if (!elementPseudoId && (!includePseudo || *includePseudo)) { | 927 if (!elementPseudoId && (!includePseudo || *includePseudo)) { |
927 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches> > pseudoEle
ments = TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches>::create(); | 928 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches> > pseudoEle
ments = TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches>::create(); |
928 for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_IN
TERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) { | 929 for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_IN
TERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) { |
929 RefPtr<CSSRuleList> matchedRules = styleResolver->pseudoCSSRulesForE
lement(element, pseudoId, StyleResolver::AllCSSRules, DoNotIncludeStyleSheetInCS
SOMWrapper); | 930 RefPtr<CSSRuleList> matchedRules = styleResolver->pseudoCSSRulesForE
lement(element, pseudoId, StyleResolver::AllCSSRules, DoNotIncludeStyleSheetInCS
SOMWrapper); |
930 if (matchedRules && matchedRules->length()) { | 931 if (matchedRules && matchedRules->length()) { |
931 RefPtr<TypeBuilder::CSS::PseudoIdMatches> matches = TypeBuilder:
:CSS::PseudoIdMatches::create() | 932 RefPtr<TypeBuilder::CSS::PseudoIdMatches> matches = TypeBuilder:
:CSS::PseudoIdMatches::create() |
932 .setPseudoId(static_cast<int>(pseudoId)) | 933 .setPseudoId(static_cast<int>(pseudoId)) |
933 .setMatches(buildArrayForMatchedRuleList(matchedRules.get(),
styleResolver, element)); | 934 .setMatches(buildArrayForMatchedRuleList(matchedRules.get(),
styleResolver, element)); |
934 pseudoElements->addItem(matches.release()); | 935 pseudoElements->addItem(matches.release()); |
935 } | 936 } |
936 } | 937 } |
937 | 938 |
938 pseudoIdMatches = pseudoElements.release(); | 939 pseudoIdMatches = pseudoElements.release(); |
939 } | 940 } |
940 | 941 |
941 // Inherited styles. | 942 // Inherited styles. |
942 if (!elementPseudoId && (!includeInherited || *includeInherited)) { | 943 if (!elementPseudoId && (!includeInherited || *includeInherited)) { |
943 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> > entri
es = TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create(); | 944 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> > entri
es = TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create(); |
944 Element* parentElement = element->parentElement(); | 945 Element* parentElement = element->parentElement(); |
945 while (parentElement) { | 946 while (parentElement) { |
946 StyleResolver* parentStyleResolver = parentElement->ownerDocument()-
>styleResolver(); | 947 StyleResolver* parentStyleResolver = parentElement->ownerDocument()-
>styleResolver(); |
| 948 appendPendingStyleSheetsIfNeeded(parentStyleResolver); |
947 RefPtr<CSSRuleList> parentMatchedRules = parentStyleResolver->cssRul
esForElement(parentElement, StyleResolver::AllCSSRules, DoNotIncludeStyleSheetIn
CSSOMWrapper); | 949 RefPtr<CSSRuleList> parentMatchedRules = parentStyleResolver->cssRul
esForElement(parentElement, StyleResolver::AllCSSRules, DoNotIncludeStyleSheetIn
CSSOMWrapper); |
948 RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::C
SS::InheritedStyleEntry::create() | 950 RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::C
SS::InheritedStyleEntry::create() |
949 .setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRu
les.get(), styleResolver, parentElement)); | 951 .setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRu
les.get(), styleResolver, parentElement)); |
950 if (parentElement->style() && parentElement->style()->length()) { | 952 if (parentElement->style() && parentElement->style()->length()) { |
951 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyle
Sheet(parentElement); | 953 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyle
Sheet(parentElement); |
952 if (styleSheet) | 954 if (styleSheet) |
953 entry->setInlineStyle(styleSheet->buildObjectForStyle(styleS
heet->styleForId(InspectorCSSId(styleSheet->id(), 0)))); | 955 entry->setInlineStyle(styleSheet->buildObjectForStyle(styleS
heet->styleForId(InspectorCSSId(styleSheet->id(), 0)))); |
954 } | 956 } |
955 | 957 |
956 entries->addItem(entry.release()); | 958 entries->addItem(entry.release()); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 | 1065 |
1064 void InspectorCSSAgent::getStyleSheet(ErrorString* errorString, const String& st
yleSheetId, RefPtr<TypeBuilder::CSS::CSSStyleSheetBody>& styleSheetObject) | 1066 void InspectorCSSAgent::getStyleSheet(ErrorString* errorString, const String& st
yleSheetId, RefPtr<TypeBuilder::CSS::CSSStyleSheetBody>& styleSheetObject) |
1065 { | 1067 { |
1066 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, styleSheetId); | 1068 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, styleSheetId); |
1067 if (!inspectorStyleSheet) | 1069 if (!inspectorStyleSheet) |
1068 return; | 1070 return; |
1069 | 1071 |
1070 Document* doc = inspectorStyleSheet->pageStyleSheet() ? inspectorStyleSheet-
>pageStyleSheet()->ownerDocument() : 0; | 1072 Document* doc = inspectorStyleSheet->pageStyleSheet() ? inspectorStyleSheet-
>pageStyleSheet()->ownerDocument() : 0; |
1071 if (!doc || !doc->styleResolver()) | 1073 if (!doc || !doc->styleResolver()) |
1072 return; | 1074 return; |
| 1075 appendPendingStyleSheetsIfNeeded(doc->styleResolver()); |
1073 | 1076 |
1074 RefPtr<TypeBuilder::CSS::CSSStyleSheetBody> result = TypeBuilder::CSS::CSSSt
yleSheetBody::create() | 1077 RefPtr<TypeBuilder::CSS::CSSStyleSheetBody> result = TypeBuilder::CSS::CSSSt
yleSheetBody::create() |
1075 .setStyleSheetId(styleSheetId) | 1078 .setStyleSheetId(styleSheetId) |
1076 .setRules(buildArrayForRuleList(inspectorStyleSheet->pageStyleSheet()->r
ules().get(), doc->styleResolver())); | 1079 .setRules(buildArrayForRuleList(inspectorStyleSheet->pageStyleSheet()->r
ules().get(), doc->styleResolver())); |
1077 | 1080 |
1078 bool success = inspectorStyleSheet->fillObjectForStyleSheet(result); | 1081 bool success = inspectorStyleSheet->fillObjectForStyleSheet(result); |
1079 if (success) | 1082 if (success) |
1080 styleSheetObject = result; | 1083 styleSheetObject = result; |
1081 } | 1084 } |
1082 | 1085 |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 documentsToChange.add(element->ownerDocument()); | 1739 documentsToChange.add(element->ownerDocument()); |
1737 } | 1740 } |
1738 | 1741 |
1739 m_nodeIdToForcedPseudoState.clear(); | 1742 m_nodeIdToForcedPseudoState.clear(); |
1740 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1743 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
1741 (*it)->setNeedsStyleRecalc(); | 1744 (*it)->setNeedsStyleRecalc(); |
1742 } | 1745 } |
1743 | 1746 |
1744 } // namespace WebCore | 1747 } // namespace WebCore |
1745 | 1748 |
OLD | NEW |