OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. | 3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 StyleSheetContents* parent_sheet = ParentStyleSheet(); | 421 StyleSheetContents* parent_sheet = ParentStyleSheet(); |
422 if (parent_sheet) { | 422 if (parent_sheet) { |
423 parent_sheet->CheckLoaded(); | 423 parent_sheet->CheckLoaded(); |
424 return; | 424 return; |
425 } | 425 } |
426 | 426 |
427 DCHECK_EQ(this, RootStyleSheet()); | 427 DCHECK_EQ(this, RootStyleSheet()); |
428 if (loading_clients_.IsEmpty()) | 428 if (loading_clients_.IsEmpty()) |
429 return; | 429 return; |
430 | 430 |
431 // Avoid |CSSSStyleSheet| and |ownerNode| being deleted by scripts that run | 431 // Avoid |CSSSStyleSheet| and |OwnerNode| being deleted by scripts that run |
432 // via ScriptableDocumentParser::executeScriptsWaitingForResources(). Also | 432 // via ScriptableDocumentParser::ExecuteScriptsWaitingForResources(). Also |
433 // protect the |CSSStyleSheet| from being deleted during iteration via the | 433 // protect the |CSSStyleSheet| from being deleted during iteration via the |
434 // |sheetLoaded| method. | 434 // |SheetLoaded| method. |
435 // | 435 // |
436 // When a sheet is loaded it is moved from the set of loading clients | 436 // When a sheet is loaded it is moved from the set of loading clients |
437 // to the set of completed clients. We therefore need the copy in order to | 437 // to the set of completed clients. We therefore need the copy in order to |
438 // not modify the set while iterating it. | 438 // not modify the set while iterating it. |
439 HeapVector<Member<CSSStyleSheet>> loading_clients; | 439 HeapVector<Member<CSSStyleSheet>> loading_clients; |
440 CopyToVector(loading_clients_, loading_clients); | 440 CopyToVector(loading_clients_, loading_clients); |
441 | 441 |
442 for (unsigned i = 0; i < loading_clients.size(); ++i) { | 442 for (unsigned i = 0; i < loading_clients.size(); ++i) { |
443 if (loading_clients[i]->LoadCompleted()) | 443 if (loading_clients[i]->LoadCompleted()) |
444 continue; | 444 continue; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 } | 561 } |
562 | 562 |
563 StyleSheetContents* StyleSheetContents::ParentStyleSheet() const { | 563 StyleSheetContents* StyleSheetContents::ParentStyleSheet() const { |
564 return owner_rule_ ? owner_rule_->ParentStyleSheet() : nullptr; | 564 return owner_rule_ ? owner_rule_->ParentStyleSheet() : nullptr; |
565 } | 565 } |
566 | 566 |
567 void StyleSheetContents::RegisterClient(CSSStyleSheet* sheet) { | 567 void StyleSheetContents::RegisterClient(CSSStyleSheet* sheet) { |
568 DCHECK(!loading_clients_.Contains(sheet)); | 568 DCHECK(!loading_clients_.Contains(sheet)); |
569 DCHECK(!completed_clients_.Contains(sheet)); | 569 DCHECK(!completed_clients_.Contains(sheet)); |
570 | 570 |
571 // InspectorCSSAgent::buildObjectForRule creates CSSStyleSheet without any | 571 // InspectorCSSAgent::BuildObjectForRule creates CSSStyleSheet without any |
572 // owner node. | 572 // owner node. |
573 if (!sheet->OwnerDocument()) | 573 if (!sheet->OwnerDocument()) |
574 return; | 574 return; |
575 | 575 |
576 if (Document* document = ClientSingleOwnerDocument()) { | 576 if (Document* document = ClientSingleOwnerDocument()) { |
577 if (sheet->OwnerDocument() != document) | 577 if (sheet->OwnerDocument() != document) |
578 has_single_owner_document_ = false; | 578 has_single_owner_document_ = false; |
579 } | 579 } |
580 loading_clients_.insert(sheet); | 580 loading_clients_.insert(sheet); |
581 } | 581 } |
582 | 582 |
583 void StyleSheetContents::UnregisterClient(CSSStyleSheet* sheet) { | 583 void StyleSheetContents::UnregisterClient(CSSStyleSheet* sheet) { |
584 loading_clients_.erase(sheet); | 584 loading_clients_.erase(sheet); |
585 completed_clients_.erase(sheet); | 585 completed_clients_.erase(sheet); |
586 | 586 |
587 if (!sheet->OwnerDocument() || !loading_clients_.IsEmpty() || | 587 if (!sheet->OwnerDocument() || !loading_clients_.IsEmpty() || |
588 !completed_clients_.IsEmpty()) | 588 !completed_clients_.IsEmpty()) |
589 return; | 589 return; |
590 | 590 |
591 has_single_owner_document_ = true; | 591 has_single_owner_document_ = true; |
592 } | 592 } |
593 | 593 |
594 void StyleSheetContents::ClientLoadCompleted(CSSStyleSheet* sheet) { | 594 void StyleSheetContents::ClientLoadCompleted(CSSStyleSheet* sheet) { |
595 DCHECK(loading_clients_.Contains(sheet) || !sheet->OwnerDocument()); | 595 DCHECK(loading_clients_.Contains(sheet) || !sheet->OwnerDocument()); |
596 loading_clients_.erase(sheet); | 596 loading_clients_.erase(sheet); |
597 // In m_ownerNode->sheetLoaded, the CSSStyleSheet might be detached. | 597 // In owner_node_->SheetLoaded, the CSSStyleSheet might be detached. |
598 // (i.e. clearOwnerNode was invoked.) | 598 // (i.e. ClearOwnerNode was invoked.) |
599 // In this case, we don't need to add the stylesheet to completed clients. | 599 // In this case, we don't need to add the stylesheet to completed clients. |
600 if (!sheet->OwnerDocument()) | 600 if (!sheet->OwnerDocument()) |
601 return; | 601 return; |
602 completed_clients_.insert(sheet); | 602 completed_clients_.insert(sheet); |
603 } | 603 } |
604 | 604 |
605 void StyleSheetContents::ClientLoadStarted(CSSStyleSheet* sheet) { | 605 void StyleSheetContents::ClientLoadStarted(CSSStyleSheet* sheet) { |
606 DCHECK(completed_clients_.Contains(sheet)); | 606 DCHECK(completed_clients_.Contains(sheet)); |
607 completed_clients_.erase(sheet); | 607 completed_clients_.erase(sheet); |
608 loading_clients_.insert(sheet); | 608 loading_clients_.insert(sheet); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 visitor->Trace(namespace_rules_); | 704 visitor->Trace(namespace_rules_); |
705 visitor->Trace(child_rules_); | 705 visitor->Trace(child_rules_); |
706 visitor->Trace(loading_clients_); | 706 visitor->Trace(loading_clients_); |
707 visitor->Trace(completed_clients_); | 707 visitor->Trace(completed_clients_); |
708 visitor->Trace(rule_set_); | 708 visitor->Trace(rule_set_); |
709 visitor->Trace(referenced_from_resource_); | 709 visitor->Trace(referenced_from_resource_); |
710 visitor->Trace(parser_context_); | 710 visitor->Trace(parser_context_); |
711 } | 711 } |
712 | 712 |
713 } // namespace blink | 713 } // namespace blink |
OLD | NEW |