本文整理汇总了C++中RenderObject::contentWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderObject::contentWidth方法的具体用法?C++ RenderObject::contentWidth怎么用?C++ RenderObject::contentWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderObject
的用法示例。
在下文中一共展示了RenderObject::contentWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: positionForCoordinates
VisiblePosition RenderContainer::positionForCoordinates(int _x, int _y)
{
// no children...return this render object's element, if there is one, and offset 0
if (!firstChild())
return VisiblePosition(element(), 0, DOWNSTREAM);
// look for the geometrically-closest child and pass off to that child
int min = INT_MAX;
RenderObject *closestRenderer = 0;
for (RenderObject *renderer = firstChild(); renderer; renderer = renderer->nextSibling()) {
if (!renderer->firstChild() && !renderer->isInline() && !renderer->isBlockFlow())
continue;
int absx, absy;
renderer->absolutePosition(absx, absy);
int top = absy + borderTop() + paddingTop();
int bottom = top + renderer->contentHeight();
int left = absx + borderLeft() + paddingLeft();
int right = left + renderer->contentWidth();
int cmp;
cmp = abs(_y - top); if (cmp < min) { closestRenderer = renderer; min = cmp; }
cmp = abs(_y - bottom); if (cmp < min) { closestRenderer = renderer; min = cmp; }
cmp = abs(_x - left); if (cmp < min) { closestRenderer = renderer; min = cmp; }
cmp = abs(_x - right); if (cmp < min) { closestRenderer = renderer; min = cmp; }
}
if (closestRenderer)
return closestRenderer->positionForCoordinates(_x, _y);
return VisiblePosition(element(), 0, DOWNSTREAM);
}
示例2: CSSPrimitiveValueImpl
CSSValueImpl *CSSComputedStyleDeclarationImpl::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const
{
NodeImpl *node = m_node.handle();
if (!node)
return 0;
// Make sure our layout is up to date before we allow a query on these attributes.
DocumentImpl* docimpl = node->getDocument();
if (docimpl && updateLayout)
docimpl->updateLayout();
RenderObject *renderer = node->renderer();
if (!renderer)
return 0;
RenderStyle *style = renderer->style();
if (!style)
return 0;
switch (propertyID)
{
case CSS_PROP_BACKGROUND_COLOR:
return new CSSPrimitiveValueImpl(style->backgroundColor().rgb());
case CSS_PROP_BACKGROUND_IMAGE:
if (style->backgroundImage())
return new CSSPrimitiveValueImpl(style->backgroundImage()->url(), CSSPrimitiveValue::CSS_URI);
return new CSSPrimitiveValueImpl(CSS_VAL_NONE);
case CSS_PROP_BACKGROUND_REPEAT:
switch (style->backgroundRepeat()) {
case khtml::REPEAT:
return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT);
case khtml::REPEAT_X:
return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT_X);
case khtml::REPEAT_Y:
return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT_Y);
case khtml::NO_REPEAT:
return new CSSPrimitiveValueImpl(CSS_VAL_NO_REPEAT);
}
ASSERT_NOT_REACHED();
return 0;
case CSS_PROP_BACKGROUND_ATTACHMENT:
if (style->backgroundAttachment())
return new CSSPrimitiveValueImpl(CSS_VAL_SCROLL);
else
return new CSSPrimitiveValueImpl(CSS_VAL_FIXED);
case CSS_PROP_BACKGROUND_POSITION:
{
DOMString string;
Length length(style->backgroundXPosition());
if (length.isPercent())
string = numberAsString(length.length()) + "%";
else
string = numberAsString(length.minWidth(renderer->contentWidth()));
string += " ";
length = style->backgroundYPosition();
if (length.isPercent())
string += numberAsString(length.length()) + "%";
else
string += numberAsString(length.minWidth(renderer->contentWidth()));
return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
}
case CSS_PROP_BACKGROUND_POSITION_X:
return valueForLength(style->backgroundXPosition());
case CSS_PROP_BACKGROUND_POSITION_Y:
return valueForLength(style->backgroundYPosition());
#ifndef KHTML_NO_XBL
case CSS_PROP__KHTML_BINDING:
// FIXME: unimplemented
break;
#endif
case CSS_PROP_BORDER_COLLAPSE:
if (style->borderCollapse())
return new CSSPrimitiveValueImpl(CSS_VAL_COLLAPSE);
else
return new CSSPrimitiveValueImpl(CSS_VAL_SEPARATE);
case CSS_PROP_BORDER_SPACING:
{
QString string(numberAsString(style->horizontalBorderSpacing()) +
"px " +
numberAsString(style->verticalBorderSpacing()) +
"px");
return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING);
}
case CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING:
return new CSSPrimitiveValueImpl(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
case CSS_PROP__KHTML_BORDER_VERTICAL_SPACING:
return new CSSPrimitiveValueImpl(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX);
case CSS_PROP_BORDER_TOP_COLOR:
return new CSSPrimitiveValueImpl(style->borderLeftColor().rgb());
case CSS_PROP_BORDER_RIGHT_COLOR:
return new CSSPrimitiveValueImpl(style->borderRightColor().rgb());
case CSS_PROP_BORDER_BOTTOM_COLOR:
return new CSSPrimitiveValueImpl(style->borderBottomColor().rgb());
case CSS_PROP_BORDER_LEFT_COLOR:
return new CSSPrimitiveValueImpl(style->borderLeftColor().rgb());
case CSS_PROP_BORDER_TOP_STYLE:
return valueForBorderStyle(style->borderTopStyle());
case CSS_PROP_BORDER_RIGHT_STYLE:
return valueForBorderStyle(style->borderRightStyle());
case CSS_PROP_BORDER_BOTTOM_STYLE:
return valueForBorderStyle(style->borderBottomStyle());
//.........这里部分代码省略.........
示例3: positionForCoordinates
VisiblePosition RenderContainer::positionForCoordinates(int x, int y)
{
// no children...return this render object's element, if there is one, and offset 0
if (!m_firstChild)
return VisiblePosition(element(), 0, DOWNSTREAM);
if (isTable() && element()) {
int right = contentWidth() + borderRight() + paddingRight() + borderLeft() + paddingLeft();
int bottom = contentHeight() + borderTop() + paddingTop() + borderBottom() + paddingBottom();
if (x < 0 || x > right || y < 0 || y > bottom) {
if (x <= right / 2)
return VisiblePosition(Position(element(), 0));
else
return VisiblePosition(Position(element(), maxDeepOffset(element())));
}
}
// Pass off to the closest child.
int minDist = INT_MAX;
RenderObject* closestRenderer = 0;
int newX = x;
int newY = y;
if (isTableRow()) {
newX += xPos();
newY += yPos();
}
for (RenderObject* renderer = m_firstChild; renderer; renderer = renderer->nextSibling()) {
if (!renderer->firstChild() && !renderer->isInline() && !renderer->isBlockFlow()
|| renderer->style()->visibility() != VISIBLE)
continue;
int top = borderTop() + paddingTop() + (isTableRow() ? 0 : renderer->yPos());
int bottom = top + renderer->contentHeight();
int left = borderLeft() + paddingLeft() + (isTableRow() ? 0 : renderer->xPos());
int right = left + renderer->contentWidth();
if (x <= right && x >= left && y <= top && y >= bottom) {
if (renderer->isTableRow())
return renderer->positionForCoordinates(x + newX - renderer->xPos(), y + newY - renderer->yPos());
return renderer->positionForCoordinates(x - renderer->xPos(), y - renderer->yPos());
}
// Find the distance from (x, y) to the box. Split the space around the box into 8 pieces
// and use a different compare depending on which piece (x, y) is in.
IntPoint cmp;
if (x > right) {
if (y < top)
cmp = IntPoint(right, top);
else if (y > bottom)
cmp = IntPoint(right, bottom);
else
cmp = IntPoint(right, y);
} else if (x < left) {
if (y < top)
cmp = IntPoint(left, top);
else if (y > bottom)
cmp = IntPoint(left, bottom);
else
cmp = IntPoint(left, y);
} else {
if (y < top)
cmp = IntPoint(x, top);
else
cmp = IntPoint(x, bottom);
}
int x1minusx2 = cmp.x() - x;
int y1minusy2 = cmp.y() - y;
int dist = x1minusx2 * x1minusx2 + y1minusy2 * y1minusy2;
if (dist < minDist) {
closestRenderer = renderer;
minDist = dist;
}
}
if (closestRenderer)
return closestRenderer->positionForCoordinates(newX - closestRenderer->xPos(), newY - closestRenderer->yPos());
return VisiblePosition(element(), 0, DOWNSTREAM);
}