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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutMedia.cpp

Issue 1370723002: Include viewport visibility checks for autoplay experiment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: identical to PS4 on 1329853004 (probably rebased) Created 5 years, 2 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
OLDNEW
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
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
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);
esprehn 2015/10/01 07:04:14 inline the remove case here
liberato (no reviews please) 2015/10/01 22:49:02 Done.
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);
esprehn 2015/10/01 07:04:14 remove this, you don't need to hook inserted at al
liberato (no reviews please) 2015/10/01 22:49:02 inserted is needed to catch cases where an element
137 }
138
139 void LayoutMedia::willBeRemovedFromTree()
esprehn 2015/10/01 07:04:14 why do you hook removal? I don't think you need th
liberato (no reviews please) 2015/10/01 22:49:02 Done.
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 if (HTMLMediaElement* element = mediaElement())
152 element->notifyPositionMayHaveChanged();
153 }
154
155 void LayoutMedia::updatePositionChangeRegistration(bool doRegister)
156 {
157 // If we don't have a view, then take no action.
158 if (!view())
ojan 2015/10/01 06:14:26 Pretty sure this isn't possible.
liberato (no reviews please) 2015/10/01 22:49:02 it does happen during the test: #0 0x000000463b2b
159 return;
160
161 // If our registration state matches the incoming state, then no work
162 // is needed.
163 if (doRegister == m_registeredForPositionChangeNotifications)
164 return;
165
166 if (doRegister)
esprehn 2015/10/01 07:04:14 Remove this method
liberato (no reviews please) 2015/10/01 22:49:03 Done.
167 view()->registerMediaForPositionChangeNotification(this);
168 else
169 view()->unregisterMediaForPositionChangeNotification(this);
170
171 m_registeredForPositionChangeNotifications = doRegister;
172 }
173
174 void LayoutMedia::setRequestPositionUpdates(bool want)
175 {
176 m_wantPositionChangeNotifications = want;
177 updatePositionChangeRegistration(m_wantPositionChangeNotifications);
esprehn 2015/10/01 07:04:14 inline the positive case here
liberato (no reviews please) 2015/10/01 22:49:02 Done, though both cases are used.
178 }
179
122 } // namespace blink 180 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698