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

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: 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
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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::reset() 434 void InspectorCSSAgent::reset()
435 { 435 {
436 m_idToInspectorStyleSheet.clear(); 436 m_idToInspectorStyleSheet.clear();
437 m_cssStyleSheetToInspectorStyleSheet.clear(); 437 m_cssStyleSheetToInspectorStyleSheet.clear();
438 m_documentToCSSStyleSheets.clear(); 438 m_documentToCSSStyleSheets.clear();
439 m_invalidatedDocuments.clear();
439 m_nodeToInspectorStyleSheet.clear(); 440 m_nodeToInspectorStyleSheet.clear();
440 m_documentToViaInspectorStyleSheet.clear(); 441 m_documentToViaInspectorStyleSheet.clear();
441 resetNonPersistentData(); 442 resetNonPersistentData();
442 } 443 }
443 444
444 void InspectorCSSAgent::resetNonPersistentData() 445 void InspectorCSSAgent::resetNonPersistentData()
445 { 446 {
446 resetPseudoStates(); 447 resetPseudoStates();
447 } 448 }
448 449
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 513
513 for (DocumentStyleSheets::iterator it = m_documentToCSSStyleSheets.begin(); it != m_documentToCSSStyleSheets.end(); ++it) { 514 for (DocumentStyleSheets::iterator it = m_documentToCSSStyleSheets.begin(); it != m_documentToCSSStyleSheets.end(); ++it) {
514 Document* document = it->key; 515 Document* document = it->key;
515 if (!document->frame() || document->frame() == frame) 516 if (!document->frame() || document->frame() == frame)
516 documentDisposed(document); 517 documentDisposed(document);
517 } 518 }
518 } 519 }
519 520
520 void InspectorCSSAgent::mediaQueryResultChanged() 521 void InspectorCSSAgent::mediaQueryResultChanged()
521 { 522 {
522 if (m_frontend) 523 validateFrontendStylesheets();
523 m_frontend->mediaQueryResultChanged(); 524 m_frontend->mediaQueryResultChanged();
524 } 525 }
525 526
526 void InspectorCSSAgent::willMutateRules() 527 void InspectorCSSAgent::willMutateRules()
527 { 528 {
528 ++m_styleSheetsPendingMutation; 529 ++m_styleSheetsPendingMutation;
529 } 530 }
530 531
531 void InspectorCSSAgent::didMutateRules(CSSStyleSheet* styleSheet) 532 void InspectorCSSAgent::didMutateRules(CSSStyleSheet* styleSheet)
532 { 533 {
533 --m_styleSheetsPendingMutation; 534 --m_styleSheetsPendingMutation;
(...skipping 16 matching lines...) Expand all
550 ASSERT(m_styleDeclarationPendingMutation); 551 ASSERT(m_styleDeclarationPendingMutation);
551 m_styleDeclarationPendingMutation = false; 552 m_styleDeclarationPendingMutation = false;
552 if (!styleSheetEditInProgress() && !isInlineStyle) { 553 if (!styleSheetEditInProgress() && !isInlineStyle) {
553 CSSStyleSheet* parentSheet = style->parentStyleSheet(); 554 CSSStyleSheet* parentSheet = style->parentStyleSheet();
554 Document* owner = parentSheet ? parentSheet->ownerDocument() : 0; 555 Document* owner = parentSheet ? parentSheet->ownerDocument() : 0;
555 if (owner) 556 if (owner)
556 owner->modifiedStyleSheet(parentSheet, RecalcStyleDeferred, FullStyl eUpdate); 557 owner->modifiedStyleSheet(parentSheet, RecalcStyleDeferred, FullStyl eUpdate);
557 } 558 }
558 } 559 }
559 560
561 void InspectorCSSAgent::didProcessTask()
562 {
563 validateFrontendStylesheets();
564 }
565
560 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document) 566 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document)
561 { 567 {
562 if (styleSheetEditInProgress()) 568 if (styleSheetEditInProgress())
563 return; 569 return;
564 updateActiveStyleSheets(document, ExistingFrontendRefresh); 570 m_invalidatedDocuments.add(document);
571 if (m_creatingViaInspectorStyleSheet)
572 validateFrontendStylesheets();
565 } 573 }
566 574
567 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU pdateType styleSheetsUpdateType) 575 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU pdateType styleSheetsUpdateType)
568 { 576 {
569 Vector<CSSStyleSheet*> newSheetsVector; 577 Vector<CSSStyleSheet*> newSheetsVector;
570 collectAllDocumentStyleSheets(document, newSheetsVector); 578 collectAllDocumentStyleSheets(document, newSheetsVector);
571 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType); 579 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType);
572 } 580 }
573 581
574 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CS SStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) 582 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CS SStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 documentCSSStyleSheets->add(cssStyleSheet); 627 documentCSSStyleSheets->add(cssStyleSheet);
620 if (m_frontend) 628 if (m_frontend)
621 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh eetInfo()); 629 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh eetInfo());
622 } 630 }
623 } 631 }
624 632
625 if (documentCSSStyleSheets->isEmpty()) 633 if (documentCSSStyleSheets->isEmpty())
626 m_documentToCSSStyleSheets.remove(document); 634 m_documentToCSSStyleSheets.remove(document);
627 } 635 }
628 636
637 void InspectorCSSAgent::validateFrontendStylesheets()
638 {
639 if (!m_invalidatedDocuments.size())
640 return;
641 HashSet<Document*> invalidatedDocuments;
642 m_invalidatedDocuments.swap(&invalidatedDocuments);
643 for (HashSet<Document*>::iterator it = invalidatedDocuments.begin(); it != i nvalidatedDocuments.end(); ++it)
644 updateActiveStyleSheets(*it, ExistingFrontendRefresh);
645 }
646
629 void InspectorCSSAgent::documentDisposed(Document* document) 647 void InspectorCSSAgent::documentDisposed(Document* document)
630 { 648 {
649 m_invalidatedDocuments.remove(document);
631 setActiveStyleSheets(document, Vector<CSSStyleSheet*>(), ExistingFrontendRef resh); 650 setActiveStyleSheets(document, Vector<CSSStyleSheet*>(), ExistingFrontendRef resh);
632 } 651 }
633 652
634 void InspectorCSSAgent::frameDetachedFromParent(LocalFrame* frame) 653 void InspectorCSSAgent::frameDetachedFromParent(LocalFrame* frame)
635 { 654 {
636 documentDisposed(frame->document()); 655 documentDisposed(frame->document());
637 } 656 }
638 657
639 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy pe pseudoType) 658 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy pe pseudoType)
640 { 659 {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 *errorString = "Frame does not have a document"; 908 *errorString = "Frame does not have a document";
890 return; 909 return;
891 } 910 }
892 911
893 InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(document, true); 912 InspectorStyleSheet* inspectorStyleSheet = viaInspectorStyleSheet(document, true);
894 if (!inspectorStyleSheet) { 913 if (!inspectorStyleSheet) {
895 *errorString = "No target stylesheet found"; 914 *errorString = "No target stylesheet found";
896 return; 915 return;
897 } 916 }
898 917
918 updateActiveStyleSheets(document, ExistingFrontendRefresh);
vsevik 2014/03/17 12:49:28 remove
919
899 *outStyleSheetId = inspectorStyleSheet->id(); 920 *outStyleSheetId = inspectorStyleSheet->id();
900 } 921 }
901 922
902 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result) 923 void InspectorCSSAgent::addRule(ErrorString* errorString, const String& styleShe etId, const String& selector, RefPtr<TypeBuilder::CSS::CSSRule>& result)
903 { 924 {
904 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , styleSheetId); 925 InspectorStyleSheet* inspectorStyleSheet = assertStyleSheetForId(errorString , styleSheetId);
905 if (!inspectorStyleSheet) 926 if (!inspectorStyleSheet)
906 return; 927 return;
907 928
908 TrackExceptionState exceptionState; 929 TrackExceptionState exceptionState;
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 1330
1310 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el ement); 1331 NodeToInspectorStyleSheet::iterator it = m_nodeToInspectorStyleSheet.find(el ement);
1311 if (it == m_nodeToInspectorStyleSheet.end()) 1332 if (it == m_nodeToInspectorStyleSheet.end())
1312 return; 1333 return;
1313 1334
1314 it->value->didModifyElementAttribute(); 1335 it->value->didModifyElementAttribute();
1315 } 1336 }
1316 1337
1317 void InspectorCSSAgent::styleSheetChanged(InspectorStyleSheet* styleSheet) 1338 void InspectorCSSAgent::styleSheetChanged(InspectorStyleSheet* styleSheet)
1318 { 1339 {
1319 if (m_frontend) 1340 validateFrontendStylesheets();
1320 m_frontend->styleSheetChanged(styleSheet->id()); 1341 m_frontend->styleSheetChanged(styleSheet->id());
1321 } 1342 }
1322 1343
1323 void InspectorCSSAgent::willReparseStyleSheet() 1344 void InspectorCSSAgent::willReparseStyleSheet()
1324 { 1345 {
1325 ASSERT(!m_isSettingStyleSheetText); 1346 ASSERT(!m_isSettingStyleSheetText);
1326 m_isSettingStyleSheetText = true; 1347 m_isSettingStyleSheetText = true;
1327 } 1348 }
1328 1349
1329 void InspectorCSSAgent::didReparseStyleSheet() 1350 void InspectorCSSAgent::didReparseStyleSheet()
1330 { 1351 {
(...skipping 10 matching lines...) Expand all
1341 documentsToChange.add(element->ownerDocument()); 1362 documentsToChange.add(element->ownerDocument());
1342 } 1363 }
1343 1364
1344 m_nodeIdToForcedPseudoState.clear(); 1365 m_nodeIdToForcedPseudoState.clear();
1345 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it) 1366 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu mentsToChange.end(); it != end; ++it)
1346 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); 1367 (*it)->setNeedsStyleRecalc(SubtreeStyleChange);
1347 } 1368 }
1348 1369
1349 } // namespace WebCore 1370 } // namespace WebCore
1350 1371
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorCSSAgent.h ('k') | Source/core/inspector/InspectorController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698