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 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 DCHECK(selection().isValidFor(*m_frame->document())); | 699 DCHECK(selection().isValidFor(*m_frame->document())); |
700 if (!isCaret()) | 700 if (!isCaret()) |
701 return nullptr; | 701 return nullptr; |
702 return CaretBase::caretLayoutObject(selection().start().anchorNode()); | 702 return CaretBase::caretLayoutObject(selection().start().anchorNode()); |
703 } | 703 } |
704 | 704 |
705 IntRect FrameSelection::absoluteCaretBounds() | 705 IntRect FrameSelection::absoluteCaretBounds() |
706 { | 706 { |
707 DCHECK(selection().isValidFor(*m_frame->document())); | 707 DCHECK(selection().isValidFor(*m_frame->document())); |
708 DCHECK_NE(m_frame->document()->lifecycle().state(), DocumentLifecycle::InPai
ntInvalidation); | 708 DCHECK_NE(m_frame->document()->lifecycle().state(), DocumentLifecycle::InPai
ntInvalidation); |
709 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 709 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
710 if (!isCaret()) { | 710 if (!isCaret()) { |
711 m_caretBase->clearCaretRect(); | 711 m_caretBase->clearCaretRect(); |
712 } else { | 712 } else { |
713 if (isTextFormControl(selection())) | 713 if (isTextFormControl(selection())) |
714 m_caretBase->updateCaretRect(PositionWithAffinity(isVisuallyEquivale
ntCandidate(selection().start()) ? selection().start() : Position(), selection()
.affinity())); | 714 m_caretBase->updateCaretRect(PositionWithAffinity(isVisuallyEquivale
ntCandidate(selection().start()) ? selection().start() : Position(), selection()
.affinity())); |
715 else | 715 else |
716 m_caretBase->updateCaretRect(createVisiblePosition(selection().start
(), selection().affinity())); | 716 m_caretBase->updateCaretRect(createVisiblePosition(selection().start
(), selection().affinity())); |
717 } | 717 } |
718 return m_caretBase->absoluteBoundsForLocalRect(selection().start().anchorNod
e(), m_caretBase->localCaretRectWithoutUpdate()); | 718 return m_caretBase->absoluteBoundsForLocalRect(selection().start().anchorNod
e(), m_caretBase->localCaretRectWithoutUpdate()); |
719 } | 719 } |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 { | 956 { |
957 bool activeAndFocused = isFocusedAndActive(); | 957 bool activeAndFocused = isFocusedAndActive(); |
958 Document* document = m_frame->document(); | 958 Document* document = m_frame->document(); |
959 | 959 |
960 // Trigger style invalidation from the focused element. Even though | 960 // Trigger style invalidation from the focused element. Even though |
961 // the focused element hasn't changed, the evaluation of focus pseudo | 961 // the focused element hasn't changed, the evaluation of focus pseudo |
962 // selectors are dependent on whether the frame is focused and active. | 962 // selectors are dependent on whether the frame is focused and active. |
963 if (Element* element = document->focusedElement()) | 963 if (Element* element = document->focusedElement()) |
964 element->focusStateChanged(); | 964 element->focusStateChanged(); |
965 | 965 |
966 document->updateLayoutTree(); | 966 document->updateStyleAndLayoutTree(); |
967 | 967 |
968 // Because LayoutObject::selectionBackgroundColor() and | 968 // Because LayoutObject::selectionBackgroundColor() and |
969 // LayoutObject::selectionForegroundColor() check if the frame is active, | 969 // LayoutObject::selectionForegroundColor() check if the frame is active, |
970 // we have to update places those colors were painted. | 970 // we have to update places those colors were painted. |
971 LayoutViewItem view = document->layoutViewItem(); | 971 LayoutViewItem view = document->layoutViewItem(); |
972 if (!view.isNull()) | 972 if (!view.isNull()) |
973 view.invalidatePaintForSelection(); | 973 view.invalidatePaintForSelection(); |
974 | 974 |
975 // Caret appears in the active frame. | 975 // Caret appears in the active frame. |
976 if (activeAndFocused) | 976 if (activeAndFocused) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsi
ngEnabled(); | 1137 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsi
ngEnabled(); |
1138 if (caretBrowsing) { | 1138 if (caretBrowsing) { |
1139 if (Element* anchor = enclosingAnchorElement(base())) { | 1139 if (Element* anchor = enclosingAnchorElement(base())) { |
1140 m_frame->page()->focusController().setFocusedElement(anchor, m_frame
); | 1140 m_frame->page()->focusController().setFocusedElement(anchor, m_frame
); |
1141 return; | 1141 return; |
1142 } | 1142 } |
1143 } | 1143 } |
1144 | 1144 |
1145 if (Element* target = rootEditableElement()) { | 1145 if (Element* target = rootEditableElement()) { |
1146 // Walk up the DOM tree to search for a node to focus. | 1146 // Walk up the DOM tree to search for a node to focus. |
1147 m_frame->document()->updateLayoutTreeIgnorePendingStylesheets(); | 1147 m_frame->document()->updateStyleAndLayoutTreeIgnorePendingStylesheets(); |
1148 while (target) { | 1148 while (target) { |
1149 // We don't want to set focus on a subframe when selecting in a pare
nt frame, | 1149 // We don't want to set focus on a subframe when selecting in a pare
nt frame, |
1150 // so add the !isFrameElement check here. There's probably a better
way to make this | 1150 // so add the !isFrameElement check here. There's probably a better
way to make this |
1151 // work in the long term, but this is the safest fix at this time. | 1151 // work in the long term, but this is the safest fix at this time. |
1152 if (target->isMouseFocusable() && !isFrameElement(target)) { | 1152 if (target->isMouseFocusable() && !isFrameElement(target)) { |
1153 m_frame->page()->focusController().setFocusedElement(target, m_f
rame); | 1153 m_frame->page()->focusController().setFocusedElement(target, m_f
rame); |
1154 return; | 1154 return; |
1155 } | 1155 } |
1156 target = target->parentOrShadowHostElement(); | 1156 target = target->parentOrShadowHostElement(); |
1157 } | 1157 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 if (!documentElement) | 1297 if (!documentElement) |
1298 return; | 1298 return; |
1299 if (HTMLBodyElement* body = Traversal<HTMLBodyElement>::firstChild(*document
Element)) | 1299 if (HTMLBodyElement* body = Traversal<HTMLBodyElement>::firstChild(*document
Element)) |
1300 setSelection(VisibleSelection(firstPositionInOrBeforeNode(body), TextAff
inity::Downstream)); | 1300 setSelection(VisibleSelection(firstPositionInOrBeforeNode(body), TextAff
inity::Downstream)); |
1301 } | 1301 } |
1302 | 1302 |
1303 void FrameSelection::setShouldShowBlockCursor(bool shouldShowBlockCursor) | 1303 void FrameSelection::setShouldShowBlockCursor(bool shouldShowBlockCursor) |
1304 { | 1304 { |
1305 m_shouldShowBlockCursor = shouldShowBlockCursor; | 1305 m_shouldShowBlockCursor = shouldShowBlockCursor; |
1306 | 1306 |
1307 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1307 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
1308 | 1308 |
1309 updateAppearance(); | 1309 updateAppearance(); |
1310 } | 1310 } |
1311 | 1311 |
1312 template <typename Strategy> | 1312 template <typename Strategy> |
1313 VisibleSelectionTemplate<Strategy> FrameSelection::validateSelection(const Visib
leSelectionTemplate<Strategy>& selection) | 1313 VisibleSelectionTemplate<Strategy> FrameSelection::validateSelection(const Visib
leSelectionTemplate<Strategy>& selection) |
1314 { | 1314 { |
1315 if (!m_frame || selection.isNone()) | 1315 if (!m_frame || selection.isNone()) |
1316 return selection; | 1316 return selection; |
1317 | 1317 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 | 1455 |
1456 void showTree(const blink::FrameSelection* sel) | 1456 void showTree(const blink::FrameSelection* sel) |
1457 { | 1457 { |
1458 if (sel) | 1458 if (sel) |
1459 sel->showTreeForThis(); | 1459 sel->showTreeForThis(); |
1460 else | 1460 else |
1461 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); | 1461 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); |
1462 } | 1462 } |
1463 | 1463 |
1464 #endif | 1464 #endif |
OLD | NEW |