Bug 876426. Part 1: Fire 'resizevideocontrols' event on video controls element when the element's size is changed. r=mattwoodrow

This commit is contained in:
Robert O'Callahan 2013-05-28 17:00:59 +12:00
Родитель ddedd8a3c9
Коммит 46ec98b29f
1 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -234,6 +234,20 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
return result.forget();
}
class DispatchResizeToControls : public nsRunnable
{
public:
DispatchResizeToControls(nsIContent* aContent)
: mContent(aContent) {}
NS_IMETHOD Run() {
nsContentUtils::DispatchTrustedEvent(mContent->OwnerDoc(), mContent,
NS_LITERAL_STRING("resizevideocontrols"),
false, false);
return NS_OK;
}
nsCOMPtr<nsIContent> mContent;
};
NS_IMETHODIMP
nsVideoFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,
@ -307,12 +321,17 @@ nsVideoFrame::Reflow(nsPresContext* aPresContext,
} else if (child->GetContent() == mVideoControls) {
// Reflow the video controls frame.
nsBoxLayoutState boxState(PresContext(), aReflowState.rendContext);
nsSize size = child->GetSize();
nsBoxFrame::LayoutChildAt(boxState,
child,
nsRect(mBorderPadding.left,
mBorderPadding.top,
aReflowState.ComputedWidth(),
aReflowState.ComputedHeight()));
if (child->GetSize() != size) {
nsRefPtr<nsRunnable> event = new DispatchResizeToControls(child->GetContent());
nsContentUtils::AddScriptRunner(event);
}
} else if (child->GetContent() == mCaptionDiv) {
// Reflow to caption div
nsHTMLReflowMetrics kidDesiredSize;