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

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 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
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/layout/style/LayoutStyle.h" 64 #include "core/layout/style/LayoutStyle.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 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 // If there fixed position elements, scrolling may cause compositing layers to change. 1648 // If there fixed position elements, scrolling may cause compositing layers to change.
1648 // Update widget and layer positions after scrolling, but only if we're not inside of 1649 // Update widget and layer positions after scrolling, but only if we're not inside of
1649 // layout. 1650 // layout.
1650 if (!m_nestedLayoutCount) { 1651 if (!m_nestedLayoutCount) {
1651 updateWidgetPositions(); 1652 updateWidgetPositions();
1652 if (LayoutView* layoutView = this->layoutView()) 1653 if (LayoutView* layoutView = this->layoutView())
1653 layoutView->layer()->setNeedsCompositingInputsUpdate(); 1654 layoutView->layer()->setNeedsCompositingInputsUpdate();
1654 } 1655 }
1655 } 1656 }
1656 1657
1657 bool FrameView::computeCompositedSelectionBounds(LocalFrame& frame, CompositedSe lectionBound& start, CompositedSelectionBound& end) 1658 bool FrameView::computeCompositedSelection(LocalFrame& frame, CompositedSelectio n& selection)
1658 { 1659 {
1659 const VisibleSelection &selection = frame.selection().selection(); 1660 const VisibleSelection& visibleSelection = frame.selection().selection();
1660 if (!selection.isCaretOrRange()) 1661 if (!visibleSelection.isCaretOrRange())
1661 return false; 1662 return false;
1662 1663
1663 VisiblePosition visibleStart(selection.visibleStart()); 1664 VisiblePosition visibleStart(visibleSelection.visibleStart());
1664 VisiblePosition visibleEnd(selection.visibleEnd()); 1665 VisiblePosition visibleEnd(visibleSelection.visibleEnd());
1665 1666
1666 RenderedPosition renderedStart(visibleStart); 1667 RenderedPosition renderedStart(visibleStart);
1667 RenderedPosition renderedEnd(visibleEnd); 1668 RenderedPosition renderedEnd(visibleEnd);
1668 1669
1669 renderedStart.positionInGraphicsLayerBacking(start); 1670 renderedStart.positionInGraphicsLayerBacking(selection.start);
1670 if (!start.layer) 1671 if (!selection.start.layer)
1671 return false; 1672 return false;
1672 1673
1673 renderedEnd.positionInGraphicsLayerBacking(end); 1674 renderedEnd.positionInGraphicsLayerBacking(selection.end);
1674 if (!end.layer) 1675 if (!selection.end.layer)
1675 return false; 1676 return false;
1676 1677
1677 if (selection.isCaret()) { 1678 selection.type = visibleSelection.selectionType();
1678 start.type = end.type = CompositedSelectionBound::Caret; 1679 selection.isEditable = visibleSelection.isContentEditable();
1679 return true; 1680 if (selection.isEditable) {
1681 if (HTMLTextFormControlElement* enclosingTextFormControlElement = enclos ingTextFormControl(visibleSelection.rootEditableElement()))
1682 selection.isEmptyTextFormControl = enclosingTextFormControlElement-> value().isEmpty();
1680 } 1683 }
1684 selection.start.isTextDirectionRTL = visibleStart.deepEquivalent().primaryDi rection() == RTL;
1685 selection.end.isTextDirectionRTL = visibleEnd.deepEquivalent().primaryDirect ion() == RTL;
1681 1686
1682 TextDirection startDir = visibleStart.deepEquivalent().primaryDirection();
1683 TextDirection endDir = visibleEnd.deepEquivalent().primaryDirection();
1684 start.type = startDir == RTL ? CompositedSelectionBound::SelectionRight : Co mpositedSelectionBound::SelectionLeft;
1685 end.type = endDir == RTL ? CompositedSelectionBound::SelectionLeft : Composi tedSelectionBound::SelectionRight;
1686 return true; 1687 return true;
1687 } 1688 }
1688 1689
1689 void FrameView::updateCompositedSelectionBoundsIfNeeded() 1690 void FrameView::updateCompositedSelectionIfNeeded()
1690 { 1691 {
1691 if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled()) 1692 if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled())
1692 return; 1693 return;
1693 1694
1694 Page* page = frame().page(); 1695 Page* page = frame().page();
1695 ASSERT(page); 1696 ASSERT(page);
1696 1697
1697 CompositedSelectionBound start, end; 1698 CompositedSelection selection;
1698 LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame( )); 1699 LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame( ));
1699 if (!frame || !computeCompositedSelectionBounds(*frame, start, end)) { 1700 if (!frame || !computeCompositedSelection(*frame, selection)) {
1700 page->chrome().client().clearCompositedSelectionBounds(); 1701 page->chrome().client().clearCompositedSelection();
1701 return; 1702 return;
1702 } 1703 }
1703 1704
1704 page->chrome().client().updateCompositedSelectionBounds(start, end); 1705 page->chrome().client().updateCompositedSelection(selection);
1705 } 1706 }
1706 1707
1707 HostWindow* FrameView::hostWindow() const 1708 HostWindow* FrameView::hostWindow() const
1708 { 1709 {
1709 Page* page = frame().page(); 1710 Page* page = frame().page();
1710 if (!page) 1711 if (!page)
1711 return nullptr; 1712 return nullptr;
1712 return &page->chrome(); 1713 return &page->chrome();
1713 } 1714 }
1714 1715
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
2548 2549
2549 LayoutView* view = layoutView(); 2550 LayoutView* view = layoutView();
2550 if (view) { 2551 if (view) {
2551 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up dateLayerTree", "data", InspectorUpdateLayerTreeEvent::data(m_frame.get())); 2552 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up dateLayerTree", "data", InspectorUpdateLayerTreeEvent::data(m_frame.get()));
2552 2553
2553 view->compositor()->updateIfNeededRecursive(); 2554 view->compositor()->updateIfNeededRecursive();
2554 2555
2555 if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot()) 2556 if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot())
2556 scrollingCoordinator()->updateAfterCompositingChangeIfNeeded(); 2557 scrollingCoordinator()->updateAfterCompositingChangeIfNeeded();
2557 2558
2558 updateCompositedSelectionBoundsIfNeeded(); 2559 updateCompositedSelectionIfNeeded();
2559 2560
2560 scrollContentsIfNeededRecursive(); 2561 scrollContentsIfNeededRecursive();
2561 2562
2562 invalidateTreeIfNeededRecursive(); 2563 invalidateTreeIfNeededRecursive();
2563 2564
2564 ASSERT(!view->hasPendingSelection()); 2565 ASSERT(!view->hasPendingSelection());
2565 } 2566 }
2566 2567
2567 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean); 2568 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean);
2568 } 2569 }
(...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after
4069 { 4070 {
4070 Settings* settings = frame().settings(); 4071 Settings* settings = frame().settings();
4071 if (!settings || !settings->rootLayerScrolls()) 4072 if (!settings || !settings->rootLayerScrolls())
4072 return this; 4073 return this;
4073 4074
4074 LayoutView* layoutView = this->layoutView(); 4075 LayoutView* layoutView = this->layoutView();
4075 return layoutView ? layoutView->scrollableArea() : nullptr; 4076 return layoutView ? layoutView->scrollableArea() : nullptr;
4076 } 4077 }
4077 4078
4078 } // namespace blink 4079 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698