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

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

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

Powered by Google App Engine
This is Rietveld 408576698