| 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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 // A non-active document has no styles. | 949 // A non-active document has no styles. |
| 950 if (!ownerDocument->isActive()) | 950 if (!ownerDocument->isActive()) |
| 951 return; | 951 return; |
| 952 | 952 |
| 953 // FIXME: It's really gross for the inspector to reach in and access StyleRe
solver | 953 // FIXME: It's really gross for the inspector to reach in and access StyleRe
solver |
| 954 // directly here. We need to provide the Inspector better APIs to get this i
nformation | 954 // directly here. We need to provide the Inspector better APIs to get this i
nformation |
| 955 // without grabbing at internal style classes! | 955 // without grabbing at internal style classes! |
| 956 | 956 |
| 957 // Matched rules. | 957 // Matched rules. |
| 958 StyleResolver* styleResolver = ownerDocument->styleResolver(); | 958 StyleResolver* styleResolver = ownerDocument->styleResolver(); |
| 959 appendPendingStyleSheetsIfNeeded(styleResolver); |
| 959 // FIXME: This code should not pass DoNotIncludeStyleSheetInCSSOMWrapper. Al
l CSSOMWrappers should always have a parent sheet or rule. | 960 // FIXME: This code should not pass DoNotIncludeStyleSheetInCSSOMWrapper. Al
l CSSOMWrappers should always have a parent sheet or rule. |
| 960 RefPtr<CSSRuleList> matchedRules = styleResolver->pseudoCSSRulesForElement(e
lement, elementPseudoId, StyleResolver::AllCSSRules, DoNotIncludeStyleSheetInCSS
OMWrapper); | 961 RefPtr<CSSRuleList> matchedRules = styleResolver->pseudoCSSRulesForElement(e
lement, elementPseudoId, StyleResolver::AllCSSRules, DoNotIncludeStyleSheetInCSS
OMWrapper); |
| 961 matchedCSSRules = buildArrayForMatchedRuleList(matchedRules.get(), styleReso
lver, originalElement); | 962 matchedCSSRules = buildArrayForMatchedRuleList(matchedRules.get(), styleReso
lver, originalElement); |
| 962 | 963 |
| 963 // Pseudo elements. | 964 // Pseudo elements. |
| 964 if (!elementPseudoId && (!includePseudo || *includePseudo)) { | 965 if (!elementPseudoId && (!includePseudo || *includePseudo)) { |
| 965 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches> > pseudoEle
ments = TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches>::create(); | 966 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches> > pseudoEle
ments = TypeBuilder::Array<TypeBuilder::CSS::PseudoIdMatches>::create(); |
| 966 for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_IN
TERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) { | 967 for (PseudoId pseudoId = FIRST_PUBLIC_PSEUDOID; pseudoId < AFTER_LAST_IN
TERNAL_PSEUDOID; pseudoId = static_cast<PseudoId>(pseudoId + 1)) { |
| 967 RefPtr<CSSRuleList> matchedRules = styleResolver->pseudoCSSRulesForE
lement(element, pseudoId, StyleResolver::AllCSSRules, DoNotIncludeStyleSheetInCS
SOMWrapper); | 968 RefPtr<CSSRuleList> matchedRules = styleResolver->pseudoCSSRulesForE
lement(element, pseudoId, StyleResolver::AllCSSRules, DoNotIncludeStyleSheetInCS
SOMWrapper); |
| 968 if (matchedRules && matchedRules->length()) { | 969 if (matchedRules && matchedRules->length()) { |
| 969 RefPtr<TypeBuilder::CSS::PseudoIdMatches> matches = TypeBuilder:
:CSS::PseudoIdMatches::create() | 970 RefPtr<TypeBuilder::CSS::PseudoIdMatches> matches = TypeBuilder:
:CSS::PseudoIdMatches::create() |
| 970 .setPseudoId(static_cast<int>(pseudoId)) | 971 .setPseudoId(static_cast<int>(pseudoId)) |
| 971 .setMatches(buildArrayForMatchedRuleList(matchedRules.get(),
styleResolver, element)); | 972 .setMatches(buildArrayForMatchedRuleList(matchedRules.get(),
styleResolver, element)); |
| 972 pseudoElements->addItem(matches.release()); | 973 pseudoElements->addItem(matches.release()); |
| 973 } | 974 } |
| 974 } | 975 } |
| 975 | 976 |
| 976 pseudoIdMatches = pseudoElements.release(); | 977 pseudoIdMatches = pseudoElements.release(); |
| 977 } | 978 } |
| 978 | 979 |
| 979 // Inherited styles. | 980 // Inherited styles. |
| 980 if (!elementPseudoId && (!includeInherited || *includeInherited)) { | 981 if (!elementPseudoId && (!includeInherited || *includeInherited)) { |
| 981 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> > entri
es = TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create(); | 982 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> > entri
es = TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create(); |
| 982 Element* parentElement = element->parentElement(); | 983 Element* parentElement = element->parentElement(); |
| 983 while (parentElement) { | 984 while (parentElement) { |
| 984 StyleResolver* parentStyleResolver = parentElement->ownerDocument()-
>styleResolver(); | 985 StyleResolver* parentStyleResolver = parentElement->ownerDocument()-
>styleResolver(); |
| 986 appendPendingStyleSheetsIfNeeded(parentStyleResolver); |
| 985 RefPtr<CSSRuleList> parentMatchedRules = parentStyleResolver->cssRul
esForElement(parentElement, StyleResolver::AllCSSRules, DoNotIncludeStyleSheetIn
CSSOMWrapper); | 987 RefPtr<CSSRuleList> parentMatchedRules = parentStyleResolver->cssRul
esForElement(parentElement, StyleResolver::AllCSSRules, DoNotIncludeStyleSheetIn
CSSOMWrapper); |
| 986 RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::C
SS::InheritedStyleEntry::create() | 988 RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::C
SS::InheritedStyleEntry::create() |
| 987 .setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRu
les.get(), styleResolver, parentElement)); | 989 .setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRu
les.get(), styleResolver, parentElement)); |
| 988 if (parentElement->style() && parentElement->style()->length()) { | 990 if (parentElement->style() && parentElement->style()->length()) { |
| 989 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyle
Sheet(parentElement); | 991 InspectorStyleSheetForInlineStyle* styleSheet = asInspectorStyle
Sheet(parentElement); |
| 990 if (styleSheet) | 992 if (styleSheet) |
| 991 entry->setInlineStyle(styleSheet->buildObjectForStyle(styleS
heet->styleForId(InspectorCSSId(styleSheet->id(), 0)))); | 993 entry->setInlineStyle(styleSheet->buildObjectForStyle(styleS
heet->styleForId(InspectorCSSId(styleSheet->id(), 0)))); |
| 992 } | 994 } |
| 993 | 995 |
| 994 entries->addItem(entry.release()); | 996 entries->addItem(entry.release()); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 | 1102 |
| 1101 void InspectorCSSAgent::getStyleSheet(ErrorString* errorString, const String& st
yleSheetId, RefPtr<TypeBuilder::CSS::CSSStyleSheetBody>& styleSheetObject) | 1103 void InspectorCSSAgent::getStyleSheet(ErrorString* errorString, const String& st
yleSheetId, RefPtr<TypeBuilder::CSS::CSSStyleSheetBody>& styleSheetObject) |
| 1102 { | 1104 { |
| 1103 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, styleSheetId); | 1105 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, styleSheetId); |
| 1104 if (!inspectorStyleSheet) | 1106 if (!inspectorStyleSheet) |
| 1105 return; | 1107 return; |
| 1106 | 1108 |
| 1107 Document* doc = inspectorStyleSheet->pageStyleSheet() ? inspectorStyleSheet-
>pageStyleSheet()->ownerDocument() : 0; | 1109 Document* doc = inspectorStyleSheet->pageStyleSheet() ? inspectorStyleSheet-
>pageStyleSheet()->ownerDocument() : 0; |
| 1108 if (!doc || !doc->styleResolver()) | 1110 if (!doc || !doc->styleResolver()) |
| 1109 return; | 1111 return; |
| 1112 appendPendingStyleSheetsIfNeeded(doc->styleResolver()); |
| 1110 | 1113 |
| 1111 RefPtr<TypeBuilder::CSS::CSSStyleSheetBody> result = TypeBuilder::CSS::CSSSt
yleSheetBody::create() | 1114 RefPtr<TypeBuilder::CSS::CSSStyleSheetBody> result = TypeBuilder::CSS::CSSSt
yleSheetBody::create() |
| 1112 .setStyleSheetId(styleSheetId) | 1115 .setStyleSheetId(styleSheetId) |
| 1113 .setRules(buildArrayForRuleList(inspectorStyleSheet->pageStyleSheet()->r
ules().get(), doc->styleResolver())); | 1116 .setRules(buildArrayForRuleList(inspectorStyleSheet->pageStyleSheet()->r
ules().get(), doc->styleResolver())); |
| 1114 | 1117 |
| 1115 bool success = inspectorStyleSheet->fillObjectForStyleSheet(result); | 1118 bool success = inspectorStyleSheet->fillObjectForStyleSheet(result); |
| 1116 if (success) | 1119 if (success) |
| 1117 styleSheetObject = result; | 1120 styleSheetObject = result; |
| 1118 } | 1121 } |
| 1119 | 1122 |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 documentsToChange.add(element->ownerDocument()); | 1776 documentsToChange.add(element->ownerDocument()); |
| 1774 } | 1777 } |
| 1775 | 1778 |
| 1776 m_nodeIdToForcedPseudoState.clear(); | 1779 m_nodeIdToForcedPseudoState.clear(); |
| 1777 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1780 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
| 1778 (*it)->setNeedsStyleRecalc(); | 1781 (*it)->setNeedsStyleRecalc(); |
| 1779 } | 1782 } |
| 1780 | 1783 |
| 1781 } // namespace WebCore | 1784 } // namespace WebCore |
| 1782 | 1785 |
| OLD | NEW |