本文整理汇总了C++中LayoutBlock::mapToVisualRectInAncestorSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutBlock::mapToVisualRectInAncestorSpace方法的具体用法?C++ LayoutBlock::mapToVisualRectInAncestorSpace怎么用?C++ LayoutBlock::mapToVisualRectInAncestorSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutBlock
的用法示例。
在下文中一共展示了LayoutBlock::mapToVisualRectInAncestorSpace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setBodyInnerHTML
TEST_F(VisualRectMappingTest, ContainerOverflowHidden) {
setBodyInnerHTML(
"<div id='container' style='position: absolute; top: 111px; left: 222px;"
" border: 10px solid red; overflow: hidden; width: 50px; height: "
"80px;'>"
" <div id='target' style='box-shadow: 40px 20px black; width: 100px; "
"height: 90px'></div>"
"</div>");
LayoutBlock* container =
toLayoutBlock(getLayoutObjectByElementId("container"));
EXPECT_EQ(LayoutUnit(), container->scrollTop());
EXPECT_EQ(LayoutUnit(), container->scrollLeft());
container->setScrollTop(LayoutUnit(27));
container->setScrollLeft(LayoutUnit(28));
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));
EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect);
rect = targetVisualRect;
EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect));
// Rect is not clipped by container's overflow clip.
EXPECT_EQ(LayoutRect(10, 10, 140, 110), rect);
}
示例2: enableCompositing
TEST_F(VisualRectMappingTest,
DifferentPaintInvalidaitionContainerForAbsolutePosition) {
enableCompositing();
document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
setBodyInnerHTML(
"<div id='stacking-context' style='opacity: 0.9; background: blue; "
"will-change: transform'>"
" <div id='scroller' style='overflow: scroll; width: 80px; height: "
"80px'>"
" <div id='absolute' style='position: absolute; top: 111px; left: "
"222px; width: 50px; height: 50px; background: green'></div>"
" <div id='normal-flow' style='width: 2000px; height: 2000px; "
"background: yellow'></div>"
" </div>"
"</div>");
LayoutBlock* scroller = toLayoutBlock(getLayoutObjectByElementId("scroller"));
scroller->setScrollTop(LayoutUnit(77));
scroller->setScrollLeft(LayoutUnit(88));
document().view()->updateAllLifecyclePhases();
LayoutBlock* normalFlow =
toLayoutBlock(getLayoutObjectByElementId("normal-flow"));
EXPECT_EQ(scroller, &normalFlow->containerForPaintInvalidation());
LayoutRect normalFlowVisualRect = normalFlow->localVisualRect();
EXPECT_EQ(LayoutRect(0, 0, 2000, 2000), normalFlowVisualRect);
LayoutRect rect = normalFlowVisualRect;
EXPECT_TRUE(normalFlow->mapToVisualRectInAncestorSpace(scroller, rect));
EXPECT_EQ(LayoutRect(0, 0, 2000, 2000), rect);
checkPaintInvalidationStateRectMapping(rect, normalFlowVisualRect,
*normalFlow, layoutView(), *scroller);
LayoutBlock* stackingContext =
toLayoutBlock(getLayoutObjectByElementId("stacking-context"));
LayoutBlock* absolute = toLayoutBlock(getLayoutObjectByElementId("absolute"));
EXPECT_EQ(stackingContext, &absolute->containerForPaintInvalidation());
EXPECT_EQ(stackingContext, absolute->container());
LayoutRect absoluteVisualRect = absolute->localVisualRect();
EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteVisualRect);
rect = absoluteVisualRect;
EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect));
EXPECT_EQ(LayoutRect(222, 111, 50, 50), rect);
checkPaintInvalidationStateRectMapping(rect, absoluteVisualRect, *absolute,
layoutView(), *stackingContext);
}
示例3: originalRect
TEST_F(VisualRectMappingTest, LayoutViewDisplayNone) {
document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
setBodyInnerHTML(
"<style>body { margin: 0; }</style>"
"<div id=frameContainer>"
" <iframe id='frame' src='http://test.com' width='50' height='50' "
"frameBorder='0'></iframe>"
"</div>");
setChildFrameHTML(
"<style>body { margin: 0; }</style><div "
"style='width:100px;height:100px;'></div>");
document().view()->updateAllLifecyclePhases();
LayoutBlock* frameContainer =
toLayoutBlock(getLayoutObjectByElementId("frameContainer"));
LayoutBlock* frameBody =
toLayoutBlock(childDocument().body()->layoutObject());
LayoutBlock* frameDiv = toLayoutBlock(frameBody->lastChild());
// This part is copied from the LayoutView test, just to ensure that the
// mapped rect is valid before display:none is set on the iframe.
childDocument().view()->setScrollOffset(ScrollOffset(0, 47),
ProgrammaticScroll);
LayoutRect originalRect(4, 60, 20, 80);
LayoutRect rect = originalRect;
EXPECT_TRUE(frameDiv->mapToVisualRectInAncestorSpace(frameContainer, rect));
EXPECT_EQ(rect, LayoutRect(4, 13, 20, 37));
Element* frameElement = document().getElementById("frame");
frameElement->setInlineStyleProperty(CSSPropertyDisplay, "none");
document().view()->updateAllLifecyclePhases();
rect = originalRect;
EXPECT_FALSE(frameDiv->mapToVisualRectInAncestorSpace(&layoutView(), rect));
EXPECT_EQ(rect, LayoutRect());
}