Index: Source/core/frame/UseCounter.cpp |
diff --git a/Source/core/frame/UseCounter.cpp b/Source/core/frame/UseCounter.cpp |
index f9f078aaac2cb558e9d78bd29c362731b60767f4..d06ee7c7a10fa68aabb6869ab91748f55a863027 100644 |
--- a/Source/core/frame/UseCounter.cpp |
+++ b/Source/core/frame/UseCounter.cpp |
@@ -669,10 +669,15 @@ void UseCounter::countDeprecationIfNotPrivateScript(v8::Isolate* isolate, Execut |
UseCounter::countDeprecation(context, feature); |
} |
-// FIXME: Update other UseCounter::deprecationMessage() cases to use this. |
-static String replacedBy(const char* oldString, const char* newString) |
+static String replacedBy(const char* deprecatedItem, const char* firstAlternative, const char* secondAlternative = nullptr) |
jsbell
2014/12/18 20:05:50
This is fine, but IMHO it would be more readable t
|
{ |
- return String::format("'%s' is deprecated. Please use '%s' instead.", oldString, newString); |
+ String replacementMessage; |
+ if (secondAlternative) |
+ replacementMessage = String::format("'%s' or '%s'", firstAlternative, secondAlternative); |
+ else |
+ replacementMessage = String::format("'%s'", firstAlternative); |
+ |
+ return String::format("'%s' is deprecated. Please use %s instead.", deprecatedItem, replacementMessage.utf8().data()); |
} |
String UseCounter::deprecationMessage(Feature feature) |
@@ -680,20 +685,20 @@ String UseCounter::deprecationMessage(Feature feature) |
switch (feature) { |
// Quota |
case PrefixedStorageInfo: |
- return "'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead."; |
+ return replacedBy("window.webkitStorageInfo", "navigator.webkitTemporaryStorage", "navigator.webkitPersistentStorage"); |
// Keyboard Event (DOM Level 3) |
case KeyboardEventKeyLocation: |
return replacedBy("KeyboardEvent.keyLocation", "KeyboardEvent.location"); |
case ConsoleMarkTimeline: |
- return "console.markTimeline is deprecated. Please use the console.timeStamp instead."; |
+ return replacedBy("console.markTimeline", "console.timeStamp"); |
case FileError: |
return "FileError is deprecated. Please use the 'name' or 'message' attributes of DOMError rather than 'code'."; |
case ShowModalDialog: |
- return "showModalDialog is deprecated. Please use window.open and postMessage instead."; |
+ return replacedBy("showModalDialog", "window.open", "postMessage"); |
jsbell
2014/12/18 20:05:50
The new message is a bit misleading. You don't use
|
case CSSStyleSheetInsertRuleOptionalArg: |
return "Calling CSSStyleSheet.insertRule() with one argument is deprecated. Please pass the index argument as well: insertRule(x, 0)."; |
@@ -702,19 +707,19 @@ String UseCounter::deprecationMessage(Feature feature) |
return "'HTMLVideoElement.webkitSupportsFullscreen' is deprecated. Its value is true if the video is loaded."; |
case PrefixedVideoDisplayingFullscreen: |
- return "'HTMLVideoElement.webkitDisplayingFullscreen' is deprecated. Please use the 'fullscreenchange' and 'webkitfullscreenchange' events instead."; |
+ return replacedBy("HTMLVideoElement.webkitDisplayingFullscreen", "fullscreenchange", "webkitfullscreenchange"); |
jsbell
2014/12/18 20:05:50
Can we skip recommending webkitfullscreenchange an
|
case PrefixedVideoEnterFullscreen: |
- return "'HTMLVideoElement.webkitEnterFullscreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' instead."; |
+ return replacedBy("HTMLVideoElement.webkitEnterFullscreen()", "Element.requestFullscreen()", "Element.webkitRequestFullscreen()"); |
jsbell
2014/12/18 20:05:50
Can we skip recommending the nonstandard prefixed
|
case PrefixedVideoExitFullscreen: |
- return "'HTMLVideoElement.webkitExitFullscreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead."; |
+ return replacedBy("HTMLVideoElement.webkitExitFullscreen()", "Document.exitFullscreen()", "Document.webkitExitFullscreen()"); |
jsbell
2014/12/18 20:05:50
Can we skip recommending the nonstandard prefixed
|
case PrefixedVideoEnterFullScreen: |
- return "'HTMLVideoElement.webkitEnterFullScreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' instead."; |
+ return replacedBy("HTMLVideoElement.webkitEnterFullScreen()", "Element.requestFullscreen()", "Element.webkitRequestFullscreen()"); |
jsbell
2014/12/18 20:05:50
Can we skip recommending the nonstandard prefixed
|
case PrefixedVideoExitFullScreen: |
- return "'HTMLVideoElement.webkitExitFullScreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead."; |
+ return replacedBy("HTMLVideoElement.webkitExitFullScreen()", "Document.exitFullscreen()", "Document.webkitExitFullscreen()"); |
jsbell
2014/12/18 20:05:50
Can we skip recommending the nonstandard prefixed
|
case PrefixedIndexedDB: |
return replacedBy("webkitIndexedDB", "indexedDB"); |
@@ -765,16 +770,16 @@ String UseCounter::deprecationMessage(Feature feature) |
return "Setting 'XMLHttpRequest.withCredentials' for synchronous requests is deprecated."; |
case EventSourceURL: |
- return "'EventSource.URL' is deprecated. Please use 'EventSource.url' instead."; |
+ return replacedBy("EventSource.URL", "EventSource.url"); |
case WebSocketURL: |
- return "'WebSocket.URL' is deprecated. Please use 'WebSocket.url' instead."; |
+ return replacedBy("WebSocket.URL", "WebSocket.url"); |
case HTMLTableElementVspace: |
- return "The 'vspace' attribute on table is deprecated. Please use CSS instead."; |
+ return "The 'vspace' attribute on table is deprecated. Please use CSS margin-top and margin-bottom property instead."; |
case HTMLTableElementHspace: |
- return "The 'hspace' attribute on table is deprecated. Please use CSS instead."; |
+ return "The 'hspace' attribute on table is deprecated. Please use CSS margin-left and margin-right property instead."; |
case PictureSourceSrc: |
return "<source src> with a <picture> parent is invalid and therefore ignored. Please use <source srcset> instead."; |
@@ -786,10 +791,10 @@ String UseCounter::deprecationMessage(Feature feature) |
return "The XMLHttpRequest progress event property 'totalSize' is deprecated. Please use 'total' instead."; |
case ConsoleTimeline: |
- return "console.timeline is deprecated. Please use the console.time instead."; |
+ return replacedBy("console.timeline", "console.time"); |
case ConsoleTimelineEnd: |
- return "console.timelineEnd is deprecated. Please use the console.timeEnd instead."; |
+ return replacedBy("console.timelineEnd", "console.timeEnd"); |
case XMLHttpRequestSynchronousInNonWorkerOutsideBeforeUnload: |
return "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/."; |