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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 #include "core/events/KeyboardEvent.h" | 49 #include "core/events/KeyboardEvent.h" |
| 50 #include "core/events/WheelEvent.h" | 50 #include "core/events/WheelEvent.h" |
| 51 #include "core/frame/EventHandlerRegistry.h" | 51 #include "core/frame/EventHandlerRegistry.h" |
| 52 #include "core/frame/FrameHost.h" | 52 #include "core/frame/FrameHost.h" |
| 53 #include "core/frame/FrameView.h" | 53 #include "core/frame/FrameView.h" |
| 54 #include "core/frame/LocalFrame.h" | 54 #include "core/frame/LocalFrame.h" |
| 55 #include "core/frame/PinchViewport.h" | 55 #include "core/frame/PinchViewport.h" |
| 56 #include "core/frame/RemoteFrame.h" | 56 #include "core/frame/RemoteFrame.h" |
| 57 #include "core/frame/Settings.h" | 57 #include "core/frame/Settings.h" |
| 58 #include "core/frame/SmartClip.h" | 58 #include "core/frame/SmartClip.h" |
| 59 #include "core/frame/TopControls.h" | |
| 59 #include "core/html/HTMLInputElement.h" | 60 #include "core/html/HTMLInputElement.h" |
| 60 #include "core/html/HTMLMediaElement.h" | 61 #include "core/html/HTMLMediaElement.h" |
| 61 #include "core/html/HTMLPlugInElement.h" | 62 #include "core/html/HTMLPlugInElement.h" |
| 62 #include "core/html/HTMLTextAreaElement.h" | 63 #include "core/html/HTMLTextAreaElement.h" |
| 63 #include "core/html/canvas/WebGLRenderingContext.h" | 64 #include "core/html/canvas/WebGLRenderingContext.h" |
| 64 #include "core/html/forms/PopupMenuClient.h" | 65 #include "core/html/forms/PopupMenuClient.h" |
| 65 #include "core/html/ime/InputMethodContext.h" | 66 #include "core/html/ime/InputMethodContext.h" |
| 66 #include "core/inspector/InspectorController.h" | 67 #include "core/inspector/InspectorController.h" |
| 67 #include "core/layout/TextAutosizer.h" | 68 #include "core/layout/TextAutosizer.h" |
| 68 #include "core/layout/compositing/LayerCompositor.h" | 69 #include "core/layout/compositing/LayerCompositor.h" |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 , m_fullscreenController(FullscreenController::create(this)) | 407 , m_fullscreenController(FullscreenController::create(this)) |
| 407 , m_showFPSCounter(false) | 408 , m_showFPSCounter(false) |
| 408 , m_showPaintRects(false) | 409 , m_showPaintRects(false) |
| 409 , m_showDebugBorders(false) | 410 , m_showDebugBorders(false) |
| 410 , m_continuousPaintingEnabled(false) | 411 , m_continuousPaintingEnabled(false) |
| 411 , m_showScrollBottleneckRects(false) | 412 , m_showScrollBottleneckRects(false) |
| 412 , m_baseBackgroundColor(Color::white) | 413 , m_baseBackgroundColor(Color::white) |
| 413 , m_backgroundColorOverride(Color::transparent) | 414 , m_backgroundColorOverride(Color::transparent) |
| 414 , m_zoomFactorOverride(0) | 415 , m_zoomFactorOverride(0) |
| 415 , m_userGestureObserved(false) | 416 , m_userGestureObserved(false) |
| 416 , m_topControlsShownRatio(0) | |
| 417 , m_topControlsHeight(0) | |
| 418 , m_topControlsShrinkLayoutSize(true) | |
| 419 { | 417 { |
| 420 Page::PageClients pageClients; | 418 Page::PageClients pageClients; |
| 421 pageClients.chromeClient = &m_chromeClientImpl; | 419 pageClients.chromeClient = &m_chromeClientImpl; |
| 422 pageClients.contextMenuClient = &m_contextMenuClientImpl; | 420 pageClients.contextMenuClient = &m_contextMenuClientImpl; |
| 423 pageClients.editorClient = &m_editorClientImpl; | 421 pageClients.editorClient = &m_editorClientImpl; |
| 424 pageClients.dragClient = &m_dragClientImpl; | 422 pageClients.dragClient = &m_dragClientImpl; |
| 425 pageClients.inspectorClient = &m_inspectorClientImpl; | 423 pageClients.inspectorClient = &m_inspectorClientImpl; |
| 426 pageClients.spellCheckerClient = &m_spellCheckerClientImpl; | 424 pageClients.spellCheckerClient = &m_spellCheckerClientImpl; |
| 427 | 425 |
| 428 m_page = adoptPtrWillBeNoop(new Page(pageClients)); | 426 m_page = adoptPtrWillBeNoop(new Page(pageClients)); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 701 // Scrolling-related gesture events invoke EventHandler recursively for each frame down | 699 // Scrolling-related gesture events invoke EventHandler recursively for each frame down |
| 702 // the chain, doing a single-frame hit-test per frame. This matches hand leWheelEvent. | 700 // the chain, doing a single-frame hit-test per frame. This matches hand leWheelEvent. |
| 703 // Perhaps we could simplify things by rewriting scroll handling to work inner frame | 701 // Perhaps we could simplify things by rewriting scroll handling to work inner frame |
| 704 // out, and then unify with other gesture events. | 702 // out, and then unify with other gesture events. |
| 705 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureS crollEvent(platformEvent); | 703 eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureS crollEvent(platformEvent); |
| 706 m_client->didHandleGestureEvent(event, eventCancelled); | 704 m_client->didHandleGestureEvent(event, eventCancelled); |
| 707 return eventSwallowed; | 705 return eventSwallowed; |
| 708 case WebInputEvent::GesturePinchBegin: | 706 case WebInputEvent::GesturePinchBegin: |
| 709 case WebInputEvent::GesturePinchEnd: | 707 case WebInputEvent::GesturePinchEnd: |
| 710 case WebInputEvent::GesturePinchUpdate: | 708 case WebInputEvent::GesturePinchUpdate: |
| 711 // Gesture pinch events are aborted in PageWidgetDelegate::handleInputEv ent and should | |
| 712 // not reach here. | |
| 713 ASSERT_NOT_REACHED(); | |
| 714 return false; | 709 return false; |
| 715 default: | 710 default: |
| 716 break; | 711 break; |
| 717 } | 712 } |
| 718 | 713 |
| 719 // Hit test across all frames and do touch adjustment as necessary for the e vent type. | 714 // Hit test across all frames and do touch adjustment as necessary for the e vent type. |
| 720 GestureEventWithHitTestResults targetedEvent = | 715 GestureEventWithHitTestResults targetedEvent = |
| 721 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(pl atformEvent); | 716 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(pl atformEvent); |
| 722 | 717 |
| 723 // Handle link highlighting outside the main switch to avoid getting lost in the | 718 // Handle link highlighting outside the main switch to avoid getting lost in the |
| (...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1699 // and thus will not be invalidated in |FrameView::performPreLayoutTasks|. | 1694 // and thus will not be invalidated in |FrameView::performPreLayoutTasks|. |
| 1700 // Therefore we should force explicit media queries invalidation here. | 1695 // Therefore we should force explicit media queries invalidation here. |
| 1701 if (page()->inspectorController().deviceEmulationEnabled()) { | 1696 if (page()->inspectorController().deviceEmulationEnabled()) { |
| 1702 if (Document* document = mainFrameImpl()->frame()->document()) { | 1697 if (Document* document = mainFrameImpl()->frame()->document()) { |
| 1703 document->styleResolverChanged(); | 1698 document->styleResolverChanged(); |
| 1704 document->mediaQueryAffectingValueChanged(); | 1699 document->mediaQueryAffectingValueChanged(); |
| 1705 } | 1700 } |
| 1706 } | 1701 } |
| 1707 } | 1702 } |
| 1708 | 1703 |
| 1709 void WebViewImpl::setTopControlsShownRatio(float offset) | 1704 void WebViewImpl::setTopControlsShownRatio(float offset) |
|
Rick Byers
2015/02/19 16:38:38
looks like this no longer has any callers, remove
majidvp
2015/02/19 19:18:01
Done.
| |
| 1710 { | 1705 { |
| 1711 m_topControlsShownRatio = offset; | 1706 topControls().setShownRatio(offset); |
| 1712 m_layerTreeView->setTopControlsShownRatio(offset); | |
| 1713 didUpdateTopControls(); | |
| 1714 } | 1707 } |
| 1715 | 1708 |
| 1716 void WebViewImpl::setTopControlsHeight(float height, bool topControlsShrinkLayou tSize) | 1709 void WebViewImpl::setTopControlsHeight(float height, bool topControlsShrinkLayou tSize) |
| 1717 { | 1710 { |
| 1718 if (m_topControlsHeight == height && m_topControlsShrinkLayoutSize == topCon trolsShrinkLayoutSize) | 1711 topControls().setHeight(height, topControlsShrinkLayoutSize); |
| 1719 return; | 1712 } |
| 1720 | 1713 |
| 1721 m_topControlsHeight = height; | 1714 void WebViewImpl::updateTopControlsState(WebTopControlsState constraint, WebTopC ontrolsState current, bool animate) |
| 1722 m_topControlsShrinkLayoutSize = topControlsShrinkLayoutSize; | 1715 { |
| 1723 didUpdateTopControls(); | 1716 topControls().updateConstraints(constraint); |
| 1717 m_layerTreeView->updateTopControlsState(constraint, current, animate); | |
| 1724 } | 1718 } |
| 1725 | 1719 |
| 1726 void WebViewImpl::didUpdateTopControls() | 1720 void WebViewImpl::didUpdateTopControls() |
| 1727 { | 1721 { |
| 1722 if (m_layerTreeView) { | |
| 1723 m_layerTreeView->setTopControlsShownRatio(topControls().shownRatio()); | |
| 1724 m_layerTreeView->setTopControlsHeight(topControls().height(), topControl s().shrinkViewport()); | |
| 1725 } | |
| 1726 | |
| 1728 WebLocalFrameImpl* mainFrame = mainFrameImpl(); | 1727 WebLocalFrameImpl* mainFrame = mainFrameImpl(); |
| 1729 if (!mainFrame) | 1728 if (!mainFrame) |
| 1730 return; | 1729 return; |
| 1731 | 1730 |
| 1732 FrameView* view = mainFrame->frameView(); | 1731 FrameView* view = mainFrame->frameView(); |
| 1733 if (!view) | 1732 if (!view) |
| 1734 return; | 1733 return; |
| 1735 | 1734 |
| 1736 float topControlsViewportAdjustment = 0; | 1735 float topControlsViewportAdjustment = topControls().layoutHeight() - topCont rols().contentOffset(); |
| 1737 if (m_topControlsShrinkLayoutSize) | |
| 1738 topControlsViewportAdjustment += m_topControlsHeight; | |
| 1739 topControlsViewportAdjustment -= m_topControlsShownRatio * m_topControlsHeig ht; | |
| 1740 | 1736 |
| 1741 if (!pinchVirtualViewportEnabled()) { | 1737 if (!pinchVirtualViewportEnabled()) { |
| 1742 // The viewport bounds were adjusted on the compositor by this much due to top controls. Tell | 1738 // The viewport bounds were adjusted on the compositor by this much due to top controls. Tell |
| 1743 // the FrameView about it so it can make correct scroll offset clamping decisions during compositor | 1739 // the FrameView about it so it can make correct scroll offset clamping decisions during compositor |
| 1744 // commits. | 1740 // commits. |
| 1745 view->setTopControlsViewportAdjustment(topControlsViewportAdjustment); | 1741 view->setTopControlsViewportAdjustment(topControlsViewportAdjustment); |
| 1746 } else { | 1742 } else { |
| 1747 PinchViewport& pinchViewport = page()->frameHost().pinchViewport(); | 1743 PinchViewport& pinchViewport = page()->frameHost().pinchViewport(); |
| 1748 | 1744 |
| 1749 if (pinchViewport.visibleRect().isEmpty()) | 1745 if (pinchViewport.visibleRect().isEmpty()) |
| 1750 return; | 1746 return; |
| 1751 | 1747 |
| 1752 pinchViewport.setTopControlsAdjustment(topControlsViewportAdjustment); | 1748 pinchViewport.setTopControlsAdjustment(topControlsViewportAdjustment); |
| 1753 | 1749 |
| 1754 // On ChromeOS the pinch viewport can change size independent of the layout view port due to the | 1750 // On ChromeOS the pinch viewport can change size independent of the layout view port due to the |
| 1755 // on screen keyboard so we should only set the FrameView adjustment on Android. | 1751 // on screen keyboard so we should only set the FrameView adjustment on Android. |
| 1756 if (settings() && settings()->mainFrameResizesAreOrientationChanges()) { | 1752 if (settings() && settings()->mainFrameResizesAreOrientationChanges()) { |
| 1757 // Shrink the FrameView by the amount that will maintain the aspect- ratio with the PinchViewport. | 1753 // Shrink the FrameView by the amount that will maintain the aspect- ratio with the PinchViewport. |
| 1758 float aspectRatio = pinchViewport.visibleRect().width() / pinchViewp ort.visibleRect().height(); | 1754 float aspectRatio = pinchViewport.visibleRect().width() / pinchViewp ort.visibleRect().height(); |
| 1759 float newHeight = view->unscaledVisibleContentSize(ExcludeScrollbars ).width() / aspectRatio; | 1755 float newHeight = view->unscaledVisibleContentSize(ExcludeScrollbars ).width() / aspectRatio; |
| 1760 float adjustment = newHeight - view->unscaledVisibleContentSize(Excl udeScrollbars).height(); | 1756 float adjustment = newHeight - view->unscaledVisibleContentSize(Excl udeScrollbars).height(); |
| 1761 view->setTopControlsViewportAdjustment(adjustment); | 1757 view->setTopControlsViewportAdjustment(adjustment); |
| 1762 } | 1758 } |
| 1763 } | 1759 } |
| 1764 } | 1760 } |
| 1765 | 1761 |
| 1762 TopControls& WebViewImpl::topControls() | |
| 1763 { | |
| 1764 return page()->frameHost().topControls(); | |
| 1765 } | |
| 1766 | |
| 1766 void WebViewImpl::resize(const WebSize& newSize) | 1767 void WebViewImpl::resize(const WebSize& newSize) |
| 1767 { | 1768 { |
| 1768 if (m_shouldAutoResize || m_size == newSize) | 1769 if (m_shouldAutoResize || m_size == newSize) |
| 1769 return; | 1770 return; |
| 1770 | 1771 |
| 1771 WebLocalFrameImpl* mainFrame = mainFrameImpl(); | 1772 WebLocalFrameImpl* mainFrame = mainFrameImpl(); |
| 1772 if (!mainFrame) | 1773 if (!mainFrame) |
| 1773 return; | 1774 return; |
| 1774 | 1775 |
| 1775 FrameView* view = mainFrame->frameView(); | 1776 FrameView* view = mainFrame->frameView(); |
| (...skipping 2633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4409 float topControlsShownRatioDelta) | 4410 float topControlsShownRatioDelta) |
| 4410 { | 4411 { |
| 4411 ASSERT(pinchVirtualViewportEnabled()); | 4412 ASSERT(pinchVirtualViewportEnabled()); |
| 4412 | 4413 |
| 4413 if (!mainFrameImpl()) | 4414 if (!mainFrameImpl()) |
| 4414 return; | 4415 return; |
| 4415 FrameView* frameView = mainFrameImpl()->frameView(); | 4416 FrameView* frameView = mainFrameImpl()->frameView(); |
| 4416 if (!frameView) | 4417 if (!frameView) |
| 4417 return; | 4418 return; |
| 4418 | 4419 |
| 4419 setTopControlsShownRatio(m_topControlsShownRatio + topControlsShownRatioDelt a); | 4420 topControls().setShownRatio(topControls().shownRatio() + topControlsShownRat ioDelta); |
| 4420 | 4421 |
| 4421 FloatPoint pinchViewportOffset = page()->frameHost().pinchViewport().visible Rect().location(); | 4422 FloatPoint pinchViewportOffset = page()->frameHost().pinchViewport().visible Rect().location(); |
| 4422 pinchViewportOffset.move(pinchViewportDelta.width, pinchViewportDelta.height ); | 4423 pinchViewportOffset.move(pinchViewportDelta.width, pinchViewportDelta.height ); |
| 4423 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, pinchViewp ortOffset); | 4424 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, pinchViewp ortOffset); |
| 4424 | 4425 |
| 4425 if (pageScaleDelta != 1) | 4426 if (pageScaleDelta != 1) |
| 4426 m_doubleTapZoomPending = false; | 4427 m_doubleTapZoomPending = false; |
| 4427 | 4428 |
| 4428 frameView->setElasticOverscroll(elasticOverscrollDelta + frameView->elasticO verscroll()); | 4429 frameView->setElasticOverscroll(elasticOverscrollDelta + frameView->elasticO verscroll()); |
| 4429 | 4430 |
| 4430 updateMainFrameScrollPosition(frameView->scrollableArea()->scrollPositionDou ble() + | 4431 updateMainFrameScrollPosition(frameView->scrollableArea()->scrollPositionDou ble() + |
| 4431 DoubleSize(outerViewportDelta.width, outerViewportDelta.height), /* prog rammaticScroll */ false); | 4432 DoubleSize(outerViewportDelta.width, outerViewportDelta.height), /* prog rammaticScroll */ false); |
| 4432 } | 4433 } |
| 4433 | 4434 |
| 4434 void WebViewImpl::applyViewportDeltas(const WebSize& scrollDelta, float pageScal eDelta, float topControlsShownRatioDelta) | 4435 void WebViewImpl::applyViewportDeltas(const WebSize& scrollDelta, float pageScal eDelta, float topControlsShownRatioDelta) |
| 4435 { | 4436 { |
| 4436 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4437 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 4437 return; | 4438 return; |
| 4438 | 4439 |
| 4439 setTopControlsShownRatio(m_topControlsShownRatio + topControlsShownRatioDelt a); | 4440 topControls().setShownRatio(topControls().shownRatio() + topControlsShownRat ioDelta); |
| 4440 | 4441 |
| 4441 if (pageScaleDelta == 1) { | 4442 if (pageScaleDelta == 1) { |
| 4442 TRACE_EVENT_INSTANT2("blink", "WebViewImpl::applyScrollAndScale::scrollB y", "x", scrollDelta.width, "y", scrollDelta.height); | 4443 TRACE_EVENT_INSTANT2("blink", "WebViewImpl::applyScrollAndScale::scrollB y", "x", scrollDelta.width, "y", scrollDelta.height); |
| 4443 WebSize webScrollOffset = mainFrame()->scrollOffset(); | 4444 WebSize webScrollOffset = mainFrame()->scrollOffset(); |
| 4444 IntPoint scrollOffset(webScrollOffset.width + scrollDelta.width, webScro llOffset.height + scrollDelta.height); | 4445 IntPoint scrollOffset(webScrollOffset.width + scrollDelta.width, webScro llOffset.height + scrollDelta.height); |
| 4445 updateMainFrameScrollPosition(scrollOffset, false); | 4446 updateMainFrameScrollPosition(scrollOffset, false); |
| 4446 } else { | 4447 } else { |
| 4447 // The page scale changed, so apply a scale and scroll in a single | 4448 // The page scale changed, so apply a scale and scroll in a single |
| 4448 // operation. | 4449 // operation. |
| 4449 WebSize scrollOffset = mainFrame()->scrollOffset(); | 4450 WebSize scrollOffset = mainFrame()->scrollOffset(); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4609 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4610 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4610 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4611 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
| 4611 } | 4612 } |
| 4612 | 4613 |
| 4613 void WebViewImpl::forceNextWebGLContextCreationToFail() | 4614 void WebViewImpl::forceNextWebGLContextCreationToFail() |
| 4614 { | 4615 { |
| 4615 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4616 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
| 4616 } | 4617 } |
| 4617 | 4618 |
| 4618 } // namespace blink | 4619 } // namespace blink |
| OLD | NEW |