+2011-05-27 Adam Barth <abarth@webkit.org>
+
+ Reviewed by Eric Seidel.
+
+ HTMLVideoElement::currentSrc() should return a KURL
+ https://bugs.webkit.org/show_bug.cgi?id=61578
+
+ I suspect we got into this mess because the author of this code didn't
+ know about the URL attribute in WebKit IDL, which is super useful!
+
+ Bad news: The line of code in question seems to have another bug, which
+ I've documented in a FIXME. Let the yak shaving continue!
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::urlForLogging):
+ (WebCore::HTMLMediaElement::loadResource):
+ (WebCore::HTMLMediaElement::isSafeToLoadURL):
+ (WebCore::HTMLMediaElement::selectNextSourceChild):
+ (WebCore::HTMLMediaElement::getPluginProxyParams):
+ * html/HTMLMediaElement.h:
+ (WebCore::HTMLMediaElement::currentSrc):
+ (WebCore::HTMLMediaElement::currentURL):
+ * html/canvas/CanvasRenderingContext.cpp:
+ (WebCore::CanvasRenderingContext::checkOrigin):
+ * rendering/HitTestResult.cpp:
+ (WebCore::HitTestResult::absoluteMediaURL):
+ - This complete URL call was unnecessary because currentSrc is
+ already absolute.
+
2011-05-27 Mikhail Naganov <mnaganov@chromium.org>
Reviewed by Pavel Feldman.
namespace WebCore {
#if !LOG_DISABLED
-static String urlForLogging(const String& url)
+static const char* urlForLogging(const KURL& url)
{
static const unsigned maximumURLLengthForLogging = 128;
- if (url.length() < maximumURLLengthForLogging)
- return url;
- return url.substring(0, maximumURLLengthForLogging) + "...";
+ if (url.string().length() < maximumURLLengthForLogging)
+ return url.string().utf8().data();
+ return String(url.string().substring(0, maximumURLLengthForLogging) + "...").utf8().data();
}
-static const char *boolString(bool val)
+static const char* boolString(bool val)
{
return val ? "true" : "false";
}
setAttribute(srcAttr, url);
}
-String HTMLMediaElement::currentSrc() const
-{
- return m_currentSrc;
-}
-
HTMLMediaElement::NetworkState HTMLMediaElement::networkState() const
{
return m_networkState;
{
ASSERT(isSafeToLoadURL(initialURL, Complain));
- LOG(Media, "HTMLMediaElement::loadResource(%s, %s)", urlForLogging(initialURL.string()).utf8().data(), contentType.raw().utf8().data());
+ LOG(Media, "HTMLMediaElement::loadResource(%s, %s)", urlForLogging(initialURL), contentType.raw().utf8().data());
Frame* frame = document()->frame();
if (!frame)
m_currentSrc = url;
- LOG(Media, "HTMLMediaElement::loadResource - m_currentSrc -> %s", urlForLogging(m_currentSrc).utf8().data());
+ LOG(Media, "HTMLMediaElement::loadResource - m_currentSrc -> %s", urlForLogging(m_currentSrc));
if (m_sendProgressEvents)
startProgressEventTimer();
m_player->setPreservesPitch(m_webkitPreservesPitch);
updateVolume();
- m_player->load(m_currentSrc, contentType);
+ m_player->load(m_currentSrc.string(), contentType);
// If there is no poster to display, allow the media engine to render video frames as soon as
// they are available.
bool HTMLMediaElement::isSafeToLoadURL(const KURL& url, InvalidSourceAction actionIfInvalid)
{
if (!url.isValid()) {
- LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%s) -> FALSE because url is invalid", urlForLogging(url.string()).utf8().data());
+ LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%s) -> FALSE because url is invalid", urlForLogging(url));
return false;
}
if (!frame || !document()->securityOrigin()->canDisplay(url)) {
if (actionIfInvalid == Complain)
FrameLoader::reportLocalLoadFailed(frame, url.string());
- LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%s) -> FALSE rejected by SecurityOrigin", urlForLogging(url.string()).utf8().data());
+ LOG(Media, "HTMLMediaElement::isSafeToLoadURL(%s) -> FALSE rejected by SecurityOrigin", urlForLogging(url));
return false;
}
mediaURL = source->getNonEmptyURLAttribute(srcAttr);
#if !LOG_DISABLED
if (shouldLog)
- LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'src' is %s", urlForLogging(mediaURL).utf8().data());
+ LOG(Media, "HTMLMediaElement::selectNextSourceChild - 'src' is %s", urlForLogging(mediaURL));
#endif
if (mediaURL.isEmpty())
goto check_again;
#if !LOG_DISABLED
if (shouldLog)
- LOG(Media, "HTMLMediaElement::selectNextSourceChild -> %p, %s", m_currentSourceNode, canUse ? urlForLogging(mediaURL.string()).utf8().data() : "");
+ LOG(Media, "HTMLMediaElement::selectNextSourceChild -> %p, %s", m_currentSourceNode, canUse ? urlForLogging(mediaURL) : "");
#endif
return canUse ? mediaURL : KURL();
}
#if !LOG_DISABLED
if (source->hasTagName(sourceTag)) {
KURL url = source->getNonEmptyURLAttribute(srcAttr);
- LOG(Media, "HTMLMediaElement::sourceWasAdded - 'src' is %s", urlForLogging(url).utf8().data());
+ LOG(Media, "HTMLMediaElement::sourceWasAdded - 'src' is %s", urlForLogging(url));
}
#endif
#if !LOG_DISABLED
if (source->hasTagName(sourceTag)) {
KURL url = source->getNonEmptyURLAttribute(srcAttr);
- LOG(Media, "HTMLMediaElement::sourceWillBeRemoved - 'src' is %s", urlForLogging(url).utf8().data());
+ LOG(Media, "HTMLMediaElement::sourceWillBeRemoved - 'src' is %s", urlForLogging(url));
}
#endif
if (!isSafeToLoadURL(url, Complain))
url = selectNextSourceChild(0, DoNothing);
- m_currentSrc = url.string();
+ m_currentSrc = url;
if (url.isValid() && frame && frame->loader()->willLoadMediaElementURL(url)) {
names.append("_media_element_src_");
- values.append(m_currentSrc);
+ values.append(m_currentSrc.string());
}
}