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 10 matching lines...) Expand all Loading... | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef MIDIConnectionEvent_h | 31 #ifndef PartialLayoutState_h |
32 #define MIDIConnectionEvent_h | 32 #define PartialLayoutState_h |
33 | 33 |
34 #include "core/dom/Event.h" | 34 #include "core/rendering/RenderObject.h" |
35 #include "modules/webmidi/MIDIPort.h" | |
36 | 35 |
37 namespace WebCore { | 36 namespace WebCore { |
38 | 37 |
39 struct MIDIConnectionEventInit : public EventInit { | 38 class PartialLayoutState { |
40 MIDIConnectionEventInit() | 39 friend class PartialLayoutDisabler; |
41 : port(0) | 40 public: |
41 PartialLayoutState() | |
42 : m_shouldStop(false) | |
43 , m_stopAtRenderer(0) | |
44 , m_disableCount(0) | |
42 { | 45 { |
43 }; | 46 } |
44 | 47 |
45 RefPtr<MIDIPort> port; | 48 bool shouldStop() const { return m_shouldStop; } |
eseidel
2013/09/03 19:14:27
I might have called this isStopping()?
pdr.
2013/09/03 21:37:35
Done.
| |
49 bool checkPartialLayoutComplete(RenderObject*); | |
eseidel
2013/09/03 19:14:27
const?
pdr.
2013/09/03 21:37:35
Done.
| |
50 void setStopAtRenderer(RenderObject* renderer) { m_stopAtRenderer = renderer ; } | |
eseidel
2013/09/03 19:14:27
const?
pdr.
2013/09/03 21:37:35
Done.
| |
51 RenderObject* stopAtRenderer() { return m_disableCount > 0 ? 0 : m_stopAtRen derer; } | |
esprehn
2013/09/03 18:15:36
Is there a reason stopAtRenderer() needs to be pub
eseidel
2013/09/03 19:14:27
const?
pdr.
2013/09/03 21:37:35
Done.
| |
52 void reset() { m_shouldStop = false; m_stopAtRenderer = 0; } | |
eseidel
2013/09/03 19:14:27
Yeah, I would probably have added assignment inste
pdr.
2013/09/03 21:37:35
Mind if we save this for a followup?
This may tur
| |
53 | |
54 private: | |
55 void disable() { m_disableCount++; } | |
eseidel
2013/09/03 19:14:27
ASSERT(!m_shouldStop);?
pdr.
2013/09/03 21:37:35
Done.
| |
56 void enable() { ASSERT(m_disableCount > 0); m_disableCount--; } | |
57 | |
58 bool m_shouldStop; | |
eseidel
2013/09/03 19:14:27
This tracks "did we reach the stopping renderer ye
pdr.
2013/09/03 21:37:35
EOn 2013/09/03 19:14:27, eseidel wrote:
| |
59 RenderObject* m_stopAtRenderer; | |
60 int m_disableCount; | |
46 }; | 61 }; |
47 | 62 |
48 class MIDIConnectionEvent : public Event { | 63 inline bool PartialLayoutState::checkPartialLayoutComplete(RenderObject* rendere r) |
49 public: | 64 { |
50 static PassRefPtr<MIDIConnectionEvent> create() | 65 if (m_shouldStop) |
eseidel
2013/09/03 19:14:27
Is it OK for this method to be called after should
pdr.
2013/09/03 21:37:35
This is a good question.
This function is combini
| |
51 { | 66 return true; |
52 return adoptRef(new MIDIConnectionEvent()); | 67 |
68 if (renderer == stopAtRenderer()) { | |
69 m_shouldStop = true; | |
70 m_stopAtRenderer = 0; | |
eseidel
2013/09/03 19:14:27
You might add a note as to why you clear the m_sto
| |
71 return true; | |
53 } | 72 } |
54 | 73 |
55 static PassRefPtr<MIDIConnectionEvent> create(const AtomicString& type, Pass RefPtr<MIDIPort> port) | 74 return false; |
75 } | |
76 | |
77 class PartialLayoutDisabler { | |
78 WTF_MAKE_NONCOPYABLE(PartialLayoutDisabler); | |
79 public: | |
80 PartialLayoutDisabler(PartialLayoutState& partialLayout, bool disable) | |
eseidel
2013/09/03 19:14:27
should disable default to true?
pdr.
2013/09/03 21:37:35
Done.
| |
81 : m_partialLayout(partialLayout) | |
82 , m_disable(disable) | |
56 { | 83 { |
57 return adoptRef(new MIDIConnectionEvent(type, port)); | 84 if (m_disable) |
85 m_partialLayout.disable(); | |
58 } | 86 } |
59 | 87 |
60 static PassRefPtr<MIDIConnectionEvent> create(const AtomicString& type, cons t MIDIConnectionEventInit& initializer) | 88 ~PartialLayoutDisabler() |
61 { | 89 { |
62 return adoptRef(new MIDIConnectionEvent(type, initializer)); | 90 if (m_disable) |
91 m_partialLayout.enable(); | |
63 } | 92 } |
64 | |
65 RefPtr<MIDIPort> port() { return m_port; } | |
66 | |
67 virtual const AtomicString& interfaceName() const OVERRIDE { return eventNam es().interfaceForMIDIConnectionEvent; } | |
68 | |
69 private: | 93 private: |
70 MIDIConnectionEvent() | 94 PartialLayoutState& m_partialLayout; |
71 { | 95 bool m_disable; |
72 ScriptWrappable::init(this); | |
73 } | |
74 | |
75 MIDIConnectionEvent(const AtomicString& type, PassRefPtr<MIDIPort> port) | |
76 : Event(type, false, false) | |
77 , m_port(port) | |
78 { | |
79 ScriptWrappable::init(this); | |
80 } | |
81 | |
82 MIDIConnectionEvent(const AtomicString& type, const MIDIConnectionEventInit& initializer) | |
83 : Event(type, initializer) | |
84 , m_port(initializer.port) | |
85 { | |
86 ScriptWrappable::init(this); | |
87 } | |
88 | |
89 RefPtr<MIDIPort> m_port; | |
90 }; | 96 }; |
91 | 97 |
92 } // namespace WebCore | 98 } // namespace WebCore |
93 | 99 |
94 #endif // MIDIConnectionEvent_h | 100 #endif // PartialLayoutState_h |
OLD | NEW |