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

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

Issue 949203002: Separate the text track container from the media controls (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: same size as media controls Created 5 years, 10 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) 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 { 46 {
47 return toHTMLMediaElement(node()); 47 return toHTMLMediaElement(node());
48 } 48 }
49 49
50 void LayoutMedia::layout() 50 void LayoutMedia::layout()
51 { 51 {
52 LayoutSize oldSize = contentBoxRect().size(); 52 LayoutSize oldSize = contentBoxRect().size();
53 53
54 LayoutImage::layout(); 54 LayoutImage::layout();
55 55
56 LayoutBox* controlsRenderer = toLayoutBox(m_children.firstChild());
57 if (!controlsRenderer)
58 return;
59
60 bool controlsNeedLayout = controlsRenderer->needsLayout();
61 LayoutSize newSize = contentBoxRect().size(); 56 LayoutSize newSize = contentBoxRect().size();
62 if (newSize == oldSize && !controlsNeedLayout)
63 return;
64 57
65 LayoutState state(*this, locationOffset()); 58 LayoutState state(*this, locationOffset());
66 59
67 controlsRenderer->setLocation(LayoutPoint(borderLeft(), borderTop()) + Layou tSize(paddingLeft(), paddingTop())); 60 for (LayoutObject* child = m_children.firstChild(); child; child = child->ne xtSibling()) {
philipj_slow 2015/02/26 09:51:52 Rune, does this make any sense? I couldn't find an
fs 2015/02/26 12:30:51 I believe RenderBlockFlow uses a while-loop (see R
rune 2015/02/26 13:17:15 I'm not too familiar with layout, but this looks l
philipj_slow 2015/02/27 07:13:52 Yeah, I'll leave this alone if it's not too terrib
68 controlsRenderer->style()->setHeight(Length(newSize.height(), Fixed)); 61 ASSERT(child->node()->isMediaControls() || child->node()->isTextTrackCon tainer());
69 controlsRenderer->style()->setWidth(Length(newSize.width(), Fixed)); 62
70 controlsRenderer->forceLayout(); 63 if (newSize == oldSize && !child->needsLayout())
64 continue;
65
66 LayoutBox* layoutBox = toLayoutBox(child);
67 layoutBox->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSi ze(paddingLeft(), paddingTop()));
philipj_slow 2015/02/26 09:51:52 Not sure if this could be done with width/height:
68 layoutBox->style()->setHeight(Length(newSize.height(), Fixed));
69 layoutBox->style()->setWidth(Length(newSize.width(), Fixed));
70 layoutBox->forceLayout();
71 }
72
71 clearNeedsLayout(); 73 clearNeedsLayout();
72 } 74 }
73 75
74 bool LayoutMedia::isChildAllowed(LayoutObject* child, const LayoutStyle&) const 76 bool LayoutMedia::isChildAllowed(LayoutObject* child, const LayoutStyle&) const
75 { 77 {
76 // The only allowed child is the media controls. The user agent stylesheet 78 // Two types of child layout objects are allowed: media controls
77 // (mediaControls.css) has ::-webkit-media-controls { display: flex; }. If 79 // and the text track container.
78 // author style sets display: inline we would get an inline renderer as a 80
79 // child of replaced content, which is not supposed to be possible. This 81 // The user agent stylesheet (mediaControls.css) has
80 // check can be removed if ::-webkit-media-controls is made internal. 82 // ::-webkit-media-controls { display: flex; }. If author style
81 return child->isFlexibleBox(); 83 // sets display: inline we would get an inline renderer as a child
84 // of replaced content, which is not supposed to be possible. This
85 // check can be removed if ::-webkit-media-controls is made
86 // internal.
87 if (child->node()->isMediaControls())
fs 2015/02/26 12:30:51 Maybe assert child->node() here (in this method) a
philipj_slow 2015/02/27 07:13:52 Done.
88 return child->isFlexibleBox();
89
90 // The text track container should only be added for video elements.
91 if (child->node()->isTextTrackContainer()) {
92 ASSERT(isVideo());
93 return true;
94 }
95
96 return false;
82 } 97 }
83 98
84 void LayoutMedia::paintReplaced(const PaintInfo&, const LayoutPoint&) 99 void LayoutMedia::paintReplaced(const PaintInfo&, const LayoutPoint&)
85 { 100 {
86 } 101 }
87 102
88 } // namespace blink 103 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698