~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/html/HTMLVideoElement.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
 
2
 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
3
3
 *
4
4
 * Redistribution and use in source and binary forms, with or without
5
5
 * modification, are permitted provided that the following conditions
33
33
#include "Document.h"
34
34
#include "HTMLImageLoader.h"
35
35
#include "HTMLNames.h"
 
36
#include "MappedAttribute.h"
36
37
#include "RenderImage.h"
37
38
#include "RenderVideo.h"
38
39
 
52
53
    return HTMLElement::rendererIsNeeded(style); 
53
54
}
54
55
 
 
56
#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
55
57
RenderObject* HTMLVideoElement::createRenderer(RenderArena* arena, RenderStyle*)
56
58
{
57
59
    if (m_shouldShowPosterImage)
58
60
        return new (arena) RenderImage(this);
59
61
    return new (arena) RenderVideo(this);
60
62
}
 
63
#endif
61
64
 
62
65
void HTMLVideoElement::attach()
63
66
{
64
67
    HTMLMediaElement::attach();
65
 
    
 
68
 
 
69
#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
66
70
    if (m_shouldShowPosterImage) {
67
71
        if (!m_imageLoader)
68
72
            m_imageLoader.set(new HTMLImageLoader(this));
69
73
        m_imageLoader->updateFromElement();
70
74
        if (renderer() && renderer()->isImage()) {
71
 
            RenderImage* imageRenderer = static_cast<RenderImage*>(renderer());
 
75
            RenderImage* imageRenderer = toRenderImage(renderer());
72
76
            imageRenderer->setCachedImage(m_imageLoader->image()); 
73
77
        }
74
78
    }
75
 
 
 
79
#endif
76
80
}
77
81
 
78
82
void HTMLVideoElement::detach()
91
95
    if (attrName == posterAttr) {
92
96
        updatePosterImage();
93
97
        if (m_shouldShowPosterImage) {
 
98
#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
94
99
            if (!m_imageLoader)
95
100
                m_imageLoader.set(new HTMLImageLoader(this));
96
101
            m_imageLoader->updateFromElementIgnoringPreviousError();
 
102
#else
 
103
            if (m_player)
 
104
                m_player->setPoster(poster());
 
105
#endif
97
106
        }
98
107
    } else if (attrName == widthAttr)
99
108
        addCSSLength(attr, CSSPropertyWidth, attr->value());
163
172
 
164
173
void HTMLVideoElement::updatePosterImage()
165
174
{
 
175
#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
166
176
    bool oldShouldShowPosterImage = m_shouldShowPosterImage;
167
 
    m_shouldShowPosterImage = !poster().isEmpty() && m_networkState < LOADED_FIRST_FRAME;
 
177
#endif
 
178
 
 
179
    m_shouldShowPosterImage = !poster().isEmpty() && readyState() < HAVE_CURRENT_DATA;
 
180
 
 
181
#if !ENABLE(PLUGIN_PROXY_FOR_VIDEO)
168
182
    if (attached() && oldShouldShowPosterImage != m_shouldShowPosterImage) {
169
183
        detach();
170
184
        attach();
171
185
    }
 
186
#endif
 
187
}
 
188
 
 
189
void HTMLVideoElement::paint(GraphicsContext* context, const IntRect& destRect)
 
190
{
 
191
    // FIXME: We should also be able to paint the poster image.
 
192
 
 
193
    MediaPlayer* player = HTMLMediaElement::player();
 
194
    if (!player)
 
195
        return;
 
196
 
 
197
    player->setVisible(true); // Make player visible or it won't draw.
 
198
    player->paint(context, destRect);
 
199
}
 
200
 
 
201
void HTMLVideoElement::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& destRect)
 
202
{
 
203
    // FIXME: We should also be able to paint the poster image.
 
204
    
 
205
    MediaPlayer* player = HTMLMediaElement::player();
 
206
    if (!player)
 
207
        return;
 
208
    
 
209
    player->setVisible(true); // Make player visible or it won't draw.
 
210
    player->paintCurrentFrameInContext(context, destRect);
172
211
}
173
212
 
174
213
}