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

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

Issue 2479653003: Fix crash when computing media controls width for out of process iframe (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 152 }
153 153
154 void LayoutMedia::setRequestPositionUpdates(bool want) { 154 void LayoutMedia::setRequestPositionUpdates(bool want) {
155 if (want) 155 if (want)
156 view()->registerMediaForPositionChangeNotification(*this); 156 view()->registerMediaForPositionChangeNotification(*this);
157 else 157 else
158 view()->unregisterMediaForPositionChangeNotification(*this); 158 view()->unregisterMediaForPositionChangeNotification(*this);
159 } 159 }
160 160
161 LayoutUnit LayoutMedia::computePanelWidth(const LayoutRect& mediaRect) const { 161 LayoutUnit LayoutMedia::computePanelWidth(const LayoutRect& mediaRect) const {
162 // We don't know if the main frame has an horizontal scrollbar if it is out of
163 // process.
164 if (document().page()->mainFrame()->isRemoteFrame())
dcheng 2016/11/04 16:48:36 What breaks if we don't go through the rest of thi
mlamouri (slow - plz ping) 2016/11/04 17:00:56 The feature is meant to make the default controls
mlamouri (slow - plz ping) 2016/11/04 18:17:55 Do you want me to file a bug and add a TODO?
165 return mediaRect.width();
166
162 FrameHost* frameHost = document().frameHost(); 167 FrameHost* frameHost = document().frameHost();
163 LocalFrame* mainFrame = document().page()->deprecatedLocalMainFrame(); 168 LocalFrame* mainFrame = document().page()->deprecatedLocalMainFrame();
164 FrameView* pageView = mainFrame ? mainFrame->view() : nullptr; 169 FrameView* pageView = mainFrame ? mainFrame->view() : nullptr;
165 if (!frameHost || !mainFrame || !pageView) 170 if (!frameHost || !mainFrame || !pageView)
166 return mediaRect.width(); 171 return mediaRect.width();
167 172
168 if (pageView->horizontalScrollbarMode() != ScrollbarAlwaysOff) 173 if (pageView->horizontalScrollbarMode() != ScrollbarAlwaysOff)
169 return mediaRect.width(); 174 return mediaRect.width();
170 175
171 // On desktop, this will include scrollbars when they stay visible. 176 // On desktop, this will include scrollbars when they stay visible.
172 const LayoutUnit visibleWidth(frameHost->visualViewport().visibleWidth()); 177 const LayoutUnit visibleWidth(frameHost->visualViewport().visibleWidth());
173 const LayoutUnit absoluteXOffset( 178 const LayoutUnit absoluteXOffset(
174 localToAbsolute( 179 localToAbsolute(
175 FloatPoint(mediaRect.location()), 180 FloatPoint(mediaRect.location()),
176 UseTransforms | ApplyContainerFlip | TraverseDocumentBoundaries) 181 UseTransforms | ApplyContainerFlip | TraverseDocumentBoundaries)
177 .x()); 182 .x());
178 DCHECK_GE(visibleWidth - absoluteXOffset, 0); 183 DCHECK_GE(visibleWidth - absoluteXOffset, 0);
179 184
180 return std::min(mediaRect.width(), visibleWidth - absoluteXOffset); 185 return std::min(mediaRect.width(), visibleWidth - absoluteXOffset);
181 } 186 }
182 187
183 } // namespace blink 188 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698