summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/page
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-13 16:23:25 +0100
committerBen Murdoch <benm@google.com>2011-05-16 11:35:02 +0100
commit65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch)
treef478babb801e720de7bfaee23443ffe029f58731 /Source/WebCore/page
parent47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff)
downloadexternal_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebCore/page')
-rw-r--r--Source/WebCore/page/Chrome.cpp7
-rw-r--r--Source/WebCore/page/ChromeClient.h2
-rw-r--r--Source/WebCore/page/Console.cpp140
-rw-r--r--Source/WebCore/page/Console.h3
-rw-r--r--Source/WebCore/page/Console.idl4
-rw-r--r--Source/WebCore/page/ContextMenuController.cpp5
-rw-r--r--Source/WebCore/page/DOMWindow.cpp44
-rw-r--r--Source/WebCore/page/DOMWindow.h9
-rw-r--r--Source/WebCore/page/DOMWindow.idl5
-rw-r--r--Source/WebCore/page/DragController.cpp30
-rw-r--r--Source/WebCore/page/DragController.h4
-rw-r--r--Source/WebCore/page/EditorClient.h2
-rw-r--r--Source/WebCore/page/EventHandler.cpp20
-rw-r--r--Source/WebCore/page/Frame.cpp16
-rw-r--r--Source/WebCore/page/Frame.h5
-rw-r--r--Source/WebCore/page/FrameView.cpp49
-rw-r--r--Source/WebCore/page/FrameView.h1
-rw-r--r--Source/WebCore/page/GeolocationController.cpp6
-rw-r--r--Source/WebCore/page/Page.cpp19
-rw-r--r--Source/WebCore/page/PerformanceTiming.cpp2
-rw-r--r--Source/WebCore/page/PerformanceTiming.h2
-rw-r--r--Source/WebCore/page/PerformanceTiming.idl2
-rw-r--r--Source/WebCore/page/PrintContext.cpp86
-rw-r--r--Source/WebCore/page/PrintContext.h31
-rw-r--r--Source/WebCore/page/SecurityOrigin.cpp27
-rw-r--r--Source/WebCore/page/SecurityOrigin.h6
-rw-r--r--Source/WebCore/page/android/DragControllerAndroid.cpp2
-rw-r--r--Source/WebCore/page/animation/KeyframeAnimation.cpp4
-rw-r--r--Source/WebCore/page/brew/DragControllerBrew.cpp2
-rw-r--r--Source/WebCore/page/chromium/DragControllerChromium.cpp4
-rw-r--r--Source/WebCore/page/chromium/FrameChromium.cpp1
-rw-r--r--Source/WebCore/page/efl/DragControllerEfl.cpp4
-rw-r--r--Source/WebCore/page/gtk/DragControllerGtk.cpp4
-rw-r--r--Source/WebCore/page/haiku/DragControllerHaiku.cpp2
-rw-r--r--Source/WebCore/page/mac/DragControllerMac.mm10
-rw-r--r--Source/WebCore/page/mac/FrameMac.mm41
-rw-r--r--Source/WebCore/page/qt/DragControllerQt.cpp4
-rw-r--r--Source/WebCore/page/qt/FrameQt.cpp1
-rw-r--r--Source/WebCore/page/win/DragControllerWin.cpp4
-rw-r--r--Source/WebCore/page/wx/DragControllerWx.cpp2
40 files changed, 261 insertions, 351 deletions
diff --git a/Source/WebCore/page/Chrome.cpp b/Source/WebCore/page/Chrome.cpp
index a801065..0405408 100644
--- a/Source/WebCore/page/Chrome.cpp
+++ b/Source/WebCore/page/Chrome.cpp
@@ -33,7 +33,7 @@
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HitTestResult.h"
-#include "InspectorController.h"
+#include "InspectorInstrumentation.h"
#include "Page.h"
#include "PageGroupLoadDeferrer.h"
#include "RenderObject.h"
@@ -344,10 +344,7 @@ void Chrome::mouseDidMoveOverElement(const HitTestResult& result, unsigned modif
}
m_client->mouseDidMoveOverElement(result, modifierFlags);
-#if ENABLE(INSPECTOR)
- if (InspectorController* inspector = m_page->inspectorController())
- inspector->mouseDidMoveOverElement(result, modifierFlags);
-#endif
+ InspectorInstrumentation::mouseDidMoveOverElement(m_page, result, modifierFlags);
}
void Chrome::setToolTip(const HitTestResult& result)
diff --git a/Source/WebCore/page/ChromeClient.h b/Source/WebCore/page/ChromeClient.h
index 0276a14..51c8959 100644
--- a/Source/WebCore/page/ChromeClient.h
+++ b/Source/WebCore/page/ChromeClient.h
@@ -100,6 +100,8 @@ namespace WebCore {
// Frame wants to create the new Page. Also, the newly created window
// should not be shown to the user until the ChromeClient of the newly
// created Page has its show method called.
+ // The FrameLoadRequest parameter is only for ChromeClient to check if the
+ // request could be fulfilled. The ChromeClient should not load the request.
virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&) = 0;
virtual void show() = 0;
diff --git a/Source/WebCore/page/Console.cpp b/Source/WebCore/page/Console.cpp
index 219647d..d4aed41 100644
--- a/Source/WebCore/page/Console.cpp
+++ b/Source/WebCore/page/Console.cpp
@@ -31,11 +31,11 @@
#include "Chrome.h"
#include "ChromeClient.h"
-#include "ConsoleMessage.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameTree.h"
#include "InspectorController.h"
+#include "InspectorInstrumentation.h"
#include "MemoryInfo.h"
#include "Page.h"
#include "PageGroup.h"
@@ -146,12 +146,10 @@ void Console::addMessage(MessageSource source, MessageType type, MessageLevel le
if (source == JSMessageSource)
page->chrome()->client()->addMessageToConsole(source, type, level, message, lineNumber, sourceURL);
-#if ENABLE(INSPECTOR)
if (callStack)
- page->inspectorController()->addMessageToConsole(source, type, level, message, 0, callStack);
+ InspectorInstrumentation::addMessageToConsole(page, source, type, level, message, 0, callStack.get());
else
- page->inspectorController()->addMessageToConsole(source, type, level, message, lineNumber, sourceURL);
-#endif
+ InspectorInstrumentation::addMessageToConsole(page, source, type, level, message, lineNumber, sourceURL);
if (!Console::shouldPrintExceptions())
return;
@@ -189,9 +187,7 @@ void Console::addMessage(MessageType type, MessageLevel level, PassRefPtr<Script
if (arguments->getFirstArgumentAsString(message))
page->chrome()->client()->addMessageToConsole(JSMessageSource, type, level, message, lastCaller.lineNumber(), lastCaller.sourceURL());
-#if ENABLE(INSPECTOR)
- page->inspectorController()->addMessageToConsole(JSMessageSource, type, level, message, arguments, callStack);
-#endif
+ InspectorInstrumentation::addMessageToConsole(page, JSMessageSource, type, level, message, arguments.get(), callStack.get());
}
void Console::debug(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack)
@@ -250,65 +246,13 @@ void Console::assertCondition(bool condition, PassRefPtr<ScriptArguments> argume
void Console::count(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack)
{
-#if ENABLE(INSPECTOR)
- Page* page = this->page();
- if (!page)
- return;
-
- const ScriptCallFrame& lastCaller = callStack->at(0);
- // Follow Firebug's behavior of counting with null and undefined title in
- // the same bucket as no argument
- String title;
- arguments->getFirstArgumentAsString(title);
-
- page->inspectorController()->count(title, lastCaller.lineNumber(), lastCaller.sourceURL());
-#else
- UNUSED_PARAM(callStack);
-#endif
+ InspectorInstrumentation::consoleCount(page(), arguments.get(), callStack.get());
}
void Console::markTimeline(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack>)
{
-#if ENABLE(INSPECTOR)
- Page* page = this->page();
- if (!page)
- return;
-
- String message;
- arguments->getFirstArgumentAsString(message);
-
- page->inspectorController()->markTimeline(message);
-#else
- UNUSED_PARAM(arguments);
-#endif
-}
-
-#if ENABLE(WML)
-String Console::lastWMLErrorMessage() const
-{
-#if ENABLE(INSPECTOR)
- Page* page = this->page();
- if (!page)
- return String();
-
- const Vector<OwnPtr<ConsoleMessage> >& consoleMessages = page->inspectorController()->consoleMessages();
- if (consoleMessages.isEmpty())
- return String();
-
- Vector<OwnPtr<ConsoleMessage> >::const_iterator it = consoleMessages.begin();
- const Vector<OwnPtr<ConsoleMessage> >::const_iterator end = consoleMessages.end();
-
- for (; it != end; ++it) {
- ConsoleMessage* message = it->get();
- if (message->source() != WMLMessageSource)
- continue;
-
- return message->message();
- }
-#endif
- return String();
+ InspectorInstrumentation::consoleMarkTimeline(page(), arguments.get());
}
-#endif
#if ENABLE(JAVASCRIPT_DEBUGGER)
@@ -335,10 +279,8 @@ void Console::profile(const String& title, ScriptState* state, PassRefPtr<Script
ScriptProfiler::start(state, resolvedTitle);
-#if ENABLE(INSPECTOR)
const ScriptCallFrame& lastCaller = callStack->at(0);
- controller->addStartProfilingMessageToConsole(resolvedTitle, lastCaller.lineNumber(), lastCaller.sourceURL());
-#endif
+ InspectorInstrumentation::addStartProfilingMessageToConsole(page, resolvedTitle, lastCaller.lineNumber(), lastCaller.sourceURL());
}
void Console::profileEnd(const String& title, ScriptState* state, PassRefPtr<ScriptCallStack> callStack)
@@ -369,85 +311,27 @@ void Console::profileEnd(const String& title, ScriptState* state, PassRefPtr<Scr
void Console::time(const String& title)
{
-#if ENABLE(INSPECTOR)
- Page* page = this->page();
- if (!page)
- return;
-
- // Follow Firebug's behavior of requiring a title that is not null or
- // undefined for timing functions
- if (title.isNull())
- return;
-
- page->inspectorController()->startTiming(title);
-#else
- UNUSED_PARAM(title);
-#endif
+ InspectorInstrumentation::startConsoleTiming(page(), title);
}
void Console::timeEnd(const String& title, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack> callStack)
{
-#if ENABLE(INSPECTOR)
- Page* page = this->page();
- if (!page)
- return;
-
- // Follow Firebug's behavior of requiring a title that is not null or
- // undefined for timing functions
- if (title.isNull())
- return;
-
- double elapsed;
- if (!page->inspectorController()->stopTiming(title, elapsed))
- return;
-
- String message = title + String::format(": %.0fms", elapsed);
-
- const ScriptCallFrame& lastCaller = callStack->at(0);
- page->inspectorController()->addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, message, lastCaller.lineNumber(), lastCaller.sourceURL());
-#else
- UNUSED_PARAM(title);
- UNUSED_PARAM(callStack);
-#endif
+ InspectorInstrumentation::stopConsoleTiming(page(), title, callStack.get());
}
void Console::group(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack)
{
-#if ENABLE(INSPECTOR)
- Page* page = this->page();
- if (!page)
- return;
-
- page->inspectorController()->startGroup(arguments, callStack);
-#else
- UNUSED_PARAM(arguments);
- UNUSED_PARAM(callStack);
-#endif
+ InspectorInstrumentation::addMessageToConsole(page(), JSMessageSource, StartGroupMessageType, LogMessageLevel, String(), arguments.get(), callStack.get());
}
void Console::groupCollapsed(PassRefPtr<ScriptArguments> arguments, PassRefPtr<ScriptCallStack> callStack)
{
-#if ENABLE(INSPECTOR)
- Page* page = this->page();
- if (!page)
- return;
-
- page->inspectorController()->startGroup(arguments, callStack, true);
-#else
- UNUSED_PARAM(arguments);
- UNUSED_PARAM(callStack);
-#endif
+ InspectorInstrumentation::addMessageToConsole(page(), JSMessageSource, StartGroupCollapsedMessageType, LogMessageLevel, String(), arguments.get(), callStack.get());
}
void Console::groupEnd()
{
-#if ENABLE(INSPECTOR)
- Page* page = this->page();
- if (!page)
- return;
-
- page->inspectorController()->endGroup(JSMessageSource, 0, String());
-#endif
+ InspectorInstrumentation::addMessageToConsole(page(), JSMessageSource, EndGroupMessageType, LogMessageLevel, String(), 0, String());
}
bool Console::shouldCaptureFullStackTrace() const
diff --git a/Source/WebCore/page/Console.h b/Source/WebCore/page/Console.h
index dd692a2..ceefb38 100644
--- a/Source/WebCore/page/Console.h
+++ b/Source/WebCore/page/Console.h
@@ -101,9 +101,6 @@ public:
void assertCondition(bool condition, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void count(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void markTimeline(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
-#if ENABLE(WML)
- String lastWMLErrorMessage() const;
-#endif
#if ENABLE(JAVASCRIPT_DEBUGGER)
const ProfilesArray& profiles() const { return m_profiles; }
void profile(const String&, ScriptState*, PassRefPtr<ScriptCallStack>);
diff --git a/Source/WebCore/page/Console.idl b/Source/WebCore/page/Console.idl
index 503bb91..189280d 100644
--- a/Source/WebCore/page/Console.idl
+++ b/Source/WebCore/page/Console.idl
@@ -42,10 +42,6 @@ module window {
[CustomArgumentHandling] void count();
[CustomArgumentHandling] void markTimeline();
-#if defined(ENABLE_WML) && ENABLE_WML
- [DontEnum] DOMString lastWMLErrorMessage();
-#endif
-
#if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
readonly attribute [CustomGetter] Array profiles;
[Custom] void profile(in DOMString title);
diff --git a/Source/WebCore/page/ContextMenuController.cpp b/Source/WebCore/page/ContextMenuController.cpp
index ac89db2..0909f70 100644
--- a/Source/WebCore/page/ContextMenuController.cpp
+++ b/Source/WebCore/page/ContextMenuController.cpp
@@ -158,9 +158,10 @@ static void openNewWindow(const KURL& urlToLoad, Frame* frame)
{
if (Page* oldPage = frame->page()) {
FrameLoadRequest request(frame->document()->securityOrigin(), ResourceRequest(urlToLoad, frame->loader()->outgoingReferrer()));
- WindowFeatures features;
- if (Page* newPage = oldPage->chrome()->createWindow(frame, request, features, NavigationAction()))
+ if (Page* newPage = oldPage->chrome()->createWindow(frame, request, WindowFeatures(), NavigationAction())) {
+ newPage->mainFrame()->loader()->loadFrameRequest(request, false, false, 0, 0, SendReferrer);
newPage->chrome()->show();
+ }
}
}
diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp
index be6c179..99c8fcd 100644
--- a/Source/WebCore/page/DOMWindow.cpp
+++ b/Source/WebCore/page/DOMWindow.cpp
@@ -43,6 +43,7 @@
#include "DOMStringList.h"
#include "DOMTimer.h"
#include "DOMTokenList.h"
+#include "DOMURL.h"
#include "Database.h"
#include "DatabaseCallback.h"
#include "DeviceMotionController.h"
@@ -64,7 +65,6 @@
#include "History.h"
#include "IDBFactory.h"
#include "IDBFactoryBackendInterface.h"
-#include "InspectorController.h"
#include "InspectorInstrumentation.h"
#include "KURL.h"
#include "Location.h"
@@ -627,9 +627,7 @@ Storage* DOMWindow::sessionStorage(ExceptionCode& ec) const
return 0;
RefPtr<StorageArea> storageArea = page->sessionStorage()->storageArea(document->securityOrigin());
-#if ENABLE(INSPECTOR)
- page->inspectorController()->didUseDOMStorage(storageArea.get(), false, m_frame);
-#endif
+ InspectorInstrumentation::didUseDOMStorage(page, storageArea.get(), false, m_frame);
m_sessionStorage = Storage::create(m_frame, storageArea.release());
return m_sessionStorage.get();
@@ -657,9 +655,7 @@ Storage* DOMWindow::localStorage(ExceptionCode& ec) const
return 0;
RefPtr<StorageArea> storageArea = page->group().localStorage()->storageArea(document->securityOrigin());
-#if ENABLE(INSPECTOR)
- page->inspectorController()->didUseDOMStorage(storageArea.get(), true, m_frame);
-#endif
+ InspectorInstrumentation::didUseDOMStorage(page, storageArea.get(), true, m_frame);
m_localStorage = Storage::create(m_frame, storageArea.release());
return m_localStorage.get();
@@ -1355,7 +1351,7 @@ void DOMWindow::scrollTo(int x, int y) const
m_frame->document()->updateLayoutIgnorePendingStylesheets();
- FrameView* view = m_frame->view();
+ RefPtr<FrameView> view = m_frame->view();
if (!view)
return;
@@ -1542,13 +1538,7 @@ void DOMWindow::dispatchLoadEvent()
ownerElement->dispatchGenericEvent(ownerEvent.release());
}
-#if ENABLE(INSPECTOR)
- if (!frame() || !frame()->page())
- return;
-
- if (InspectorController* controller = frame()->page()->inspectorController())
- controller->mainResourceFiredLoadEvent(frame()->loader()->documentLoader(), url());
-#endif
+ InspectorInstrumentation::mainResourceFiredLoadEvent(frame(), url());
}
bool DOMWindow::dispatchEvent(PassRefPtr<Event> prpEvent, PassRefPtr<EventTarget> prpTarget)
@@ -1622,6 +1612,7 @@ EventTargetData* DOMWindow::ensureEventTargetData()
return &m_eventTargetData;
}
+<<<<<<< HEAD
#if ENABLE(BLOB)
String DOMWindow::createObjectURL(Blob* blob)
{
@@ -1647,6 +1638,8 @@ void DOMWindow::clearDOMStorage()
}
#endif
+=======
+>>>>>>> WebKit.org @ r75993
void DOMWindow::setLocation(const String& urlString, DOMWindow* activeWindow, DOMWindow* firstWindow, SetLocationLocking locking)
{
Frame* activeFrame = activeWindow->frame();
@@ -1725,17 +1718,11 @@ Frame* DOMWindow::createWindow(const String& urlString, const AtomicString& fram
{
Frame* activeFrame = activeWindow->frame();
- // FIXME: It's much better for client API if a new window starts with a URL, here where we
- // know what URL we are going to open. Unfortunately, this code passes the empty string
- // for the URL, but there's a reason for that. Before loading we have to set up the opener,
- // openedByDOM, and dialogArguments values. Also, to decide whether to use the URL we currently
- // do an isInsecureScriptAccess call using the window we create, which can't be done before
- // creating it. We'd have to resolve all those issues to pass the URL instead of an empty string.
-
// For whatever reason, Firefox uses the first frame to determine the outgoingReferrer. We replicate that behavior here.
String referrer = firstFrame->loader()->outgoingReferrer();
- ResourceRequest request(KURL(), referrer);
+ KURL completedURL = urlString.isEmpty() ? KURL(ParsedURLString, "") : firstFrame->document()->completeURL(urlString);
+ ResourceRequest request(completedURL, referrer);
FrameLoader::addHTTPOriginIfNeeded(request, firstFrame->loader()->outgoingOrigin());
FrameLoadRequest frameRequest(activeWindow->securityOrigin(), request, frameName);
@@ -1755,8 +1742,6 @@ Frame* DOMWindow::createWindow(const String& urlString, const AtomicString& fram
if (function)
function(newFrame->domWindow(), functionContext);
- KURL completedURL = urlString.isEmpty() ? KURL(ParsedURLString, "") : firstFrame->document()->completeURL(urlString);
-
if (created)
newFrame->loader()->changeLocation(activeWindow->securityOrigin(), completedURL, referrer, false, false);
else if (!urlString.isEmpty()) {
@@ -1854,4 +1839,13 @@ void DOMWindow::showModalDialog(const String& urlString, const String& dialogFea
dialogFrame->page()->chrome()->runModal();
}
+#if ENABLE(BLOB)
+DOMURL* DOMWindow::webkitURL() const
+{
+ if (!m_domURL)
+ m_domURL = DOMURL::create(this->scriptExecutionContext());
+ return m_domURL.get();
+}
+#endif
+
} // namespace WebCore
diff --git a/Source/WebCore/page/DOMWindow.h b/Source/WebCore/page/DOMWindow.h
index 8f434d6..3614627 100644
--- a/Source/WebCore/page/DOMWindow.h
+++ b/Source/WebCore/page/DOMWindow.h
@@ -34,12 +34,12 @@
namespace WebCore {
class BarInfo;
- class Blob;
class CSSRuleList;
class CSSStyleDeclaration;
class Console;
class DOMApplicationCache;
class DOMSelection;
+ class DOMURL;
class Database;
class DatabaseCallback;
class Document;
@@ -343,8 +343,7 @@ namespace WebCore {
using RefCounted<DOMWindow>::deref;
#if ENABLE(BLOB)
- String createObjectURL(Blob*);
- void revokeObjectURL(const String&);
+ DOMURL* webkitURL() const;
#endif
#if ENABLE(DATABASE)
@@ -469,6 +468,10 @@ namespace WebCore {
#if ENABLE(WEB_TIMING)
mutable RefPtr<Performance> m_performance;
#endif
+
+#if ENABLE(BLOB)
+ mutable RefPtr<DOMURL> m_domURL;
+#endif
};
inline String DOMWindow::status() const
diff --git a/Source/WebCore/page/DOMWindow.idl b/Source/WebCore/page/DOMWindow.idl
index 5aab15e..77ffe41 100644
--- a/Source/WebCore/page/DOMWindow.idl
+++ b/Source/WebCore/page/DOMWindow.idl
@@ -779,10 +779,7 @@ module window {
attribute [Conditional=BLOB] BlobBuilderConstructor BlobBuilder;
-#if defined(ENABLE_BLOB) && ENABLE_BLOB
- [ConvertNullStringTo=Undefined] DOMString createObjectURL(in Blob blob);
- void revokeObjectURL(in DOMString blobURL);
-#endif
+ readonly attribute [Conditional=BLOB] DOMURL webkitURL;
#endif // defined(LANGUAGE_JAVASCRIPT)
diff --git a/Source/WebCore/page/DragController.cpp b/Source/WebCore/page/DragController.cpp
index d0e9a8c..7be708c 100644
--- a/Source/WebCore/page/DragController.cpp
+++ b/Source/WebCore/page/DragController.cpp
@@ -99,7 +99,7 @@ DragController::~DragController()
m_client->dragControllerDestroyed();
}
-static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragData, RefPtr<Range> context,
+static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragData, Frame* frame, RefPtr<Range> context,
bool allowPlainText, bool& chosePlainText)
{
ASSERT(dragData);
@@ -108,19 +108,19 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD
Document* document = context->ownerDocument();
ASSERT(document);
if (document && dragData->containsCompatibleContent()) {
- if (PassRefPtr<DocumentFragment> fragment = dragData->asFragment(document))
+ if (PassRefPtr<DocumentFragment> fragment = dragData->asFragment(frame, context, allowPlainText, chosePlainText))
return fragment;
- if (dragData->containsURL(DragData::DoNotConvertFilenames)) {
+ if (dragData->containsURL(frame, DragData::DoNotConvertFilenames)) {
String title;
- String url = dragData->asURL(DragData::DoNotConvertFilenames, &title);
+ String url = dragData->asURL(frame, DragData::DoNotConvertFilenames, &title);
if (!url.isEmpty()) {
RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(document);
anchor->setHref(url);
if (title.isEmpty()) {
// Try the plain text first because the url might be normalized or escaped.
if (dragData->containsPlainText())
- title = dragData->asPlainText();
+ title = dragData->asPlainText(frame);
if (title.isEmpty())
title = url;
}
@@ -135,15 +135,15 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD
}
if (allowPlainText && dragData->containsPlainText()) {
chosePlainText = true;
- return createFragmentFromText(context.get(), dragData->asPlainText()).get();
+ return createFragmentFromText(context.get(), dragData->asPlainText(frame)).get();
}
return 0;
}
-bool DragController::dragIsMove(SelectionController* selection)
+bool DragController::dragIsMove(SelectionController* selection, DragData* dragData)
{
- return m_documentUnderMouse == m_dragInitiator && selection->isContentEditable() && !isCopyKeyDown();
+ return m_documentUnderMouse == m_dragInitiator && selection->isContentEditable() && !isCopyKeyDown(dragData);
}
// FIXME: This method is poorly named. We're just clearing the selection from the document this drag is exiting.
@@ -214,7 +214,7 @@ bool DragController::performDrag(DragData* dragData)
return false;
m_client->willPerformDragDestinationAction(DragDestinationActionLoad, dragData);
- m_page->mainFrame()->loader()->load(ResourceRequest(dragData->asURL()), false);
+ m_page->mainFrame()->loader()->load(ResourceRequest(dragData->asURL(m_page->mainFrame())), false);
return true;
}
@@ -335,7 +335,7 @@ bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction a
}
Frame* innerFrame = element->document()->frame();
- operation = dragIsMove(innerFrame->selection()) ? DragOperationMove : DragOperationCopy;
+ operation = dragIsMove(innerFrame->selection(), dragData) ? DragOperationMove : DragOperationCopy;
return true;
}
// If we're not over an editable region, make sure we're clearing any prior drag cursor.
@@ -372,7 +372,7 @@ static bool setSelectionToDragCaret(Frame* frame, VisibleSelection& dragCaret, R
bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData* dragData)
{
VisibleSelection dragCaret(m_page->dragCaretController()->selection());
- String text = dragCaret.isContentRichlyEditable() ? "" : dragData->asPlainText();
+ String text = dragCaret.isContentRichlyEditable() ? "" : dragData->asPlainText(innerFrame);
Node* target = innerFrame->editor()->findEventTargetFrom(dragCaret);
ExceptionCode ec = 0;
return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow(), text), ec);
@@ -449,16 +449,16 @@ bool DragController::concludeEditDrag(DragData* dragData)
return false;
CachedResourceLoader* cachedResourceLoader = range->ownerDocument()->cachedResourceLoader();
cachedResourceLoader->setAllowStaleResources(true);
- if (dragIsMove(innerFrame->selection()) || dragCaret.isContentRichlyEditable()) {
+ if (dragIsMove(innerFrame->selection(), dragData) || dragCaret.isContentRichlyEditable()) {
bool chosePlainText = false;
- RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, range, true, chosePlainText);
+ RefPtr<DocumentFragment> fragment = documentFragmentFromDragData(dragData, innerFrame, range, true, chosePlainText);
if (!fragment || !innerFrame->editor()->shouldInsertFragment(fragment, range, EditorInsertActionDropped)) {
cachedResourceLoader->setAllowStaleResources(false);
return false;
}
m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
- if (dragIsMove(innerFrame->selection())) {
+ if (dragIsMove(innerFrame->selection(), dragData)) {
// NSTextView behavior is to always smart delete on moving a selection,
// but only to smart insert if the selection granularity is word granularity.
bool smartDelete = innerFrame->editor()->smartInsertDeleteEnabled();
@@ -469,7 +469,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.get(), fragment, true, dragData->canSmartReplace(), chosePlainText));
}
} else {
- String text = dragData->asPlainText();
+ String text = dragData->asPlainText(innerFrame);
if (text.isEmpty() || !innerFrame->editor()->shouldInsertText(text, range.get(), EditorInsertActionDropped)) {
cachedResourceLoader->setAllowStaleResources(false);
return false;
diff --git a/Source/WebCore/page/DragController.h b/Source/WebCore/page/DragController.h
index 0e90a52..10bb5f8 100644
--- a/Source/WebCore/page/DragController.h
+++ b/Source/WebCore/page/DragController.h
@@ -99,8 +99,8 @@ namespace WebCore {
bool tryDHTMLDrag(DragData*, DragOperation&);
DragOperation dragOperation(DragData*);
void cancelDrag();
- bool dragIsMove(SelectionController*);
- bool isCopyKeyDown();
+ bool dragIsMove(SelectionController*, DragData*);
+ bool isCopyKeyDown(DragData*);
void mouseMovedIntoDocument(Document*);
diff --git a/Source/WebCore/page/EditorClient.h b/Source/WebCore/page/EditorClient.h
index 1ec0c7e..71ba3dd 100644
--- a/Source/WebCore/page/EditorClient.h
+++ b/Source/WebCore/page/EditorClient.h
@@ -157,6 +157,8 @@ public:
virtual NSString* userVisibleString(NSURL*) = 0;
virtual DocumentFragment* documentFragmentFromAttributedString(NSAttributedString*, Vector< RefPtr<ArchiveResource> >&) = 0;
virtual void setInsertionPasteboard(NSPasteboard*) = 0;
+ virtual NSURL* canonicalizeURL(NSURL*) = 0;
+ virtual NSURL* canonicalizeURLString(NSString*) = 0;
#ifdef BUILDING_ON_TIGER
virtual NSArray* pasteboardTypesForSelection(Frame*) = 0;
#endif
diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp
index a04bcf0..942f032 100644
--- a/Source/WebCore/page/EventHandler.cpp
+++ b/Source/WebCore/page/EventHandler.cpp
@@ -32,10 +32,12 @@
#include "Chrome.h"
#include "ChromeClient.h"
#include "Cursor.h"
+#include "CursorList.h"
#include "Document.h"
#include "DragController.h"
#include "Editor.h"
#include "EventNames.h"
+#include "EventQueue.h"
#include "FloatPoint.h"
#include "FloatRect.h"
#include "FocusController.h"
@@ -50,7 +52,7 @@
#include "HitTestRequest.h"
#include "HitTestResult.h"
#include "Image.h"
-#include "InspectorController.h"
+#include "InspectorInstrumentation.h"
#include "KeyboardEvent.h"
#include "MouseEvent.h"
#include "MouseEventWithHitTestResults.h"
@@ -1321,17 +1323,11 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
m_mousePressNode = mev.targetNode();
-#if ENABLE(INSPECTOR)
- if (Page* page = m_frame->page()) {
- InspectorController* inspector = page->inspectorController();
- if (inspector && inspector->enabled() && inspector->searchingForNodeInPage()) {
- inspector->handleMousePress();
- invalidateClick();
- return true;
- }
+ if (InspectorInstrumentation::handleMousePress(m_frame->page())) {
+ invalidateClick();
+ return true;
}
-#endif
-
+
Frame* subframe = subframeForHitTestResult(mev);
if (subframe && passMousePressEventToSubframe(mev, subframe)) {
// Start capturing future events for this frame. We only do this if we didn't clear
@@ -2825,7 +2821,7 @@ void EventHandler::sendScrollEvent()
{
setFrameWasScrolledByUser();
if (m_frame->view() && m_frame->document())
- m_frame->document()->dispatchEvent(Event::create(eventNames().scrollEvent, true, false));
+ m_frame->document()->eventQueue()->enqueueScrollEvent(m_frame->document(), EventQueue::ScrollEventDocumentTarget);
}
void EventHandler::setFrameWasScrolledByUser()
diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp
index 11a86c6..4c7c6b7 100644
--- a/Source/WebCore/page/Frame.cpp
+++ b/Source/WebCore/page/Frame.cpp
@@ -979,6 +979,18 @@ void Frame::setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor
}
}
+#if USE(ACCELERATED_COMPOSITING)
+void Frame::updateContentsScale(float scale)
+{
+ for (Frame* child = tree()->firstChild(); child; child = child->tree()->nextSibling())
+ child->updateContentsScale(scale);
+
+ RenderView* root = contentRenderer();
+ if (root && root->compositor())
+ root->compositor()->updateContentsScale(scale);
+}
+#endif
+
void Frame::scalePage(float scale, const IntPoint& origin)
{
Document* document = this->document();
@@ -992,6 +1004,10 @@ void Frame::scalePage(float scale, const IntPoint& origin)
document->recalcStyle(Node::Force);
+#if USE(ACCELERATED_COMPOSITING)
+ updateContentsScale(scale);
+#endif
+
if (FrameView* view = this->view()) {
if (document->renderer() && document->renderer()->needsLayout() && view->didFirstLayout())
view->layout();
diff --git a/Source/WebCore/page/Frame.h b/Source/WebCore/page/Frame.h
index 4928742..a1e5c10 100644
--- a/Source/WebCore/page/Frame.h
+++ b/Source/WebCore/page/Frame.h
@@ -35,6 +35,7 @@
#include "EventHandler.h"
#include "FrameLoader.h"
#include "FrameTree.h"
+#include "NavigationScheduler.h"
#include "SelectionController.h"
#include "ScriptController.h"
#include "UserScriptTypes.h"
@@ -207,6 +208,10 @@ namespace WebCore {
void injectUserScriptsForWorld(DOMWrapperWorld*, const UserScriptVector&, UserScriptInjectionTime);
void lifeSupportTimerFired(Timer<Frame>*);
+#if USE(ACCELERATED_COMPOSITING)
+ void updateContentsScale(float);
+#endif
+
HashSet<FrameDestructionObserver*> m_destructionObservers;
Page* m_page;
diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp
index 926d943..fdf01ec 100644
--- a/Source/WebCore/page/FrameView.cpp
+++ b/Source/WebCore/page/FrameView.cpp
@@ -566,6 +566,24 @@ void FrameView::updateCompositingLayers()
#endif
}
+void FrameView::syncCompositingStateForThisFrame()
+{
+ if (RenderView* view = m_frame->contentRenderer())
+ view->compositor()->flushPendingLayerChanges();
+
+#if ENABLE(FULLSCREEN_API)
+ // The fullScreenRenderer's graphicsLayer has been re-parented, and the above recursive syncCompositingState
+ // call will not cause the subtree under it to repaint. Explicitly call the syncCompositingState on
+ // the fullScreenRenderer's graphicsLayer here:
+ Document* document = m_frame->document();
+ if (isDocumentRunningFullScreenAnimation(document)) {
+ RenderLayerBacking* backing = document->fullScreenRenderer()->layer()->backing();
+ if (GraphicsLayer* fullScreenLayer = backing->graphicsLayer())
+ fullScreenLayer->syncCompositingState();
+ }
+#endif
+}
+
void FrameView::setNeedsOneShotDrawingSynchronization()
{
Page* page = frame() ? frame()->page() : 0;
@@ -655,21 +673,8 @@ bool FrameView::syncCompositingStateRecursive()
if (needsLayout())
return false;
- if (GraphicsLayer* rootLayer = contentRenderer->compositor()->rootPlatformLayer())
- rootLayer->syncCompositingState();
+ syncCompositingStateForThisFrame();
-#if ENABLE(FULLSCREEN_API)
- // The fullScreenRenderer's graphicsLayer has been re-parented, and the above recursive syncCompositingState
- // call will not cause the subtree under it to repaint. Explicitly call the syncCompositingState on
- // the fullScreenRenderer's graphicsLayer here:
- Document* document = m_frame->document();
- if (isDocumentRunningFullScreenAnimation(document)) {
- RenderLayerBacking* backing = document->fullScreenRenderer()->layer()->backing();
- if (GraphicsLayer* fullScreenLayer = backing->graphicsLayer())
- fullScreenLayer->syncCompositingState();
- }
-#endif
-
bool allSubframesSynced = true;
const HashSet<RefPtr<Widget> >* viewChildren = children();
HashSet<RefPtr<Widget> >::const_iterator end = viewChildren->end();
@@ -2231,20 +2236,8 @@ void FrameView::paintContents(GraphicsContext* p, const IntRect& rect)
return;
#if USE(ACCELERATED_COMPOSITING)
- if (!p->paintingDisabled()) {
- if (GraphicsLayer* rootLayer = contentRenderer->compositor()->rootPlatformLayer())
- rootLayer->syncCompositingState();
-#if ENABLE(FULLSCREEN_API)
- // The fullScreenRenderer's graphicsLayer has been re-parented, and the above recursive syncCompositingState
- // call will not cause the subtree under it to repaint. Explicitly call the syncCompositingState on
- // the fullScreenRenderer's graphicsLayer here:
- if (isDocumentRunningFullScreenAnimation(document)) {
- RenderLayerBacking* backing = document->fullScreenRenderer()->layer()->backing();
- if (GraphicsLayer* fullScreenLayer = backing->graphicsLayer())
- fullScreenLayer->syncCompositingState();
- }
-#endif
- }
+ if (!p->paintingDisabled())
+ syncCompositingStateForThisFrame();
#endif
PaintBehavior oldPaintBehavior = m_paintBehavior;
diff --git a/Source/WebCore/page/FrameView.h b/Source/WebCore/page/FrameView.h
index ed45d00..bdeab90 100644
--- a/Source/WebCore/page/FrameView.h
+++ b/Source/WebCore/page/FrameView.h
@@ -103,6 +103,7 @@ public:
#if USE(ACCELERATED_COMPOSITING)
void updateCompositingLayers();
+ void syncCompositingStateForThisFrame();
// Called when changes to the GraphicsLayer hierarchy have to be synchronized with
// content rendered via the normal painting path.
diff --git a/Source/WebCore/page/GeolocationController.cpp b/Source/WebCore/page/GeolocationController.cpp
index 28d522d..764b913 100644
--- a/Source/WebCore/page/GeolocationController.cpp
+++ b/Source/WebCore/page/GeolocationController.cpp
@@ -41,8 +41,12 @@ GeolocationController::GeolocationController(Page* page, GeolocationClient* clie
GeolocationController::~GeolocationController()
{
- if (m_client)
+ if (m_client) {
+ if (!m_observers.isEmpty())
+ m_client->stopUpdating();
+
m_client->geolocationDestroyed();
+ }
}
void GeolocationController::addObserver(Geolocation* observer, bool enableHighAccuracy)
diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp
index 5b87051..b864aa2 100644
--- a/Source/WebCore/page/Page.cpp
+++ b/Source/WebCore/page/Page.cpp
@@ -47,6 +47,7 @@
#include "HTMLElement.h"
#include "HistoryItem.h"
#include "InspectorController.h"
+#include "InspectorInstrumentation.h"
#include "Logging.h"
#include "MediaCanStartListener.h"
#include "Navigator.h"
@@ -94,6 +95,7 @@
#include "GeolocationController.h"
#endif
+<<<<<<< HEAD
#if ENABLE(INSPECTOR) && ENABLE(OFFLINE_WEB_APPLICATIONS)
#include "InspectorApplicationCacheAgent.h"
#endif
@@ -102,6 +104,8 @@
#include "PackageNotifier.h"
#endif
+=======
+>>>>>>> WebKit.org @ r75993
namespace WebCore {
static HashSet<Page*>* allPages;
@@ -114,19 +118,12 @@ static void networkStateChanged()
{
Vector<RefPtr<Frame> > frames;
-#if ENABLE(INSPECTOR) && ENABLE(OFFLINE_WEB_APPLICATIONS)
- bool isNowOnline = networkStateNotifier().onLine();
-#endif
-
// Get all the frames of all the pages in all the page groups
HashSet<Page*>::iterator end = allPages->end();
for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) {
for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext())
frames.append(frame);
-#if ENABLE(INSPECTOR) && ENABLE(OFFLINE_WEB_APPLICATIONS)
- if (InspectorApplicationCacheAgent* applicationCacheAgent = (*it)->inspectorController()->applicationCacheAgent())
- applicationCacheAgent->updateNetworkState(isNowOnline);
-#endif
+ InspectorInstrumentation::networkStateChanged(*it);
}
AtomicString eventName = networkStateNotifier().onLine() ? eventNames().onlineEvent : eventNames().offlineEvent;
@@ -227,10 +224,8 @@ Page::~Page()
frame->pageDestroyed();
m_editorClient->pageDestroyed();
-
-#if ENABLE(INSPECTOR)
- m_inspectorController->inspectedPageDestroyed();
-#endif
+
+ InspectorInstrumentation::inspectedPageDestroyed(this);
backForward()->close();
diff --git a/Source/WebCore/page/PerformanceTiming.cpp b/Source/WebCore/page/PerformanceTiming.cpp
index fb8bfb7..76b410a 100644
--- a/Source/WebCore/page/PerformanceTiming.cpp
+++ b/Source/WebCore/page/PerformanceTiming.cpp
@@ -227,7 +227,7 @@ unsigned long long PerformanceTiming::connectEnd() const
return resourceLoadTimeRelativeToAbsolute(connectEnd);
}
-unsigned long long PerformanceTiming::sslHandshakeStart() const
+unsigned long long PerformanceTiming::secureConnectionStart() const
{
DocumentLoader* loader = documentLoader();
if (!loader)
diff --git a/Source/WebCore/page/PerformanceTiming.h b/Source/WebCore/page/PerformanceTiming.h
index 9c35672..0c37383 100644
--- a/Source/WebCore/page/PerformanceTiming.h
+++ b/Source/WebCore/page/PerformanceTiming.h
@@ -61,7 +61,7 @@ public:
unsigned long long domainLookupEnd() const;
unsigned long long connectStart() const;
unsigned long long connectEnd() const;
- unsigned long long sslHandshakeStart() const;
+ unsigned long long secureConnectionStart() const;
unsigned long long requestStart() const;
unsigned long long responseStart() const;
unsigned long long responseEnd() const;
diff --git a/Source/WebCore/page/PerformanceTiming.idl b/Source/WebCore/page/PerformanceTiming.idl
index a0f08e2..dacf93b 100644
--- a/Source/WebCore/page/PerformanceTiming.idl
+++ b/Source/WebCore/page/PerformanceTiming.idl
@@ -42,7 +42,7 @@ module window {
readonly attribute unsigned long long domainLookupEnd;
readonly attribute unsigned long long connectStart;
readonly attribute unsigned long long connectEnd;
- readonly attribute unsigned long long sslHandshakeStart;
+ readonly attribute unsigned long long secureConnectionStart;
readonly attribute unsigned long long requestStart;
readonly attribute unsigned long long responseStart;
readonly attribute unsigned long long responseEnd;
diff --git a/Source/WebCore/page/PrintContext.cpp b/Source/WebCore/page/PrintContext.cpp
index f051ead..e82420d 100644
--- a/Source/WebCore/page/PrintContext.cpp
+++ b/Source/WebCore/page/PrintContext.cpp
@@ -28,10 +28,21 @@
#include "RenderView.h"
#include <wtf/text/StringConcatenate.h>
-using namespace WebCore;
-
namespace WebCore {
+// By imaging to a width a little wider than the available pixels,
+// thin pages will be scaled down a little, matching the way they
+// print in IE and Camino. This lets them use fewer sheets than they
+// would otherwise, which is presumably why other browsers do this.
+// Wide pages will be scaled down more than this.
+const float printingMinimumShrinkFactor = 1.25f;
+
+// This number determines how small we are willing to reduce the page content
+// in order to accommodate the widest line. If the page would have to be
+// reduced smaller to make the widest line fit, we just clip instead (this
+// behavior matches MacIE and Mozilla, at least)
+const float printingMaximumShrinkFactor = 2;
+
PrintContext::PrintContext(Frame* frame)
: m_frame(frame)
, m_isPrinting(false)
@@ -42,20 +53,19 @@ PrintContext::~PrintContext()
{
if (m_isPrinting)
end();
- m_pageRects.clear();
}
-int PrintContext::pageCount() const
+size_t PrintContext::pageCount() const
{
return m_pageRects.size();
}
-const IntRect& PrintContext::pageRect(int pageNumber) const
+const IntRect& PrintContext::pageRect(size_t pageNumber) const
{
return m_pageRects[pageNumber];
}
-void PrintContext::computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight)
+void PrintContext::computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight, bool allowHorizontalTiling)
{
m_pageRects.clear();
outPageHeight = 0;
@@ -73,7 +83,7 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig
float ratio = printRect.height() / printRect.width();
float pageWidth = view->docWidth();
- float pageHeight = pageWidth * ratio;
+ float pageHeight = floorf(pageWidth * ratio);
outPageHeight = pageHeight; // this is the height of the page adjusted by margins
pageHeight -= headerHeight + footerHeight;
@@ -82,16 +92,16 @@ void PrintContext::computePageRects(const FloatRect& printRect, float headerHeig
return;
}
- computePageRectsWithPageSizeInternal(FloatSize(pageWidth / userScaleFactor, pageHeight / userScaleFactor), false);
+ computePageRectsWithPageSizeInternal(FloatSize(pageWidth / userScaleFactor, pageHeight / userScaleFactor), allowHorizontalTiling);
}
-void PrintContext::computePageRectsWithPageSize(const FloatSize& pageSizeInPixels, bool allowHorizontalMultiPages)
+void PrintContext::computePageRectsWithPageSize(const FloatSize& pageSizeInPixels, bool allowHorizontalTiling)
{
m_pageRects.clear();
- computePageRectsWithPageSizeInternal(pageSizeInPixels, allowHorizontalMultiPages);
+ computePageRectsWithPageSizeInternal(pageSizeInPixels, allowHorizontalTiling);
}
-void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels, bool allowHorizontalMultiPages)
+void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels, bool allowHorizontalTiling)
{
if (!m_frame->document() || !m_frame->view() || !m_frame->document()->renderer())
return;
@@ -105,7 +115,7 @@ void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSiz
unsigned pageCount = ceilf((float)docRect.height() / pageHeight);
for (unsigned i = 0; i < pageCount; ++i) {
- if (allowHorizontalMultiPages) {
+ if (allowHorizontalTiling) {
for (int currentX = docRect.x(); currentX < docRect.right(); currentX += pageWidth)
m_pageRects.append(IntRect(currentX, docRect.y() + i * pageHeight, pageWidth, pageHeight));
} else
@@ -115,28 +125,28 @@ void PrintContext::computePageRectsWithPageSizeInternal(const FloatSize& pageSiz
void PrintContext::begin(float width, float height)
{
- ASSERT(!m_isPrinting);
+ // This function can be called multiple times to adjust printing parameters without going back to screen mode.
m_isPrinting = true;
- // By imaging to a width a little wider than the available pixels,
- // thin pages will be scaled down a little, matching the way they
- // print in IE and Camino. This lets them use fewer sheets than they
- // would otherwise, which is presumably why other browsers do this.
- // Wide pages will be scaled down more than this.
- const float PrintingMinimumShrinkFactor = 1.25f;
-
- // This number determines how small we are willing to reduce the page content
- // in order to accommodate the widest line. If the page would have to be
- // reduced smaller to make the widest line fit, we just clip instead (this
- // behavior matches MacIE and Mozilla, at least)
- const float PrintingMaximumShrinkFactor = 2.0f;
-
- float minLayoutWidth = width * PrintingMinimumShrinkFactor;
- float minLayoutHeight = height * PrintingMinimumShrinkFactor;
-
- // FIXME: This will modify the rendering of the on-screen frame.
- // Could lead to flicker during printing.
- m_frame->setPrinting(true, FloatSize(minLayoutWidth, minLayoutHeight), PrintingMaximumShrinkFactor / PrintingMinimumShrinkFactor, Frame::AdjustViewSize);
+ float minLayoutWidth = width * printingMinimumShrinkFactor;
+ float minLayoutHeight = height * printingMinimumShrinkFactor;
+
+ // This changes layout, so callers need to make sure that they don't paint to screen while in printing mode.
+ m_frame->setPrinting(true, FloatSize(minLayoutWidth, minLayoutHeight), printingMaximumShrinkFactor / printingMinimumShrinkFactor, Frame::AdjustViewSize);
+}
+
+float PrintContext::computeAutomaticScaleFactor(float availablePaperWidth)
+{
+ if (!m_frame->view())
+ return 1;
+
+ float viewWidth = m_frame->view()->contentsWidth();
+ if (viewWidth < 1)
+ return 1;
+
+ float maxShrinkToFitScaleFactor = 1 / printingMaximumShrinkFactor;
+ float shrinkToFitScaleFactor = availablePaperWidth / viewWidth;
+ return max(maxShrinkToFitScaleFactor, shrinkToFitScaleFactor);
}
void PrintContext::spoolPage(GraphicsContext& ctx, int pageNumber, float width)
@@ -152,6 +162,16 @@ void PrintContext::spoolPage(GraphicsContext& ctx, int pageNumber, float width)
ctx.restore();
}
+void PrintContext::spoolRect(GraphicsContext& ctx, const IntRect& rect)
+{
+ ctx.save();
+ ctx.scale(FloatSize(1, -1));
+ ctx.translate(0, -rect.height());
+ ctx.clip(rect);
+ m_frame->view()->paintContents(&ctx, rect);
+ ctx.restore();
+}
+
void PrintContext::end()
{
ASSERT(m_isPrinting);
@@ -189,7 +209,7 @@ int PrintContext::pageNumberForElement(Element* element, const FloatSize& pageSi
int top = box->offsetTop();
int left = box->offsetLeft();
- int pageNumber = 0;
+ size_t pageNumber = 0;
for (; pageNumber < printContext.pageCount(); pageNumber++) {
const IntRect& page = printContext.pageRect(pageNumber);
if (page.x() <= left && left < page.right() && page.y() <= top && top < page.bottom())
diff --git a/Source/WebCore/page/PrintContext.h b/Source/WebCore/page/PrintContext.h
index ceda892..ce2554a 100644
--- a/Source/WebCore/page/PrintContext.h
+++ b/Source/WebCore/page/PrintContext.h
@@ -38,23 +38,38 @@ public:
PrintContext(Frame*);
~PrintContext();
- int pageCount() const;
- const IntRect& pageRect(int pageNumber) const;
+ Frame* frame() const { return m_frame; }
+
+ // Break up a page into rects without relayout.
+ // FIXME: This means that CSS page breaks won't be on page boundary if the size is different than what was passed to begin(). That's probably not always desirable.
+ // FIXME: Header and footer height should be applied before layout, not after.
+ // FIXME: The printRect argument is only used to determine page aspect ratio, it would be better to pass a FloatSize with page dimensions instead.
+ void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight, bool allowHorizontalTiling = false);
+
+ // Deprecated. Page size computation is already in this class, clients shouldn't be copying it.
+ void computePageRectsWithPageSize(const FloatSize& pageSizeInPixels, bool allowHorizontalTiling);
+
+ // These are only valid after page rects are computed.
+ size_t pageCount() const;
+ const IntRect& pageRect(size_t pageNumber) const;
const Vector<IntRect>& pageRects() const { return m_pageRects; }
- void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight);
- void computePageRectsWithPageSize(const FloatSize& pageSizeInPixels, bool allowHorizontalMultiPages);
+ float computeAutomaticScaleFactor(float availablePaperWidth);
- // TODO: eliminate width param
+ // Enter print mode, updating layout for new page size.
+ // This function can be called multiple times to apply new print options without going back to screen mode.
void begin(float width, float height = 0);
- // TODO: eliminate width param
+ // FIXME: eliminate width argument.
void spoolPage(GraphicsContext& ctx, int pageNumber, float width);
+ void spoolRect(GraphicsContext& ctx, const IntRect&);
+
+ // Return to screen mode.
void end();
// Used by layout tests.
- static int pageNumberForElement(Element*, const FloatSize& pageSizeInPixels);
+ static int pageNumberForElement(Element*, const FloatSize& pageSizeInPixels); // Returns -1 if page isn't found.
static String pageProperty(Frame* frame, const char* propertyName, int pageNumber);
static bool isPageBoxVisible(Frame* frame, int pageNumber);
static String pageSizeAndMarginsInPixels(Frame* frame, int pageNumber, int width, int height, int marginTop, int marginRight, int marginBottom, int marginLeft);
@@ -69,7 +84,7 @@ protected:
Vector<IntRect> m_pageRects;
private:
- void computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels, bool allowHorizontalMultiPages);
+ void computePageRectsWithPageSizeInternal(const FloatSize& pageSizeInPixels, bool allowHorizontalTiling);
// Used to prevent misuses of begin() and end() (e.g., call end without begin).
bool m_isPrinting;
diff --git a/Source/WebCore/page/SecurityOrigin.cpp b/Source/WebCore/page/SecurityOrigin.cpp
index 16de640..789fdf9 100644
--- a/Source/WebCore/page/SecurityOrigin.cpp
+++ b/Source/WebCore/page/SecurityOrigin.cpp
@@ -299,25 +299,30 @@ bool SecurityOrigin::isAccessWhiteListed(const SecurityOrigin* targetOrigin) con
}
return false;
}
-
+
+bool SecurityOrigin::isAccessToURLWhiteListed(const KURL& url) const
+{
+ RefPtr<SecurityOrigin> targetOrigin = SecurityOrigin::create(url);
+ return isAccessWhiteListed(targetOrigin.get());
+}
+
bool SecurityOrigin::canDisplay(const KURL& url) const
{
+ String protocol = url.protocol().lower();
+
#if ENABLE(BLOB)
- if (url.protocolIs(BlobURL::blobProtocol()))
+ // FIXME: We should generalize this check.
+ if (protocol == BlobURL::blobProtocol())
return canRequest(url);
#endif
- if (!restrictAccessToLocal())
- return true;
+ if (SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated(protocol))
+ return m_protocol == protocol || isAccessToURLWhiteListed(url);
- if (!SchemeRegistry::shouldTreatURLAsLocal(url.string()))
- return true;
+ if (restrictAccessToLocal() && SchemeRegistry::shouldTreatURLSchemeAsLocal(protocol))
+ return canLoadLocalResources() || isAccessToURLWhiteListed(url);
- RefPtr<SecurityOrigin> targetOrigin = SecurityOrigin::create(url);
- if (isAccessWhiteListed(targetOrigin.get()))
- return true;
-
- return canLoadLocalResources();
+ return true;
}
void SecurityOrigin::grantLoadLocalResources()
diff --git a/Source/WebCore/page/SecurityOrigin.h b/Source/WebCore/page/SecurityOrigin.h
index 61f6ab8..f27c593 100644
--- a/Source/WebCore/page/SecurityOrigin.h
+++ b/Source/WebCore/page/SecurityOrigin.h
@@ -193,9 +193,11 @@ private:
SecurityOrigin(const KURL&, SandboxFlags);
explicit SecurityOrigin(const SecurityOrigin*);
- bool passesFileCheck(const SecurityOrigin* other) const;
+ // FIXME: Rename this function to something more semantic.
+ bool passesFileCheck(const SecurityOrigin*) const;
- bool isAccessWhiteListed(const SecurityOrigin* targetOrigin) const;
+ bool isAccessWhiteListed(const SecurityOrigin*) const;
+ bool isAccessToURLWhiteListed(const KURL&) const;
SandboxFlags m_sandboxFlags;
String m_protocol;
diff --git a/Source/WebCore/page/android/DragControllerAndroid.cpp b/Source/WebCore/page/android/DragControllerAndroid.cpp
index b20ab60..e67daaf 100644
--- a/Source/WebCore/page/android/DragControllerAndroid.cpp
+++ b/Source/WebCore/page/android/DragControllerAndroid.cpp
@@ -32,7 +32,7 @@
namespace WebCore {
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
{
return false;
}
diff --git a/Source/WebCore/page/animation/KeyframeAnimation.cpp b/Source/WebCore/page/animation/KeyframeAnimation.cpp
index a499188..5f19fe4 100644
--- a/Source/WebCore/page/animation/KeyframeAnimation.cpp
+++ b/Source/WebCore/page/animation/KeyframeAnimation.cpp
@@ -189,7 +189,7 @@ void KeyframeAnimation::animate(CompositeAnimation*, RenderObject*, const Render
// Get the from/to styles and progress between
const RenderStyle* fromStyle = 0;
const RenderStyle* toStyle = 0;
- double progress;
+ double progress = 0.0;
fetchIntervalEndpointsForProperty(property, fromStyle, toStyle, progress);
bool needsAnim = blendProperties(this, property, animatedStyle.get(), fromStyle, toStyle, progress);
@@ -226,7 +226,7 @@ void KeyframeAnimation::getAnimatedStyle(RefPtr<RenderStyle>& animatedStyle)
// Get the from/to styles and progress between
const RenderStyle* fromStyle = 0;
const RenderStyle* toStyle = 0;
- double progress;
+ double progress = 0.0;
fetchIntervalEndpointsForProperty(property, fromStyle, toStyle, progress);
blendProperties(this, property, animatedStyle.get(), fromStyle, toStyle, progress);
diff --git a/Source/WebCore/page/brew/DragControllerBrew.cpp b/Source/WebCore/page/brew/DragControllerBrew.cpp
index ef89821..5878c24 100644
--- a/Source/WebCore/page/brew/DragControllerBrew.cpp
+++ b/Source/WebCore/page/brew/DragControllerBrew.cpp
@@ -41,7 +41,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
{
return false;
}
diff --git a/Source/WebCore/page/chromium/DragControllerChromium.cpp b/Source/WebCore/page/chromium/DragControllerChromium.cpp
index de53d19..e17972d 100644
--- a/Source/WebCore/page/chromium/DragControllerChromium.cpp
+++ b/Source/WebCore/page/chromium/DragControllerChromium.cpp
@@ -51,10 +51,10 @@ DragOperation DragController::dragOperation(DragData* dragData)
// attached sheet If this can be determined from within WebCore
// operationForDrag can be pulled into WebCore itself
ASSERT(dragData);
- return dragData->containsURL() && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
+ return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
}
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
{
// FIXME: This should not be OS specific. Delegate to the embedder instead.
#if OS(WINDOWS)
diff --git a/Source/WebCore/page/chromium/FrameChromium.cpp b/Source/WebCore/page/chromium/FrameChromium.cpp
index 15ff8b4..f6f47a6 100644
--- a/Source/WebCore/page/chromium/FrameChromium.cpp
+++ b/Source/WebCore/page/chromium/FrameChromium.cpp
@@ -28,6 +28,7 @@
#include "Document.h"
#include "FloatRect.h"
+#include "GraphicsContext.h"
#include "ImageBuffer.h"
#include "RenderView.h"
#include "Settings.h"
diff --git a/Source/WebCore/page/efl/DragControllerEfl.cpp b/Source/WebCore/page/efl/DragControllerEfl.cpp
index 0c5f002..f5c0ecc 100644
--- a/Source/WebCore/page/efl/DragControllerEfl.cpp
+++ b/Source/WebCore/page/efl/DragControllerEfl.cpp
@@ -43,14 +43,14 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
{
return false;
}
DragOperation DragController::dragOperation(DragData* dragData)
{
- if (dragData->containsURL())
+ if (dragData->containsURL(0))
return DragOperationCopy;
return DragOperationNone;
diff --git a/Source/WebCore/page/gtk/DragControllerGtk.cpp b/Source/WebCore/page/gtk/DragControllerGtk.cpp
index 5f9044f..29749e2 100644
--- a/Source/WebCore/page/gtk/DragControllerGtk.cpp
+++ b/Source/WebCore/page/gtk/DragControllerGtk.cpp
@@ -42,7 +42,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
{
return false;
}
@@ -50,7 +50,7 @@ bool DragController::isCopyKeyDown()
DragOperation DragController::dragOperation(DragData* dragData)
{
//FIXME: This logic is incomplete
- if (dragData->containsURL())
+ if (dragData->containsURL(0))
return DragOperationCopy;
return DragOperationNone;
diff --git a/Source/WebCore/page/haiku/DragControllerHaiku.cpp b/Source/WebCore/page/haiku/DragControllerHaiku.cpp
index ef08ac2..de8ca81 100644
--- a/Source/WebCore/page/haiku/DragControllerHaiku.cpp
+++ b/Source/WebCore/page/haiku/DragControllerHaiku.cpp
@@ -44,7 +44,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
{
if (modifiers() & B_COMMAND_KEY)
return true;
diff --git a/Source/WebCore/page/mac/DragControllerMac.mm b/Source/WebCore/page/mac/DragControllerMac.mm
index 05c8e09..9b61510 100644
--- a/Source/WebCore/page/mac/DragControllerMac.mm
+++ b/Source/WebCore/page/mac/DragControllerMac.mm
@@ -42,19 +42,19 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData* dragData)
{
- return [[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask;
+ return dragData->flags() & DragApplicationIsCopyKeyDown;
}
DragOperation DragController::dragOperation(DragData* dragData)
{
ASSERT(dragData);
- if ([NSApp modalWindow] || !dragData->containsURL())
+
+ if ((dragData->flags() & DragApplicationIsModal) || !dragData->containsURL(m_page->mainFrame()))
return DragOperationNone;
- if (!m_documentUnderMouse || (![[m_page->mainFrame()->view()->getOuterView() window] attachedSheet]
- && [dragData->platformData() draggingSource] != m_page->mainFrame()->view()->getOuterView()))
+ if (!m_documentUnderMouse || (!(dragData->flags() & (DragApplicationHasAttachedSheet | DragApplicationIsSource))))
return DragOperationCopy;
return DragOperationNone;
diff --git a/Source/WebCore/page/mac/FrameMac.mm b/Source/WebCore/page/mac/FrameMac.mm
index d4e4098..b49fffb 100644
--- a/Source/WebCore/page/mac/FrameMac.mm
+++ b/Source/WebCore/page/mac/FrameMac.mm
@@ -255,50 +255,33 @@ NSString* Frame::matchLabelsAgainstElement(NSArray* labels, Element* element)
NSImage* Frame::imageFromRect(NSRect rect) const
{
- NSView* view = m_view->documentView();
- if (!view)
- return nil;
- if (![view respondsToSelector:@selector(drawSingleRect:)])
- return nil;
+ PaintBehavior oldBehavior = m_view->paintBehavior();
+ m_view->setPaintBehavior(oldBehavior | PaintBehaviorFlattenCompositingLayers);
- PaintBehavior oldPaintBehavior = m_view->paintBehavior();
- m_view->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompositingLayers);
-
BEGIN_BLOCK_OBJC_EXCEPTIONS;
- NSRect bounds = [view bounds];
-
- // Round image rect size in window coordinate space to avoid pixel cracks at HiDPI (4622794)
- rect = [view convertRect:rect toView:nil];
- rect.size.height = roundf(rect.size.height);
- rect.size.width = roundf(rect.size.width);
- rect = [view convertRect:rect fromView:nil];
-
NSImage* resultImage = [[[NSImage alloc] initWithSize:rect.size] autorelease];
-
+
if (rect.size.width != 0 && rect.size.height != 0) {
[resultImage setFlipped:YES];
[resultImage lockFocus];
- CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
- CGContextSaveGState(context);
- CGContextTranslateCTM(context, bounds.origin.x - rect.origin.x, bounds.origin.y - rect.origin.y);
- // Note: Must not call drawRect: here, because drawRect: assumes that it's called from AppKit's
- // display machinery. It calls getRectsBeingDrawn:count:, which can only be called inside
- // when a real AppKit display is underway.
- [view drawSingleRect:rect];
+ GraphicsContext graphicsContext((CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]);
+ graphicsContext.save();
+ graphicsContext.translate(-rect.origin.x, -rect.origin.y);
+ m_view->paintContents(&graphicsContext, IntRect(rect));
+ graphicsContext.restore();
- CGContextRestoreGState(context);
[resultImage unlockFocus];
[resultImage setFlipped:NO];
}
-
- m_view->setPaintBehavior(oldPaintBehavior);
+
+ m_view->setPaintBehavior(oldBehavior);
return resultImage;
-
+
END_BLOCK_OBJC_EXCEPTIONS;
- m_view->setPaintBehavior(oldPaintBehavior);
+ m_view->setPaintBehavior(oldBehavior);
return nil;
}
diff --git a/Source/WebCore/page/qt/DragControllerQt.cpp b/Source/WebCore/page/qt/DragControllerQt.cpp
index 33815b5..cdea55b 100644
--- a/Source/WebCore/page/qt/DragControllerQt.cpp
+++ b/Source/WebCore/page/qt/DragControllerQt.cpp
@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
{
return false;
}
@@ -51,7 +51,7 @@ bool DragController::isCopyKeyDown()
DragOperation DragController::dragOperation(DragData* dragData)
{
//FIXME: This logic is incomplete
- if (dragData->containsURL())
+ if (dragData->containsURL(0))
return DragOperationCopy;
return DragOperationNone;
diff --git a/Source/WebCore/page/qt/FrameQt.cpp b/Source/WebCore/page/qt/FrameQt.cpp
index 467592c..bb577e0 100644
--- a/Source/WebCore/page/qt/FrameQt.cpp
+++ b/Source/WebCore/page/qt/FrameQt.cpp
@@ -24,6 +24,7 @@
#include "config.h"
#include "Frame.h"
#include "FrameView.h"
+#include "GraphicsContext.h"
#include "Image.h"
#include "ImageBuffer.h"
diff --git a/Source/WebCore/page/win/DragControllerWin.cpp b/Source/WebCore/page/win/DragControllerWin.cpp
index f0404ff..6b1cd3e 100644
--- a/Source/WebCore/page/win/DragControllerWin.cpp
+++ b/Source/WebCore/page/win/DragControllerWin.cpp
@@ -47,10 +47,10 @@ DragOperation DragController::dragOperation(DragData* dragData)
//If this can be determined from within WebCore operationForDrag can be pulled into
//WebCore itself
ASSERT(dragData);
- return dragData->containsURL() && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
+ return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
}
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
{
return ::GetAsyncKeyState(VK_CONTROL);
}
diff --git a/Source/WebCore/page/wx/DragControllerWx.cpp b/Source/WebCore/page/wx/DragControllerWx.cpp
index c288a01..4a4d064 100644
--- a/Source/WebCore/page/wx/DragControllerWx.cpp
+++ b/Source/WebCore/page/wx/DragControllerWx.cpp
@@ -43,7 +43,7 @@ const int DragController::DragIconBottomInset = 3;
const float DragController::DragImageAlpha = 0.75f;
-bool DragController::isCopyKeyDown()
+bool DragController::isCopyKeyDown(DragData*)
{
notImplemented();
return false;