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

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

Issue 302993003: Route selection bounds updates through WebLayerTreeView (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 4 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 | Source/core/page/ChromeClient.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 14 matching lines...) Expand all
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/frame/FrameView.h" 28 #include "core/frame/FrameView.h"
29 29
30 #include "core/HTMLNames.h" 30 #include "core/HTMLNames.h"
31 #include "core/accessibility/AXObjectCache.h" 31 #include "core/accessibility/AXObjectCache.h"
32 #include "core/css/FontFaceSet.h" 32 #include "core/css/FontFaceSet.h"
33 #include "core/css/resolver/StyleResolver.h" 33 #include "core/css/resolver/StyleResolver.h"
34 #include "core/dom/DocumentMarkerController.h" 34 #include "core/dom/DocumentMarkerController.h"
35 #include "core/editing/Editor.h"
35 #include "core/editing/FrameSelection.h" 36 #include "core/editing/FrameSelection.h"
36 #include "core/events/OverflowEvent.h" 37 #include "core/events/OverflowEvent.h"
37 #include "core/fetch/ResourceFetcher.h" 38 #include "core/fetch/ResourceFetcher.h"
38 #include "core/fetch/ResourceLoadPriorityOptimizer.h" 39 #include "core/fetch/ResourceLoadPriorityOptimizer.h"
39 #include "core/frame/FrameHost.h" 40 #include "core/frame/FrameHost.h"
40 #include "core/frame/LocalFrame.h" 41 #include "core/frame/LocalFrame.h"
41 #include "core/frame/Settings.h" 42 #include "core/frame/Settings.h"
42 #include "core/html/HTMLFrameElement.h" 43 #include "core/html/HTMLFrameElement.h"
43 #include "core/html/HTMLPlugInElement.h" 44 #include "core/html/HTMLPlugInElement.h"
44 #include "core/html/parser/TextResourceDecoder.h" 45 #include "core/html/parser/TextResourceDecoder.h"
(...skipping 14 matching lines...) Expand all
59 #include "core/rendering/RenderLayer.h" 60 #include "core/rendering/RenderLayer.h"
60 #include "core/rendering/RenderListBox.h" 61 #include "core/rendering/RenderListBox.h"
61 #include "core/rendering/RenderPart.h" 62 #include "core/rendering/RenderPart.h"
62 #include "core/rendering/RenderScrollbar.h" 63 #include "core/rendering/RenderScrollbar.h"
63 #include "core/rendering/RenderScrollbarPart.h" 64 #include "core/rendering/RenderScrollbarPart.h"
64 #include "core/rendering/RenderTheme.h" 65 #include "core/rendering/RenderTheme.h"
65 #include "core/rendering/RenderView.h" 66 #include "core/rendering/RenderView.h"
66 #include "core/rendering/RenderWidget.h" 67 #include "core/rendering/RenderWidget.h"
67 #include "core/rendering/TextAutosizer.h" 68 #include "core/rendering/TextAutosizer.h"
68 #include "core/rendering/compositing/CompositedLayerMapping.h" 69 #include "core/rendering/compositing/CompositedLayerMapping.h"
70 #include "core/rendering/compositing/CompositedSelectionBound.h"
69 #include "core/rendering/compositing/RenderLayerCompositor.h" 71 #include "core/rendering/compositing/RenderLayerCompositor.h"
70 #include "core/rendering/style/RenderStyle.h" 72 #include "core/rendering/style/RenderStyle.h"
71 #include "core/rendering/svg/RenderSVGRoot.h" 73 #include "core/rendering/svg/RenderSVGRoot.h"
72 #include "core/svg/SVGDocumentExtensions.h" 74 #include "core/svg/SVGDocumentExtensions.h"
73 #include "core/svg/SVGSVGElement.h" 75 #include "core/svg/SVGSVGElement.h"
74 #include "platform/RuntimeEnabledFeatures.h" 76 #include "platform/RuntimeEnabledFeatures.h"
75 #include "platform/ScriptForbiddenScope.h" 77 #include "platform/ScriptForbiddenScope.h"
76 #include "platform/TraceEvent.h" 78 #include "platform/TraceEvent.h"
77 #include "platform/fonts/FontCache.h" 79 #include "platform/fonts/FontCache.h"
78 #include "platform/geometry/FloatRect.h" 80 #include "platform/geometry/FloatRect.h"
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 1691
1690 // Also don't need to do this for invisible items. 1692 // Also don't need to do this for invisible items.
1691 if (layer->viewportConstrainedNotCompositedReason() == RenderLayer::NotC ompositedForBoundsOutOfView 1693 if (layer->viewportConstrainedNotCompositedReason() == RenderLayer::NotC ompositedForBoundsOutOfView
1692 || layer->viewportConstrainedNotCompositedReason() == RenderLayer::N otCompositedForNoVisibleContent) 1694 || layer->viewportConstrainedNotCompositedReason() == RenderLayer::N otCompositedForNoVisibleContent)
1693 continue; 1695 continue;
1694 1696
1695 layer->repainter().computeRepaintRectsIncludingNonCompositingDescendants (); 1697 layer->repainter().computeRepaintRectsIncludingNonCompositingDescendants ();
1696 } 1698 }
1697 } 1699 }
1698 1700
1701 static bool computeCompositedLayerAndRect(Node* node, IntRect absoluteRect, Grap hicsLayer*& layer, IntRect& layerRect)
1702 {
1703 RenderLayer* renderLayer;
1704 GraphicsLayer* graphicsLayer;
1705 if (!RenderLayerCompositor::computeEnclosingCompositingLayer(node, renderLay er, graphicsLayer))
1706 return false;
1707
1708 ASSERT(renderLayer);
1709 ASSERT(graphicsLayer);
1710
1711 absoluteRect.move(-graphicsLayer->offsetFromRenderer());
1712 FloatQuad absoluteQuad(absoluteRect);
1713 FloatQuad layerQuad;
1714 RenderLayerCompositor::convertTargetSpaceQuadToCompositedLayer(absoluteQuad, node->renderer(), renderLayer->renderer(), layerQuad);
1715
1716 layer = graphicsLayer;
1717
1718 // An enclosed rect avoids bounding box rounding outside the layer bounds.
1719 layerRect = enclosedIntRect(layerQuad.boundingBox());
1720
1721 // The delivered edge rect should have but a single dimension (height).
1722 // Note that this *should* also hold for the provided |absoluteRect|, but
1723 // zero-ing the width here gives a stronger guarantee.
1724 layerRect.setWidth(0);
1725
1726 return true;
1727 }
1728
1729 static bool computeCompositedSelectionBounds(LocalFrame& frame, CompositedSelect ionBound& start, CompositedSelectionBound& end)
1730 {
1731 FrameSelection& selection = frame.selection();
1732 if (!selection.isCaretOrRange())
1733 return false;
1734
1735 if (selection.isCaret()) {
1736 if (!computeCompositedLayerAndRect(selection.rootEditableElementOrDocume ntElement(), selection.absoluteCaretBounds(), start.layer, start.edgeRectInLayer ))
1737 return false;
1738 start.type = CompositedSelectionBound::Caret;
1739 end = start;
1740 return true;
1741 }
1742
1743 RefPtrWillBeRawPtr<Range> selectedRange = selection.toNormalizedRange();
1744 if (!selectedRange)
1745 return false;
1746
1747 RefPtrWillBeRawPtr<Range> range(Range::create(selectedRange->startContainer( )->document(),
1748 selectedRange->startContainer(),
1749 selectedRange->startOffset(),
1750 selectedRange->startContainer(),
1751 selectedRange->startOffset()));
1752 IntRect startRect = frame.editor().firstRectForRange(range.get());
1753 if (!computeCompositedLayerAndRect(selection.start().anchorNode(), startRect , start.layer, start.edgeRectInLayer))
1754 return false;
1755
1756 range = Range::create(selectedRange->endContainer()->document(),
1757 selectedRange->endContainer(),
1758 selectedRange->endOffset(),
1759 selectedRange->endContainer(),
1760 selectedRange->endOffset());
1761 IntRect endRect = frame.editor().firstRectForRange(range.get());
1762 if (!computeCompositedLayerAndRect(selection.end().anchorNode(), endRect, en d.layer, end.edgeRectInLayer))
1763 return false;
1764
1765 TextDirection startDir = selection.start().primaryDirection();
1766 TextDirection endDir = selection.end().primaryDirection();
1767 if (startDir == endDir) {
1768 if (startDir == RTL) {
1769 start.type = CompositedSelectionBound::SelectionRight;
1770 end.type = CompositedSelectionBound::SelectionLeft;
1771 } else {
1772 start.type = CompositedSelectionBound::SelectionLeft;
1773 end.type = CompositedSelectionBound::SelectionRight;
1774 }
1775 } else {
1776 if (startDir == RTL) {
1777 start.type = CompositedSelectionBound::SelectionRight;
1778 end.type = CompositedSelectionBound::SelectionRight;
1779 } else {
1780 start.type = CompositedSelectionBound::SelectionLeft;
1781 end.type = CompositedSelectionBound::SelectionLeft;
1782 }
1783 }
1784
1785 return true;
1786 }
1787
1699 void FrameView::updateCompositedSelectionBoundsIfNeeded() 1788 void FrameView::updateCompositedSelectionBoundsIfNeeded()
1700 { 1789 {
1701 if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled()) 1790 if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled())
1702 return; 1791 return;
1703 1792
1704 Page* page = frame().page(); 1793 Page* page = frame().page();
1705 ASSERT(page); 1794 ASSERT(page);
1706 1795
1796 CompositedSelectionBound start, end;
1707 LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame( )); 1797 LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame( ));
1708 if (!frame || !frame->selection().isCaretOrRange()) { 1798 if (!frame || !computeCompositedSelectionBounds(*frame, start, end)) {
1709 page->chrome().client().clearCompositedSelectionBounds(); 1799 page->chrome().client().clearCompositedSelectionBounds();
1710 return; 1800 return;
1711 } 1801 }
1712 1802
1713 // TODO(jdduke): Compute and route selection bounds through ChromeClient. 1803 page->chrome().client().updateCompositedSelectionBounds(start, end);
1714 } 1804 }
1715 1805
1716 bool FrameView::isRubberBandInProgress() const 1806 bool FrameView::isRubberBandInProgress() const
1717 { 1807 {
1718 if (scrollbarsSuppressed()) 1808 if (scrollbarsSuppressed())
1719 return false; 1809 return false;
1720 1810
1721 // If the main thread updates the scroll position for this FrameView, we sho uld return 1811 // If the main thread updates the scroll position for this FrameView, we sho uld return
1722 // ScrollAnimator::isRubberBandInProgress(). 1812 // ScrollAnimator::isRubberBandInProgress().
1723 if (ScrollAnimator* scrollAnimator = existingScrollAnimator()) 1813 if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after
3288 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation) 3378 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation)
3289 { 3379 {
3290 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); 3380 ScrollableArea::willRemoveScrollbar(scrollbar, orientation);
3291 if (AXObjectCache* cache = axObjectCache()) { 3381 if (AXObjectCache* cache = axObjectCache()) {
3292 cache->remove(scrollbar); 3382 cache->remove(scrollbar);
3293 cache->handleScrollbarUpdate(this); 3383 cache->handleScrollbarUpdate(this);
3294 } 3384 }
3295 } 3385 }
3296 3386
3297 } // namespace blink 3387 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/page/ChromeClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698