| 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 "platform/Timer.h" | 36 #include "platform/Timer.h" |
| 37 #include "wtf/HashCountedSet.h" | 37 #include "wtf/HashCountedSet.h" |
| 38 #include "wtf/HashSet.h" | 38 #include "wtf/HashSet.h" |
| 39 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 40 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
| 41 #include "wtf/WeakPtr.h" | 41 #include "wtf/WeakPtr.h" |
| 42 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 class CSSSelectorWatch : public DocumentSupplement { | 46 class CSSSelectorWatch FINAL : public NoBaseWillBeGarbageCollectedFinalized<CSSS
electorWatch>, public DocumentSupplement { |
| 47 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(CSSSelectorWatch); |
| 47 public: | 48 public: |
| 48 virtual ~CSSSelectorWatch() { } | 49 virtual ~CSSSelectorWatch() { } |
| 49 | 50 |
| 50 static CSSSelectorWatch& from(Document&); | 51 static CSSSelectorWatch& from(Document&); |
| 51 | 52 |
| 52 void watchCSSSelectors(const Vector<String>& selectors); | 53 void watchCSSSelectors(const Vector<String>& selectors); |
| 53 const WillBeHeapVector<RefPtrWillBeMember<StyleRule> >& watchedCallbackSelec
tors() const { return m_watchedCallbackSelectors; } | 54 const WillBeHeapVector<RefPtrWillBeMember<StyleRule> >& watchedCallbackSelec
tors() const { return m_watchedCallbackSelectors; } |
| 54 | 55 |
| 55 void updateSelectorMatches(const Vector<String>& removedSelectors, const Vec
tor<String>& addedSelectors); | 56 void updateSelectorMatches(const Vector<String>& removedSelectors, const Vec
tor<String>& addedSelectors); |
| 56 | 57 |
| 57 virtual void trace(Visitor*) OVERRIDE { } | 58 virtual void trace(Visitor*) OVERRIDE; |
| 58 | 59 |
| 59 private: | 60 private: |
| 60 CSSSelectorWatch(Document&); | 61 CSSSelectorWatch(Document&); |
| 61 void callbackSelectorChangeTimerFired(Timer<CSSSelectorWatch>*); | 62 void callbackSelectorChangeTimerFired(Timer<CSSSelectorWatch>*); |
| 62 | 63 |
| 63 Document& m_document; | 64 Document& m_document; |
| 64 | 65 |
| 65 WillBePersistentHeapVector<RefPtrWillBeMember<StyleRule> > m_watchedCallback
Selectors; | 66 WillBeHeapVector<RefPtrWillBeMember<StyleRule> > m_watchedCallbackSelectors; |
| 66 | 67 |
| 67 // Maps a CSS selector string with a -webkit-callback property to the number | 68 // Maps a CSS selector string with a -webkit-callback property to the number |
| 68 // of matching RenderStyle objects in this document. | 69 // of matching RenderStyle objects in this document. |
| 69 HashCountedSet<String> m_matchingCallbackSelectors; | 70 HashCountedSet<String> m_matchingCallbackSelectors; |
| 70 // Selectors are relative to m_matchingCallbackSelectors's contents at | 71 // Selectors are relative to m_matchingCallbackSelectors's contents at |
| 71 // the previous call to selectorMatchChanged. | 72 // the previous call to selectorMatchChanged. |
| 72 HashSet<String> m_addedSelectors; | 73 HashSet<String> m_addedSelectors; |
| 73 HashSet<String> m_removedSelectors; | 74 HashSet<String> m_removedSelectors; |
| 74 | 75 |
| 75 Timer<CSSSelectorWatch> m_callbackSelectorChangeTimer; | 76 Timer<CSSSelectorWatch> m_callbackSelectorChangeTimer; |
| 76 | 77 |
| 77 // When an element is reparented, the new location's style is evaluated afte
r the expriation of the relayout timer. | 78 // When an element is reparented, the new location's style is evaluated afte
r the expriation of the relayout timer. |
| 78 // We don't want to send redundant callbacks to the embedder, so this counte
r lets us wait another time around the event loop. | 79 // We don't want to send redundant callbacks to the embedder, so this counte
r lets us wait another time around the event loop. |
| 79 int m_timerExpirations; | 80 int m_timerExpirations; |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 } // namespace WebCore | 83 } // namespace WebCore |
| 83 | 84 |
| 84 #endif // CSSSelectorWatch_h | 85 #endif // CSSSelectorWatch_h |
| OLD | NEW |