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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 void FrameSelection::DocumentAttached(Document* document) { | 428 void FrameSelection::DocumentAttached(Document* document) { |
429 DCHECK(document); | 429 DCHECK(document); |
430 use_secure_keyboard_entry_when_active_ = false; | 430 use_secure_keyboard_entry_when_active_ = false; |
431 selection_editor_->DocumentAttached(document); | 431 selection_editor_->DocumentAttached(document); |
432 SetContext(document); | 432 SetContext(document); |
433 } | 433 } |
434 | 434 |
435 void FrameSelection::ContextDestroyed(Document* document) { | 435 void FrameSelection::ContextDestroyed(Document* document) { |
436 granularity_ = kCharacterGranularity; | 436 granularity_ = kCharacterGranularity; |
437 | 437 |
438 LayoutViewItem view = frame_->ContentLayoutItem(); | 438 layout_selection_->OnDocumentShutdown(); |
439 if (!view.IsNull()) | |
440 view.ClearSelection(); | |
441 | 439 |
442 frame_->GetEditor().ClearTypingStyle(); | 440 frame_->GetEditor().ClearTypingStyle(); |
443 } | 441 } |
444 | 442 |
445 void FrameSelection::ClearPreviousCaretVisualRect(const LayoutBlock& block) { | 443 void FrameSelection::ClearPreviousCaretVisualRect(const LayoutBlock& block) { |
446 frame_caret_->ClearPreviousVisualRect(block); | 444 frame_caret_->ClearPreviousVisualRect(block); |
447 } | 445 } |
448 | 446 |
449 void FrameSelection::LayoutBlockWillBeDestroyed(const LayoutBlock& block) { | 447 void FrameSelection::LayoutBlockWillBeDestroyed(const LayoutBlock& block) { |
450 frame_caret_->LayoutBlockWillBeDestroyed(block); | 448 frame_caret_->LayoutBlockWillBeDestroyed(block); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 if (Element* element = GetDocument().FocusedElement()) | 700 if (Element* element = GetDocument().FocusedElement()) |
703 element->FocusStateChanged(); | 701 element->FocusStateChanged(); |
704 | 702 |
705 GetDocument().UpdateStyleAndLayoutTree(); | 703 GetDocument().UpdateStyleAndLayoutTree(); |
706 | 704 |
707 // Because LayoutObject::selectionBackgroundColor() and | 705 // Because LayoutObject::selectionBackgroundColor() and |
708 // LayoutObject::selectionForegroundColor() check if the frame is active, | 706 // LayoutObject::selectionForegroundColor() check if the frame is active, |
709 // we have to update places those colors were painted. | 707 // we have to update places those colors were painted. |
710 LayoutViewItem view = GetDocument().GetLayoutViewItem(); | 708 LayoutViewItem view = GetDocument().GetLayoutViewItem(); |
711 if (!view.IsNull()) | 709 if (!view.IsNull()) |
712 view.InvalidatePaintForSelection(); | 710 layout_selection_->InvalidatePaintForSelection(); |
713 | 711 |
714 // Caret appears in the active frame. | 712 // Caret appears in the active frame. |
715 if (active_and_focused) | 713 if (active_and_focused) |
716 SetSelectionFromNone(); | 714 SetSelectionFromNone(); |
717 else | 715 else |
718 frame_->GetSpellChecker().SpellCheckAfterBlur(); | 716 frame_->GetSpellChecker().SpellCheckAfterBlur(); |
719 frame_caret_->SetCaretVisibility(active_and_focused | 717 frame_caret_->SetCaretVisibility(active_and_focused |
720 ? CaretVisibility::kVisible | 718 ? CaretVisibility::kVisible |
721 : CaretVisibility::kHidden); | 719 : CaretVisibility::kHidden); |
722 | 720 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 } | 877 } |
880 | 878 |
881 LayoutRect FrameSelection::UnclippedBounds() const { | 879 LayoutRect FrameSelection::UnclippedBounds() const { |
882 FrameView* view = frame_->View(); | 880 FrameView* view = frame_->View(); |
883 LayoutViewItem layout_view = frame_->ContentLayoutItem(); | 881 LayoutViewItem layout_view = frame_->ContentLayoutItem(); |
884 | 882 |
885 if (!view || layout_view.IsNull()) | 883 if (!view || layout_view.IsNull()) |
886 return LayoutRect(); | 884 return LayoutRect(); |
887 | 885 |
888 view->UpdateLifecycleToLayoutClean(); | 886 view->UpdateLifecycleToLayoutClean(); |
889 return LayoutRect(layout_view.SelectionBounds()); | 887 return LayoutRect(layout_selection_->SelectionBounds()); |
890 } | 888 } |
891 | 889 |
892 static inline HTMLFormElement* AssociatedFormElement(HTMLElement& element) { | 890 static inline HTMLFormElement* AssociatedFormElement(HTMLElement& element) { |
893 if (isHTMLFormElement(element)) | 891 if (isHTMLFormElement(element)) |
894 return &toHTMLFormElement(element); | 892 return &toHTMLFormElement(element); |
895 return element.formOwner(); | 893 return element.formOwner(); |
896 } | 894 } |
897 | 895 |
898 // Scans logically forward from "start", including any child frames. | 896 // Scans logically forward from "start", including any child frames. |
899 static HTMLFormElement* ScanForForm(Node* start) { | 897 static HTMLFormElement* ScanForForm(Node* start) { |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 } | 1138 } |
1141 | 1139 |
1142 Range* FrameSelection::DocumentCachedRange() const { | 1140 Range* FrameSelection::DocumentCachedRange() const { |
1143 return selection_editor_->DocumentCachedRange(); | 1141 return selection_editor_->DocumentCachedRange(); |
1144 } | 1142 } |
1145 | 1143 |
1146 void FrameSelection::ClearDocumentCachedRange() { | 1144 void FrameSelection::ClearDocumentCachedRange() { |
1147 selection_editor_->ClearDocumentCachedRange(); | 1145 selection_editor_->ClearDocumentCachedRange(); |
1148 } | 1146 } |
1149 | 1147 |
| 1148 void FrameSelection::LayoutSelectionStartEnd(int& start_pos, int& end_pos) { |
| 1149 layout_selection_->SelectionStartEnd(start_pos, end_pos); |
| 1150 } |
| 1151 |
| 1152 void FrameSelection::ClearLayoutSelection() { |
| 1153 layout_selection_->ClearSelection(); |
| 1154 } |
| 1155 |
1150 } // namespace blink | 1156 } // namespace blink |
1151 | 1157 |
1152 #ifndef NDEBUG | 1158 #ifndef NDEBUG |
1153 | 1159 |
1154 void showTree(const blink::FrameSelection& sel) { | 1160 void showTree(const blink::FrameSelection& sel) { |
1155 sel.ShowTreeForThis(); | 1161 sel.ShowTreeForThis(); |
1156 } | 1162 } |
1157 | 1163 |
1158 void showTree(const blink::FrameSelection* sel) { | 1164 void showTree(const blink::FrameSelection* sel) { |
1159 if (sel) | 1165 if (sel) |
1160 sel->ShowTreeForThis(); | 1166 sel->ShowTreeForThis(); |
1161 else | 1167 else |
1162 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; | 1168 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; |
1163 } | 1169 } |
1164 | 1170 |
1165 #endif | 1171 #endif |
OLD | NEW |