Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1037)

Unified Diff: Source/core/frame/UseCounter.cpp

Issue 717493003: Update UseCounter::deprecationMessage() cases to use the replacedBy function (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/UseCounter.cpp
diff --git a/Source/core/frame/UseCounter.cpp b/Source/core/frame/UseCounter.cpp
index 5fbb2a824762479f2a3e6b66c023bc3986eb78d5..f6a54e61ef788c0f45adf123a81303261ffa2a73 100644
--- a/Source/core/frame/UseCounter.cpp
+++ b/Source/core/frame/UseCounter.cpp
@@ -665,10 +665,20 @@ 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)
+template <typename... T>
Julien - ping for review 2014/12/12 00:33:29 Variadic template is allowed but seems to be troub
+static String replacedBy(const char* deprecatedItem, T... replacementItems)
{
- return String::format("'%s' is deprecated. Please use '%s' instead.", oldString, newString);
+ String replacementMessage;
Julien - ping for review 2014/12/12 17:27:46 Probably better to use a StringBuilder even if the
+ int itemsCount = 0;
+
+ 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
+ if (itemsCount)
+ replacementMessage.append(" or ");
+ replacementMessage.append(String::format("%s", replacementItem));
+ itemsCount++;
+ }
+
+ return String::format("%s is deprecated. Please use %s instead.", deprecatedItem, replacementMessage.stripWhiteSpace().utf8().data());
}
String UseCounter::deprecationMessage(Feature feature)
@@ -676,20 +686,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");
case CSSStyleSheetInsertRuleOptionalArg:
return "Calling CSSStyleSheet.insertRule() with one argument is deprecated. Please pass the index argument as well: insertRule(x, 0).";
@@ -698,19 +708,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");
case PrefixedVideoEnterFullscreen:
- return "'HTMLVideoElement.webkitEnterFullscreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' instead.";
+ return replacedBy("HTMLVideoElement.webkitEnterFullscreen()", "Element.requestFullscreen()", "Element.webkitRequestFullscreen()");
case PrefixedVideoExitFullscreen:
- return "'HTMLVideoElement.webkitExitFullscreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead.";
+ return replacedBy("HTMLVideoElement.webkitExitFullscreen()", "Document.exitFullscreen()", "Document.webkitExitFullscreen()");
case PrefixedVideoEnterFullScreen:
- return "'HTMLVideoElement.webkitEnterFullScreen()' is deprecated. Please use 'Element.requestFullscreen()' and 'Element.webkitRequestFullscreen()' instead.";
+ return replacedBy("HTMLVideoElement.webkitEnterFullScreen()", "Element.requestFullscreen()", "Element.webkitRequestFullscreen()");
case PrefixedVideoExitFullScreen:
- return "'HTMLVideoElement.webkitExitFullScreen()' is deprecated. Please use 'Document.exitFullscreen()' and 'Document.webkitExitFullscreen()' instead.";
+ return replacedBy("HTMLVideoElement.webkitExitFullScreen()", "Document.exitFullscreen()", "Document.webkitExitFullscreen()");
case PrefixedGamepad:
return replacedBy("navigator.webkitGetGamepads", "navigator.getGamepads");
@@ -764,31 +774,31 @@ 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 replacedBy("'vspace' attribute on table", "CSS margin property");
case HTMLTableElementHspace:
- return "The 'hspace' attribute on table is deprecated. Please use CSS instead.";
+ return replacedBy("'hspace' attribute on table", "CSS margin property");
case PictureSourceSrc:
return "<source src> with a <picture> parent is invalid and therefore ignored. Please use <source srcset> instead.";
case XHRProgressEventPosition:
- return "The XMLHttpRequest progress event property 'position' is deprecated. Please use 'loaded' instead.";
+ return replacedBy("The XMLHttpRequest progress event property position", "loaded");
case XHRProgressEventTotalSize:
- return "The XMLHttpRequest progress event property 'totalSize' is deprecated. Please use 'total' instead.";
+ return replacedBy("The XMLHttpRequest progress event property totalSize", "total");
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/.";
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698