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 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
699 if (!host) | 699 if (!host) |
700 return; | 700 return; |
701 | 701 |
702 if (!host->useCounter().hasRecordedMeasurement(feature)) { | 702 if (!host->useCounter().hasRecordedMeasurement(feature)) { |
703 host->useCounter().recordMeasurement(feature); | 703 host->useCounter().recordMeasurement(feature); |
704 ASSERT(!deprecationMessage(feature).isEmpty()); | 704 ASSERT(!deprecationMessage(feature).isEmpty()); |
705 frame->console().addMessage(ConsoleMessage::create(DeprecationMessageSou rce, WarningMessageLevel, deprecationMessage(feature))); | 705 frame->console().addMessage(ConsoleMessage::create(DeprecationMessageSou rce, WarningMessageLevel, deprecationMessage(feature))); |
706 } | 706 } |
707 } | 707 } |
708 | 708 |
709 void UseCounter::countDeprecation(LocalFrame* frame, CSSPropertyID cssPropertyID ) | |
alancutter (OOO until 2018)
2016/01/18 04:00:44
const LocalFrame*.
nainar
2016/01/18 06:09:55
Done.
| |
710 { | |
711 if (!frame) | |
712 return; | |
713 FrameHost* host = frame->host(); | |
alancutter (OOO until 2018)
2016/01/18 04:00:44
No need for local variable.
nainar
2016/01/18 06:09:55
Done.
| |
714 if (!host) | |
alancutter (OOO until 2018)
2016/01/18 04:00:44
You can merge these two ifs together.
nainar
2016/01/18 06:09:55
Done.
| |
715 return; | |
716 | |
717 if (!deprecationMessage(cssPropertyID).isEmpty()) | |
alancutter (OOO until 2018)
2016/01/18 04:00:44
Avoid calling deprecationMessage() twice.
nainar
2016/01/18 06:09:55
Done.
| |
718 frame->console().addMessage(ConsoleMessage::create(DeprecationMessageSou rce, WarningMessageLevel, deprecationMessage(cssPropertyID))); | |
719 } | |
720 | |
709 void UseCounter::countDeprecation(ExecutionContext* context, Feature feature) | 721 void UseCounter::countDeprecation(ExecutionContext* context, Feature feature) |
710 { | 722 { |
711 if (!context) | 723 if (!context) |
712 return; | 724 return; |
713 if (context->isDocument()) { | 725 if (context->isDocument()) { |
714 UseCounter::countDeprecation(*toDocument(context), feature); | 726 UseCounter::countDeprecation(*toDocument(context), feature); |
715 return; | 727 return; |
716 } | 728 } |
717 if (context->isWorkerGlobalScope()) | 729 if (context->isWorkerGlobalScope()) |
718 toWorkerGlobalScope(context)->countDeprecation(feature); | 730 toWorkerGlobalScope(context)->countDeprecation(feature); |
719 } | 731 } |
720 | 732 |
721 void UseCounter::countDeprecation(const Document& document, Feature feature) | 733 void UseCounter::countDeprecation(const Document& document, Feature feature) |
722 { | 734 { |
723 UseCounter::countDeprecation(document.frame(), feature); | 735 UseCounter::countDeprecation(document.frame(), feature); |
724 } | 736 } |
725 | 737 |
726 void UseCounter::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, Execut ionContext* context, Feature feature) | 738 void UseCounter::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, Execut ionContext* context, Feature feature) |
727 { | 739 { |
728 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) | 740 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) |
729 return; | 741 return; |
730 UseCounter::countDeprecation(context, feature); | 742 UseCounter::countDeprecation(context, feature); |
731 } | 743 } |
732 | 744 |
733 static const char* milestoneString(int milestone) | 745 static const char* milestoneString(int milestone) |
734 { | 746 { |
735 switch (milestone) { | 747 switch (milestone) { |
736 case 50: | 748 case 50: |
737 return "M50, around April 2016"; | 749 return "M50, around April 2016"; |
750 case 51: | |
751 return "M51, around June 2016"; | |
738 case 53: | 752 case 53: |
739 return "M53, around September 2016"; | 753 return "M53, around September 2016"; |
740 } | 754 } |
741 | 755 |
742 ASSERT_NOT_REACHED(); | 756 ASSERT_NOT_REACHED(); |
743 return nullptr; | 757 return nullptr; |
744 } | 758 } |
745 | 759 |
746 static String replacedBy(const char* feature, const char* replacement) | 760 static String replacedBy(const char* feature, const char* replacement) |
747 { | 761 { |
748 return String::format("%s is deprecated. Please use %s instead.", feature, r eplacement); | 762 return String::format("%s is deprecated. Please use %s instead.", feature, r eplacement); |
749 } | 763 } |
750 | 764 |
751 static String willBeRemoved(const char* feature, int milestone, const char* deta ils) | 765 static String willBeRemoved(const char* feature, int milestone, const char* deta ils) |
752 { | 766 { |
753 return String::format("%s is deprecated and will be removed in %s. See https ://www.chromestatus.com/features/%s for more details.", feature, milestoneString (milestone), details); | 767 return String::format("%s is deprecated and will be removed in %s. See https ://www.chromestatus.com/features/%s for more details.", feature, milestoneString (milestone), details); |
754 } | 768 } |
755 | 769 |
756 static String replacedWillBeRemoved(const char* feature, const char* replacement , int milestone, const char* details) | 770 static String replacedWillBeRemoved(const char* feature, const char* replacement , int milestone, const char* details) |
757 { | 771 { |
758 return String::format("%s is deprecated and will be removed in %s. Please us e %s instead. See https://www.chromestatus.com/features/%s for more details.", f eature, milestoneString(milestone), replacement, details); | 772 return String::format("%s is deprecated and will be removed in %s. Please us e %s instead. See https://www.chromestatus.com/features/%s for more details.", f eature, milestoneString(milestone), replacement, details); |
759 } | 773 } |
760 | 774 |
775 String UseCounter::deprecationMessage(CSSPropertyID cssPropertyID) | |
776 { | |
777 switch (cssPropertyID) { | |
778 case CSSPropertyWebkitBackgroundComposite: | |
779 return willBeRemoved("'-webkit-background-composite'", 51, "660729945600 8192"); | |
780 // CSSPropertyIDs that aren't deprecated don't have a deprecation message. | |
alancutter (OOO until 2018)
2016/01/18 04:00:44
Instead of this comment have a comment in the head
nainar
2016/01/18 06:09:55
Done.
| |
781 default: | |
782 return String(); | |
alancutter (OOO until 2018)
2016/01/18 04:00:44
Use emptyString().
nainar
2016/01/18 06:09:54
Done.
| |
783 } | |
784 } | |
785 | |
761 String UseCounter::deprecationMessage(Feature feature) | 786 String UseCounter::deprecationMessage(Feature feature) |
762 { | 787 { |
763 switch (feature) { | 788 switch (feature) { |
764 // Quota | 789 // Quota |
765 case PrefixedStorageInfo: | 790 case PrefixedStorageInfo: |
766 return replacedBy("'window.webkitStorageInfo'", "'navigator.webkitTempor aryStorage' or 'navigator.webkitPersistentStorage'"); | 791 return replacedBy("'window.webkitStorageInfo'", "'navigator.webkitTempor aryStorage' or 'navigator.webkitPersistentStorage'"); |
767 | 792 |
768 // Keyboard Event (DOM Level 3) | 793 // Keyboard Event (DOM Level 3) |
769 case KeyboardEventKeyLocation: | 794 case KeyboardEventKeyLocation: |
770 return replacedWillBeRemoved("'KeyboardEvent.keyLocation'", "'KeyboardEv ent.location'", 50, "4997403308457984"); | 795 return replacedWillBeRemoved("'KeyboardEvent.keyLocation'", "'KeyboardEv ent.location'", 50, "4997403308457984"); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1017 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) | 1042 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) |
1018 { | 1043 { |
1019 // FIXME: We may want to handle stylesheets that have multiple owners | 1044 // FIXME: We may want to handle stylesheets that have multiple owners |
1020 // https://crbug.com/242125 | 1045 // https://crbug.com/242125 |
1021 if (sheetContents && sheetContents->hasSingleOwnerNode()) | 1046 if (sheetContents && sheetContents->hasSingleOwnerNode()) |
1022 return getFrom(sheetContents->singleOwnerDocument()); | 1047 return getFrom(sheetContents->singleOwnerDocument()); |
1023 return 0; | 1048 return 0; |
1024 } | 1049 } |
1025 | 1050 |
1026 } // namespace blink | 1051 } // namespace blink |
OLD | NEW |