| 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::showDeprecationWarning(const LocalFrame* frame, CSSPropertyID c
ssPropertyID) |
| 710 { |
| 711 if (!frame || !frame->host()) |
| 712 return; |
| 713 |
| 714 String message = deprecationMessage(cssPropertyID); |
| 715 if (!message.isEmpty()) |
| 716 frame->console().addMessage(ConsoleMessage::create(DeprecationMessageSou
rce, WarningMessageLevel, message)); |
| 717 } |
| 718 |
| 709 void UseCounter::countDeprecation(ExecutionContext* context, Feature feature) | 719 void UseCounter::countDeprecation(ExecutionContext* context, Feature feature) |
| 710 { | 720 { |
| 711 if (!context) | 721 if (!context) |
| 712 return; | 722 return; |
| 713 if (context->isDocument()) { | 723 if (context->isDocument()) { |
| 714 UseCounter::countDeprecation(*toDocument(context), feature); | 724 UseCounter::countDeprecation(*toDocument(context), feature); |
| 715 return; | 725 return; |
| 716 } | 726 } |
| 717 if (context->isWorkerGlobalScope()) | 727 if (context->isWorkerGlobalScope()) |
| 718 toWorkerGlobalScope(context)->countDeprecation(feature); | 728 toWorkerGlobalScope(context)->countDeprecation(feature); |
| 719 } | 729 } |
| 720 | 730 |
| 721 void UseCounter::countDeprecation(const Document& document, Feature feature) | 731 void UseCounter::countDeprecation(const Document& document, Feature feature) |
| 722 { | 732 { |
| 723 UseCounter::countDeprecation(document.frame(), feature); | 733 UseCounter::countDeprecation(document.frame(), feature); |
| 724 } | 734 } |
| 725 | 735 |
| 726 void UseCounter::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, Execut
ionContext* context, Feature feature) | 736 void UseCounter::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, Execut
ionContext* context, Feature feature) |
| 727 { | 737 { |
| 728 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) | 738 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) |
| 729 return; | 739 return; |
| 730 UseCounter::countDeprecation(context, feature); | 740 UseCounter::countDeprecation(context, feature); |
| 731 } | 741 } |
| 732 | 742 |
| 733 static const char* milestoneString(int milestone) | 743 static const char* milestoneString(int milestone) |
| 734 { | 744 { |
| 735 switch (milestone) { | 745 switch (milestone) { |
| 736 case 50: | 746 case 50: |
| 737 return "M50, around April 2016"; | 747 return "M50, around April 2016"; |
| 748 case 51: |
| 749 return "M51, around June 2016"; |
| 738 case 53: | 750 case 53: |
| 739 return "M53, around September 2016"; | 751 return "M53, around September 2016"; |
| 740 } | 752 } |
| 741 | 753 |
| 742 ASSERT_NOT_REACHED(); | 754 ASSERT_NOT_REACHED(); |
| 743 return nullptr; | 755 return nullptr; |
| 744 } | 756 } |
| 745 | 757 |
| 746 static String replacedBy(const char* feature, const char* replacement) | 758 static String replacedBy(const char* feature, const char* replacement) |
| 747 { | 759 { |
| 748 return String::format("%s is deprecated. Please use %s instead.", feature, r
eplacement); | 760 return String::format("%s is deprecated. Please use %s instead.", feature, r
eplacement); |
| 749 } | 761 } |
| 750 | 762 |
| 751 static String willBeRemoved(const char* feature, int milestone, const char* deta
ils) | 763 static String willBeRemoved(const char* feature, int milestone, const char* deta
ils) |
| 752 { | 764 { |
| 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); | 765 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 } | 766 } |
| 755 | 767 |
| 756 static String replacedWillBeRemoved(const char* feature, const char* replacement
, int milestone, const char* details) | 768 static String replacedWillBeRemoved(const char* feature, const char* replacement
, int milestone, const char* details) |
| 757 { | 769 { |
| 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); | 770 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 } | 771 } |
| 760 | 772 |
| 773 String UseCounter::deprecationMessage(CSSPropertyID cssPropertyID) |
| 774 { |
| 775 switch (cssPropertyID) { |
| 776 case CSSPropertyWebkitBackgroundComposite: |
| 777 return willBeRemoved("'-webkit-background-composite'", 51, "660729945600
8192"); |
| 778 default: |
| 779 return emptyString(); |
| 780 } |
| 781 } |
| 782 |
| 761 String UseCounter::deprecationMessage(Feature feature) | 783 String UseCounter::deprecationMessage(Feature feature) |
| 762 { | 784 { |
| 763 switch (feature) { | 785 switch (feature) { |
| 764 // Quota | 786 // Quota |
| 765 case PrefixedStorageInfo: | 787 case PrefixedStorageInfo: |
| 766 return replacedBy("'window.webkitStorageInfo'", "'navigator.webkitTempor
aryStorage' or 'navigator.webkitPersistentStorage'"); | 788 return replacedBy("'window.webkitStorageInfo'", "'navigator.webkitTempor
aryStorage' or 'navigator.webkitPersistentStorage'"); |
| 767 | 789 |
| 768 // Keyboard Event (DOM Level 3) | 790 // Keyboard Event (DOM Level 3) |
| 769 case KeyboardEventKeyLocation: | 791 case KeyboardEventKeyLocation: |
| 770 return replacedWillBeRemoved("'KeyboardEvent.keyLocation'", "'KeyboardEv
ent.location'", 50, "4997403308457984"); | 792 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) | 1039 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) |
| 1018 { | 1040 { |
| 1019 // FIXME: We may want to handle stylesheets that have multiple owners | 1041 // FIXME: We may want to handle stylesheets that have multiple owners |
| 1020 // https://crbug.com/242125 | 1042 // https://crbug.com/242125 |
| 1021 if (sheetContents && sheetContents->hasSingleOwnerNode()) | 1043 if (sheetContents && sheetContents->hasSingleOwnerNode()) |
| 1022 return getFrom(sheetContents->singleOwnerDocument()); | 1044 return getFrom(sheetContents->singleOwnerDocument()); |
| 1023 return 0; | 1045 return 0; |
| 1024 } | 1046 } |
| 1025 | 1047 |
| 1026 } // namespace blink | 1048 } // namespace blink |
| OLD | NEW |