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

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

Issue 1018593004: Implement <video controls> dodging for text track layout (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 10 matching lines...) Expand all
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 "config.h" 26 #include "config.h"
27 27
28 #include "core/layout/LayoutMedia.h" 28 #include "core/layout/LayoutMedia.h"
29 29
30 #include "core/html/HTMLMediaElement.h" 30 #include "core/html/HTMLMediaElement.h"
31 #include "core/html/shadow/MediaControls.h"
32 #include "core/layout/LayoutTextTrackContainer.h"
31 #include "core/layout/LayoutView.h" 33 #include "core/layout/LayoutView.h"
32 34
33 namespace blink { 35 namespace blink {
34 36
35 LayoutMedia::LayoutMedia(HTMLMediaElement* video) 37 LayoutMedia::LayoutMedia(HTMLMediaElement* video)
36 : LayoutImage(video) 38 : LayoutImage(video)
37 { 39 {
38 setImageResource(LayoutImageResource::create()); 40 setImageResource(LayoutImageResource::create());
39 } 41 }
40 42
41 LayoutMedia::~LayoutMedia() 43 LayoutMedia::~LayoutMedia()
42 { 44 {
43 } 45 }
44 46
45 HTMLMediaElement* LayoutMedia::mediaElement() const 47 HTMLMediaElement* LayoutMedia::mediaElement() const
46 { 48 {
47 return toHTMLMediaElement(node()); 49 return toHTMLMediaElement(node());
48 } 50 }
49 51
50 void LayoutMedia::layout() 52 void LayoutMedia::layout()
51 { 53 {
52 LayoutSize oldSize = contentBoxRect().size(); 54 LayoutSize oldSize = contentBoxRect().size();
53 55
54 LayoutImage::layout(); 56 LayoutImage::layout();
55 57
56 LayoutSize newSize = contentBoxRect().size(); 58 LayoutSize newSize = contentBoxRect().size();
57 59
60 bool sizeChanged = newSize != oldSize;
61
58 LayoutState state(*this, locationOffset()); 62 LayoutState state(*this, locationOffset());
59 63
60 for (LayoutObject* child = m_children.firstChild(); child; child = child->ne xtSibling()) { 64 // Iterate the children in reverse order so that the media controls are laid
61 ASSERT(child->node()->isMediaControls() || child->node()->isTextTrackCon tainer()); 65 // out before the text track container.
66 IntRect controlsRect;
67 #if ENABLE(ASSERT)
68 bool didLayoutTextTrackContainer = false;
69 #endif
70 for (LayoutObject* child = m_children.lastChild(); child; child = child->pre viousSibling()) {
fs 2015/03/17 10:27:56 I think you could also just drop the for-loop enti
71 bool isMediaControls = child->node()->isMediaControls();
72 bool isTextTrackContainer = child->node()->isTextTrackContainer();
73 ASSERT(isMediaControls || isTextTrackContainer);
62 74
63 if (newSize == oldSize && !child->needsLayout()) 75 if (isTextTrackContainer) {
64 continue; 76 #if ENABLE(ASSERT)
77 didLayoutTextTrackContainer = true;
78 #endif
79 static_cast<LayoutTextTrackContainer*>(child)->setControlsRect(contr olsRect);
80 }
65 81
66 LayoutBox* layoutBox = toLayoutBox(child); 82 if (sizeChanged || child->needsLayout()) {
67 layoutBox->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSi ze(paddingLeft(), paddingTop())); 83 LayoutBox* layoutBox = toLayoutBox(child);
68 layoutBox->style()->setHeight(Length(newSize.height(), Fixed)); 84 layoutBox->setLocation(LayoutPoint(borderLeft(), borderTop()) + Layo utSize(paddingLeft(), paddingTop()));
69 layoutBox->style()->setWidth(Length(newSize.width(), Fixed)); 85 layoutBox->style()->setHeight(Length(newSize.height(), Fixed));
70 layoutBox->forceLayout(); 86 layoutBox->style()->setWidth(Length(newSize.width(), Fixed));
87 layoutBox->forceLayout();
88 }
89
90 if (isMediaControls) {
91 ASSERT(!didLayoutTextTrackContainer);
92 controlsRect = toMediaControls(child->node())->absoluteRectForTextTr acks();
93 }
71 } 94 }
72 95
73 clearNeedsLayout(); 96 clearNeedsLayout();
74 } 97 }
75 98
76 bool LayoutMedia::isChildAllowed(LayoutObject* child, const LayoutStyle&) const 99 bool LayoutMedia::isChildAllowed(LayoutObject* child, const LayoutStyle&) const
77 { 100 {
78 // Two types of child layout objects are allowed: media controls 101 // Two types of child layout objects are allowed: media controls
79 // and the text track container. Filter children by node type. 102 // and the text track container. Filter children by node type.
80 ASSERT(child->node()); 103 ASSERT(child->node());
(...skipping 11 matching lines...) Expand all
92 return true; 115 return true;
93 116
94 return false; 117 return false;
95 } 118 }
96 119
97 void LayoutMedia::paintReplaced(const PaintInfo&, const LayoutPoint&) 120 void LayoutMedia::paintReplaced(const PaintInfo&, const LayoutPoint&)
98 { 121 {
99 } 122 }
100 123
101 } // namespace blink 124 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/track/TextTrackContainer.cpp ('k') | Source/core/layout/LayoutTextTrackContainer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698