summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/chromium/src/WebFrameImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/chromium/src/WebFrameImpl.cpp')
-rw-r--r--Source/WebKit/chromium/src/WebFrameImpl.cpp143
1 files changed, 121 insertions, 22 deletions
diff --git a/Source/WebKit/chromium/src/WebFrameImpl.cpp b/Source/WebKit/chromium/src/WebFrameImpl.cpp
index c86e715..c06087d 100644
--- a/Source/WebKit/chromium/src/WebFrameImpl.cpp
+++ b/Source/WebKit/chromium/src/WebFrameImpl.cpp
@@ -90,6 +90,7 @@
#include "FrameLoader.h"
#include "FrameTree.h"
#include "FrameView.h"
+#include "HitTestResult.h"
#include "HTMLCollection.h"
#include "HTMLFormElement.h"
#include "HTMLFrameOwnerElement.h"
@@ -106,6 +107,7 @@
#include "PluginDocument.h"
#include "PrintContext.h"
#include "RenderFrame.h"
+#include "RenderLayer.h"
#include "RenderObject.h"
#include "RenderTreeAsText.h"
#include "RenderView.h"
@@ -140,6 +142,7 @@
#include "WebPerformance.h"
#include "WebPlugin.h"
#include "WebPluginContainerImpl.h"
+#include "WebPoint.h"
#include "WebRange.h"
#include "WebRect.h"
#include "WebScriptSource.h"
@@ -158,6 +161,18 @@
#include <gdk/gdk.h>
#endif
+#if USE(V8)
+#include "AsyncFileSystem.h"
+#include "AsyncFileSystemChromium.h"
+#include "DirectoryEntry.h"
+#include "DOMFileSystem.h"
+#include "FileEntry.h"
+#include "V8DirectoryEntry.h"
+#include "V8DOMFileSystem.h"
+#include "V8FileEntry.h"
+#include "WebFileSystem.h"
+#endif
+
using namespace WebCore;
namespace WebKit {
@@ -358,7 +373,7 @@ public:
{
}
- virtual void begin(float width)
+ virtual void begin(float width, float height)
{
}
@@ -466,6 +481,13 @@ WebFrame* WebFrame::frameForCurrentContext()
return WebFrameImpl::fromFrame(frame);
}
+#if WEBKIT_USING_V8
+WebFrame* WebFrame::frameForContext(v8::Handle<v8::Context> context)
+{
+ return WebFrameImpl::fromFrame(V8Proxy::retrieveFrame(context));
+}
+#endif
+
WebFrame* WebFrame::fromFrameOwnerElement(const WebElement& element)
{
return WebFrameImpl::fromFrameOwnerElement(
@@ -544,6 +566,12 @@ WebSize WebFrameImpl::scrollOffset() const
return WebSize();
}
+void WebFrameImpl::setScrollOffset(const WebSize& offset)
+{
+ if (FrameView* view = frameView())
+ view->setScrollOffset(IntPoint(offset.width, offset.height));
+}
+
WebSize WebFrameImpl::contentsSize() const
{
return frame()->view()->contentsSize();
@@ -573,6 +601,11 @@ WebView* WebFrameImpl::view() const
return viewImpl();
}
+void WebFrameImpl::clearOpener()
+{
+ m_frame->loader()->setOpener(0);
+}
+
WebFrame* WebFrameImpl::opener() const
{
Frame* opener = 0;
@@ -822,6 +855,25 @@ v8::Local<v8::Context> WebFrameImpl::mainWorldScriptContext() const
return V8Proxy::mainWorldContext(m_frame);
}
+
+v8::Handle<v8::Value> WebFrameImpl::createFileSystem(WebFileSystem::Type type,
+ const WebString& name,
+ const WebString& path)
+{
+ return toV8(DOMFileSystem::create(frame()->document(), name, AsyncFileSystemChromium::create(static_cast<AsyncFileSystem::Type>(type), path)));
+}
+
+v8::Handle<v8::Value> WebFrameImpl::createFileEntry(WebFileSystem::Type type,
+ const WebString& fileSystemName,
+ const WebString& fileSystemPath,
+ const WebString& filePath,
+ bool isDirectory)
+{
+ RefPtr<DOMFileSystemBase> fileSystem = DOMFileSystem::create(frame()->document(), fileSystemName, AsyncFileSystemChromium::create(static_cast<AsyncFileSystem::Type>(type), fileSystemPath));
+ if (isDirectory)
+ return toV8(DirectoryEntry::create(fileSystem, filePath));
+ return toV8(FileEntry::create(fileSystem, filePath));
+}
#endif
bool WebFrameImpl::insertStyleText(
@@ -892,8 +944,8 @@ void WebFrameImpl::loadHistoryItem(const WebHistoryItem& item)
m_frame->page()->backForward()->setCurrentItem(currentItem.get());
}
- m_frame->loader()->history()->goToItem(
- historyItem.get(), FrameLoadTypeIndexedBackForward);
+ m_frame->page()->goToItem(historyItem.get(),
+ FrameLoadTypeIndexedBackForward);
}
void WebFrameImpl::loadData(const WebData& data,
@@ -1027,11 +1079,17 @@ void WebFrameImpl::dispatchWillSendRequest(WebURLRequest& request)
0, 0, request.toMutableResourceRequest(), response);
}
+// FIXME: Remove this overload when clients have been changed to pass options.
WebURLLoader* WebFrameImpl::createAssociatedURLLoader()
{
return new AssociatedURLLoader(this);
}
+WebURLLoader* WebFrameImpl::createAssociatedURLLoader(const WebURLLoaderOptions& options)
+{
+ return new AssociatedURLLoader(this, options);
+}
+
void WebFrameImpl::commitDocumentData(const char* data, size_t length)
{
m_frame->loader()->documentLoader()->commitData(data, length);
@@ -1057,7 +1115,7 @@ void WebFrameImpl::replaceSelection(const WebString& text)
RefPtr<DocumentFragment> fragment = createFragmentFromText(
frame()->selection()->toNormalizedRange().get(), text);
applyCommand(ReplaceSelectionCommand::create(
- frame()->document(), fragment.get(), false, true, true));
+ frame()->document(), fragment.get(), ReplaceSelectionCommand::SmartReplace | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting));
}
void WebFrameImpl::insertText(const WebString& text)
@@ -1274,6 +1332,39 @@ bool WebFrameImpl::selectWordAroundCaret()
return true;
}
+void WebFrameImpl::selectRange(const WebPoint& start, const WebPoint& end)
+{
+ VisibleSelection selection(visiblePositionForWindowPoint(start),
+ visiblePositionForWindowPoint(end));
+
+ if (frame()->selection()->shouldChangeSelection(selection))
+ frame()->selection()->setSelection(selection, CharacterGranularity,
+ MakeNonDirectionalSelection);
+}
+
+VisiblePosition WebFrameImpl::visiblePositionForWindowPoint(const WebPoint& point)
+{
+ HitTestRequest::HitTestRequestType hitType = HitTestRequest::MouseMove;
+ hitType |= HitTestRequest::ReadOnly;
+ hitType |= HitTestRequest::Active;
+ HitTestRequest request(hitType);
+ FrameView* view = frame()->view();
+ HitTestResult result(view->windowToContents(
+ view->convertFromContainingWindow(IntPoint(point.x, point.y))));
+
+ frame()->document()->renderView()->layer()->hitTest(request, result);
+
+ // Matching the logic in MouseEventWithHitTestResults::targetNode()
+ Node* node = result.innerNode();
+ if (!node)
+ return VisiblePosition();
+ Element* element = node->parentElement();
+ if (!node->inDocument() && element && element->inDocument())
+ node = element;
+
+ return node->renderer()->positionForPoint(result.localPoint());
+}
+
int WebFrameImpl::printBegin(const WebSize& pageSize,
const WebNode& constrainToNode,
int printerDPI,
@@ -1335,7 +1426,13 @@ float WebFrameImpl::printPage(int page, WebCanvas* canvas)
return 0;
}
- return m_printContext->spoolPage(GraphicsContextBuilder(canvas).context(), page);
+ GraphicsContextBuilder builder(canvas);
+ GraphicsContext& gc = builder.context();
+#if WEBKIT_USING_SKIA
+ gc.platformContext()->setPrinting(true);
+#endif
+
+ return m_printContext->spoolPage(gc, page);
}
void WebFrameImpl::printEnd()
@@ -1451,12 +1548,8 @@ bool WebFrameImpl::find(int identifier,
m_activeMatchIndex = m_lastMatchCount - 1;
}
if (selectionRect) {
- WebRect rect = frame()->view()->convertToContainingWindow(currSelectionRect);
- rect.x -= frameView()->scrollOffset().width();
- rect.y -= frameView()->scrollOffset().height();
- *selectionRect = rect;
-
- reportFindInPageSelection(rect, m_activeMatchIndex + 1, identifier);
+ *selectionRect = frameView()->contentsToWindow(currSelectionRect);
+ reportFindInPageSelection(*selectionRect, m_activeMatchIndex + 1, identifier);
}
}
} else {
@@ -1553,8 +1646,7 @@ void WebFrameImpl::scopeStringMatches(int identifier,
// find an alternative.
RefPtr<Range> resultRange(findPlainText(searchRange.get(),
searchText,
- true,
- options.matchCase));
+ options.matchCase ? 0 : CaseInsensitive));
if (resultRange->collapsed(ec)) {
if (!resultRange->startContainer()->isInShadowTree())
break;
@@ -1594,10 +1686,8 @@ void WebFrameImpl::scopeStringMatches(int identifier,
m_locatingActiveRect = false;
// Notify browser of new location for the selected rectangle.
- resultBounds.move(-frameView()->scrollOffset().width(),
- -frameView()->scrollOffset().height());
reportFindInPageSelection(
- frame()->view()->convertToContainingWindow(resultBounds),
+ frameView()->contentsToWindow(resultBounds),
m_activeMatchIndex + 1,
identifier);
}
@@ -1712,9 +1802,18 @@ WebString WebFrameImpl::contentAsMarkup() const
return createFullMarkup(m_frame->document());
}
-WebString WebFrameImpl::renderTreeAsText() const
+WebString WebFrameImpl::renderTreeAsText(bool showDebugInfo) const
{
- return externalRepresentation(m_frame);
+ RenderAsTextBehavior behavior = RenderAsTextBehaviorNormal;
+
+ if (showDebugInfo) {
+ behavior |= RenderAsTextShowCompositedLayers
+ | RenderAsTextShowAddresses
+ | RenderAsTextShowIDAndClass
+ | RenderAsTextShowLayerNesting;
+ }
+
+ return externalRepresentation(m_frame, behavior);
}
WebString WebFrameImpl::counterValueForElementById(const WebString& id) const
@@ -1761,7 +1860,7 @@ bool WebFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length) cons
{
if (!m_frame)
return false;
- return m_frame->editor()->selectionStartHasSpellingMarkerFor(from, length);
+ return m_frame->editor()->selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length);
}
bool WebFrameImpl::pauseSVGAnimation(const WebString& animationId, double time, const WebString& elementId)
@@ -1784,11 +1883,11 @@ bool WebFrameImpl::pauseSVGAnimation(const WebString& animationId, double time,
#endif
}
-WebString WebFrameImpl::layerTreeAsText() const
+WebString WebFrameImpl::layerTreeAsText(bool showDebugInfo) const
{
if (!m_frame)
return WebString();
- return WebString(m_frame->layerTreeAsText());
+ return WebString(m_frame->layerTreeAsText(showDebugInfo));
}
// WebFrameImpl public ---------------------------------------------------------
@@ -1952,7 +2051,7 @@ void WebFrameImpl::createFrameView()
view->setParentVisible(true);
}
-WebFrameImpl* WebFrameImpl::fromFrame(const Frame* frame)
+WebFrameImpl* WebFrameImpl::fromFrame(Frame* frame)
{
if (!frame)
return 0;