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

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: address nits Created 5 years, 9 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()) {
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()));
68 // TODO(philipj): Remove the mutableStyleRef() and depend on CSS
69 // width/height: inherit to match the media element size.
70 layoutBox->mutableStyleRef().setHeight(Length(newSize.height(), Fixed));
71 layoutBox->mutableStyleRef().setWidth(Length(newSize.width(), Fixed));
72 layoutBox->forceLayout();
73 }
74
71 clearNeedsLayout(); 75 clearNeedsLayout();
72 } 76 }
73 77
74 bool LayoutMedia::isChildAllowed(LayoutObject* child, const LayoutStyle&) const 78 bool LayoutMedia::isChildAllowed(LayoutObject* child, const LayoutStyle&) const
75 { 79 {
76 // The only allowed child is the media controls. The user agent stylesheet 80 // Two types of child layout objects are allowed: media controls
77 // (mediaControls.css) has ::-webkit-media-controls { display: flex; }. If 81 // and the text track container. Filter children by node type.
78 // author style sets display: inline we would get an inline renderer as a 82 ASSERT(child->node());
79 // child of replaced content, which is not supposed to be possible. This 83
80 // check can be removed if ::-webkit-media-controls is made internal. 84 // The user agent stylesheet (mediaControls.css) has
81 return child->isFlexibleBox(); 85 // ::-webkit-media-controls { display: flex; }. If author style
86 // sets display: inline we would get an inline renderer as a child
87 // of replaced content, which is not supposed to be possible. This
88 // check can be removed if ::-webkit-media-controls is made
89 // internal.
90 if (child->node()->isMediaControls())
91 return child->isFlexibleBox();
92
93 if (child->node()->isTextTrackContainer())
94 return true;
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
« no previous file with comments | « Source/core/html/track/TextTrackContainer.cpp ('k') | Source/core/layout/LayoutTextTrackContainer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698