Changeset 141509 in webkit


Ignore:
Timestamp:
Jan 31, 2013 5:12:22 PM (11 years ago)
Author:
haraken@chromium.org
Message:

[V8] Clean up Dictionary::get() by removing redundant FindInstanceInPrototypeChain()
https://bugs.webkit.org/show_bug.cgi?id=108443

Reviewed by Adam Barth.

In Dictionary::get(), wrapper->FindInstanceInPrototypeChain(V8XXX::GetTemplate())
is unnecessary for DOM wrappers other than DOMWindow. For wrappers other than
DOMWindow, we can simply use V8XXX::HasInstance(wrapper).

Tests: fast/events/constructors/*

  • bindings/v8/Dictionary.cpp:

(WebCore::Dictionary::get):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r141505 r141509  
     12013-01-31  Kentaro Hara  <haraken@chromium.org>
     2
     3        [V8] Clean up Dictionary::get() by removing redundant FindInstanceInPrototypeChain()
     4        https://bugs.webkit.org/show_bug.cgi?id=108443
     5
     6        Reviewed by Adam Barth.
     7
     8        In Dictionary::get(), wrapper->FindInstanceInPrototypeChain(V8XXX::GetTemplate())
     9        is unnecessary for DOM wrappers other than DOMWindow. For wrappers other than
     10        DOMWindow, we can simply use V8XXX::HasInstance(wrapper).
     11
     12        Tests: fast/events/constructors/*
     13
     14        * bindings/v8/Dictionary.cpp:
     15        (WebCore::Dictionary::get):
     16
    1172013-01-31  Julien Chaffraix  <jchaffraix@webkit.org>
    218
  • trunk/Source/WebCore/bindings/v8/Dictionary.cpp

    r141383 r141509  
    255255        return false;
    256256
    257     DOMWindow* source = 0;
     257    // We need to handle a DOMWindow specially, because a DOMWindow wrapper
     258    // exists on a prototype chain of v8Value.
     259    value = 0;
    258260    if (v8Value->IsObject()) {
    259261        v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
    260262        v8::Handle<v8::Object> window = wrapper->FindInstanceInPrototypeChain(V8DOMWindow::GetTemplate(m_isolate));
    261263        if (!window.IsEmpty())
    262             source = V8DOMWindow::toNative(window);
    263     }
    264     value = source;
     264            value = V8DOMWindow::toNative(window);
     265    }
    265266    return true;
    266267}
     
    272273        return false;
    273274
    274     Storage* source = 0;
    275     if (v8Value->IsObject()) {
    276         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
    277         v8::Handle<v8::Object> storage = wrapper->FindInstanceInPrototypeChain(V8Storage::GetTemplate(m_isolate));
    278         if (!storage.IsEmpty())
    279             source = V8Storage::toNative(storage);
    280     }
    281     value = source;
     275    value = 0;
     276    if (V8Storage::HasInstance(v8Value))
     277        value = V8Storage::toNative(v8::Handle<v8::Object>::Cast(v8Value));
    282278    return true;
    283279}
     
    335331        return false;
    336332
    337     Uint8Array* source = 0;
    338     if (v8Value->IsObject()) {
    339         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
    340         v8::Handle<v8::Object> array = wrapper->FindInstanceInPrototypeChain(V8Uint8Array::GetTemplate(m_isolate));
    341         if (!array.IsEmpty())
    342             source = V8Uint8Array::toNative(array);
    343     }
    344     value = source;
     333    value = 0;
     334    if (V8Uint8Array::HasInstance(v8Value))
     335        value = V8Uint8Array::toNative(v8::Handle<v8::Object>::Cast(v8Value));
    345336    return true;
    346337}
     
    353344        return false;
    354345
    355     MediaKeyError* source = 0;
    356     if (v8Value->IsObject()) {
    357         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
    358         v8::Handle<v8::Object> error = wrapper->FindInstanceInPrototypeChain(V8MediaKeyError::GetTemplate(m_isolate));
    359         if (!error.IsEmpty())
    360             source = V8MediaKeyError::toNative(error);
    361     }
    362     value = source;
     346    value = 0;
     347    if (V8MediaKeyError::HasInstance(v8Value))
     348        value = V8MediaKeyError::toNative(v8::Handle<v8::Object>::Cast(v8Value));
    363349    return true;
    364350}
     
    394380        return false;
    395381
    396     SpeechRecognitionError* source = 0;
    397     if (v8Value->IsObject()) {
    398         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
    399         v8::Handle<v8::Object> speechRecognitionError = wrapper->FindInstanceInPrototypeChain(V8SpeechRecognitionError::GetTemplate(m_isolate));
    400         if (!speechRecognitionError.IsEmpty())
    401             source = V8SpeechRecognitionError::toNative(speechRecognitionError);
    402     }
    403     value = source;
     382    value = 0;
     383    if (V8SpeechRecognitionError::HasInstance(v8Value))
     384        value = V8SpeechRecognitionError::toNative(v8::Handle<v8::Object>::Cast(v8Value));
    404385    return true;
    405386}
     
    411392        return false;
    412393
    413     SpeechRecognitionResult* source = 0;
    414     if (v8Value->IsObject()) {
    415         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
    416         v8::Handle<v8::Object> speechRecognitionResult = wrapper->FindInstanceInPrototypeChain(V8SpeechRecognitionResult::GetTemplate(m_isolate));
    417         if (!speechRecognitionResult.IsEmpty())
    418             source = V8SpeechRecognitionResult::toNative(speechRecognitionResult);
    419     }
    420     value = source;
     394    value = 0;
     395    if (V8SpeechRecognitionResult::HasInstance(v8Value))
     396        value = V8SpeechRecognitionResult::toNative(v8::Handle<v8::Object>::Cast(v8Value));
    421397    return true;
    422398}
     
    428404        return false;
    429405
    430     SpeechRecognitionResultList* source = 0;
    431     if (v8Value->IsObject()) {
    432         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
    433         v8::Handle<v8::Object> speechRecognitionResultList = wrapper->FindInstanceInPrototypeChain(V8SpeechRecognitionResultList::GetTemplate(m_isolate));
    434         if (!speechRecognitionResultList.IsEmpty())
    435             source = V8SpeechRecognitionResultList::toNative(speechRecognitionResultList);
    436     }
    437     value = source;
     406    value = 0;
     407    if (V8SpeechRecognitionResultList::HasInstance(v8Value))
     408        value = V8SpeechRecognitionResultList::toNative(v8::Handle<v8::Object>::Cast(v8Value));
    438409    return true;
    439410}
     
    448419        return false;
    449420
    450     MediaStream* stream = 0;
    451     if (v8Value->IsObject()) {
    452         v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
    453         v8::Handle<v8::Object> error = wrapper->FindInstanceInPrototypeChain(V8MediaStream::GetTemplate(m_isolate));
    454         if (!error.IsEmpty())
    455             stream = V8MediaStream::toNative(error);
    456     }
    457     value = stream;
     421    value = 0;
     422    if (V8MediaStream::HasInstance(v8Value))
     423        value = V8MediaStream::toNative(v8::Handle<v8::Object>::Cast(v8Value));
    458424    return true;
    459425}
     
    466432        return false;
    467433
    468     EventTarget* target = 0;
    469     // We need to handle a DOMWindow specially, because a wrapper object of a DOMWindow
     434    value = 0;
     435    // We need to handle a DOMWindow specially, because a DOMWindow wrapper
    470436    // exists on a prototype chain of v8Value.
    471437    if (v8Value->IsObject()) {
     
    480446    if (V8DOMWrapper::isDOMWrapper(v8Value)) {
    481447        v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
    482         target = toWrapperTypeInfo(wrapper)->toEventTarget(wrapper);
    483     }
    484     value = target;
     448        value = toWrapperTypeInfo(wrapper)->toEventTarget(wrapper);
     449    }
    485450    return true;
    486451}
Note: See TracChangeset for help on using the changeset viewer.