本文整理汇总了C++中LayoutBlock::scrolledContentOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutBlock::scrolledContentOffset方法的具体用法?C++ LayoutBlock::scrolledContentOffset怎么用?C++ LayoutBlock::scrolledContentOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutBlock
的用法示例。
在下文中一共展示了LayoutBlock::scrolledContentOffset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: originalRect
TEST_F(VisualRectMappingTest, LayoutInline) {
document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
setBodyInnerHTML(
"<style>body { margin: 0; }</style>"
"<div id='container' style='overflow: scroll; width: 50px; height: 50px'>"
" <span><img style='width: 20px; height: 100px'></span>"
" <span id=leaf></span></div>");
LayoutBlock* container =
toLayoutBlock(getLayoutObjectByElementId("container"));
LayoutObject* leaf = container->lastChild();
container->setScrollTop(LayoutUnit(50));
LayoutRect originalRect(0, 60, 20, 80);
LayoutRect rect = originalRect;
EXPECT_TRUE(leaf->mapToVisualRectInAncestorSpace(container, rect));
rect.move(-container->scrolledContentOffset());
EXPECT_EQ(rect, LayoutRect(0, 10, 20, 80));
rect = originalRect;
EXPECT_TRUE(leaf->mapToVisualRectInAncestorSpace(&layoutView(), rect));
EXPECT_EQ(rect, LayoutRect(0, 10, 20, 40));
checkPaintInvalidationStateRectMapping(rect, originalRect, *leaf,
layoutView(), layoutView());
rect = LayoutRect(0, 60, 80, 0);
EXPECT_TRUE(
leaf->mapToVisualRectInAncestorSpace(container, rect, EdgeInclusive));
rect.move(-container->scrolledContentOffset());
EXPECT_EQ(rect, LayoutRect(0, 10, 80, 0));
}
示例2: setBodyInnerHTML
TEST_F(VisualRectMappingTest, ContainerAndTargetDifferentFlippedWritingMode) {
setBodyInnerHTML(
"<div id='container' style='writing-mode: vertical-rl; position: "
"absolute; top: 111px; left: 222px;"
" border: solid red; border-width: 10px 20px 30px 40px;"
" overflow: scroll; width: 50px; height: 80px'>"
" <div id='target' style='writing-mode: vertical-lr; box-shadow: 40px "
"20px black; width: 100px; height: 90px'></div>"
" <div style='width: 100px; height: 100px'></div>"
"</div>");
LayoutBlock* container =
toLayoutBlock(getLayoutObjectByElementId("container"));
EXPECT_EQ(LayoutUnit(), container->scrollTop());
// The initial scroll offset is to the left-most because of flipped blocks
// writing mode.
// 150 = total_layout_overflow(100 + 100) - width(50)
EXPECT_EQ(LayoutUnit(150), container->scrollLeft());
container->setScrollTop(LayoutUnit(7));
container->setScrollLeft(
LayoutUnit(142)); // Scroll to the right by 8 pixels.
document().view()->updateAllLifecyclePhases();
LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
LayoutRect targetVisualRect = target->localVisualRect();
// 140 = width(100) + box_shadow_offset_x(40)
// 110 = height(90) + box_shadow_offset_y(20)
EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetVisualRect);
LayoutRect rect = targetVisualRect;
EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect));
// This rect is in physical coordinates of target.
EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect);
rect = targetVisualRect;
EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect));
rect.move(-container->scrolledContentOffset());
// -2 = target_physical_x(100) + container_border_left(40) - scroll_left(142)
// 3 = target_y(0) + container_border_top(10) - scroll_top(7)
// Rect is not clipped by container's overflow clip.
EXPECT_EQ(LayoutRect(-2, 3, 140, 110), rect);
}