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

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

Issue 1653673002: Even more explicit LayoutUnit conversion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@moarConstructors
Patch Set: address comments Created 4 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
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 { 45 {
46 return toHTMLMediaElement(node()); 46 return toHTMLMediaElement(node());
47 } 47 }
48 48
49 void LayoutMedia::layout() 49 void LayoutMedia::layout()
50 { 50 {
51 LayoutSize oldSize = contentBoxRect().size(); 51 LayoutSize oldSize = contentBoxRect().size();
52 52
53 LayoutImage::layout(); 53 LayoutImage::layout();
54 54
55 LayoutSize newSize = contentBoxRect().size(); 55 LayoutRect newRect = contentBoxRect();
56 56
57 LayoutState state(*this, locationOffset()); 57 LayoutState state(*this, locationOffset());
58 58
59 // Iterate the children in reverse order so that the media controls are laid 59 // Iterate the children in reverse order so that the media controls are laid
60 // out before the text track container. This is to ensure that the text 60 // out before the text track container. This is to ensure that the text
61 // track rendering has an up-to-date position of the media controls for 61 // track rendering has an up-to-date position of the media controls for
62 // overlap checking, see LayoutVTTCue. 62 // overlap checking, see LayoutVTTCue.
63 #if ENABLE(ASSERT) 63 #if ENABLE(ASSERT)
64 bool seenTextTrackContainer = false; 64 bool seenTextTrackContainer = false;
65 #endif 65 #endif
66 for (LayoutObject* child = m_children.lastChild(); child; child = child->pre viousSibling()) { 66 for (LayoutObject* child = m_children.lastChild(); child; child = child->pre viousSibling()) {
67 #if ENABLE(ASSERT) 67 #if ENABLE(ASSERT)
68 if (child->node()->isMediaControls()) 68 if (child->node()->isMediaControls())
69 ASSERT(!seenTextTrackContainer); 69 ASSERT(!seenTextTrackContainer);
70 else if (child->node()->isTextTrackContainer()) 70 else if (child->node()->isTextTrackContainer())
71 seenTextTrackContainer = true; 71 seenTextTrackContainer = true;
72 else 72 else
73 ASSERT_NOT_REACHED(); 73 ASSERT_NOT_REACHED();
74 #endif 74 #endif
75 75
76 if (newSize == oldSize && !child->needsLayout()) 76 if (newRect.size() == oldSize && !child->needsLayout())
77 continue; 77 continue;
78 78
79 LayoutBox* layoutBox = toLayoutBox(child); 79 LayoutBox* layoutBox = toLayoutBox(child);
80 layoutBox->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSi ze(paddingLeft(), paddingTop())); 80 layoutBox->setLocation(newRect.location());
81 // TODO(philipj): Remove the mutableStyleRef() and depend on CSS 81 // TODO(philipj): Remove the mutableStyleRef() and depend on CSS
82 // width/height: inherit to match the media element size. 82 // width/height: inherit to match the media element size.
83 layoutBox->mutableStyleRef().setHeight(Length(newSize.height(), Fixed)); 83 layoutBox->mutableStyleRef().setHeight(Length(newRect.height(), Fixed));
84 layoutBox->mutableStyleRef().setWidth(Length(newSize.width(), Fixed)); 84 layoutBox->mutableStyleRef().setWidth(Length(newRect.width(), Fixed));
85 layoutBox->forceLayout(); 85 layoutBox->forceLayout();
86 } 86 }
87 87
88 clearNeedsLayout(); 88 clearNeedsLayout();
89 89
90 // Notify our MediaControls that a layout has happened. 90 // Notify our MediaControls that a layout has happened.
91 if (mediaElement() && mediaElement()->mediaControls() && newSize.width() != oldSize.width()) 91 if (mediaElement() && mediaElement()->mediaControls() && newRect.width() != oldSize.width())
92 mediaElement()->mediaControls()->notifyPanelWidthChanged(newSize.width() ); 92 mediaElement()->mediaControls()->notifyPanelWidthChanged(newRect.width() );
93 } 93 }
94 94
95 bool LayoutMedia::isChildAllowed(LayoutObject* child, const ComputedStyle&) cons t 95 bool LayoutMedia::isChildAllowed(LayoutObject* child, const ComputedStyle&) cons t
96 { 96 {
97 // Two types of child layout objects are allowed: media controls 97 // Two types of child layout objects are allowed: media controls
98 // and the text track container. Filter children by node type. 98 // and the text track container. Filter children by node type.
99 ASSERT(child->node()); 99 ASSERT(child->node());
100 100
101 // The user agent stylesheet (mediaControls.css) has 101 // The user agent stylesheet (mediaControls.css) has
102 // ::-webkit-media-controls { display: flex; }. If author style 102 // ::-webkit-media-controls { display: flex; }. If author style
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 void LayoutMedia::setRequestPositionUpdates(bool want) 144 void LayoutMedia::setRequestPositionUpdates(bool want)
145 { 145 {
146 if (want) 146 if (want)
147 view()->registerMediaForPositionChangeNotification(*this); 147 view()->registerMediaForPositionChangeNotification(*this);
148 else 148 else
149 view()->unregisterMediaForPositionChangeNotification(*this); 149 view()->unregisterMediaForPositionChangeNotification(*this);
150 } 150 }
151 151
152 } // namespace blink 152 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutListMarker.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutReplaced.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698