Commit b5297527 authored by akling@apple.com's avatar akling@apple.com

<https://webkit.org/b/119954> Page::dragCaretController() should return a reference.

Reviewed by Antti Koivisto.

Page::m_dragCaretController is never null.

* dom/Document.cpp:
(WebCore::Document::nodeChildrenWillBeRemoved):
(WebCore::Document::nodeWillBeRemoved):
* page/DragController.cpp:
(WebCore::DragController::cancelDrag):
(WebCore::DragController::dragEnded):
(WebCore::DragController::tryDocumentDrag):
(WebCore::DragController::dispatchTextInputEventFor):
(WebCore::DragController::concludeEditDrag):
(WebCore::DragController::placeDragCaret):
* page/Page.h:
(WebCore::Page::dragCaretController):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintCaret):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154238 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 976b412f
2013-08-17 Andreas Kling <akling@apple.com>
<https://webkit.org/b/119954> Page::dragCaretController() should return a reference.
Reviewed by Antti Koivisto.
Page::m_dragCaretController is never null.
* dom/Document.cpp:
(WebCore::Document::nodeChildrenWillBeRemoved):
(WebCore::Document::nodeWillBeRemoved):
* page/DragController.cpp:
(WebCore::DragController::cancelDrag):
(WebCore::DragController::dragEnded):
(WebCore::DragController::tryDocumentDrag):
(WebCore::DragController::dispatchTextInputEventFor):
(WebCore::DragController::concludeEditDrag):
(WebCore::DragController::placeDragCaret):
* page/Page.h:
(WebCore::Page::dragCaretController):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintCaret):
2013-08-17 Andreas Kling <akling@apple.com>
<https://webkit.org/b/119952> Simplify Editor's back-pointer to the Frame.
......@@ -3464,7 +3464,7 @@ void Document::nodeChildrenWillBeRemoved(ContainerNode* container)
for (Node* n = container->firstChild(); n; n = n->nextSibling()) {
frame->eventHandler().nodeWillBeRemoved(n);
frame->selection()->nodeWillBeRemoved(n);
frame->page()->dragCaretController()->nodeWillBeRemoved(n);
frame->page()->dragCaretController().nodeWillBeRemoved(n);
}
}
}
......@@ -3484,7 +3484,7 @@ void Document::nodeWillBeRemoved(Node* n)
if (Frame* frame = this->frame()) {
frame->eventHandler().nodeWillBeRemoved(n);
frame->selection()->nodeWillBeRemoved(n);
frame->page()->dragCaretController()->nodeWillBeRemoved(n);
frame->page()->dragCaretController().nodeWillBeRemoved(n);
}
}
......
......@@ -172,14 +172,14 @@ bool DragController::dragIsMove(FrameSelection* selection, DragData* dragData)
// FIXME: This method is poorly named. We're just clearing the selection from the document this drag is exiting.
void DragController::cancelDrag()
{
m_page->dragCaretController()->clear();
m_page->dragCaretController().clear();
}
void DragController::dragEnded()
{
m_dragInitiator = 0;
m_didInitiateDrag = false;
m_page->dragCaretController()->clear();
m_page->dragCaretController().clear();
m_client->dragEnded();
}
......@@ -340,7 +340,7 @@ bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction a
return false;
if (isHandlingDrag) {
m_page->dragCaretController()->clear();
m_page->dragCaretController().clear();
return true;
}
......@@ -363,7 +363,7 @@ bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction a
}
if (!m_fileInputElementUnderMouse)
m_page->dragCaretController()->setCaretPosition(m_documentUnderMouse->frame()->visiblePositionForPoint(point));
m_page->dragCaretController().setCaretPosition(m_documentUnderMouse->frame()->visiblePositionForPoint(point));
Frame* innerFrame = element->document()->frame();
dragSession.operation = dragIsMove(innerFrame->selection(), dragData) ? DragOperationMove : DragOperationCopy;
......@@ -394,7 +394,7 @@ bool DragController::tryDocumentDrag(DragData* dragData, DragDestinationAction a
}
// We are not over an editable region. Make sure we're clearing any prior drag cursor.
m_page->dragCaretController()->clear();
m_page->dragCaretController().clear();
if (m_fileInputElementUnderMouse)
m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false);
m_fileInputElementUnderMouse = 0;
......@@ -440,9 +440,9 @@ static bool setSelectionToDragCaret(Frame* frame, VisibleSelection& dragCaret, R
bool DragController::dispatchTextInputEventFor(Frame* innerFrame, DragData* dragData)
{
ASSERT(m_page->dragCaretController()->hasCaret());
String text = m_page->dragCaretController()->isContentRichlyEditable() ? "" : dragData->asPlainText(innerFrame);
Node* target = innerFrame->editor().findEventTargetFrom(m_page->dragCaretController()->caretPosition());
ASSERT(m_page->dragCaretController().hasCaret());
String text = m_page->dragCaretController().isContentRichlyEditable() ? "" : dragData->asPlainText(innerFrame);
Node* target = innerFrame->editor().findEventTargetFrom(m_page->dragCaretController().caretPosition());
return target->dispatchEvent(TextEvent::createForDrop(innerFrame->document()->domWindow(), text), IGNORE_EXCEPTION);
}
......@@ -466,7 +466,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
RefPtr<Frame> innerFrame = element->document()->frame();
ASSERT(innerFrame);
if (m_page->dragCaretController()->hasCaret() && !dispatchTextInputEventFor(innerFrame.get(), dragData))
if (m_page->dragCaretController().hasCaret() && !dispatchTextInputEventFor(innerFrame.get(), dragData))
return true;
if (dragData->containsColor()) {
......@@ -494,12 +494,12 @@ bool DragController::concludeEditDrag(DragData* dragData)
}
if (!m_page->dragController().canProcessDrag(dragData)) {
m_page->dragCaretController()->clear();
m_page->dragCaretController().clear();
return false;
}
VisibleSelection dragCaret = m_page->dragCaretController()->caretPosition();
m_page->dragCaretController()->clear();
VisibleSelection dragCaret = m_page->dragCaretController().caretPosition();
m_page->dragCaretController().clear();
RefPtr<Range> range = dragCaret.toNormalizedRange();
RefPtr<Element> rootEditableElement = innerFrame->selection()->rootEditableElement();
......@@ -941,7 +941,7 @@ void DragController::placeDragCaret(const IntPoint& windowPoint)
return;
IntPoint framePoint = frameView->windowToContents(windowPoint);
m_page->dragCaretController()->setCaretPosition(frame->visiblePositionForPoint(framePoint));
m_page->dragCaretController().setCaretPosition(frame->visiblePositionForPoint(framePoint));
}
} // namespace WebCore
......
......@@ -185,7 +185,7 @@ public:
int subframeCount() const { checkSubframeCountConsistency(); return m_subframeCount; }
Chrome& chrome() const { return *m_chrome; }
DragCaretController* dragCaretController() const { return m_dragCaretController.get(); }
DragCaretController& dragCaretController() const { return *m_dragCaretController; }
#if ENABLE(DRAG_SUPPORT)
DragController& dragController() const { return *m_dragController; }
#endif
......@@ -440,10 +440,10 @@ private:
void unthrottleTimers();
const OwnPtr<Chrome> m_chrome;
OwnPtr<DragCaretController> m_dragCaretController;
const OwnPtr<DragCaretController> m_dragCaretController;
#if ENABLE(DRAG_SUPPORT)
OwnPtr<DragController> m_dragController;
const OwnPtr<DragController> m_dragController;
#endif
const OwnPtr<FocusController> m_focusController;
#if ENABLE(CONTEXT_MENUS)
......
......@@ -3279,15 +3279,15 @@ void RenderBlock::paintCaret(PaintInfo& paintInfo, const LayoutPoint& paintOffse
caretPainter = frame()->selection()->caretRenderer();
isContentEditable = frame()->selection()->rendererIsEditable();
} else {
caretPainter = frame()->page()->dragCaretController()->caretRenderer();
isContentEditable = frame()->page()->dragCaretController()->isContentEditable();
caretPainter = frame()->page()->dragCaretController().caretRenderer();
isContentEditable = frame()->page()->dragCaretController().isContentEditable();
}
if (caretPainter == this && (isContentEditable || caretBrowsing)) {
if (type == CursorCaret)
frame()->selection()->paintCaret(paintInfo.context, paintOffset, paintInfo.rect);
else
frame()->page()->dragCaretController()->paintDragCaret(frame(), paintInfo.context, paintOffset, paintInfo.rect);
frame()->page()->dragCaretController().paintDragCaret(frame(), paintInfo.context, paintOffset, paintInfo.rect);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment