OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/frame/Deprecation.h" |
| 6 |
| 7 #include "core/frame/FrameConsole.h" |
| 8 #include "core/frame/FrameHost.h" |
| 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/frame/UseCounter.h" |
| 11 #include "core/inspector/ConsoleMessage.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 Deprecation::Deprecation() |
| 16 { |
| 17 m_cssPropertyDeprecationBits.ensureSize(lastUnresolvedCSSProperty + 1); |
| 18 m_cssPropertyDeprecationBits.clearAll(); |
| 19 } |
| 20 |
| 21 Deprecation::~Deprecation() |
| 22 { |
| 23 m_cssPropertyDeprecationBits.clearAll(); |
| 24 } |
| 25 |
| 26 void Deprecation::clearSuppression() |
| 27 { |
| 28 m_cssPropertyDeprecationBits.clearAll(); |
| 29 } |
| 30 |
| 31 void Deprecation::suppress(CSSPropertyID unresolvedProperty) |
| 32 { |
| 33 ASSERT(unresolvedProperty >= firstCSSProperty); |
| 34 ASSERT(unresolvedProperty <= lastUnresolvedCSSProperty); |
| 35 m_cssPropertyDeprecationBits.quickSet(unresolvedProperty); |
| 36 } |
| 37 bool Deprecation::isSuppressed(CSSPropertyID unresolvedProperty) |
| 38 { |
| 39 ASSERT(unresolvedProperty >= firstCSSProperty); |
| 40 ASSERT(unresolvedProperty <= lastUnresolvedCSSProperty); |
| 41 return m_cssPropertyDeprecationBits.quickGet(unresolvedProperty); |
| 42 } |
| 43 |
| 44 void Deprecation::warnOnDeprecatedProperties(const LocalFrame* frame, CSSPropert
yID unresolvedProperty) |
| 45 { |
| 46 FrameHost* host = frame ? frame->host() : nullptr; |
| 47 if (!host || host->deprecation().isSuppressed(unresolvedProperty)) |
| 48 return; |
| 49 |
| 50 String message = deprecationMessage(unresolvedProperty); |
| 51 if (!message.isEmpty()) { |
| 52 host->deprecation().suppress(unresolvedProperty); |
| 53 frame->console().addMessage(ConsoleMessage::create(DeprecationMessageSou
rce, WarningMessageLevel, message)); |
| 54 } |
| 55 } |
| 56 |
| 57 String Deprecation::deprecationMessage(CSSPropertyID unresolvedProperty) |
| 58 { |
| 59 switch (unresolvedProperty) { |
| 60 case CSSPropertyWebkitBackgroundComposite: |
| 61 return UseCounter::willBeRemoved("'-webkit-background-composite'", 51, "
6607299456008192"); |
| 62 default: |
| 63 return emptyString(); |
| 64 } |
| 65 } |
| 66 |
| 67 } // namespace blink |
OLD | NEW |