/platform/external/webkit/WebCore/bindings/v8/custom/V8DocumentLocationCustom.cpp

https://github.com/aharish/totoro-gb-opensource-update2 · C++ · 56 lines · 25 code · 8 blank · 23 comment · 2 complexity · 24e12b4ba725affc911f61c740dd99f3 MD5 · raw file

  1. /*
  2. * Copyright (C) 2000 Harri Porten (porten@kde.org)
  3. * Copyright (C) 2001 Peter Kelly (pmk@post.com)
  4. * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
  5. * Copyright (C) 2006 James G. Speth (speth@end.com)
  6. * Copyright (C) 2006 Samuel Weinig (sam@webkit.org)
  7. * Copyright (C) 2007, 2008, 2009 Google Inc. All Rights Reserved.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2 of the License, or (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include "config.h"
  24. #include "V8Document.h"
  25. #include "DOMWindow.h"
  26. #include "Frame.h"
  27. #include "V8Binding.h"
  28. #include "V8Location.h"
  29. #include "V8Proxy.h"
  30. namespace WebCore {
  31. v8::Handle<v8::Value> V8Document::locationAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
  32. {
  33. Document* document = V8Document::toNative(info.Holder());
  34. if (!document->frame())
  35. return v8::Null();
  36. DOMWindow* window = document->frame()->domWindow();
  37. return toV8(window->location());
  38. }
  39. void V8Document::locationAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
  40. {
  41. Document* document = V8Document::toNative(info.Holder());
  42. if (!document->frame())
  43. return;
  44. DOMWindow* window = document->frame()->domWindow();
  45. // setLocation does security checks. // XXXMB- verify!
  46. V8DOMWindowShell::setLocation(window, toWebCoreString(value));
  47. }
  48. } // namespace WebCore