summaryrefslogtreecommitdiffstats
path: root/WebCore/editing/SelectionController.cpp
diff options
context:
space:
mode:
authorFeng Qian <>2009-04-10 18:11:29 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-10 18:11:29 -0700
commit8f72e70a9fd78eec56623b3a62e68f16b7b27e28 (patch)
tree181bf9a400c30a1bf34ea6d72560e8d00111d549 /WebCore/editing/SelectionController.cpp
parent7ed56f225e0ade046e1c2178977f72b2d896f196 (diff)
downloadexternal_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.zip
external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.tar.gz
external_webkit-8f72e70a9fd78eec56623b3a62e68f16b7b27e28.tar.bz2
AI 145796: Land the WebKit merge @r42026.
Automated import of CL 145796
Diffstat (limited to 'WebCore/editing/SelectionController.cpp')
-rw-r--r--WebCore/editing/SelectionController.cpp67
1 files changed, 32 insertions, 35 deletions
diff --git a/WebCore/editing/SelectionController.cpp b/WebCore/editing/SelectionController.cpp
index 67f675e..d606891 100644
--- a/WebCore/editing/SelectionController.cpp
+++ b/WebCore/editing/SelectionController.cpp
@@ -76,30 +76,30 @@ SelectionController::SelectionController(Frame* frame, bool isDragCaretControlle
void SelectionController::moveTo(const VisiblePosition &pos, bool userTriggered)
{
- setSelection(Selection(pos.deepEquivalent(), pos.deepEquivalent(), pos.affinity()), true, true, userTriggered);
+ setSelection(VisibleSelection(pos.deepEquivalent(), pos.deepEquivalent(), pos.affinity()), true, true, userTriggered);
}
void SelectionController::moveTo(const VisiblePosition &base, const VisiblePosition &extent, bool userTriggered)
{
- setSelection(Selection(base.deepEquivalent(), extent.deepEquivalent(), base.affinity()), true, true, userTriggered);
+ setSelection(VisibleSelection(base.deepEquivalent(), extent.deepEquivalent(), base.affinity()), true, true, userTriggered);
}
void SelectionController::moveTo(const Position &pos, EAffinity affinity, bool userTriggered)
{
- setSelection(Selection(pos, affinity), true, true, userTriggered);
+ setSelection(VisibleSelection(pos, affinity), true, true, userTriggered);
}
void SelectionController::moveTo(const Range *r, EAffinity affinity, bool userTriggered)
{
- setSelection(Selection(startPosition(r), endPosition(r), affinity), true, true, userTriggered);
+ setSelection(VisibleSelection(startPosition(r), endPosition(r), affinity), true, true, userTriggered);
}
void SelectionController::moveTo(const Position &base, const Position &extent, EAffinity affinity, bool userTriggered)
{
- setSelection(Selection(base, extent, affinity), true, true, userTriggered);
+ setSelection(VisibleSelection(base, extent, affinity), true, true, userTriggered);
}
-void SelectionController::setSelection(const Selection& s, bool closeTyping, bool clearTypingStyle, bool userTriggered)
+void SelectionController::setSelection(const VisibleSelection& s, bool closeTyping, bool clearTypingStyle, bool userTriggered)
{
if (m_isDragCaretController) {
invalidateCaretRect();
@@ -134,7 +134,7 @@ void SelectionController::setSelection(const Selection& s, bool closeTyping, boo
if (m_sel == s)
return;
- Selection oldSelection = m_sel;
+ VisibleSelection oldSelection = m_sel;
m_sel = s;
@@ -151,7 +151,7 @@ void SelectionController::setSelection(const Selection& s, bool closeTyping, boo
m_frame->notifyRendererOfSelectionChange(userTriggered);
m_frame->respondToChangedSelection(oldSelection, closeTyping);
if (userTriggered)
- m_frame->revealCaret(RenderLayer::gAlignToEdgeIfNeeded);
+ m_frame->revealSelection(ScrollAlignment::alignToEdgeIfNeeded, true);
notifyAccessibilityForSelectionChange();
}
@@ -215,12 +215,12 @@ void SelectionController::nodeWillBeRemoved(Node *node)
if (clearRenderTreeSelection) {
RefPtr<Document> document = m_sel.start().node()->document();
document->updateRendering();
- if (RenderView* view = static_cast<RenderView*>(document->renderer()))
+ if (RenderView* view = toRenderView(document->renderer()))
view->clearSelection();
}
if (clearDOMTreeSelection)
- setSelection(Selection(), false, false);
+ setSelection(VisibleSelection(), false, false);
}
void SelectionController::willBeModified(EAlteration alter, EDirection direction)
@@ -700,27 +700,27 @@ int SelectionController::xPosForVerticalArrowNavigation(EPositionType type)
void SelectionController::clear()
{
- setSelection(Selection());
+ setSelection(VisibleSelection());
}
void SelectionController::setBase(const VisiblePosition &pos, bool userTriggered)
{
- setSelection(Selection(pos.deepEquivalent(), m_sel.extent(), pos.affinity()), true, true, userTriggered);
+ setSelection(VisibleSelection(pos.deepEquivalent(), m_sel.extent(), pos.affinity()), true, true, userTriggered);
}
void SelectionController::setExtent(const VisiblePosition &pos, bool userTriggered)
{
- setSelection(Selection(m_sel.base(), pos.deepEquivalent(), pos.affinity()), true, true, userTriggered);
+ setSelection(VisibleSelection(m_sel.base(), pos.deepEquivalent(), pos.affinity()), true, true, userTriggered);
}
void SelectionController::setBase(const Position &pos, EAffinity affinity, bool userTriggered)
{
- setSelection(Selection(pos, m_sel.extent(), affinity), true, true, userTriggered);
+ setSelection(VisibleSelection(pos, m_sel.extent(), affinity), true, true, userTriggered);
}
void SelectionController::setExtent(const Position &pos, EAffinity affinity, bool userTriggered)
{
- setSelection(Selection(m_sel.base(), pos, affinity), true, true, userTriggered);
+ setSelection(VisibleSelection(m_sel.base(), pos, affinity), true, true, userTriggered);
}
void SelectionController::setNeedsLayout(bool flag)
@@ -830,7 +830,7 @@ IntRect SelectionController::caretRepaintRect() const
bool SelectionController::recomputeCaretRect()
{
- if (!m_frame || !m_frame->document())
+ if (!m_frame)
return false;
FrameView* v = m_frame->document()->view();
@@ -853,9 +853,10 @@ bool SelectionController::recomputeCaretRect()
if (oldAbsRepaintRect == m_absCaretBounds)
return false;
- if (RenderView* view = static_cast<RenderView*>(m_frame->document()->renderer())) {
- view->repaintViewRectangle(oldAbsRepaintRect, false);
- view->repaintViewRectangle(m_absCaretBounds, false);
+ if (RenderView* view = toRenderView(m_frame->document()->renderer())) {
+ // FIXME: make caret repainting container-aware.
+ view->repaintRectangleInViewAndCompositedLayers(oldAbsRepaintRect, false);
+ view->repaintRectangleInViewAndCompositedLayers(m_absCaretBounds, false);
}
return true;
@@ -886,8 +887,8 @@ void SelectionController::invalidateCaretRect()
m_needsLayout = true;
if (!caretRectChanged) {
- if (RenderView* view = static_cast<RenderView*>(d->renderer()))
- view->repaintViewRectangle(caretRepaintRect(), false);
+ if (RenderView* view = toRenderView(d->renderer()))
+ view->repaintRectangleInViewAndCompositedLayers(caretRepaintRect(), false);
}
}
@@ -931,9 +932,9 @@ void SelectionController::debugRenderer(RenderObject *r, bool selected) const
if (selected) {
int offset = 0;
if (r->node() == m_sel.start().node())
- offset = m_sel.start().offset();
+ offset = m_sel.start().m_offset;
else if (r->node() == m_sel.end().node())
- offset = m_sel.end().offset();
+ offset = m_sel.end().m_offset;
int pos;
InlineTextBox *box = textRenderer->findNextInlineTextBox(offset, pos);
@@ -995,7 +996,8 @@ bool SelectionController::contains(const IntPoint& point)
if (!document->renderer())
return false;
- HitTestRequest request(true, true);
+ HitTestRequest request(HitTestRequest::ReadOnly |
+ HitTestRequest::Active);
HitTestResult result(point);
document->renderView()->layer()->hitTest(request, result);
Node* innerNode = result.innerNode();
@@ -1041,8 +1043,6 @@ void SelectionController::selectFrameElementInParentIfFullySelected()
// Get to the <iframe> or <frame> (or even <object>) element in the parent frame.
Document* doc = m_frame->document();
- if (!doc)
- return;
Element* ownerElement = doc->ownerElement();
if (!ownerElement)
return;
@@ -1060,7 +1060,7 @@ void SelectionController::selectFrameElementInParentIfFullySelected()
VisiblePosition afterOwnerElement(VisiblePosition(ownerElementParent, ownerElementNodeIndex + 1, VP_UPSTREAM_IF_POSSIBLE));
// Focus on the parent frame, and then select from before this element to after.
- Selection newSelection(beforeOwnerElement, afterOwnerElement);
+ VisibleSelection newSelection(beforeOwnerElement, afterOwnerElement);
if (parent->shouldChangeSelection(newSelection)) {
page->focusController()->setFocusedFrame(parent);
parent->selection()->setSelection(newSelection);
@@ -1070,8 +1070,6 @@ void SelectionController::selectFrameElementInParentIfFullySelected()
void SelectionController::selectAll()
{
Document* document = m_frame->document();
- if (!document)
- return;
if (document->focusedNode() && document->focusedNode()->canSelectAll()) {
document->focusedNode()->selectAll();
@@ -1088,7 +1086,7 @@ void SelectionController::selectAll()
}
if (!root)
return;
- Selection newSelection(Selection::selectionFromContentsOfNode(root));
+ VisibleSelection newSelection(VisibleSelection::selectionFromContentsOfNode(root));
if (m_frame->shouldChangeSelection(newSelection))
setSelection(newSelection);
selectFrameElementInParentIfFullySelected();
@@ -1132,7 +1130,7 @@ bool SelectionController::setSelectedRange(Range* range, EAffinity affinity, boo
// FIXME: Can we provide extentAffinity?
VisiblePosition visibleStart(startContainer, startOffset, collapsed ? affinity : DOWNSTREAM);
VisiblePosition visibleEnd(endContainer, endOffset, SEL_DEFAULT_AFFINITY);
- setSelection(Selection(visibleStart, visibleEnd), closeTyping);
+ setSelection(VisibleSelection(visibleStart, visibleEnd), closeTyping);
return true;
}
@@ -1166,8 +1164,8 @@ void SelectionController::focusedOrActiveStateChanged()
// Because RenderObject::selectionBackgroundColor() and
// RenderObject::selectionForegroundColor() check if the frame is active,
// we have to update places those colors were painted.
- if (RenderView* view = static_cast<RenderView*>(m_frame->document()->renderer()))
- view->repaintViewRectangle(enclosingIntRect(m_frame->selectionBounds()));
+ if (RenderView* view = toRenderView(m_frame->document()->renderer()))
+ view->repaintRectangleInViewAndCompositedLayers(enclosingIntRect(m_frame->selectionBounds()));
// Caret appears in the active frame.
if (activeAndFocused)
@@ -1205,8 +1203,7 @@ void SelectionController::setFocused(bool flag)
focusedOrActiveStateChanged();
- if (Document* doc = m_frame->document())
- doc->dispatchWindowEvent(flag ? eventNames().focusEvent : eventNames().blurEvent, false, false);
+ m_frame->document()->dispatchWindowEvent(flag ? eventNames().focusEvent : eventNames().blurEvent, false, false);
}
bool SelectionController::isFocusedAndActive() const