| 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 class Element; | 38 class Element; |
| 39 | 39 |
| 40 class CustomElementObserver { | 40 class CustomElementObserver { |
| 41 public: | 41 public: |
| 42 CustomElementObserver() { } | 42 CustomElementObserver() { } |
| 43 virtual ~CustomElementObserver() { } | 43 virtual ~CustomElementObserver() { } |
| 44 | 44 |
| 45 // API for CustomElement to kick off notifications | 45 // API for CustomElement to kick off notifications |
| 46 | 46 |
| 47 static void notifyElementDidFinishParsingChildren(Element*); |
| 47 static void notifyElementWasDestroyed(Element*); | 48 static void notifyElementWasDestroyed(Element*); |
| 48 | 49 |
| 49 protected: | 50 protected: |
| 50 void observe(Element*); | 51 void observe(Element*); |
| 51 void unobserve(Element*); | 52 void unobserve(Element*); |
| 52 | 53 |
| 54 virtual void elementDidFinishParsingChildren(Element*) = 0; |
| 53 virtual void elementWasDestroyed(Element* element) { unobserve(element); } | 55 virtual void elementWasDestroyed(Element* element) { unobserve(element); } |
| 54 | 56 |
| 55 private: | 57 private: |
| 56 // Maps elements to the observer watching them. At most one per | 58 // Maps elements to the observer watching them. At most one per |
| 57 // element at a time. | 59 // element at a time. |
| 58 typedef HashMap<Element*, CustomElementObserver*> ElementObserverMap; | 60 typedef HashMap<Element*, CustomElementObserver*> ElementObserverMap; |
| 59 static ElementObserverMap& elementObservers(); | 61 static ElementObserverMap& elementObservers(); |
| 60 }; | 62 }; |
| 61 | 63 |
| 62 } | 64 } |
| 63 | 65 |
| 64 #endif // CustomElementObserver_h | 66 #endif // CustomElementObserver_h |
| OLD | NEW |