OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010 Apple 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 17 matching lines...) Expand all Loading... | |
28 #include "core/layout/LayoutMedia.h" | 28 #include "core/layout/LayoutMedia.h" |
29 | 29 |
30 #include "core/html/HTMLMediaElement.h" | 30 #include "core/html/HTMLMediaElement.h" |
31 #include "core/html/shadow/MediaControls.h" | 31 #include "core/html/shadow/MediaControls.h" |
32 #include "core/layout/LayoutView.h" | 32 #include "core/layout/LayoutView.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 LayoutMedia::LayoutMedia(HTMLMediaElement* video) | 36 LayoutMedia::LayoutMedia(HTMLMediaElement* video) |
37 : LayoutImage(video) | 37 : LayoutImage(video) |
38 , m_registeredForPositionChangeNotifications(false) | |
39 , m_wantPositionChangeNotifications(false) | |
38 { | 40 { |
39 setImageResource(LayoutImageResource::create()); | 41 setImageResource(LayoutImageResource::create()); |
40 } | 42 } |
41 | 43 |
42 LayoutMedia::~LayoutMedia() | 44 LayoutMedia::~LayoutMedia() |
43 { | 45 { |
44 } | 46 } |
45 | 47 |
46 HTMLMediaElement* LayoutMedia::mediaElement() const | 48 HTMLMediaElement* LayoutMedia::mediaElement() const |
47 { | 49 { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 if (child->node()->isTextTrackContainer()) | 114 if (child->node()->isTextTrackContainer()) |
113 return true; | 115 return true; |
114 | 116 |
115 return false; | 117 return false; |
116 } | 118 } |
117 | 119 |
118 void LayoutMedia::paintReplaced(const PaintInfo&, const LayoutPoint&) | 120 void LayoutMedia::paintReplaced(const PaintInfo&, const LayoutPoint&) |
119 { | 121 { |
120 } | 122 } |
121 | 123 |
124 void LayoutMedia::willBeDestroyed() | |
125 { | |
126 updatePositionChangeRegistration(false); | |
127 LayoutImage::willBeDestroyed(); | |
128 } | |
129 | |
130 void LayoutMedia::insertedIntoTree() | |
131 { | |
132 LayoutImage::insertedIntoTree(); | |
133 | |
134 // Note that if we don't want them and aren't registered, then this | |
135 // will do nothing. | |
136 updatePositionChangeRegistration(m_wantPositionChangeNotifications); | |
137 } | |
138 | |
139 void LayoutMedia::willBeRemovedFromTree() | |
140 { | |
141 // Note that if we don't want them and/or aren't registered, then this | |
142 // will do nothing. | |
143 updatePositionChangeRegistration(false); | |
144 | |
145 LayoutImage::willBeRemovedFromTree(); | |
146 } | |
147 | |
148 void LayoutMedia::notifyPositionMayHaveChanged() | |
149 { | |
150 // Tell our element about it. | |
151 HTMLMediaElement* element = mediaElement(); | |
152 if (element) | |
ojan
2015/09/01 20:20:11
Nit: Typical blink style is to do the following, s
liberato (no reviews please)
2015/09/04 06:49:46
never thought of that, thanks!
| |
153 element->notifyPositionMayHaveChanged(); | |
ojan
2015/09/01 20:20:11
How about having the LayoutMedia store a bit as to
liberato (no reviews please)
2015/09/04 06:49:46
i implemented the logic as you suggest. however,
| |
154 } | |
155 | |
156 void LayoutMedia::updatePositionChangeRegistration(bool doRegister) | |
157 { | |
158 // If we don't have a view, then take no action. | |
159 if (!view()) | |
160 return; | |
161 | |
162 // If our registration state matches the incoming state, then no work | |
163 // is needed. | |
164 if (doRegister == m_registeredForPositionChangeNotifications) | |
165 return; | |
166 | |
167 if (doRegister) | |
168 view()->registerMediaForPositionChangeNotification(this); | |
169 else | |
170 view()->unregisterMediaForPositionChangeNotification(this); | |
171 | |
172 m_registeredForPositionChangeNotifications = doRegister; | |
173 } | |
174 | |
175 void LayoutMedia::setRequestPositionUpdates(bool want) | |
176 { | |
177 m_wantPositionChangeNotifications = want; | |
178 updatePositionChangeRegistration(m_wantPositionChangeNotifications); | |
179 } | |
180 | |
122 } // namespace blink | 181 } // namespace blink |
OLD | NEW |