OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google, Inc. All rights reserved. | 2 * Copyright (C) 2012 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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 { | 673 { |
674 Frame* frame = document.frame(); | 674 Frame* frame = document.frame(); |
675 if (!frame) | 675 if (!frame) |
676 return false; | 676 return false; |
677 FrameHost* host = frame->host(); | 677 FrameHost* host = frame->host(); |
678 if (!host) | 678 if (!host) |
679 return false; | 679 return false; |
680 return host->useCounter().hasRecordedMeasurement(feature); | 680 return host->useCounter().hasRecordedMeasurement(feature); |
681 } | 681 } |
682 | 682 |
683 bool UseCounter::isCounted(CSSPropertyID unresolvedProperty) | |
684 { | |
685 return m_CSSFeatureBits.quickGet(unresolvedProperty); | |
686 } | |
687 | |
688 | |
689 bool UseCounter::isCounted(Document& document, const String& string) | |
690 { | |
691 Frame* frame = document.frame(); | |
692 if (!frame) | |
693 return false; | |
694 FrameHost* host = frame->host(); | |
695 if (!host) | |
696 return false; | |
697 CSSPropertyID propertyID = cssPropertyID(string); | |
698 | |
699 if (propertyID != CSSPropertyInvalid) | |
Timothy Loh
2016/02/26 06:37:45
better to rearrange this so the success case is at
nainar
2016/02/26 06:59:55
Done.
| |
700 return host->useCounter().isCounted(propertyID); | |
701 return false; | |
702 } | |
703 | |
683 void UseCounter::count(const ExecutionContext* context, Feature feature) | 704 void UseCounter::count(const ExecutionContext* context, Feature feature) |
684 { | 705 { |
685 if (!context) | 706 if (!context) |
686 return; | 707 return; |
687 if (context->isDocument()) { | 708 if (context->isDocument()) { |
688 count(*toDocument(context), feature); | 709 count(*toDocument(context), feature); |
689 return; | 710 return; |
690 } | 711 } |
691 if (context->isWorkerGlobalScope()) | 712 if (context->isWorkerGlobalScope()) |
692 toWorkerGlobalScope(context)->countFeature(feature); | 713 toWorkerGlobalScope(context)->countFeature(feature); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
759 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) | 780 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) |
760 { | 781 { |
761 // FIXME: We may want to handle stylesheets that have multiple owners | 782 // FIXME: We may want to handle stylesheets that have multiple owners |
762 // https://crbug.com/242125 | 783 // https://crbug.com/242125 |
763 if (sheetContents && sheetContents->hasSingleOwnerNode()) | 784 if (sheetContents && sheetContents->hasSingleOwnerNode()) |
764 return getFrom(sheetContents->singleOwnerDocument()); | 785 return getFrom(sheetContents->singleOwnerDocument()); |
765 return 0; | 786 return 0; |
766 } | 787 } |
767 | 788 |
768 } // namespace blink | 789 } // namespace blink |
OLD | NEW |