Chromium Code Reviews| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 | 76 |
| 77 // TODO(mlamouri): we miss some layouts because needsLayout returns false in | 77 // TODO(mlamouri): we miss some layouts because needsLayout returns false in |
| 78 // some cases where we want to change the width of the controls because the | 78 // some cases where we want to change the width of the controls because the |
| 79 // visible viewport has changed for example. | 79 // visible viewport has changed for example. |
| 80 if (newRect.size() == oldSize && !child->needsLayout()) | 80 if (newRect.size() == oldSize && !child->needsLayout()) |
| 81 continue; | 81 continue; |
| 82 | 82 |
| 83 LayoutUnit width = newRect.width(); | 83 LayoutUnit width = newRect.width(); |
| 84 if (child->node()->isMediaControls()) { | 84 if (child->node()->isMediaControls()) { |
| 85 width = computePanelWidth(newRect); | 85 width = computePanelWidth(newRect); |
| 86 if (width != oldSize.width()) | 86 newPanelWidth = width; |
| 87 newPanelWidth = width; | |
| 88 } | 87 } |
| 89 | 88 |
| 90 LayoutBox* layoutBox = toLayoutBox(child); | 89 LayoutBox* layoutBox = toLayoutBox(child); |
| 91 layoutBox->setLocation(newRect.location()); | 90 layoutBox->setLocation(newRect.location()); |
| 92 // TODO(foolip): Remove the mutableStyleRef() and depend on CSS | 91 // TODO(foolip): Remove the mutableStyleRef() and depend on CSS |
| 93 // width/height: inherit to match the media element size. | 92 // width/height: inherit to match the media element size. |
| 94 layoutBox->mutableStyleRef().setHeight(Length(newRect.height(), Fixed)); | 93 layoutBox->mutableStyleRef().setHeight(Length(newRect.height(), Fixed)); |
| 95 layoutBox->mutableStyleRef().setWidth(Length(width, Fixed)); | 94 layoutBox->mutableStyleRef().setWidth(Length(width, Fixed)); |
| 96 | 95 |
| 97 layoutBox->forceLayout(); | 96 layoutBox->forceLayout(); |
| 98 } | 97 } |
| 99 | 98 |
| 100 clearNeedsLayout(); | 99 clearNeedsLayout(); |
| 101 | 100 |
| 102 // Notify our MediaControls that a layout has happened. | 101 // Notify our MediaControls that a layout has happened. |
| 103 if (mediaElement() && mediaElement()->mediaControls() && | 102 if (mediaElement() && mediaElement()->mediaControls() && |
| 104 newPanelWidth.has_value()) { | 103 newPanelWidth.has_value()) { |
| 105 mediaElement()->mediaControls()->notifyPanelWidthChanged( | 104 if (!m_lastReportedPanelWidth.has_value() || |
| 106 newPanelWidth.value()); | 105 m_lastReportedPanelWidth.value() != newPanelWidth.value()) { |
| 106 mediaElement()->mediaControls()->notifyPanelWidthChanged( | |
| 107 newPanelWidth.value()); | |
| 108 // store the last value we reported, so we know if it has changed | |
|
whywhat
2016/12/08 23:21:06
nit: Use proper sentence format for consistency (s
billorr
2016/12/08 23:34:58
Done.
| |
| 109 m_lastReportedPanelWidth = newPanelWidth.value(); | |
| 110 } | |
| 107 } | 111 } |
| 108 } | 112 } |
| 109 | 113 |
| 110 bool LayoutMedia::isChildAllowed(LayoutObject* child, | 114 bool LayoutMedia::isChildAllowed(LayoutObject* child, |
| 111 const ComputedStyle&) const { | 115 const ComputedStyle&) const { |
| 112 // Two types of child layout objects are allowed: media controls | 116 // Two types of child layout objects are allowed: media controls |
| 113 // and the text track container. Filter children by node type. | 117 // and the text track container. Filter children by node type. |
| 114 ASSERT(child->node()); | 118 ASSERT(child->node()); |
| 115 | 119 |
| 116 // The user agent stylesheet (mediaControls.css) has | 120 // The user agent stylesheet (mediaControls.css) has |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 .x()); | 164 .x()); |
| 161 const LayoutUnit newWidth = visibleWidth - absoluteXOffset; | 165 const LayoutUnit newWidth = visibleWidth - absoluteXOffset; |
| 162 | 166 |
| 163 if (newWidth < 0) | 167 if (newWidth < 0) |
| 164 return mediaRect.width(); | 168 return mediaRect.width(); |
| 165 | 169 |
| 166 return std::min(mediaRect.width(), visibleWidth - absoluteXOffset); | 170 return std::min(mediaRect.width(), visibleWidth - absoluteXOffset); |
| 167 } | 171 } |
| 168 | 172 |
| 169 } // namespace blink | 173 } // namespace blink |
| OLD | NEW |