本文整理汇总了C++中LayoutBoxModelObject类的典型用法代码示例。如果您正苦于以下问题:C++ LayoutBoxModelObject类的具体用法?C++ LayoutBoxModelObject怎么用?C++ LayoutBoxModelObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LayoutBoxModelObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toLayoutBoxModelObject
// static
bool InspectorHighlight::getBoxModel(Node* node, RefPtr<TypeBuilder::DOM::BoxModel>& model)
{
LayoutObject* layoutObject = node->layoutObject();
FrameView* view = node->document().view();
if (!layoutObject || !view)
return false;
FloatQuad content, padding, border, margin;
if (!buildNodeQuads(node, &content, &padding, &border, &margin))
return false;
IntRect boundingBox = view->contentsToRootFrame(layoutObject->absoluteBoundingBoxRect());
LayoutBoxModelObject* modelObject = layoutObject->isBoxModelObject() ? toLayoutBoxModelObject(layoutObject) : nullptr;
model = TypeBuilder::DOM::BoxModel::create()
.setContent(buildArrayForQuad(content))
.setPadding(buildArrayForQuad(padding))
.setBorder(buildArrayForQuad(border))
.setMargin(buildArrayForQuad(margin))
.setWidth(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetWidth(), modelObject) : boundingBox.width())
.setHeight(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetHeight(), modelObject) : boundingBox.height());
Shape::DisplayPaths paths;
FloatQuad boundsQuad;
if (const ShapeOutsideInfo* shapeOutsideInfo = shapeOutsideInfoForNode(node, &paths, &boundsQuad)) {
RefPtr<TypeBuilder::DOM::ShapeOutsideInfo> shapeTypeBuilder = TypeBuilder::DOM::ShapeOutsideInfo::create()
.setBounds(buildArrayForQuad(boundsQuad))
.setShape(ShapePathBuilder::buildPath(*view, *layoutObject, *shapeOutsideInfo, paths.shape))
.setMarginShape(ShapePathBuilder::buildPath(*view, *layoutObject, *shapeOutsideInfo, paths.marginShape));
model->setShapeOutside(shapeTypeBuilder);
}
return true;
}
示例2: deriveBorderBoxFromContainerContext
static void deriveBorderBoxFromContainerContext(const LayoutBoxModelObject& object, PaintPropertyTreeBuilderContext& context)
{
// TODO(trchen): There is some insanity going on with tables. Double check results.
switch (object.styleRef().position()) {
case StaticPosition:
break;
case RelativePosition:
context.paintOffset += object.offsetForInFlowPosition();
break;
case AbsolutePosition:
context.currentTransform = context.transformForOutOfFlowPositioned;
context.paintOffset = context.paintOffsetForOutOfFlowPositioned;
break;
case StickyPosition:
context.paintOffset += object.offsetForInFlowPosition();
break;
case FixedPosition:
context.currentTransform = context.transformForFixedPositioned;
context.paintOffset = context.paintOffsetForFixedPositioned;
break;
default:
ASSERT_NOT_REACHED();
}
if (object.isBox())
context.paintOffset += toLayoutBox(object).locationOffset();
}
示例3: protect
int PrintContext::pageNumberForElement(Element* element, const FloatSize& pageSizeInPixels)
{
// Make sure the element is not freed during the layout.
RefPtrWillBeRawPtr<Element> protect(element);
element->document().updateLayout();
LayoutBoxModelObject* box = enclosingBoxModelObject(element->layoutObject());
if (!box)
return -1;
LocalFrame* frame = element->document().frame();
FloatRect pageRect(FloatPoint(0, 0), pageSizeInPixels);
PrintContext printContext(frame);
printContext.begin(pageRect.width(), pageRect.height());
FloatSize scaledPageSize = pageSizeInPixels;
scaledPageSize.scale(frame->view()->contentsSize().width() / pageRect.width());
printContext.computePageRectsWithPageSize(scaledPageSize);
int top = box->pixelSnappedOffsetTop();
int left = box->pixelSnappedOffsetLeft();
size_t pageNumber = 0;
for (; pageNumber < printContext.pageCount(); pageNumber++) {
const IntRect& page = printContext.pageRect(pageNumber);
if (page.x() <= left && left < page.maxX() && page.y() <= top && top < page.maxY())
return pageNumber;
}
return -1;
}
示例4: ASSERT
void LineBoxListPainter::paint(const LayoutBoxModelObject& layoutObject, const PaintInfo& paintInfo, const LayoutPoint& paintOffset) const
{
ASSERT(!shouldPaintSelfOutline(paintInfo.phase) && !shouldPaintDescendantOutlines(paintInfo.phase));
// Only paint during the foreground/selection phases.
if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseTextClip && paintInfo.phase != PaintPhaseMask)
return;
ASSERT(layoutObject.isLayoutBlock() || (layoutObject.isLayoutInline() && layoutObject.hasLayer())); // The only way an inline could paint like this is if it has a layer.
if (paintInfo.phase == PaintPhaseForeground && paintInfo.isPrinting())
addPDFURLRectsForInlineChildrenRecursively(layoutObject, paintInfo, paintOffset);
// If we have no lines then we have no work to do.
if (!m_lineBoxList.firstLineBox())
return;
if (!m_lineBoxList.anyLineIntersectsRect(LineLayoutBoxModel(const_cast<LayoutBoxModelObject*>(&layoutObject)), paintInfo.cullRect(), paintOffset))
return;
PaintInfo info(paintInfo);
// See if our root lines intersect with the dirty rect. If so, then we paint
// them. Note that boxes can easily overlap, so we can't make any assumptions
// based off positions of our first line box or our last line box.
for (InlineFlowBox* curr = m_lineBoxList.firstLineBox(); curr; curr = curr->nextLineBox()) {
if (m_lineBoxList.lineIntersectsDirtyRect(LineLayoutBoxModel(const_cast<LayoutBoxModelObject*>(&layoutObject)), curr, info.cullRect(), paintOffset)) {
RootInlineBox& root = curr->root();
curr->paint(info, paintOffset, root.lineTop(), root.lineBottom());
}
}
}
示例5: computeHighlightLayerPathAndPosition
bool LinkHighlightImpl::computeHighlightLayerPathAndPosition(const LayoutBoxModelObject& paintInvalidationContainer)
{
if (!m_node || !m_node->layoutObject() || !m_currentGraphicsLayer)
return false;
// FIXME: This is defensive code to avoid crashes such as those described in
// crbug.com/440887. This should be cleaned up once we fix the root cause of
// of the paint invalidation container not being composited.
if (!paintInvalidationContainer.layer()->compositedLayerMapping() && !paintInvalidationContainer.layer()->groupedMapping())
return false;
// Get quads for node in absolute coordinates.
Vector<FloatQuad> quads;
computeQuads(*m_node, quads);
DCHECK(quads.size());
Path newPath;
for (size_t quadIndex = 0; quadIndex < quads.size(); ++quadIndex) {
FloatQuad absoluteQuad = quads[quadIndex];
// Scrolling content layers have the same offset from layout object as the non-scrolling layers. Thus we need
// to adjust for their scroll offset.
if (m_isScrollingGraphicsLayer) {
DoubleSize adjustedScrollOffset = paintInvalidationContainer.layer()->getScrollableArea()->adjustedScrollOffset();
absoluteQuad.move(adjustedScrollOffset.width(), adjustedScrollOffset.height());
}
// Transform node quads in target absolute coords to local coordinates in the compositor layer.
FloatQuad transformedQuad;
convertTargetSpaceQuadToCompositedLayer(absoluteQuad, m_node->layoutObject(), paintInvalidationContainer, transformedQuad);
// FIXME: for now, we'll only use rounded paths if we have a single node quad. The reason for this is that
// we may sometimes get a chain of adjacent boxes (e.g. for text nodes) which end up looking like sausage
// links: these should ideally be merged into a single rect before creating the path, but that's
// another CL.
if (quads.size() == 1 && transformedQuad.isRectilinear()
&& !m_owningWebViewImpl->settingsImpl()->mockGestureTapHighlightsEnabled()) {
FloatSize rectRoundingRadii(3, 3);
newPath.addRoundedRect(transformedQuad.boundingBox(), rectRoundingRadii);
} else {
addQuadToPath(transformedQuad, newPath);
}
}
FloatRect boundingRect = newPath.boundingRect();
newPath.translate(-toFloatSize(boundingRect.location()));
bool pathHasChanged = !(newPath == m_path);
if (pathHasChanged) {
m_path = newPath;
m_contentLayer->layer()->setBounds(enclosingIntRect(boundingRect).size());
}
m_contentLayer->layer()->setPosition(boundingRect.location());
return pathHasChanged;
}
示例6: createEffectIfNeeded
static PassRefPtr<EffectPaintPropertyNode> createEffectIfNeeded(const LayoutBoxModelObject& object, PaintPropertyTreeBuilderContext& context)
{
const ComputedStyle& style = object.styleRef();
if (!object.isBox() || !style.hasOpacity())
return nullptr;
RefPtr<EffectPaintPropertyNode> newEffectNode = EffectPaintPropertyNode::create(style.opacity(), context.currentEffect);
context.currentEffect = newEffectNode.get();
return newEffectNode.release();
}
示例7: createPerspectiveIfNeeded
static PassRefPtr<TransformPaintPropertyNode> createPerspectiveIfNeeded(const LayoutBoxModelObject& object, PaintPropertyTreeBuilderContext& context)
{
const ComputedStyle& style = object.styleRef();
if (!object.isBox() || !style.hasPerspective())
return nullptr;
RefPtr<TransformPaintPropertyNode> newTransformNodeForPerspective = TransformPaintPropertyNode::create(
TransformationMatrix().applyPerspective(style.perspective()),
perspectiveOrigin(toLayoutBox(object)) + toLayoutSize(context.paintOffset), context.currentTransform);
context.currentTransform = newTransformNodeForPerspective.get();
return newTransformNodeForPerspective.release();
}
示例8: checkIsClippingStackingContextAndContainer
static void checkIsClippingStackingContextAndContainer(LayoutBoxModelObject& obj)
{
EXPECT_TRUE(obj.canContainFixedPositionObjects());
EXPECT_TRUE(obj.hasClipRelatedProperty());
EXPECT_TRUE(obj.style()->containsPaint());
// TODO(leviw): Ideally, we wouldn't require a paint layer to handle the clipping
// and stacking performed by paint containment.
ASSERT(obj.layer());
PaintLayer* layer = obj.layer();
EXPECT_TRUE(layer->stackingNode() && layer->stackingNode()->isStackingContext());
}
示例9: updateOutOfFlowContext
static void updateOutOfFlowContext(const LayoutBoxModelObject& object, PaintPropertyTreeBuilderContext& context)
{
const ComputedStyle& style = object.styleRef();
bool hasTransform = object.isBox() && style.hasTransform();
if (style.position() != StaticPosition || hasTransform) {
context.transformForOutOfFlowPositioned = context.currentTransform;
context.paintOffsetForOutOfFlowPositioned = context.paintOffset;
}
if (hasTransform) {
context.transformForFixedPositioned = context.currentTransform;
context.paintOffsetForFixedPositioned = context.paintOffset;
}
}
示例10: createPaintOffsetTranslationIfNeeded
static PassRefPtr<TransformPaintPropertyNode> createPaintOffsetTranslationIfNeeded(const LayoutBoxModelObject& object, PaintPropertyTreeBuilderContext& context)
{
// TODO(trchen): Eliminate PaintLayer dependency.
bool shouldCreatePaintOffsetTranslationNode = object.layer() && object.layer()->paintsWithTransform(GlobalPaintNormalPhase);
if (context.paintOffset == LayoutPoint() || !shouldCreatePaintOffsetTranslationNode)
return nullptr;
RefPtr<TransformPaintPropertyNode> newTransformNodeForPaintOffsetTranslation = TransformPaintPropertyNode::create(
TransformationMatrix().translate(context.paintOffset.x(), context.paintOffset.y()),
FloatPoint3D(), context.currentTransform);
context.currentTransform = newTransformNodeForPaintOffsetTranslation.get();
context.paintOffset = LayoutPoint();
return newTransformNodeForPaintOffsetTranslation.release();
}
示例11: toLayoutInline
void BlockPainter::paintContinuationOutlines(const PaintInfo& info, const LayoutPoint& paintOffset)
{
LayoutInline* inlineCont = m_layoutBlock.inlineElementContinuation();
if (inlineCont && inlineCont->style()->hasOutline() && inlineCont->style()->visibility() == VISIBLE) {
LayoutInline* inlineLayoutObject = toLayoutInline(inlineCont->node()->layoutObject());
LayoutBlock* cb = m_layoutBlock.containingBlock();
bool inlineEnclosedInSelfPaintingLayer = false;
for (LayoutBoxModelObject* box = inlineLayoutObject; box != cb; box = box->parent()->enclosingBoxModelObject()) {
if (box->hasSelfPaintingLayer()) {
inlineEnclosedInSelfPaintingLayer = true;
break;
}
}
// Do not add continuations for outline painting by our containing block if we are a relative positioned
// anonymous block (i.e. have our own layer), paint them straightaway instead. This is because a block depends on layoutObjects in its continuation table being
// in the same layer.
if (!inlineEnclosedInSelfPaintingLayer && !m_layoutBlock.hasLayer()) {
cb->addContinuationWithOutline(inlineLayoutObject);
} else if (!inlineLayoutObject->firstLineBox() || (!inlineEnclosedInSelfPaintingLayer && m_layoutBlock.hasLayer())) {
// The outline might be painted multiple times if multiple blocks have the same inline element continuation, and the inline has a self-painting layer.
ScopeRecorder scopeRecorder(*info.context);
InlinePainter(*inlineLayoutObject).paintOutline(info, paintOffset - m_layoutBlock.locationOffset() + inlineLayoutObject->containingBlock()->location());
}
}
ContinuationOutlineTableMap* table = continuationOutlineTable();
if (table->isEmpty())
return;
OwnPtr<ListHashSet<LayoutInline*>> continuations = table->take(&m_layoutBlock);
if (!continuations)
return;
LayoutPoint accumulatedPaintOffset = paintOffset;
// Paint each continuation outline.
ListHashSet<LayoutInline*>::iterator end = continuations->end();
for (ListHashSet<LayoutInline*>::iterator it = continuations->begin(); it != end; ++it) {
// Need to add in the coordinates of the intervening blocks.
LayoutInline* flow = *it;
LayoutBlock* block = flow->containingBlock();
for ( ; block && block != &m_layoutBlock; block = block->containingBlock())
accumulatedPaintOffset.moveBy(block->location());
ASSERT(block);
InlinePainter(*flow).paintOutline(info, accumulatedPaintOffset);
}
}
示例12: createTransformIfNeeded
static PassRefPtr<TransformPaintPropertyNode> createTransformIfNeeded(const LayoutBoxModelObject& object, PaintPropertyTreeBuilderContext& context)
{
const ComputedStyle& style = object.styleRef();
if (!object.isBox() || !style.hasTransform())
return nullptr;
ASSERT(context.paintOffset == LayoutPoint());
TransformationMatrix matrix;
style.applyTransform(matrix, toLayoutBox(object).size(), ComputedStyle::ExcludeTransformOrigin,
ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTransformProperties);
RefPtr<TransformPaintPropertyNode> newTransformNodeForTransform = TransformPaintPropertyNode::create(
matrix, transformOrigin(toLayoutBox(object)), context.currentTransform);
context.currentTransform = newTransformNodeForTransform.get();
return newTransformNodeForTransform.release();
}
示例13: target
void MouseRelatedEvent::computeRelativePosition()
{
Node* targetNode = target() ? target()->toNode() : nullptr;
if (!targetNode)
return;
// Compute coordinates that are based on the target.
m_layerLocation = m_pageLocation;
m_offsetLocation = m_pageLocation;
// Must have an updated layout tree for this math to work correctly.
targetNode->document().updateLayoutIgnorePendingStylesheets();
// Adjust offsetLocation to be relative to the target's padding box.
if (LayoutObject* r = targetNode->layoutObject()) {
FloatPoint localPos = r->absoluteToLocal(FloatPoint(absoluteLocation()), UseTransforms);
// Adding this here to address crbug.com/570666. Basically we'd like to
// find the local coordinates relative to the padding box not the border box.
if (r->isBoxModelObject()) {
LayoutBoxModelObject* layoutBox = toLayoutBoxModelObject(r);
localPos.move(-layoutBox->borderLeft(), -layoutBox->borderTop());
}
m_offsetLocation = roundedLayoutPoint(localPos);
float scaleFactor = 1 / pageZoomFactor(this);
if (scaleFactor != 1.0f)
m_offsetLocation.scale(scaleFactor, scaleFactor);
}
// Adjust layerLocation to be relative to the layer.
// FIXME: event.layerX and event.layerY are poorly defined,
// and probably don't always correspond to PaintLayer offsets.
// https://bugs.webkit.org/show_bug.cgi?id=21868
Node* n = targetNode;
while (n && !n->layoutObject())
n = n->parentNode();
if (n) {
// FIXME: This logic is a wrong implementation of convertToLayerCoords.
for (PaintLayer* layer = n->layoutObject()->enclosingLayer(); layer; layer = layer->parent())
m_layerLocation -= toLayoutSize(layer->location());
}
m_hasCachedRelativePosition = true;
}
示例14: invalidatePaintOfScrollbarIfNeeded
static void invalidatePaintOfScrollbarIfNeeded(Scrollbar* scrollbar, GraphicsLayer* graphicsLayer, bool& previouslyWasOverlay, LayoutRect& previousPaintInvalidationRect, bool needsPaintInvalidationArg, LayoutBox& box, const PaintInvalidationState& paintInvalidationState, const LayoutBoxModelObject& paintInvalidationContainer)
{
bool isOverlay = scrollbar && scrollbar->isOverlayScrollbar();
// Calculate paint invalidation rect of the scrollbar, except overlay composited scrollbars because we invalidate the graphics layer only.
LayoutRect newPaintInvalidationRect;
if (scrollbar && !(graphicsLayer && isOverlay))
newPaintInvalidationRect = scrollControlPaintInvalidationRect(scrollbar->frameRect(), box, paintInvalidationState, paintInvalidationContainer);
bool needsPaintInvalidation = needsPaintInvalidationArg;
if (graphicsLayer) {
// If the scrollbar needs paint invalidation but didn't change location/size or the scrollbar is an
// overlay scrollbar (paint invalidation rect is empty), invalidating the graphics layer is enough
// (which has been done in ScrollableArea::setScrollbarNeedsPaintInvalidation()).
// Otherwise invalidatePaintOfScrollControlIfNeeded() below will invalidate the old and new location
// of the scrollbar on the box's paint invalidation container to ensure newly expanded/shrunk areas
// of the box to be invalidated.
needsPaintInvalidation = false;
}
// Invalidate the box's display item client if the box's padding box size is affected by change of the
// non-overlay scrollbar width. We detect change of paint invalidation rect size instead of change of
// scrollbar width change, which may have some false-positives (e.g. the scrollbar changed length but
// not width) but won't invalidate more than expected because in the false-positive case the box must
// have changed size and have been invalidated.
LayoutSize newScrollbarUsedSpaceInBox;
if (!isOverlay)
newScrollbarUsedSpaceInBox = newPaintInvalidationRect.size();
LayoutSize previousScrollbarUsedSpaceInBox;
if (!previouslyWasOverlay)
previousScrollbarUsedSpaceInBox= previousPaintInvalidationRect.size();
if (newScrollbarUsedSpaceInBox != previousScrollbarUsedSpaceInBox)
paintInvalidationContainer.invalidateDisplayItemClientOnBacking(box, PaintInvalidationScroll);
bool invalidated = invalidatePaintOfScrollControlIfNeeded(newPaintInvalidationRect, previousPaintInvalidationRect, needsPaintInvalidation, box, paintInvalidationContainer);
previousPaintInvalidationRect = newPaintInvalidationRect;
previouslyWasOverlay = isOverlay;
if (!invalidated || !scrollbar || graphicsLayer)
return;
paintInvalidationContainer.invalidateDisplayItemClientOnBacking(*scrollbar, PaintInvalidationScroll);
if (scrollbar->isCustomScrollbar())
toLayoutScrollbar(scrollbar)->invalidateDisplayItemClientsOfScrollbarParts(paintInvalidationContainer);
}
示例15: createScrollTranslationIfNeeded
static PassRefPtr<TransformPaintPropertyNode> createScrollTranslationIfNeeded(const LayoutBoxModelObject& object, PaintPropertyTreeBuilderContext& context)
{
if (!object.hasOverflowClip())
return nullptr;
PaintLayer* layer = object.layer();
ASSERT(layer);
DoubleSize scrollOffset = layer->scrollableArea()->scrollOffset();
if (scrollOffset.isZero() && !layer->scrollsOverflow())
return nullptr;
RefPtr<TransformPaintPropertyNode> newTransformNodeForScrollTranslation = TransformPaintPropertyNode::create(
TransformationMatrix().translate(-scrollOffset.width(), -scrollOffset.height()),
FloatPoint3D(), context.currentTransform);
context.currentTransform = newTransformNodeForScrollTranslation.get();
return newTransformNodeForScrollTranslation.release();
}