Changeset 104634 in webkit


Ignore:
Timestamp:
Jan 10, 2012 3:01:52 PM (12 years ago)
Author:
bbudge@chromium.org
Message:

Allow plugins to add rotate items to browser's context menu. Adds a new
WebPluginAction struct, with rotate types.
https://bugs.webkit.org/show_bug.cgi?id=75645

Reviewed by Darin Fisher.

  • WebKit.gyp:
  • public/WebContextMenuData.h:
  • public/WebPlugin.h:

(WebKit::WebPlugin::canRotateView):
(WebKit::WebPlugin::rotateView):

  • public/WebPluginAction.h: Added.

(WebKit::WebPluginAction::WebPluginAction):

  • public/WebView.h:
  • src/ContextMenuClientImpl.cpp:

(WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):

  • src/WebViewImpl.cpp:

(WebKit::WebViewImpl::performMediaPlayerAction):
(WebKit::WebViewImpl::performPluginAction):

  • src/WebViewImpl.h:
Location:
trunk/Source/WebKit/chromium
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r104626 r104634  
     12012-01-10  Bill Budge  <bbudge@chromium.org>
     2
     3        Allow plugins to add rotate items to browser's context menu. Adds a new
     4        WebPluginAction struct, with rotate types.
     5        https://bugs.webkit.org/show_bug.cgi?id=75645
     6
     7        Reviewed by Darin Fisher.
     8
     9        * WebKit.gyp:
     10        * public/WebContextMenuData.h:
     11        * public/WebPlugin.h:
     12        (WebKit::WebPlugin::canRotateView):
     13        (WebKit::WebPlugin::rotateView):
     14        * public/WebPluginAction.h: Added.
     15        (WebKit::WebPluginAction::WebPluginAction):
     16        * public/WebView.h:
     17        * src/ContextMenuClientImpl.cpp:
     18        (WebKit::ContextMenuClientImpl::getCustomMenuFromDefaultItems):
     19        * src/WebViewImpl.cpp:
     20        (WebKit::WebViewImpl::performMediaPlayerAction):
     21        (WebKit::WebViewImpl::performPluginAction):
     22        * src/WebViewImpl.h:
     23
    1242012-01-10  Dana Jansens  <danakj@chromium.org>
    225
  • trunk/Source/WebKit/chromium/WebKit.gyp

    r104607 r104634  
    217217                'public/WebPermissionClient.h',
    218218                'public/WebPlugin.h',
     219                'public/WebPluginAction.h',
    219220                'public/WebPluginContainer.h',
    220221                'public/WebPluginDocument.h',
  • trunk/Source/WebKit/chromium/public/WebContextMenuData.h

    r101709 r104634  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
     2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    103103        MediaControlRootElement = 0x80,
    104104        MediaCanPrint = 0x100,
     105        MediaCanRotate = 0x200,
    105106    };
    106107
  • trunk/Source/WebKit/chromium/public/WebPlugin.h

    r103147 r104634  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
     2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    126126    virtual void stopFind() { }
    127127
     128    // View rotation types.
     129    enum RotationType {
     130        RotationType90Clockwise,
     131        RotationType90Counterclockwise
     132    };
     133    // Whether the plugin can rotate the view of its content.
     134    virtual bool canRotateView() { return false; }
     135    // Rotates the plugin's view of its content.
     136    virtual void rotateView(RotationType type) { }
     137
    128138protected:
    129139    ~WebPlugin() { }
  • trunk/Source/WebKit/chromium/public/WebView.h

    r104537 r104634  
    5656class WebViewClient;
    5757struct WebMediaPlayerAction;
     58struct WebPluginAction;
    5859struct WebPoint;
    5960
     
    274275    // Media ---------------------------------------------------------------
    275276
    276     // Performs the specified action on the node at the given location.
     277    // Performs the specified media player action on the node at the given location.
    277278    virtual void performMediaPlayerAction(
    278279        const WebMediaPlayerAction&, const WebPoint& location) = 0;
     280
     281    // Performs the specified plugin action on the node at the given location.
     282    virtual void performPluginAction(
     283        const WebPluginAction&, const WebPoint& location) = 0;
    279284
    280285
  • trunk/Source/WebKit/chromium/src/ContextMenuClientImpl.cpp

    r102044 r104634  
    11/*
    2  * Copyright (C) 2009 Google Inc. All rights reserved.
     2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    235235                data.srcURL = pluginElement->document()->completeURL(pluginElement->url());
    236236                data.mediaFlags |= WebContextMenuData::MediaCanSave;
     237
     238                // Add context menu commands that are supported by the plugin.
     239                if (plugin->plugin()->canRotateView())
     240                    data.mediaFlags |= WebContextMenuData::MediaCanRotate;
    237241            }
    238242        }
  • trunk/Source/WebKit/chromium/src/WebViewImpl.cpp

    r104600 r104634  
    11/*
    2  * Copyright (C) 2011 Google Inc. All rights reserved.
     2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    9696#include "RenderLayerCompositor.h"
    9797#include "RenderView.h"
     98#include "RenderWidget.h"
    9899#include "ResourceHandle.h"
    99100#include "SchemeRegistry.h"
     
    126127#include "WebNode.h"
    127128#include "WebPlugin.h"
     129#include "WebPluginAction.h"
    128130#include "WebPluginContainerImpl.h"
    129131#include "platform/WebPoint.h"
     
    21842186    RefPtr<Node> node = result.innerNonSharedNode();
    21852187    if (!node->hasTagName(HTMLNames::videoTag) && !node->hasTagName(HTMLNames::audioTag))
    2186       return;
     2188        return;
    21872189
    21882190    RefPtr<HTMLMediaElement> mediaElement =
     
    22092211}
    22102212
     2213void WebViewImpl::performPluginAction(const WebPluginAction& action,
     2214                                      const WebPoint& location)
     2215{
     2216    HitTestResult result = hitTestResultForWindowPos(location);
     2217    RefPtr<Node> node = result.innerNonSharedNode();
     2218    if (!node->hasTagName(HTMLNames::objectTag) && !node->hasTagName(HTMLNames::embedTag))
     2219        return;
     2220
     2221    RenderObject* object = node->renderer();
     2222    if (object && object->isWidget()) {
     2223        Widget* widget = toRenderWidget(object)->widget();
     2224        if (widget && widget->isPluginContainer()) {
     2225            WebPluginContainerImpl* plugin = static_cast<WebPluginContainerImpl*>(widget);
     2226            switch (action.type) {
     2227            case WebPluginAction::Rotate90Clockwise:
     2228                plugin->plugin()->rotateView(WebPlugin::RotationType90Clockwise);
     2229                break;
     2230            case WebPluginAction::Rotate90Counterclockwise:
     2231                plugin->plugin()->rotateView(WebPlugin::RotationType90Counterclockwise);
     2232                break;
     2233            default:
     2234                ASSERT_NOT_REACHED();
     2235            }
     2236        }
     2237    }
     2238}
     2239
    22112240void WebViewImpl::copyImageAt(const WebPoint& point)
    22122241{
  • trunk/Source/WebKit/chromium/src/WebViewImpl.h

    r104248 r104634  
    187187        const WebMediaPlayerAction& action,
    188188        const WebPoint& location);
     189    virtual void performPluginAction(
     190        const WebPluginAction&,
     191        const WebPoint&);
    189192    virtual void copyImageAt(const WebPoint& point);
    190193    virtual void dragSourceEndedAt(
Note: See TracChangeset for help on using the changeset viewer.