Index: Source/core/rendering/PartialLayoutState.h |
diff --git a/Source/modules/webmidi/MIDIConnectionEvent.h b/Source/core/rendering/PartialLayoutState.h |
similarity index 51% |
copy from Source/modules/webmidi/MIDIConnectionEvent.h |
copy to Source/core/rendering/PartialLayoutState.h |
index 4b193ee5df10f863f164b2eabb3a0a41185af54a..f2fcfa29196dbc93de0bfbe8485ff780595ae89f 100644 |
--- a/Source/modules/webmidi/MIDIConnectionEvent.h |
+++ b/Source/core/rendering/PartialLayoutState.h |
@@ -28,67 +28,73 @@ |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef MIDIConnectionEvent_h |
-#define MIDIConnectionEvent_h |
+#ifndef PartialLayoutState_h |
+#define PartialLayoutState_h |
-#include "core/dom/Event.h" |
-#include "modules/webmidi/MIDIPort.h" |
+#include "core/rendering/RenderObject.h" |
namespace WebCore { |
-struct MIDIConnectionEventInit : public EventInit { |
- MIDIConnectionEventInit() |
- : port(0) |
- { |
- }; |
- |
- RefPtr<MIDIPort> port; |
-}; |
- |
-class MIDIConnectionEvent : public Event { |
+class PartialLayoutState { |
+ friend class PartialLayoutDisabler; |
public: |
- static PassRefPtr<MIDIConnectionEvent> create() |
+ PartialLayoutState() |
+ : m_shouldStop(false) |
+ , m_stopAtRenderer(0) |
+ , m_disableCount(0) |
{ |
- return adoptRef(new MIDIConnectionEvent()); |
} |
- static PassRefPtr<MIDIConnectionEvent> create(const AtomicString& type, PassRefPtr<MIDIPort> port) |
- { |
- return adoptRef(new MIDIConnectionEvent(type, port)); |
- } |
+ 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.
|
+ bool checkPartialLayoutComplete(RenderObject*); |
eseidel
2013/09/03 19:14:27
const?
pdr.
2013/09/03 21:37:35
Done.
|
+ void setStopAtRenderer(RenderObject* renderer) { m_stopAtRenderer = renderer; } |
eseidel
2013/09/03 19:14:27
const?
pdr.
2013/09/03 21:37:35
Done.
|
+ RenderObject* stopAtRenderer() { return m_disableCount > 0 ? 0 : m_stopAtRenderer; } |
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.
|
+ 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
|
- static PassRefPtr<MIDIConnectionEvent> create(const AtomicString& type, const MIDIConnectionEventInit& initializer) |
- { |
- return adoptRef(new MIDIConnectionEvent(type, initializer)); |
- } |
+private: |
+ void disable() { m_disableCount++; } |
eseidel
2013/09/03 19:14:27
ASSERT(!m_shouldStop);?
pdr.
2013/09/03 21:37:35
Done.
|
+ void enable() { ASSERT(m_disableCount > 0); m_disableCount--; } |
- RefPtr<MIDIPort> port() { return m_port; } |
+ 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:
|
+ RenderObject* m_stopAtRenderer; |
+ int m_disableCount; |
+}; |
- virtual const AtomicString& interfaceName() const OVERRIDE { return eventNames().interfaceForMIDIConnectionEvent; } |
+inline bool PartialLayoutState::checkPartialLayoutComplete(RenderObject* renderer) |
+{ |
+ 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
|
+ return true; |
-private: |
- MIDIConnectionEvent() |
- { |
- ScriptWrappable::init(this); |
+ if (renderer == stopAtRenderer()) { |
+ m_shouldStop = true; |
+ m_stopAtRenderer = 0; |
eseidel
2013/09/03 19:14:27
You might add a note as to why you clear the m_sto
|
+ return true; |
} |
- MIDIConnectionEvent(const AtomicString& type, PassRefPtr<MIDIPort> port) |
- : Event(type, false, false) |
- , m_port(port) |
+ return false; |
+} |
+ |
+class PartialLayoutDisabler { |
+ WTF_MAKE_NONCOPYABLE(PartialLayoutDisabler); |
+public: |
+ 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.
|
+ : m_partialLayout(partialLayout) |
+ , m_disable(disable) |
{ |
- ScriptWrappable::init(this); |
+ if (m_disable) |
+ m_partialLayout.disable(); |
} |
- MIDIConnectionEvent(const AtomicString& type, const MIDIConnectionEventInit& initializer) |
- : Event(type, initializer) |
- , m_port(initializer.port) |
+ ~PartialLayoutDisabler() |
{ |
- ScriptWrappable::init(this); |
+ if (m_disable) |
+ m_partialLayout.enable(); |
} |
- |
- RefPtr<MIDIPort> m_port; |
+private: |
+ PartialLayoutState& m_partialLayout; |
+ bool m_disable; |
}; |
} // namespace WebCore |
-#endif // MIDIConnectionEvent_h |
+#endif // PartialLayoutState_h |