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

Side by Side Diff: Source/core/inspector/InspectorCSSAgent.cpp

Issue 153233002: *** DO NOT LAND *** Remove regions support, keeping a bare minimum to support "region-based"... (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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) 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
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
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
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
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
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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 if (!needStyleRecalc) 1077 if (!needStyleRecalc)
1261 return; 1078 return;
1262 1079
1263 if (forcedPseudoState) 1080 if (forcedPseudoState)
1264 m_nodeIdToForcedPseudoState.set(nodeId, forcedPseudoState); 1081 m_nodeIdToForcedPseudoState.set(nodeId, forcedPseudoState);
1265 else 1082 else
1266 m_nodeIdToForcedPseudoState.remove(nodeId); 1083 m_nodeIdToForcedPseudoState.remove(nodeId);
1267 element->ownerDocument()->setNeedsStyleRecalc(); 1084 element->ownerDocument()->setNeedsStyleRecalc();
1268 } 1085 }
1269 1086
1270 void InspectorCSSAgent::getNamedFlowCollection(ErrorString* errorString, int doc umentNodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::NamedFlow> >& result)
1271 {
1272 Document* document = m_domAgent->assertDocument(errorString, documentNodeId) ;
1273 if (!document)
1274 return;
1275
1276 m_namedFlowCollectionsRequested.add(documentNodeId);
1277
1278 Vector<RefPtr<NamedFlow> > namedFlowsVector = document->namedFlows()->namedF lows();
1279 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::NamedFlow> > namedFlows = TypeBu ilder::Array<TypeBuilder::CSS::NamedFlow>::create();
1280
1281 for (Vector<RefPtr<NamedFlow> >::iterator it = namedFlowsVector.begin(); it != namedFlowsVector.end(); ++it)
1282 namedFlows->addItem(buildObjectForNamedFlow(errorString, it->get(), docu mentNodeId));
1283
1284 result = namedFlows.release();
1285 }
1286
1287 PassRefPtr<TypeBuilder::CSS::CSSMedia> InspectorCSSAgent::buildMediaObject(const MediaList* media, MediaListSource mediaListSource, const String& sourceURL, CSS StyleSheet* parentStyleSheet) 1087 PassRefPtr<TypeBuilder::CSS::CSSMedia> InspectorCSSAgent::buildMediaObject(const MediaList* media, MediaListSource mediaListSource, const String& sourceURL, CSS StyleSheet* parentStyleSheet)
1288 { 1088 {
1289 // Make certain compilers happy by initializing |source| up-front. 1089 // Make certain compilers happy by initializing |source| up-front.
1290 TypeBuilder::CSS::CSSMedia::Source::Enum source = TypeBuilder::CSS::CSSMedia ::Source::InlineSheet; 1090 TypeBuilder::CSS::CSSMedia::Source::Enum source = TypeBuilder::CSS::CSSMedia ::Source::InlineSheet;
1291 switch (mediaListSource) { 1091 switch (mediaListSource) {
1292 case MediaListSourceMediaRule: 1092 case MediaListSourceMediaRule:
1293 source = TypeBuilder::CSS::CSSMedia::Source::MediaRule; 1093 source = TypeBuilder::CSS::CSSMedia::Source::MediaRule;
1294 break; 1094 break;
1295 case MediaListSourceImportRule: 1095 case MediaListSourceImportRule:
1296 source = TypeBuilder::CSS::CSSMedia::Source::ImportRule; 1096 source = TypeBuilder::CSS::CSSMedia::Source::ImportRule;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 *errorString = "No node with given id found"; 1214 *errorString = "No node with given id found";
1415 return 0; 1215 return 0;
1416 } 1216 }
1417 if (!node->isElementNode()) { 1217 if (!node->isElementNode()) {
1418 *errorString = "Not an element node"; 1218 *errorString = "Not an element node";
1419 return 0; 1219 return 0;
1420 } 1220 }
1421 return toElement(node); 1221 return toElement(node);
1422 } 1222 }
1423 1223
1424 int InspectorCSSAgent::documentNodeWithRequestedFlowsId(Document* document)
1425 {
1426 int documentNodeId = m_domAgent->boundNodeId(document);
1427 if (!documentNodeId || !m_namedFlowCollectionsRequested.contains(documentNod eId))
1428 return 0;
1429
1430 return documentNodeId;
1431 }
1432
1433 void InspectorCSSAgent::collectAllStyleSheets(Vector<InspectorStyleSheet*>& resu lt) 1224 void InspectorCSSAgent::collectAllStyleSheets(Vector<InspectorStyleSheet*>& resu lt)
1434 { 1225 {
1435 Vector<CSSStyleSheet*> cssStyleSheets; 1226 Vector<CSSStyleSheet*> cssStyleSheets;
1436 Vector<Document*> documents = m_domAgent->documents(); 1227 Vector<Document*> documents = m_domAgent->documents();
1437 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end (); ++it) 1228 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end (); ++it)
1438 collectAllDocumentStyleSheets(*it, cssStyleSheets); 1229 collectAllDocumentStyleSheets(*it, cssStyleSheets);
1439 for (Vector<CSSStyleSheet*>::iterator it = cssStyleSheets.begin(); it != css StyleSheets.end(); ++it) 1230 for (Vector<CSSStyleSheet*>::iterator it = cssStyleSheets.begin(); it != css StyleSheets.end(); ++it)
1440 result.append(bindStyleSheet(*it)); 1231 result.append(bindStyleSheet(*it));
1441 } 1232 }
1442 1233
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(element->pr esentationAttributeStyle()); 1437 StylePropertySet* attributeStyle = const_cast<StylePropertySet*>(element->pr esentationAttributeStyle());
1647 if (!attributeStyle) 1438 if (!attributeStyle)
1648 return 0; 1439 return 0;
1649 1440
1650 MutableStylePropertySet* mutableAttributeStyle = toMutableStylePropertySet(a ttributeStyle); 1441 MutableStylePropertySet* mutableAttributeStyle = toMutableStylePropertySet(a ttributeStyle);
1651 1442
1652 RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSI d(), mutableAttributeStyle->ensureCSSStyleDeclaration(), 0); 1443 RefPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSI d(), mutableAttributeStyle->ensureCSSStyleDeclaration(), 0);
1653 return inspectorStyle->buildObjectForStyle(); 1444 return inspectorStyle->buildObjectForStyle();
1654 } 1445 }
1655 1446
1656 PassRefPtr<TypeBuilder::Array<TypeBuilder::CSS::Region> > InspectorCSSAgent::bui ldArrayForRegions(ErrorString* errorString, PassRefPtr<NodeList> regionList, int documentNodeId)
1657 {
1658 RefPtr<TypeBuilder::Array<TypeBuilder::CSS::Region> > regions = TypeBuilder: :Array<TypeBuilder::CSS::Region>::create();
1659
1660 for (unsigned i = 0; i < regionList->length(); ++i) {
1661 TypeBuilder::CSS::Region::RegionOverset::Enum regionOverset;
1662
1663 switch (toElement(regionList->item(i))->renderRegion()->regionOversetSta te()) {
1664 case RegionFit:
1665 regionOverset = TypeBuilder::CSS::Region::RegionOverset::Fit;
1666 break;
1667 case RegionEmpty:
1668 regionOverset = TypeBuilder::CSS::Region::RegionOverset::Empty;
1669 break;
1670 case RegionOverset:
1671 regionOverset = TypeBuilder::CSS::Region::RegionOverset::Overset;
1672 break;
1673 case RegionUndefined:
1674 continue;
1675 default:
1676 ASSERT_NOT_REACHED();
1677 continue;
1678 }
1679
1680 RefPtr<TypeBuilder::CSS::Region> region = TypeBuilder::CSS::Region::crea te()
1681 .setRegionOverset(regionOverset)
1682 // documentNodeId was previously asserted
1683 .setNodeId(m_domAgent->pushNodeToFrontend(errorString, documentNodeI d, regionList->item(i)));
1684
1685 regions->addItem(region);
1686 }
1687
1688 return regions.release();
1689 }
1690
1691 PassRefPtr<TypeBuilder::CSS::NamedFlow> InspectorCSSAgent::buildObjectForNamedFl ow(ErrorString* errorString, NamedFlow* webkitNamedFlow, int documentNodeId)
1692 {
1693 RefPtr<NodeList> contentList = webkitNamedFlow->getContent();
1694 RefPtr<TypeBuilder::Array<int> > content = TypeBuilder::Array<int>::create() ;
1695
1696 for (unsigned i = 0; i < contentList->length(); ++i) {
1697 // documentNodeId was previously asserted
1698 content->addItem(m_domAgent->pushNodeToFrontend(errorString, documentNod eId, contentList->item(i)));
1699 }
1700
1701 RefPtr<TypeBuilder::CSS::NamedFlow> namedFlow = TypeBuilder::CSS::NamedFlow: :create()
1702 .setDocumentNodeId(documentNodeId)
1703 .setName(webkitNamedFlow->name().string())
1704 .setOverset(webkitNamedFlow->overset())
1705 .setContent(content)
1706 .setRegions(buildArrayForRegions(errorString, webkitNamedFlow->getRegion s(), documentNodeId));
1707
1708 return namedFlow.release();
1709 }
1710
1711 void InspectorCSSAgent::didRemoveDocument(Document* document) 1447 void InspectorCSSAgent::didRemoveDocument(Document* document)
1712 { 1448 {
1713 if (document) 1449 if (document)
1714 m_documentToViaInspectorStyleSheet.remove(document); 1450 m_documentToViaInspectorStyleSheet.remove(document);
1715 } 1451 }
1716 1452
1717 void InspectorCSSAgent::didRemoveDOMNode(Node* node) 1453 void InspectorCSSAgent::didRemoveDOMNode(Node* node)
1718 { 1454 {
1719 if (!node) 1455 if (!node)
1720 return; 1456 return;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 documentsToChange.add(element->ownerDocument()); 1506 documentsToChange.add(element->ownerDocument());
1771 } 1507 }
1772 1508
1773 m_nodeIdToForcedPseudoState.clear(); 1509 m_nodeIdToForcedPseudoState.clear();
1774 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1510 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1775 (*it)->setNeedsStyleRecalc(); 1511 (*it)->setNeedsStyleRecalc();
1776 } 1512 }
1777 1513
1778 } // namespace WebCore 1514 } // namespace WebCore
1779 1515
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.h ('k') | Source/core/inspector/InspectorInstrumentation.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698