summaryrefslogtreecommitdiff
path: root/Source/WebCore/page/DragController.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
commitcd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch)
tree8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/WebCore/page/DragController.cpp
parentd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff)
downloadqtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/WebCore/page/DragController.cpp')
-rw-r--r--Source/WebCore/page/DragController.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/Source/WebCore/page/DragController.cpp b/Source/WebCore/page/DragController.cpp
index 5d834df84..a47b6a4bc 100644
--- a/Source/WebCore/page/DragController.cpp
+++ b/Source/WebCore/page/DragController.cpp
@@ -27,7 +27,7 @@
#include "DragController.h"
#if ENABLE(DRAG_SUPPORT)
-#include "CSSStyleDeclaration.h"
+#include "CSSMutableStyleDeclaration.h"
#include "Clipboard.h"
#include "ClipboardAccessPolicy.h"
#include "CachedResourceLoader.h"
@@ -201,19 +201,21 @@ bool DragController::performDrag(DragData* dragData)
{
ASSERT(dragData);
m_documentUnderMouse = m_page->mainFrame()->documentAtPoint(dragData->clientPosition());
- if (m_isHandlingDrag) {
- ASSERT(m_dragDestinationAction & DragDestinationActionDHTML);
+ if (m_dragDestinationAction & DragDestinationActionDHTML) {
m_client->willPerformDragDestinationAction(DragDestinationActionDHTML, dragData);
RefPtr<Frame> mainFrame = m_page->mainFrame();
+ bool preventedDefault = false;
if (mainFrame->view()) {
// Sending an event can result in the destruction of the view and part.
RefPtr<Clipboard> clipboard = Clipboard::create(ClipboardReadable, dragData, mainFrame.get());
clipboard->setSourceOperation(dragData->draggingSourceOperationMask());
- mainFrame->eventHandler()->performDragAndDrop(createMouseEvent(dragData), clipboard.get());
- clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard here for security
+ preventedDefault = mainFrame->eventHandler()->performDragAndDrop(createMouseEvent(dragData), clipboard.get());
+ clipboard->setAccessPolicy(ClipboardNumb); // Invalidate clipboard here for security
+ }
+ if (m_isHandlingDrag || preventedDefault) {
+ m_documentUnderMouse = 0;
+ return true;
}
- m_documentUnderMouse = 0;
- return true;
}
if ((m_dragDestinationAction & DragDestinationActionEdit) && concludeEditDrag(dragData)) {
@@ -268,8 +270,8 @@ static HTMLInputElement* asFileInput(Node* node)
HTMLInputElement* inputElement = node->toInputElement();
// If this is a button inside of the a file input, move up to the file input.
- if (inputElement && inputElement->isTextButton() && inputElement->treeScope()->isShadowRoot())
- inputElement = inputElement->treeScope()->shadowHost()->toInputElement();
+ if (inputElement && inputElement->isTextButton() && inputElement->treeScope()->rootNode()->isShadowRoot())
+ inputElement = inputElement->treeScope()->rootNode()->shadowHost()->toInputElement();
return inputElement && inputElement->isFileUpload() ? inputElement : 0;
}
@@ -357,6 +359,8 @@ bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction a
dragSession.numberOfItemsToBeAccepted = 0;
else if (m_fileInputElementUnderMouse->multiple())
dragSession.numberOfItemsToBeAccepted = numberOfFiles;
+ else if (numberOfFiles > 1)
+ dragSession.numberOfItemsToBeAccepted = 0;
else
dragSession.numberOfItemsToBeAccepted = 1;
@@ -443,9 +447,8 @@ bool DragController::concludeEditDrag(DragData* dragData)
if (!color.isValid())
return false;
RefPtr<Range> innerRange = innerFrame->selection()->toNormalizedRange();
- RefPtr<CSSStyleDeclaration> style = m_documentUnderMouse->createCSSStyleDeclaration();
- ExceptionCode ec;
- style->setProperty(CSSPropertyColor, color.serialized(), false, ec);
+ RefPtr<CSSMutableStyleDeclaration> style = CSSMutableStyleDeclaration::create();
+ style->setProperty(CSSPropertyColor, color.serialized(), false);
if (!innerFrame->editor()->shouldApplyStyle(style.get(), innerRange.get()))
return false;
m_client->willPerformDragDestinationAction(DragDestinationActionEdit, dragData);
@@ -477,6 +480,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
VisibleSelection dragCaret = m_page->dragCaretController()->caretPosition();
m_page->dragCaretController()->clear();
RefPtr<Range> range = dragCaret.toNormalizedRange();
+ RefPtr<Element> rootEditableElement = innerFrame->selection()->rootEditableElement();
// For range to be null a WebKit client must have done something bad while
// manually controlling drag behaviour
@@ -519,6 +523,11 @@ bool DragController::concludeEditDrag(DragData* dragData)
applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.get(), createFragmentFromText(range.get(), text), ReplaceSelectionCommand::SelectReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::PreventNesting));
}
+ if (rootEditableElement) {
+ if (Frame* frame = rootEditableElement->document()->frame())
+ frame->eventHandler()->updateDragStateAfterEditDragIfNeeded(rootEditableElement.get());
+ }
+
return true;
}