Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 #include "core/page/InjectedStyleSheets.h" | 72 #include "core/page/InjectedStyleSheets.h" |
| 73 #include "core/page/Page.h" | 73 #include "core/page/Page.h" |
| 74 #include "core/page/PagePopupClient.h" | 74 #include "core/page/PagePopupClient.h" |
| 75 #include "core/page/PointerLockController.h" | 75 #include "core/page/PointerLockController.h" |
| 76 #include "core/page/ScopedPageLoadDeferrer.h" | 76 #include "core/page/ScopedPageLoadDeferrer.h" |
| 77 #include "core/page/TouchDisambiguation.h" | 77 #include "core/page/TouchDisambiguation.h" |
| 78 #include "core/rendering/FastTextAutosizer.h" | 78 #include "core/rendering/FastTextAutosizer.h" |
| 79 #include "core/rendering/RenderView.h" | 79 #include "core/rendering/RenderView.h" |
| 80 #include "core/rendering/RenderWidget.h" | 80 #include "core/rendering/RenderWidget.h" |
| 81 #include "core/rendering/TextAutosizer.h" | 81 #include "core/rendering/TextAutosizer.h" |
| 82 #include "core/rendering/compositing/CompositedLayerMapping.h" | |
| 82 #include "core/rendering/compositing/RenderLayerCompositor.h" | 83 #include "core/rendering/compositing/RenderLayerCompositor.h" |
| 83 #include "modules/device_orientation/DeviceOrientationInspectorAgent.h" | 84 #include "modules/device_orientation/DeviceOrientationInspectorAgent.h" |
| 84 #include "modules/encryptedmedia/MediaKeysController.h" | 85 #include "modules/encryptedmedia/MediaKeysController.h" |
| 85 #include "modules/indexeddb/InspectorIndexedDBAgent.h" | 86 #include "modules/indexeddb/InspectorIndexedDBAgent.h" |
| 86 #include "modules/push_messaging/PushController.h" | 87 #include "modules/push_messaging/PushController.h" |
| 87 #include "modules/screen_orientation/ScreenOrientationController.h" | 88 #include "modules/screen_orientation/ScreenOrientationController.h" |
| 88 #include "platform/ContextMenu.h" | 89 #include "platform/ContextMenu.h" |
| 89 #include "platform/ContextMenuItem.h" | 90 #include "platform/ContextMenuItem.h" |
| 90 #include "platform/Cursor.h" | 91 #include "platform/Cursor.h" |
| 91 #include "platform/KeyboardCodes.h" | 92 #include "platform/KeyboardCodes.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 116 #include "public/web/WebActiveWheelFlingParameters.h" | 117 #include "public/web/WebActiveWheelFlingParameters.h" |
| 117 #include "public/web/WebAutofillClient.h" | 118 #include "public/web/WebAutofillClient.h" |
| 118 #include "public/web/WebFrameClient.h" | 119 #include "public/web/WebFrameClient.h" |
| 119 #include "public/web/WebHitTestResult.h" | 120 #include "public/web/WebHitTestResult.h" |
| 120 #include "public/web/WebInputElement.h" | 121 #include "public/web/WebInputElement.h" |
| 121 #include "public/web/WebMediaPlayerAction.h" | 122 #include "public/web/WebMediaPlayerAction.h" |
| 122 #include "public/web/WebNode.h" | 123 #include "public/web/WebNode.h" |
| 123 #include "public/web/WebPlugin.h" | 124 #include "public/web/WebPlugin.h" |
| 124 #include "public/web/WebPluginAction.h" | 125 #include "public/web/WebPluginAction.h" |
| 125 #include "public/web/WebRange.h" | 126 #include "public/web/WebRange.h" |
| 127 #include "public/web/WebSelection.h" | |
| 126 #include "public/web/WebTextInputInfo.h" | 128 #include "public/web/WebTextInputInfo.h" |
| 127 #include "public/web/WebViewClient.h" | 129 #include "public/web/WebViewClient.h" |
| 128 #include "public/web/WebWindowFeatures.h" | 130 #include "public/web/WebWindowFeatures.h" |
| 129 #include "web/CompositionUnderlineVectorBuilder.h" | 131 #include "web/CompositionUnderlineVectorBuilder.h" |
| 130 #include "web/ContextFeaturesClientImpl.h" | 132 #include "web/ContextFeaturesClientImpl.h" |
| 131 #include "web/DatabaseClientImpl.h" | 133 #include "web/DatabaseClientImpl.h" |
| 132 #include "web/FullscreenController.h" | 134 #include "web/FullscreenController.h" |
| 133 #include "web/GraphicsLayerFactoryChromium.h" | 135 #include "web/GraphicsLayerFactoryChromium.h" |
| 134 #include "web/LinkHighlight.h" | 136 #include "web/LinkHighlight.h" |
| 135 #include "web/LocalFileSystemClient.h" | 137 #include "web/LocalFileSystemClient.h" |
| (...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1715 } | 1717 } |
| 1716 | 1718 |
| 1717 void WebViewImpl::layout() | 1719 void WebViewImpl::layout() |
| 1718 { | 1720 { |
| 1719 TRACE_EVENT0("webkit", "WebViewImpl::layout"); | 1721 TRACE_EVENT0("webkit", "WebViewImpl::layout"); |
| 1720 PageWidgetDelegate::layout(m_page.get()); | 1722 PageWidgetDelegate::layout(m_page.get()); |
| 1721 updateLayerTreeBackgroundColor(); | 1723 updateLayerTreeBackgroundColor(); |
| 1722 | 1724 |
| 1723 for (size_t i = 0; i < m_linkHighlights.size(); ++i) | 1725 for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
| 1724 m_linkHighlights[i]->updateGeometry(); | 1726 m_linkHighlights[i]->updateGeometry(); |
| 1727 | |
| 1728 updateLayerTreeSelection(); | |
| 1725 } | 1729 } |
| 1726 | 1730 |
| 1727 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) | 1731 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) |
| 1728 { | 1732 { |
| 1729 // This should only be used when compositing is not being used for this | 1733 // This should only be used when compositing is not being used for this |
| 1730 // WebView, and it is painting into the recording of its parent. | 1734 // WebView, and it is painting into the recording of its parent. |
| 1731 ASSERT(!isAcceleratedCompositingActive()); | 1735 ASSERT(!isAcceleratedCompositingActive()); |
| 1732 | 1736 |
| 1733 double paintStart = currentTime(); | 1737 double paintStart = currentTime(); |
| 1734 PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTran sparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque); | 1738 PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTran sparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque); |
| (...skipping 2265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4000 m_rootTransformLayer = m_page->mainFrame()->view()->renderView()->compos itor()->ensureRootTransformLayer(); | 4004 m_rootTransformLayer = m_page->mainFrame()->view()->renderView()->compos itor()->ensureRootTransformLayer(); |
| 4001 | 4005 |
| 4002 if (m_rootTransformLayer) { | 4006 if (m_rootTransformLayer) { |
| 4003 WebCore::TransformationMatrix transform; | 4007 WebCore::TransformationMatrix transform; |
| 4004 transform.translate(m_rootLayerOffset.width, m_rootLayerOffset.height); | 4008 transform.translate(m_rootLayerOffset.width, m_rootLayerOffset.height); |
| 4005 transform = transform.scale(m_rootLayerScale); | 4009 transform = transform.scale(m_rootLayerScale); |
| 4006 m_rootTransformLayer->setTransform(transform); | 4010 m_rootTransformLayer->setTransform(transform); |
| 4007 } | 4011 } |
| 4008 } | 4012 } |
| 4009 | 4013 |
| 4014 static FloatPoint convertTargetPointToCompositedLayerPoint(IntPoint point, Rende rObject* targetRenderer, RenderObject* compositedRenderer) | |
| 4015 { | |
| 4016 point = targetRenderer->frame()->view()->contentsToWindow(point); | |
| 4017 point = compositedRenderer->frame()->view()->windowToContents(point); | |
| 4018 return compositedRenderer->absoluteToLocal(point, UseTransforms); | |
| 4019 } | |
| 4020 | |
| 4021 static bool computeCompositedLayerAndRect(Node* node, IntRect absoluteRect, int& layerId, WebRect& layerRect) | |
|
aelias_OOO_until_Jul13
2014/06/12 06:02:01
Looks very similar to the logic in LinkHighlight.c
jdduke (slow)
2014/06/12 18:03:20
Any suggestions on where to place to put such code
| |
| 4022 { | |
| 4023 if (!node || !node->renderer()) | |
| 4024 return false; | |
| 4025 | |
| 4026 // Find the nearest enclosing composited layer and attach to it. We may need to cross frame boundaries | |
| 4027 // to find a suitable layer. | |
| 4028 RenderObject* renderer = node->renderer(); | |
| 4029 RenderLayer* renderLayer; | |
| 4030 do { | |
| 4031 renderLayer = renderer->enclosingLayer()->enclosingCompositingLayerForRe paint(); | |
| 4032 if (!renderLayer) { | |
| 4033 renderer = renderer->frame()->ownerRenderer(); | |
| 4034 if (!renderer) | |
| 4035 return false; | |
| 4036 } | |
| 4037 } while (!renderLayer); | |
| 4038 | |
| 4039 CompositedLayerMappingPtr compositedLayerMapping = renderLayer->compositingS tate() == PaintsIntoGroupedBacking ? renderLayer->groupedMapping() : renderLayer ->compositedLayerMapping(); | |
| 4040 GraphicsLayer* graphicsLayer = renderLayer->compositingState() == PaintsInto GroupedBacking ? compositedLayerMapping->squashingLayer() : compositedLayerMappi ng->mainGraphicsLayer(); | |
| 4041 | |
| 4042 if (!graphicsLayer->drawsContent()) { | |
| 4043 if (renderLayer->scrollableArea() && renderLayer->scrollableArea()->uses CompositedScrolling()) { | |
| 4044 ASSERT(renderLayer->hasCompositedLayerMapping() && renderLayer->comp ositedLayerMapping()->scrollingContentsLayer()); | |
| 4045 graphicsLayer = compositedLayerMapping->scrollingContentsLayer(); | |
| 4046 } | |
| 4047 } | |
| 4048 | |
| 4049 layerId = graphicsLayer->platformLayer()->id(); | |
| 4050 | |
| 4051 absoluteRect.move(-graphicsLayer->offsetFromRenderer()); | |
| 4052 | |
| 4053 FloatQuad layerQuad; | |
| 4054 layerQuad.setP1(convertTargetPointToCompositedLayerPoint(absoluteRect.minXMi nYCorner(), node->renderer(), renderLayer->renderer())); | |
| 4055 layerQuad.setP2(convertTargetPointToCompositedLayerPoint(absoluteRect.maxXMi nYCorner(), node->renderer(), renderLayer->renderer())); | |
| 4056 layerQuad.setP3(convertTargetPointToCompositedLayerPoint(absoluteRect.maxXMa xYCorner(), node->renderer(), renderLayer->renderer())); | |
| 4057 layerQuad.setP4(convertTargetPointToCompositedLayerPoint(absoluteRect.minXMa xYCorner(), node->renderer(), renderLayer->renderer())); | |
| 4058 layerRect = layerQuad.enclosingBoundingBox(); | |
| 4059 | |
| 4060 return true; | |
| 4061 } | |
| 4062 | |
| 4063 void WebViewImpl::updateLayerTreeSelection() | |
| 4064 { | |
| 4065 if (!m_layerTreeView || !settings()->compositedSelectionUpdatesEnabled()) | |
| 4066 return; | |
| 4067 | |
| 4068 const LocalFrame* frame = toLocalFrame(focusedWebCoreFrame()); | |
| 4069 if (!frame || !frame->selection().isCaretOrRange()) | |
| 4070 return m_layerTreeView->clearSelection(); | |
| 4071 | |
| 4072 FrameSelection& selection = frame->selection(); | |
| 4073 | |
| 4074 // TODO(jdduke): Cache selection and compare? | |
| 4075 if (selection.isCaret()) { | |
| 4076 WebSelection webSelection; | |
| 4077 if (!computeCompositedLayerAndRect(selection.rootEditableElementOrDocume ntElement(), | |
| 4078 selection.absoluteCaretBounds(), | |
| 4079 webSelection.anchorLayerId, | |
| 4080 webSelection.anchorRectInLayer)) { | |
| 4081 return m_layerTreeView->clearSelection(); | |
| 4082 } | |
| 4083 | |
| 4084 // TODO(jdduke): Populate editable bounds. | |
| 4085 webSelection.type = WebSelection::TypeInsertion; | |
| 4086 m_layerTreeView->registerSelection(webSelection); | |
| 4087 return; | |
| 4088 } | |
| 4089 | |
| 4090 RefPtrWillBeRawPtr<Range> selectedRange = selection.toNormalizedRange(); | |
| 4091 if (!selectedRange) | |
| 4092 return m_layerTreeView->clearSelection(); | |
| 4093 | |
| 4094 WebSelection webSelection; | |
| 4095 | |
| 4096 RefPtrWillBeRawPtr<Range> range(Range::create(selectedRange->startContainer( )->document(), | |
| 4097 selectedRange->startContainer(), | |
| 4098 selectedRange->startOffset(), | |
| 4099 selectedRange->startContainer(), | |
| 4100 selectedRange->startOffset())); | |
| 4101 IntRect anchor = frame->editor().firstRectForRange(range.get()); | |
| 4102 if (!computeCompositedLayerAndRect(selection.start().anchorNode(), | |
| 4103 anchor, | |
| 4104 webSelection.anchorLayerId, | |
| 4105 webSelection.anchorRectInLayer)) { | |
| 4106 return m_layerTreeView->clearSelection(); | |
| 4107 } | |
| 4108 | |
| 4109 range = Range::create(selectedRange->endContainer()->document(), | |
| 4110 selectedRange->endContainer(), | |
| 4111 selectedRange->endOffset(), | |
| 4112 selectedRange->endContainer(), | |
| 4113 selectedRange->endOffset()); | |
| 4114 IntRect focus = frame->editor().firstRectForRange(range.get()); | |
| 4115 if (!computeCompositedLayerAndRect(selection.end().anchorNode(), | |
| 4116 focus, | |
| 4117 webSelection.focusLayerId, | |
| 4118 webSelection.focusRectInLayer)) { | |
| 4119 return m_layerTreeView->clearSelection(); | |
| 4120 } | |
| 4121 | |
| 4122 // TODO(jdduke): Populate editable bounds. | |
| 4123 webSelection.type = WebSelection::TypeSelection; | |
| 4124 webSelection.anchorDirection = selection.start().primaryDirection() == RTL ? WebTextDirectionRightToLeft : WebTextDirectionLeftToRight; | |
| 4125 webSelection.focusDirection = selection.end().primaryDirection() == RTL ? We bTextDirectionRightToLeft : WebTextDirectionLeftToRight; | |
| 4126 webSelection.anchorIsFirst = selection.selection().isBaseFirst(); | |
| 4127 m_layerTreeView->registerSelection(webSelection); | |
| 4128 } | |
| 4129 | |
| 4010 bool WebViewImpl::detectContentOnTouch(const WebPoint& position) | 4130 bool WebViewImpl::detectContentOnTouch(const WebPoint& position) |
| 4011 { | 4131 { |
| 4012 HitTestResult touchHit = hitTestResultForWindowPos(position); | 4132 HitTestResult touchHit = hitTestResultForWindowPos(position); |
| 4013 | 4133 |
| 4014 if (touchHit.isContentEditable()) | 4134 if (touchHit.isContentEditable()) |
| 4015 return false; | 4135 return false; |
| 4016 | 4136 |
| 4017 Node* node = touchHit.innerNode(); | 4137 Node* node = touchHit.innerNode(); |
| 4018 if (!node || !node->isTextNode()) | 4138 if (!node || !node->isTextNode()) |
| 4019 return false; | 4139 return false; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4101 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); | 4221 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); |
| 4102 | 4222 |
| 4103 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4223 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 4104 return false; | 4224 return false; |
| 4105 | 4225 |
| 4106 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4226 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4107 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4227 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
| 4108 } | 4228 } |
| 4109 | 4229 |
| 4110 } // namespace blink | 4230 } // namespace blink |
| OLD | NEW |