#include "bindings/v8/ScriptSourceCode.h"
#include "bindings/v8/ScriptValue.h"
#include "bindings/v8/V8GCController.h"
+#include "bindings/v8/V8PerIsolateData.h"
#include "core/dom/Document.h"
#include "core/dom/DocumentMarker.h"
#include "core/dom/DocumentMarkerController.h"
graphicsContext.setFillColor(Color::white);
graphicsContext.fillRect(FloatRect(0, 0, pageWidth, totalHeight));
- graphicsContext.save();
-
int currentHeight = 0;
for (size_t pageIndex = 0; pageIndex < numPages; pageIndex++) {
// Draw a line for a page boundary if this isn't the first page.
currentHeight += pageSizeInPixels.height() + 1;
}
-
- graphicsContext.restore();
}
virtual void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight)
return WebVector<WebIconURL>();
}
+void WebFrameImpl::setIsRemote(bool isRemote)
+{
+ m_isRemote = isRemote;
+ if (isRemote)
+ client()->initializeChildFrame(frame()->view()->frameRect(), frame()->view()->visibleContentScaleFactor());
+}
+
void WebFrameImpl::setRemoteWebLayer(WebLayer* webLayer)
{
if (!frame())
frame()->loader().setOpener(webFrame ? toWebFrameImpl(webFrame)->frame() : 0);
}
+void WebFrameImpl::appendChild(WebFrame* child)
+{
+ // FIXME: Original code asserts that the frames have the same Page. We
+ // should add an equivalent check... figure out what.
+ WebFrameImpl* childImpl = toWebFrameImpl(child);
+ childImpl->m_parent = this;
+ WebFrameImpl* oldLast = m_lastChild;
+ m_lastChild = childImpl;
+
+ if (oldLast) {
+ childImpl->m_previousSibling = oldLast;
+ oldLast->m_nextSibling = childImpl;
+ } else {
+ m_firstChild = childImpl;
+ }
+ // FIXME: Not sure if this is a legitimate assert.
+ ASSERT(frame());
+ frame()->tree().invalidateScopedChildCount();
+}
+
+void WebFrameImpl::removeChild(WebFrame* child)
+{
+ WebFrameImpl* childImpl = toWebFrameImpl(child);
+ childImpl->m_parent = 0;
+
+ if (m_firstChild == childImpl)
+ m_firstChild = childImpl->m_nextSibling;
+ else
+ childImpl->m_previousSibling->m_nextSibling = childImpl->m_nextSibling;
+
+ if (m_lastChild == childImpl)
+ m_lastChild = childImpl->m_previousSibling;
+ else
+ childImpl->m_nextSibling->m_previousSibling = childImpl->m_previousSibling;
+
+ childImpl->m_previousSibling = childImpl->m_nextSibling = 0;
+ // FIXME: Not sure if this is a legitimate assert.
+ ASSERT(frame());
+ frame()->tree().invalidateScopedChildCount();
+}
+
WebFrame* WebFrameImpl::parent() const
{
- if (!frame())
- return 0;
- return fromFrame(frame()->tree().parent());
+ return m_parent;
}
WebFrame* WebFrameImpl::top() const
{
- if (!frame())
- return 0;
- return fromFrame(frame()->tree().top());
+ WebFrameImpl* frame = const_cast<WebFrameImpl*>(this);
+ for (WebFrameImpl* parent = frame; parent; parent = parent->m_parent)
+ frame = parent;
+ return frame;
}
-WebFrame* WebFrameImpl::firstChild() const
+WebFrame* WebFrameImpl::previousSibling() const
{
- if (!frame())
- return 0;
- return fromFrame(frame()->tree().firstChild());
+ return m_previousSibling;
}
-WebFrame* WebFrameImpl::lastChild() const
+WebFrame* WebFrameImpl::nextSibling() const
{
- if (!frame())
- return 0;
- return fromFrame(frame()->tree().lastChild());
+ return m_nextSibling;
}
-WebFrame* WebFrameImpl::nextSibling() const
+WebFrame* WebFrameImpl::firstChild() const
{
- if (!frame())
- return 0;
- return fromFrame(frame()->tree().nextSibling());
+ return m_firstChild;
}
-WebFrame* WebFrameImpl::previousSibling() const
+WebFrame* WebFrameImpl::lastChild() const
{
- if (!frame())
- return 0;
- return fromFrame(frame()->tree().previousSibling());
+ return m_lastChild;
}
-WebFrame* WebFrameImpl::traverseNext(bool wrap) const
+WebFrame* WebFrameImpl::traversePrevious(bool wrap) const
{
if (!frame())
return 0;
- return fromFrame(frame()->tree().traverseNextWithWrap(wrap));
+ return fromFrame(frame()->tree().traversePreviousWithWrap(wrap));
}
-WebFrame* WebFrameImpl::traversePrevious(bool wrap) const
+WebFrame* WebFrameImpl::traverseNext(bool wrap) const
{
if (!frame())
return 0;
- return fromFrame(frame()->tree().traversePreviousWithWrap(wrap));
+ return fromFrame(frame()->tree().traverseNextWithWrap(wrap));
}
WebFrame* WebFrameImpl::findChildByName(const WebString& name) const
{
if (!frame())
return;
- if (!frame()->settings()->isScriptEnabled())
+ if (!frame()->settings()->scriptEnabled())
return;
V8GCController::collectGarbage(v8::Isolate::GetCurrent());
}
v8::Local<v8::Context> WebFrameImpl::mainWorldScriptContext() const
{
- if (!frame())
- return v8::Local<v8::Context>();
- return ScriptController::mainWorldContext(frame());
+ return toV8Context(V8PerIsolateData::mainThreadIsolate(), frame(), DOMWrapperWorld::mainWorld());
}
v8::Handle<v8::Value> WebFrameImpl::createFileSystem(WebFileSystemType type, const WebString& name, const WebString& path)
// We're shutting down.
if (!frame()->loader().documentLoader())
return WebHistoryItem();
-
- // If we are still loading, then we don't want to clobber the current
- // history item as this could cause us to lose the scroll position and
- // document state. However, it is OK for new navigations.
- // FIXME: Can we make this a plain old getter, instead of worrying about
- // clobbering here?
- if (frame()->loader().loadType() == FrameLoadTypeStandard || !frame()->loader().documentLoader()->isLoadingInAPISense())
- frame()->loader().saveDocumentAndScrollState();
-
return WebHistoryItem(frame()->page()->historyController().currentItemForExport());
}
referrer = SecurityPolicy::generateReferrerHeader(frame()->document()->referrerPolicy(), request.url(), referrer);
if (referrer.isEmpty())
return;
- request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer);
+ request.setHTTPReferrer(referrer, static_cast<WebReferrerPolicy>(frame()->document()->referrerPolicy()));
}
void WebFrameImpl::dispatchWillSendRequest(WebURLRequest& request)
WebFrameImpl::WebFrameImpl(WebFrameClient* client, long long embedderIdentifier)
: m_frameInit(WebFrameInit::create(this, embedderIdentifier))
+ , m_parent(0)
+ , m_previousSibling(0)
+ , m_nextSibling(0)
+ , m_firstChild(0)
+ , m_lastChild(0)
, m_client(client)
, m_permissionClient(0)
, m_currentActiveMatchFrame(0)
childFrame->tree().setName(request.frameName());
- frame()->tree().appendChild(childFrame);
-
+ // FIXME: This comment is not quite accurate anymore.
// Frame::init() can trigger onload event in the parent frame,
// which may detach this frame and trigger a null-pointer access
// in FrameTree::removeChild. Move init() after appendChild call