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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 UseCounter::countDeprecation(document.frame(), feature); | 658 UseCounter::countDeprecation(document.frame(), feature); |
659 } | 659 } |
660 | 660 |
661 void UseCounter::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, Execut ionContext* context, Feature feature) | 661 void UseCounter::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, Execut ionContext* context, Feature feature) |
662 { | 662 { |
663 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) | 663 if (DOMWrapperWorld::current(isolate).isPrivateScriptIsolatedWorld()) |
664 return; | 664 return; |
665 UseCounter::countDeprecation(context, feature); | 665 UseCounter::countDeprecation(context, feature); |
666 } | 666 } |
667 | 667 |
668 // FIXME: Update other UseCounter::deprecationMessage() cases to use this. | 668 template <typename... T> |
Julien - ping for review
2014/12/12 00:33:29
Variadic template is allowed but seems to be troub
| |
669 static String replacedBy(const char* oldString, const char* newString) | 669 static String replacedBy(const char* deprecatedItem, T... replacementItems) |
670 { | 670 { |
671 return String::format("'%s' is deprecated. Please use '%s' instead.", oldStr ing, newString); | 671 String replacementMessage; |
Julien - ping for review
2014/12/12 17:27:46
Probably better to use a StringBuilder even if the
| |
672 int itemsCount = 0; | |
673 | |
674 for (const char* replacementItem : { replacementItems... }) { | |
Nico
2014/12/12 03:57:49
I think iterating over an initializer list require
Julien - ping for review
2014/12/12 17:27:46
Thanks Nico, it seems like we should just stick wi
| |
675 if (itemsCount) | |
676 replacementMessage.append(" or "); | |
677 replacementMessage.append(String::format("%s", replacementItem)); | |
678 itemsCount++; | |
679 } | |
680 | |
681 return String::format("%s is deprecated. Please use %s instead.", deprecated Item, replacementMessage.stripWhiteSpace().utf8().data()); | |
672 } | 682 } |
673 | 683 |
674 String UseCounter::deprecationMessage(Feature feature) | 684 String UseCounter::deprecationMessage(Feature feature) |
675 { | 685 { |
676 switch (feature) { | 686 switch (feature) { |
677 // Quota | 687 // Quota |
678 case PrefixedStorageInfo: | 688 case PrefixedStorageInfo: |
679 return "'window.webkitStorageInfo' is deprecated. Please use 'navigator. webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead."; | 689 return replacedBy("window.webkitStorageInfo", "navigator.webkitTemporary Storage", "navigator.webkitPersistentStorage"); |
680 | 690 |
681 // Keyboard Event (DOM Level 3) | 691 // Keyboard Event (DOM Level 3) |
682 case KeyboardEventKeyLocation: | 692 case KeyboardEventKeyLocation: |
683 return replacedBy("KeyboardEvent.keyLocation", "KeyboardEvent.location") ; | 693 return replacedBy("KeyboardEvent.keyLocation", "KeyboardEvent.location") ; |
684 | 694 |
685 case ConsoleMarkTimeline: | 695 case ConsoleMarkTimeline: |
686 return "console.markTimeline is deprecated. Please use the console.timeS tamp instead."; | 696 return replacedBy("console.markTimeline", "console.timeStamp"); |
687 | 697 |
688 case FileError: | 698 case FileError: |
689 return "FileError is deprecated. Please use the 'name' or 'message' attr ibutes of DOMError rather than 'code'."; | 699 return "FileError is deprecated. Please use the 'name' or 'message' attr ibutes of DOMError rather than 'code'."; |
690 | 700 |
691 case ShowModalDialog: | 701 case ShowModalDialog: |
692 return "showModalDialog is deprecated. Please use window.open and postMe ssage instead."; | 702 return replacedBy("showModalDialog", "window.open", "postMessage"); |
693 | 703 |
694 case CSSStyleSheetInsertRuleOptionalArg: | 704 case CSSStyleSheetInsertRuleOptionalArg: |
695 return "Calling CSSStyleSheet.insertRule() with one argument is deprecat ed. Please pass the index argument as well: insertRule(x, 0)."; | 705 return "Calling CSSStyleSheet.insertRule() with one argument is deprecat ed. Please pass the index argument as well: insertRule(x, 0)."; |
696 | 706 |
697 case PrefixedVideoSupportsFullscreen: | 707 case PrefixedVideoSupportsFullscreen: |
698 return "'HTMLVideoElement.webkitSupportsFullscreen' is deprecated. Its v alue is true if the video is loaded."; | 708 return "'HTMLVideoElement.webkitSupportsFullscreen' is deprecated. Its v alue is true if the video is loaded."; |
699 | 709 |
700 case PrefixedVideoDisplayingFullscreen: | 710 case PrefixedVideoDisplayingFullscreen: |
701 return "'HTMLVideoElement.webkitDisplayingFullscreen' is deprecated. Ple ase use the 'fullscreenchange' and 'webkitfullscreenchange' events instead."; | 711 return replacedBy("HTMLVideoElement.webkitDisplayingFullscreen", "fullsc reenchange", "webkitfullscreenchange"); |
702 | 712 |
703 case PrefixedVideoEnterFullscreen: | 713 case PrefixedVideoEnterFullscreen: |
704 return "'HTMLVideoElement.webkitEnterFullscreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' inste ad."; | 714 return replacedBy("HTMLVideoElement.webkitEnterFullscreen()", "Element.r equestFullscreen()", "Element.webkitRequestFullscreen()"); |
705 | 715 |
706 case PrefixedVideoExitFullscreen: | 716 case PrefixedVideoExitFullscreen: |
707 return "'HTMLVideoElement.webkitExitFullscreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead."; | 717 return replacedBy("HTMLVideoElement.webkitExitFullscreen()", "Document.e xitFullscreen()", "Document.webkitExitFullscreen()"); |
708 | 718 |
709 case PrefixedVideoEnterFullScreen: | 719 case PrefixedVideoEnterFullScreen: |
710 return "'HTMLVideoElement.webkitEnterFullScreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' inste ad."; | 720 return replacedBy("HTMLVideoElement.webkitEnterFullScreen()", "Element.r equestFullscreen()", "Element.webkitRequestFullscreen()"); |
711 | 721 |
712 case PrefixedVideoExitFullScreen: | 722 case PrefixedVideoExitFullScreen: |
713 return "'HTMLVideoElement.webkitExitFullScreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead."; | 723 return replacedBy("HTMLVideoElement.webkitExitFullScreen()", "Document.e xitFullscreen()", "Document.webkitExitFullscreen()"); |
714 | 724 |
715 case PrefixedGamepad: | 725 case PrefixedGamepad: |
716 return replacedBy("navigator.webkitGetGamepads", "navigator.getGamepads" ); | 726 return replacedBy("navigator.webkitGetGamepads", "navigator.getGamepads" ); |
717 | 727 |
718 case PrefixedIndexedDB: | 728 case PrefixedIndexedDB: |
719 return replacedBy("webkitIndexedDB", "indexedDB"); | 729 return replacedBy("webkitIndexedDB", "indexedDB"); |
720 | 730 |
721 case PrefixedIDBCursorConstructor: | 731 case PrefixedIDBCursorConstructor: |
722 return replacedBy("webkitIDBCursor", "IDBCursor"); | 732 return replacedBy("webkitIDBCursor", "IDBCursor"); |
723 | 733 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
757 case RangeDetach: | 767 case RangeDetach: |
758 return "'Range.detach' is now a no-op, as per DOM (http://dom.spec.whatw g.org/#dom-range-detach)."; | 768 return "'Range.detach' is now a no-op, as per DOM (http://dom.spec.whatw g.org/#dom-range-detach)."; |
759 | 769 |
760 case OverflowChangedEvent: | 770 case OverflowChangedEvent: |
761 return "The 'overflowchanged' event is deprecated and may be removed. Pl ease do not use it."; | 771 return "The 'overflowchanged' event is deprecated and may be removed. Pl ease do not use it."; |
762 | 772 |
763 case SyncXHRWithCredentials: | 773 case SyncXHRWithCredentials: |
764 return "Setting 'XMLHttpRequest.withCredentials' for synchronous request s is deprecated."; | 774 return "Setting 'XMLHttpRequest.withCredentials' for synchronous request s is deprecated."; |
765 | 775 |
766 case EventSourceURL: | 776 case EventSourceURL: |
767 return "'EventSource.URL' is deprecated. Please use 'EventSource.url' in stead."; | 777 return replacedBy("EventSource.URL", "EventSource.url"); |
768 | 778 |
769 case WebSocketURL: | 779 case WebSocketURL: |
770 return "'WebSocket.URL' is deprecated. Please use 'WebSocket.url' instea d."; | 780 return replacedBy("WebSocket.URL", "WebSocket.url"); |
771 | 781 |
772 case HTMLTableElementVspace: | 782 case HTMLTableElementVspace: |
773 return "The 'vspace' attribute on table is deprecated. Please use CSS in stead."; | 783 return replacedBy("'vspace' attribute on table", "CSS margin property"); |
774 | 784 |
775 case HTMLTableElementHspace: | 785 case HTMLTableElementHspace: |
776 return "The 'hspace' attribute on table is deprecated. Please use CSS in stead."; | 786 return replacedBy("'hspace' attribute on table", "CSS margin property"); |
777 | 787 |
778 case PictureSourceSrc: | 788 case PictureSourceSrc: |
779 return "<source src> with a <picture> parent is invalid and therefore ig nored. Please use <source srcset> instead."; | 789 return "<source src> with a <picture> parent is invalid and therefore ig nored. Please use <source srcset> instead."; |
780 | 790 |
781 case XHRProgressEventPosition: | 791 case XHRProgressEventPosition: |
782 return "The XMLHttpRequest progress event property 'position' is depreca ted. Please use 'loaded' instead."; | 792 return replacedBy("The XMLHttpRequest progress event property position", "loaded"); |
783 | 793 |
784 case XHRProgressEventTotalSize: | 794 case XHRProgressEventTotalSize: |
785 return "The XMLHttpRequest progress event property 'totalSize' is deprec ated. Please use 'total' instead."; | 795 return replacedBy("The XMLHttpRequest progress event property totalSize" , "total"); |
786 | 796 |
787 case ConsoleTimeline: | 797 case ConsoleTimeline: |
788 return "console.timeline is deprecated. Please use the console.time inst ead."; | 798 return replacedBy("console.timeline", "console.time"); |
789 | 799 |
790 case ConsoleTimelineEnd: | 800 case ConsoleTimelineEnd: |
791 return "console.timelineEnd is deprecated. Please use the console.timeEn d instead."; | 801 return replacedBy("console.timelineEnd", "console.timeEnd"); |
792 | 802 |
793 case XMLHttpRequestSynchronousInNonWorkerOutsideBeforeUnload: | 803 case XMLHttpRequestSynchronousInNonWorkerOutsideBeforeUnload: |
794 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/."; | 804 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/."; |
795 | 805 |
796 case FontFaceSetReady: | 806 case FontFaceSetReady: |
797 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 ."; | 807 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 ."; |
798 | 808 |
799 case DOMImplementationHasFeatureReturnFalse: | 809 case DOMImplementationHasFeatureReturnFalse: |
800 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)."; | 810 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)."; |
801 | 811 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
846 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) | 856 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) |
847 { | 857 { |
848 // FIXME: We may want to handle stylesheets that have multiple owners | 858 // FIXME: We may want to handle stylesheets that have multiple owners |
849 // http://crbug.com/242125 | 859 // http://crbug.com/242125 |
850 if (sheetContents && sheetContents->hasSingleOwnerNode()) | 860 if (sheetContents && sheetContents->hasSingleOwnerNode()) |
851 return getFrom(sheetContents->singleOwnerDocument()); | 861 return getFrom(sheetContents->singleOwnerDocument()); |
852 return 0; | 862 return 0; |
853 } | 863 } |
854 | 864 |
855 } // namespace blink | 865 } // namespace blink |
OLD | NEW |