OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 ASSERT(m_world->isMainWorld()); | 471 ASSERT(m_world->isMainWorld()); |
472 if (!isGlobalInitialized()) | 472 if (!isGlobalInitialized()) |
473 return; | 473 return; |
474 if (!isContextInitialized()) | 474 if (!isContextInitialized()) |
475 return; | 475 return; |
476 updateActivityLogger(); | 476 updateActivityLogger(); |
477 updateDocumentProperty(); | 477 updateDocumentProperty(); |
478 updateSecurityOrigin(m_frame->securityContext()->getSecurityOrigin()); | 478 updateSecurityOrigin(m_frame->securityContext()->getSecurityOrigin()); |
479 } | 479 } |
480 | 480 |
481 static v8::Local<v8::Value> getNamedProperty(HTMLDocument* htmlDocument, const A tomicString& key, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) | |
482 { | |
483 if (!htmlDocument->hasNamedItem(key) && !htmlDocument->hasExtraNamedItem(key )) | |
484 return v8Undefined(); | |
485 | |
486 DocumentNameCollection* items = htmlDocument->documentNamedItems(key); | |
487 if (items->isEmpty()) | |
488 return v8Undefined(); | |
489 | |
490 if (items->hasExactlyOneItem()) { | |
491 HTMLElement* element = items->item(0); | |
492 ASSERT(element); | |
493 Frame* frame = isHTMLIFrameElement(*element) ? toHTMLIFrameElement(*elem ent).contentFrame() : 0; | |
494 if (frame) | |
495 return toV8(frame->domWindow(), creationContext, isolate); | |
496 return toV8(element, creationContext, isolate); | |
497 } | |
498 return toV8(items, creationContext, isolate); | |
499 } | |
500 | |
501 static void getter(v8::Local<v8::Name> property, const v8::PropertyCallbackInfo< v8::Value>& info) | |
502 { | |
503 if (!property->IsString()) | |
504 return; | |
505 // FIXME: Consider passing StringImpl directly. | |
506 AtomicString name = toCoreAtomicString(property.As<v8::String>()); | |
507 HTMLDocument* htmlDocument = V8HTMLDocument::toImpl(info.Holder()); | |
508 ASSERT(htmlDocument); | |
509 v8::Local<v8::Value> result = getNamedProperty(htmlDocument, name, info.Hold er(), info.GetIsolate()); | |
510 if (!result.IsEmpty()) { | |
511 v8SetReturnValue(info, result); | |
512 return; | |
513 } | |
514 v8::Local<v8::Value> prototype = info.Holder()->GetPrototype(); | |
515 if (prototype->IsObject()) { | |
haraken
2016/05/23 21:50:16
Would you help me understand why you can remove th
peria
2016/05/24 07:00:12
This routine was to emulate named properties using
| |
516 v8::Local<v8::Value> value; | |
517 if (prototype.As<v8::Object>()->Get(info.GetIsolate()->GetCurrentContext (), property).ToLocal(&value)) | |
518 v8SetReturnValue(info, value); | |
519 } | |
520 } | |
521 | |
522 void WindowProxy::namedItemAdded(HTMLDocument* document, const AtomicString& nam e) | |
523 { | |
524 ASSERT(m_world->isMainWorld()); | |
525 | |
526 if (!isContextInitialized() || !m_scriptState->contextIsValid()) | |
527 return; | |
528 | |
529 ScriptState::Scope scope(m_scriptState.get()); | |
530 ASSERT(!m_document.isEmpty()); | |
531 v8::Local<v8::Context> context = m_scriptState->context(); | |
532 v8::Local<v8::Object> documentHandle = m_document.newLocal(m_isolate); | |
533 checkDocumentWrapper(documentHandle, document); | |
534 documentHandle->SetAccessor(context, v8String(m_isolate, name), getter); | |
535 } | |
536 | |
537 void WindowProxy::namedItemRemoved(HTMLDocument* document, const AtomicString& n ame) | |
538 { | |
539 ASSERT(m_world->isMainWorld()); | |
540 | |
541 if (!isContextInitialized()) | |
542 return; | |
543 | |
544 if (document->hasNamedItem(name) || document->hasExtraNamedItem(name)) | |
545 return; | |
546 | |
547 ScriptState::Scope scope(m_scriptState.get()); | |
548 ASSERT(!m_document.isEmpty()); | |
549 v8::Local<v8::Object> documentHandle = m_document.newLocal(m_isolate); | |
550 checkDocumentWrapper(documentHandle, document); | |
551 documentHandle->Delete(m_isolate->GetCurrentContext(), v8String(m_isolate, n ame)); | |
552 } | |
553 | |
554 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) | 481 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) |
555 { | 482 { |
556 if (!isContextInitialized()) | 483 if (!isContextInitialized()) |
557 return; | 484 return; |
558 setSecurityToken(origin); | 485 setSecurityToken(origin); |
559 } | 486 } |
560 | 487 |
561 } // namespace blink | 488 } // namespace blink |
OLD | NEW |