Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: webkit/glue/context_menu_client_impl.cc

Issue 164279: View Background Image Feature (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/context_menu.h ('k') | webkit/glue/webview_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/context_menu_client_impl.cc
===================================================================
--- webkit/glue/context_menu_client_impl.cc (revision 21856)
+++ webkit/glue/context_menu_client_impl.cc (working copy)
@@ -14,6 +14,13 @@
#include "EventHandler.h"
#include "FrameLoader.h"
#include "FrameView.h"
+#include "CSSMutableStyleDeclaration.h"
+#include "CSSPrimitiveValue.h"
+#include "CSSProperty.h"
+#include "CSSStyleSelector.h"
+#include "CSSValue.h"
+#include "CSSValueKeywords.h"
+#include "CSSImageValue.h"
#include "HitTestResult.h"
#include "HTMLMediaElement.h"
#include "HTMLNames.h"
@@ -34,6 +41,7 @@
#include "base/word_iterator.h"
+using namespace WebCore;
using WebKit::WebDataSource;
namespace {
@@ -170,17 +178,17 @@
if (!link_url.isEmpty()) {
node_type.type |= ContextNodeType::LINK;
}
-
WebCore::KURL src_url;
ContextMenuMediaParams media_params;
+ GURL bkg_url;
if (!r.absoluteImageURL().isEmpty()) {
src_url = r.absoluteImageURL();
node_type.type |= ContextNodeType::IMAGE;
} else if (!r.absoluteMediaURL().isEmpty()) {
src_url = r.absoluteMediaURL();
-
+
// We know that if absoluteMediaURL() is not empty, then this is a media
// element.
WebCore::HTMLMediaElement* media_element =
@@ -207,7 +215,38 @@
}
// TODO(ajwong): Report error states in the media player.
}
+ else {
+ //looks to see if the node we're clicking on contains a background image
+ //since the media inspection was done I figured we could
+ //apply that to the background image
+ WebCore::HTMLElement* gen_element =
+ static_cast<WebCore::HTMLElement*>(r.innerNonSharedNode());
+ //for now just take the inline style. The end solution will merge with the element in the css doc.
+ RefPtr<WebCore::CSSMutableStyleDeclaration> decl = gen_element->getInlineStyleDecl()->copy();
+ WebCore::CSSMutableStyleDeclarationConstIterator end = decl->end();
+
+ //this is a dumb loop in the sense that I'm just looking for any property that
+ //supports an image value.
+ //
+ //Will need to make this better going forward
+ for(WebCore::CSSMutableStyleDeclarationConstIterator it = decl->begin(); it != end; ++it) {
+ const WebCore::CSSProperty& prop = *it;
+ WebCore::CSSValue* val = prop.value();
+
+ //wasn't sure the difference between isImageGeneratorValue or isImageValue
+ //appears isImageValue returns true for what we need, but I'm lumping the
+ //other in here for now.
+ if ((val->isImageGeneratorValue()) || (val->isImageValue())) {
+ WebCore::CSSImageValue* imgVal =
+ static_cast<WebCore::CSSImageValue*>(val);
+
+ //this is nice. well done.
+ bkg_url = webkit_glue::StringToGURL(imgVal->getStringValue());
+ }
+ }
+ }
+
// If it's not a link, an image, a media element, or an image/media link,
// show a selection menu or a more generic page menu.
std::wstring selection_text_string;
@@ -218,12 +257,16 @@
std::string frame_charset = WideToASCII(
webkit_glue::StringToStdWString(selected_frame->loader()->encoding()));
+
+
// Send the frame and page URLs in any case.
ContextNodeType frame_node = ContextNodeType(ContextNodeType::NONE);
ContextNodeType page_node =
GetTypeAndURLFromFrame(webview_->main_frame()->frame(),
&page_url,
ContextNodeType(ContextNodeType::PAGE));
+
+
if (selected_frame != webview_->main_frame()->frame()) {
frame_node =
GetTypeAndURLFromFrame(selected_frame,
@@ -287,6 +330,7 @@
webkit_glue::KURLToGURL(src_url),
page_url,
frame_url,
+ bkg_url,
media_params,
selection_text_string,
misspelled_word_string,
@@ -327,8 +371,12 @@
return false; // TODO(jackson): Eventually include the inspector context menu item
}
+
+
#if defined(OS_MACOSX)
void ContextMenuClientImpl::searchWithSpotlight() {
// TODO(pinkerton): write this
}
#endif
+
+
« no previous file with comments | « webkit/glue/context_menu.h ('k') | webkit/glue/webview_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698