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

Side by Side Diff: Source/core/frame/FrameView.cpp

Issue 929213004: Plumb selection bounds as a single unit (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: TODO for moving WebSelectionBound Created 5 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 | « Source/core/frame/FrameView.h ('k') | Source/core/layout/compositing/CompositedSelection.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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 26 matching lines...) Expand all
37 #include "core/editing/FrameSelection.h" 37 #include "core/editing/FrameSelection.h"
38 #include "core/editing/RenderedPosition.h" 38 #include "core/editing/RenderedPosition.h"
39 #include "core/events/OverflowEvent.h" 39 #include "core/events/OverflowEvent.h"
40 #include "core/fetch/ResourceFetcher.h" 40 #include "core/fetch/ResourceFetcher.h"
41 #include "core/fetch/ResourceLoadPriorityOptimizer.h" 41 #include "core/fetch/ResourceLoadPriorityOptimizer.h"
42 #include "core/frame/FrameHost.h" 42 #include "core/frame/FrameHost.h"
43 #include "core/frame/LocalFrame.h" 43 #include "core/frame/LocalFrame.h"
44 #include "core/frame/Settings.h" 44 #include "core/frame/Settings.h"
45 #include "core/html/HTMLFrameElement.h" 45 #include "core/html/HTMLFrameElement.h"
46 #include "core/html/HTMLPlugInElement.h" 46 #include "core/html/HTMLPlugInElement.h"
47 #include "core/html/HTMLTextFormControlElement.h"
47 #include "core/html/parser/TextResourceDecoder.h" 48 #include "core/html/parser/TextResourceDecoder.h"
48 #include "core/inspector/InspectorInstrumentation.h" 49 #include "core/inspector/InspectorInstrumentation.h"
49 #include "core/inspector/InspectorTraceEvents.h" 50 #include "core/inspector/InspectorTraceEvents.h"
50 #include "core/layout/LayoutAnalyzer.h" 51 #include "core/layout/LayoutAnalyzer.h"
51 #include "core/layout/LayoutCounter.h" 52 #include "core/layout/LayoutCounter.h"
52 #include "core/layout/LayoutEmbeddedObject.h" 53 #include "core/layout/LayoutEmbeddedObject.h"
53 #include "core/layout/LayoutListBox.h" 54 #include "core/layout/LayoutListBox.h"
54 #include "core/layout/LayoutPart.h" 55 #include "core/layout/LayoutPart.h"
55 #include "core/layout/LayoutScrollbar.h" 56 #include "core/layout/LayoutScrollbar.h"
56 #include "core/layout/LayoutScrollbarPart.h" 57 #include "core/layout/LayoutScrollbarPart.h"
57 #include "core/layout/LayoutTheme.h" 58 #include "core/layout/LayoutTheme.h"
58 #include "core/layout/LayoutView.h" 59 #include "core/layout/LayoutView.h"
59 #include "core/layout/TextAutosizer.h" 60 #include "core/layout/TextAutosizer.h"
60 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h" 61 #include "core/layout/compositing/CompositedDeprecatedPaintLayerMapping.h"
61 #include "core/layout/compositing/CompositedSelectionBound.h" 62 #include "core/layout/compositing/CompositedSelection.h"
62 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" 63 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h"
63 #include "core/style/ComputedStyle.h" 64 #include "core/style/ComputedStyle.h"
64 #include "core/layout/svg/LayoutSVGRoot.h" 65 #include "core/layout/svg/LayoutSVGRoot.h"
65 #include "core/loader/FrameLoader.h" 66 #include "core/loader/FrameLoader.h"
66 #include "core/loader/FrameLoaderClient.h" 67 #include "core/loader/FrameLoaderClient.h"
67 #include "core/page/Chrome.h" 68 #include "core/page/Chrome.h"
68 #include "core/page/ChromeClient.h" 69 #include "core/page/ChromeClient.h"
69 #include "core/page/EventHandler.h" 70 #include "core/page/EventHandler.h"
70 #include "core/page/FocusController.h" 71 #include "core/page/FocusController.h"
71 #include "core/page/FrameTree.h" 72 #include "core/page/FrameTree.h"
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 // If there fixed position elements, scrolling may cause compositing layers to change. 1679 // If there fixed position elements, scrolling may cause compositing layers to change.
1679 // Update widget and layer positions after scrolling, but only if we're not inside of 1680 // Update widget and layer positions after scrolling, but only if we're not inside of
1680 // layout. 1681 // layout.
1681 if (!m_nestedLayoutCount) { 1682 if (!m_nestedLayoutCount) {
1682 updateWidgetPositions(); 1683 updateWidgetPositions();
1683 if (LayoutView* layoutView = this->layoutView()) 1684 if (LayoutView* layoutView = this->layoutView())
1684 layoutView->layer()->setNeedsCompositingInputsUpdate(); 1685 layoutView->layer()->setNeedsCompositingInputsUpdate();
1685 } 1686 }
1686 } 1687 }
1687 1688
1688 bool FrameView::computeCompositedSelectionBounds(LocalFrame& frame, CompositedSe lectionBound& start, CompositedSelectionBound& end) 1689 bool FrameView::computeCompositedSelection(LocalFrame& frame, CompositedSelectio n& selection)
1689 { 1690 {
1690 const VisibleSelection &selection = frame.selection().selection(); 1691 const VisibleSelection& visibleSelection = frame.selection().selection();
1691 if (!selection.isCaretOrRange()) 1692 if (!visibleSelection.isCaretOrRange())
1692 return false; 1693 return false;
1693 1694
1694 VisiblePosition visibleStart(selection.visibleStart()); 1695 VisiblePosition visibleStart(visibleSelection.visibleStart());
1695 VisiblePosition visibleEnd(selection.visibleEnd()); 1696 VisiblePosition visibleEnd(visibleSelection.visibleEnd());
1696 1697
1697 RenderedPosition renderedStart(visibleStart); 1698 RenderedPosition renderedStart(visibleStart);
1698 RenderedPosition renderedEnd(visibleEnd); 1699 RenderedPosition renderedEnd(visibleEnd);
1699 1700
1700 renderedStart.positionInGraphicsLayerBacking(start); 1701 renderedStart.positionInGraphicsLayerBacking(selection.start);
1701 if (!start.layer) 1702 if (!selection.start.layer)
1702 return false; 1703 return false;
1703 1704
1704 renderedEnd.positionInGraphicsLayerBacking(end); 1705 renderedEnd.positionInGraphicsLayerBacking(selection.end);
1705 if (!end.layer) 1706 if (!selection.end.layer)
1706 return false; 1707 return false;
1707 1708
1708 if (selection.isCaret()) { 1709 selection.type = visibleSelection.selectionType();
1709 start.type = end.type = CompositedSelectionBound::Caret; 1710 selection.isEditable = visibleSelection.isContentEditable();
1710 return true; 1711 if (selection.isEditable) {
1712 if (HTMLTextFormControlElement* enclosingTextFormControlElement = enclos ingTextFormControl(visibleSelection.rootEditableElement()))
1713 selection.isEmptyTextFormControl = enclosingTextFormControlElement-> value().isEmpty();
1711 } 1714 }
1715 selection.start.isTextDirectionRTL = visibleStart.deepEquivalent().primaryDi rection() == RTL;
1716 selection.end.isTextDirectionRTL = visibleEnd.deepEquivalent().primaryDirect ion() == RTL;
1712 1717
1713 TextDirection startDir = visibleStart.deepEquivalent().primaryDirection();
1714 TextDirection endDir = visibleEnd.deepEquivalent().primaryDirection();
1715 start.type = startDir == RTL ? CompositedSelectionBound::SelectionRight : Co mpositedSelectionBound::SelectionLeft;
1716 end.type = endDir == RTL ? CompositedSelectionBound::SelectionLeft : Composi tedSelectionBound::SelectionRight;
1717 return true; 1718 return true;
1718 } 1719 }
1719 1720
1720 void FrameView::updateCompositedSelectionBoundsIfNeeded() 1721 void FrameView::updateCompositedSelectionIfNeeded()
1721 { 1722 {
1722 if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled()) 1723 if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled())
1723 return; 1724 return;
1724 1725
1725 Page* page = frame().page(); 1726 Page* page = frame().page();
1726 ASSERT(page); 1727 ASSERT(page);
1727 1728
1728 CompositedSelectionBound start, end; 1729 CompositedSelection selection;
1729 LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame( )); 1730 LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame( ));
1730 if (!frame || !computeCompositedSelectionBounds(*frame, start, end)) { 1731 if (!frame || !computeCompositedSelection(*frame, selection)) {
1731 page->chrome().client().clearCompositedSelectionBounds(); 1732 page->chrome().client().clearCompositedSelection();
1732 return; 1733 return;
1733 } 1734 }
1734 1735
1735 page->chrome().client().updateCompositedSelectionBounds(start, end); 1736 page->chrome().client().updateCompositedSelection(selection);
1736 } 1737 }
1737 1738
1738 HostWindow* FrameView::hostWindow() const 1739 HostWindow* FrameView::hostWindow() const
1739 { 1740 {
1740 Page* page = frame().page(); 1741 Page* page = frame().page();
1741 if (!page) 1742 if (!page)
1742 return nullptr; 1743 return nullptr;
1743 return &page->chrome(); 1744 return &page->chrome();
1744 } 1745 }
1745 1746
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
2583 2584
2584 LayoutView* view = layoutView(); 2585 LayoutView* view = layoutView();
2585 if (view) { 2586 if (view) {
2586 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up dateLayerTree", "data", InspectorUpdateLayerTreeEvent::data(m_frame.get())); 2587 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up dateLayerTree", "data", InspectorUpdateLayerTreeEvent::data(m_frame.get()));
2587 2588
2588 view->compositor()->updateIfNeededRecursive(); 2589 view->compositor()->updateIfNeededRecursive();
2589 2590
2590 if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot()) 2591 if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot())
2591 scrollingCoordinator()->updateAfterCompositingChangeIfNeeded(); 2592 scrollingCoordinator()->updateAfterCompositingChangeIfNeeded();
2592 2593
2593 updateCompositedSelectionBoundsIfNeeded(); 2594 updateCompositedSelectionIfNeeded();
2594 2595
2595 scrollContentsIfNeededRecursive(); 2596 scrollContentsIfNeededRecursive();
2596 2597
2597 invalidateTreeIfNeededRecursive(); 2598 invalidateTreeIfNeededRecursive();
2598 2599
2599 ASSERT(!view->hasPendingSelection()); 2600 ASSERT(!view->hasPendingSelection());
2600 } 2601 }
2601 2602
2602 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean); 2603 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean);
2603 } 2604 }
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
4104 { 4105 {
4105 Settings* settings = frame().settings(); 4106 Settings* settings = frame().settings();
4106 if (!settings || !settings->rootLayerScrolls()) 4107 if (!settings || !settings->rootLayerScrolls())
4107 return this; 4108 return this;
4108 4109
4109 LayoutView* layoutView = this->layoutView(); 4110 LayoutView* layoutView = this->layoutView();
4110 return layoutView ? layoutView->scrollableArea() : nullptr; 4111 return layoutView ? layoutView->scrollableArea() : nullptr;
4111 } 4112 }
4112 4113
4113 } // namespace blink 4114 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/layout/compositing/CompositedSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698