| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 const AtomicString& IDBRequest::interfaceName() const | 404 const AtomicString& IDBRequest::interfaceName() const |
| 405 { | 405 { |
| 406 return EventTargetNames::IDBRequest; | 406 return EventTargetNames::IDBRequest; |
| 407 } | 407 } |
| 408 | 408 |
| 409 ExecutionContext* IDBRequest::executionContext() const | 409 ExecutionContext* IDBRequest::executionContext() const |
| 410 { | 410 { |
| 411 return ActiveDOMObject::executionContext(); | 411 return ActiveDOMObject::executionContext(); |
| 412 } | 412 } |
| 413 | 413 |
| 414 bool IDBRequest::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> event) | 414 WebInputEventResult IDBRequest::dispatchEventInternal(PassRefPtrWillBeRawPtr<Eve
nt> event) |
| 415 { | 415 { |
| 416 IDB_TRACE("IDBRequest::dispatchEvent"); | 416 IDB_TRACE("IDBRequest::dispatchEvent"); |
| 417 if (m_contextStopped || !executionContext()) | 417 if (m_contextStopped || !executionContext()) |
| 418 return false; | 418 return WebInputEventResult::HandledSuppressed; |
| 419 ASSERT(m_readyState == PENDING); | 419 ASSERT(m_readyState == PENDING); |
| 420 ASSERT(m_hasPendingActivity); | 420 ASSERT(m_hasPendingActivity); |
| 421 ASSERT(m_enqueuedEvents.size()); | 421 ASSERT(m_enqueuedEvents.size()); |
| 422 ASSERT(event->target() == this); | 422 ASSERT(event->target() == this); |
| 423 | 423 |
| 424 ScriptState::Scope scope(m_scriptState.get()); | 424 ScriptState::Scope scope(m_scriptState.get()); |
| 425 | 425 |
| 426 if (event->type() != EventTypeNames::blocked) | 426 if (event->type() != EventTypeNames::blocked) |
| 427 m_readyState = DONE; | 427 m_readyState = DONE; |
| 428 dequeueEvent(event.get()); | 428 dequeueEvent(event.get()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 451 m_didFireUpgradeNeededEvent = true; | 451 m_didFireUpgradeNeededEvent = true; |
| 452 } | 452 } |
| 453 | 453 |
| 454 // FIXME: When we allow custom event dispatching, this will probably need to
change. | 454 // FIXME: When we allow custom event dispatching, this will probably need to
change. |
| 455 ASSERT_WITH_MESSAGE(event->type() == EventTypeNames::success || event->type(
) == EventTypeNames::error || event->type() == EventTypeNames::blocked || event-
>type() == EventTypeNames::upgradeneeded, "event type was %s", event->type().utf
8().data()); | 455 ASSERT_WITH_MESSAGE(event->type() == EventTypeNames::success || event->type(
) == EventTypeNames::error || event->type() == EventTypeNames::blocked || event-
>type() == EventTypeNames::upgradeneeded, "event type was %s", event->type().utf
8().data()); |
| 456 const bool setTransactionActive = m_transaction && (event->type() == EventTy
peNames::success || event->type() == EventTypeNames::upgradeneeded || (event->ty
pe() == EventTypeNames::error && !m_requestAborted)); | 456 const bool setTransactionActive = m_transaction && (event->type() == EventTy
peNames::success || event->type() == EventTypeNames::upgradeneeded || (event->ty
pe() == EventTypeNames::error && !m_requestAborted)); |
| 457 | 457 |
| 458 if (setTransactionActive) | 458 if (setTransactionActive) |
| 459 m_transaction->setActive(true); | 459 m_transaction->setActive(true); |
| 460 | 460 |
| 461 bool dontPreventDefault = IDBEventDispatcher::dispatch(event.get(), targets)
; | 461 WebInputEventResult eventResult = IDBEventDispatcher::dispatch(event.get(),
targets); |
| 462 | 462 |
| 463 if (m_transaction) { | 463 if (m_transaction) { |
| 464 if (m_readyState == DONE) | 464 if (m_readyState == DONE) |
| 465 m_transaction->unregisterRequest(this); | 465 m_transaction->unregisterRequest(this); |
| 466 | 466 |
| 467 // Possibly abort the transaction. This must occur after unregistering (
so this request | 467 // Possibly abort the transaction. This must occur after unregistering (
so this request |
| 468 // doesn't receive a second error) and before deactivating (which might
trigger commit). | 468 // doesn't receive a second error) and before deactivating (which might
trigger commit). |
| 469 if (event->type() == EventTypeNames::error && dontPreventDefault && !m_r
equestAborted) { | 469 if (event->type() == EventTypeNames::error && eventResult == WebInputEve
ntResult::NotHandled && !m_requestAborted) { |
| 470 m_transaction->setError(m_error); | 470 m_transaction->setError(m_error); |
| 471 m_transaction->abort(IGNORE_EXCEPTION); | 471 m_transaction->abort(IGNORE_EXCEPTION); |
| 472 } | 472 } |
| 473 | 473 |
| 474 // If this was the last request in the transaction's list, it may commit
here. | 474 // If this was the last request in the transaction's list, it may commit
here. |
| 475 if (setTransactionActive) | 475 if (setTransactionActive) |
| 476 m_transaction->setActive(false); | 476 m_transaction->setActive(false); |
| 477 } | 477 } |
| 478 | 478 |
| 479 if (cursorToNotify) | 479 if (cursorToNotify) |
| 480 cursorToNotify->postSuccessHandlerCallback(); | 480 cursorToNotify->postSuccessHandlerCallback(); |
| 481 | 481 |
| 482 // An upgradeneeded event will always be followed by a success or error even
t, so must | 482 // An upgradeneeded event will always be followed by a success or error even
t, so must |
| 483 // be kept alive. | 483 // be kept alive. |
| 484 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) | 484 if (m_readyState == DONE && event->type() != EventTypeNames::upgradeneeded) |
| 485 m_hasPendingActivity = false; | 485 m_hasPendingActivity = false; |
| 486 | 486 |
| 487 return dontPreventDefault; | 487 return eventResult; |
| 488 } | 488 } |
| 489 | 489 |
| 490 void IDBRequest::uncaughtExceptionInEventHandler() | 490 void IDBRequest::uncaughtExceptionInEventHandler() |
| 491 { | 491 { |
| 492 if (m_transaction && !m_requestAborted) { | 492 if (m_transaction && !m_requestAborted) { |
| 493 m_transaction->setError(DOMException::create(AbortError, "Uncaught excep
tion in event handler.")); | 493 m_transaction->setError(DOMException::create(AbortError, "Uncaught excep
tion in event handler.")); |
| 494 m_transaction->abort(IGNORE_EXCEPTION); | 494 m_transaction->abort(IGNORE_EXCEPTION); |
| 495 } | 495 } |
| 496 } | 496 } |
| 497 | 497 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 | 531 |
| 532 void IDBRequest::dequeueEvent(Event* event) | 532 void IDBRequest::dequeueEvent(Event* event) |
| 533 { | 533 { |
| 534 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { | 534 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { |
| 535 if (m_enqueuedEvents[i].get() == event) | 535 if (m_enqueuedEvents[i].get() == event) |
| 536 m_enqueuedEvents.remove(i); | 536 m_enqueuedEvents.remove(i); |
| 537 } | 537 } |
| 538 } | 538 } |
| 539 | 539 |
| 540 } // namespace blink | 540 } // namespace blink |
| OLD | NEW |