REGRESSION (r174985-174986): Site display disappears 
https://bugs.webkit.org/show_bug.cgi?id=138082

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

In support of the change in WebCore, this adds a new functor class to unwind to our
caller's frame possibly skipping of intermediate C++ frames.

* interpreter/StackVisitor.h:
(JSC::CallerFunctor::CallerFunctor):
(JSC::CallerFunctor::callerFrame):
(JSC::CallerFunctor::operator()):

Source/WebCore:

This effectively reverts to the behavior before r174985 by using the 
lexical global object of the caller's frame to find the active document.
Before r174985, native functions are invoked with the ScopeShain of their
caller.  The lexical global object is accessed from the ScopeChain.

* bindings/js/JSHTMLDocumentCustom.cpp:
(WebCore::JSHTMLDocument::getOwnPropertySlot):
(WebCore::findOwningDocument):
(WebCore::documentWrite):
(WebCore::JSHTMLDocument::write):
(WebCore::JSHTMLDocument::writeln):
* html/HTMLDocument.idl:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@175706 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/interpreter/StackVisitor.h b/Source/JavaScriptCore/interpreter/StackVisitor.h
index 3f229e7..c6e7fdf 100644
--- a/Source/JavaScriptCore/interpreter/StackVisitor.h
+++ b/Source/JavaScriptCore/interpreter/StackVisitor.h
@@ -150,6 +150,32 @@
     Frame m_frame;
 };
 
+class CallerFunctor {
+public:
+    CallerFunctor()
+        : m_hasSkippedFirstFrame(false)
+        , m_callerFrame(0)
+    {
+    }
+
+    CallFrame* callerFrame() const { return m_callerFrame; }
+
+    StackVisitor::Status operator()(StackVisitor& visitor)
+    {
+        if (!m_hasSkippedFirstFrame) {
+            m_hasSkippedFirstFrame = true;
+            return StackVisitor::Continue;
+        }
+
+        m_callerFrame = visitor->callFrame();
+        return StackVisitor::Done;
+    }
+    
+private:
+    bool m_hasSkippedFirstFrame;
+    CallFrame* m_callerFrame;
+};
+
 } // namespace JSC
 
 #endif // StackVisitor_h