V8DocumentLocationCustom.cpp [plain text]
#include "config.h"
#include "V8Document.h"
#include "DOMWindow.h"
#include "Frame.h"
#include "Location.h"
#include "V8Binding.h"
#include "V8BindingState.h"
#include "V8Location.h"
#include "V8Proxy.h"
namespace WebCore {
v8::Handle<v8::Value> V8Document::locationAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
Document* document = V8Document::toNative(info.Holder());
if (!document->frame())
return v8::Null();
DOMWindow* window = document->frame()->domWindow();
return toV8(window->location(), info.GetIsolate());
}
void V8Document::locationAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
Document* document = V8Document::toNative(info.Holder());
if (!document->frame())
return;
State<V8Binding>* state = V8BindingState::Only();
DOMWindow* activeWindow = state->activeWindow();
if (!activeWindow)
return;
DOMWindow* firstWindow = state->firstWindow();
if (!firstWindow)
return;
DOMWindow* window = document->frame()->domWindow();
if (Location* location = window->location())
location->setHref(toWebCoreString(value), activeWindow, firstWindow);
}
}