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

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

Issue 2795783004: Move core MediaControls implementation to modules/media_controls/. (Closed)
Patch Set: rebase Created 3 years, 8 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) 2012 Victor Carbune (victor@rosedu.org) 2 * Copyright (C) 2012 Victor Carbune (victor@rosedu.org)
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "core/layout/LayoutVTTCue.h" 26 #include "core/layout/LayoutVTTCue.h"
27 27
28 #include "core/frame/Settings.h" 28 #include "core/frame/Settings.h"
29 #include "core/html/shadow/MediaControls.h" 29 #include "core/html/HTMLMediaElement.h"
30 #include "core/html/media/MediaControls.h"
30 #include "core/layout/LayoutInline.h" 31 #include "core/layout/LayoutInline.h"
31 #include "core/layout/LayoutState.h" 32 #include "core/layout/LayoutState.h"
32 #include "wtf/MathExtras.h" 33 #include "wtf/MathExtras.h"
33 34
34 namespace blink { 35 namespace blink {
35 36
36 namespace { 37 namespace {
37 38
38 class SnapToLinesLayouter { 39 class SnapToLinesLayouter {
39 STACK_ALLOCATED(); 40 STACK_ALLOCATED();
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 // done positioning below. If there are multiple such positions that are 320 // done positioning below. If there are multiple such positions that are
320 // equidistant from their current position, use the highest one amongst 321 // equidistant from their current position, use the highest one amongst
321 // them; if there are several at that height, then use the leftmost one 322 // them; if there are several at that height, then use the leftmost one
322 // amongst them. 323 // amongst them.
323 324
324 // 5. Otherwise, jump to the step labeled done positioning below. (The 325 // 5. Otherwise, jump to the step labeled done positioning below. (The
325 // boxes will unfortunately overlap.) 326 // boxes will unfortunately overlap.)
326 } 327 }
327 328
328 IntRect LayoutVTTCue::computeControlsRect() const { 329 IntRect LayoutVTTCue::computeControlsRect() const {
329 // Determine the area covered by the media controls, if any. If the controls 330 // Determine the area covered by the media controls, if any. For this, the
330 // are present, they are the next sibling of the text track container, which 331 // LayoutVTTCue will walk the tree up to the HTMLMediaElement, then ask for
331 // is our parent. (LayoutMedia ensures that the media controls are laid out 332 // the MediaControls.
332 // before text tracks, so that the layout is up to date here.)
333 DCHECK(parent()->node()->isTextTrackContainer()); 333 DCHECK(parent()->node()->isTextTrackContainer());
334 LayoutObject* controlsContainer = parent()->nextSibling(); 334 DCHECK(isHTMLMediaElement(parent()->parent()->node()));
335 if (!controlsContainer) 335
336 HTMLMediaElement* mediaElement =
337 toHTMLMediaElement(parent()->parent()->node());
338 DCHECK(mediaElement);
339
340 MediaControls* controls = mediaElement->mediaControls();
341 if (!controls || !controls->containerLayoutObject())
336 return IntRect(); 342 return IntRect();
343
337 // Only a part of the media controls is used for overlap avoidance. 344 // Only a part of the media controls is used for overlap avoidance.
338 MediaControls* controls = toMediaControls(controlsContainer->node()); 345 LayoutObject* panelLayoutObject =
339 LayoutObject* controlsLayout = controls->layoutObjectForTextTrackLayout(); 346 mediaElement->mediaControls()->panelLayoutObject();
347
340 // The (second part of the) following is mostly defensive - in general 348 // The (second part of the) following is mostly defensive - in general
341 // there should be a LayoutBox representing the part of the controls that 349 // there should be a LayoutBox representing the part of the controls that
342 // are relevant for overlap avoidance. (The controls pseudo elements are 350 // are relevant for overlap avoidance. (The controls pseudo elements are
343 // generally reachable from outside the shadow tree though, hence the 351 // generally reachable from outside the shadow tree though, hence the
344 // "mostly".) 352 // "mostly".)
345 if (!controlsLayout || !controlsLayout->isBox()) 353 if (!panelLayoutObject || !panelLayoutObject->isBox())
346 return IntRect(); 354 return IntRect();
355
347 // Assume that the controls container are positioned in the same relative 356 // Assume that the controls container are positioned in the same relative
348 // position as the text track container. (LayoutMedia::layout ensures this.) 357 // position as the text track container. (LayoutMedia::layout ensures this.)
349 return contentBoxRelativeToAncestor(toLayoutBox(*controlsLayout), 358 return contentBoxRelativeToAncestor(
350 toLayoutBox(*controlsContainer)); 359 toLayoutBox(*panelLayoutObject),
360 toLayoutBox(*controls->containerLayoutObject()));
351 } 361 }
352 362
353 void LayoutVTTCue::layout() { 363 void LayoutVTTCue::layout() {
354 LayoutBlockFlow::layout(); 364 LayoutBlockFlow::layout();
355 365
356 DCHECK(firstChild()); 366 DCHECK(firstChild());
357 367
358 LayoutState state(*this); 368 LayoutState state(*this);
359 369
360 // http://dev.w3.org/html5/webvtt/#dfn-apply-webvtt-cue-settings - step 13. 370 // http://dev.w3.org/html5/webvtt/#dfn-apply-webvtt-cue-settings - step 13.
361 if (!std::isnan(m_snapToLinesPosition)) 371 if (!std::isnan(m_snapToLinesPosition))
362 SnapToLinesLayouter(*this, computeControlsRect()).layout(); 372 SnapToLinesLayouter(*this, computeControlsRect()).layout();
363 else 373 else
364 repositionCueSnapToLinesNotSet(); 374 repositionCueSnapToLinesNotSet();
365 } 375 }
366 376
367 } // namespace blink 377 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutMedia.cpp ('k') | third_party/WebKit/Source/core/paint/MediaControlsPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698