Skip to content
Permalink
Browse files
Clean up the boolean argument to visibleContentRect
https://bugs.webkit.org/show_bug.cgi?id=110167

Source/WebCore:

Reviewed by Simon Fraser.

Replace the boolean argument to visibleContentRect() with
an enum.

No behavior change.

* WebCore.exp.in:
* dom/Document.cpp:
(WebCore::Document::viewportSize):
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::update):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::innerHeight):
(WebCore::DOMWindow::innerWidth):
* page/FrameView.cpp:
(WebCore::FrameView::calculateScrollbarModesForLayout):
(WebCore::FrameView::layout):
(WebCore::FrameView::performPostLayoutTasks):
(WebCore::FrameView::windowClipRect):
* page/SpatialNavigation.cpp:
(WebCore::canScrollInDirection):
* platform/ScrollView.cpp:
(WebCore::ScrollView::unscaledVisibleContentSize):
(WebCore::ScrollView::visibleContentRect):
(WebCore::ScrollView::layoutSize):
(WebCore::ScrollView::updateScrollbars):
(WebCore::ScrollView::paint):
* platform/ScrollView.h:
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::visibleContentRect):
* platform/ScrollableArea.h:
* rendering/RenderDialog.cpp:
(WebCore::RenderDialog::layout):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::maximumScrollPosition):
(WebCore::RenderLayer::visibleContentRect):
* rendering/RenderLayer.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::frameViewDidChangeSize):
(WebCore::RenderLayerCompositor::updateRootLayerPosition):

Source/WebKit/blackberry:

Reviewed by Simon Fraser.

Replace the boolean argument to visibleContentRect() with
an enum.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::getRecursiveVisibleWindowRect):
* WebKitSupport/InRegionScrollableArea.cpp:
(BlackBerry::WebKit::InRegionScrollableArea::InRegionScrollableArea):

Source/WebKit/chromium:

Reviewed by Simon Fraser.

Replace the boolean argument to visibleContentRect() with
an enum.

* src/ChromeClientImpl.cpp:
(WebKit::ChromeClientImpl::popupOpened):

Source/WebKit/efl:

Reviewed by Simon Fraser.

Replace the boolean argument to visibleContentRect() with
an enum.

* ewk/ewk_frame.cpp:
(ewk_frame_visible_content_geometry_get):

Source/WebKit/win:

Reviewed by Simon Fraser.

Replace the boolean argument to visibleContentRect() with
an enum.

* WebFrame.cpp:
(WebFrame::visibleContentRect):
(WebFrame::frameBounds):

Source/WebKit2:

Reviewed by Simon Fraser.

Replace the boolean argument to visibleContentRect() with
an enum.

* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::visibleContentBounds):
(WebKit::WebFrame::visibleContentBoundsExcludingScrollbars):


Canonical link: https://commits.webkit.org/128482@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143295 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
smfr committed Feb 19, 2013
1 parent 9bf1ca0 commit ad7775267a49110e1ea72f46817a817b64c6734e
Showing 30 changed files with 166 additions and 47 deletions.
@@ -1,3 +1,50 @@
2013-02-18 Simon Fraser <simon.fraser@apple.com>

Clean up the boolean argument to visibleContentRect
https://bugs.webkit.org/show_bug.cgi?id=110167

Reviewed by Simon Fraser.

Replace the boolean argument to visibleContentRect() with
an enum.

No behavior change.

* WebCore.exp.in:
* dom/Document.cpp:
(WebCore::Document::viewportSize):
* inspector/InspectorOverlay.cpp:
(WebCore::InspectorOverlay::update):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::innerHeight):
(WebCore::DOMWindow::innerWidth):
* page/FrameView.cpp:
(WebCore::FrameView::calculateScrollbarModesForLayout):
(WebCore::FrameView::layout):
(WebCore::FrameView::performPostLayoutTasks):
(WebCore::FrameView::windowClipRect):
* page/SpatialNavigation.cpp:
(WebCore::canScrollInDirection):
* platform/ScrollView.cpp:
(WebCore::ScrollView::unscaledVisibleContentSize):
(WebCore::ScrollView::visibleContentRect):
(WebCore::ScrollView::layoutSize):
(WebCore::ScrollView::updateScrollbars):
(WebCore::ScrollView::paint):
* platform/ScrollView.h:
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::visibleContentRect):
* platform/ScrollableArea.h:
* rendering/RenderDialog.cpp:
(WebCore::RenderDialog::layout):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::maximumScrollPosition):
(WebCore::RenderLayer::visibleContentRect):
* rendering/RenderLayer.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::frameViewDidChangeSize):
(WebCore::RenderLayerCompositor::updateRootLayerPosition):

2013-02-18 Ryosuke Niwa <rniwa@webkit.org>

That didn't work either. Just make it public. This is why I hate nested classes. They just don't work.
@@ -1179,7 +1179,6 @@ __ZNK7WebCore10ScrollView16windowToContentsERKNS_7IntRectE
__ZNK7WebCore10ScrollView16windowToContentsERKNS_8IntPointE
__ZNK7WebCore10ScrollView18contentsToRootViewERKNS_7IntRectE
__ZNK7WebCore10ScrollView18contentsToRootViewERKNS_8IntPointE
__ZNK7WebCore10ScrollView18visibleContentRectEb
__ZNK7WebCore11FrameLoader10isCompleteEv
__ZNK7WebCore11FrameLoader14cancelledErrorERKNS_15ResourceRequestE
__ZNK7WebCore11FrameLoader14frameHasLoadedEv
@@ -1789,7 +1788,7 @@ __ZN7WebCore8IntPointC1ERK8_NSPoint
__ZN7WebCore8IntPointC1ERK7CGPoint
__ZN7WebCore9FloatRectC1ERK7_NSRect
__ZNK7WebCore10FloatPointcv8_NSPointEv
__ZNK7WebCore14ScrollableArea18visibleContentRectEb
__ZNK7WebCore14ScrollableArea18visibleContentRectENS0_36VisibleContentRectIncludesScrollbarsE
__ZNK7WebCore6Cursor14platformCursorEv
__ZNK7WebCore7IntRectcv7_NSRectEv
__ZNK7WebCore7IntSizecv6CGSizeEv
@@ -5701,7 +5701,7 @@ IntSize Document::viewportSize() const
{
if (!view())
return IntSize();
return view()->visibleContentRect(/* includeScrollbars */ true).size();
return view()->visibleContentRect(ScrollableArea::IncludeScrollbars).size();
}

#if ENABLE(CSS_DEVICE_ADAPTATION)
@@ -283,7 +283,7 @@ void InspectorOverlay::update()

FrameView* overlayView = overlayPage()->mainFrame()->view();
IntSize viewportSize = enclosingIntRect(view->visibleContentRect()).size();
IntSize frameViewFullSize = enclosingIntRect(view->visibleContentRect(true)).size();
IntSize frameViewFullSize = enclosingIntRect(view->visibleContentRect(ScrollableArea::IncludeScrollbars)).size();
IntSize size = m_size.isEmpty() ? frameViewFullSize : m_size;
overlayPage()->setPageScaleFactor(m_page->pageScaleFactor(), IntPoint());
size.scale(m_page->pageScaleFactor());
@@ -1142,7 +1142,7 @@ int DOMWindow::innerHeight() const

// If the device height is overridden, do not include the horizontal scrollbar into the innerHeight (since it is absent on the real device).
bool includeScrollbars = !InspectorInstrumentation::shouldApplyScreenHeightOverride(m_frame);
return view->mapFromLayoutToCSSUnits(static_cast<int>(view->visibleContentRect(includeScrollbars).height()));
return view->mapFromLayoutToCSSUnits(static_cast<int>(view->visibleContentRect(includeScrollbars ? ScrollableArea::IncludeScrollbars : ScrollableArea::ExcludeScrollbars).height()));
}

int DOMWindow::innerWidth() const
@@ -1156,7 +1156,7 @@ int DOMWindow::innerWidth() const

// If the device width is overridden, do not include the vertical scrollbar into the innerWidth (since it is absent on the real device).
bool includeScrollbars = !InspectorInstrumentation::shouldApplyScreenWidthOverride(m_frame);
return view->mapFromLayoutToCSSUnits(static_cast<int>(view->visibleContentRect(includeScrollbars).width()));
return view->mapFromLayoutToCSSUnits(static_cast<int>(view->visibleContentRect(includeScrollbars ? ScrollableArea::IncludeScrollbars : ScrollableArea::ExcludeScrollbars).width()));
}

int DOMWindow::screenX() const
@@ -688,7 +688,7 @@ void FrameView::calculateScrollbarModesForLayout(ScrollbarMode& hMode, Scrollbar
hMode = ScrollbarAuto;
// Seamless documents begin with heights of 0; we special case that here
// to correctly render documents that don't need scrollbars.
IntSize fullVisibleSize = visibleContentRect(true /*includeScrollbars*/).size();
IntSize fullVisibleSize = visibleContentRect(IncludeScrollbars).size();
bool isSeamlessDocument = frame() && frame()->document() && frame()->document()->shouldDisplaySeamlesslyWithParent();
vMode = (isSeamlessDocument && !fullVisibleSize.height()) ? ScrollbarAlwaysOff : ScrollbarAuto;
} else {
@@ -1161,7 +1161,7 @@ void FrameView::layout(bool allowSubtree)
if (useFixedLayout() && !fixedLayoutSize().isEmpty() && delegatesScrolling())
m_lastViewportSize = fixedLayoutSize();
else
m_lastViewportSize = visibleContentRect(true /*includeScrollbars*/).size();
m_lastViewportSize = visibleContentRect(IncludeScrollbars).size();
m_lastZoomFactor = root->style()->zoom();

// Set the initial vMode to AlwaysOn if we're auto.
@@ -2602,7 +2602,7 @@ void FrameView::performPostLayoutTasks()
if (useFixedLayout() && !fixedLayoutSize().isEmpty() && delegatesScrolling())
currentSize = fixedLayoutSize();
else
currentSize = visibleContentRect(true /*includeScrollbars*/).size();
currentSize = visibleContentRect(IncludeScrollbars).size();
float currentZoomFactor = renderView->style()->zoom();
bool resized = !m_firstLayout && (currentSize != m_lastViewportSize || currentZoomFactor != m_lastZoomFactor);
m_lastViewportSize = currentSize;
@@ -2784,7 +2784,7 @@ IntRect FrameView::windowClipRect(bool clipToContents) const
return IntRect(IntPoint(), contentsSize());

// Set our clip rect to be our contents.
IntRect clipRect = contentsToWindow(visibleContentRect(!clipToContents));
IntRect clipRect = contentsToWindow(visibleContentRect(clipToContents ? ExcludeScrollbars : IncludeScrollbars));
if (!m_frame || !m_frame->ownerElement())
return clipRect;

@@ -485,7 +485,7 @@ bool canScrollInDirection(const Frame* frame, FocusDirection direction)
return false;
LayoutSize size = frame->view()->contentsSize();
LayoutSize offset = frame->view()->scrollOffset();
LayoutRect rect = frame->view()->visibleContentRect(true);
LayoutRect rect = frame->view()->visibleContentRect(ScrollableArea::IncludeScrollbars);

switch (direction) {
case FocusDirectionLeft:
@@ -225,18 +225,18 @@ void ScrollView::setDelegatesScrolling(bool delegatesScrolling)
delegatesScrollingDidChange();
}

IntSize ScrollView::unscaledVisibleContentSize(bool includeScrollbars) const
IntSize ScrollView::unscaledVisibleContentSize(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
{
if (platformWidget())
return platformVisibleContentRect(includeScrollbars).size();
return platformVisibleContentRect(scrollbarInclusion == IncludeScrollbars).size();

if (!m_fixedVisibleContentRect.isEmpty())
return m_fixedVisibleContentRect.size();

int verticalScrollbarWidth = 0;
int horizontalScrollbarHeight = 0;

if (!includeScrollbars) {
if (scrollbarInclusion == ExcludeScrollbars) {
if (Scrollbar* verticalBar = verticalScrollbar())
verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBar->width() : 0;
if (Scrollbar* horizontalBar = horizontalScrollbar())
@@ -248,23 +248,23 @@ IntSize ScrollView::unscaledVisibleContentSize(bool includeScrollbars) const
}

#if !PLATFORM(GTK)
IntRect ScrollView::visibleContentRect(bool includeScrollbars) const
IntRect ScrollView::visibleContentRect(VisibleContentRectIncludesScrollbars scollbarInclusion) const
{
if (platformWidget())
return platformVisibleContentRect(includeScrollbars);
return platformVisibleContentRect(scollbarInclusion == IncludeScrollbars);

if (!m_fixedVisibleContentRect.isEmpty())
return m_fixedVisibleContentRect;

FloatSize visibleContentSize = unscaledVisibleContentSize(includeScrollbars);
FloatSize visibleContentSize = unscaledVisibleContentSize(scollbarInclusion);
visibleContentSize.scale(1 / visibleContentScaleFactor());
return IntRect(IntPoint(m_scrollOffset), expandedIntSize(visibleContentSize));
}
#endif

IntSize ScrollView::layoutSize() const
{
return m_fixedLayoutSize.isEmpty() || !m_useFixedLayout ? unscaledVisibleContentSize(false) : m_fixedLayoutSize;
return m_fixedLayoutSize.isEmpty() || !m_useFixedLayout ? unscaledVisibleContentSize(ExcludeScrollbars) : m_fixedLayoutSize;
}

IntSize ScrollView::fixedLayoutSize() const
@@ -504,7 +504,7 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset)
bool sendContentResizedNotification = false;

IntSize docSize = contentsSize();
IntSize fullVisibleSize = visibleContentRect(true /*includeScrollbars*/).size();
IntSize fullVisibleSize = visibleContentRect(IncludeScrollbars).size();

if (hScroll == ScrollbarAuto) {
newHasHorizontalScrollbar = docSize.width() > visibleWidth();
@@ -1053,7 +1053,7 @@ void ScrollView::paint(GraphicsContext* context, const IntRect& rect)

IntRect documentDirtyRect = rect;
if (!paintsEntireContents()) {
IntRect visibleAreaWithoutScrollbars(location(), visibleContentRect(false).size());
IntRect visibleAreaWithoutScrollbars(location(), visibleContentRect().size());
documentDirtyRect.intersect(visibleAreaWithoutScrollbars);
}

@@ -1084,7 +1084,7 @@ void ScrollView::paint(GraphicsContext* context, const IntRect& rect)
if (!m_scrollbarsSuppressed && (m_horizontalScrollbar || m_verticalScrollbar)) {
GraphicsContextStateSaver stateSaver(*context);
IntRect scrollViewDirtyRect = rect;
IntRect visibleAreaWithScrollbars(location(), visibleContentRect(true).size());
IntRect visibleAreaWithScrollbars(location(), visibleContentRect(IncludeScrollbars).size());
scrollViewDirtyRect.intersect(visibleAreaWithScrollbars);
context->translate(x(), y());
scrollViewDirtyRect.moveBy(-location());
@@ -144,7 +144,7 @@ class ScrollView : public Widget, public ScrollableArea {
// In the situation the client is responsible for the scrolling (ie. with a tiled backing store) it is possible to use
// the setFixedVisibleContentRect instead for the mainframe, though this must be updated manually, e.g just before resuming the page
// which usually will happen when panning, pinching and rotation ends, or when scale or position are changed manually.
virtual IntRect visibleContentRect(bool includeScrollbars = false) const OVERRIDE;
virtual IntRect visibleContentRect(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const OVERRIDE;
virtual void setFixedVisibleContentRect(const IntRect& visibleContentRect) { m_fixedVisibleContentRect = visibleContentRect; }
IntRect fixedVisibleContentRect() const { return m_fixedVisibleContentRect; }
IntSize visibleSize() const { return visibleContentRect().size(); }
@@ -155,7 +155,7 @@ class ScrollView : public Widget, public ScrollableArea {
// visibleContentScaleFactor is usually 1, except when the setting applyPageScaleFactorInCompositor is true and the
// ScrollView is the main frame; in that case, visibleContentScaleFactor is equal to the page's pageScaleFactor.
// Ports that don't use pageScaleFactor can treat unscaledVisibleContentSize and visibleContentRect().size() as equivalent.
IntSize unscaledVisibleContentSize(bool includeScrollbars) const;
IntSize unscaledVisibleContentSize(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
virtual float visibleContentScaleFactor() const { return 1; }

// Functions for getting/setting the size webkit should use to layout the contents. By default this is the same as the visible
@@ -403,12 +403,12 @@ IntPoint ScrollableArea::maximumScrollPosition() const
return IntPoint(contentsSize().width() - visibleWidth(), contentsSize().height() - visibleHeight());
}

IntRect ScrollableArea::visibleContentRect(bool includeScrollbars) const
IntRect ScrollableArea::visibleContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
{
int verticalScrollbarWidth = 0;
int horizontalScrollbarHeight = 0;

if (includeScrollbars) {
if (scrollbarInclusion == IncludeScrollbars) {
if (Scrollbar* verticalBar = verticalScrollbar())
verticalScrollbarWidth = !verticalBar->isOverlayScrollbar() ? verticalBar->width() : 0;
if (Scrollbar* horizontalBar = horizontalScrollbar())
@@ -138,7 +138,9 @@ class ScrollableArea {
virtual IntPoint scrollPosition() const;
virtual IntPoint minimumScrollPosition() const;
virtual IntPoint maximumScrollPosition() const;
virtual IntRect visibleContentRect(bool /*includeScrollbars*/ = false) const;

enum VisibleContentRectIncludesScrollbars { ExcludeScrollbars, IncludeScrollbars };
virtual IntRect visibleContentRect(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
virtual int visibleHeight() const = 0;
virtual int visibleWidth() const = 0;
virtual IntSize contentsSize() const = 0;
@@ -86,7 +86,7 @@ HostWindow* FramelessScrollView::hostWindow() const

IntRect FramelessScrollView::windowClipRect(bool clipToContents) const
{
return contentsToWindow(visibleContentRect(!clipToContents));
return contentsToWindow(visibleContentRect(clipToContents ? ExcludeScrollbars : IncludeScrollbars));
}

void FramelessScrollView::paintContents(GraphicsContext*, const IntRect&)
@@ -63,8 +63,10 @@ PassRefPtr<Scrollbar> ScrollView::createScrollbar(ScrollbarOrientation orientati
return Scrollbar::createNativeScrollbar(this, orientation, RegularScrollbar);
}

IntRect ScrollView::visibleContentRect(bool includeScrollbars) const
IntRect ScrollView::visibleContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
{
bool includeScrollbars = scrollbarInclusion == IncludeScrollbars;

// If we are an interior frame scrollbar or are in some sort of transition
// state, just calculate our size based on what the GTK+ theme says the
// scrollbar width should be.
@@ -53,7 +53,7 @@ void RenderDialog::layout()
FrameView* frameView = document()->view();
int scrollTop = frameView->scrollOffset().height();
FloatPoint absolutePoint(0, scrollTop);
int visibleHeight = frameView->visibleContentRect(true).height();
int visibleHeight = frameView->visibleContentRect(ScrollableArea::IncludeScrollbars).height();
if (height() < visibleHeight)
absolutePoint.move(0, (visibleHeight - height()) / 2);
FloatPoint localPoint = containingBlock()->absoluteToLocal(absolutePoint);
@@ -2445,14 +2445,14 @@ IntPoint RenderLayer::minimumScrollPosition() const
IntPoint RenderLayer::maximumScrollPosition() const
{
// FIXME: m_scrollSize may not be up-to-date if m_scrollDimensionsDirty is true.
return scrollOrigin() + roundedIntSize(m_scrollSize) - visibleContentRect(true).size();
return scrollOrigin() + roundedIntSize(m_scrollSize) - visibleContentRect(IncludeScrollbars).size();
}

IntRect RenderLayer::visibleContentRect(bool includeScrollbars) const
IntRect RenderLayer::visibleContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
{
int verticalScrollbarWidth = 0;
int horizontalScrollbarHeight = 0;
if (includeScrollbars) {
if (scrollbarInclusion == IncludeScrollbars) {
verticalScrollbarWidth = (verticalScrollbar() && !verticalScrollbar()->isOverlayScrollbar()) ? verticalScrollbar()->width() : 0;
horizontalScrollbarHeight = (horizontalScrollbar() && !horizontalScrollbar()->isOverlayScrollbar()) ? horizontalScrollbar()->height() : 0;
}
@@ -934,7 +934,7 @@ class RenderLayer : public ScrollableArea {
virtual IntPoint scrollPosition() const;
virtual IntPoint minimumScrollPosition() const;
virtual IntPoint maximumScrollPosition() const;
virtual IntRect visibleContentRect(bool includeScrollbars) const;
virtual IntRect visibleContentRect(VisibleContentRectIncludesScrollbars) const;
virtual int visibleHeight() const;
virtual int visibleWidth() const;
virtual IntSize contentsSize() const;
@@ -1179,7 +1179,7 @@ void RenderLayerCompositor::frameViewDidChangeSize()
{
if (m_clipLayer) {
FrameView* frameView = m_renderView->frameView();
m_clipLayer->setSize(frameView->unscaledVisibleContentSize(false /* exclude scrollbars */));
m_clipLayer->setSize(frameView->unscaledVisibleContentSize());

frameViewDidScroll();
updateOverflowControlsLayers();
@@ -1553,7 +1553,7 @@ void RenderLayerCompositor::updateRootLayerPosition()
}
if (m_clipLayer) {
FrameView* frameView = m_renderView->frameView();
m_clipLayer->setSize(frameView->unscaledVisibleContentSize(false /* exclude scrollbars */));
m_clipLayer->setSize(frameView->unscaledVisibleContentSize());
}

#if ENABLE(RUBBER_BANDING)
@@ -106,7 +106,7 @@ bool TextAutosizer::processSubtree(RenderObject* layoutRoot)
windowInfo.windowSize = m_document->settings()->textAutosizingWindowSizeOverride();
if (windowInfo.windowSize.isEmpty()) {
bool includeScrollbars = !InspectorInstrumentation::shouldApplyScreenWidthOverride(mainFrame);
windowInfo.windowSize = mainFrame->view()->unscaledVisibleContentSize(includeScrollbars);
windowInfo.windowSize = mainFrame->view()->unscaledVisibleContentSize(includeScrollbars ? ScrollableArea::IncludeScrollbars : ScrollableArea::ExcludeScrollbars);
if (!m_document->settings()->applyDeviceScaleFactorInCompositor())
windowInfo.windowSize.scale(1 / m_document->page()->deviceScaleFactor());
}
@@ -2595,7 +2595,7 @@ IntRect WebPagePrivate::getRecursiveVisibleWindowRect(ScrollView* view, bool noC
return IntRect(IntPoint::zero(), view->contentsSize());
}

IntRect visibleWindowRect(view->contentsToWindow(view->visibleContentRect(false)));
IntRect visibleWindowRect(view->contentsToWindow(view->visibleContentRect()));
if (view->parent() && !(noClipOfMainFrame && view->parent() == m_mainFrame->view())) {
// Intersect with parent visible rect.
visibleWindowRect.intersect(getRecursiveVisibleWindowRect(view->parent(), noClipOfMainFrame));

0 comments on commit ad77752

Please sign in to comment.