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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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; }
49 bool checkPartialLayoutComplete(RenderObject*);
50 void setStopAtRenderer(RenderObject* renderer) { m_stopAtRenderer = renderer ; }
51 RenderObject* stopAtRenderer() { return m_disableCount > 0 ? 0 : m_stopAtRen derer; }
52 void reset() { m_shouldStop = false; m_stopAtRenderer = 0; }
53
54 private:
55 void disable() { m_disableCount++; }
56 void enable() { ASSERT(m_disableCount > 0); m_disableCount--; }
57
58 bool m_shouldStop;
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)
51 { 66 return true;
52 return adoptRef(new MIDIConnectionEvent()); 67
68 if (renderer == stopAtRenderer()) {
69 m_shouldStop = true;
70 m_stopAtRenderer = 0;
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)
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698