Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(873)

Unified Diff: Source/core/rendering/PartialLayoutState.h

Issue 18601002: Add infrastructure for partial layouts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address reviewer comments. Add PartialLayoutState and PartialLayoutDisabler Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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; }
+ bool checkPartialLayoutComplete(RenderObject*);
+ void setStopAtRenderer(RenderObject* renderer) { m_stopAtRenderer = renderer; }
+ RenderObject* stopAtRenderer() { return m_disableCount > 0 ? 0 : m_stopAtRenderer; }
+ void reset() { m_shouldStop = false; m_stopAtRenderer = 0; }
- static PassRefPtr<MIDIConnectionEvent> create(const AtomicString& type, const MIDIConnectionEventInit& initializer)
- {
- return adoptRef(new MIDIConnectionEvent(type, initializer));
- }
+private:
+ void disable() { m_disableCount++; }
+ void enable() { ASSERT(m_disableCount > 0); m_disableCount--; }
- RefPtr<MIDIPort> port() { return m_port; }
+ bool m_shouldStop;
+ RenderObject* m_stopAtRenderer;
+ int m_disableCount;
+};
- virtual const AtomicString& interfaceName() const OVERRIDE { return eventNames().interfaceForMIDIConnectionEvent; }
+inline bool PartialLayoutState::checkPartialLayoutComplete(RenderObject* renderer)
+{
+ if (m_shouldStop)
+ return true;
-private:
- MIDIConnectionEvent()
- {
- ScriptWrappable::init(this);
+ if (renderer == stopAtRenderer()) {
+ m_shouldStop = true;
+ m_stopAtRenderer = 0;
+ 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)
+ : 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

Powered by Google App Engine
This is Rietveld 408576698