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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 { | 89 { |
90 return !frame || frame->editor().behavior().shouldConsiderSelectionAsDirecti
onal(); | 90 return !frame || frame->editor().behavior().shouldConsiderSelectionAsDirecti
onal(); |
91 } | 91 } |
92 | 92 |
93 FrameSelection::FrameSelection(LocalFrame* frame) | 93 FrameSelection::FrameSelection(LocalFrame* frame) |
94 : m_frame(frame) | 94 : m_frame(frame) |
95 , m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation()) | 95 , m_xPosForVerticalArrowNavigation(NoXPosForVerticalArrowNavigation()) |
96 , m_observingVisibleSelection(false) | 96 , m_observingVisibleSelection(false) |
97 , m_granularity(CharacterGranularity) | 97 , m_granularity(CharacterGranularity) |
98 , m_caretBlinkTimer(this, &FrameSelection::caretBlinkTimerFired) | 98 , m_caretBlinkTimer(this, &FrameSelection::caretBlinkTimerFired) |
99 , m_absCaretBoundsDirty(true) | 99 , m_caretRectDirty(true) |
100 , m_caretPaint(true) | 100 , m_caretPaint(true) |
101 , m_isCaretBlinkingSuspended(false) | 101 , m_isCaretBlinkingSuspended(false) |
102 , m_focused(frame && frame->page() && frame->page()->focusController().focus
edFrame() == frame) | 102 , m_focused(frame && frame->page() && frame->page()->focusController().focus
edFrame() == frame) |
103 , m_shouldShowBlockCursor(false) | 103 , m_shouldShowBlockCursor(false) |
104 { | 104 { |
105 if (shouldAlwaysUseDirectionalSelection(m_frame)) | 105 if (shouldAlwaysUseDirectionalSelection(m_frame)) |
106 m_selection.setIsDirectional(true); | 106 m_selection.setIsDirectional(true); |
107 } | 107 } |
108 | 108 |
109 FrameSelection::~FrameSelection() | 109 FrameSelection::~FrameSelection() |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 265 |
266 VisibleSelection oldSelection = m_selection; | 266 VisibleSelection oldSelection = m_selection; |
267 | 267 |
268 m_selection = s; | 268 m_selection = s; |
269 setCaretRectNeedsUpdate(); | 269 setCaretRectNeedsUpdate(); |
270 | 270 |
271 if (!s.isNone() && !(options & DoNotSetFocus)) | 271 if (!s.isNone() && !(options & DoNotSetFocus)) |
272 setFocusedNodeIfNeeded(); | 272 setFocusedNodeIfNeeded(); |
273 | 273 |
274 if (!(options & DoNotUpdateAppearance)) { | 274 if (!(options & DoNotUpdateAppearance)) { |
275 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | |
276 | |
277 // Hits in compositing/overflow/do-not-paint-outline-into-composited-scr
olling-contents.html | 275 // Hits in compositing/overflow/do-not-paint-outline-into-composited-scr
olling-contents.html |
278 DisableCompositingQueryAsserts disabler; | 276 DisableCompositingQueryAsserts disabler; |
279 updateAppearance(); | 277 updateAppearance(ResetCaretBlink); |
280 } | 278 } |
281 | 279 |
282 // Always clear the x position used for vertical arrow navigation. | 280 // Always clear the x position used for vertical arrow navigation. |
283 // It will be restored by the vertical arrow navigation code if necessary. | 281 // It will be restored by the vertical arrow navigation code if necessary. |
284 m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation(); | 282 m_xPosForVerticalArrowNavigation = NoXPosForVerticalArrowNavigation(); |
285 selectFrameElementInParentIfFullySelected(); | 283 selectFrameElementInParentIfFullySelected(); |
286 notifyRendererOfSelectionChange(userTriggered); | 284 notifyRendererOfSelectionChange(userTriggered); |
287 m_frame->editor().respondToChangedSelection(oldSelection, options); | 285 m_frame->editor().respondToChangedSelection(oldSelection, options); |
288 if (userTriggered == UserTriggered) { | 286 if (userTriggered == UserTriggered) { |
289 ScrollAlignment alignment; | 287 ScrollAlignment alignment; |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 static bool isNonOrphanedCaret(const VisibleSelection& selection) | 1221 static bool isNonOrphanedCaret(const VisibleSelection& selection) |
1224 { | 1222 { |
1225 return selection.isCaret() && !selection.start().isOrphan() && !selection.en
d().isOrphan(); | 1223 return selection.isCaret() && !selection.start().isOrphan() && !selection.en
d().isOrphan(); |
1226 } | 1224 } |
1227 | 1225 |
1228 static bool isTextFormControl(const VisibleSelection& selection) | 1226 static bool isTextFormControl(const VisibleSelection& selection) |
1229 { | 1227 { |
1230 return enclosingTextFormControl(selection.start()); | 1228 return enclosingTextFormControl(selection.start()); |
1231 } | 1229 } |
1232 | 1230 |
1233 LayoutRect FrameSelection::localCaretRect() | |
1234 { | |
1235 if (shouldUpdateCaretRect()) { | |
1236 if (!isNonOrphanedCaret(m_selection)) | |
1237 clearCaretRect(); | |
1238 else if (isTextFormControl(m_selection)) | |
1239 m_absCaretBoundsDirty |= updateCaretRect(m_frame->document(), Positi
onWithAffinity(m_selection.start().isCandidate() ? m_selection.start() : Positio
n(), m_selection.affinity())); | |
1240 else | |
1241 m_absCaretBoundsDirty |= updateCaretRect(m_frame->document(), Visibl
ePosition(m_selection.start(), m_selection.affinity())); | |
1242 } | |
1243 | |
1244 return localCaretRectWithoutUpdate(); | |
1245 } | |
1246 | |
1247 IntRect FrameSelection::absoluteCaretBounds() | 1231 IntRect FrameSelection::absoluteCaretBounds() |
1248 { | 1232 { |
1249 recomputeCaretRect(); | 1233 ASSERT(m_frame->document()->lifecycle().state() != DocumentLifecycle::InPain
tInvalidation); |
1250 return m_absCaretBounds; | 1234 m_frame->document()->updateLayoutIgnorePendingStylesheets(); |
| 1235 if (!isNonOrphanedCaret(m_selection)) { |
| 1236 clearCaretRect(); |
| 1237 } else { |
| 1238 if (isTextFormControl(m_selection)) |
| 1239 updateCaretRect(m_frame->document(), PositionWithAffinity(m_selectio
n.start().isCandidate() ? m_selection.start() : Position(), m_selection.affinity
())); |
| 1240 else |
| 1241 updateCaretRect(m_frame->document(), VisiblePosition(m_selection.sta
rt(), m_selection.affinity())); |
| 1242 } |
| 1243 return absoluteBoundsForLocalRect(m_selection.start().deprecatedNode(), loca
lCaretRectWithoutUpdate()); |
1251 } | 1244 } |
1252 | 1245 |
1253 bool FrameSelection::recomputeCaretRect() | 1246 static LayoutRect localCaretRect(const VisibleSelection& m_selection, const Posi
tionWithAffinity& caretPosition, RenderObject*& renderer) |
1254 { | 1247 { |
1255 if (!shouldUpdateCaretRect()) | 1248 renderer = nullptr; |
1256 return false; | 1249 if (!isNonOrphanedCaret(m_selection)) |
| 1250 return LayoutRect(); |
1257 | 1251 |
1258 if (!m_frame || !m_frame->document()->view()) | 1252 return localCaretRectOfPosition(caretPosition, renderer); |
1259 return false; | 1253 } |
1260 | 1254 |
1261 LayoutRect oldRect = localCaretRectWithoutUpdate(); | 1255 static void invalidateLocalCaretRect(RenderObject* renderer, const LayoutRect& c
aretRect) |
1262 LayoutRect newRect = localCaretRect(); | 1256 { |
1263 if (oldRect == newRect && !m_absCaretBoundsDirty) | 1257 // FIXME: Need to over-paint 1 pixel to workaround some rounding problems. |
1264 return false; | 1258 // https://bugs.webkit.org/show_bug.cgi?id=108283 |
1265 | 1259 LayoutRect inflatedRect = caretRect; |
1266 IntRect oldAbsCaretBounds = m_absCaretBounds; | 1260 inflatedRect.inflate(1); |
1267 m_absCaretBounds = absoluteBoundsForLocalRect(m_selection.start().deprecated
Node(), localCaretRectWithoutUpdate()); | 1261 renderer->invalidatePaintRectangle(inflatedRect); |
1268 m_absCaretBoundsDirty = false; | |
1269 | |
1270 if (oldAbsCaretBounds == m_absCaretBounds) | |
1271 return false; | |
1272 | |
1273 if (RenderView* view = m_frame->document()->renderView()) { | |
1274 if (m_previousCaretNode && shouldRepaintCaret(view, m_previousCaretNode-
>isContentEditable())) | |
1275 repaintCaretForLocalRect(m_previousCaretNode.get(), oldRect); | |
1276 Node* node = m_selection.start().deprecatedNode(); | |
1277 m_previousCaretNode = node; | |
1278 if (shouldRepaintCaret(view, isContentEditable())) | |
1279 repaintCaretForLocalRect(node, newRect); | |
1280 } | |
1281 | |
1282 return true; | |
1283 } | 1262 } |
1284 | 1263 |
1285 void FrameSelection::invalidateCaretRect() | 1264 void FrameSelection::invalidateCaretRect() |
1286 { | 1265 { |
1287 if (!isCaret()) | 1266 if (!m_caretRectDirty) |
| 1267 return; |
| 1268 m_caretRectDirty = false; |
| 1269 |
| 1270 RenderObject* renderer = nullptr; |
| 1271 LayoutRect newRect = localCaretRect(m_selection, PositionWithAffinity(m_sele
ction.start(), m_selection.affinity()), renderer); |
| 1272 Node* newNode = renderer ? renderer->node() : nullptr; |
| 1273 |
| 1274 if (!m_caretBlinkTimer.isActive() && newNode == m_previousCaretNode && newRe
ct == m_previousCaretRect) |
1288 return; | 1275 return; |
1289 | 1276 |
1290 CaretBase::invalidateCaretRect(m_selection.start().deprecatedNode(), recompu
teCaretRect()); | 1277 RenderView* view = m_frame->document()->renderView(); |
| 1278 if (m_previousCaretNode && shouldRepaintCaret(view, m_previousCaretNode->isC
ontentEditable())) |
| 1279 invalidateLocalCaretRect(m_previousCaretNode->renderer(), m_previousCare
tRect); |
| 1280 if (newNode && shouldRepaintCaret(view, newNode->isContentEditable())) |
| 1281 invalidateLocalCaretRect(newNode->renderer(), newRect); |
| 1282 |
| 1283 m_previousCaretNode = newNode; |
| 1284 m_previousCaretRect = newRect; |
1291 } | 1285 } |
1292 | 1286 |
1293 void FrameSelection::paintCaret(GraphicsContext* context, const LayoutPoint& pai
ntOffset, const LayoutRect& clipRect) | 1287 void FrameSelection::paintCaret(GraphicsContext* context, const LayoutPoint& pai
ntOffset, const LayoutRect& clipRect) |
1294 { | 1288 { |
1295 if (m_selection.isCaret() && m_caretPaint) | 1289 if (m_selection.isCaret() && m_caretPaint) { |
| 1290 updateCaretRect(m_frame->document(), m_selection.visibleStart()); |
1296 CaretBase::paintCaret(m_selection.start().deprecatedNode(), context, pai
ntOffset, clipRect); | 1291 CaretBase::paintCaret(m_selection.start().deprecatedNode(), context, pai
ntOffset, clipRect); |
| 1292 } |
1297 } | 1293 } |
1298 | 1294 |
1299 bool FrameSelection::contains(const LayoutPoint& point) | 1295 bool FrameSelection::contains(const LayoutPoint& point) |
1300 { | 1296 { |
1301 Document* document = m_frame->document(); | 1297 Document* document = m_frame->document(); |
1302 | 1298 |
1303 // Treat a collapsed selection like no selection. | 1299 // Treat a collapsed selection like no selection. |
1304 if (!isRange()) | 1300 if (!isRange()) |
1305 return false; | 1301 return false; |
1306 if (!document->renderView()) | 1302 if (!document->renderView()) |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache()) | 1454 if (AXObjectCache* cache = m_frame->document()->existingAXObjectCache()) |
1459 cache->selectionChanged(m_selection.start().containerNode()); | 1455 cache->selectionChanged(m_selection.start().containerNode()); |
1460 } | 1456 } |
1461 } | 1457 } |
1462 | 1458 |
1463 void FrameSelection::notifyCompositorForSelectionChange() | 1459 void FrameSelection::notifyCompositorForSelectionChange() |
1464 { | 1460 { |
1465 if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled()) | 1461 if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled()) |
1466 return; | 1462 return; |
1467 | 1463 |
1468 if (Page* page = m_frame->page()) | 1464 scheduleVisualUpdate(); |
1469 page->animator().scheduleVisualUpdate(); | |
1470 } | 1465 } |
1471 | 1466 |
1472 void FrameSelection::focusedOrActiveStateChanged() | 1467 void FrameSelection::focusedOrActiveStateChanged() |
1473 { | 1468 { |
1474 bool activeAndFocused = isFocusedAndActive(); | 1469 bool activeAndFocused = isFocusedAndActive(); |
1475 | 1470 |
1476 RefPtrWillBeRawPtr<Document> document = m_frame->document(); | 1471 RefPtrWillBeRawPtr<Document> document = m_frame->document(); |
1477 document->updateRenderTreeIfNeeded(); | 1472 document->updateRenderTreeIfNeeded(); |
1478 | 1473 |
1479 // Because RenderObject::selectionBackgroundColor() and | 1474 // Because RenderObject::selectionBackgroundColor() and |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 bool FrameSelection::isFocusedAndActive() const | 1528 bool FrameSelection::isFocusedAndActive() const |
1534 { | 1529 { |
1535 return m_focused && m_frame->page() && m_frame->page()->focusController().is
Active(); | 1530 return m_focused && m_frame->page() && m_frame->page()->focusController().is
Active(); |
1536 } | 1531 } |
1537 | 1532 |
1538 inline static bool shouldStopBlinkingDueToTypingCommand(LocalFrame* frame) | 1533 inline static bool shouldStopBlinkingDueToTypingCommand(LocalFrame* frame) |
1539 { | 1534 { |
1540 return frame->editor().lastEditCommand() && frame->editor().lastEditCommand(
)->shouldStopCaretBlinking(); | 1535 return frame->editor().lastEditCommand() && frame->editor().lastEditCommand(
)->shouldStopCaretBlinking(); |
1541 } | 1536 } |
1542 | 1537 |
1543 void FrameSelection::updateAppearance() | 1538 void FrameSelection::updateAppearance(ResetCaretBlinkOption option) |
1544 { | 1539 { |
1545 // Paint a block cursor instead of a caret in overtype mode unless the caret
is at the end of a line (in this case | 1540 // Paint a block cursor instead of a caret in overtype mode unless the caret
is at the end of a line (in this case |
1546 // the FrameSelection will paint a blinking caret as usual). | 1541 // the FrameSelection will paint a blinking caret as usual). |
1547 bool paintBlockCursor = m_shouldShowBlockCursor && m_selection.isCaret() &&
!isLogicalEndOfLine(m_selection.visibleEnd()); | 1542 bool paintBlockCursor = m_shouldShowBlockCursor && m_selection.isCaret() &&
!isLogicalEndOfLine(m_selection.visibleEnd()); |
1548 | 1543 |
1549 bool caretRectChangedOrCleared = recomputeCaretRect(); | |
1550 bool shouldBlink = !paintBlockCursor && shouldBlinkCaret(); | 1544 bool shouldBlink = !paintBlockCursor && shouldBlinkCaret(); |
1551 | 1545 |
| 1546 bool willNeedCaretRectUpdate = false; |
| 1547 |
1552 // If the caret moved, stop the blink timer so we can restart with a | 1548 // If the caret moved, stop the blink timer so we can restart with a |
1553 // black caret in the new location. | 1549 // black caret in the new location. |
1554 if (caretRectChangedOrCleared || !shouldBlink || shouldStopBlinkingDueToTypi
ngCommand(m_frame)) { | 1550 if (option == ResetCaretBlink || !shouldBlink || shouldStopBlinkingDueToTypi
ngCommand(m_frame)) { |
1555 m_caretBlinkTimer.stop(); | 1551 m_caretBlinkTimer.stop(); |
1556 if (!shouldBlink && m_caretPaint) { | 1552 |
1557 m_caretPaint = false; | 1553 m_caretPaint = false; |
1558 invalidateCaretRect(); | 1554 willNeedCaretRectUpdate = true; |
1559 } | |
1560 } | 1555 } |
1561 | 1556 |
1562 // Start blinking with a black caret. Be sure not to restart if we're | 1557 // Start blinking with a black caret. Be sure not to restart if we're |
1563 // already blinking in the right location. | 1558 // already blinking in the right location. |
1564 if (shouldBlink && !m_caretBlinkTimer.isActive()) { | 1559 if (shouldBlink && !m_caretBlinkTimer.isActive()) { |
1565 if (double blinkInterval = RenderTheme::theme().caretBlinkInterval()) | 1560 if (double blinkInterval = RenderTheme::theme().caretBlinkInterval()) |
1566 m_caretBlinkTimer.startRepeating(blinkInterval, FROM_HERE); | 1561 m_caretBlinkTimer.startRepeating(blinkInterval, FROM_HERE); |
1567 | 1562 |
1568 if (!m_caretPaint) { | 1563 m_caretPaint = true; |
1569 m_caretPaint = true; | 1564 willNeedCaretRectUpdate = true; |
1570 invalidateCaretRect(); | |
1571 } | |
1572 } | 1565 } |
1573 | 1566 |
| 1567 if (willNeedCaretRectUpdate) |
| 1568 setCaretRectNeedsUpdate(); |
| 1569 |
1574 RenderView* view = m_frame->contentRenderer(); | 1570 RenderView* view = m_frame->contentRenderer(); |
1575 if (!view) | 1571 if (!view) |
1576 return; | 1572 return; |
1577 | 1573 |
1578 // Construct a new VisibleSolution, since m_selection is not necessarily val
id, and the following steps | 1574 // Construct a new VisibleSolution, since m_selection is not necessarily val
id, and the following steps |
1579 // assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69
563> and <rdar://problem/10232866>. | 1575 // assume a valid selection. See <https://bugs.webkit.org/show_bug.cgi?id=69
563> and <rdar://problem/10232866>. |
1580 VisiblePosition endVisiblePosition = paintBlockCursor ? modifyExtendingForwa
rd(CharacterGranularity) : m_selection.visibleEnd(); | 1576 |
1581 VisibleSelection selection(m_selection.visibleStart(), endVisiblePosition); | 1577 VisibleSelection selection; |
| 1578 if (isTextFormControl(m_selection)) { |
| 1579 Position endPosition = paintBlockCursor ? m_selection.extent().next() :
m_selection.end(); |
| 1580 selection.setWithoutValidation(m_selection.start(), endPosition); |
| 1581 } else { |
| 1582 VisiblePosition endVisiblePosition = paintBlockCursor ? modifyExtendingF
orward(CharacterGranularity) : m_selection.visibleEnd(); |
| 1583 selection = VisibleSelection(m_selection.visibleStart(), endVisiblePosit
ion); |
| 1584 } |
1582 | 1585 |
1583 if (!selection.isRange()) { | 1586 if (!selection.isRange()) { |
1584 view->clearSelection(); | 1587 view->clearSelection(); |
1585 return; | 1588 return; |
1586 } | 1589 } |
1587 | 1590 |
1588 // Use the rightmost candidate for the start of the selection, and the leftm
ost candidate for the end of the selection. | 1591 // Use the rightmost candidate for the start of the selection, and the leftm
ost candidate for the end of the selection. |
1589 // Example: foo <a>bar</a>. Imagine that a line wrap occurs after 'foo', an
d that 'bar' is selected. If we pass [foo, 3] | 1592 // Example: foo <a>bar</a>. Imagine that a line wrap occurs after 'foo', an
d that 'bar' is selected. If we pass [foo, 3] |
1590 // as the start of the selection, the selection painting code will think tha
t content on the line containing 'foo' is selected | 1593 // as the start of the selection, the selection painting code will think tha
t content on the line containing 'foo' is selected |
1591 // and will fill the gap before 'bar'. | 1594 // and will fill the gap before 'bar'. |
(...skipping 14 matching lines...) Expand all Loading... |
1606 if (startRenderer->view() == view && endRenderer->view() == view) | 1609 if (startRenderer->view() == view && endRenderer->view() == view) |
1607 view->setSelection(startRenderer, startPos.deprecatedEditingOffset()
, endRenderer, endPos.deprecatedEditingOffset()); | 1610 view->setSelection(startRenderer, startPos.deprecatedEditingOffset()
, endRenderer, endPos.deprecatedEditingOffset()); |
1608 } | 1611 } |
1609 } | 1612 } |
1610 | 1613 |
1611 void FrameSelection::setCaretVisibility(CaretVisibility visibility) | 1614 void FrameSelection::setCaretVisibility(CaretVisibility visibility) |
1612 { | 1615 { |
1613 if (caretVisibility() == visibility) | 1616 if (caretVisibility() == visibility) |
1614 return; | 1617 return; |
1615 | 1618 |
1616 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | |
1617 if (m_caretPaint) { | |
1618 m_caretPaint = false; | |
1619 invalidateCaretRect(); | |
1620 } | |
1621 CaretBase::setCaretVisibility(visibility); | 1619 CaretBase::setCaretVisibility(visibility); |
1622 | 1620 |
1623 updateAppearance(); | 1621 updateAppearance(); |
1624 } | 1622 } |
1625 | 1623 |
1626 bool FrameSelection::shouldBlinkCaret() const | 1624 bool FrameSelection::shouldBlinkCaret() const |
1627 { | 1625 { |
1628 if (!caretIsVisible() || !isCaret()) | 1626 if (!caretIsVisible() || !isCaret()) |
1629 return false; | 1627 return false; |
1630 | 1628 |
(...skipping 11 matching lines...) Expand all Loading... |
1642 return focusedElement->containsIncludingShadowDOM(m_selection.start().anchor
Node()); | 1640 return focusedElement->containsIncludingShadowDOM(m_selection.start().anchor
Node()); |
1643 } | 1641 } |
1644 | 1642 |
1645 void FrameSelection::caretBlinkTimerFired(Timer<FrameSelection>*) | 1643 void FrameSelection::caretBlinkTimerFired(Timer<FrameSelection>*) |
1646 { | 1644 { |
1647 ASSERT(caretIsVisible()); | 1645 ASSERT(caretIsVisible()); |
1648 ASSERT(isCaret()); | 1646 ASSERT(isCaret()); |
1649 if (isCaretBlinkingSuspended() && m_caretPaint) | 1647 if (isCaretBlinkingSuspended() && m_caretPaint) |
1650 return; | 1648 return; |
1651 m_caretPaint = !m_caretPaint; | 1649 m_caretPaint = !m_caretPaint; |
1652 invalidateCaretRect(); | 1650 setCaretRectNeedsUpdate(); |
1653 } | 1651 } |
1654 | 1652 |
1655 void FrameSelection::notifyRendererOfSelectionChange(EUserTriggered userTriggere
d) | 1653 void FrameSelection::notifyRendererOfSelectionChange(EUserTriggered userTriggere
d) |
1656 { | 1654 { |
1657 m_frame->document()->updateRenderTreeIfNeeded(); | |
1658 | |
1659 if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(start
())) | 1655 if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(start
())) |
1660 textControl->selectionChanged(userTriggered == UserTriggered); | 1656 textControl->selectionChanged(userTriggered == UserTriggered); |
1661 } | 1657 } |
1662 | 1658 |
1663 // Helper function that tells whether a particular node is an element that has a
n entire | 1659 // Helper function that tells whether a particular node is an element that has a
n entire |
1664 // LocalFrame and FrameView, a <frame>, <iframe>, or <object>. | 1660 // LocalFrame and FrameView, a <frame>, <iframe>, or <object>. |
1665 static bool isFrameElement(const Node* n) | 1661 static bool isFrameElement(const Node* n) |
1666 { | 1662 { |
1667 if (!n) | 1663 if (!n) |
1668 return false; | 1664 return false; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1908 void FrameSelection::trace(Visitor* visitor) | 1904 void FrameSelection::trace(Visitor* visitor) |
1909 { | 1905 { |
1910 visitor->trace(m_selection); | 1906 visitor->trace(m_selection); |
1911 visitor->trace(m_originalBase); | 1907 visitor->trace(m_originalBase); |
1912 visitor->trace(m_logicalRange); | 1908 visitor->trace(m_logicalRange); |
1913 visitor->trace(m_previousCaretNode); | 1909 visitor->trace(m_previousCaretNode); |
1914 visitor->trace(m_typingStyle); | 1910 visitor->trace(m_typingStyle); |
1915 VisibleSelection::ChangeObserver::trace(visitor); | 1911 VisibleSelection::ChangeObserver::trace(visitor); |
1916 } | 1912 } |
1917 | 1913 |
| 1914 void FrameSelection::setCaretRectNeedsUpdate() |
| 1915 { |
| 1916 m_caretRectDirty = true; |
| 1917 |
| 1918 scheduleVisualUpdate(); |
| 1919 } |
| 1920 |
| 1921 void FrameSelection::scheduleVisualUpdate() const |
| 1922 { |
| 1923 if (!m_frame) |
| 1924 return; |
| 1925 if (Page* page = m_frame->page()) |
| 1926 page->animator().scheduleVisualUpdate(); |
| 1927 } |
| 1928 |
1918 } | 1929 } |
1919 | 1930 |
1920 #ifndef NDEBUG | 1931 #ifndef NDEBUG |
1921 | 1932 |
1922 void showTree(const blink::FrameSelection& sel) | 1933 void showTree(const blink::FrameSelection& sel) |
1923 { | 1934 { |
1924 sel.showTreeForThis(); | 1935 sel.showTreeForThis(); |
1925 } | 1936 } |
1926 | 1937 |
1927 void showTree(const blink::FrameSelection* sel) | 1938 void showTree(const blink::FrameSelection* sel) |
1928 { | 1939 { |
1929 if (sel) | 1940 if (sel) |
1930 sel->showTreeForThis(); | 1941 sel->showTreeForThis(); |
1931 } | 1942 } |
1932 | 1943 |
1933 #endif | 1944 #endif |
OLD | NEW |