OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (C) 2016 Google, Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * 1. Redistributions of source code must retain the above copyright | |
8 * notice, this list of conditions and the following disclaimer. | |
9 * 2. Redistributions in binary form must reproduce the above copyright | |
10 * notice, this list of conditions and the following disclaimer in the | |
11 * documentation and/or other materials provided with the distribution. | |
12 * | |
13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY | |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
24 */ | |
25 | |
26 #include "core/frame/DeprecationHelper.h" | |
27 | |
28 #include "core/frame/FrameConsole.h" | |
29 #include "core/frame/FrameHost.h" | |
30 #include "core/frame/LocalFrame.h" | |
31 #include "core/frame/UseCounter.h" | |
32 #include "core/inspector/ConsoleMessage.h" | |
33 | |
34 namespace blink { | |
35 | |
36 DeprecationHelper::DeprecationHelper() | |
37 { | |
38 m_CSSPropertyDeprecationBits.ensureSize(lastUnresolvedCSSProperty + 1); | |
39 m_CSSPropertyDeprecationBits.clearAll(); | |
40 } | |
41 | |
42 DeprecationHelper::~DeprecationHelper() | |
43 { | |
44 m_CSSPropertyDeprecationBits.clearAll(); | |
45 } | |
46 | |
47 void DeprecationHelper::showDeprecationWarning(const LocalFrame* frame, CSSPrope rtyID propertyID) | |
48 { | |
49 if (!frame) | |
50 return; | |
51 FrameHost* host = frame->host(); | |
52 if (!host) | |
53 return; | |
54 | |
55 String message = deprecationMessage(propertyID); | |
56 if (!host->deprecationHelper().isCounted(propertyID) && !message.isEmpty()) { | |
57 host->deprecationHelper().count(propertyID); | |
58 frame->console().addMessage(ConsoleMessage::create(DeprecationMessageSou rce, WarningMessageLevel, message)); | |
59 } | |
60 } | |
61 | |
62 const char* milestoneString(int milestone) | |
63 { | |
64 switch (milestone) { | |
65 case 50: | |
66 return "M50, around April 2016"; | |
67 case 51: | |
68 return "M51, around June 2016"; | |
69 case 53: | |
70 return "M53, around September 2016"; | |
71 } | |
72 ASSERT_NOT_REACHED(); | |
73 return nullptr; | |
74 } | |
75 | |
76 String willBeRemoved(const char* feature, int milestone, const char* details) | |
77 { | |
78 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); | |
79 } | |
alancutter (OOO until 2018)
2016/01/21 00:58:38
Don't copy paste this, expose it as a static metho
nainar
2016/01/21 02:39:06
Done.
| |
80 | |
81 String DeprecationHelper::deprecationMessage(CSSPropertyID cssPropertyID) | |
82 { | |
83 switch (cssPropertyID) { | |
84 case CSSPropertyWebkitBackgroundComposite: | |
85 return willBeRemoved("'-webkit-background-composite'", 51, "660729945600 8192"); | |
86 default: | |
87 return emptyString(); | |
88 } | |
89 } | |
90 | |
91 } // namespace blink | |
OLD | NEW |