OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "core/dom/ExecutionContext.h" | 36 #include "core/dom/ExecutionContext.h" |
37 #include "core/dom/StyleEngine.h" | 37 #include "core/dom/StyleEngine.h" |
38 #include "core/dom/TaskRunnerHelper.h" | 38 #include "core/dom/TaskRunnerHelper.h" |
39 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
40 #include "core/frame/LocalFrameClient.h" | 40 #include "core/frame/LocalFrameClient.h" |
41 #include "core/style/StyleRareNonInheritedData.h" | 41 #include "core/style/StyleRareNonInheritedData.h" |
42 | 42 |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 // The address of this string is important; its value is just documentation. | 45 // The address of this string is important; its value is just documentation. |
46 static const char kSupplementName[] = "CSSSelectorWatch"; | 46 static const char kSupplementNameWatch[] = "CSSSelectorWatch"; |
47 | 47 |
48 CSSSelectorWatch::CSSSelectorWatch(Document& document) | 48 CSSSelectorWatch::CSSSelectorWatch(Document& document) |
49 : Supplement<Document>(document), | 49 : Supplement<Document>(document), |
50 m_callbackSelectorChangeTimer( | 50 m_callbackSelectorChangeTimer( |
51 TaskRunnerHelper::get(TaskType::UnspecedTimer, &document), | 51 TaskRunnerHelper::get(TaskType::UnspecedTimer, &document), |
52 this, | 52 this, |
53 &CSSSelectorWatch::callbackSelectorChangeTimerFired), | 53 &CSSSelectorWatch::callbackSelectorChangeTimerFired), |
54 m_timerExpirations(0) {} | 54 m_timerExpirations(0) {} |
55 | 55 |
56 CSSSelectorWatch& CSSSelectorWatch::from(Document& document) { | 56 CSSSelectorWatch& CSSSelectorWatch::from(Document& document) { |
57 CSSSelectorWatch* watch = fromIfExists(document); | 57 CSSSelectorWatch* watch = fromIfExists(document); |
58 if (!watch) { | 58 if (!watch) { |
59 watch = new CSSSelectorWatch(document); | 59 watch = new CSSSelectorWatch(document); |
60 Supplement<Document>::provideTo(document, kSupplementName, watch); | 60 Supplement<Document>::provideTo(document, kSupplementNameWatch, watch); |
61 } | 61 } |
62 return *watch; | 62 return *watch; |
63 } | 63 } |
64 | 64 |
65 CSSSelectorWatch* CSSSelectorWatch::fromIfExists(Document& document) { | 65 CSSSelectorWatch* CSSSelectorWatch::fromIfExists(Document& document) { |
66 return static_cast<CSSSelectorWatch*>( | 66 return static_cast<CSSSelectorWatch*>( |
67 Supplement<Document>::from(document, kSupplementName)); | 67 Supplement<Document>::from(document, kSupplementNameWatch)); |
68 } | 68 } |
69 | 69 |
70 void CSSSelectorWatch::callbackSelectorChangeTimerFired(TimerBase*) { | 70 void CSSSelectorWatch::callbackSelectorChangeTimerFired(TimerBase*) { |
71 // Should be ensured by updateSelectorMatches(): | 71 // Should be ensured by updateSelectorMatches(): |
72 DCHECK(!m_addedSelectors.isEmpty() || !m_removedSelectors.isEmpty()); | 72 DCHECK(!m_addedSelectors.isEmpty() || !m_removedSelectors.isEmpty()); |
73 | 73 |
74 if (m_timerExpirations < 1) { | 74 if (m_timerExpirations < 1) { |
75 m_timerExpirations++; | 75 m_timerExpirations++; |
76 m_callbackSelectorChangeTimer.startOneShot(0, BLINK_FROM_HERE); | 76 m_callbackSelectorChangeTimer.startOneShot(0, BLINK_FROM_HERE); |
77 return; | 77 return; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 167 } |
168 supplementable()->styleEngine().watchedSelectorsChanged(); | 168 supplementable()->styleEngine().watchedSelectorsChanged(); |
169 } | 169 } |
170 | 170 |
171 DEFINE_TRACE(CSSSelectorWatch) { | 171 DEFINE_TRACE(CSSSelectorWatch) { |
172 visitor->trace(m_watchedCallbackSelectors); | 172 visitor->trace(m_watchedCallbackSelectors); |
173 Supplement<Document>::trace(visitor); | 173 Supplement<Document>::trace(visitor); |
174 } | 174 } |
175 | 175 |
176 } // namespace blink | 176 } // namespace blink |
OLD | NEW |