本文整理汇总了C++中RenderBox类的典型用法代码示例。如果您正苦于以下问题:C++ RenderBox类的具体用法?C++ RenderBox怎么用?C++ RenderBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findLegend
RenderObject* RenderFieldset::layoutSpecialExcludedChild(bool relayoutChildren)
{
RenderBox* legend = findLegend();
if (legend) {
if (relayoutChildren)
legend->setNeedsLayout(true);
legend->layoutIfNeeded();
LayoutUnit logicalLeft;
if (style()->isLeftToRightDirection()) {
switch (legend->style()->textAlign()) {
case CENTER:
logicalLeft = (logicalWidth() - logicalWidthForChild(legend)) / 2;
break;
case RIGHT:
logicalLeft = logicalWidth() - borderEnd() - paddingEnd() - logicalWidthForChild(legend);
break;
default:
logicalLeft = borderStart() + paddingStart() + marginStartForChild(legend);
break;
}
} else {
switch (legend->style()->textAlign()) {
case LEFT:
logicalLeft = borderStart() + paddingStart();
break;
case CENTER: {
// Make sure that the extra pixel goes to the end side in RTL (since it went to the end side
// in LTR).
LayoutUnit centeredWidth = logicalWidth() - logicalWidthForChild(legend);
logicalLeft = centeredWidth - centeredWidth / 2;
break;
}
default:
logicalLeft = logicalWidth() - borderStart() - paddingStart() - marginStartForChild(legend) - logicalWidthForChild(legend);
break;
}
}
setLogicalLeftForChild(legend, logicalLeft);
LayoutUnit b = borderBefore();
LayoutUnit h = logicalHeightForChild(legend);
setLogicalTopForChild(legend, max<LayoutUnit>((b - h) / 2, 0));
setLogicalHeight(max(b, h) + paddingBefore());
}
return legend;
}
示例2: computeReplacedLogicalHeightRespectingMinMaxHeight
LayoutUnit RenderReplaced::computeReplacedLogicalHeight() const
{
// 10.5 Content height: the 'height' property: http://www.w3.org/TR/CSS21/visudet.html#propdef-height
if (hasReplacedLogicalHeight())
return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style()->logicalHeight()));
RenderBox* contentRenderer = embeddedContentBox();
// 10.6.2 Inline, replaced elements: http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-height
bool isPercentageIntrinsicSize = false;
double intrinsicRatio = 0;
FloatSize intrinsicSize;
if (contentRenderer)
contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
else
computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio, isPercentageIntrinsicSize);
if (intrinsicRatio && !isHorizontalWritingMode())
intrinsicRatio = 1 / intrinsicRatio;
bool widthIsAuto = style()->logicalWidth().isAuto();
bool hasIntrinsicHeight = m_hasIntrinsicSize || (!isPercentageIntrinsicSize && intrinsicSize.height() > 0);
// If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic height, then that intrinsic height is the used value of 'height'.
if (widthIsAuto && hasIntrinsicHeight) {
if (m_hasIntrinsicSize)
return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight());
return static_cast<LayoutUnit>(intrinsicSize.height() * style()->effectiveZoom());
}
// Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is:
// (used width) / (intrinsic ratio)
if (intrinsicRatio && !isPercentageIntrinsicSize) {
// FIXME: Remove unnecessary rounding when layout is off ints: webkit.org/b/63656
return computeReplacedLogicalHeightRespectingMinMaxHeight(round(availableLogicalWidth() / intrinsicRatio));
}
// Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'.
if (hasIntrinsicHeight) {
if (m_hasIntrinsicSize)
return computeReplacedLogicalHeightRespectingMinMaxHeight(calcAspectRatioLogicalHeight());
return static_cast<LayoutUnit>(intrinsicSize.height() * style()->effectiveZoom());
}
// Otherwise, if 'height' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'height' must be set to the height
// of the largest rectangle that has a 2:1 ratio, has a height not greater than 150px, and has a width not greater than the device width.
return computeReplacedLogicalHeightRespectingMinMaxHeight(cDefaultHeight);
}
示例3: borderAndPaddingBeforeInWritingMode
static inline LayoutUnit borderAndPaddingBeforeInWritingMode(const RenderBox& renderer, WritingMode writingMode)
{
switch (writingMode) {
case TopToBottomWritingMode: return renderer.borderTop() + renderer.paddingTop();
case BottomToTopWritingMode: return renderer.borderBottom() + renderer.paddingBottom();
case LeftToRightWritingMode: return renderer.borderLeft() + renderer.paddingLeft();
case RightToLeftWritingMode: return renderer.borderRight() + renderer.paddingRight();
}
ASSERT_NOT_REACHED();
return renderer.borderAndPaddingBefore();
}
示例4: toRenderBox
void RenderMediaVolumeSliderContainer::layout()
{
RenderBlock::layout();
if (style()->display() == NONE || !nextSibling() || !nextSibling()->isBox())
return;
RenderBox* buttonBox = toRenderBox(nextSibling());
int absoluteOffsetTop = buttonBox->localToAbsolute(FloatPoint(0, -size().height())).y();
LayoutStateDisabler layoutStateDisabler(view());
// If the slider would be rendered outside the page, it should be moved below the controls.
if (UNLIKELY(absoluteOffsetTop < 0))
setY(buttonBox->offsetTop() + theme()->volumeSliderOffsetFromMuteButton(buttonBox, pixelSnappedSize()).y());
}
示例5:
std::unique_ptr<FloatingObject> FloatingObject::create(RenderBox& renderer)
{
auto object = std::make_unique<FloatingObject>(renderer);
object->setShouldPaint(!renderer.hasSelfPaintingLayer()); // If a layer exists, the float will paint itself. Otherwise someone else will.
object->setIsDescendant(true);
return object;
}
示例6: lowestPosition
int RenderView::docHeight() const
{
int h = lowestPosition();
// FIXME: This doesn't do any margin collapsing.
// Instead of this dh computation we should keep the result
// when we call RenderBlock::layout.
int dh = 0;
for (RenderBox* c = firstChildBox(); c; c = c->nextSiblingBox())
dh += c->height() + c->marginTop() + c->marginBottom();
if (dh > h)
h = dh;
return h;
}
示例7: resolveContentBasedTrackSizingFunctionsForItems
void RenderGrid::resolveContentBasedTrackSizingFunctionsForItems(TrackSizingDirection direction, Vector<GridTrack>& columnTracks, Vector<GridTrack>& rowTracks, size_t i, SizingFunction sizingFunction, AccumulatorGetter trackGetter, AccumulatorGrowFunction trackGrowthFunction)
{
GridTrack& track = (direction == ForColumns) ? columnTracks[i] : rowTracks[i];
for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
size_t cellIndex = resolveGridPosition(direction, child);
if (cellIndex != i)
continue;
LayoutUnit contentSize = (this->*sizingFunction)(child, direction, columnTracks);
LayoutUnit additionalBreadthSpace = contentSize - (track.*trackGetter)();
Vector<GridTrack*> tracks;
tracks.append(&track);
// FIXME: We should pass different values for |tracksForGrowthAboveMaxBreadth|.
distributeSpaceToTracks(tracks, &tracks, trackGetter, trackGrowthFunction, additionalBreadthSpace);
}
}
示例8: updateControlStatesForRenderer
void RenderTheme::updateControlStatesForRenderer(const RenderBox& box, ControlStates& controlStates) const
{
ControlStates newStates = extractControlStatesForRenderer(box);
controlStates.setStates(newStates.states());
if (isFocused(box))
controlStates.setTimeSinceControlWasFocused(box.document().page()->focusController().timeSinceFocusWasSet());
}
示例9: adoptPtr
PassOwnPtr<GridSpan> GridResolvedPosition::resolveGridPositionsFromStyle(const RenderStyle& gridContainerStyle, const RenderBox& gridItem, GridTrackSizingDirection direction)
{
GridPosition initialPosition = (direction == ForColumns) ? gridItem.style()->gridColumnStart() : gridItem.style()->gridRowStart();
const GridPositionSide initialPositionSide = (direction == ForColumns) ? ColumnStartSide : RowStartSide;
GridPosition finalPosition = (direction == ForColumns) ? gridItem.style()->gridColumnEnd() : gridItem.style()->gridRowEnd();
const GridPositionSide finalPositionSide = (direction == ForColumns) ? ColumnEndSide : RowEndSide;
// We must handle the placement error handling code here instead of in the StyleAdjuster because we don't want to
// overwrite the specified values.
if (initialPosition.isSpan() && finalPosition.isSpan())
finalPosition.setAutoPosition();
if (initialPosition.isNamedGridArea() && !gridContainerStyle.namedGridArea().contains(initialPosition.namedGridLine()))
initialPosition.setAutoPosition();
if (finalPosition.isNamedGridArea() && !gridContainerStyle.namedGridArea().contains(finalPosition.namedGridLine()))
finalPosition.setAutoPosition();
if (initialPosition.shouldBeResolvedAgainstOppositePosition() && finalPosition.shouldBeResolvedAgainstOppositePosition()) {
if (gridContainerStyle.gridAutoFlow() == AutoFlowNone)
return adoptPtr(new GridSpan(0, 0));
// We can't get our grid positions without running the auto placement algorithm.
return nullptr;
}
if (initialPosition.shouldBeResolvedAgainstOppositePosition()) {
// Infer the position from the final position ('auto / 1' or 'span 2 / 3' case).
GridResolvedPosition finalResolvedPosition = resolveGridPositionFromStyle(gridContainerStyle, finalPosition, finalPositionSide);
return resolveGridPositionAgainstOppositePosition(gridContainerStyle, finalResolvedPosition, initialPosition, initialPositionSide);
}
if (finalPosition.shouldBeResolvedAgainstOppositePosition()) {
// Infer our position from the initial position ('1 / auto' or '3 / span 2' case).
GridResolvedPosition initialResolvedPosition = resolveGridPositionFromStyle(gridContainerStyle, initialPosition, initialPositionSide);
return resolveGridPositionAgainstOppositePosition(gridContainerStyle, initialResolvedPosition, finalPosition, finalPositionSide);
}
GridResolvedPosition resolvedInitialPosition = resolveGridPositionFromStyle(gridContainerStyle, initialPosition, initialPositionSide);
GridResolvedPosition resolvedFinalPosition = resolveGridPositionFromStyle(gridContainerStyle, finalPosition, finalPositionSide);
// If 'grid-after' specifies a line at or before that specified by 'grid-before', it computes to 'span 1'.
if (resolvedFinalPosition < resolvedInitialPosition)
resolvedFinalPosition = resolvedInitialPosition;
return adoptPtr(new GridSpan(resolvedInitialPosition, resolvedFinalPosition));
}
示例10: renderer
bool ContainerNode::getLowerRightCorner(FloatPoint& point) const
{
if (!renderer())
return false;
RenderObject* o = renderer();
if (!o->isInline() || o->isReplaced()) {
RenderBox* box = toRenderBox(o);
point = o->localToAbsolute(LayoutPoint(box->size()), UseTransforms);
return true;
}
// find the last text/image child, to get a position
while (o) {
if (o->lastChild())
o = o->lastChild();
else if (o->previousSibling())
o = o->previousSibling();
else {
RenderObject* prev = 0;
while (!prev) {
o = o->parent();
if (!o)
return false;
prev = o->previousSibling();
}
o = prev;
}
ASSERT(o);
if (o->isText() || o->isReplaced()) {
point = FloatPoint();
if (o->isText()) {
RenderText* text = toRenderText(o);
IntRect linesBox = text->linesBoundingBox();
if (!linesBox.maxX() && !linesBox.maxY())
continue;
point.moveBy(linesBox.maxXMaxYCorner());
} else {
RenderBox* box = toRenderBox(o);
point.moveBy(box->frameRect().maxXMaxYCorner());
}
point = o->container()->localToAbsolute(point, UseTransforms);
return true;
}
}
return true;
}
示例11: isEnabledFor
bool ShapeOutsideInfo::isEnabledFor(const RenderBox& box)
{
ShapeValue* shapeValue = box.style()->shapeOutside();
if (!box.isFloating() || !shapeValue)
return false;
switch (shapeValue->type()) {
case ShapeValue::Shape:
return shapeValue->shape();
case ShapeValue::Image:
return shapeValue->isImageValid() && checkShapeImageOrigin(box.document(), *(shapeValue->image()));
case ShapeValue::Box:
return true;
}
return false;
}
示例12: paintButtonDecorations
void RenderThemeSymbian::paintButtonDecorations(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
{
RenderBox* b = static_cast<RenderBox*>(o);
int my = max(r.y(), i.rect.y());
int mh;
if (r.y() < i.rect.y())
mh = max(0, r.height() - (i.rect.y() - r.y()));
else
mh = std::min(i.rect.height(), r.height());
if (o->style()->hasBackground()) {
b->paintBackgroundExtended(i.context, o->style()->backgroundColor(), o->style()->backgroundLayers(), my, mh, r.x(), r.y(), r.width(), r.height());
}
if (o->style()->hasBorder()) {
b->paintBorder(i.context, r.x(), r.y(), r.width(), r.height(), o->style());
}
}
示例13: width
void RenderFieldset::paintMask(PaintInfo& paintInfo, int tx, int ty)
{
if (style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
return;
int w = width();
int h = height();
RenderBox* legend = findLegend();
if (!legend)
return RenderBlock::paintMask(paintInfo, tx, ty);
int yOff = (legend->y() > 0) ? 0 : (legend->height() - borderTop()) / 2;
h -= yOff;
ty += yOff;
paintMaskImages(paintInfo, tx, ty, w, h);
}
示例14: isElementLargeEnoughForMainContent
static bool isElementLargeEnoughForMainContent(const HTMLMediaElement& element)
{
static const double elementMainContentAreaMinimum = 400 * 300;
static const double maximumAspectRatio = 1.8; // Slightly larger than 16:9.
static const double minimumAspectRatio = .5; // Slightly smaller than 16:9.
// Elements which have not yet been laid out, or which are not yet in the DOM, cannot be main content.
RenderBox* renderer = downcast<RenderBox>(element.renderer());
if (!renderer)
return false;
double width = renderer->clientWidth();
double height = renderer->clientHeight();
double area = width * height;
double aspectRatio = width / height;
return area >= elementMainContentAreaMinimum && aspectRatio >= minimumAspectRatio && aspectRatio <= maximumAspectRatio;
}
示例15: LOGWEBGL
bool GraphicsContext3DInternal::lockFrontBuffer(T& image, SkRect& rect)
{
LOGWEBGL("GraphicsContext3DInternal::lockFrontBuffer()");
MutexLocker lock(m_fboMutex);
FBO* fbo = m_frontFBO;
if (!fbo || !fbo->image()) {
LOGWEBGL("-GraphicsContext3DInternal::lockFrontBuffer(), fbo = %p", fbo);
return false;
}
fbo->setLocked(true);
image = (T)(fbo->image());
RenderObject* renderer = m_canvas->renderer();
if (renderer && renderer->isBox()) {
RenderBox* box = (RenderBox*)renderer;
rect.setXYWH(box->borderLeft() + box->paddingLeft(),
box->borderTop() + box->paddingTop(),
box->contentWidth(),
box->contentHeight());
}
return true;
}