Changeset 122555 in webkit


Ignore:
Timestamp:
Jul 13, 2012 2:38:50 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[V8Bindings] Implement generalised method to validates that the passed object is a sequence type.
https://bugs.webkit.org/show_bug.cgi?id=91056

Patch by Vineet Chaudhary <Vineet> on 2012-07-13
Reviewed by Kentaro Hara.

Currently the V8 implementation validates that the passed object is a sequence type only
for MessagePort in V8Utilities::extractTransferables().
There should be generalised method for other types too.
Spec URL: http://www.w3.org/TR/2012/WD-WebIDL-20120207/#es-sequence

No new test, Just refactoring. There should be no behavioral changes.

  • bindings/v8/V8Binding.h:

(WebCore::toV8Sequence): Added implementation of toV8Sequence().

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122554 r122555  
     12012-07-13  Vineet Chaudhary  <rgf748@motorola.com>
     2
     3        [V8Bindings] Implement generalised method to validates that the passed object is a sequence type.
     4        https://bugs.webkit.org/show_bug.cgi?id=91056
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Currently the V8 implementation validates that the passed object is a sequence type only
     9        for MessagePort in V8Utilities::extractTransferables().
     10        There should be generalised method for other types too.
     11        Spec URL: http://www.w3.org/TR/2012/WD-WebIDL-20120207/#es-sequence
     12
     13        No new test, Just refactoring. There should be no behavioral changes.
     14
     15        * bindings/v8/V8Binding.h:
     16        (WebCore::toV8Sequence): Added implementation of toV8Sequence().
     17
    1182012-07-13  Zeno Albisser  <zeno@webkit.org>
    219
  • trunk/Source/WebCore/bindings/v8/V8Binding.h

    r122466 r122555  
    3535#include "DOMDataStore.h"
    3636#include "PlatformString.h"
     37#include "V8BindingMacros.h"
    3738#include "V8DOMWrapper.h"
    3839#include "V8GCController.h"
     
    438439        }
    439440        return result;
     441    }
     442
     443    // Validates that the passed object is a sequence type per WebIDL spec
     444    // http://www.w3.org/TR/2012/WD-WebIDL-20120207/#es-sequence
     445    inline v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value> value, uint32_t& length)
     446    {
     447        if (!value->IsObject()) {
     448            V8Proxy::throwTypeError();
     449            return v8::Local<v8::Value>();
     450        }
     451
     452        v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(value));
     453        v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
     454
     455        EXCEPTION_BLOCK(v8::Local<v8::Value>, lengthValue, object->Get(v8::String::New("length")));
     456
     457        if (lengthValue->IsUndefined() || lengthValue->IsNull()) {
     458            V8Proxy::throwTypeError();
     459            return v8::Local<v8::Value>();
     460        }
     461
     462        EXCEPTION_BLOCK(uint32_t, sequenceLength, lengthValue->Int32Value());
     463        length = sequenceLength;
     464
     465        return v8Value;
    440466    }
    441467
Note: See TracChangeset for help on using the changeset viewer.