| 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 ASSERT(selection().isValidFor(*m_frame->document())); | 702 ASSERT(selection().isValidFor(*m_frame->document())); |
| 703 LayoutObject* layoutObject = nullptr; | 703 LayoutObject* layoutObject = nullptr; |
| 704 LayoutRect newRect; | 704 LayoutRect newRect; |
| 705 if (selection().isCaret()) | 705 if (selection().isCaret()) |
| 706 newRect = localCaretRectOfPosition(PositionWithAffinity(selection().star
t(), selection().affinity()), layoutObject); | 706 newRect = localCaretRectOfPosition(PositionWithAffinity(selection().star
t(), selection().affinity()), layoutObject); |
| 707 Node* newNode = layoutObject ? layoutObject->node() : nullptr; | 707 Node* newNode = layoutObject ? layoutObject->node() : nullptr; |
| 708 | 708 |
| 709 if (!m_caretBlinkTimer.isActive() | 709 if (!m_caretBlinkTimer.isActive() |
| 710 && newNode == m_previousCaretNode | 710 && newNode == m_previousCaretNode |
| 711 && newRect == m_previousCaretRect | 711 && newRect == m_previousCaretRect |
| 712 && caretVisibility() == m_previousCaretVisibility) | 712 && getCaretVisibility() == m_previousCaretVisibility) |
| 713 return; | 713 return; |
| 714 | 714 |
| 715 LayoutView* view = m_frame->document()->layoutView(); | 715 LayoutView* view = m_frame->document()->layoutView(); |
| 716 if (m_previousCaretNode && (shouldRepaintCaret(*m_previousCaretNode) || shou
ldRepaintCaret(view))) | 716 if (m_previousCaretNode && (shouldRepaintCaret(*m_previousCaretNode) || shou
ldRepaintCaret(view))) |
| 717 invalidateLocalCaretRect(m_previousCaretNode.get(), m_previousCaretRect)
; | 717 invalidateLocalCaretRect(m_previousCaretNode.get(), m_previousCaretRect)
; |
| 718 if (newNode && (shouldRepaintCaret(*newNode) || shouldRepaintCaret(view))) | 718 if (newNode && (shouldRepaintCaret(*newNode) || shouldRepaintCaret(view))) |
| 719 invalidateLocalCaretRect(newNode, newRect); | 719 invalidateLocalCaretRect(newNode, newRect); |
| 720 m_previousCaretNode = newNode; | 720 m_previousCaretNode = newNode; |
| 721 m_previousCaretRect = newRect; | 721 m_previousCaretRect = newRect; |
| 722 m_previousCaretVisibility = caretVisibility(); | 722 m_previousCaretVisibility = getCaretVisibility(); |
| 723 } | 723 } |
| 724 | 724 |
| 725 void FrameSelection::paintCaret(GraphicsContext& context, const LayoutPoint& pai
ntOffset) | 725 void FrameSelection::paintCaret(GraphicsContext& context, const LayoutPoint& pai
ntOffset) |
| 726 { | 726 { |
| 727 if (selection().isCaret() && m_shouldPaintCaret) { | 727 if (selection().isCaret() && m_shouldPaintCaret) { |
| 728 updateCaretRect(PositionWithAffinity(selection().start(), selection().af
finity())); | 728 updateCaretRect(PositionWithAffinity(selection().start(), selection().af
finity())); |
| 729 CaretBase::paintCaret(selection().start().anchorNode(), context, paintOf
fset); | 729 CaretBase::paintCaret(selection().start().anchorNode(), context, paintOf
fset); |
| 730 } | 730 } |
| 731 } | 731 } |
| 732 | 732 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 LayoutView* view = m_frame->contentLayoutObject(); | 1011 LayoutView* view = m_frame->contentLayoutObject(); |
| 1012 if (!view) | 1012 if (!view) |
| 1013 return; | 1013 return; |
| 1014 m_pendingSelection->setHasPendingSelection(); | 1014 m_pendingSelection->setHasPendingSelection(); |
| 1015 } | 1015 } |
| 1016 | 1016 |
| 1017 void FrameSelection::setCaretVisibility(CaretVisibility visibility) | 1017 void FrameSelection::setCaretVisibility(CaretVisibility visibility) |
| 1018 { | 1018 { |
| 1019 if (caretVisibility() == visibility) | 1019 if (getCaretVisibility() == visibility) |
| 1020 return; | 1020 return; |
| 1021 | 1021 |
| 1022 CaretBase::setCaretVisibility(visibility); | 1022 CaretBase::setCaretVisibility(visibility); |
| 1023 | 1023 |
| 1024 updateAppearance(); | 1024 updateAppearance(); |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 bool FrameSelection::shouldBlinkCaret() const | 1027 bool FrameSelection::shouldBlinkCaret() const |
| 1028 { | 1028 { |
| 1029 if (!caretIsVisible() || !isCaret()) | 1029 if (!caretIsVisible() || !isCaret()) |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 } | 1204 } |
| 1205 | 1205 |
| 1206 // Try walking forward in the node tree to find a form element. | 1206 // Try walking forward in the node tree to find a form element. |
| 1207 return scanForForm(start); | 1207 return scanForForm(start); |
| 1208 } | 1208 } |
| 1209 | 1209 |
| 1210 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt
entOption revealExtentOption) | 1210 void FrameSelection::revealSelection(const ScrollAlignment& alignment, RevealExt
entOption revealExtentOption) |
| 1211 { | 1211 { |
| 1212 LayoutRect rect; | 1212 LayoutRect rect; |
| 1213 | 1213 |
| 1214 switch (selectionType()) { | 1214 switch (getSelectionType()) { |
| 1215 case NoSelection: | 1215 case NoSelection: |
| 1216 return; | 1216 return; |
| 1217 case CaretSelection: | 1217 case CaretSelection: |
| 1218 rect = LayoutRect(absoluteCaretBounds()); | 1218 rect = LayoutRect(absoluteCaretBounds()); |
| 1219 break; | 1219 break; |
| 1220 case RangeSelection: | 1220 case RangeSelection: |
| 1221 rect = LayoutRect(revealExtentOption == RevealExtent ? absoluteCaretBoun
dsOf(createVisiblePosition(extent())) : enclosingIntRect(unclippedBounds())); | 1221 rect = LayoutRect(revealExtentOption == RevealExtent ? absoluteCaretBoun
dsOf(createVisiblePosition(extent())) : enclosingIntRect(unclippedBounds())); |
| 1222 break; | 1222 break; |
| 1223 } | 1223 } |
| 1224 | 1224 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1401 | 1401 |
| 1402 void showTree(const blink::FrameSelection* sel) | 1402 void showTree(const blink::FrameSelection* sel) |
| 1403 { | 1403 { |
| 1404 if (sel) | 1404 if (sel) |
| 1405 sel->showTreeForThis(); | 1405 sel->showTreeForThis(); |
| 1406 else | 1406 else |
| 1407 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); | 1407 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); |
| 1408 } | 1408 } |
| 1409 | 1409 |
| 1410 #endif | 1410 #endif |
| OLD | NEW |