Changeset 66799 in webkit


Ignore:
Timestamp:
Sep 4, 2010 5:19:55 PM (14 years ago)
Author:
weinig@apple.com
Message:

Allow passing null to postMessage API functions
https://bugs.webkit.org/show_bug.cgi?id=45234

Reviewed by Anders Carlsson.

  • Shared/APIObject.h: Add TypeNull to enum. This is only used

for serialization purposes, and does not represent a concrete subclass
of APIObject.

  • Shared/CoreIPCSupport/WebPageProxyMessageKinds.h: Remove WillSubmitFormWithUserData

now that it is not needed.

  • Shared/UserMessageCoders.h:

(WebKit::UserMessageEncoder::baseEncode):
(WebKit::UserMessageDecoder::baseDecode):
Add explicit encoding/decoding of null for user messages.

  • UIProcess/WebContextUserMessageCoders.h:

(WebKit::WebContextUserMessageEncoder::encode):
(WebKit::WebContextUserMessageDecoder::decode):

  • WebProcess/InjectedBundle/InjectedBundleUserMessageCoders.h:

(WebKit::InjectedBundleUserMessageEncoder::encode):
(WebKit::InjectedBundleUserMessageDecoder::decode):
Update UserMessageCoders subclasses to call the base class in the correct
way to work with null messages. This means moving the encoding/decoding
of the type down to the base class, which is a nice cleanup.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::didReceiveMessage):
Remove now redundant WillSubmitFormWithUserData implementation.

  • WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:

(WebKit::WebFrameLoaderClient::dispatchWillSubmitForm):
Ditto.

Location:
trunk/WebKit2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r66794 r66799  
     12010-09-04  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        Allow passing null to postMessage API functions
     6        https://bugs.webkit.org/show_bug.cgi?id=45234
     7
     8        * Shared/APIObject.h: Add TypeNull to enum. This is only used
     9        for serialization purposes, and does not represent a concrete subclass
     10        of APIObject.
     11
     12        * Shared/CoreIPCSupport/WebPageProxyMessageKinds.h: Remove WillSubmitFormWithUserData
     13        now that it is not needed.
     14
     15        * Shared/UserMessageCoders.h:
     16        (WebKit::UserMessageEncoder::baseEncode):
     17        (WebKit::UserMessageDecoder::baseDecode):
     18        Add explicit encoding/decoding of null for user messages.
     19
     20        * UIProcess/WebContextUserMessageCoders.h:
     21        (WebKit::WebContextUserMessageEncoder::encode):
     22        (WebKit::WebContextUserMessageDecoder::decode):
     23        * WebProcess/InjectedBundle/InjectedBundleUserMessageCoders.h:
     24        (WebKit::InjectedBundleUserMessageEncoder::encode):
     25        (WebKit::InjectedBundleUserMessageDecoder::decode):
     26        Update UserMessageCoders subclasses to call the base class in the correct
     27        way to work with null messages. This means moving the encoding/decoding
     28        of the type down to the base class, which is a nice cleanup.
     29
     30        * UIProcess/WebPageProxy.cpp:
     31        (WebKit::WebPageProxy::didReceiveMessage):
     32        Remove now redundant WillSubmitFormWithUserData implementation.
     33
     34        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     35        (WebKit::WebFrameLoaderClient::dispatchWillSubmitForm):
     36        Ditto.
     37
    1382010-09-03  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
    239
  • trunk/WebKit2/Shared/APIObject.h

    r66619 r66799  
    3535    enum Type {
    3636        // Base types
     37        TypeNull,
    3738        TypeArray,
    3839        TypeData,
  • trunk/WebKit2/Shared/CoreIPCSupport/WebPageProxyMessageKinds.h

    r66789 r66799  
    6868    TakeFocus,
    6969    WillSubmitForm,
    70     WillSubmitFormWithUserData,
    7170   
    7271    BackForwardAddItem,
  • trunk/WebKit2/Shared/UserMessageCoders.h

    r66693 r66799  
    3333namespace WebKit {
    3434
     35//   - Null -> Null
    3536//   - Array -> Array
    3637//   - Dictionary -> Dictionary
     
    4041class UserMessageEncoder {
    4142public:
    42     bool baseEncode(CoreIPC::ArgumentEncoder* encoder, APIObject::Type type) const
     43    bool baseEncode(CoreIPC::ArgumentEncoder* encoder, APIObject::Type& type) const
    4344    {
     45        if (!m_root) {
     46            encoder->encodeUInt32(APIObject::TypeNull);
     47            return true;
     48        }
     49
     50        type = m_root->type();
     51        encoder->encodeUInt32(type);
     52
    4453        switch (type) {
    4554        case APIObject::TypeArray: {
     
    8695
    8796// Handles
     97//   - Null -> Null
    8898//   - Array -> Array
    8999//   - Dictionary -> Dictionary
     
    93103class UserMessageDecoder {
    94104public:
    95     static bool baseDecode(CoreIPC::ArgumentDecoder* decoder, Owner& coder, APIObject::Type type)
     105    static bool baseDecode(CoreIPC::ArgumentDecoder* decoder, Owner& coder, APIObject::Type& type)
    96106    {
     107        uint32_t typeAsUInt32;
     108        if (!decoder->decode(typeAsUInt32))
     109            return false;
     110
     111        type = static_cast<APIObject::Type>(typeAsUInt32);
     112
    97113        switch (type) {
    98114        case APIObject::TypeArray: {
  • trunk/WebKit2/UIProcess/WebContextUserMessageCoders.h

    r66688 r66799  
    4444    void encode(CoreIPC::ArgumentEncoder* encoder) const
    4545    {
    46         APIObject::Type type = m_root->type();
    47         encoder->encode(static_cast<uint32_t>(type));
    48 
     46        APIObject::Type type = APIObject::TypeNull;
    4947        if (baseEncode(encoder, type))
    5048            return;
     
    8482    static bool decode(CoreIPC::ArgumentDecoder* decoder, WebContextUserMessageDecoder& coder)
    8583    {
    86         uint32_t type;
    87         if (!decoder->decode(type))
     84        APIObject::Type type = APIObject::TypeNull;
     85        if (!Base::baseDecode(decoder, coder, type))
    8886            return false;
    8987
    90         if (!Base::baseDecode(decoder, coder, static_cast<APIObject::Type>(type)))
    91             return false;
    92 
    93         // If the base decoded something into root, we are done.
    94         if (coder.m_root)
     88        if (coder.m_root || type == APIObject::TypeNull)
    9589            return true;
    9690
  • trunk/WebKit2/UIProcess/WebPageProxy.cpp

    r66789 r66799  
    577577            Vector<std::pair<String, String> > textFieldValues;
    578578            uint64_t listenerID;
    579             if (!arguments->decode(CoreIPC::Out(frameID, sourceFrameID, textFieldValues, listenerID)))
    580                 return;
    581 
    582             APIObject* noUserData = 0;
    583             willSubmitForm(process()->webFrame(frameID), process()->webFrame(sourceFrameID), textFieldValues, noUserData, listenerID);
    584             break;
    585         }
    586         case WebPageProxyMessage::WillSubmitFormWithUserData: {
    587             uint64_t frameID;
    588             uint64_t sourceFrameID;
    589             Vector<std::pair<String, String> > textFieldValues;
    590             uint64_t listenerID;
    591            
     579
    592580            RefPtr<APIObject> userData;
    593581            WebContextUserMessageDecoder messageDecoder(userData, pageNamespace()->context());
     
    599587            break;
    600588        }
    601        
    602589        case WebPageProxyMessage::DidRunJavaScriptInMainFrame: {
    603590            String resultString;
  • trunk/WebKit2/WebProcess/InjectedBundle/InjectedBundleUserMessageCoders.h

    r66688 r66799  
    4444    void encode(CoreIPC::ArgumentEncoder* encoder) const
    4545    {
    46         APIObject::Type type = m_root->type();
    47         encoder->encode(static_cast<uint32_t>(type));
    48        
     46        APIObject::Type type = APIObject::TypeNull;
    4947        if (baseEncode(encoder, type))
    5048            return;
     
    8280    static bool decode(CoreIPC::ArgumentDecoder* decoder, InjectedBundleUserMessageDecoder& coder)
    8381    {
    84         uint32_t type;
    85         if (!decoder->decode(type))
     82        APIObject::Type type = APIObject::TypeNull;
     83        if (!Base::baseDecode(decoder, coder, type))
    8684            return false;
    8785
    88         if (!Base::baseDecode(decoder, coder, static_cast<APIObject::Type>(type)))
    89             return false;
    90 
    91         // If the base created something in root, we are done.
    92         if (coder.m_root)
     86        if (coder.m_root || type == APIObject::TypeNull)
    9387            return true;
    9488
  • trunk/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r66794 r66799  
    524524    uint64_t listenerID = m_frame->setUpPolicyListener(function);
    525525
    526     if (userData) {
    527         WebProcess::shared().connection()->send(WebPageProxyMessage::WillSubmitFormWithUserData, webPage->pageID(),
    528                                                 CoreIPC::In(m_frame->frameID(), sourceFrame->frameID(), values, listenerID, InjectedBundleUserMessageEncoder(userData.get())));
    529     } else {
    530         WebProcess::shared().connection()->send(WebPageProxyMessage::WillSubmitForm, webPage->pageID(),
    531                                                 CoreIPC::In(m_frame->frameID(), sourceFrame->frameID(), values, listenerID));
    532     }
     526    WebProcess::shared().connection()->send(WebPageProxyMessage::WillSubmitForm, webPage->pageID(),
     527                                            CoreIPC::In(m_frame->frameID(), sourceFrame->frameID(), values, listenerID, InjectedBundleUserMessageEncoder(userData.get())));
    533528}
    534529
Note: See TracChangeset for help on using the changeset viewer.