OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 clearCaretRect(); | 1241 clearCaretRect(); |
1242 } else { | 1242 } else { |
1243 if (isTextFormControl(m_selection)) | 1243 if (isTextFormControl(m_selection)) |
1244 updateCaretRect(m_frame->document(), PositionWithAffinity(m_selectio
n.start().isCandidate() ? m_selection.start() : Position(), m_selection.affinity
())); | 1244 updateCaretRect(m_frame->document(), PositionWithAffinity(m_selectio
n.start().isCandidate() ? m_selection.start() : Position(), m_selection.affinity
())); |
1245 else | 1245 else |
1246 updateCaretRect(m_frame->document(), VisiblePosition(m_selection.sta
rt(), m_selection.affinity())); | 1246 updateCaretRect(m_frame->document(), VisiblePosition(m_selection.sta
rt(), m_selection.affinity())); |
1247 } | 1247 } |
1248 return absoluteBoundsForLocalRect(m_selection.start().deprecatedNode(), loca
lCaretRectWithoutUpdate()); | 1248 return absoluteBoundsForLocalRect(m_selection.start().deprecatedNode(), loca
lCaretRectWithoutUpdate()); |
1249 } | 1249 } |
1250 | 1250 |
1251 static LayoutRect localCaretRect(const VisibleSelection& m_selection, const Posi
tionWithAffinity& caretPosition, RenderObject*& renderer) | 1251 static LayoutRect localCaretRect(const VisibleSelection& m_selection, const Posi
tionWithAffinity& caretPosition, LayoutObject*& renderer) |
1252 { | 1252 { |
1253 renderer = nullptr; | 1253 renderer = nullptr; |
1254 if (!isNonOrphanedCaret(m_selection)) | 1254 if (!isNonOrphanedCaret(m_selection)) |
1255 return LayoutRect(); | 1255 return LayoutRect(); |
1256 | 1256 |
1257 return localCaretRectOfPosition(caretPosition, renderer); | 1257 return localCaretRectOfPosition(caretPosition, renderer); |
1258 } | 1258 } |
1259 | 1259 |
1260 void FrameSelection::invalidateCaretRect() | 1260 void FrameSelection::invalidateCaretRect() |
1261 { | 1261 { |
1262 if (!m_caretRectDirty) | 1262 if (!m_caretRectDirty) |
1263 return; | 1263 return; |
1264 m_caretRectDirty = false; | 1264 m_caretRectDirty = false; |
1265 | 1265 |
1266 RenderObject* renderer = nullptr; | 1266 LayoutObject* renderer = nullptr; |
1267 LayoutRect newRect = localCaretRect(m_selection, PositionWithAffinity(m_sele
ction.start(), m_selection.affinity()), renderer); | 1267 LayoutRect newRect = localCaretRect(m_selection, PositionWithAffinity(m_sele
ction.start(), m_selection.affinity()), renderer); |
1268 Node* newNode = renderer ? renderer->node() : nullptr; | 1268 Node* newNode = renderer ? renderer->node() : nullptr; |
1269 | 1269 |
1270 if (!m_caretBlinkTimer.isActive() && newNode == m_previousCaretNode && newRe
ct == m_previousCaretRect) | 1270 if (!m_caretBlinkTimer.isActive() && newNode == m_previousCaretNode && newRe
ct == m_previousCaretRect) |
1271 return; | 1271 return; |
1272 | 1272 |
1273 RenderView* view = m_frame->document()->renderView(); | 1273 RenderView* view = m_frame->document()->renderView(); |
1274 if (m_previousCaretNode && (shouldRepaintCaret(*m_previousCaretNode) || shou
ldRepaintCaret(view))) | 1274 if (m_previousCaretNode && (shouldRepaintCaret(*m_previousCaretNode) || shou
ldRepaintCaret(view))) |
1275 invalidateLocalCaretRect(m_previousCaretNode.get(), m_previousCaretRect)
; | 1275 invalidateLocalCaretRect(m_previousCaretNode.get(), m_previousCaretRect)
; |
1276 if (newNode && (shouldRepaintCaret(*newNode) || shouldRepaintCaret(view))) | 1276 if (newNode && (shouldRepaintCaret(*newNode) || shouldRepaintCaret(view))) |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 m_frame->eventHandler().notifySelectionChanged(); | 1465 m_frame->eventHandler().notifySelectionChanged(); |
1466 } | 1466 } |
1467 | 1467 |
1468 void FrameSelection::focusedOrActiveStateChanged() | 1468 void FrameSelection::focusedOrActiveStateChanged() |
1469 { | 1469 { |
1470 bool activeAndFocused = isFocusedAndActive(); | 1470 bool activeAndFocused = isFocusedAndActive(); |
1471 | 1471 |
1472 RefPtrWillBeRawPtr<Document> document = m_frame->document(); | 1472 RefPtrWillBeRawPtr<Document> document = m_frame->document(); |
1473 document->updateRenderTreeIfNeeded(); | 1473 document->updateRenderTreeIfNeeded(); |
1474 | 1474 |
1475 // Because RenderObject::selectionBackgroundColor() and | 1475 // Because LayoutObject::selectionBackgroundColor() and |
1476 // RenderObject::selectionForegroundColor() check if the frame is active, | 1476 // LayoutObject::selectionForegroundColor() check if the frame is active, |
1477 // we have to update places those colors were painted. | 1477 // we have to update places those colors were painted. |
1478 if (RenderView* view = document->renderView()) | 1478 if (RenderView* view = document->renderView()) |
1479 view->invalidatePaintForSelection(); | 1479 view->invalidatePaintForSelection(); |
1480 | 1480 |
1481 // Caret appears in the active frame. | 1481 // Caret appears in the active frame. |
1482 if (activeAndFocused) | 1482 if (activeAndFocused) |
1483 setSelectionFromNone(); | 1483 setSelectionFromNone(); |
1484 else | 1484 else |
1485 m_frame->spellChecker().spellCheckAfterBlur(); | 1485 m_frame->spellChecker().spellCheckAfterBlur(); |
1486 setCaretVisibility(activeAndFocused ? Visible : Hidden); | 1486 setCaretVisibility(activeAndFocused ? Visible : Hidden); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(start
())) | 1617 if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(start
())) |
1618 textControl->selectionChanged(userTriggered == UserTriggered); | 1618 textControl->selectionChanged(userTriggered == UserTriggered); |
1619 } | 1619 } |
1620 | 1620 |
1621 // Helper function that tells whether a particular node is an element that has a
n entire | 1621 // Helper function that tells whether a particular node is an element that has a
n entire |
1622 // LocalFrame and FrameView, a <frame>, <iframe>, or <object>. | 1622 // LocalFrame and FrameView, a <frame>, <iframe>, or <object>. |
1623 static bool isFrameElement(const Node* n) | 1623 static bool isFrameElement(const Node* n) |
1624 { | 1624 { |
1625 if (!n) | 1625 if (!n) |
1626 return false; | 1626 return false; |
1627 RenderObject* renderer = n->renderer(); | 1627 LayoutObject* renderer = n->renderer(); |
1628 if (!renderer || !renderer->isRenderPart()) | 1628 if (!renderer || !renderer->isRenderPart()) |
1629 return false; | 1629 return false; |
1630 Widget* widget = toRenderPart(renderer)->widget(); | 1630 Widget* widget = toRenderPart(renderer)->widget(); |
1631 return widget && widget->isFrameView(); | 1631 return widget && widget->isFrameView(); |
1632 } | 1632 } |
1633 | 1633 |
1634 void FrameSelection::setFocusedNodeIfNeeded() | 1634 void FrameSelection::setFocusedNodeIfNeeded() |
1635 { | 1635 { |
1636 if (isNone() || !isFocused()) | 1636 if (isNone() || !isFocused()) |
1637 return; | 1637 return; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1944 sel.showTreeForThis(); | 1944 sel.showTreeForThis(); |
1945 } | 1945 } |
1946 | 1946 |
1947 void showTree(const blink::FrameSelection* sel) | 1947 void showTree(const blink::FrameSelection* sel) |
1948 { | 1948 { |
1949 if (sel) | 1949 if (sel) |
1950 sel->showTreeForThis(); | 1950 sel->showTreeForThis(); |
1951 } | 1951 } |
1952 | 1952 |
1953 #endif | 1953 #endif |
OLD | NEW |