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 28 matching lines...) Expand all Loading... |
39 #include "core/css/CSSRuleList.h" | 39 #include "core/css/CSSRuleList.h" |
40 #include "core/css/CSSStyleRule.h" | 40 #include "core/css/CSSStyleRule.h" |
41 #include "core/css/CSSStyleSheet.h" | 41 #include "core/css/CSSStyleSheet.h" |
42 #include "core/css/MediaList.h" | 42 #include "core/css/MediaList.h" |
43 #include "core/css/StylePropertySet.h" | 43 #include "core/css/StylePropertySet.h" |
44 #include "core/css/StyleRule.h" | 44 #include "core/css/StyleRule.h" |
45 #include "core/css/StyleSheet.h" | 45 #include "core/css/StyleSheet.h" |
46 #include "core/css/StyleSheetContents.h" | 46 #include "core/css/StyleSheetContents.h" |
47 #include "core/css/StyleSheetList.h" | 47 #include "core/css/StyleSheetList.h" |
48 #include "core/css/resolver/StyleResolver.h" | 48 #include "core/css/resolver/StyleResolver.h" |
49 #include "core/dom/NamedFlow.h" | |
50 #include "core/dom/NamedFlowCollection.h" | |
51 #include "core/dom/Node.h" | 49 #include "core/dom/Node.h" |
52 #include "core/dom/NodeList.h" | 50 #include "core/dom/NodeList.h" |
53 #include "core/fetch/CSSStyleSheetResource.h" | 51 #include "core/fetch/CSSStyleSheetResource.h" |
54 #include "core/fetch/ResourceClient.h" | 52 #include "core/fetch/ResourceClient.h" |
55 #include "core/fetch/ResourceFetcher.h" | 53 #include "core/fetch/ResourceFetcher.h" |
56 #include "core/fetch/StyleSheetResourceClient.h" | 54 #include "core/fetch/StyleSheetResourceClient.h" |
57 #include "core/html/HTMLHeadElement.h" | 55 #include "core/html/HTMLHeadElement.h" |
58 #include "core/inspector/InspectorHistory.h" | 56 #include "core/inspector/InspectorHistory.h" |
59 #include "core/inspector/InspectorPageAgent.h" | 57 #include "core/inspector/InspectorPageAgent.h" |
60 #include "core/inspector/InspectorResourceAgent.h" | 58 #include "core/inspector/InspectorResourceAgent.h" |
61 #include "core/inspector/InspectorState.h" | 59 #include "core/inspector/InspectorState.h" |
62 #include "core/inspector/InstrumentingAgents.h" | 60 #include "core/inspector/InstrumentingAgents.h" |
63 #include "core/loader/DocumentLoader.h" | 61 #include "core/loader/DocumentLoader.h" |
64 #include "core/frame/Frame.h" | 62 #include "core/frame/Frame.h" |
65 #include "core/page/Page.h" | 63 #include "core/page/Page.h" |
66 #include "core/rendering/InlineTextBox.h" | 64 #include "core/rendering/InlineTextBox.h" |
67 #include "core/rendering/RenderObject.h" | 65 #include "core/rendering/RenderObject.h" |
68 #include "core/rendering/RenderRegion.h" | |
69 #include "core/rendering/RenderText.h" | 66 #include "core/rendering/RenderText.h" |
70 #include "core/rendering/RenderTextFragment.h" | 67 #include "core/rendering/RenderTextFragment.h" |
71 #include "platform/fonts/Font.h" | 68 #include "platform/fonts/Font.h" |
72 #include "platform/fonts/GlyphBuffer.h" | 69 #include "platform/fonts/GlyphBuffer.h" |
73 #include "platform/fonts/WidthIterator.h" | 70 #include "platform/fonts/WidthIterator.h" |
74 #include "platform/text/TextRun.h" | 71 #include "platform/text/TextRun.h" |
75 #include "wtf/CurrentTime.h" | 72 #include "wtf/CurrentTime.h" |
76 #include "wtf/text/CString.h" | 73 #include "wtf/text/CString.h" |
77 #include "wtf/text/StringConcatenate.h" | 74 #include "wtf/text/StringConcatenate.h" |
78 | 75 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 result |= PseudoHover; | 111 result |= PseudoHover; |
115 else if (pseudoClass == focus) | 112 else if (pseudoClass == focus) |
116 result |= PseudoFocus; | 113 result |= PseudoFocus; |
117 else if (pseudoClass == visited) | 114 else if (pseudoClass == visited) |
118 result |= PseudoVisited; | 115 result |= PseudoVisited; |
119 } | 116 } |
120 | 117 |
121 return result; | 118 return result; |
122 } | 119 } |
123 | 120 |
124 class UpdateRegionLayoutTask { | |
125 public: | |
126 UpdateRegionLayoutTask(InspectorCSSAgent*); | |
127 void scheduleFor(NamedFlow*, int documentNodeId); | |
128 void unschedule(NamedFlow*); | |
129 void reset(); | |
130 void onTimer(Timer<UpdateRegionLayoutTask>*); | |
131 | |
132 private: | |
133 InspectorCSSAgent* m_cssAgent; | |
134 Timer<UpdateRegionLayoutTask> m_timer; | |
135 HashMap<NamedFlow*, int> m_namedFlows; | |
136 }; | |
137 | |
138 UpdateRegionLayoutTask::UpdateRegionLayoutTask(InspectorCSSAgent* cssAgent) | |
139 : m_cssAgent(cssAgent) | |
140 , m_timer(this, &UpdateRegionLayoutTask::onTimer) | |
141 { | |
142 } | |
143 | |
144 void UpdateRegionLayoutTask::scheduleFor(NamedFlow* namedFlow, int documentNodeI
d) | |
145 { | |
146 m_namedFlows.add(namedFlow, documentNodeId); | |
147 | |
148 if (!m_timer.isActive()) | |
149 m_timer.startOneShot(0); | |
150 } | |
151 | |
152 void UpdateRegionLayoutTask::unschedule(NamedFlow* namedFlow) | |
153 { | |
154 m_namedFlows.remove(namedFlow); | |
155 } | |
156 | |
157 void UpdateRegionLayoutTask::reset() | |
158 { | |
159 m_timer.stop(); | |
160 m_namedFlows.clear(); | |
161 } | |
162 | |
163 void UpdateRegionLayoutTask::onTimer(Timer<UpdateRegionLayoutTask>*) | |
164 { | |
165 // The timer is stopped on m_cssAgent destruction, so this method will never
be called after m_cssAgent has been destroyed. | |
166 Vector<std::pair<NamedFlow*, int> > namedFlows; | |
167 | |
168 for (HashMap<NamedFlow*, int>::iterator it = m_namedFlows.begin(), end = m_n
amedFlows.end(); it != end; ++it) | |
169 namedFlows.append(std::make_pair(it->key, it->value)); | |
170 | |
171 for (unsigned i = 0, size = namedFlows.size(); i < size; ++i) { | |
172 NamedFlow* namedFlow = namedFlows.at(i).first; | |
173 int documentNodeId = namedFlows.at(i).second; | |
174 | |
175 if (m_namedFlows.contains(namedFlow)) { | |
176 m_cssAgent->regionLayoutUpdated(namedFlow, documentNodeId); | |
177 m_namedFlows.remove(namedFlow); | |
178 } | |
179 } | |
180 | |
181 if (!m_namedFlows.isEmpty() && !m_timer.isActive()) | |
182 m_timer.startOneShot(0); | |
183 } | |
184 | |
185 class ChangeRegionOversetTask { | |
186 public: | |
187 ChangeRegionOversetTask(InspectorCSSAgent*); | |
188 void scheduleFor(NamedFlow*, int documentNodeId); | |
189 void unschedule(NamedFlow*); | |
190 void reset(); | |
191 void onTimer(Timer<ChangeRegionOversetTask>*); | |
192 | |
193 private: | |
194 InspectorCSSAgent* m_cssAgent; | |
195 Timer<ChangeRegionOversetTask> m_timer; | |
196 HashMap<NamedFlow*, int> m_namedFlows; | |
197 }; | |
198 | |
199 ChangeRegionOversetTask::ChangeRegionOversetTask(InspectorCSSAgent* cssAgent) | |
200 : m_cssAgent(cssAgent) | |
201 , m_timer(this, &ChangeRegionOversetTask::onTimer) | |
202 { | |
203 } | |
204 | |
205 void ChangeRegionOversetTask::scheduleFor(NamedFlow* namedFlow, int documentNode
Id) | |
206 { | |
207 m_namedFlows.add(namedFlow, documentNodeId); | |
208 | |
209 if (!m_timer.isActive()) | |
210 m_timer.startOneShot(0); | |
211 } | |
212 | |
213 void ChangeRegionOversetTask::unschedule(NamedFlow* namedFlow) | |
214 { | |
215 m_namedFlows.remove(namedFlow); | |
216 } | |
217 | |
218 void ChangeRegionOversetTask::reset() | |
219 { | |
220 m_timer.stop(); | |
221 m_namedFlows.clear(); | |
222 } | |
223 | |
224 void ChangeRegionOversetTask::onTimer(Timer<ChangeRegionOversetTask>*) | |
225 { | |
226 // The timer is stopped on m_cssAgent destruction, so this method will never
be called after m_cssAgent has been destroyed. | |
227 for (HashMap<NamedFlow*, int>::iterator it = m_namedFlows.begin(), end = m_n
amedFlows.end(); it != end; ++it) | |
228 m_cssAgent->regionOversetChanged(it->key, it->value); | |
229 | |
230 m_namedFlows.clear(); | |
231 } | |
232 | |
233 class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action { | 121 class InspectorCSSAgent::StyleSheetAction : public InspectorHistory::Action { |
234 WTF_MAKE_NONCOPYABLE(StyleSheetAction); | 122 WTF_MAKE_NONCOPYABLE(StyleSheetAction); |
235 public: | 123 public: |
236 StyleSheetAction(const String& name, InspectorStyleSheet* styleSheet) | 124 StyleSheetAction(const String& name, InspectorStyleSheet* styleSheet) |
237 : InspectorHistory::Action(name) | 125 : InspectorHistory::Action(name) |
238 , m_styleSheet(styleSheet) | 126 , m_styleSheet(styleSheet) |
239 { | 127 { |
240 } | 128 } |
241 | 129 |
242 protected: | 130 protected: |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 m_idToInspectorStyleSheet.clear(); | 521 m_idToInspectorStyleSheet.clear(); |
634 m_cssStyleSheetToInspectorStyleSheet.clear(); | 522 m_cssStyleSheetToInspectorStyleSheet.clear(); |
635 m_frameToCSSStyleSheets.clear(); | 523 m_frameToCSSStyleSheets.clear(); |
636 m_nodeToInspectorStyleSheet.clear(); | 524 m_nodeToInspectorStyleSheet.clear(); |
637 m_documentToViaInspectorStyleSheet.clear(); | 525 m_documentToViaInspectorStyleSheet.clear(); |
638 resetNonPersistentData(); | 526 resetNonPersistentData(); |
639 } | 527 } |
640 | 528 |
641 void InspectorCSSAgent::resetNonPersistentData() | 529 void InspectorCSSAgent::resetNonPersistentData() |
642 { | 530 { |
643 m_namedFlowCollectionsRequested.clear(); | |
644 if (m_updateRegionLayoutTask) | |
645 m_updateRegionLayoutTask->reset(); | |
646 if (m_changeRegionOversetTask) | |
647 m_changeRegionOversetTask->reset(); | |
648 resetPseudoStates(); | 531 resetPseudoStates(); |
649 } | 532 } |
650 | 533 |
651 void InspectorCSSAgent::enable(ErrorString*, PassRefPtr<EnableCallback> prpCallb
ack) | 534 void InspectorCSSAgent::enable(ErrorString*, PassRefPtr<EnableCallback> prpCallb
ack) |
652 { | 535 { |
653 m_state->setBoolean(CSSAgentState::cssAgentEnabled, true); | 536 m_state->setBoolean(CSSAgentState::cssAgentEnabled, true); |
654 | 537 |
655 Vector<InspectorStyleSheet*> styleSheets; | 538 Vector<InspectorStyleSheet*> styleSheets; |
656 collectAllStyleSheets(styleSheets); | 539 collectAllStyleSheets(styleSheets); |
657 | 540 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 | 599 |
717 updateActiveStyleSheets(frame, Vector<CSSStyleSheet*>(), ExistingFrontendRef
resh); | 600 updateActiveStyleSheets(frame, Vector<CSSStyleSheet*>(), ExistingFrontendRef
resh); |
718 } | 601 } |
719 | 602 |
720 void InspectorCSSAgent::mediaQueryResultChanged() | 603 void InspectorCSSAgent::mediaQueryResultChanged() |
721 { | 604 { |
722 if (m_frontend) | 605 if (m_frontend) |
723 m_frontend->mediaQueryResultChanged(); | 606 m_frontend->mediaQueryResultChanged(); |
724 } | 607 } |
725 | 608 |
726 void InspectorCSSAgent::didCreateNamedFlow(Document* document, NamedFlow* namedF
low) | |
727 { | |
728 int documentNodeId = documentNodeWithRequestedFlowsId(document); | |
729 if (!documentNodeId) | |
730 return; | |
731 | |
732 ErrorString errorString; | |
733 m_frontend->namedFlowCreated(buildObjectForNamedFlow(&errorString, namedFlow
, documentNodeId)); | |
734 } | |
735 | |
736 void InspectorCSSAgent::willRemoveNamedFlow(Document* document, NamedFlow* named
Flow) | |
737 { | |
738 int documentNodeId = documentNodeWithRequestedFlowsId(document); | |
739 if (!documentNodeId) | |
740 return; | |
741 | |
742 if (m_updateRegionLayoutTask) | |
743 m_updateRegionLayoutTask->unschedule(namedFlow); | |
744 | |
745 m_frontend->namedFlowRemoved(documentNodeId, namedFlow->name().string()); | |
746 } | |
747 | |
748 void InspectorCSSAgent::willMutateRules() | 609 void InspectorCSSAgent::willMutateRules() |
749 { | 610 { |
750 ++m_styleSheetsPendingMutation; | 611 ++m_styleSheetsPendingMutation; |
751 } | 612 } |
752 | 613 |
753 void InspectorCSSAgent::didMutateRules(CSSStyleSheet* styleSheet) | 614 void InspectorCSSAgent::didMutateRules(CSSStyleSheet* styleSheet) |
754 { | 615 { |
755 --m_styleSheetsPendingMutation; | 616 --m_styleSheetsPendingMutation; |
756 ASSERT(m_styleSheetsPendingMutation >= 0); | 617 ASSERT(m_styleSheetsPendingMutation >= 0); |
757 | 618 |
(...skipping 14 matching lines...) Expand all Loading... |
772 ASSERT(m_styleDeclarationPendingMutation); | 633 ASSERT(m_styleDeclarationPendingMutation); |
773 m_styleDeclarationPendingMutation = false; | 634 m_styleDeclarationPendingMutation = false; |
774 if (!styleSheetEditInProgress() && !isInlineStyle) { | 635 if (!styleSheetEditInProgress() && !isInlineStyle) { |
775 CSSStyleSheet* parentSheet = style->parentStyleSheet(); | 636 CSSStyleSheet* parentSheet = style->parentStyleSheet(); |
776 Document* owner = parentSheet ? parentSheet->ownerDocument() : 0; | 637 Document* owner = parentSheet ? parentSheet->ownerDocument() : 0; |
777 if (owner) | 638 if (owner) |
778 owner->modifiedStyleSheet(parentSheet, RecalcStyleDeferred, FullStyl
eUpdate); | 639 owner->modifiedStyleSheet(parentSheet, RecalcStyleDeferred, FullStyl
eUpdate); |
779 } | 640 } |
780 } | 641 } |
781 | 642 |
782 void InspectorCSSAgent::didUpdateRegionLayout(Document* document, NamedFlow* nam
edFlow) | |
783 { | |
784 int documentNodeId = documentNodeWithRequestedFlowsId(document); | |
785 if (!documentNodeId) | |
786 return; | |
787 | |
788 if (!m_updateRegionLayoutTask) | |
789 m_updateRegionLayoutTask = adoptPtr(new UpdateRegionLayoutTask(this)); | |
790 m_updateRegionLayoutTask->scheduleFor(namedFlow, documentNodeId); | |
791 } | |
792 | |
793 void InspectorCSSAgent::regionLayoutUpdated(NamedFlow* namedFlow, int documentNo
deId) | |
794 { | |
795 if (namedFlow->flowState() == NamedFlow::FlowStateNull) | |
796 return; | |
797 | |
798 ErrorString errorString; | |
799 RefPtr<NamedFlow> protector(namedFlow); | |
800 | |
801 m_frontend->regionLayoutUpdated(buildObjectForNamedFlow(&errorString, namedF
low, documentNodeId)); | |
802 } | |
803 | |
804 void InspectorCSSAgent::didChangeRegionOverset(Document* document, NamedFlow* na
medFlow) | |
805 { | |
806 int documentNodeId = documentNodeWithRequestedFlowsId(document); | |
807 if (!documentNodeId) | |
808 return; | |
809 | |
810 if (!m_changeRegionOversetTask) | |
811 m_changeRegionOversetTask = adoptPtr(new ChangeRegionOversetTask(this)); | |
812 m_changeRegionOversetTask->scheduleFor(namedFlow, documentNodeId); | |
813 } | |
814 | |
815 void InspectorCSSAgent::regionOversetChanged(NamedFlow* namedFlow, int documentN
odeId) | |
816 { | |
817 if (namedFlow->flowState() == NamedFlow::FlowStateNull) | |
818 return; | |
819 | |
820 ErrorString errorString; | |
821 RefPtr<NamedFlow> protector(namedFlow); | |
822 | |
823 m_frontend->regionOversetChanged(buildObjectForNamedFlow(&errorString, named
Flow, documentNodeId)); | |
824 } | |
825 | |
826 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document) | 643 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document) |
827 { | 644 { |
828 if (styleSheetEditInProgress()) | 645 if (styleSheetEditInProgress()) |
829 return; | 646 return; |
830 updateActiveStyleSheetsForDocument(document, ExistingFrontendRefresh); | 647 updateActiveStyleSheetsForDocument(document, ExistingFrontendRefresh); |
831 } | 648 } |
832 | 649 |
833 void InspectorCSSAgent::updateActiveStyleSheetsForDocument(Document* document, S
tyleSheetsUpdateType styleSheetsUpdateType) | 650 void InspectorCSSAgent::updateActiveStyleSheetsForDocument(Document* document, S
tyleSheetsUpdateType styleSheetsUpdateType) |
834 { | 651 { |
835 Frame* frame = document->frame(); | 652 Frame* frame = document->frame(); |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 if (!needStyleRecalc) | 1078 if (!needStyleRecalc) |
1262 return; | 1079 return; |
1263 | 1080 |
1264 if (forcedPseudoState) | 1081 if (forcedPseudoState) |
1265 m_nodeIdToForcedPseudoState.set(nodeId, forcedPseudoState); | 1082 m_nodeIdToForcedPseudoState.set(nodeId, forcedPseudoState); |
1266 else | 1083 else |
1267 m_nodeIdToForcedPseudoState.remove(nodeId); | 1084 m_nodeIdToForcedPseudoState.remove(nodeId); |
1268 element->ownerDocument()->setNeedsStyleRecalc(); | 1085 element->ownerDocument()->setNeedsStyleRecalc(); |
1269 } | 1086 } |
1270 | 1087 |
1271 void InspectorCSSAgent::getNamedFlowCollection(ErrorString* errorString, int doc
umentNodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::NamedFlow> >& result) | |
1272 { | |
1273 Document* document = m_domAgent->assertDocument(errorString, documentNodeId)
; | |
1274 if (!document) | |
1275 return; | |
1276 | |
1277 m_namedFlowCollectionsRequested.add(documentNodeId); | |
1278 | |
1279 Vector<RefPtr<NamedFlow> > namedFlowsVector = document->namedFlows()->namedF
lows(); | |
1280 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::NamedFlow> > namedFlows = TypeBu
ilder::Array<TypeBuilder::CSS::NamedFlow>::create(); | |
1281 | |
1282 for (Vector<RefPtr<NamedFlow> >::iterator it = namedFlowsVector.begin(); it
!= namedFlowsVector.end(); ++it) | |
1283 namedFlows->addItem(buildObjectForNamedFlow(errorString, it->get(), docu
mentNodeId)); | |
1284 | |
1285 result = namedFlows.release(); | |
1286 } | |
1287 | |
1288 PassRefPtr<TypeBuilder::CSS::CSSMedia> InspectorCSSAgent::buildMediaObject(const
MediaList* media, MediaListSource mediaListSource, const String& sourceURL, CSS
StyleSheet* parentStyleSheet) | 1088 PassRefPtr<TypeBuilder::CSS::CSSMedia> InspectorCSSAgent::buildMediaObject(const
MediaList* media, MediaListSource mediaListSource, const String& sourceURL, CSS
StyleSheet* parentStyleSheet) |
1289 { | 1089 { |
1290 // Make certain compilers happy by initializing |source| up-front. | 1090 // Make certain compilers happy by initializing |source| up-front. |
1291 TypeBuilder::CSS::CSSMedia::Source::Enum source = TypeBuilder::CSS::CSSMedia
::Source::InlineSheet; | 1091 TypeBuilder::CSS::CSSMedia::Source::Enum source = TypeBuilder::CSS::CSSMedia
::Source::InlineSheet; |
1292 switch (mediaListSource) { | 1092 switch (mediaListSource) { |
1293 case MediaListSourceMediaRule: | 1093 case MediaListSourceMediaRule: |
1294 source = TypeBuilder::CSS::CSSMedia::Source::MediaRule; | 1094 source = TypeBuilder::CSS::CSSMedia::Source::MediaRule; |
1295 break; | 1095 break; |
1296 case MediaListSourceImportRule: | 1096 case MediaListSourceImportRule: |
1297 source = TypeBuilder::CSS::CSSMedia::Source::ImportRule; | 1097 source = TypeBuilder::CSS::CSSMedia::Source::ImportRule; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 *errorString = "No node with given id found"; | 1215 *errorString = "No node with given id found"; |
1416 return 0; | 1216 return 0; |
1417 } | 1217 } |
1418 if (!node->isElementNode()) { | 1218 if (!node->isElementNode()) { |
1419 *errorString = "Not an element node"; | 1219 *errorString = "Not an element node"; |
1420 return 0; | 1220 return 0; |
1421 } | 1221 } |
1422 return toElement(node); | 1222 return toElement(node); |
1423 } | 1223 } |
1424 | 1224 |
1425 int InspectorCSSAgent::documentNodeWithRequestedFlowsId(Document* document) | |
1426 { | |
1427 int documentNodeId = m_domAgent->boundNodeId(document); | |
1428 if (!documentNodeId || !m_namedFlowCollectionsRequested.contains(documentNod
eId)) | |
1429 return 0; | |
1430 | |
1431 return documentNodeId; | |
1432 } | |
1433 | |
1434 void InspectorCSSAgent::collectAllStyleSheets(Vector<InspectorStyleSheet*>& resu
lt) | 1225 void InspectorCSSAgent::collectAllStyleSheets(Vector<InspectorStyleSheet*>& resu
lt) |
1435 { | 1226 { |
1436 Vector<CSSStyleSheet*> cssStyleSheets; | 1227 Vector<CSSStyleSheet*> cssStyleSheets; |
1437 Vector<Document*> documents = m_domAgent->documents(); | 1228 Vector<Document*> documents = m_domAgent->documents(); |
1438 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end
(); ++it) | 1229 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end
(); ++it) |
1439 collectAllDocumentStyleSheets(*it, cssStyleSheets); | 1230 collectAllDocumentStyleSheets(*it, cssStyleSheets); |
1440 for (Vector<CSSStyleSheet*>::iterator it = cssStyleSheets.begin(); it != css
StyleSheets.end(); ++it) | 1231 for (Vector<CSSStyleSheet*>::iterator it = cssStyleSheets.begin(); it != css
StyleSheets.end(); ++it) |
1441 result.append(bindStyleSheet(*it)); | 1232 result.append(bindStyleSheet(*it)); |
1442 } | 1233 } |
1443 | 1234 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1647 StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(element->pr
esentationAttributeStyle()); | 1438 StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(element->pr
esentationAttributeStyle()); |
1648 if (!attributeStyle) | 1439 if (!attributeStyle) |
1649 return 0; | 1440 return 0; |
1650 | 1441 |
1651 MutableStylePropertySet* mutableAttributeStyle = toMutableStylePropertySet(a
ttributeStyle); | 1442 MutableStylePropertySet* mutableAttributeStyle = toMutableStylePropertySet(a
ttributeStyle); |
1652 | 1443 |
1653 RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSI
d(), mutableAttributeStyle->ensureCSSStyleDeclaration(), 0); | 1444 RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSI
d(), mutableAttributeStyle->ensureCSSStyleDeclaration(), 0); |
1654 return inspectorStyle->buildObjectForStyle(); | 1445 return inspectorStyle->buildObjectForStyle(); |
1655 } | 1446 } |
1656 | 1447 |
1657 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Region> > InspectorCSSAgent::bui
ldArrayForRegions(ErrorString* errorString, PassRefPtr<NodeList> regionList, int
documentNodeId) | |
1658 { | |
1659 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::Region> > regions = TypeBuilder:
:Array<TypeBuilder::CSS::Region>::create(); | |
1660 | |
1661 for (unsigned i = 0; i < regionList->length(); ++i) { | |
1662 TypeBuilder::CSS::Region::RegionOverset::Enum regionOverset; | |
1663 | |
1664 switch (toElement(regionList->item(i))->renderRegion()->regionOversetSta
te()) { | |
1665 case RegionFit: | |
1666 regionOverset = TypeBuilder::CSS::Region::RegionOverset::Fit; | |
1667 break; | |
1668 case RegionEmpty: | |
1669 regionOverset = TypeBuilder::CSS::Region::RegionOverset::Empty; | |
1670 break; | |
1671 case RegionOverset: | |
1672 regionOverset = TypeBuilder::CSS::Region::RegionOverset::Overset; | |
1673 break; | |
1674 case RegionUndefined: | |
1675 continue; | |
1676 default: | |
1677 ASSERT_NOT_REACHED(); | |
1678 continue; | |
1679 } | |
1680 | |
1681 RefPtr<TypeBuilder::CSS::Region> region = TypeBuilder::CSS::Region::crea
te() | |
1682 .setRegionOverset(regionOverset) | |
1683 // documentNodeId was previously asserted | |
1684 .setNodeId(m_domAgent->pushNodeToFrontend(errorString, documentNodeI
d, regionList->item(i))); | |
1685 | |
1686 regions->addItem(region); | |
1687 } | |
1688 | |
1689 return regions.release(); | |
1690 } | |
1691 | |
1692 PassRefPtr<TypeBuilder::CSS::NamedFlow> InspectorCSSAgent::buildObjectForNamedFl
ow(ErrorString* errorString, NamedFlow* webkitNamedFlow, int documentNodeId) | |
1693 { | |
1694 RefPtr<NodeList> contentList = webkitNamedFlow->getContent(); | |
1695 RefPtr<TypeBuilder::Array<int> > content = TypeBuilder::Array<int>::create()
; | |
1696 | |
1697 for (unsigned i = 0; i < contentList->length(); ++i) { | |
1698 // documentNodeId was previously asserted | |
1699 content->addItem(m_domAgent->pushNodeToFrontend(errorString, documentNod
eId, contentList->item(i))); | |
1700 } | |
1701 | |
1702 RefPtr<TypeBuilder::CSS::NamedFlow> namedFlow = TypeBuilder::CSS::NamedFlow:
:create() | |
1703 .setDocumentNodeId(documentNodeId) | |
1704 .setName(webkitNamedFlow->name().string()) | |
1705 .setOverset(webkitNamedFlow->overset()) | |
1706 .setContent(content) | |
1707 .setRegions(buildArrayForRegions(errorString, webkitNamedFlow->getRegion
s(), documentNodeId)); | |
1708 | |
1709 return namedFlow.release(); | |
1710 } | |
1711 | |
1712 void InspectorCSSAgent::didRemoveDocument(Document* document) | 1448 void InspectorCSSAgent::didRemoveDocument(Document* document) |
1713 { | 1449 { |
1714 if (document) | 1450 if (document) |
1715 m_documentToViaInspectorStyleSheet.remove(document); | 1451 m_documentToViaInspectorStyleSheet.remove(document); |
1716 } | 1452 } |
1717 | 1453 |
1718 void InspectorCSSAgent::didRemoveDOMNode(Node* node) | 1454 void InspectorCSSAgent::didRemoveDOMNode(Node* node) |
1719 { | 1455 { |
1720 if (!node) | 1456 if (!node) |
1721 return; | 1457 return; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1771 documentsToChange.add(element->ownerDocument()); | 1507 documentsToChange.add(element->ownerDocument()); |
1772 } | 1508 } |
1773 | 1509 |
1774 m_nodeIdToForcedPseudoState.clear(); | 1510 m_nodeIdToForcedPseudoState.clear(); |
1775 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1511 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
1776 (*it)->setNeedsStyleRecalc(); | 1512 (*it)->setNeedsStyleRecalc(); |
1777 } | 1513 } |
1778 | 1514 |
1779 } // namespace WebCore | 1515 } // namespace WebCore |
1780 | 1516 |
OLD | NEW |