Commit 30951718 authored by skobes@chromium.org's avatar skobes@chromium.org

Update Element methods for root layer scrolling.

Four methods on blink::Element that provide special functionality for the html
element (document.documentElement in JS) are updated for compatibility with root
layer scrolling.

BUG=518885
R=eae@chromium.org

Review URL: https://codereview.chromium.org/1310323003 .

git-svn-id: svn://svn.chromium.org/blink/trunk@201166 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 4697420a
Tests that the html element excludes scrollbars when reporting clientWidth and clientHeight, and that it implements scroll() by scrolling the frame.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS htmlElement.clientWidth is innerWidth - 20
PASS htmlElement.clientHeight is innerHeight - 20
PASS scrollX is 10
PASS scrollY is 10
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<style>
::-webkit-scrollbar {
width: 20px;
height: 20px;
}
#space {
height: 1000px;
width: 1000px;
}
</style>
<div id="space"></div>
<script>
description(
"Tests that the html element excludes scrollbars when reporting " +
"clientWidth and clientHeight, and that it implements scroll() " +
"by scrolling the frame.");
var htmlElement = document.documentElement;
shouldBe("htmlElement.clientWidth", "innerWidth - 20");
shouldBe("htmlElement.clientHeight", "innerHeight - 20");
htmlElement.scroll(10, 10);
shouldBe("scrollX", "10");
shouldBe("scrollY", "10");
</script>
......@@ -653,12 +653,10 @@ int Element::clientWidth()
bool inQuirksMode = document().inQuirksMode();
if ((!inQuirksMode && document().documentElement() == this)
|| (inQuirksMode && isHTMLElement() && document().body() == this)) {
if (FrameView* view = document().view()) {
if (LayoutView* layoutView = document().layoutView()) {
if (document().page()->settings().forceZeroLayoutHeight())
return adjustLayoutUnitForAbsoluteZoom(view->visibleContentSize().width(), *layoutView);
return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().width(), *layoutView);
}
if (LayoutView* layoutView = document().layoutView()) {
if (document().page()->settings().forceZeroLayoutHeight())
return adjustLayoutUnitForAbsoluteZoom(layoutView->overflowClipRect(LayoutPoint()).width(), *layoutView);
return adjustLayoutUnitForAbsoluteZoom(layoutView->layoutSize().width(), *layoutView);
}
}
......@@ -677,12 +675,10 @@ int Element::clientHeight()
if ((!inQuirksMode && document().documentElement() == this)
|| (inQuirksMode && isHTMLElement() && document().body() == this)) {
if (FrameView* view = document().view()) {
if (LayoutView* layoutView = document().layoutView()) {
if (document().page()->settings().forceZeroLayoutHeight())
return adjustLayoutUnitForAbsoluteZoom(view->visibleContentSize().height(), *layoutView);
return adjustLayoutUnitForAbsoluteZoom(view->layoutSize().height(), *layoutView);
}
if (LayoutView* layoutView = document().layoutView()) {
if (document().page()->settings().forceZeroLayoutHeight())
return adjustLayoutUnitForAbsoluteZoom(layoutView->overflowClipRect(LayoutPoint()).height(), *layoutView);
return adjustLayoutUnitForAbsoluteZoom(layoutView->layoutSize().height(), *layoutView);
}
}
......@@ -871,13 +867,13 @@ void Element::scrollFrameBy(const ScrollToOptions& scrollToOptions)
LocalFrame* frame = document().frame();
if (!frame)
return;
FrameView* view = frame->view();
if (!view)
ScrollableArea* layoutViewport = frame->view() ? frame->view()->layoutViewportScrollableArea() : 0;
if (!layoutViewport)
return;
double newScaledLeft = left * frame->pageZoomFactor() + view->scrollPositionDouble().x();
double newScaledTop = top * frame->pageZoomFactor() + view->scrollPositionDouble().y();
view->setScrollPosition(DoublePoint(newScaledLeft, newScaledTop), ProgrammaticScroll, scrollBehavior);
double newScaledLeft = left * frame->pageZoomFactor() + layoutViewport->scrollPositionDouble().x();
double newScaledTop = top * frame->pageZoomFactor() + layoutViewport->scrollPositionDouble().y();
layoutViewport->setScrollPosition(DoublePoint(newScaledLeft, newScaledTop), ProgrammaticScroll, scrollBehavior);
}
void Element::scrollFrameTo(const ScrollToOptions& scrollToOptions)
......@@ -887,17 +883,17 @@ void Element::scrollFrameTo(const ScrollToOptions& scrollToOptions)
LocalFrame* frame = document().frame();
if (!frame)
return;
FrameView* view = frame->view();
if (!view)
ScrollableArea* layoutViewport = frame->view() ? frame->view()->layoutViewportScrollableArea() : 0;
if (!layoutViewport)
return;
double scaledLeft = view->scrollPositionDouble().x();
double scaledTop = view->scrollPositionDouble().y();
double scaledLeft = layoutViewport->scrollPositionDouble().x();
double scaledTop = layoutViewport->scrollPositionDouble().y();
if (scrollToOptions.hasLeft())
scaledLeft = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.left()) * frame->pageZoomFactor();
if (scrollToOptions.hasTop())
scaledTop = ScrollableArea::normalizeNonFiniteScroll(scrollToOptions.top()) * frame->pageZoomFactor();
view->setScrollPosition(DoublePoint(scaledLeft, scaledTop), ProgrammaticScroll, scrollBehavior);
layoutViewport->setScrollPosition(DoublePoint(scaledLeft, scaledTop), ProgrammaticScroll, scrollBehavior);
}
void Element::incrementProxyCount()
......
......@@ -560,12 +560,12 @@ protected:
virtual void parserDidSetAttributes() { }
private:
void scrollLayoutBoxBy(const ScrollToOptions&);
void scrollLayoutBoxTo(const ScrollToOptions&);
void scrollFrameBy(const ScrollToOptions&);
void scrollFrameTo(const ScrollToOptions&);
private:
bool hasElementFlag(ElementFlags mask) const { return hasRareData() && hasElementFlagInternal(mask); }
void setElementFlag(ElementFlags, bool value = true);
void clearElementFlag(ElementFlags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment