| 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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 DCHECK(selection().isValidFor(*m_frame->document())); | 683 DCHECK(selection().isValidFor(*m_frame->document())); |
| 684 if (!isCaret()) | 684 if (!isCaret()) |
| 685 return nullptr; | 685 return nullptr; |
| 686 return CaretBase::caretLayoutObject(selection().start().anchorNode()); | 686 return CaretBase::caretLayoutObject(selection().start().anchorNode()); |
| 687 } | 687 } |
| 688 | 688 |
| 689 IntRect FrameSelection::absoluteCaretBounds() | 689 IntRect FrameSelection::absoluteCaretBounds() |
| 690 { | 690 { |
| 691 DCHECK(selection().isValidFor(*m_frame->document())); | 691 DCHECK(selection().isValidFor(*m_frame->document())); |
| 692 DCHECK_NE(m_frame->document()->lifecycle().state(), DocumentLifecycle::InPai
ntInvalidation); | 692 DCHECK_NE(m_frame->document()->lifecycle().state(), DocumentLifecycle::InPai
ntInvalidation); |
| 693 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 693 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 694 if (!isCaret()) { | 694 if (!isCaret()) { |
| 695 m_caretBase->clearCaretRect(); | 695 m_caretBase->clearCaretRect(); |
| 696 } else { | 696 } else { |
| 697 if (isTextFormControl(selection())) | 697 if (isTextFormControl(selection())) |
| 698 m_caretBase->updateCaretRect(PositionWithAffinity(isVisuallyEquivale
ntCandidate(selection().start()) ? selection().start() : Position(), selection()
.affinity())); | 698 m_caretBase->updateCaretRect(PositionWithAffinity(isVisuallyEquivale
ntCandidate(selection().start()) ? selection().start() : Position(), selection()
.affinity())); |
| 699 else | 699 else |
| 700 m_caretBase->updateCaretRect(createVisiblePosition(selection().start
(), selection().affinity())); | 700 m_caretBase->updateCaretRect(createVisiblePosition(selection().start
(), selection().affinity())); |
| 701 } | 701 } |
| 702 return m_caretBase->absoluteBoundsForLocalRect(selection().start().anchorNod
e(), m_caretBase->localCaretRectWithoutUpdate()); | 702 return m_caretBase->absoluteBoundsForLocalRect(selection().start().anchorNod
e(), m_caretBase->localCaretRectWithoutUpdate()); |
| 703 } | 703 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 { | 930 { |
| 931 bool activeAndFocused = isFocusedAndActive(); | 931 bool activeAndFocused = isFocusedAndActive(); |
| 932 Document* document = m_frame->document(); | 932 Document* document = m_frame->document(); |
| 933 | 933 |
| 934 // Trigger style invalidation from the focused element. Even though | 934 // Trigger style invalidation from the focused element. Even though |
| 935 // the focused element hasn't changed, the evaluation of focus pseudo | 935 // the focused element hasn't changed, the evaluation of focus pseudo |
| 936 // selectors are dependent on whether the frame is focused and active. | 936 // selectors are dependent on whether the frame is focused and active. |
| 937 if (Element* element = document->focusedElement()) | 937 if (Element* element = document->focusedElement()) |
| 938 element->focusStateChanged(); | 938 element->focusStateChanged(); |
| 939 | 939 |
| 940 document->updateLayoutTree(); | 940 document->updateStyleAndLayoutTree(); |
| 941 | 941 |
| 942 // Because LayoutObject::selectionBackgroundColor() and | 942 // Because LayoutObject::selectionBackgroundColor() and |
| 943 // LayoutObject::selectionForegroundColor() check if the frame is active, | 943 // LayoutObject::selectionForegroundColor() check if the frame is active, |
| 944 // we have to update places those colors were painted. | 944 // we have to update places those colors were painted. |
| 945 LayoutViewItem view = document->layoutViewItem(); | 945 LayoutViewItem view = document->layoutViewItem(); |
| 946 if (!view.isNull()) | 946 if (!view.isNull()) |
| 947 view.invalidatePaintForSelection(); | 947 view.invalidatePaintForSelection(); |
| 948 | 948 |
| 949 // Caret appears in the active frame. | 949 // Caret appears in the active frame. |
| 950 if (activeAndFocused) | 950 if (activeAndFocused) |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsi
ngEnabled(); | 1111 bool caretBrowsing = m_frame->settings() && m_frame->settings()->caretBrowsi
ngEnabled(); |
| 1112 if (caretBrowsing) { | 1112 if (caretBrowsing) { |
| 1113 if (Element* anchor = enclosingAnchorElement(base())) { | 1113 if (Element* anchor = enclosingAnchorElement(base())) { |
| 1114 m_frame->page()->focusController().setFocusedElement(anchor, m_frame
); | 1114 m_frame->page()->focusController().setFocusedElement(anchor, m_frame
); |
| 1115 return; | 1115 return; |
| 1116 } | 1116 } |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 if (Element* target = rootEditableElement()) { | 1119 if (Element* target = rootEditableElement()) { |
| 1120 // Walk up the DOM tree to search for a node to focus. | 1120 // Walk up the DOM tree to search for a node to focus. |
| 1121 m_frame->document()->updateLayoutTreeIgnorePendingStylesheets(); | 1121 m_frame->document()->updateStyleAndLayoutTreeIgnorePendingStylesheets(); |
| 1122 while (target) { | 1122 while (target) { |
| 1123 // We don't want to set focus on a subframe when selecting in a pare
nt frame, | 1123 // We don't want to set focus on a subframe when selecting in a pare
nt frame, |
| 1124 // so add the !isFrameElement check here. There's probably a better
way to make this | 1124 // so add the !isFrameElement check here. There's probably a better
way to make this |
| 1125 // work in the long term, but this is the safest fix at this time. | 1125 // work in the long term, but this is the safest fix at this time. |
| 1126 if (target->isMouseFocusable() && !isFrameElement(target)) { | 1126 if (target->isMouseFocusable() && !isFrameElement(target)) { |
| 1127 m_frame->page()->focusController().setFocusedElement(target, m_f
rame); | 1127 m_frame->page()->focusController().setFocusedElement(target, m_f
rame); |
| 1128 return; | 1128 return; |
| 1129 } | 1129 } |
| 1130 target = target->parentOrShadowHostElement(); | 1130 target = target->parentOrShadowHostElement(); |
| 1131 } | 1131 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 if (!documentElement) | 1271 if (!documentElement) |
| 1272 return; | 1272 return; |
| 1273 if (HTMLBodyElement* body = Traversal<HTMLBodyElement>::firstChild(*document
Element)) | 1273 if (HTMLBodyElement* body = Traversal<HTMLBodyElement>::firstChild(*document
Element)) |
| 1274 setSelection(VisibleSelection(firstPositionInOrBeforeNode(body), TextAff
inity::Downstream)); | 1274 setSelection(VisibleSelection(firstPositionInOrBeforeNode(body), TextAff
inity::Downstream)); |
| 1275 } | 1275 } |
| 1276 | 1276 |
| 1277 void FrameSelection::setShouldShowBlockCursor(bool shouldShowBlockCursor) | 1277 void FrameSelection::setShouldShowBlockCursor(bool shouldShowBlockCursor) |
| 1278 { | 1278 { |
| 1279 m_shouldShowBlockCursor = shouldShowBlockCursor; | 1279 m_shouldShowBlockCursor = shouldShowBlockCursor; |
| 1280 | 1280 |
| 1281 m_frame->document()->updateLayoutIgnorePendingStylesheets(); | 1281 m_frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 1282 | 1282 |
| 1283 updateAppearance(); | 1283 updateAppearance(); |
| 1284 } | 1284 } |
| 1285 | 1285 |
| 1286 template <typename Strategy> | 1286 template <typename Strategy> |
| 1287 VisibleSelectionTemplate<Strategy> FrameSelection::validateSelection(const Visib
leSelectionTemplate<Strategy>& selection) | 1287 VisibleSelectionTemplate<Strategy> FrameSelection::validateSelection(const Visib
leSelectionTemplate<Strategy>& selection) |
| 1288 { | 1288 { |
| 1289 if (!m_frame || selection.isNone()) | 1289 if (!m_frame || selection.isNone()) |
| 1290 return selection; | 1290 return selection; |
| 1291 | 1291 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 | 1429 |
| 1430 void showTree(const blink::FrameSelection* sel) | 1430 void showTree(const blink::FrameSelection* sel) |
| 1431 { | 1431 { |
| 1432 if (sel) | 1432 if (sel) |
| 1433 sel->showTreeForThis(); | 1433 sel->showTreeForThis(); |
| 1434 else | 1434 else |
| 1435 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); | 1435 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); |
| 1436 } | 1436 } |
| 1437 | 1437 |
| 1438 #endif | 1438 #endif |
| OLD | NEW |