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

Side by Side Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2443613002: Rename classes related to top controls (Closed)
Patch Set: fix test Created 4 years, 1 month 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) 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/editing/FrameSelection.h" 42 #include "core/editing/FrameSelection.h"
43 #include "core/editing/InputMethodController.h" 43 #include "core/editing/InputMethodController.h"
44 #include "core/editing/iterators/TextIterator.h" 44 #include "core/editing/iterators/TextIterator.h"
45 #include "core/editing/markers/DocumentMarkerController.h" 45 #include "core/editing/markers/DocumentMarkerController.h"
46 #include "core/editing/serializers/HTMLInterchange.h" 46 #include "core/editing/serializers/HTMLInterchange.h"
47 #include "core/editing/serializers/Serialization.h" 47 #include "core/editing/serializers/Serialization.h"
48 #include "core/events/KeyboardEvent.h" 48 #include "core/events/KeyboardEvent.h"
49 #include "core/events/UIEventWithKeyState.h" 49 #include "core/events/UIEventWithKeyState.h"
50 #include "core/events/WheelEvent.h" 50 #include "core/events/WheelEvent.h"
51 #include "core/fetch/UniqueIdentifier.h" 51 #include "core/fetch/UniqueIdentifier.h"
52 #include "core/frame/BrowserControls.h"
52 #include "core/frame/EventHandlerRegistry.h" 53 #include "core/frame/EventHandlerRegistry.h"
53 #include "core/frame/FrameHost.h" 54 #include "core/frame/FrameHost.h"
54 #include "core/frame/FrameView.h" 55 #include "core/frame/FrameView.h"
55 #include "core/frame/LocalFrame.h" 56 #include "core/frame/LocalFrame.h"
56 #include "core/frame/PageScaleConstraintsSet.h" 57 #include "core/frame/PageScaleConstraintsSet.h"
57 #include "core/frame/RemoteFrame.h" 58 #include "core/frame/RemoteFrame.h"
58 #include "core/frame/Settings.h" 59 #include "core/frame/Settings.h"
59 #include "core/frame/SmartClip.h" 60 #include "core/frame/SmartClip.h"
60 #include "core/frame/TopControls.h"
61 #include "core/frame/UseCounter.h" 61 #include "core/frame/UseCounter.h"
62 #include "core/frame/VisualViewport.h" 62 #include "core/frame/VisualViewport.h"
63 #include "core/html/HTMLMediaElement.h" 63 #include "core/html/HTMLMediaElement.h"
64 #include "core/html/HTMLPlugInElement.h" 64 #include "core/html/HTMLPlugInElement.h"
65 #include "core/html/HTMLTextAreaElement.h" 65 #include "core/html/HTMLTextAreaElement.h"
66 #include "core/input/EventHandler.h" 66 #include "core/input/EventHandler.h"
67 #include "core/input/TouchActionUtil.h" 67 #include "core/input/TouchActionUtil.h"
68 #include "core/layout/LayoutPart.h" 68 #include "core/layout/LayoutPart.h"
69 #include "core/layout/TextAutosizer.h" 69 #include "core/layout/TextAutosizer.h"
70 #include "core/layout/api/LayoutViewItem.h" 70 #include "core/layout/api/LayoutViewItem.h"
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 } 1885 }
1886 1886
1887 void WebViewImpl::resizeVisualViewport(const WebSize& newSize) { 1887 void WebViewImpl::resizeVisualViewport(const WebSize& newSize) {
1888 page()->frameHost().visualViewport().setSize(newSize); 1888 page()->frameHost().visualViewport().setSize(newSize);
1889 page()->frameHost().visualViewport().clampToBoundaries(); 1889 page()->frameHost().visualViewport().clampToBoundaries();
1890 } 1890 }
1891 1891
1892 void WebViewImpl::performResize() { 1892 void WebViewImpl::performResize() {
1893 // We'll keep the initial containing block size from changing when the top 1893 // We'll keep the initial containing block size from changing when the top
1894 // controls hide so that the ICB will always be the same size as the 1894 // controls hide so that the ICB will always be the same size as the
1895 // viewport with the top controls shown. 1895 // viewport with the browser controls shown.
1896 IntSize ICBSize = m_size; 1896 IntSize ICBSize = m_size;
1897 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && 1897 if (RuntimeEnabledFeatures::inertTopControlsEnabled() &&
1898 !topControls().shrinkViewport()) 1898 !browserControls().shrinkViewport())
1899 ICBSize.expand(0, -topControls().height()); 1899 ICBSize.expand(0, -browserControls().height());
1900 1900
1901 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(ICBSize); 1901 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(ICBSize);
1902 1902
1903 updatePageDefinedViewportConstraints( 1903 updatePageDefinedViewportConstraints(
1904 mainFrameImpl()->frame()->document()->viewportDescription()); 1904 mainFrameImpl()->frame()->document()->viewportDescription());
1905 updateMainFrameLayoutSize(); 1905 updateMainFrameLayoutSize();
1906 1906
1907 page()->frameHost().visualViewport().setSize(m_size); 1907 page()->frameHost().visualViewport().setSize(m_size);
1908 1908
1909 if (mainFrameImpl()->frameView()) { 1909 if (mainFrameImpl()->frameView()) {
1910 mainFrameImpl()->frameView()->setInitialViewportSize(ICBSize); 1910 mainFrameImpl()->frameView()->setInitialViewportSize(ICBSize);
1911 if (!mainFrameImpl()->frameView()->needsLayout()) 1911 if (!mainFrameImpl()->frameView()->needsLayout())
1912 postLayoutResize(mainFrameImpl()); 1912 postLayoutResize(mainFrameImpl());
1913 } 1913 }
1914 } 1914 }
1915 1915
1916 void WebViewImpl::updateTopControlsState(WebTopControlsState constraint, 1916 void WebViewImpl::updateBrowserControlsState(WebBrowserControlsState constraint,
1917 WebTopControlsState current, 1917 WebBrowserControlsState current,
1918 bool animate) { 1918 bool animate) {
1919 topControls().updateConstraintsAndState(constraint, current, animate); 1919 browserControls().updateConstraintsAndState(constraint, current, animate);
1920 1920
1921 if (m_layerTreeView) 1921 if (m_layerTreeView)
1922 m_layerTreeView->updateTopControlsState(constraint, current, animate); 1922 m_layerTreeView->updateBrowserControlsState(constraint, current, animate);
1923 } 1923 }
1924 1924
1925 void WebViewImpl::didUpdateTopControls() { 1925 void WebViewImpl::didUpdateBrowserControls() {
1926 if (m_layerTreeView) { 1926 if (m_layerTreeView) {
1927 m_layerTreeView->setTopControlsShownRatio(topControls().shownRatio()); 1927 m_layerTreeView->setBrowserControlsShownRatio(
1928 m_layerTreeView->setTopControlsHeight(topControls().height(), 1928 browserControls().shownRatio());
1929 topControls().shrinkViewport()); 1929 m_layerTreeView->setBrowserControlsHeight(
1930 browserControls().height(), browserControls().shrinkViewport());
1930 } 1931 }
1931 1932
1932 WebLocalFrameImpl* mainFrame = mainFrameImpl(); 1933 WebLocalFrameImpl* mainFrame = mainFrameImpl();
1933 if (!mainFrame) 1934 if (!mainFrame)
1934 return; 1935 return;
1935 1936
1936 FrameView* view = mainFrame->frameView(); 1937 FrameView* view = mainFrame->frameView();
1937 if (!view) 1938 if (!view)
1938 return; 1939 return;
1939 1940
1940 VisualViewport& visualViewport = page()->frameHost().visualViewport(); 1941 VisualViewport& visualViewport = page()->frameHost().visualViewport();
1941 1942
1942 { 1943 {
1943 // This object will save the current visual viewport offset w.r.t. the 1944 // This object will save the current visual viewport offset w.r.t. the
1944 // document and restore it when the object goes out of scope. It's 1945 // document and restore it when the object goes out of scope. It's
1945 // needed since the top controls adjustment will change the maximum 1946 // needed since the browser controls adjustment will change the maximum
1946 // scroll offset and we may need to reposition them to keep the user's 1947 // scroll offset and we may need to reposition them to keep the user's
1947 // apparent position unchanged. 1948 // apparent position unchanged.
1948 ResizeViewportAnchor::ResizeScope resizeScope(*m_resizeViewportAnchor); 1949 ResizeViewportAnchor::ResizeScope resizeScope(*m_resizeViewportAnchor);
1949 1950
1950 float topControlsViewportAdjustment = 1951 float browserControlsViewportAdjustment =
1951 topControls().layoutHeight() - topControls().contentOffset(); 1952 browserControls().layoutHeight() - browserControls().contentOffset();
1952 visualViewport.setTopControlsAdjustment(topControlsViewportAdjustment); 1953 visualViewport.setBrowserControlsAdjustment(
1954 browserControlsViewportAdjustment);
1953 1955
1954 // Since the FrameView is sized to be the visual viewport at minimum 1956 // Since the FrameView is sized to be the visual viewport at minimum
1955 // scale, its adjustment must also be scaled by the minimum scale. 1957 // scale, its adjustment must also be scaled by the minimum scale.
1956 view->setTopControlsViewportAdjustment(topControlsViewportAdjustment / 1958 view->setBrowserControlsViewportAdjustment(
1957 minimumPageScaleFactor()); 1959 browserControlsViewportAdjustment / minimumPageScaleFactor());
1958 } 1960 }
1959 } 1961 }
1960 1962
1961 TopControls& WebViewImpl::topControls() { 1963 BrowserControls& WebViewImpl::browserControls() {
1962 return page()->frameHost().topControls(); 1964 return page()->frameHost().browserControls();
1963 } 1965 }
1964 1966
1965 void WebViewImpl::resizeViewWhileAnchored(FrameView* view, 1967 void WebViewImpl::resizeViewWhileAnchored(FrameView* view,
1966 float topControlsHeight, 1968 float browserControlsHeight,
1967 bool topControlsShrinkLayout) { 1969 bool browserControlsShrinkLayout) {
1968 DCHECK(mainFrameImpl()); 1970 DCHECK(mainFrameImpl());
1969 1971
1970 topControls().setHeight(topControlsHeight, topControlsShrinkLayout); 1972 browserControls().setHeight(browserControlsHeight,
1973 browserControlsShrinkLayout);
1971 1974
1972 { 1975 {
1973 // Avoids unnecessary invalidations while various bits of state in 1976 // Avoids unnecessary invalidations while various bits of state in
1974 // TextAutosizer are updated. 1977 // TextAutosizer are updated.
1975 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page()); 1978 TextAutosizer::DeferUpdatePageInfo deferUpdatePageInfo(page());
1976 performResize(); 1979 performResize();
1977 } 1980 }
1978 1981
1979 m_fullscreenController->updateSize(); 1982 m_fullscreenController->updateSize();
1980 1983
1981 // Update lifecyle phases immediately to recalculate the minimum scale limit 1984 // Update lifecyle phases immediately to recalculate the minimum scale limit
1982 // for rotation anchoring, and to make sure that no lifecycle states are 1985 // for rotation anchoring, and to make sure that no lifecycle states are
1983 // stale if this WebView is embedded in another one. 1986 // stale if this WebView is embedded in another one.
1984 updateAllLifecyclePhases(); 1987 updateAllLifecyclePhases();
1985 } 1988 }
1986 1989
1987 void WebViewImpl::resizeWithTopControls(const WebSize& newSize, 1990 void WebViewImpl::resizeWithBrowserControls(const WebSize& newSize,
1988 float topControlsHeight, 1991 float browserControlsHeight,
1989 bool topControlsShrinkLayout) { 1992 bool browserControlsShrinkLayout) {
1990 if (m_shouldAutoResize) 1993 if (m_shouldAutoResize)
1991 return; 1994 return;
1992 1995
1993 if (m_size == newSize && topControls().height() == topControlsHeight && 1996 if (m_size == newSize &&
1994 topControls().shrinkViewport() == topControlsShrinkLayout) 1997 browserControls().height() == browserControlsHeight &&
1998 browserControls().shrinkViewport() == browserControlsShrinkLayout)
1995 return; 1999 return;
1996 2000
1997 if (page()->mainFrame() && !page()->mainFrame()->isLocalFrame()) { 2001 if (page()->mainFrame() && !page()->mainFrame()->isLocalFrame()) {
1998 // Viewport resize for a remote main frame does not require any 2002 // Viewport resize for a remote main frame does not require any
1999 // particular action, but the state needs to reflect the correct size 2003 // particular action, but the state needs to reflect the correct size
2000 // so that it can be used for initalization if the main frame gets 2004 // so that it can be used for initalization if the main frame gets
2001 // swapped to a LocalFrame at a later time. 2005 // swapped to a LocalFrame at a later time.
2002 m_size = newSize; 2006 m_size = newSize;
2003 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(m_size); 2007 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(m_size);
2004 page()->frameHost().visualViewport().setSize(m_size); 2008 page()->frameHost().visualViewport().setSize(m_size);
(...skipping 13 matching lines...) Expand all
2018 bool isRotation = 2022 bool isRotation =
2019 page()->settings().mainFrameResizesAreOrientationChanges() && 2023 page()->settings().mainFrameResizesAreOrientationChanges() &&
2020 m_size.width && contentsSize().width() && newSize.width != m_size.width && 2024 m_size.width && contentsSize().width() && newSize.width != m_size.width &&
2021 !m_fullscreenController->isFullscreen(); 2025 !m_fullscreenController->isFullscreen();
2022 m_size = newSize; 2026 m_size = newSize;
2023 2027
2024 FloatSize viewportAnchorCoords(viewportAnchorCoordX, viewportAnchorCoordY); 2028 FloatSize viewportAnchorCoords(viewportAnchorCoordX, viewportAnchorCoordY);
2025 if (isRotation) { 2029 if (isRotation) {
2026 RotationViewportAnchor anchor(*view, visualViewport, viewportAnchorCoords, 2030 RotationViewportAnchor anchor(*view, visualViewport, viewportAnchorCoords,
2027 pageScaleConstraintsSet()); 2031 pageScaleConstraintsSet());
2028 resizeViewWhileAnchored(view, topControlsHeight, topControlsShrinkLayout); 2032 resizeViewWhileAnchored(view, browserControlsHeight,
2033 browserControlsShrinkLayout);
2029 } else { 2034 } else {
2030 ResizeViewportAnchor::ResizeScope resizeScope(*m_resizeViewportAnchor); 2035 ResizeViewportAnchor::ResizeScope resizeScope(*m_resizeViewportAnchor);
2031 resizeViewWhileAnchored(view, topControlsHeight, topControlsShrinkLayout); 2036 resizeViewWhileAnchored(view, browserControlsHeight,
2037 browserControlsShrinkLayout);
2032 } 2038 }
2033 sendResizeEventAndRepaint(); 2039 sendResizeEventAndRepaint();
2034 } 2040 }
2035 2041
2036 void WebViewImpl::resize(const WebSize& newSize) { 2042 void WebViewImpl::resize(const WebSize& newSize) {
2037 if (m_shouldAutoResize || m_size == newSize) 2043 if (m_shouldAutoResize || m_size == newSize)
2038 return; 2044 return;
2039 2045
2040 resizeWithTopControls(newSize, topControls().height(), 2046 resizeWithBrowserControls(newSize, browserControls().height(),
2041 topControls().shrinkViewport()); 2047 browserControls().shrinkViewport());
2042 } 2048 }
2043 2049
2044 void WebViewImpl::didEnterFullscreen() { 2050 void WebViewImpl::didEnterFullscreen() {
2045 m_fullscreenController->didEnterFullscreen(); 2051 m_fullscreenController->didEnterFullscreen();
2046 } 2052 }
2047 2053
2048 void WebViewImpl::didExitFullscreen() { 2054 void WebViewImpl::didExitFullscreen() {
2049 m_fullscreenController->didExitFullscreen(); 2055 m_fullscreenController->didExitFullscreen();
2050 } 2056 }
2051 2057
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after
4334 } 4340 }
4335 } 4341 }
4336 4342
4337 void WebViewImpl::applyViewportDeltas( 4343 void WebViewImpl::applyViewportDeltas(
4338 const WebFloatSize& visualViewportDelta, 4344 const WebFloatSize& visualViewportDelta,
4339 // TODO(bokan): This parameter is to be removed but requires adjusting many 4345 // TODO(bokan): This parameter is to be removed but requires adjusting many
4340 // callsites. 4346 // callsites.
4341 const WebFloatSize&, 4347 const WebFloatSize&,
4342 const WebFloatSize& elasticOverscrollDelta, 4348 const WebFloatSize& elasticOverscrollDelta,
4343 float pageScaleDelta, 4349 float pageScaleDelta,
4344 float topControlsShownRatioDelta) { 4350 float browserControlsShownRatioDelta) {
4345 VisualViewport& visualViewport = page()->frameHost().visualViewport(); 4351 VisualViewport& visualViewport = page()->frameHost().visualViewport();
4346 4352
4347 // Store the desired offsets the visual viewport before setting the top 4353 // Store the desired offsets the visual viewport before setting the top
4348 // controls ratio since doing so will change the bounds and move the 4354 // controls ratio since doing so will change the bounds and move the
4349 // viewports to keep the offsets valid. The compositor may have already 4355 // viewports to keep the offsets valid. The compositor may have already
4350 // done that so we don't want to double apply the deltas here. 4356 // done that so we don't want to double apply the deltas here.
4351 FloatPoint visualViewportOffset = visualViewport.visibleRect().location(); 4357 FloatPoint visualViewportOffset = visualViewport.visibleRect().location();
4352 visualViewportOffset.move(visualViewportDelta.width, 4358 visualViewportOffset.move(visualViewportDelta.width,
4353 visualViewportDelta.height); 4359 visualViewportDelta.height);
4354 4360
4355 topControls().setShownRatio(topControls().shownRatio() + 4361 browserControls().setShownRatio(browserControls().shownRatio() +
4356 topControlsShownRatioDelta); 4362 browserControlsShownRatioDelta);
4357 4363
4358 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, 4364 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta,
4359 visualViewportOffset); 4365 visualViewportOffset);
4360 4366
4361 if (pageScaleDelta != 1) { 4367 if (pageScaleDelta != 1) {
4362 m_doubleTapZoomPending = false; 4368 m_doubleTapZoomPending = false;
4363 visualViewport.userDidChangeScale(); 4369 visualViewport.userDidChangeScale();
4364 } 4370 }
4365 4371
4366 m_elasticOverscroll += elasticOverscrollDelta; 4372 m_elasticOverscroll += elasticOverscrollDelta;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
4551 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) 4557 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame())
4552 return nullptr; 4558 return nullptr;
4553 return focusedFrame; 4559 return focusedFrame;
4554 } 4560 }
4555 4561
4556 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { 4562 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const {
4557 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4563 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4558 } 4564 }
4559 4565
4560 } // namespace blink 4566 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/Source/web/tests/BrowserControlsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698