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

Side by Side Diff: third_party/WebKit/Source/core/frame/UseCounter.cpp

Issue 1711703002: Add internals.isCSSPropertyUseCounted functionality (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
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
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 ASSERT(propertyID != CSSPropertyInvalid);
Timothy Loh 2016/02/24 03:40:35 this needs to be defensive if you don't want clust
nainar 2016/02/24 04:29:53 Done.
699 return host->useCounter().isCounted(propertyID);
700 }
701
683 void UseCounter::count(const ExecutionContext* context, Feature feature) 702 void UseCounter::count(const ExecutionContext* context, Feature feature)
684 { 703 {
685 if (!context) 704 if (!context)
686 return; 705 return;
687 if (context->isDocument()) { 706 if (context->isDocument()) {
688 count(*toDocument(context), feature); 707 count(*toDocument(context), feature);
689 return; 708 return;
690 } 709 }
691 if (context->isWorkerGlobalScope()) 710 if (context->isWorkerGlobalScope())
692 toWorkerGlobalScope(context)->countFeature(feature); 711 toWorkerGlobalScope(context)->countFeature(feature);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) 778 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents)
760 { 779 {
761 // FIXME: We may want to handle stylesheets that have multiple owners 780 // FIXME: We may want to handle stylesheets that have multiple owners
762 // https://crbug.com/242125 781 // https://crbug.com/242125
763 if (sheetContents && sheetContents->hasSingleOwnerNode()) 782 if (sheetContents && sheetContents->hasSingleOwnerNode())
764 return getFrom(sheetContents->singleOwnerDocument()); 783 return getFrom(sheetContents->singleOwnerDocument());
765 return 0; 784 return 0;
766 } 785 }
767 786
768 } // namespace blink 787 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698