[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
philn at webkit.org
philn at webkit.org
Wed Dec 22 13:28:26 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 38c47ce480d204ec0e576456e6c457775554f173
Author: philn at webkit.org <philn at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Sep 16 16:21:44 2010 +0000
2010-09-15 Philippe Normand <pnormand at igalia.com>
Reviewed by Eric Carlson.
[GTK] enhanced context menu for media elements
https://bugs.webkit.org/show_bug.cgi?id=45021
New items in the media Element context menu:
- play/pause
- mute/unmute
- controls display control
- switch to fullscreen (for video only)
- loop playback control
- copy media url to clipboard
- open in new window
Test: media/context-menu-actions.html
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected):
* platform/ContextMenu.cpp:
(WebCore::ContextMenu::populate):
(WebCore::ContextMenu::checkOrEnableIfNeeded):
* platform/ContextMenuItem.h:
* platform/LocalizationStrategy.h:
* platform/LocalizedStrings.cpp:
(WebCore::contextMenuItemTagOpenMediaInNewWindow):
(WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
(WebCore::contextMenuItemTagToggleMediaControls):
(WebCore::contextMenuItemTagToggleMediaLoop):
(WebCore::contextMenuItemTagEnterVideoFullscreen):
(WebCore::contextMenuItemTagMediaPlay):
(WebCore::contextMenuItemTagMediaPause):
(WebCore::contextMenuItemTagMediaMute):
(WebCore::contextMenuItemTagMediaUnMute):
* platform/LocalizedStrings.h:
* platform/android/LocalizedStringsAndroid.cpp:
(WebCore::contextMenuItemTagOpenMediaInNewWindow):
(WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
(WebCore::contextMenuItemTagToggleMediaControls):
(WebCore::contextMenuItemTagToggleMediaLoop):
(WebCore::contextMenuItemTagEnterVideoFullscreen):
(WebCore::contextMenuItemTagMediaPlay):
(WebCore::contextMenuItemTagMediaPause):
(WebCore::contextMenuItemTagMediaMute):
(WebCore::contextMenuItemTagMediaUnMute):
* platform/brew/LocalizedStringsBrew.cpp:
(WebCore::contextMenuItemTagOpenMediaInNewWindow):
(WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
(WebCore::contextMenuItemTagToggleMediaControls):
(WebCore::contextMenuItemTagToggleMediaLoop):
(WebCore::contextMenuItemTagEnterVideoFullscreen):
(WebCore::contextMenuItemTagMediaPlay):
(WebCore::contextMenuItemTagMediaPause):
(WebCore::contextMenuItemTagMediaMute):
(WebCore::contextMenuItemTagMediaUnMute):
* platform/efl/LocalizedStringsEfl.cpp:
(WebCore::contextMenuItemTagOpenMediaInNewWindow):
(WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
(WebCore::contextMenuItemTagToggleMediaControls):
(WebCore::contextMenuItemTagToggleMediaLoop):
(WebCore::contextMenuItemTagEnterVideoFullscreen):
(WebCore::contextMenuItemTagMediaPlay):
(WebCore::contextMenuItemTagMediaPause):
(WebCore::contextMenuItemTagMediaMute):
(WebCore::contextMenuItemTagMediaUnMute):
* platform/gtk/ContextMenuItemGtk.cpp:
(WebCore::gtkStockIDFromContextMenuAction):
* platform/gtk/LocalizedStringsGtk.cpp:
(WebCore::contextMenuItemTagOpenMediaInNewWindow):
(WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
(WebCore::contextMenuItemTagToggleMediaControls):
(WebCore::contextMenuItemTagToggleMediaLoop):
(WebCore::contextMenuItemTagEnterVideoFullscreen):
(WebCore::contextMenuItemTagMediaPlay):
(WebCore::contextMenuItemTagMediaPause):
(WebCore::contextMenuItemTagMediaMute):
(WebCore::contextMenuItemTagMediaUnMute):
* platform/haiku/LocalizedStringsHaiku.cpp:
(WebCore::contextMenuItemTagOpenMediaInNewWindow):
(WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
(WebCore::contextMenuItemTagToggleMediaControls):
(WebCore::contextMenuItemTagToggleMediaLoop):
(WebCore::contextMenuItemTagEnterVideoFullscreen):
(WebCore::contextMenuItemTagMediaPlay):
(WebCore::contextMenuItemTagMediaPause):
(WebCore::contextMenuItemTagMediaMute):
(WebCore::contextMenuItemTagMediaUnMute):
* platform/wx/LocalizedStringsWx.cpp:
(WebCore::contextMenuItemTagOpenMediaInNewWindow):
(WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
(WebCore::contextMenuItemTagToggleMediaControls):
(WebCore::contextMenuItemTagToggleMediaLoop):
(WebCore::contextMenuItemTagEnterVideoFullscreen):
(WebCore::contextMenuItemTagMediaPlay):
(WebCore::contextMenuItemTagMediaPause):
(WebCore::contextMenuItemTagMediaMute):
(WebCore::contextMenuItemTagMediaUnMute):
* rendering/HitTestResult.cpp:
(WebCore::HitTestResult::absoluteMediaURL):
(WebCore::HitTestResult::mediaSupportsFullscreen):
(WebCore::HitTestResult::mediaElement):
(WebCore::HitTestResult::toggleMediaControlsDisplay):
(WebCore::HitTestResult::toggleMediaLoopPlayback):
(WebCore::HitTestResult::enterFullscreenForVideo):
(WebCore::HitTestResult::mediaControlsEnabled):
(WebCore::HitTestResult::mediaLoopEnabled):
(WebCore::HitTestResult::mediaPlaying):
(WebCore::HitTestResult::toggleMediaPlayState):
(WebCore::HitTestResult::mediaHasAudio):
(WebCore::HitTestResult::mediaMuted):
(WebCore::HitTestResult::toggleMediaMuteState):
* rendering/HitTestResult.h:
WebKitTools:
Reviewed by Eric Carlson.
[GTK] enhanced context menu for media elements
https://bugs.webkit.org/show_bug.cgi?id=45021
EventSender::contextClick() now returns an array of js
objects. Each object has a title property and a click() method.
* DumpRenderTree/gtk/EventSender.cpp:
(getMenuItemTitleCallback):
(setMenuItemTitleCallback):
(menuItemClickCallback):
(getMenuItemClass):
(contextClickCallback):
LayoutTests:
Reviewed by Eric Carlson.
[GTK] enhanced context menu for media elements
https://bugs.webkit.org/show_bug.cgi?id=45021
New test checking the actions that can be triggered by activating
the contex-menu of the media element. Skipped on mac, qt and win
because of lack of DRT support.
* media/context-menu-actions-expected.txt: Added.
* media/context-menu-actions.html: Added.
* platform/mac/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67628 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 9bd4045..c24ba64 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,20 @@
+2010-09-15 Philippe Normand <pnormand at igalia.com>
+
+ Reviewed by Eric Carlson.
+
+ [GTK] enhanced context menu for media elements
+ https://bugs.webkit.org/show_bug.cgi?id=45021
+
+ New test checking the actions that can be triggered by activating
+ the contex-menu of the media element. Skipped on mac, qt and win
+ because of lack of DRT support.
+
+ * media/context-menu-actions-expected.txt: Added.
+ * media/context-menu-actions.html: Added.
+ * platform/mac/Skipped:
+ * platform/qt/Skipped:
+ * platform/win/Skipped:
+
2010-09-16 Tony Gentilcore <tonyg at chromium.org>
Reviewed by Adam Barth.
diff --git a/LayoutTests/media/context-menu-actions-expected.txt b/LayoutTests/media/context-menu-actions-expected.txt
new file mode 100644
index 0000000..6918f3d
--- /dev/null
+++ b/LayoutTests/media/context-menu-actions-expected.txt
@@ -0,0 +1,26 @@
+Test the various actions available in the HTML5 media element context-menu.
+
+RUN(video.src = 'content/test.mp4')
+EVENT(play)
+EXPECTED (video.paused == 'false') OK
+Toggling play state
+EXPECTED (video.paused == 'true') OK
+
+EXPECTED (video.muted == 'false') OK
+Toggling mute state
+EXPECTED (video.muted == 'true') OK
+
+EXPECTED (video.controls == 'true') OK
+Toggling media controls
+EXPECTED (video.controls == 'false') OK
+
+EXPECTED (video.loop == 'false') OK
+Toggling loop state
+EXPECTED (video.loop == 'true') OK
+
+EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
+Toggling fullscreen state
+EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
+
+END OF TEST
+
diff --git a/LayoutTests/media/context-menu-actions.html b/LayoutTests/media/context-menu-actions.html
new file mode 100644
index 0000000..ae80f14
--- /dev/null
+++ b/LayoutTests/media/context-menu-actions.html
@@ -0,0 +1,91 @@
+<html>
+<head>
+ <script src="media-file.js"></script>
+ <script src=video-test.js></script>
+ <script>
+
+ function playing()
+ {
+ if (window.layoutTestController) {
+ if (!window.eventSender) {
+ layoutTestController.dumpAsText();
+ endTest();
+ return;
+ }
+ } else {
+ endTest();
+ return;
+ }
+
+ findMediaElement();
+
+ var x, y, items;
+ x = video.offsetParent.offsetLeft + video.offsetLeft + video.offsetWidth / 2;
+ y = video.offsetParent.offsetTop + video.offsetTop + video.offsetHeight / 2;
+ eventSender.mouseMoveTo(x, y);
+ items = eventSender.contextClick();
+
+
+ for (var i = 0; i < items.length; i++)
+ {
+ if (items[i].title.match("Controls")) {
+ testExpected("video.controls", true, '==');
+ consoleWrite("Toggling media controls");
+ items[i].click();
+ testExpected("video.controls", false, '==');
+ consoleWrite("");
+ }
+
+ if (items[i].title.match("Pause")) {
+ testExpected("video.paused", false, '==');
+ consoleWrite("Toggling play state");
+ items[i].click();
+ testExpected("video.paused", true, '==');
+ consoleWrite("");
+ }
+
+ if (items[i].title.match("Loop")) {
+ testExpected("video.loop", false, '==');
+ consoleWrite("Toggling loop state");
+ items[i].click();
+ testExpected("video.loop", true, '==');
+ consoleWrite("");
+ }
+
+ if (items[i].title.match("Mute")) {
+ testExpected("video.muted", false, '==');
+ consoleWrite("Toggling mute state");
+ items[i].click();
+ testExpected("video.muted", true, '==');
+ consoleWrite("");
+ }
+
+ if (items[i].title.match("Fullscreen") && video.webkitSupportsFullscreen) {
+ testExpected("video.webkitDisplayingFullscreen", false, '==');
+ consoleWrite("Toggling fullscreen state");
+ items[i].click();
+ testExpected("video.webkitDisplayingFullscreen", true, '==');
+ consoleWrite("");
+ }
+
+ // TODO: test copy link location and open in new window.
+ }
+ layoutTestController.dumpAsText();
+ endTest();
+ }
+
+ function start()
+ {
+ findMediaElement();
+ waitForEvent('play', playing);
+ run("video.src = '" + findMediaFile("video", "content/test") + "'");
+ }
+
+ </script>
+</head>
+<body onload="start()">
+ <p>Test the various actions available in the HTML5 media element context-menu.</p>
+ <video id="video" autoplay controls></video>
+</body>
+</html>
+
diff --git a/LayoutTests/platform/mac/Skipped b/LayoutTests/platform/mac/Skipped
index b8ca528..b4111ae 100644
--- a/LayoutTests/platform/mac/Skipped
+++ b/LayoutTests/platform/mac/Skipped
@@ -310,3 +310,7 @@ fast/files/workers
# viewport meta tag support
fast/viewport
+
+# needs enhanced eventSender.contextMenu() return value
+# see also https://bugs.webkit.org/show_bug.cgi?id=45021
+media/context-menu-actions.html
diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped
index f8abee7..3664001 100644
--- a/LayoutTests/platform/qt/Skipped
+++ b/LayoutTests/platform/qt/Skipped
@@ -2269,6 +2269,8 @@ editing/selection/5195166-1.html
# missing DRT feature, see also https://bugs.webkit.org/show_bug.cgi?id=39102
editing/selection/context-menu-on-text.html
+# and https://bugs.webkit.org/show_bug.cgi?id=45021
+media/context-menu-actions.html
# ============================================================================= #
# Failing editing/spelling tests
diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped
index 8460cf4..9ef9cbd 100644
--- a/LayoutTests/platform/win/Skipped
+++ b/LayoutTests/platform/win/Skipped
@@ -297,6 +297,8 @@ http/tests/css/css-image-loading.html
# missing DRT feature, see also https://bugs.webkit.org/show_bug.cgi?id=39102
editing/selection/context-menu-on-text.html
+# and https://bugs.webkit.org/show_bug.cgi?id=45021
+media/context-menu-actions.html
################################################################################
####################### No bugs filed about the below yet#######################
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1a8213f..904ebb4 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,117 @@
+2010-09-15 Philippe Normand <pnormand at igalia.com>
+
+ Reviewed by Eric Carlson.
+
+ [GTK] enhanced context menu for media elements
+ https://bugs.webkit.org/show_bug.cgi?id=45021
+
+ New items in the media Element context menu:
+ - play/pause
+ - mute/unmute
+ - controls display control
+ - switch to fullscreen (for video only)
+ - loop playback control
+ - copy media url to clipboard
+ - open in new window
+
+ Test: media/context-menu-actions.html
+
+ * page/ContextMenuController.cpp:
+ (WebCore::ContextMenuController::contextMenuItemSelected):
+ * platform/ContextMenu.cpp:
+ (WebCore::ContextMenu::populate):
+ (WebCore::ContextMenu::checkOrEnableIfNeeded):
+ * platform/ContextMenuItem.h:
+ * platform/LocalizationStrategy.h:
+ * platform/LocalizedStrings.cpp:
+ (WebCore::contextMenuItemTagOpenMediaInNewWindow):
+ (WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
+ (WebCore::contextMenuItemTagToggleMediaControls):
+ (WebCore::contextMenuItemTagToggleMediaLoop):
+ (WebCore::contextMenuItemTagEnterVideoFullscreen):
+ (WebCore::contextMenuItemTagMediaPlay):
+ (WebCore::contextMenuItemTagMediaPause):
+ (WebCore::contextMenuItemTagMediaMute):
+ (WebCore::contextMenuItemTagMediaUnMute):
+ * platform/LocalizedStrings.h:
+ * platform/android/LocalizedStringsAndroid.cpp:
+ (WebCore::contextMenuItemTagOpenMediaInNewWindow):
+ (WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
+ (WebCore::contextMenuItemTagToggleMediaControls):
+ (WebCore::contextMenuItemTagToggleMediaLoop):
+ (WebCore::contextMenuItemTagEnterVideoFullscreen):
+ (WebCore::contextMenuItemTagMediaPlay):
+ (WebCore::contextMenuItemTagMediaPause):
+ (WebCore::contextMenuItemTagMediaMute):
+ (WebCore::contextMenuItemTagMediaUnMute):
+ * platform/brew/LocalizedStringsBrew.cpp:
+ (WebCore::contextMenuItemTagOpenMediaInNewWindow):
+ (WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
+ (WebCore::contextMenuItemTagToggleMediaControls):
+ (WebCore::contextMenuItemTagToggleMediaLoop):
+ (WebCore::contextMenuItemTagEnterVideoFullscreen):
+ (WebCore::contextMenuItemTagMediaPlay):
+ (WebCore::contextMenuItemTagMediaPause):
+ (WebCore::contextMenuItemTagMediaMute):
+ (WebCore::contextMenuItemTagMediaUnMute):
+ * platform/efl/LocalizedStringsEfl.cpp:
+ (WebCore::contextMenuItemTagOpenMediaInNewWindow):
+ (WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
+ (WebCore::contextMenuItemTagToggleMediaControls):
+ (WebCore::contextMenuItemTagToggleMediaLoop):
+ (WebCore::contextMenuItemTagEnterVideoFullscreen):
+ (WebCore::contextMenuItemTagMediaPlay):
+ (WebCore::contextMenuItemTagMediaPause):
+ (WebCore::contextMenuItemTagMediaMute):
+ (WebCore::contextMenuItemTagMediaUnMute):
+ * platform/gtk/ContextMenuItemGtk.cpp:
+ (WebCore::gtkStockIDFromContextMenuAction):
+ * platform/gtk/LocalizedStringsGtk.cpp:
+ (WebCore::contextMenuItemTagOpenMediaInNewWindow):
+ (WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
+ (WebCore::contextMenuItemTagToggleMediaControls):
+ (WebCore::contextMenuItemTagToggleMediaLoop):
+ (WebCore::contextMenuItemTagEnterVideoFullscreen):
+ (WebCore::contextMenuItemTagMediaPlay):
+ (WebCore::contextMenuItemTagMediaPause):
+ (WebCore::contextMenuItemTagMediaMute):
+ (WebCore::contextMenuItemTagMediaUnMute):
+ * platform/haiku/LocalizedStringsHaiku.cpp:
+ (WebCore::contextMenuItemTagOpenMediaInNewWindow):
+ (WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
+ (WebCore::contextMenuItemTagToggleMediaControls):
+ (WebCore::contextMenuItemTagToggleMediaLoop):
+ (WebCore::contextMenuItemTagEnterVideoFullscreen):
+ (WebCore::contextMenuItemTagMediaPlay):
+ (WebCore::contextMenuItemTagMediaPause):
+ (WebCore::contextMenuItemTagMediaMute):
+ (WebCore::contextMenuItemTagMediaUnMute):
+ * platform/wx/LocalizedStringsWx.cpp:
+ (WebCore::contextMenuItemTagOpenMediaInNewWindow):
+ (WebCore::contextMenuItemTagCopyMediaLinkToClipboard):
+ (WebCore::contextMenuItemTagToggleMediaControls):
+ (WebCore::contextMenuItemTagToggleMediaLoop):
+ (WebCore::contextMenuItemTagEnterVideoFullscreen):
+ (WebCore::contextMenuItemTagMediaPlay):
+ (WebCore::contextMenuItemTagMediaPause):
+ (WebCore::contextMenuItemTagMediaMute):
+ (WebCore::contextMenuItemTagMediaUnMute):
+ * rendering/HitTestResult.cpp:
+ (WebCore::HitTestResult::absoluteMediaURL):
+ (WebCore::HitTestResult::mediaSupportsFullscreen):
+ (WebCore::HitTestResult::mediaElement):
+ (WebCore::HitTestResult::toggleMediaControlsDisplay):
+ (WebCore::HitTestResult::toggleMediaLoopPlayback):
+ (WebCore::HitTestResult::enterFullscreenForVideo):
+ (WebCore::HitTestResult::mediaControlsEnabled):
+ (WebCore::HitTestResult::mediaLoopEnabled):
+ (WebCore::HitTestResult::mediaPlaying):
+ (WebCore::HitTestResult::toggleMediaPlayState):
+ (WebCore::HitTestResult::mediaHasAudio):
+ (WebCore::HitTestResult::mediaMuted):
+ (WebCore::HitTestResult::toggleMediaMuteState):
+ * rendering/HitTestResult.h:
+
2010-09-16 Tony Gentilcore <tonyg at chromium.org>
Reviewed by Adam Barth.
diff --git a/WebCore/page/ContextMenuController.cpp b/WebCore/page/ContextMenuController.cpp
index d2317d2..de64988 100644
--- a/WebCore/page/ContextMenuController.cpp
+++ b/WebCore/page/ContextMenuController.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Igalia S.L
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -186,6 +187,27 @@ void ContextMenuController::contextMenuItemSelected(ContextMenuItem* item)
// For now, call into the client. This is temporary!
frame->editor()->copyImage(result);
break;
+ case ContextMenuItemTagOpenMediaInNewWindow:
+ openNewWindow(result.absoluteMediaURL(), frame);
+ break;
+ case ContextMenuItemTagCopyMediaLinkToClipboard:
+ frame->editor()->copyURL(result.absoluteMediaURL(), result.textContent());
+ break;
+ case ContextMenuItemTagToggleMediaControls:
+ result.toggleMediaControlsDisplay();
+ break;
+ case ContextMenuItemTagToggleMediaLoop:
+ result.toggleMediaLoopPlayback();
+ break;
+ case ContextMenuItemTagEnterVideoFullscreen:
+ result.enterFullscreenForVideo();
+ break;
+ case ContextMenuItemTagMediaPlayPause:
+ result.toggleMediaPlayState();
+ break;
+ case ContextMenuItemTagMediaMute:
+ result.toggleMediaMuteState();
+ break;
case ContextMenuItemTagOpenFrameInNewWindow: {
DocumentLoader* loader = frame->loader()->documentLoader();
if (!loader->unreachableURL().isEmpty())
diff --git a/WebCore/platform/ContextMenu.cpp b/WebCore/platform/ContextMenu.cpp
index 37d4c2b..fdcd3c9 100644
--- a/WebCore/platform/ContextMenu.cpp
+++ b/WebCore/platform/ContextMenu.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2008 Christian Dywan <christian at imendio.com>
+ * Copyright (C) 2010 Igalia S.L
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -282,6 +283,20 @@ void ContextMenu::populate()
contextMenuItemTagDownloadImageToDisk());
ContextMenuItem CopyImageItem(ActionType, ContextMenuItemTagCopyImageToClipboard,
contextMenuItemTagCopyImageToClipboard());
+ ContextMenuItem OpenMediaInNewWindowItem(ActionType, ContextMenuItemTagOpenMediaInNewWindow,
+ contextMenuItemTagOpenMediaInNewWindow());
+ ContextMenuItem CopyMediaLinkItem(ActionType, ContextMenuItemTagCopyMediaLinkToClipboard,
+ contextMenuItemTagCopyMediaLinkToClipboard());
+ ContextMenuItem MediaPlayPause(ActionType, ContextMenuItemTagMediaPlayPause,
+ contextMenuItemTagMediaPlay());
+ ContextMenuItem MediaMute(ActionType, ContextMenuItemTagMediaMute,
+ contextMenuItemTagMediaMute());
+ ContextMenuItem ToggleMediaControls(CheckableActionType, ContextMenuItemTagToggleMediaControls,
+ contextMenuItemTagToggleMediaControls());
+ ContextMenuItem ToggleMediaLoop(CheckableActionType, ContextMenuItemTagToggleMediaLoop,
+ contextMenuItemTagToggleMediaLoop());
+ ContextMenuItem EnterVideoFullscreen(ActionType, ContextMenuItemTagEnterVideoFullscreen,
+ contextMenuItemTagEnterVideoFullscreen());
#if PLATFORM(MAC)
ContextMenuItem SearchSpotlightItem(ActionType, ContextMenuItemTagSearchInSpotlight,
contextMenuItemTagSearchInSpotlight());
@@ -349,6 +364,22 @@ void ContextMenu::populate()
appendItem(CopyImageItem);
}
+ KURL mediaURL = result.absoluteMediaURL();
+ if (!mediaURL.isEmpty()) {
+ if (!linkURL.isEmpty() || !imageURL.isEmpty())
+ appendItem(*separatorItem());
+
+ appendItem(MediaPlayPause);
+ appendItem(MediaMute);
+ appendItem(ToggleMediaControls);
+ appendItem(ToggleMediaLoop);
+ appendItem(EnterVideoFullscreen);
+
+ appendItem(*separatorItem());
+ appendItem(CopyMediaLinkItem);
+ appendItem(OpenMediaInNewWindowItem);
+ }
+
if (imageURL.isEmpty() && linkURL.isEmpty()) {
if (result.isSelected()) {
if (selectionContainsPossibleWord(frame)) {
@@ -375,12 +406,6 @@ void ContextMenu::populate()
#if ENABLE(INSPECTOR)
if (!(frame->page() && frame->page()->inspectorController()->hasInspectorFrontendClient())) {
#endif
-#if PLATFORM(GTK)
- appendItem(BackItem);
- appendItem(ForwardItem);
- appendItem(StopItem);
- appendItem(ReloadItem);
-#else
if (frame->page() && frame->page()->canGoBackOrForward(-1))
appendItem(BackItem);
@@ -393,7 +418,6 @@ void ContextMenu::populate()
appendItem(StopItem);
else
appendItem(ReloadItem);
-#endif
#if ENABLE(INSPECTOR)
}
#endif
@@ -788,6 +812,17 @@ void ContextMenu::checkOrEnableIfNeeded(ContextMenuItem& item) const
case ContextMenuItemTagOpenImageInNewWindow:
case ContextMenuItemTagDownloadImageToDisk:
case ContextMenuItemTagCopyImageToClipboard:
+ case ContextMenuItemTagOpenMediaInNewWindow:
+ case ContextMenuItemTagCopyMediaLinkToClipboard:
+ case ContextMenuItemTagToggleMediaControls:
+ shouldCheck = m_hitTestResult.mediaControlsEnabled();
+ break;
+ case ContextMenuItemTagToggleMediaLoop:
+ shouldCheck = m_hitTestResult.mediaLoopEnabled();
+ break;
+ case ContextMenuItemTagEnterVideoFullscreen:
+ shouldEnable = m_hitTestResult.mediaSupportsFullscreen();
+ break;
case ContextMenuItemTagOpenFrameInNewWindow:
case ContextMenuItemTagSpellingGuess:
case ContextMenuItemTagOther:
@@ -823,6 +858,19 @@ void ContextMenu::checkOrEnableIfNeeded(ContextMenuItem& item) const
case ContextMenuItemLastCustomTag:
case ContextMenuItemBaseApplicationTag:
break;
+ case ContextMenuItemTagMediaPlayPause:
+ if (m_hitTestResult.mediaPlaying())
+ item.setTitle(contextMenuItemTagMediaPause());
+ else
+ item.setTitle(contextMenuItemTagMediaPlay());
+ break;
+ case ContextMenuItemTagMediaMute:
+ shouldEnable = m_hitTestResult.mediaHasAudio();
+ if (!shouldEnable || !m_hitTestResult.mediaMuted())
+ item.setTitle(contextMenuItemTagMediaMute());
+ else
+ item.setTitle(contextMenuItemTagMediaUnMute());
+ break;
}
item.setChecked(shouldCheck);
diff --git a/WebCore/platform/ContextMenuItem.h b/WebCore/platform/ContextMenuItem.h
index 058f644..f7fa5e6 100644
--- a/WebCore/platform/ContextMenuItem.h
+++ b/WebCore/platform/ContextMenuItem.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2010 Igalia S.L
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -143,6 +144,13 @@ namespace WebCore {
ContextMenuItemTagCapitalize,
ContextMenuItemTagChangeBack,
#endif
+ ContextMenuItemTagOpenMediaInNewWindow,
+ ContextMenuItemTagCopyMediaLinkToClipboard,
+ ContextMenuItemTagToggleMediaControls,
+ ContextMenuItemTagToggleMediaLoop,
+ ContextMenuItemTagEnterVideoFullscreen,
+ ContextMenuItemTagMediaPlayPause,
+ ContextMenuItemTagMediaMute,
ContextMenuItemBaseCustomTag = 5000,
ContextMenuItemCustomTagNoAction = 5998,
ContextMenuItemLastCustomTag = 5999,
diff --git a/WebCore/platform/LocalizationStrategy.h b/WebCore/platform/LocalizationStrategy.h
index 178cfa2..6c4db6a 100644
--- a/WebCore/platform/LocalizationStrategy.h
+++ b/WebCore/platform/LocalizationStrategy.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Igalia S.L
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -112,6 +113,15 @@ public:
virtual String contextMenuItemTagCapitalize() = 0;
virtual String contextMenuItemTagChangeBack(const String& replacedString) = 0;
#endif
+ virtual String contextMenuItemTagOpenMediaInNewWindow() = 0;
+ virtual String contextMenuItemTagCopyMediaLinkToClipboard() = 0;
+ virtual String contextMenuItemTagToggleMediaControls() = 0;
+ virtual String contextMenuItemTagToggleMediaLoop() = 0;
+ virtual String contextMenuItemTagEnterVideoFullscreen() = 0;
+ virtual String contextMenuItemTagMediaPlay() = 0;
+ virtual String contextMenuItemTagMediaPause() = 0;
+ virtual String contextMenuItemTagMediaMute() = 0;
+ virtual String contextMenuItemTagMediaUnMute() = 0;
virtual String contextMenuItemTagInspectElement() = 0;
#endif // ENABLE(CONTEXT_MENUS)
diff --git a/WebCore/platform/LocalizedStrings.cpp b/WebCore/platform/LocalizedStrings.cpp
index a69e0fb..b2e6b51 100644
--- a/WebCore/platform/LocalizedStrings.cpp
+++ b/WebCore/platform/LocalizedStrings.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2003, 2006, 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 Igalia S.L
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -362,6 +363,51 @@ String contextMenuItemTagChangeBack(const String& replacedString)
}
#endif // PLATFORM(MAC)
+
+String contextMenuItemTagOpenMediaInNewWindow()
+{
+ return platformStrategies()->localizationStrategy()->contextMenuItemTagOpenMediaInNewWindow();
+}
+
+String contextMenuItemTagCopyMediaLinkToClipboard()
+{
+ return platformStrategies()->localizationStrategy()->contextMenuItemTagCopyMediaLinkToClipboard();
+}
+
+String contextMenuItemTagToggleMediaControls()
+{
+ return platformStrategies()->localizationStrategy()->contextMenuItemTagToggleMediaControls();
+}
+
+String contextMenuItemTagToggleMediaLoop()
+{
+ return platformStrategies()->localizationStrategy()->contextMenuItemTagToggleMediaLoop();
+}
+
+String contextMenuItemTagEnterVideoFullscreen()
+{
+ return platformStrategies()->localizationStrategy()->contextMenuItemTagEnterVideoFullscreen();
+}
+
+String contextMenuItemTagMediaPlay()
+{
+ return platformStrategies()->localizationStrategy()->contextMenuItemTagMediaPlay();
+}
+
+String contextMenuItemTagMediaPause()
+{
+ return platformStrategies()->localizationStrategy()->contextMenuItemTagMediaPause();
+}
+
+String contextMenuItemTagMediaMute()
+{
+ return platformStrategies()->localizationStrategy()->contextMenuItemTagMediaMute();
+}
+
+String contextMenuItemTagMediaUnMute()
+{
+ return platformStrategies()->localizationStrategy()->contextMenuItemTagMediaUnMute();
+}
String contextMenuItemTagInspectElement()
{
diff --git a/WebCore/platform/LocalizedStrings.h b/WebCore/platform/LocalizedStrings.h
index 04042b6..e13a407 100644
--- a/WebCore/platform/LocalizedStrings.h
+++ b/WebCore/platform/LocalizedStrings.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2003, 2006, 2009 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2010 Igalia S.L
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -108,6 +109,15 @@ namespace WebCore {
String contextMenuItemTagCapitalize();
String contextMenuItemTagChangeBack(const String& replacedString);
#endif
+ String contextMenuItemTagOpenMediaInNewWindow();
+ String contextMenuItemTagCopyMediaLinkToClipboard();
+ String contextMenuItemTagToggleMediaControls();
+ String contextMenuItemTagToggleMediaLoop();
+ String contextMenuItemTagEnterVideoFullscreen();
+ String contextMenuItemTagMediaPlay();
+ String contextMenuItemTagMediaPause();
+ String contextMenuItemTagMediaMute();
+ String contextMenuItemTagMediaUnMute();
String contextMenuItemTagInspectElement();
#endif // ENABLE(CONTEXT_MENUS)
diff --git a/WebCore/platform/android/LocalizedStringsAndroid.cpp b/WebCore/platform/android/LocalizedStringsAndroid.cpp
index 2fc880b..8d9250a 100644
--- a/WebCore/platform/android/LocalizedStringsAndroid.cpp
+++ b/WebCore/platform/android/LocalizedStringsAndroid.cpp
@@ -81,6 +81,60 @@ String contextMenuItemTagCopyImageToClipboard()
return String();
}
+String contextMenuItemTagOpenMediaInNewWindow()
+{
+ notImplemented();
+ return String();
+}
+
+String contextMenuItemTagCopyMediaLinkToClipboard()
+{
+ notImplemented();
+ return String();
+}
+
+String contextMenuItemTagToggleMediaControls()
+{
+ notImplemented();
+ return String();
+}
+
+String contextMenuItemTagToggleMediaLoop()
+{
+ notImplemented();
+ return String();
+}
+
+String contextMenuItemTagEnterVideoFullscreen()
+{
+ notImplemented();
+ return String();
+}
+
+String contextMenuItemTagMediaPlay()
+{
+ notImplemented();
+ return String();
+}
+
+String contextMenuItemTagMediaPause()
+{
+ notImplemented();
+ return String();
+}
+
+String contextMenuItemTagMediaMute()
+{
+ notImplemented();
+ return String();
+}
+
+String contextMenuItemTagMediaUnMute()
+{
+ notImplemented();
+ return String();
+}
+
String contextMenuItemTagOpenFrameInNewWindow()
{
notImplemented();
diff --git a/WebCore/platform/brew/LocalizedStringsBrew.cpp b/WebCore/platform/brew/LocalizedStringsBrew.cpp
index 1bc5985..b5289c2 100644
--- a/WebCore/platform/brew/LocalizedStringsBrew.cpp
+++ b/WebCore/platform/brew/LocalizedStringsBrew.cpp
@@ -96,6 +96,51 @@ String contextMenuItemTagCopyImageToClipboard()
return "Copy image to clipboard";
}
+String contextMenuItemTagOpenMediaInNewWindow()
+{
+ return "Open Media in New Window";
+}
+
+String contextMenuItemTagCopyMediaLinkToClipboard()
+{
+ return "Copy Media Link Location";
+}
+
+String contextMenuItemTagToggleMediaControls()
+{
+ return "Toggle Media Controls";
+}
+
+String contextMenuItemTagToggleMediaLoop()
+{
+ return "Toggle Media Loop Playback";
+}
+
+String contextMenuItemTagEnterVideoFullscreen()
+{
+ return "Switch Video to Fullscreen";
+}
+
+String contextMenuItemTagMediaPlay()
+{
+ return "Play";
+}
+
+String contextMenuItemTagMediaPause()
+{
+ return "Pause";
+}
+
+String contextMenuItemTagMediaMute()
+{
+ return "Mute";
+}
+
+String contextMenuItemTagMediaUnMute()
+{
+ return "UnMute";
+}
+
String contextMenuItemTagOpenFrameInNewWindow()
{
return "Open frame in new window";
diff --git a/WebCore/platform/efl/LocalizedStringsEfl.cpp b/WebCore/platform/efl/LocalizedStringsEfl.cpp
index 6023205..c645e0d 100644
--- a/WebCore/platform/efl/LocalizedStringsEfl.cpp
+++ b/WebCore/platform/efl/LocalizedStringsEfl.cpp
@@ -98,6 +98,51 @@ String contextMenuItemTagCopyImageToClipboard()
return String::fromUTF8("Copy Image");
}
+String contextMenuItemTagOpenMediaInNewWindow()
+{
+ return String::fromUTF8("Open Media in New Window");
+}
+
+String contextMenuItemTagCopyMediaLinkToClipboard()
+{
+ return String::fromUTF8("Copy Media Link Location");
+}
+
+String contextMenuItemTagToggleMediaControls()
+{
+ return String::fromUTF8("Toggle Media Controls");
+}
+
+String contextMenuItemTagToggleMediaLoop()
+{
+ return String::fromUTF8("Toggle Media Loop Playback");
+}
+
+String contextMenuItemTagEnterVideoFullscreen()
+{
+ return String::fromUTF8("Switch Video to Fullscreen");
+}
+
+String contextMenuItemTagMediaPlay()
+{
+ return String::fromUTF8("Play");
+}
+
+String contextMenuItemTagMediaPause()
+{
+ return String::fromUTF8("Pause");
+}
+
+String contextMenuItemTagMediaMute()
+{
+ return String::fromUTF8("Mute");
+}
+
+String contextMenuItemTagMediaUnMute()
+{
+ return String::fromUTF8("UnMute");
+}
+
String contextMenuItemTagOpenFrameInNewWindow()
{
return String::fromUTF8("Open Frame in New Window");
diff --git a/WebCore/platform/gtk/ContextMenuItemGtk.cpp b/WebCore/platform/gtk/ContextMenuItemGtk.cpp
index e2c5b84..bd25a4a 100644
--- a/WebCore/platform/gtk/ContextMenuItemGtk.cpp
+++ b/WebCore/platform/gtk/ContextMenuItemGtk.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2007 Holger Hans Peter Freyther
+ * Copyright (C) 2010 Igalia S.L
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -33,11 +34,13 @@ static const char* gtkStockIDFromContextMenuAction(const ContextMenuAction& acti
switch (action) {
case ContextMenuItemTagCopyLinkToClipboard:
case ContextMenuItemTagCopyImageToClipboard:
+ case ContextMenuItemTagCopyMediaLinkToClipboard:
case ContextMenuItemTagCopy:
return GTK_STOCK_COPY;
case ContextMenuItemTagOpenLinkInNewWindow:
case ContextMenuItemTagOpenImageInNewWindow:
case ContextMenuItemTagOpenFrameInNewWindow:
+ case ContextMenuItemTagOpenMediaInNewWindow:
return GTK_STOCK_OPEN;
case ContextMenuItemTagDownloadLinkToDisk:
case ContextMenuItemTagDownloadImageToDisk:
@@ -99,6 +102,12 @@ static const char* gtkStockIDFromContextMenuAction(const ContextMenuAction& acti
return GTK_STOCK_UNDERLINE;
case ContextMenuItemTagShowColors:
return GTK_STOCK_SELECT_COLOR;
+ case ContextMenuItemTagToggleMediaControls:
+ case ContextMenuItemTagToggleMediaLoop:
+ // No icon for this.
+ return NULL;
+ case ContextMenuItemTagEnterVideoFullscreen:
+ return GTK_STOCK_FULLSCREEN;
default:
return NULL;
}
diff --git a/WebCore/platform/gtk/LocalizedStringsGtk.cpp b/WebCore/platform/gtk/LocalizedStringsGtk.cpp
index 432c92f..499123b 100644
--- a/WebCore/platform/gtk/LocalizedStringsGtk.cpp
+++ b/WebCore/platform/gtk/LocalizedStringsGtk.cpp
@@ -4,6 +4,7 @@
* Copyright (C) 2007 Holger Hans Peter Freyther
* Copyright (C) 2008 Christian Dywan <christian at imendio.com>
* Copyright (C) 2008 Nuanti Ltd.
+ * Copyright (C) 2010 Igalia S.L
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -110,6 +111,51 @@ String contextMenuItemTagCopyImageToClipboard()
return String::fromUTF8(_("Cop_y Image"));
}
+String contextMenuItemTagOpenMediaInNewWindow()
+{
+ return String::fromUTF8(_("Open _Media in New Window"));
+}
+
+String contextMenuItemTagCopyMediaLinkToClipboard()
+{
+ return String::fromUTF8(_("Cop_y Media Link Location"));
+}
+
+String contextMenuItemTagToggleMediaControls()
+{
+ return String::fromUTF8(_("_Toggle Media Controls"));
+}
+
+String contextMenuItemTagToggleMediaLoop()
+{
+ return String::fromUTF8(_("Toggle Media _Loop Playback"));
+}
+
+String contextMenuItemTagEnterVideoFullscreen()
+{
+ return String::fromUTF8(_("Switch Video to _Fullscreen"));
+}
+
+String contextMenuItemTagMediaPlay()
+{
+ return String::fromUTF8(_("_Play"));
+}
+
+String contextMenuItemTagMediaPause()
+{
+ return String::fromUTF8(_("_Pause"));
+}
+
+String contextMenuItemTagMediaMute()
+{
+ return String::fromUTF8(_("_Mute"));
+}
+
+String contextMenuItemTagMediaUnMute()
+{
+ return String::fromUTF8(_("Un_Mute"));
+}
+
String contextMenuItemTagOpenFrameInNewWindow()
{
return String::fromUTF8(_("Open _Frame in New Window"));
diff --git a/WebCore/platform/haiku/LocalizedStringsHaiku.cpp b/WebCore/platform/haiku/LocalizedStringsHaiku.cpp
index 5321792..28d825b 100644
--- a/WebCore/platform/haiku/LocalizedStringsHaiku.cpp
+++ b/WebCore/platform/haiku/LocalizedStringsHaiku.cpp
@@ -98,6 +98,51 @@ String contextMenuItemTagCopyImageToClipboard()
return "Copy image to clipboard";
}
+String contextMenuItemTagOpenMediaInNewWindow()
+{
+ return "Open Media in New Window";
+}
+
+String contextMenuItemTagCopyMediaLinkToClipboard()
+{
+ return "Copy Media Link Location";
+}
+
+String contextMenuItemTagToggleMediaControls()
+{
+ return "Toggle Media Controls";
+}
+
+String contextMenuItemTagToggleMediaLoop()
+{
+ return "Toggle Media Loop Playback";
+}
+
+String contextMenuItemTagEnterVideoFullscreen()
+{
+ return "Switch Video to Fullscreen";
+}
+
+String contextMenuItemTagMediaPlay()
+{
+ return "Play";
+}
+
+String contextMenuItemTagMediaPause()
+{
+ return "Pause";
+}
+
+String contextMenuItemTagMediaMute()
+{
+ return "Mute";
+}
+
+String contextMenuItemTagMediaUnMute()
+{
+ return "UnMute";
+}
+
String contextMenuItemTagOpenFrameInNewWindow()
{
return "Open frame in new window";
diff --git a/WebCore/platform/wx/LocalizedStringsWx.cpp b/WebCore/platform/wx/LocalizedStringsWx.cpp
index 4112f64..a5afcb7 100644
--- a/WebCore/platform/wx/LocalizedStringsWx.cpp
+++ b/WebCore/platform/wx/LocalizedStringsWx.cpp
@@ -97,6 +97,51 @@ String contextMenuItemTagCopyImageToClipboard()
return String("Copy Image to Clipboard");
}
+String contextMenuItemTagOpenMediaInNewWindow()
+{
+ return String("Open Media in New Window");
+}
+
+String contextMenuItemTagCopyMediaLinkToClipboard()
+{
+ return String("Copy Media Link Location");
+}
+
+String contextMenuItemTagToggleMediaControls()
+{
+ return String("Toggle Media Controls");
+}
+
+String contextMenuItemTagToggleMediaLoop()
+{
+ return String("Toggle Media Loop Playback");
+}
+
+String contextMenuItemTagEnterVideoFullscreen()
+{
+ return String("Switch Video to Fullscreen");
+}
+
+String contextMenuItemTagMediaPlay()
+{
+ return String("Play");
+}
+
+String contextMenuItemTagMediaPause()
+{
+ return String("Pause");
+}
+
+String contextMenuItemTagMediaMute()
+{
+ return String("Mute");
+}
+
+String contextMenuItemTagMediaUnMute()
+{
+ return String("UnMute");
+}
+
String contextMenuItemTagOpenFrameInNewWindow()
{
return String("Open Frame in New Window");
diff --git a/WebCore/rendering/HitTestResult.cpp b/WebCore/rendering/HitTestResult.cpp
index 496c4ba..4ae9990 100644
--- a/WebCore/rendering/HitTestResult.cpp
+++ b/WebCore/rendering/HitTestResult.cpp
@@ -24,6 +24,7 @@
#include "Frame.h"
#include "FrameTree.h"
#include "HTMLAnchorElement.h"
+#include "HTMLVideoElement.h"
#include "HTMLImageElement.h"
#include "HTMLInputElement.h"
#include "HTMLMediaElement.h"
@@ -292,22 +293,125 @@ KURL HitTestResult::absoluteImageURL() const
KURL HitTestResult::absoluteMediaURL() const
{
#if ENABLE(VIDEO)
+ if (HTMLMediaElement* mediaElt = mediaElement())
+ return m_innerNonSharedNode->document()->completeURL(deprecatedParseURL(mediaElt->currentSrc()));
+ return KURL();
+#else
+ return KURL();
+#endif
+}
+
+bool HitTestResult::mediaSupportsFullscreen() const
+{
+#if ENABLE(VIDEO)
+ HTMLMediaElement* mediaElt(mediaElement());
+ return (mediaElt && mediaElt->hasTagName(HTMLNames::videoTag) && mediaElt->supportsFullscreen());
+#else
+ return false;
+#endif
+}
+
+#if ENABLE(VIDEO)
+HTMLMediaElement* HitTestResult::mediaElement() const
+{
if (!(m_innerNonSharedNode && m_innerNonSharedNode->document()))
- return KURL();
+ return 0;
if (!(m_innerNonSharedNode->renderer() && m_innerNonSharedNode->renderer()->isMedia()))
- return KURL();
+ return 0;
- AtomicString urlString;
- if (m_innerNonSharedNode->hasTagName(HTMLNames::videoTag) || m_innerNonSharedNode->hasTagName(HTMLNames::audioTag)) {
- HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(m_innerNonSharedNode.get());
- urlString = mediaElement->currentSrc();
- } else
- return KURL();
+ if (m_innerNonSharedNode->hasTagName(HTMLNames::videoTag) || m_innerNonSharedNode->hasTagName(HTMLNames::audioTag))
+ return static_cast<HTMLMediaElement*>(m_innerNonSharedNode.get());
+ return 0;
+}
+#endif
- return m_innerNonSharedNode->document()->completeURL(deprecatedParseURL(urlString));
-#else
- return KURL();
+void HitTestResult::toggleMediaControlsDisplay() const
+{
+#if ENABLE(VIDEO)
+ if (HTMLMediaElement* mediaElt = mediaElement())
+ mediaElt->setControls(!mediaElt->controls());
+#endif
+}
+
+void HitTestResult::toggleMediaLoopPlayback() const
+{
+#if ENABLE(VIDEO)
+ if (HTMLMediaElement* mediaElt = mediaElement())
+ mediaElt->setLoop(!mediaElt->loop());
+#endif
+}
+
+void HitTestResult::enterFullscreenForVideo() const
+{
+#if ENABLE(VIDEO)
+ HTMLMediaElement* mediaElt(mediaElement());
+ if (mediaElt && mediaElt->hasTagName(HTMLNames::videoTag)) {
+ HTMLVideoElement* videoElt = static_cast<HTMLVideoElement*>(mediaElt);
+ if (!videoElt->isFullscreen() && mediaElt->supportsFullscreen())
+ videoElt->enterFullscreen();
+ }
+#endif
+}
+
+bool HitTestResult::mediaControlsEnabled() const
+{
+#if ENABLE(VIDEO)
+ if (HTMLMediaElement* mediaElt = mediaElement())
+ return mediaElt->controls();
+#endif
+ return false;
+}
+
+bool HitTestResult::mediaLoopEnabled() const
+{
+#if ENABLE(VIDEO)
+ if (HTMLMediaElement* mediaElt = mediaElement())
+ return mediaElt->loop();
+#endif
+ return false;
+}
+
+bool HitTestResult::mediaPlaying() const
+{
+#if ENABLE(VIDEO)
+ if (HTMLMediaElement* mediaElt = mediaElement())
+ return !mediaElt->paused();
+#endif
+ return false;
+}
+
+void HitTestResult::toggleMediaPlayState() const
+{
+#if ENABLE(VIDEO)
+ if (HTMLMediaElement* mediaElt = mediaElement())
+ mediaElt->togglePlayState();
+#endif
+}
+
+bool HitTestResult::mediaHasAudio() const
+{
+#if ENABLE(VIDEO)
+ if (HTMLMediaElement* mediaElt = mediaElement())
+ return mediaElt->hasAudio();
+#endif
+ return false;
+}
+
+bool HitTestResult::mediaMuted() const
+{
+#if ENABLE(VIDEO)
+ if (HTMLMediaElement* mediaElt = mediaElement())
+ return mediaElt->muted();
+#endif
+ return false;
+}
+
+void HitTestResult::toggleMediaMuteState() const
+{
+#if ENABLE(VIDEO)
+ if (HTMLMediaElement* mediaElt = mediaElement())
+ mediaElt->setMuted(!mediaElt->muted());
#endif
}
diff --git a/WebCore/rendering/HitTestResult.h b/WebCore/rendering/HitTestResult.h
index 3a42719..e635033 100644
--- a/WebCore/rendering/HitTestResult.h
+++ b/WebCore/rendering/HitTestResult.h
@@ -32,6 +32,9 @@ namespace WebCore {
class Element;
class Frame;
+#if ENABLE(VIDEO)
+class HTMLMediaElement;
+#endif
class Image;
class IntRect;
class KURL;
@@ -80,6 +83,17 @@ public:
String textContent() const;
bool isLiveLink() const;
bool isContentEditable() const;
+ void toggleMediaControlsDisplay() const;
+ void toggleMediaLoopPlayback() const;
+ void enterFullscreenForVideo() const;
+ bool mediaControlsEnabled() const;
+ bool mediaLoopEnabled() const;
+ bool mediaPlaying() const;
+ bool mediaSupportsFullscreen() const;
+ void toggleMediaPlayState() const;
+ bool mediaHasAudio() const;
+ bool mediaMuted() const;
+ void toggleMediaMuteState() const;
// Rect-based hit test related methods.
bool isRectBasedTest() const { return m_isRectBased; }
@@ -96,6 +110,10 @@ public:
private:
+#if ENABLE(VIDEO)
+ HTMLMediaElement* mediaElement() const;
+#endif
+
RefPtr<Node> m_innerNode;
RefPtr<Node> m_innerNonSharedNode;
IntPoint m_point;
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index a24382d..c468165 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,20 @@
+2010-09-15 Philippe Normand <pnormand at igalia.com>
+
+ Reviewed by Eric Carlson.
+
+ [GTK] enhanced context menu for media elements
+ https://bugs.webkit.org/show_bug.cgi?id=45021
+
+ EventSender::contextClick() now returns an array of js
+ objects. Each object has a title property and a click() method.
+
+ * DumpRenderTree/gtk/EventSender.cpp:
+ (getMenuItemTitleCallback):
+ (setMenuItemTitleCallback):
+ (menuItemClickCallback):
+ (getMenuItemClass):
+ (contextClickCallback):
+
2010-09-14 Philippe Normand <pnormand at igalia.com>
Reviewed by Eric Carlson and Martin Robinson.
diff --git a/WebKitTools/DumpRenderTree/gtk/EventSender.cpp b/WebKitTools/DumpRenderTree/gtk/EventSender.cpp
index 0e2e469..fe7e93a 100644
--- a/WebKitTools/DumpRenderTree/gtk/EventSender.cpp
+++ b/WebKitTools/DumpRenderTree/gtk/EventSender.cpp
@@ -147,6 +147,58 @@ bool prepareMouseButtonEvent(GdkEvent* event, int eventSenderButtonNumber, guint
return true;
}
+static JSValueRef getMenuItemTitleCallback(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ GtkWidget* widget = GTK_WIDGET(JSObjectGetPrivate(object));
+ CString label;
+ if (GTK_IS_SEPARATOR_MENU_ITEM(widget))
+ label = "<separator>";
+ else
+ label = gtk_menu_item_get_label(GTK_MENU_ITEM(widget));
+
+ return JSValueMakeString(context, JSStringCreateWithUTF8CString(label.data()));
+}
+
+static bool setMenuItemTitleCallback(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+{
+ return true;
+}
+
+static JSValueRef menuItemClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ GtkMenuItem* item = GTK_MENU_ITEM(JSObjectGetPrivate(thisObject));
+ gtk_menu_item_activate(item);
+ return JSValueMakeUndefined(context);
+}
+
+static JSStaticFunction staticMenuItemFunctions[] = {
+ { "click", menuItemClickCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { 0, 0, 0 }
+};
+
+static JSStaticValue staticMenuItemValues[] = {
+ { "title", getMenuItemTitleCallback, setMenuItemTitleCallback, kJSPropertyAttributeNone },
+ { 0, 0, 0, 0 }
+};
+
+static JSClassRef getMenuItemClass()
+{
+ static JSClassRef menuItemClass = 0;
+
+ if (!menuItemClass) {
+ JSClassDefinition classDefinition = {
+ 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ classDefinition.staticFunctions = staticMenuItemFunctions;
+ classDefinition.staticValues = staticMenuItemValues;
+
+ menuItemClass = JSClassCreate(&classDefinition);
+ }
+
+ return menuItemClass;
+}
+
+
static JSValueRef contextClickCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
GdkEvent* pressEvent = gdk_event_new(GDK_BUTTON_PRESS);
@@ -165,13 +217,7 @@ static JSValueRef contextClickCallback(JSContextRef context, JSObjectRef functio
JSValueRef arrayValues[g_list_length(items)];
int index = 0;
for (GList* item = g_list_first(items); item; item = g_list_next(item)) {
- CString label;
- if (GTK_IS_SEPARATOR_MENU_ITEM(item->data))
- label = "<separator>";
- else
- label = gtk_menu_item_get_label(GTK_MENU_ITEM(item->data));
-
- arrayValues[index] = JSValueMakeString(context, JSStringCreateWithUTF8CString(label.data()));
+ arrayValues[index] = JSObjectMake(context, getMenuItemClass(), item->data);
index++;
}
if (index)
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list