| 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 m_domAgent->setDOMListener(0); | 424 m_domAgent->setDOMListener(0); |
| 425 m_domAgent = 0; | 425 m_domAgent = 0; |
| 426 } | 426 } |
| 427 | 427 |
| 428 void InspectorCSSAgent::restore() | 428 void InspectorCSSAgent::restore() |
| 429 { | 429 { |
| 430 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) | 430 if (m_state->getBoolean(CSSAgentState::cssAgentEnabled)) |
| 431 wasEnabled(nullptr); | 431 wasEnabled(nullptr); |
| 432 } | 432 } |
| 433 | 433 |
| 434 void InspectorCSSAgent::flushPendingFrontendMessages() | |
| 435 { | |
| 436 if (!m_invalidatedDocuments.size()) | |
| 437 return; | |
| 438 HashSet<Document*> invalidatedDocuments; | |
| 439 m_invalidatedDocuments.swap(&invalidatedDocuments); | |
| 440 for (HashSet<Document*>::iterator it = invalidatedDocuments.begin(); it != i
nvalidatedDocuments.end(); ++it) | |
| 441 updateActiveStyleSheets(*it, ExistingFrontendRefresh); | |
| 442 } | |
| 443 | |
| 444 void InspectorCSSAgent::reset() | 434 void InspectorCSSAgent::reset() |
| 445 { | 435 { |
| 446 m_idToInspectorStyleSheet.clear(); | 436 m_idToInspectorStyleSheet.clear(); |
| 447 m_cssStyleSheetToInspectorStyleSheet.clear(); | 437 m_cssStyleSheetToInspectorStyleSheet.clear(); |
| 448 m_documentToCSSStyleSheets.clear(); | 438 m_documentToCSSStyleSheets.clear(); |
| 449 m_invalidatedDocuments.clear(); | |
| 450 m_nodeToInspectorStyleSheet.clear(); | 439 m_nodeToInspectorStyleSheet.clear(); |
| 451 m_documentToViaInspectorStyleSheet.clear(); | 440 m_documentToViaInspectorStyleSheet.clear(); |
| 452 resetNonPersistentData(); | 441 resetNonPersistentData(); |
| 453 } | 442 } |
| 454 | 443 |
| 455 void InspectorCSSAgent::resetNonPersistentData() | 444 void InspectorCSSAgent::resetNonPersistentData() |
| 456 { | 445 { |
| 457 resetPseudoStates(); | 446 resetPseudoStates(); |
| 458 } | 447 } |
| 459 | 448 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 | 512 |
| 524 for (DocumentStyleSheets::iterator it = m_documentToCSSStyleSheets.begin();
it != m_documentToCSSStyleSheets.end(); ++it) { | 513 for (DocumentStyleSheets::iterator it = m_documentToCSSStyleSheets.begin();
it != m_documentToCSSStyleSheets.end(); ++it) { |
| 525 Document* document = it->key; | 514 Document* document = it->key; |
| 526 if (!document->frame() || document->frame() == frame) | 515 if (!document->frame() || document->frame() == frame) |
| 527 documentDisposed(document); | 516 documentDisposed(document); |
| 528 } | 517 } |
| 529 } | 518 } |
| 530 | 519 |
| 531 void InspectorCSSAgent::mediaQueryResultChanged() | 520 void InspectorCSSAgent::mediaQueryResultChanged() |
| 532 { | 521 { |
| 533 flushPendingFrontendMessages(); | 522 if (m_frontend) |
| 534 m_frontend->mediaQueryResultChanged(); | 523 m_frontend->mediaQueryResultChanged(); |
| 535 } | 524 } |
| 536 | 525 |
| 537 void InspectorCSSAgent::willMutateRules() | 526 void InspectorCSSAgent::willMutateRules() |
| 538 { | 527 { |
| 539 ++m_styleSheetsPendingMutation; | 528 ++m_styleSheetsPendingMutation; |
| 540 } | 529 } |
| 541 | 530 |
| 542 void InspectorCSSAgent::didMutateRules(CSSStyleSheet* styleSheet) | 531 void InspectorCSSAgent::didMutateRules(CSSStyleSheet* styleSheet) |
| 543 { | 532 { |
| 544 --m_styleSheetsPendingMutation; | 533 --m_styleSheetsPendingMutation; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 565 Document* owner = parentSheet ? parentSheet->ownerDocument() : 0; | 554 Document* owner = parentSheet ? parentSheet->ownerDocument() : 0; |
| 566 if (owner) | 555 if (owner) |
| 567 owner->modifiedStyleSheet(parentSheet, RecalcStyleDeferred, FullStyl
eUpdate); | 556 owner->modifiedStyleSheet(parentSheet, RecalcStyleDeferred, FullStyl
eUpdate); |
| 568 } | 557 } |
| 569 } | 558 } |
| 570 | 559 |
| 571 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document) | 560 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document) |
| 572 { | 561 { |
| 573 if (styleSheetEditInProgress()) | 562 if (styleSheetEditInProgress()) |
| 574 return; | 563 return; |
| 575 m_invalidatedDocuments.add(document); | 564 updateActiveStyleSheets(document, ExistingFrontendRefresh); |
| 576 if (m_creatingViaInspectorStyleSheet) | |
| 577 flushPendingFrontendMessages(); | |
| 578 } | 565 } |
| 579 | 566 |
| 580 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU
pdateType styleSheetsUpdateType) | 567 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU
pdateType styleSheetsUpdateType) |
| 581 { | 568 { |
| 582 Vector<CSSStyleSheet*> newSheetsVector; | 569 Vector<CSSStyleSheet*> newSheetsVector; |
| 583 collectAllDocumentStyleSheets(document, newSheetsVector); | 570 collectAllDocumentStyleSheets(document, newSheetsVector); |
| 584 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType); | 571 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType); |
| 585 } | 572 } |
| 586 | 573 |
| 587 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CS
SStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) | 574 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CS
SStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh
eetInfo()); | 621 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh
eetInfo()); |
| 635 } | 622 } |
| 636 } | 623 } |
| 637 | 624 |
| 638 if (documentCSSStyleSheets->isEmpty()) | 625 if (documentCSSStyleSheets->isEmpty()) |
| 639 m_documentToCSSStyleSheets.remove(document); | 626 m_documentToCSSStyleSheets.remove(document); |
| 640 } | 627 } |
| 641 | 628 |
| 642 void InspectorCSSAgent::documentDisposed(Document* document) | 629 void InspectorCSSAgent::documentDisposed(Document* document) |
| 643 { | 630 { |
| 644 m_invalidatedDocuments.remove(document); | |
| 645 setActiveStyleSheets(document, Vector<CSSStyleSheet*>(), ExistingFrontendRef
resh); | 631 setActiveStyleSheets(document, Vector<CSSStyleSheet*>(), ExistingFrontendRef
resh); |
| 646 } | 632 } |
| 647 | 633 |
| 648 void InspectorCSSAgent::frameDetachedFromParent(LocalFrame* frame) | 634 void InspectorCSSAgent::frameDetachedFromParent(LocalFrame* frame) |
| 649 { | 635 { |
| 650 documentDisposed(frame->document()); | 636 documentDisposed(frame->document()); |
| 651 } | 637 } |
| 652 | 638 |
| 653 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy
pe pseudoType) | 639 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy
pe pseudoType) |
| 654 { | 640 { |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 903 *errorString = "Frame does not have a document"; | 889 *errorString = "Frame does not have a document"; |
| 904 return; | 890 return; |
| 905 } | 891 } |
| 906 | 892 |
| 907 InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(document,
true); | 893 InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(document,
true); |
| 908 if (!inspectorStyleSheet) { | 894 if (!inspectorStyleSheet) { |
| 909 *errorString = "No target stylesheet found"; | 895 *errorString = "No target stylesheet found"; |
| 910 return; | 896 return; |
| 911 } | 897 } |
| 912 | 898 |
| 913 updateActiveStyleSheets(document, ExistingFrontendRefresh); | |
| 914 | |
| 915 *outStyleSheetId = inspectorStyleSheet->id(); | 899 *outStyleSheetId = inspectorStyleSheet->id(); |
| 916 } | 900 } |
| 917 | 901 |
| 918 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe
etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) | 902 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe
etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) |
| 919 { | 903 { |
| 920 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, styleSheetId); | 904 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString
, styleSheetId); |
| 921 if (!inspectorStyleSheet) | 905 if (!inspectorStyleSheet) |
| 922 return; | 906 return; |
| 923 | 907 |
| 924 TrackExceptionState exceptionState; | 908 TrackExceptionState exceptionState; |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 | 1309 |
| 1326 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); | 1310 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el
ement); |
| 1327 if (it == m_nodeToInspectorStyleSheet.end()) | 1311 if (it == m_nodeToInspectorStyleSheet.end()) |
| 1328 return; | 1312 return; |
| 1329 | 1313 |
| 1330 it->value->didModifyElementAttribute(); | 1314 it->value->didModifyElementAttribute(); |
| 1331 } | 1315 } |
| 1332 | 1316 |
| 1333 void InspectorCSSAgent::styleSheetChanged(InspectorStyleSheet* styleSheet) | 1317 void InspectorCSSAgent::styleSheetChanged(InspectorStyleSheet* styleSheet) |
| 1334 { | 1318 { |
| 1335 flushPendingFrontendMessages(); | 1319 if (m_frontend) |
| 1336 m_frontend->styleSheetChanged(styleSheet->id()); | 1320 m_frontend->styleSheetChanged(styleSheet->id()); |
| 1337 } | 1321 } |
| 1338 | 1322 |
| 1339 void InspectorCSSAgent::willReparseStyleSheet() | 1323 void InspectorCSSAgent::willReparseStyleSheet() |
| 1340 { | 1324 { |
| 1341 ASSERT(!m_isSettingStyleSheetText); | 1325 ASSERT(!m_isSettingStyleSheetText); |
| 1342 m_isSettingStyleSheetText = true; | 1326 m_isSettingStyleSheetText = true; |
| 1343 } | 1327 } |
| 1344 | 1328 |
| 1345 void InspectorCSSAgent::didReparseStyleSheet() | 1329 void InspectorCSSAgent::didReparseStyleSheet() |
| 1346 { | 1330 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1357 documentsToChange.add(element->ownerDocument()); | 1341 documentsToChange.add(element->ownerDocument()); |
| 1358 } | 1342 } |
| 1359 | 1343 |
| 1360 m_nodeIdToForcedPseudoState.clear(); | 1344 m_nodeIdToForcedPseudoState.clear(); |
| 1361 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1345 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
| 1362 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1346 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1363 } | 1347 } |
| 1364 | 1348 |
| 1365 } // namespace WebCore | 1349 } // namespace WebCore |
| 1366 | 1350 |
| OLD | NEW |