https://bugs.webkit.org/show_bug.cgi?id=130273
Reviewed by Simon Fraser.
Source/WebCore:
This patch adds support for topContentInset(). If a page has a topContentInset(),
the root layer’s position is adjusted to account for the inset. It is assumed that
the area accounted for by the inset is visible but obscured, so scrollbars need to
be moved so that they only cover the non-obscured area, and most parts of WebCore
that wonder about visibleContentSize only care about the unobscured area, so this
patch makes that visibleContentRect return the unobscuredRect. Finally since this
is achieved by moving a layer’s position, the topContentInset() also needs to be
factored into various functions that are used to convert between coordinate
spaces.
Return Page::topContentInset() if this is the main frame.
* page/FrameView.cpp:
(WebCore::FrameView::topContentInset):
* page/FrameView.h:
Cache the inset on Page.
* page/Page.cpp:
(WebCore::Page::Page):
* page/Page.h:
(WebCore::Page::topContentInset):
(WebCore::Page::setTopContentInset):
unobscuredContentRect() used to unconditionally return visibleContentRect() on
non-iOS platforms. Now that it is possible for some technically visible content to
be obscured, this code needed to be re-worked a bit to make some more sense.
visibleContentRect() now represents that visible content that is completely
unobscured, so it should call into unobscuredContentRect() rather than the other
way around.
* platform/ScrollView.cpp:
(WebCore::ScrollView::unobscuredContentRect):
unscaledTotalVisibleContentSize() includes the size of all content that might be
visible. Some of this content might be obscured.
(WebCore::ScrollView::unscaledTotalVisibleContentSize):
Most of the time, we only care about the content that is FULLY visible. That is
what you get from unscaledUnobscuredVisibleContentSize().
(WebCore::ScrollView::unscaledUnobscuredVisibleContentSize):
Use the unobscured size for these computations.
(WebCore::ScrollView::visibleContentRectInternal):
(WebCore::ScrollView::layoutSize):
Factor in the topContentInset().
(WebCore::ScrollView::scrollOffsetRelativeToDocument):
(WebCore::ScrollView::scrollPositionRelativeToDocument):
The scrollbars should be positioned to cover the non-obscured content only.
(WebCore::ScrollView::updateScrollbars):
Again, factor the topContentInset() into these conversions since the root layer’s
position has been adjusted to account for it.
(WebCore::ScrollView::contentsToRootView):
(WebCore::ScrollView::contentsToWindow):
Just like the scrollbars, the scroll corner must be moved the account for the
inset.
(WebCore::ScrollView::scrollCornerRect):
* platform/ScrollView.h:
(WebCore::ScrollView::topContentInset):
RenderLayerCompositor cares about unscaledTotalVisibleContentSize(). It does not
care if some of that content is obscured.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::frameViewDidChangeSize):
Move the root layer’s position based on the contentInset.
(WebCore::RenderLayerCompositor::updateRootLayerPosition):
(WebCore::RenderLayerCompositor::ensureRootLayer):
Allow setting contentInset via Internals for testing purposes.
* testing/Internals.cpp:
(WebCore::Internals::setTopContentInset):
* testing/Internals.h:
* testing/Internals.idl:
Source/WebKit2:
This patch adds WKView API for setting a topContentInset(). All of this work gets
that number plumbed down to WebCore.
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/API/Cocoa/WKViewPrivate.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _setTopContentInset:]):
(-[WKWebView _topContentInset]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/mac/WKView.mm:
(-[WKView _setTopContentInset:]):
(-[WKView _topContentInset]):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::setTopContentInset):
(WebKit::WebPageProxy::creationParameters):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::topContentInset):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::setTopContentInset):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
LayoutTests:
Add two tests for hit-testing with a topContentInset.
* platform/mac-wk2/tiled-drawing/content-inset-hit-testing-expected.txt: Added.
* platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame-expected.txt: Added.
* platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame.html: Added.
* platform/mac-wk2/tiled-drawing/content-inset-hit-testing.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166017
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-03-20 Beth Dakin <bdakin@apple.com>
+
+ Implement contentInset for Mac WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=130273
+
+ Reviewed by Simon Fraser.
+
+ Add two tests for hit-testing with a topContentInset.
+
+ * platform/mac-wk2/tiled-drawing/content-inset-hit-testing-expected.txt: Added.
+ * platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame-expected.txt: Added.
+ * platform/mac-wk2/tiled-drawing/content-inset-hit-testing-in-frame.html: Added.
+ * platform/mac-wk2/tiled-drawing/content-inset-hit-testing.html: Added.
+
2014-03-20 Brent Fulgham <bfulgham@apple.com>
Add a flushing mechanism for the WebVTTParser
--- /dev/null
+<html>
+<head>
+<script>
+ function runTest() {
+ if (!window.eventSender)
+ return;
+ if (window.internals)
+ window.internals.setTopContentInset(100);
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ eventSender.mouseMoveTo(20, 120);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+</script>
+</head>
+<body onload="runTest()">
+ <iframe src="resources/iframe-to-hit-test.html" scrolling="no" frameborder="no" height="300" width="600"></iframe>
+ <div id="result">This test needs to be run through WebKitTestRunner.</div>
+</body>
+</html>
--- /dev/null
+<html>
+<head>
+<style>
+ #target {
+ background-color:purple;
+ width:25px;
+ height:25px;
+ }
+</style>
+<script>
+ var numberOfClicks = 0;
+
+ function runTest() {
+ if (!window.eventSender)
+ return;
+ if (window.internals)
+ window.internals.setTopContentInset(100);
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ eventSender.mouseMoveTo(15, 115);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+
+ var result = document.getElementById("result");
+ if (numberOfClicks > 0)
+ result.innerHTML = "Pass!";
+ else
+ result.innerHTML = "Fail.";
+ }
+
+ function clicked() {
+ numberOfClicks = 1;
+ }
+</script>
+</head>
+<body onload="runTest()">
+ <div id="target" onclick="clicked()"></div>
+ <div id="result">This test needs to be run through WebKitTestRunner.</div>
+</body>
+</html>
+2014-03-20 Beth Dakin <bdakin@apple.com>
+
+ Implement contentInset for Mac WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=130273
+
+ Reviewed by Simon Fraser.
+
+ This patch adds support for topContentInset(). If a page has a topContentInset(),
+ the root layer’s position is adjusted to account for the inset. It is assumed that
+ the area accounted for by the inset is visible but obscured, so scrollbars need to
+ be moved so that they only cover the non-obscured area, and most parts of WebCore
+ that wonder about visibleContentSize only care about the unobscured area, so this
+ patch makes that visibleContentRect return the unobscuredRect. Finally since this
+ is achieved by moving a layer’s position, the topContentInset() also needs to be
+ factored into various functions that are used to convert between coordinate
+ spaces.
+
+ Return Page::topContentInset() if this is the main frame.
+ * page/FrameView.cpp:
+ (WebCore::FrameView::topContentInset):
+ * page/FrameView.h:
+
+ Cache the inset on Page.
+ * page/Page.cpp:
+ (WebCore::Page::Page):
+ * page/Page.h:
+ (WebCore::Page::topContentInset):
+ (WebCore::Page::setTopContentInset):
+
+ unobscuredContentRect() used to unconditionally return visibleContentRect() on
+ non-iOS platforms. Now that it is possible for some technically visible content to
+ be obscured, this code needed to be re-worked a bit to make some more sense.
+ visibleContentRect() now represents that visible content that is completely
+ unobscured, so it should call into unobscuredContentRect() rather than the other
+ way around.
+ * platform/ScrollView.cpp:
+ (WebCore::ScrollView::unobscuredContentRect):
+
+ unscaledTotalVisibleContentSize() includes the size of all content that might be
+ visible. Some of this content might be obscured.
+ (WebCore::ScrollView::unscaledTotalVisibleContentSize):
+
+ Most of the time, we only care about the content that is FULLY visible. That is
+ what you get from unscaledUnobscuredVisibleContentSize().
+ (WebCore::ScrollView::unscaledUnobscuredVisibleContentSize):
+
+ Use the unobscured size for these computations.
+ (WebCore::ScrollView::visibleContentRectInternal):
+ (WebCore::ScrollView::layoutSize):
+
+ Factor in the topContentInset().
+ (WebCore::ScrollView::scrollOffsetRelativeToDocument):
+ (WebCore::ScrollView::scrollPositionRelativeToDocument):
+
+ The scrollbars should be positioned to cover the non-obscured content only.
+ (WebCore::ScrollView::updateScrollbars):
+
+ Again, factor the topContentInset() into these conversions since the root layer’s
+ position has been adjusted to account for it.
+ (WebCore::ScrollView::contentsToRootView):
+ (WebCore::ScrollView::contentsToWindow):
+
+ Just like the scrollbars, the scroll corner must be moved the account for the
+ inset.
+ (WebCore::ScrollView::scrollCornerRect):
+ * platform/ScrollView.h:
+ (WebCore::ScrollView::topContentInset):
+
+ RenderLayerCompositor cares about unscaledTotalVisibleContentSize(). It does not
+ care if some of that content is obscured.
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::RenderLayerCompositor::frameViewDidChangeSize):
+
+ Move the root layer’s position based on the contentInset.
+ (WebCore::RenderLayerCompositor::updateRootLayerPosition):
+ (WebCore::RenderLayerCompositor::ensureRootLayer):
+
+ Allow setting contentInset via Internals for testing purposes.
+ * testing/Internals.cpp:
+ (WebCore::Internals::setTopContentInset):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
2014-03-20 Laszlo Vidacs <lvidacs.u-szeged@partner.samsung.com>
Optimize RenderTable::colToEffCol() for tables without colspans
__ZN7WebCore4Page16setDefersLoadingEb
__ZN7WebCore4Page18removeSchedulePairEN3WTF10PassRefPtrINS1_12SchedulePairEEE
__ZN7WebCore4Page18setPageScaleFactorEfRKNS_8IntPointE
+__ZN7WebCore4Page18setTopContentInsetEf
__ZN7WebCore4Page19addLayoutMilestonesEj
__ZN7WebCore4Page20scrollingCoordinatorEv
__ZN7WebCore4Page20setDeviceScaleFactorEf
renderView->setNeedsLayout();
}
+float FrameView::topContentInset() const
+{
+ if (!frame().isMainFrame())
+ return 0;
+
+ Page* page = frame().page();
+ return page ? page->topContentInset() : 0;
+}
+
bool FrameView::hasCompositedContent() const
{
if (RenderView* renderView = this->renderView())
virtual int footerHeight() const override { return m_footerHeight; }
void setFooterHeight(int);
+ virtual float topContentInset() const override;
+
virtual void willStartLiveResize() override;
virtual void willEndLiveResize() override;
, m_mediaVolume(1)
, m_pageScaleFactor(1)
, m_deviceScaleFactor(1)
+ , m_topContentInset(0)
, m_suppressScrollbarAnimations(false)
, m_didLoadUserStyleSheet(false)
, m_userStyleSheetModificationTime(0)
pageCache()->markPagesForFullStyleRecalc(this);
GraphicsContext::updateDocumentMarkerResources();
}
-
+
+void Page::setTopContentInset(float contentInset)
+{
+ if (m_topContentInset == contentInset)
+ return;
+
+ m_topContentInset = contentInset;
+ if (RenderView* renderView = mainFrame().contentRenderer())
+ renderView->setNeedsLayout();
+}
+
void Page::setShouldSuppressScrollbarAnimations(bool suppressAnimations)
{
if (suppressAnimations == m_suppressScrollbarAnimations)
float deviceScaleFactor() const { return m_deviceScaleFactor; }
void setDeviceScaleFactor(float);
+ float topContentInset() const { return m_topContentInset; }
+ void setTopContentInset(float);
+
bool shouldSuppressScrollbarAnimations() const { return m_suppressScrollbarAnimations; }
void setShouldSuppressScrollbarAnimations(bool suppressAnimations);
void lockAllOverlayScrollbarsToHidden(bool lockOverlayScrollbars);
float m_pageScaleFactor;
float m_deviceScaleFactor;
+ float m_topContentInset;
+
bool m_suppressScrollbarAnimations;
Pagination m_pagination;
m_delegatesScrolling = delegatesScrolling;
delegatesScrollingDidChange();
}
-
-IntSize ScrollView::unscaledVisibleContentSize(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
+
+#if !PLATFORM(IOS)
+IntRect ScrollView::unobscuredContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
+{
+ FloatSize visibleContentSize = unscaledUnobscuredVisibleContentSize(scrollbarInclusion);
+ visibleContentSize.scale(1 / visibleContentScaleFactor());
+ return IntRect(IntPoint(m_scrollOffset), expandedIntSize(visibleContentSize));
+}
+#endif
+
+IntSize ScrollView::unscaledTotalVisibleContentSize(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
{
if (platformWidget())
return platformVisibleContentSize(scrollbarInclusion == IncludeScrollbars);
return IntSize(width() - verticalScrollbarWidth, height() - horizontalScrollbarHeight).expandedTo(IntSize());
}
+
+IntSize ScrollView::unscaledUnobscuredVisibleContentSize(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
+{
+ IntSize visibleContentSize = unscaledTotalVisibleContentSize(scrollbarInclusion);
+
+ if (platformWidget())
+ return visibleContentSize;
+
+#if USE(TILED_BACKING_STORE)
+ if (!m_fixedVisibleContentRect.isEmpty())
+ return visibleContentSize;
+#endif
+
+ visibleContentSize.setHeight(visibleContentSize.height() - topContentInset());
+ return visibleContentSize;
+}
#if !PLATFORM(GTK)
-IntRect ScrollView::visibleContentRectInternal(VisibleContentRectIncludesScrollbars scollbarInclusion, VisibleContentRectBehavior visibleContentRectBehavior) const
+IntRect ScrollView::visibleContentRectInternal(VisibleContentRectIncludesScrollbars scrollbarInclusion, VisibleContentRectBehavior visibleContentRectBehavior) const
{
#if PLATFORM(IOS)
if (visibleContentRectBehavior == LegacyIOSDocumentViewRect) {
#endif
if (platformWidget())
- return platformVisibleContentRect(scollbarInclusion == IncludeScrollbars);
+ return platformVisibleContentRect(scrollbarInclusion == IncludeScrollbars);
#if USE(TILED_BACKING_STORE)
if (!m_fixedVisibleContentRect.isEmpty())
return m_fixedVisibleContentRect;
#endif
- FloatSize visibleContentSize = unscaledVisibleContentSize(scollbarInclusion);
- visibleContentSize.scale(1 / visibleContentScaleFactor());
- return IntRect(IntPoint(m_scrollOffset), expandedIntSize(visibleContentSize));
+ return unobscuredContentRect();
}
#endif
IntSize ScrollView::layoutSize() const
{
- return m_fixedLayoutSize.isEmpty() || !m_useFixedLayout ? unscaledVisibleContentSize(ExcludeScrollbars) : m_fixedLayoutSize;
+ return m_fixedLayoutSize.isEmpty() || !m_useFixedLayout ? unscaledUnobscuredVisibleContentSize(ExcludeScrollbars) : m_fixedLayoutSize;
}
IntSize ScrollView::fixedLayoutSize() const
IntSize ScrollView::scrollOffsetRelativeToDocument() const
{
IntSize scrollOffset = this->scrollOffset();
- return IntSize(scrollOffset.width(), scrollOffset.height() - headerHeight());
+ return IntSize(scrollOffset.width(), scrollOffset.height() - headerHeight() - topContentInset());
}
IntPoint ScrollView::scrollPositionRelativeToDocument() const
{
IntPoint scrollPosition = this->scrollPosition();
- return IntPoint(scrollPosition.x(), scrollPosition.y() - headerHeight());
+ return IntPoint(scrollPosition.x(), scrollPosition.y() - headerHeight() - topContentInset());
}
int ScrollView::scrollSize(ScrollbarOrientation orientation) const
int pageStep = std::max(std::max<int>(clientWidth * Scrollbar::minFractionToStepWhenPaging(), clientWidth - Scrollbar::maxOverlapBetweenPages()), 1);
IntRect oldRect(m_horizontalScrollbar->frameRect());
IntRect hBarRect(0,
- height() - m_horizontalScrollbar->height(),
- width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0),
- m_horizontalScrollbar->height());
+ height() - m_horizontalScrollbar->height(),
+ width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0),
+ m_horizontalScrollbar->height());
m_horizontalScrollbar->setFrameRect(hBarRect);
if (!m_scrollbarsSuppressed && oldRect != m_horizontalScrollbar->frameRect())
m_horizontalScrollbar->invalidate();
int pageStep = std::max(std::max<int>(clientHeight * Scrollbar::minFractionToStepWhenPaging(), clientHeight - Scrollbar::maxOverlapBetweenPages()), 1);
IntRect oldRect(m_verticalScrollbar->frameRect());
IntRect vBarRect(width() - m_verticalScrollbar->width(),
- 0,
- m_verticalScrollbar->width(),
- height() - (m_horizontalScrollbar ? m_horizontalScrollbar->height() : 0));
+ topContentInset(),
+ m_verticalScrollbar->width(),
+ height() - topContentInset() - (m_horizontalScrollbar ? m_horizontalScrollbar->height() : 0));
m_verticalScrollbar->setFrameRect(vBarRect);
if (!m_scrollbarsSuppressed && oldRect != m_verticalScrollbar->frameRect())
m_verticalScrollbar->invalidate();
if (delegatesScrolling())
return convertToRootView(contentsPoint);
- IntPoint viewPoint = contentsPoint + IntSize(0, headerHeight()) - scrollOffset();
+ IntPoint viewPoint = contentsPoint + IntSize(0, headerHeight() + topContentInset()) - scrollOffset();
return convertToRootView(viewPoint);
}
return convertToRootView(contentsRect);
IntRect viewRect = contentsRect;
- viewRect.move(-scrollOffset() + IntSize(0, headerHeight()));
+ viewRect.move(-scrollOffset() + IntSize(0, headerHeight() + topContentInset()));
return convertToRootView(viewRect);
}
if (delegatesScrolling())
return convertToContainingWindow(contentsPoint);
- IntPoint viewPoint = contentsPoint + IntSize(0, headerHeight()) - scrollOffset();
+ IntPoint viewPoint = contentsPoint + IntSize(0, headerHeight() + topContentInset()) - scrollOffset();
return convertToContainingWindow(viewPoint);
}
return convertToContainingWindow(contentsRect);
IntRect viewRect = contentsRect;
- viewRect.move(-scrollOffset() + IntSize(0, headerHeight()));
+ viewRect.move(-scrollOffset() + IntSize(0, headerHeight() + topContentInset()));
return convertToContainingWindow(viewRect);
}
if (hasOverlayScrollbars())
return cornerRect;
+ int heightTrackedByScrollbar = height() - topContentInset();
+
if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) {
cornerRect.unite(IntRect(m_horizontalScrollbar->width(),
- height() - m_horizontalScrollbar->height(),
- width() - m_horizontalScrollbar->width(),
- m_horizontalScrollbar->height()));
+ height() - m_horizontalScrollbar->height(),
+ width() - m_horizontalScrollbar->width(),
+ m_horizontalScrollbar->height()));
}
- if (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0) {
+ if (m_verticalScrollbar && heightTrackedByScrollbar - m_verticalScrollbar->height() > 0) {
cornerRect.unite(IntRect(width() - m_verticalScrollbar->width(),
- m_verticalScrollbar->height(),
- m_verticalScrollbar->width(),
- height() - m_verticalScrollbar->height()));
+ m_verticalScrollbar->height() + topContentInset(),
+ m_verticalScrollbar->width(),
+ heightTrackedByScrollbar - m_verticalScrollbar->height()));
}
-
+
return cornerRect;
}
void setCanBlitOnScroll(bool);
bool canBlitOnScroll() const;
- // The visible content rect has a location that is the scrolled offset of the document. The width and height are the viewport width
- // and height. By default the scrollbars themselves are excluded from this rectangle, but an optional boolean argument allows them to be
- // included.
+ virtual float topContentInset() const { return 0; }
+
+ // The visible content rect has a location that is the scrolled offset of the document. The width and height are the unobscured viewport
+ // width and height. By default the scrollbars themselves are excluded from this rectangle, but an optional boolean argument allows them
+ // to be included.
// 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.
IntRect unobscuredContentRect() const;
IntRect unobscuredContentRectIncludingScrollbars() const { return unobscuredContentRect(); }
#else
- IntRect unobscuredContentRect() const { return visibleContentRect(); }
+ IntRect unobscuredContentRect(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
IntRect unobscuredContentRectIncludingScrollbars() const { return visibleContentRectIncludingScrollbars(); }
#endif
TileCache* tileCache();
#endif
- // visibleContentRect().size() is computed from unscaledVisibleContentSize() divided by the value of visibleContentScaleFactor.
+ // visibleContentRect().size() is computed from unscaledUnobscuredVisibleContentSize() divided by the value of visibleContentScaleFactor.
// visibleContentScaleFactor is usually 1, except when the setting delegatesPageScaling 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(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
+ // Ports that don't use pageScaleFactor can treat unscaledUnobscuredVisibleContentSize and visibleContentRect().size() as equivalent.
+ // unscaledTotalVisibleContentSize() includes areas in the content that might be obscured by UI elements.
+ IntSize unscaledUnobscuredVisibleContentSize(VisibleContentRectIncludesScrollbars = ExcludeScrollbars) const;
+ IntSize unscaledTotalVisibleContentSize(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
{
if (m_clipLayer) {
const FrameView& frameView = m_renderView.frameView();
- m_clipLayer->setSize(frameView.unscaledVisibleContentSize());
+ m_clipLayer->setSize(frameView.unscaledTotalVisibleContentSize());
frameViewDidScroll();
updateOverflowControlsLayers();
{
if (m_rootContentLayer) {
const IntRect& documentRect = m_renderView.documentRect();
- m_rootContentLayer->setSize(documentRect.size());
- m_rootContentLayer->setPosition(FloatPoint(documentRect.x(), documentRect.y() + m_renderView.frameView().headerHeight()));
+ m_rootContentLayer->setSize(documentRect.size());
+ m_rootContentLayer->setPosition(FloatPoint(documentRect.x(), documentRect.y() + m_renderView.frameView().headerHeight()
+ + m_renderView.frameView().topContentInset()));
}
if (m_clipLayer)
- m_clipLayer->setSize(m_renderView.frameView().unscaledVisibleContentSize());
+ m_clipLayer->setSize(m_renderView.frameView().unscaledTotalVisibleContentSize());
#if ENABLE(RUBBER_BANDING)
if (m_contentShadowLayer) {
m_clipLayer->addChild(m_scrollLayer.get());
m_scrollLayer->addChild(m_rootContentLayer.get());
- m_clipLayer->setSize(m_renderView.frameView().unscaledVisibleContentSize());
+ m_clipLayer->setSize(m_renderView.frameView().unscaledTotalVisibleContentSize());
updateOverflowControlsLayers();
FrameView* frameView = document->view();
frameView->setFooterHeight(height);
}
+
+void Internals::setTopContentInset(float contentInset)
+{
+ Document* document = contextDocument();
+ if (!document)
+ return;
+
+ Page* page = document->page();
+ page->setTopContentInset(contentInset);
+}
#if ENABLE(FULLSCREEN_API)
void Internals::webkitWillEnterFullScreenForElement(Element* element)
void setHeaderHeight(float);
void setFooterHeight(float);
+ void setTopContentInset(float);
+
#if ENABLE(FULLSCREEN_API)
void webkitWillEnterFullScreenForElement(Element*);
void webkitDidEnterFullScreenForElement(Element*);
void setHeaderHeight(float height);
void setFooterHeight(float height);
+ void setTopContentInset(float contentInset);
+
#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
void webkitWillEnterFullScreenForElement(Element element);
void webkitDidEnterFullScreenForElement(Element element);
+2014-03-20 Beth Dakin <bdakin@apple.com>
+
+ Implement contentInset for Mac WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=130273
+
+ Reviewed by Simon Fraser.
+
+ This patch adds WKView API for setting a topContentInset(). All of this work gets
+ that number plumbed down to WebCore.
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode):
+ (WebKit::WebPageCreationParameters::decode):
+ * Shared/WebPageCreationParameters.h:
+ * UIProcess/API/Cocoa/WKViewPrivate.h:
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _setTopContentInset:]):
+ (-[WKWebView _topContentInset]):
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView _setTopContentInset:]):
+ (-[WKView _topContentInset]):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::WebPageProxy):
+ (WebKit::WebPageProxy::setTopContentInset):
+ (WebKit::WebPageProxy::creationParameters):
+ * UIProcess/WebPageProxy.h:
+ (WebKit::WebPageProxy::topContentInset):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::WebPage):
+ (WebKit::WebPage::setTopContentInset):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+
2014-03-20 Anders Carlsson <andersca@apple.com>
Fix 32-bit build.
encoder << canRunBeforeUnloadConfirmPanel;
encoder << canRunModal;
encoder << deviceScaleFactor;
+ encoder << topContentInset;
encoder << mediaVolume;
encoder << mayStartMediaWhenInWindow;
encoder << minimumLayoutSize;
return false;
if (!decoder.decode(parameters.deviceScaleFactor))
return false;
+ if (!decoder.decode(parameters.topContentInset))
+ return false;
if (!decoder.decode(parameters.mediaVolume))
return false;
if (!decoder.decode(parameters.mayStartMediaWhenInWindow))
bool canRunModal;
float deviceScaleFactor;
+
+ float topContentInset;
float mediaVolume;
bool mayStartMediaWhenInWindow;
@property (readwrite) BOOL allowsMagnification;
@property (readwrite) double magnification;
@property (readwrite) BOOL allowsBackForwardNavigationGestures;
+@property (nonatomic, setter=_setTopContentInset:) CGFloat _topContentInset;
@property (readonly) NSColor *_pageExtendedBackgroundColor;
@property(copy, nonatomic) NSColor *underlayColor;
_page->setDrawsTransparentBackground(drawsTransparentBackground);
}
+- (void)_setTopContentInset:(CGFloat)contentInset
+{
+ _page->setTopContentInset(contentInset);
+}
+
+- (CGFloat)_topContentInset
+{
+ return _page->topContentInset();
+}
+
#endif
@end
#else
@property (readonly) NSColor *_pageExtendedBackgroundColor;
@property (nonatomic, setter=_setDrawsTransparentBackground:) BOOL _drawsTransparentBackground;
+@property (nonatomic, setter=_setTopContentInset:) CGFloat _topContentInset;
#endif
- (void)_runJavaScriptInMainFrame:(NSString *)scriptString;
return _data->_allowsBackForwardNavigationGestures;
}
+- (void)_setTopContentInset:(CGFloat)contentInset
+{
+ _data->_page->setTopContentInset(contentInset);
+}
+
+- (CGFloat)_topContentInset
+{
+ return _data->_page->topContentInset();
+}
+
- (NSColor *)_pageExtendedBackgroundColor
{
WebCore::Color color = _data->_page->pageExtendedBackgroundColor();
, m_pageScaleFactor(1)
, m_intrinsicDeviceScaleFactor(1)
, m_customDeviceScaleFactor(0)
+ , m_topContentInset(0)
, m_layerHostingMode(LayerHostingMode::InProcess)
, m_drawsBackground(true)
, m_drawsTransparentBackground(false)
m_process->send(Messages::WebPage::SetDrawsTransparentBackground(drawsTransparentBackground), m_pageID);
}
+void WebPageProxy::setTopContentInset(float contentInset)
+{
+ if (m_topContentInset == contentInset)
+ return;
+
+ m_topContentInset = contentInset;
+
+ if (isValid())
+ m_process->send(Messages::WebPage::SetTopContentInset(contentInset), m_pageID);
+}
+
void WebPageProxy::setUnderlayColor(const Color& color)
{
if (m_underlayColor == color)
parameters.canRunBeforeUnloadConfirmPanel = m_uiClient->canRunBeforeUnloadConfirmPanel();
parameters.canRunModal = m_canRunModal;
parameters.deviceScaleFactor = deviceScaleFactor();
+ parameters.topContentInset = m_topContentInset;
parameters.mediaVolume = m_mediaVolume;
parameters.mayStartMediaWhenInWindow = m_mayStartMediaWhenInWindow;
parameters.minimumLayoutSize = m_minimumLayoutSize;
bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
void setDrawsTransparentBackground(bool);
+ float topContentInset() const { return m_topContentInset; }
+ void setTopContentInset(float);
+
WebCore::Color underlayColor() const { return m_underlayColor; }
void setUnderlayColor(const WebCore::Color&);
double m_pageScaleFactor;
float m_intrinsicDeviceScaleFactor;
float m_customDeviceScaleFactor;
+ float m_topContentInset;
LayerHostingMode m_layerHostingMode;
setScrollPinningBehavior(parameters.scrollPinningBehavior);
setBackgroundExtendsBeyondPage(parameters.backgroundExtendsBeyondPage);
+ setTopContentInset(parameters.topContentInset);
+
m_userAgent = parameters.userAgent;
WebBackForwardListProxy::setHighestItemIDFromUIProcess(parameters.highestUsedBackForwardItemID);
m_drawingArea->setNeedsDisplay();
}
+void WebPage::setTopContentInset(float contentInset)
+{
+ m_page->setTopContentInset(contentInset);
+}
+
void WebPage::viewWillStartLiveResize()
{
if (!m_page)
void setDrawsBackground(bool);
void setDrawsTransparentBackground(bool);
+ void setTopContentInset(float);
+
void viewWillStartLiveResize();
void viewWillEndLiveResize();
SetDrawsBackground(bool drawsBackground)
SetDrawsTransparentBackground(bool drawsTransparentBackground)
+ SetTopContentInset(float contentInset)
+
SetUnderlayColor(WebCore::Color color)
ViewWillStartLiveResize()