| 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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::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_frameToCSSStyleSheets.clear(); | 438 m_documentToCSSStyleSheets.clear(); |
| 439 m_nodeToInspectorStyleSheet.clear(); | 439 m_nodeToInspectorStyleSheet.clear(); |
| 440 m_documentToViaInspectorStyleSheet.clear(); | 440 m_documentToViaInspectorStyleSheet.clear(); |
| 441 resetNonPersistentData(); | 441 resetNonPersistentData(); |
| 442 } | 442 } |
| 443 | 443 |
| 444 void InspectorCSSAgent::resetNonPersistentData() | 444 void InspectorCSSAgent::resetNonPersistentData() |
| 445 { | 445 { |
| 446 resetPseudoStates(); | 446 resetPseudoStates(); |
| 447 } | 447 } |
| 448 | 448 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 483 |
| 484 void InspectorCSSAgent::wasEnabled(PassRefPtr<EnableCallback> callback) | 484 void InspectorCSSAgent::wasEnabled(PassRefPtr<EnableCallback> callback) |
| 485 { | 485 { |
| 486 if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) { | 486 if (!m_state->getBoolean(CSSAgentState::cssAgentEnabled)) { |
| 487 // We were disabled while fetching resources. | 487 // We were disabled while fetching resources. |
| 488 return; | 488 return; |
| 489 } | 489 } |
| 490 | 490 |
| 491 m_instrumentingAgents->setInspectorCSSAgent(this); | 491 m_instrumentingAgents->setInspectorCSSAgent(this); |
| 492 Vector<Document*> documents = m_domAgent->documents(); | 492 Vector<Document*> documents = m_domAgent->documents(); |
| 493 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end
(); ++it) { | 493 for (Vector<Document*>::iterator it = documents.begin(); it != documents.end
(); ++it) |
| 494 Document* document = *it; | 494 updateActiveStyleSheets(*it, InitialFrontendLoad); |
| 495 updateActiveStyleSheetsForDocument(document, InitialFrontendLoad); | |
| 496 } | |
| 497 | 495 |
| 498 if (callback) | 496 if (callback) |
| 499 callback->sendSuccess(); | 497 callback->sendSuccess(); |
| 500 } | 498 } |
| 501 | 499 |
| 502 void InspectorCSSAgent::disable(ErrorString*) | 500 void InspectorCSSAgent::disable(ErrorString*) |
| 503 { | 501 { |
| 504 m_instrumentingAgents->setInspectorCSSAgent(0); | 502 m_instrumentingAgents->setInspectorCSSAgent(0); |
| 505 m_state->setBoolean(CSSAgentState::cssAgentEnabled, false); | 503 m_state->setBoolean(CSSAgentState::cssAgentEnabled, false); |
| 506 } | 504 } |
| 507 | 505 |
| 508 void InspectorCSSAgent::didCommitLoad(LocalFrame* frame, DocumentLoader* loader) | 506 void InspectorCSSAgent::didCommitLoad(LocalFrame* frame, DocumentLoader* loader) |
| 509 { | 507 { |
| 510 if (loader->frame() == frame->page()->mainFrame()) { | 508 if (loader->frame() == frame->page()->mainFrame()) { |
| 511 reset(); | 509 reset(); |
| 512 return; | 510 return; |
| 513 } | 511 } |
| 514 | 512 |
| 515 updateActiveStyleSheets(frame, Vector<CSSStyleSheet*>(), ExistingFrontendRef
resh); | 513 for (DocumentStyleSheets::iterator it = m_documentToCSSStyleSheets.begin();
it != m_documentToCSSStyleSheets.end(); ++it) { |
| 514 Document* document = it->key; |
| 515 if (!document->frame() || document->frame() == frame) |
| 516 documentDisposed(document); |
| 517 } |
| 516 } | 518 } |
| 517 | 519 |
| 518 void InspectorCSSAgent::mediaQueryResultChanged() | 520 void InspectorCSSAgent::mediaQueryResultChanged() |
| 519 { | 521 { |
| 520 if (m_frontend) | 522 if (m_frontend) |
| 521 m_frontend->mediaQueryResultChanged(); | 523 m_frontend->mediaQueryResultChanged(); |
| 522 } | 524 } |
| 523 | 525 |
| 524 void InspectorCSSAgent::willMutateRules() | 526 void InspectorCSSAgent::willMutateRules() |
| 525 { | 527 { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 552 Document* owner = parentSheet ? parentSheet->ownerDocument() : 0; | 554 Document* owner = parentSheet ? parentSheet->ownerDocument() : 0; |
| 553 if (owner) | 555 if (owner) |
| 554 owner->modifiedStyleSheet(parentSheet, RecalcStyleDeferred, FullStyl
eUpdate); | 556 owner->modifiedStyleSheet(parentSheet, RecalcStyleDeferred, FullStyl
eUpdate); |
| 555 } | 557 } |
| 556 } | 558 } |
| 557 | 559 |
| 558 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document) | 560 void InspectorCSSAgent::activeStyleSheetsUpdated(Document* document) |
| 559 { | 561 { |
| 560 if (styleSheetEditInProgress()) | 562 if (styleSheetEditInProgress()) |
| 561 return; | 563 return; |
| 562 updateActiveStyleSheetsForDocument(document, ExistingFrontendRefresh); | 564 updateActiveStyleSheets(document, ExistingFrontendRefresh); |
| 563 } | 565 } |
| 564 | 566 |
| 565 void InspectorCSSAgent::updateActiveStyleSheetsForDocument(Document* document, S
tyleSheetsUpdateType styleSheetsUpdateType) | 567 void InspectorCSSAgent::updateActiveStyleSheets(Document* document, StyleSheetsU
pdateType styleSheetsUpdateType) |
| 566 { | 568 { |
| 567 LocalFrame* frame = document->frame(); | |
| 568 if (!frame) | |
| 569 return; | |
| 570 Vector<CSSStyleSheet*> newSheetsVector; | 569 Vector<CSSStyleSheet*> newSheetsVector; |
| 571 collectAllDocumentStyleSheets(document, newSheetsVector); | 570 collectAllDocumentStyleSheets(document, newSheetsVector); |
| 572 updateActiveStyleSheets(frame, newSheetsVector, styleSheetsUpdateType); | 571 setActiveStyleSheets(document, newSheetsVector, styleSheetsUpdateType); |
| 573 } | 572 } |
| 574 | 573 |
| 575 void InspectorCSSAgent::updateActiveStyleSheets(LocalFrame* frame, const Vector<
CSSStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) | 574 void InspectorCSSAgent::setActiveStyleSheets(Document* document, const Vector<CS
SStyleSheet*>& allSheetsVector, StyleSheetsUpdateType styleSheetsUpdateType) |
| 576 { | 575 { |
| 576 |
| 577 bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad; | 577 bool isInitialFrontendLoad = styleSheetsUpdateType == InitialFrontendLoad; |
| 578 | 578 |
| 579 HashSet<CSSStyleSheet*>* frameCSSStyleSheets = m_frameToCSSStyleSheets.get(f
rame); | 579 HashSet<CSSStyleSheet*>* documentCSSStyleSheets = m_documentToCSSStyleSheets
.get(document); |
| 580 if (!frameCSSStyleSheets) { | 580 if (!documentCSSStyleSheets) { |
| 581 frameCSSStyleSheets = new HashSet<CSSStyleSheet*>(); | 581 documentCSSStyleSheets = new HashSet<CSSStyleSheet*>(); |
| 582 OwnPtr<HashSet<CSSStyleSheet*> > frameCSSStyleSheetsPtr = adoptPtr(frame
CSSStyleSheets); | 582 OwnPtr<HashSet<CSSStyleSheet*> > documentCSSStyleSheetsPtr = adoptPtr(do
cumentCSSStyleSheets); |
| 583 m_frameToCSSStyleSheets.set(frame, frameCSSStyleSheetsPtr.release()); | 583 m_documentToCSSStyleSheets.set(document, documentCSSStyleSheetsPtr.relea
se()); |
| 584 } | 584 } |
| 585 | 585 |
| 586 HashSet<CSSStyleSheet*> removedSheets; | 586 HashSet<CSSStyleSheet*> removedSheets; |
| 587 for (HashSet<CSSStyleSheet*>::iterator it = frameCSSStyleSheets->begin(); it
!= frameCSSStyleSheets->end(); ++it) | 587 for (HashSet<CSSStyleSheet*>::iterator it = documentCSSStyleSheets->begin();
it != documentCSSStyleSheets->end(); ++it) |
| 588 removedSheets.add(*it); | 588 removedSheets.add(*it); |
| 589 | 589 |
| 590 HashSet<CSSStyleSheet*> addedSheets; | 590 HashSet<CSSStyleSheet*> addedSheets; |
| 591 for (Vector<CSSStyleSheet*>::const_iterator it = allSheetsVector.begin(); it
!= allSheetsVector.end(); ++it) { | 591 for (Vector<CSSStyleSheet*>::const_iterator it = allSheetsVector.begin(); it
!= allSheetsVector.end(); ++it) { |
| 592 CSSStyleSheet* cssStyleSheet = *it; | 592 CSSStyleSheet* cssStyleSheet = *it; |
| 593 if (removedSheets.contains(cssStyleSheet)) { | 593 if (removedSheets.contains(cssStyleSheet)) { |
| 594 removedSheets.remove(cssStyleSheet); | 594 removedSheets.remove(cssStyleSheet); |
| 595 if (isInitialFrontendLoad) | 595 if (isInitialFrontendLoad) |
| 596 addedSheets.add(cssStyleSheet); | 596 addedSheets.add(cssStyleSheet); |
| 597 } else { | 597 } else { |
| 598 addedSheets.add(cssStyleSheet); | 598 addedSheets.add(cssStyleSheet); |
| 599 } | 599 } |
| 600 } | 600 } |
| 601 | 601 |
| 602 for (HashSet<CSSStyleSheet*>::iterator it = removedSheets.begin(); it != rem
ovedSheets.end(); ++it) { | 602 for (HashSet<CSSStyleSheet*>::iterator it = removedSheets.begin(); it != rem
ovedSheets.end(); ++it) { |
| 603 CSSStyleSheet* cssStyleSheet = *it; | 603 CSSStyleSheet* cssStyleSheet = *it; |
| 604 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspe
ctorStyleSheet.get(cssStyleSheet); | 604 RefPtr<InspectorStyleSheet> inspectorStyleSheet = m_cssStyleSheetToInspe
ctorStyleSheet.get(cssStyleSheet); |
| 605 ASSERT(inspectorStyleSheet); | 605 ASSERT(inspectorStyleSheet); |
| 606 | 606 |
| 607 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { | 607 if (m_idToInspectorStyleSheet.contains(inspectorStyleSheet->id())) { |
| 608 String id = unbindStyleSheet(inspectorStyleSheet.get()); | 608 String id = unbindStyleSheet(inspectorStyleSheet.get()); |
| 609 frameCSSStyleSheets->remove(cssStyleSheet); | 609 documentCSSStyleSheets->remove(cssStyleSheet); |
| 610 if (m_frontend && !isInitialFrontendLoad) | 610 if (m_frontend && !isInitialFrontendLoad) |
| 611 m_frontend->styleSheetRemoved(id); | 611 m_frontend->styleSheetRemoved(id); |
| 612 } | 612 } |
| 613 } | 613 } |
| 614 | 614 |
| 615 for (HashSet<CSSStyleSheet*>::iterator it = addedSheets.begin(); it != added
Sheets.end(); ++it) { | 615 for (HashSet<CSSStyleSheet*>::iterator it = addedSheets.begin(); it != added
Sheets.end(); ++it) { |
| 616 CSSStyleSheet* cssStyleSheet = *it; | 616 CSSStyleSheet* cssStyleSheet = *it; |
| 617 bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSh
eet.contains(cssStyleSheet); | 617 bool isNew = isInitialFrontendLoad || !m_cssStyleSheetToInspectorStyleSh
eet.contains(cssStyleSheet); |
| 618 if (isNew) { | 618 if (isNew) { |
| 619 InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet); | 619 InspectorStyleSheet* newStyleSheet = bindStyleSheet(cssStyleSheet); |
| 620 frameCSSStyleSheets->add(cssStyleSheet); | 620 documentCSSStyleSheets->add(cssStyleSheet); |
| 621 if (m_frontend) | 621 if (m_frontend) |
| 622 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh
eetInfo()); | 622 m_frontend->styleSheetAdded(newStyleSheet->buildObjectForStyleSh
eetInfo()); |
| 623 } | 623 } |
| 624 } | 624 } |
| 625 | 625 |
| 626 if (frameCSSStyleSheets->isEmpty()) | 626 if (documentCSSStyleSheets->isEmpty()) |
| 627 m_frameToCSSStyleSheets.remove(frame); | 627 m_documentToCSSStyleSheets.remove(document); |
| 628 } |
| 629 |
| 630 void InspectorCSSAgent::documentDisposed(Document* document) |
| 631 { |
| 632 setActiveStyleSheets(document, Vector<CSSStyleSheet*>(), ExistingFrontendRef
resh); |
| 628 } | 633 } |
| 629 | 634 |
| 630 void InspectorCSSAgent::frameDetachedFromParent(LocalFrame* frame) | 635 void InspectorCSSAgent::frameDetachedFromParent(LocalFrame* frame) |
| 631 { | 636 { |
| 632 updateActiveStyleSheets(frame, Vector<CSSStyleSheet*>(), ExistingFrontendRef
resh); | 637 documentDisposed(frame->document()); |
| 633 } | 638 } |
| 634 | 639 |
| 635 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy
pe pseudoType) | 640 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoTy
pe pseudoType) |
| 636 { | 641 { |
| 637 if (m_nodeIdToForcedPseudoState.isEmpty()) | 642 if (m_nodeIdToForcedPseudoState.isEmpty()) |
| 638 return false; | 643 return false; |
| 639 | 644 |
| 640 int nodeId = m_domAgent->boundNodeId(element); | 645 int nodeId = m_domAgent->boundNodeId(element); |
| 641 if (!nodeId) | 646 if (!nodeId) |
| 642 return false; | 647 return false; |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 documentsToChange.add(element->ownerDocument()); | 1342 documentsToChange.add(element->ownerDocument()); |
| 1338 } | 1343 } |
| 1339 | 1344 |
| 1340 m_nodeIdToForcedPseudoState.clear(); | 1345 m_nodeIdToForcedPseudoState.clear(); |
| 1341 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) | 1346 for (HashSet<Document*>::iterator it = documentsToChange.begin(), end = docu
mentsToChange.end(); it != end; ++it) |
| 1342 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); | 1347 (*it)->setNeedsStyleRecalc(SubtreeStyleChange); |
| 1343 } | 1348 } |
| 1344 | 1349 |
| 1345 } // namespace WebCore | 1350 } // namespace WebCore |
| 1346 | 1351 |
| OLD | NEW |