2009-04-27 Eric Carlson <eric.carlson@apple.com>

        Reviewed by Darin Adler.

        <rdar://problem/6822344> Use of QTMovieCurrentSizeAttribute generates exception and will crash

        QTMovieCurrentSizeAttribute generates an exception with some versions of QTKit, so calculate a 
        multiplier to scale from natural size to current size when a movie is opened and use that to 
        return the correct value from the naturalSize() method.

        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
        (WebCore::MediaPlayerPrivate::MediaPlayerPrivate): Initialize m_scaleFactor.
        (WebCore::MediaPlayerPrivate::naturalSize): Return naturalSize transformed by initial scale.
        (WebCore::MediaPlayerPrivate::cacheMovieScale): New, calculate difference between initial
        size and natural size so naturalSize() accounts for non-identity movie matrix.
        (WebCore::MediaPlayerPrivate::updateStates): Call cacheMovieScale when load state reaches
        QTMovieLoadStateLoaded for the first time.



git-svn-id: svn://svn.chromium.org/blink/trunk@42918 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent f5dea500
2009-04-27 Eric Carlson <eric.carlson@apple.com>
Reviewed by Darin Adler.
<rdar://problem/6822344> Use of QTMovieCurrentSizeAttribute generates exception and will crash
QTMovieCurrentSizeAttribute generates an exception with some versions of QTKit, so calculate a
multiplier to scale from natural size to current size when a movie is opened and use that to
return the correct value from the naturalSize() method.
* platform/graphics/mac/MediaPlayerPrivateQTKit.h:
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::MediaPlayerPrivate::MediaPlayerPrivate): Initialize m_scaleFactor.
(WebCore::MediaPlayerPrivate::naturalSize): Return naturalSize transformed by initial scale.
(WebCore::MediaPlayerPrivate::cacheMovieScale): New, calculate difference between initial
size and natural size so naturalSize() accounts for non-identity movie matrix.
(WebCore::MediaPlayerPrivate::updateStates): Call cacheMovieScale when load state reaches
QTMovieLoadStateLoaded for the first time.
2009-04-27 Beth Dakin <bdakin@apple.com>
Reviewed by Dave Hyatt.
......@@ -30,6 +30,7 @@
#include "MediaPlayerPrivate.h"
#include "Timer.h"
#include "FloatSize.h"
#include <wtf/RetainPtr.h>
#ifdef __OBJC__
......@@ -128,7 +129,7 @@ private:
void disableUnsupportedTracks();
void sawUnsupportedTracks();
void cacheMovieScale();
bool metaDataAvailable() const { return m_qtMovie && m_readyState >= MediaPlayer::HaveMetadata; }
MediaPlayer* m_player;
......@@ -144,6 +145,7 @@ private:
bool m_isStreaming;
bool m_visible;
IntRect m_rect;
FloatSize m_scaleFactor;
unsigned m_enabledTrackCount;
unsigned m_totalTrackCount;
bool m_hasUnsupportedTracks;
......
......@@ -188,6 +188,7 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
, m_isStreaming(false)
, m_visible(false)
, m_rect()
, m_scaleFactor(1, 1)
, m_enabledTrackCount(0)
, m_totalTrackCount(0)
, m_hasUnsupportedTracks(false)
......@@ -563,7 +564,15 @@ IntSize MediaPlayerPrivate::naturalSize() const
if (!metaDataAvailable())
return IntSize();
return IntSize([[m_qtMovie.get() attributeForKey:QTMovieNaturalSizeAttribute] sizeValue]);
// In spite of the name of this method, return QTMovieNaturalSizeAttribute transformed by the
// initial movie scale because the spec says intrinsic size is:
//
// ... the dimensions of the resource in CSS pixels after taking into account the resource's
// dimensions, aspect ratio, clean aperture, resolution, and so forth, as defined for the
// format used by the resource
NSSize naturalSize = [[m_qtMovie.get() attributeForKey:QTMovieNaturalSizeAttribute] sizeValue];
return IntSize(naturalSize.width * m_scaleFactor.width(), naturalSize.height * m_scaleFactor.height());
}
bool MediaPlayerPrivate::hasVideo() const
......@@ -653,6 +662,28 @@ void MediaPlayerPrivate::cancelLoad()
updateStates();
}
void MediaPlayerPrivate::cacheMovieScale()
{
NSSize initialSize = NSZeroSize;
NSSize naturalSize = [[m_qtMovie.get() attributeForKey:QTMovieNaturalSizeAttribute] sizeValue];
// QTMovieCurrentSizeAttribute is not allowed with some versions of QuickTime so ask for the display
// transform attribute first. If it is supported we don't need QTMovieCurrentSizeAttribute.
NSAffineTransform *displayTransform = [m_qtMovie.get() attributeForKey:@"QTMoviePreferredTransformAttribute"];
if (displayTransform)
initialSize = [displayTransform transformSize:naturalSize];
else {
BEGIN_BLOCK_OBJC_EXCEPTIONS;
initialSize = [[m_qtMovie.get() attributeForKey:QTMovieCurrentSizeAttribute] sizeValue];
END_BLOCK_OBJC_EXCEPTIONS;
}
if (naturalSize.width)
m_scaleFactor.setWidth(initialSize.width / naturalSize.width);
if (naturalSize.height)
m_scaleFactor.setHeight(initialSize.height / naturalSize.height);
}
void MediaPlayerPrivate::updateStates()
{
MediaPlayer::NetworkState oldNetworkState = m_networkState;
......@@ -673,6 +704,9 @@ void MediaPlayerPrivate::updateStates()
} else if (!m_enabledTrackCount) {
loadState = QTMovieLoadStateError;
}
if (loadState != QTMovieLoadStateError)
cacheMovieScale();
}
BOOL completelyLoaded = !m_isStreaming && (loadState >= QTMovieLoadStateComplete);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment