OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright (C) 2012 Google, Inc. All rights reserved. | 3 * Copyright (C) 2012 Google, Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
662 UseCounter::countDeprecation(document.frame(), feature); | 662 UseCounter::countDeprecation(document.frame(), feature); |
663 } | 663 } |
664 | 664 |
665 void UseCounter::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, Execut ionContext* context, Feature feature) | 665 void UseCounter::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, Execut ionContext* context, Feature feature) |
666 { | 666 { |
667 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) | 667 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) |
668 return; | 668 return; |
669 UseCounter::countDeprecation(context, feature); | 669 UseCounter::countDeprecation(context, feature); |
670 } | 670 } |
671 | 671 |
672 // FIXME: Update other UseCounter::deprecationMessage() cases to use this. | 672 static String replacedBy(const char* deprecatedItem, const char* firstAlternativ e, const char* secondAlternative = nullptr) |
jsbell
2014/12/18 20:05:50
This is fine, but IMHO it would be more readable t
| |
673 static String replacedBy(const char* oldString, const char* newString) | |
674 { | 673 { |
675 return String::format("'%s' is deprecated. Please use '%s' instead.", oldStr ing, newString); | 674 String replacementMessage; |
675 if (secondAlternative) | |
676 replacementMessage = String::format("'%s' or '%s'", firstAlternative, se condAlternative); | |
677 else | |
678 replacementMessage = String::format("'%s'", firstAlternative); | |
679 | |
680 return String::format("'%s' is deprecated. Please use %s instead.", deprecat edItem, replacementMessage.utf8().data()); | |
676 } | 681 } |
677 | 682 |
678 String UseCounter::deprecationMessage(Feature feature) | 683 String UseCounter::deprecationMessage(Feature feature) |
679 { | 684 { |
680 switch (feature) { | 685 switch (feature) { |
681 // Quota | 686 // Quota |
682 case PrefixedStorageInfo: | 687 case PrefixedStorageInfo: |
683 return "'window.webkitStorageInfo' is deprecated. Please use 'navigator. webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead."; | 688 return replacedBy("window.webkitStorageInfo", "navigator.webkitTemporary Storage", "navigator.webkitPersistentStorage"); |
684 | 689 |
685 // Keyboard Event (DOM Level 3) | 690 // Keyboard Event (DOM Level 3) |
686 case KeyboardEventKeyLocation: | 691 case KeyboardEventKeyLocation: |
687 return replacedBy("KeyboardEvent.keyLocation", "KeyboardEvent.location") ; | 692 return replacedBy("KeyboardEvent.keyLocation", "KeyboardEvent.location") ; |
688 | 693 |
689 case ConsoleMarkTimeline: | 694 case ConsoleMarkTimeline: |
690 return "console.markTimeline is deprecated. Please use the console.timeS tamp instead."; | 695 return replacedBy("console.markTimeline", "console.timeStamp"); |
691 | 696 |
692 case FileError: | 697 case FileError: |
693 return "FileError is deprecated. Please use the 'name' or 'message' attr ibutes of DOMError rather than 'code'."; | 698 return "FileError is deprecated. Please use the 'name' or 'message' attr ibutes of DOMError rather than 'code'."; |
694 | 699 |
695 case ShowModalDialog: | 700 case ShowModalDialog: |
696 return "showModalDialog is deprecated. Please use window.open and postMe ssage instead."; | 701 return replacedBy("showModalDialog", "window.open", "postMessage"); |
jsbell
2014/12/18 20:05:50
The new message is a bit misleading. You don't use
| |
697 | 702 |
698 case CSSStyleSheetInsertRuleOptionalArg: | 703 case CSSStyleSheetInsertRuleOptionalArg: |
699 return "Calling CSSStyleSheet.insertRule() with one argument is deprecat ed. Please pass the index argument as well: insertRule(x, 0)."; | 704 return "Calling CSSStyleSheet.insertRule() with one argument is deprecat ed. Please pass the index argument as well: insertRule(x, 0)."; |
700 | 705 |
701 case PrefixedVideoSupportsFullscreen: | 706 case PrefixedVideoSupportsFullscreen: |
702 return "'HTMLVideoElement.webkitSupportsFullscreen' is deprecated. Its v alue is true if the video is loaded."; | 707 return "'HTMLVideoElement.webkitSupportsFullscreen' is deprecated. Its v alue is true if the video is loaded."; |
703 | 708 |
704 case PrefixedVideoDisplayingFullscreen: | 709 case PrefixedVideoDisplayingFullscreen: |
705 return "'HTMLVideoElement.webkitDisplayingFullscreen' is deprecated. Ple ase use the 'fullscreenchange' and 'webkitfullscreenchange' events instead."; | 710 return replacedBy("HTMLVideoElement.webkitDisplayingFullscreen", "fullsc reenchange", "webkitfullscreenchange"); |
jsbell
2014/12/18 20:05:50
Can we skip recommending webkitfullscreenchange an
| |
706 | 711 |
707 case PrefixedVideoEnterFullscreen: | 712 case PrefixedVideoEnterFullscreen: |
708 return "'HTMLVideoElement.webkitEnterFullscreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' inste ad."; | 713 return replacedBy("HTMLVideoElement.webkitEnterFullscreen()", "Element.r equestFullscreen()", "Element.webkitRequestFullscreen()"); |
jsbell
2014/12/18 20:05:50
Can we skip recommending the nonstandard prefixed
| |
709 | 714 |
710 case PrefixedVideoExitFullscreen: | 715 case PrefixedVideoExitFullscreen: |
711 return "'HTMLVideoElement.webkitExitFullscreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead."; | 716 return replacedBy("HTMLVideoElement.webkitExitFullscreen()", "Document.e xitFullscreen()", "Document.webkitExitFullscreen()"); |
jsbell
2014/12/18 20:05:50
Can we skip recommending the nonstandard prefixed
| |
712 | 717 |
713 case PrefixedVideoEnterFullScreen: | 718 case PrefixedVideoEnterFullScreen: |
714 return "'HTMLVideoElement.webkitEnterFullScreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' inste ad."; | 719 return replacedBy("HTMLVideoElement.webkitEnterFullScreen()", "Element.r equestFullscreen()", "Element.webkitRequestFullscreen()"); |
jsbell
2014/12/18 20:05:50
Can we skip recommending the nonstandard prefixed
| |
715 | 720 |
716 case PrefixedVideoExitFullScreen: | 721 case PrefixedVideoExitFullScreen: |
717 return "'HTMLVideoElement.webkitExitFullScreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead."; | 722 return replacedBy("HTMLVideoElement.webkitExitFullScreen()", "Document.e xitFullscreen()", "Document.webkitExitFullscreen()"); |
jsbell
2014/12/18 20:05:50
Can we skip recommending the nonstandard prefixed
| |
718 | 723 |
719 case PrefixedIndexedDB: | 724 case PrefixedIndexedDB: |
720 return replacedBy("webkitIndexedDB", "indexedDB"); | 725 return replacedBy("webkitIndexedDB", "indexedDB"); |
721 | 726 |
722 case PrefixedIDBCursorConstructor: | 727 case PrefixedIDBCursorConstructor: |
723 return replacedBy("webkitIDBCursor", "IDBCursor"); | 728 return replacedBy("webkitIDBCursor", "IDBCursor"); |
724 | 729 |
725 case PrefixedIDBDatabaseConstructor: | 730 case PrefixedIDBDatabaseConstructor: |
726 return replacedBy("webkitIDBDatabase", "IDBDatabase"); | 731 return replacedBy("webkitIDBDatabase", "IDBDatabase"); |
727 | 732 |
(...skipping 30 matching lines...) Expand all Loading... | |
758 case RangeDetach: | 763 case RangeDetach: |
759 return "'Range.detach' is now a no-op, as per DOM (http://dom.spec.whatw g.org/#dom-range-detach)."; | 764 return "'Range.detach' is now a no-op, as per DOM (http://dom.spec.whatw g.org/#dom-range-detach)."; |
760 | 765 |
761 case OverflowChangedEvent: | 766 case OverflowChangedEvent: |
762 return "The 'overflowchanged' event is deprecated and may be removed. Pl ease do not use it."; | 767 return "The 'overflowchanged' event is deprecated and may be removed. Pl ease do not use it."; |
763 | 768 |
764 case SyncXHRWithCredentials: | 769 case SyncXHRWithCredentials: |
765 return "Setting 'XMLHttpRequest.withCredentials' for synchronous request s is deprecated."; | 770 return "Setting 'XMLHttpRequest.withCredentials' for synchronous request s is deprecated."; |
766 | 771 |
767 case EventSourceURL: | 772 case EventSourceURL: |
768 return "'EventSource.URL' is deprecated. Please use 'EventSource.url' in stead."; | 773 return replacedBy("EventSource.URL", "EventSource.url"); |
769 | 774 |
770 case WebSocketURL: | 775 case WebSocketURL: |
771 return "'WebSocket.URL' is deprecated. Please use 'WebSocket.url' instea d."; | 776 return replacedBy("WebSocket.URL", "WebSocket.url"); |
772 | 777 |
773 case HTMLTableElementVspace: | 778 case HTMLTableElementVspace: |
774 return "The 'vspace' attribute on table is deprecated. Please use CSS in stead."; | 779 return "The 'vspace' attribute on table is deprecated. Please use CSS ma rgin-top and margin-bottom property instead."; |
775 | 780 |
776 case HTMLTableElementHspace: | 781 case HTMLTableElementHspace: |
777 return "The 'hspace' attribute on table is deprecated. Please use CSS in stead."; | 782 return "The 'hspace' attribute on table is deprecated. Please use CSS ma rgin-left and margin-right property instead."; |
778 | 783 |
779 case PictureSourceSrc: | 784 case PictureSourceSrc: |
780 return "<source src> with a <picture> parent is invalid and therefore ig nored. Please use <source srcset> instead."; | 785 return "<source src> with a <picture> parent is invalid and therefore ig nored. Please use <source srcset> instead."; |
781 | 786 |
782 case XHRProgressEventPosition: | 787 case XHRProgressEventPosition: |
783 return "The XMLHttpRequest progress event property 'position' is depreca ted. Please use 'loaded' instead."; | 788 return "The XMLHttpRequest progress event property 'position' is depreca ted. Please use 'loaded' instead."; |
784 | 789 |
785 case XHRProgressEventTotalSize: | 790 case XHRProgressEventTotalSize: |
786 return "The XMLHttpRequest progress event property 'totalSize' is deprec ated. Please use 'total' instead."; | 791 return "The XMLHttpRequest progress event property 'totalSize' is deprec ated. Please use 'total' instead."; |
787 | 792 |
788 case ConsoleTimeline: | 793 case ConsoleTimeline: |
789 return "console.timeline is deprecated. Please use the console.time inst ead."; | 794 return replacedBy("console.timeline", "console.time"); |
790 | 795 |
791 case ConsoleTimelineEnd: | 796 case ConsoleTimelineEnd: |
792 return "console.timelineEnd is deprecated. Please use the console.timeEn d instead."; | 797 return replacedBy("console.timelineEnd", "console.timeEnd"); |
793 | 798 |
794 case XMLHttpRequestSynchronousInNonWorkerOutsideBeforeUnload: | 799 case XMLHttpRequestSynchronousInNonWorkerOutsideBeforeUnload: |
795 return "Synchronous XMLHttpRequest on the main thread is deprecated beca use of its detrimental effects to the end user's experience. For more help, chec k http://xhr.spec.whatwg.org/."; | 800 return "Synchronous XMLHttpRequest on the main thread is deprecated beca use of its detrimental effects to the end user's experience. For more help, chec k http://xhr.spec.whatwg.org/."; |
796 | 801 |
797 case FontFaceSetReady: | 802 case FontFaceSetReady: |
798 return "document.fonts.ready() method is going to be replaced with docum ent.fonts.ready attribute in future releases. Please be prepared. For more help, check https://code.google.com/p/chromium/issues/detail?id=392077#c3 ."; | 803 return "document.fonts.ready() method is going to be replaced with docum ent.fonts.ready attribute in future releases. Please be prepared. For more help, check https://code.google.com/p/chromium/issues/detail?id=392077#c3 ."; |
799 | 804 |
800 case DOMImplementationHasFeatureReturnFalse: | 805 case DOMImplementationHasFeatureReturnFalse: |
801 return "'DOMImplementation.hasFeature()' returning false is deprecated. Please do not use it, as per DOM it should always return true (https://dom.spec. whatwg.org/#dom-domimplementation-hasfeature)."; | 806 return "'DOMImplementation.hasFeature()' returning false is deprecated. Please do not use it, as per DOM it should always return true (https://dom.spec. whatwg.org/#dom-domimplementation-hasfeature)."; |
802 | 807 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
877 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) | 882 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) |
878 { | 883 { |
879 // FIXME: We may want to handle stylesheets that have multiple owners | 884 // FIXME: We may want to handle stylesheets that have multiple owners |
880 // http://crbug.com/242125 | 885 // http://crbug.com/242125 |
881 if (sheetContents && sheetContents->hasSingleOwnerNode()) | 886 if (sheetContents && sheetContents->hasSingleOwnerNode()) |
882 return getFrom(sheetContents->singleOwnerDocument()); | 887 return getFrom(sheetContents->singleOwnerDocument()); |
883 return 0; | 888 return 0; |
884 } | 889 } |
885 | 890 |
886 } // namespace blink | 891 } // namespace blink |
OLD | NEW |