OLD | NEW |
---|---|
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 Loading... | |
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 layoutBox->style()->setHeight(Length(newSize.height(), Fixed)); | |
fs
2015/03/20 09:51:01
Should probably use "mutableStyleRef" here to avoi
philipj_slow
2015/03/20 15:26:11
Done.
| |
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. Filter children by node type. |
78 // author style sets display: inline we would get an inline renderer as a | 80 ASSERT(child->node()); |
79 // child of replaced content, which is not supposed to be possible. This | 81 |
80 // check can be removed if ::-webkit-media-controls is made internal. | 82 // The user agent stylesheet (mediaControls.css) has |
81 return child->isFlexibleBox(); | 83 // ::-webkit-media-controls { display: flex; }. If author style |
84 // sets display: inline we would get an inline renderer as a child | |
85 // of replaced content, which is not supposed to be possible. This | |
86 // check can be removed if ::-webkit-media-controls is made | |
87 // internal. | |
88 if (child->node()->isMediaControls()) | |
89 return child->isFlexibleBox(); | |
90 | |
91 if (child->node()->isTextTrackContainer()) | |
92 return true; | |
93 | |
94 return false; | |
82 } | 95 } |
83 | 96 |
84 void LayoutMedia::paintReplaced(const PaintInfo&, const LayoutPoint&) | 97 void LayoutMedia::paintReplaced(const PaintInfo&, const LayoutPoint&) |
85 { | 98 { |
86 } | 99 } |
87 | 100 |
88 } // namespace blink | 101 } // namespace blink |
OLD | NEW |