Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/WebKit/Source/core/editing/FrameSelection.cpp

Issue 1885373005: [Layout API] Convert (most of) FrameSelection to use Document::layoutViewItem() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/api/LayoutViewItem.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 m_selectionEditor->setWithoutValidation(selection().end(), selection ().start()); 463 m_selectionEditor->setWithoutValidation(selection().end(), selection ().start());
464 } else if (intersectsNode(selection(), &node)) { 464 } else if (intersectsNode(selection(), &node)) {
465 // If we did nothing here, when this node's layoutObject was destroyed, the rect that it 465 // If we did nothing here, when this node's layoutObject was destroyed, the rect that it
466 // occupied would be invalidated, but, selection gaps that change as a r esult of 466 // occupied would be invalidated, but, selection gaps that change as a r esult of
467 // the removal wouldn't be invalidated. 467 // the removal wouldn't be invalidated.
468 // FIXME: Don't do so much unnecessary invalidation. 468 // FIXME: Don't do so much unnecessary invalidation.
469 clearLayoutTreeSelection = true; 469 clearLayoutTreeSelection = true;
470 } 470 }
471 471
472 if (clearLayoutTreeSelection) 472 if (clearLayoutTreeSelection)
473 selection().start().document()->layoutView()->clearSelection(); 473 selection().start().document()->layoutViewItem().clearSelection();
474 474
475 if (clearDOMTreeSelection) 475 if (clearDOMTreeSelection)
476 setSelection(VisibleSelection(), DoNotSetFocus); 476 setSelection(VisibleSelection(), DoNotSetFocus);
477 477
478 // TODO(yosin): We should move to call |TypingCommand::closeTyping()| to 478 // TODO(yosin): We should move to call |TypingCommand::closeTyping()| to
479 // |Editor| class. 479 // |Editor| class.
480 if (!m_frame->document()->isRunningExecCommand()) 480 if (!m_frame->document()->isRunningExecCommand())
481 TypingCommand::closeTyping(m_frame); 481 TypingCommand::closeTyping(m_frame);
482 } 482 }
483 483
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 { 735 {
736 if (selection().isCaret() && m_shouldPaintCaret) { 736 if (selection().isCaret() && m_shouldPaintCaret) {
737 m_caretBase->updateCaretRect(PositionWithAffinity(selection().start(), s election().affinity())); 737 m_caretBase->updateCaretRect(PositionWithAffinity(selection().start(), s election().affinity()));
738 m_caretBase->paintCaret(selection().start().anchorNode(), context, paint Offset); 738 m_caretBase->paintCaret(selection().start().anchorNode(), context, paint Offset);
739 } 739 }
740 } 740 }
741 741
742 bool FrameSelection::contains(const LayoutPoint& point) 742 bool FrameSelection::contains(const LayoutPoint& point)
743 { 743 {
744 Document* document = m_frame->document(); 744 Document* document = m_frame->document();
745 if (!document->layoutView()) 745 if (document->layoutViewItem().isNull())
746 return false; 746 return false;
747 747
748 // Treat a collapsed selection like no selection. 748 // Treat a collapsed selection like no selection.
749 const VisibleSelectionInFlatTree& visibleSelection = this->visibleSelection< EditingInFlatTreeStrategy>(); 749 const VisibleSelectionInFlatTree& visibleSelection = this->visibleSelection< EditingInFlatTreeStrategy>();
750 if (!visibleSelection.isRange()) 750 if (!visibleSelection.isRange())
751 return false; 751 return false;
752 752
753 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active); 753 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
754 HitTestResult result(request, point); 754 HitTestResult result(request, point);
755 document->layoutView()->hitTest(result); 755 document->layoutViewItem().hitTest(result);
756 Node* innerNode = result.innerNode(); 756 Node* innerNode = result.innerNode();
757 if (!innerNode || !innerNode->layoutObject()) 757 if (!innerNode || !innerNode->layoutObject())
758 return false; 758 return false;
759 759
760 const VisiblePositionInFlatTree& visiblePos = createVisiblePosition(fromPosi tionInDOMTree<EditingInFlatTreeStrategy>(innerNode->layoutObject()->positionForP oint(result.localPoint()))); 760 const VisiblePositionInFlatTree& visiblePos = createVisiblePosition(fromPosi tionInDOMTree<EditingInFlatTreeStrategy>(innerNode->layoutObject()->positionForP oint(result.localPoint())));
761 if (visiblePos.isNull()) 761 if (visiblePos.isNull())
762 return false; 762 return false;
763 763
764 const VisiblePositionInFlatTree& visibleStart = visibleSelection.visibleStar t(); 764 const VisiblePositionInFlatTree& visibleStart = visibleSelection.visibleStar t();
765 const VisiblePositionInFlatTree& visibleEnd = visibleSelection.visibleEnd(); 765 const VisiblePositionInFlatTree& visibleEnd = visibleSelection.visibleEnd();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 // the focused element hasn't changed, the evaluation of focus pseudo 926 // the focused element hasn't changed, the evaluation of focus pseudo
927 // selectors are dependent on whether the frame is focused and active. 927 // selectors are dependent on whether the frame is focused and active.
928 if (Element* element = document->focusedElement()) 928 if (Element* element = document->focusedElement())
929 element->focusStateChanged(); 929 element->focusStateChanged();
930 930
931 document->updateLayoutTree(); 931 document->updateLayoutTree();
932 932
933 // Because LayoutObject::selectionBackgroundColor() and 933 // Because LayoutObject::selectionBackgroundColor() and
934 // LayoutObject::selectionForegroundColor() check if the frame is active, 934 // LayoutObject::selectionForegroundColor() check if the frame is active,
935 // we have to update places those colors were painted. 935 // we have to update places those colors were painted.
936 if (LayoutView* view = document->layoutView()) 936 if (LayoutViewItem view = document->layoutViewItem())
eae 2016/04/17 18:17:50 Can this still be null?
937 view->invalidatePaintForSelection(); 937 view.invalidatePaintForSelection();
938 938
939 // Caret appears in the active frame. 939 // Caret appears in the active frame.
940 if (activeAndFocused) 940 if (activeAndFocused)
941 setSelectionFromNone(); 941 setSelectionFromNone();
942 else 942 else
943 m_frame->spellChecker().spellCheckAfterBlur(); 943 m_frame->spellChecker().spellCheckAfterBlur();
944 setCaretVisibility(activeAndFocused ? CaretVisibility::Visible : CaretVisibi lity::Hidden); 944 setCaretVisibility(activeAndFocused ? CaretVisibility::Visible : CaretVisibi lity::Hidden);
945 945
946 // Update for caps lock state 946 // Update for caps lock state
947 m_frame->eventHandler().capsLockStateMayHaveChanged(); 947 m_frame->eventHandler().capsLockStateMayHaveChanged();
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 1419
1420 void showTree(const blink::FrameSelection* sel) 1420 void showTree(const blink::FrameSelection* sel)
1421 { 1421 {
1422 if (sel) 1422 if (sel)
1423 sel->showTreeForThis(); 1423 sel->showTreeForThis();
1424 else 1424 else
1425 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); 1425 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n");
1426 } 1426 }
1427 1427
1428 #endif 1428 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/api/LayoutViewItem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698