本文整理汇总了C++中RenderStyle类的典型用法代码示例。如果您正苦于以下问题:C++ RenderStyle类的具体用法?C++ RenderStyle怎么用?C++ RenderStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getSVGPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const
{
Node* node = m_node.get();
if (!node)
return 0;
// Make sure our layout is up to date before we allow a query on these attributes.
if (updateLayout)
node->document()->updateLayout();
RenderStyle* style = node->computedStyle();
if (!style)
return 0;
const SVGRenderStyle* svgStyle = style->svgStyle();
if (!svgStyle)
return 0;
switch (static_cast<CSSPropertyID>(propertyID)) {
case CSSPropertyClipRule:
return CSSPrimitiveValue::create(svgStyle->clipRule());
case CSSPropertyFloodOpacity:
return CSSPrimitiveValue::create(svgStyle->floodOpacity(), CSSPrimitiveValue::CSS_NUMBER);
case CSSPropertyStopOpacity:
return CSSPrimitiveValue::create(svgStyle->stopOpacity(), CSSPrimitiveValue::CSS_NUMBER);
case CSSPropertyColorInterpolation:
return CSSPrimitiveValue::create(svgStyle->colorInterpolation());
case CSSPropertyColorInterpolationFilters:
return CSSPrimitiveValue::create(svgStyle->colorInterpolationFilters());
case CSSPropertyFillOpacity:
return CSSPrimitiveValue::create(svgStyle->fillOpacity(), CSSPrimitiveValue::CSS_NUMBER);
case CSSPropertyFillRule:
return CSSPrimitiveValue::create(svgStyle->fillRule());
case CSSPropertyColorRendering:
return CSSPrimitiveValue::create(svgStyle->colorRendering());
case CSSPropertyImageRendering:
return CSSPrimitiveValue::create(svgStyle->imageRendering());
case CSSPropertyShapeRendering:
return CSSPrimitiveValue::create(svgStyle->shapeRendering());
case CSSPropertyStrokeLinecap:
return CSSPrimitiveValue::create(svgStyle->capStyle());
case CSSPropertyStrokeLinejoin:
return CSSPrimitiveValue::create(svgStyle->joinStyle());
case CSSPropertyStrokeMiterlimit:
return CSSPrimitiveValue::create(svgStyle->strokeMiterLimit(), CSSPrimitiveValue::CSS_NUMBER);
case CSSPropertyStrokeOpacity:
return CSSPrimitiveValue::create(svgStyle->strokeOpacity(), CSSPrimitiveValue::CSS_NUMBER);
case CSSPropertyAlignmentBaseline:
return CSSPrimitiveValue::create(svgStyle->alignmentBaseline());
case CSSPropertyDominantBaseline:
return CSSPrimitiveValue::create(svgStyle->dominantBaseline());
case CSSPropertyTextAnchor:
return CSSPrimitiveValue::create(svgStyle->textAnchor());
case CSSPropertyWritingMode:
return CSSPrimitiveValue::create(svgStyle->writingMode());
case CSSPropertyClipPath:
if (!svgStyle->clipperResource().isEmpty())
return CSSPrimitiveValue::create(svgStyle->clipperResource(), CSSPrimitiveValue::CSS_URI);
return CSSPrimitiveValue::createIdentifier(CSSValueNone);
case CSSPropertyMask:
if (!svgStyle->maskerResource().isEmpty())
return CSSPrimitiveValue::create(svgStyle->maskerResource(), CSSPrimitiveValue::CSS_URI);
return CSSPrimitiveValue::createIdentifier(CSSValueNone);
case CSSPropertyFilter:
if (!svgStyle->filterResource().isEmpty())
return CSSPrimitiveValue::create(svgStyle->filterResource(), CSSPrimitiveValue::CSS_URI);
return CSSPrimitiveValue::createIdentifier(CSSValueNone);
case CSSPropertyFloodColor:
return CSSPrimitiveValue::createColor(svgStyle->floodColor().rgb());
case CSSPropertyLightingColor:
return CSSPrimitiveValue::createColor(svgStyle->lightingColor().rgb());
case CSSPropertyStopColor:
return CSSPrimitiveValue::createColor(svgStyle->stopColor().rgb());
case CSSPropertyFill:
return svgStyle->fillPaint();
case CSSPropertyKerning:
return SVGLength::toCSSPrimitiveValue(svgStyle->kerning());
case CSSPropertyMarkerEnd:
if (!svgStyle->markerEndResource().isEmpty())
return CSSPrimitiveValue::create(svgStyle->markerEndResource(), CSSPrimitiveValue::CSS_URI);
return CSSPrimitiveValue::createIdentifier(CSSValueNone);
case CSSPropertyMarkerMid:
if (!svgStyle->markerMidResource().isEmpty())
return CSSPrimitiveValue::create(svgStyle->markerMidResource(), CSSPrimitiveValue::CSS_URI);
return CSSPrimitiveValue::createIdentifier(CSSValueNone);
case CSSPropertyMarkerStart:
if (!svgStyle->markerStartResource().isEmpty())
return CSSPrimitiveValue::create(svgStyle->markerStartResource(), CSSPrimitiveValue::CSS_URI);
return CSSPrimitiveValue::createIdentifier(CSSValueNone);
case CSSPropertyStroke:
return svgStyle->strokePaint();
case CSSPropertyStrokeDasharray:
return strokeDashArrayToCSSValueList(svgStyle->strokeDashArray());
case CSSPropertyStrokeDashoffset:
return SVGLength::toCSSPrimitiveValue(svgStyle->strokeDashOffset());
case CSSPropertyStrokeWidth:
return SVGLength::toCSSPrimitiveValue(svgStyle->strokeWidth());
case CSSPropertyBaselineShift: {
switch (svgStyle->baselineShift()) {
case BS_BASELINE:
//.........这里部分代码省略.........
示例2: ASSERT
void RenderObjectChildList::updateBeforeAfterContent(RenderObject* owner, PseudoId type, const RenderObject* styledObject)
{
// Double check that the document did in fact use generated content rules. Otherwise we should not have been called.
ASSERT(owner->document()->styleSheetCollection()->usesBeforeAfterRules());
// In CSS2, before/after pseudo-content cannot nest. Check this first.
if (owner->style()->styleType() == BEFORE || owner->style()->styleType() == AFTER)
return;
if (!s_enableUpdateBeforeAfterContent)
return;
if (!styledObject)
styledObject = owner;
RenderStyle* pseudoElementStyle = styledObject->getCachedPseudoStyle(type);
RenderObject* child;
switch (type) {
case BEFORE:
child = beforePseudoElementRenderer(owner);
break;
case AFTER:
child = afterPseudoElementRenderer(owner);
break;
default:
ASSERT_NOT_REACHED();
return;
}
// Whether or not we currently have generated content attached.
bool oldContentPresent = child;
// Whether or not we now want generated content.
bool newContentWanted = pseudoElementStyle && pseudoElementStyle->display() != NONE;
// For <q><p/></q>, if this object is the inline continuation of the <q>, we only want to generate
// :after content and not :before content.
if (newContentWanted && type == BEFORE && owner->isElementContinuation())
newContentWanted = false;
// Similarly, if we're the beginning of a <q>, and there's an inline continuation for our object,
// then we don't generate the :after content.
if (newContentWanted && type == AFTER && owner->virtualContinuation())
newContentWanted = false;
// If we don't want generated content any longer, or if we have generated content, but it's no longer
// identical to the new content data we want to build render objects for, then we nuke all
// of the old generated content.
if (oldContentPresent && (!newContentWanted || Node::diff(child->style(), pseudoElementStyle, owner->document()) == Node::Detach)) {
// Nuke the child.
if (child->style()->styleType() == type) {
oldContentPresent = false;
child->destroy();
child = (type == BEFORE) ? owner->virtualChildren()->firstChild() : owner->virtualChildren()->lastChild();
}
}
// If we have no pseudo-element style or if the pseudo-element style's display type is NONE, then we
// have no generated content and can now return.
if (!newContentWanted)
return;
if (owner->isRenderInline() && !pseudoElementStyle->isDisplayInlineType() && !pseudoElementStyle->isFloating() &&
!pseudoElementStyle->hasOutOfFlowPosition())
// According to the CSS2 spec (the end of section 12.1), the only allowed
// display values for the pseudo style are NONE and INLINE for inline flows.
// FIXME: CSS2.1 lifted this restriction, but block display types will crash.
// For now we at least relax the restriction to allow all inline types like inline-block
// and inline-table.
pseudoElementStyle->setDisplay(INLINE);
if (oldContentPresent) {
updateBeforeAfterStyle(child, type, pseudoElementStyle);
return; // We've updated the generated content. That's all we needed to do.
}
RenderObject* insertBefore = (type == BEFORE) ? owner->virtualChildren()->firstChild() : 0;
if (insertBefore && insertBefore->isAnonymousBlock() && insertBefore->childrenInline() && !insertBefore->isEmpty()) {
// We are going to add the "before" element. We have to check whether the "insertBefore" element
// is an anonymous block with inline children. If it is, then we should insert the "before" element
// before the first inline child of the anonymous block, otherwise we will end up with the "before"
// element in a different block. We do this only when the anonymous block has children, otherwise
// we end up with the before element in a wrong block.
insertBefore = insertBefore->firstChild();
}
// Nothing goes before the intruded run-in, not even generated content.
if (insertBefore && insertBefore->isRunIn() && owner->isRenderBlock()
&& toRenderBlock(owner)->runInIsPlacedIntoSiblingBlock(insertBefore))
insertBefore = insertBefore->nextSibling();
// Generated content consists of a single container that houses multiple children (specified
// by the content property). This generated content container gets the pseudo-element style set on it.
// For pseudo-elements that are regions, the container is the RenderRegion.
RenderObject* generatedContentContainer = 0;
if (!pseudoElementStyle->regionThread().isEmpty())
generatedContentContainer = ensureBeforeAfterContainer(owner, type, pseudoElementStyle, styledObject->node(), insertBefore);
else {
// Walk our list of generated content and create render objects for each.
for (const ContentData* content = pseudoElementStyle->contentData(); content; content = content->next()) {
//.........这里部分代码省略.........
示例3: adjustInnerStyle
void RenderMenuList::adjustInnerStyle()
{
RenderStyle* innerStyle = m_innerBlock->style();
innerStyle->setFlexGrow(1);
innerStyle->setFlexShrink(1);
// min-width: 0; is needed for correct shrinking.
// FIXME: Remove this line when https://bugs.webkit.org/show_bug.cgi?id=111790 is fixed.
innerStyle->setMinWidth(Length(0, Fixed));
// Use margin:auto instead of align-items:center to get safe centering, i.e.
// when the content overflows, treat it the same as align-items: flex-start.
// But we only do that for the cases where html.css would otherwise use center.
if (style()->alignItems() == AlignCenter) {
innerStyle->setMarginTop(Length());
innerStyle->setMarginBottom(Length());
innerStyle->setAlignSelf(AlignFlexStart);
}
innerStyle->setPaddingLeft(Length(theme()->popupInternalPaddingLeft(style()), Fixed));
innerStyle->setPaddingRight(Length(theme()->popupInternalPaddingRight(style()), Fixed));
innerStyle->setPaddingTop(Length(theme()->popupInternalPaddingTop(style()), Fixed));
innerStyle->setPaddingBottom(Length(theme()->popupInternalPaddingBottom(style()), Fixed));
if (m_optionStyle) {
if ((m_optionStyle->direction() != innerStyle->direction() || m_optionStyle->unicodeBidi() != innerStyle->unicodeBidi()))
m_innerBlock->setNeedsLayoutAndPrefWidthsRecalc();
innerStyle->setTextAlign(style()->isLeftToRightDirection() ? LEFT : RIGHT);
innerStyle->setDirection(m_optionStyle->direction());
innerStyle->setUnicodeBidi(m_optionStyle->unicodeBidi());
}
}
示例4: create
PassRefPtrWillBeRawPtr<AnimatableValue> CSSAnimatableValueFactory::createFromColor(CSSPropertyID property, const RenderStyle& style)
{
Color color = style.colorIncludingFallback(property, false);
Color visitedLinkColor = style.colorIncludingFallback(property, true);
return AnimatableColor::create(color, visitedLinkColor);
}
示例5: ASSERT
void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint&, LayoutUnit, LayoutUnit)
{
ASSERT(paintInfo.shouldPaintWithinRoot(renderer()));
ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
ASSERT(truncation() == cNoTruncation);
if (renderer()->style()->visibility() != VISIBLE)
return;
// Note: We're explicitely not supporting composition & custom underlines and custom highlighters - unlike InlineTextBox.
// If we ever need that for SVG, it's very easy to refactor and reuse the code.
RenderObject* parentRenderer = parent()->renderer();
ASSERT(parentRenderer);
bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection;
bool hasSelection = !parentRenderer->document().printing() && selectionState() != RenderObject::SelectionNone;
if (!hasSelection && paintSelectedTextOnly)
return;
RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
ASSERT(textRenderer);
if (!textShouldBePainted(textRenderer))
return;
RenderStyle* style = parentRenderer->style();
ASSERT(style);
const SVGRenderStyle* svgStyle = style->svgStyle();
ASSERT(svgStyle);
bool hasFill = svgStyle->hasFill();
bool hasVisibleStroke = svgStyle->hasVisibleStroke();
RenderStyle* selectionStyle = style;
if (hasSelection) {
selectionStyle = parentRenderer->getCachedPseudoStyle(SELECTION);
if (selectionStyle) {
const SVGRenderStyle* svgSelectionStyle = selectionStyle->svgStyle();
ASSERT(svgSelectionStyle);
if (!hasFill)
hasFill = svgSelectionStyle->hasFill();
if (!hasVisibleStroke)
hasVisibleStroke = svgSelectionStyle->hasVisibleStroke();
} else
selectionStyle = style;
}
if (textRenderer->frame() && textRenderer->frame()->view() && textRenderer->frame()->view()->paintBehavior() & PaintBehaviorRenderingSVGMask) {
hasFill = true;
hasVisibleStroke = false;
}
AffineTransform fragmentTransform;
unsigned textFragmentsSize = m_textFragments.size();
for (unsigned i = 0; i < textFragmentsSize; ++i) {
SVGTextFragment& fragment = m_textFragments.at(i);
ASSERT(!m_paintingResource);
GraphicsContextStateSaver stateSaver(*paintInfo.context);
fragment.buildFragmentTransform(fragmentTransform);
if (!fragmentTransform.isIdentity())
paintInfo.context->concatCTM(fragmentTransform);
// Spec: All text decorations except line-through should be drawn before the text is filled and stroked; thus, the text is rendered on top of these decorations.
int decorations = style->textDecorationsInEffect();
if (decorations & TextDecorationUnderline)
paintDecoration(paintInfo.context, TextDecorationUnderline, fragment);
if (decorations & TextDecorationOverline)
paintDecoration(paintInfo.context, TextDecorationOverline, fragment);
for (int i = 0; i < 3; i++) {
switch (svgStyle->paintOrderType(i)) {
case PT_FILL:
// Fill text
if (hasFill) {
m_paintingResourceMode = ApplyToFillMode | ApplyToTextMode;
paintText(paintInfo.context, style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
}
break;
case PT_STROKE:
// Stroke text
if (hasVisibleStroke) {
m_paintingResourceMode = ApplyToStrokeMode | ApplyToTextMode;
paintText(paintInfo.context, style, selectionStyle, fragment, hasSelection, paintSelectedTextOnly);
}
break;
case PT_MARKERS:
// Markers don't apply to text
break;
default:
ASSERT_NOT_REACHED();
break;
}
}
// Spec: Line-through should be drawn after the text is filled and stroked; thus, the line-through is rendered on top of the text.
if (decorations & TextDecorationLineThrough)
paintDecoration(paintInfo.context, TextDecorationLineThrough, fragment);
//.........这里部分代码省略.........
示例6: switch
bool CSSPropertyEquality::propertiesEqual(CSSPropertyID prop, const RenderStyle& a, const RenderStyle& b)
{
switch (prop) {
case CSSPropertyBackgroundColor:
return a.backgroundColor().resolve(a.color()) == b.backgroundColor().resolve(b.color())
&& a.visitedLinkBackgroundColor().resolve(a.color()) == b.visitedLinkBackgroundColor().resolve(b.color());
case CSSPropertyBackgroundImage:
return fillLayersEqual<CSSPropertyBackgroundImage>(a.backgroundLayers(), b.backgroundLayers());
case CSSPropertyBackgroundPositionX:
return fillLayersEqual<CSSPropertyBackgroundPositionX>(a.backgroundLayers(), b.backgroundLayers());
case CSSPropertyBackgroundPositionY:
return fillLayersEqual<CSSPropertyBackgroundPositionY>(a.backgroundLayers(), b.backgroundLayers());
case CSSPropertyBackgroundSize:
return fillLayersEqual<CSSPropertyBackgroundSize>(a.backgroundLayers(), b.backgroundLayers());
case CSSPropertyBaselineShift:
return dataEquivalent(a.baselineShiftValue(), b.baselineShiftValue());
case CSSPropertyBorderBottomColor:
return a.borderBottomColor().resolve(a.color()) == b.borderBottomColor().resolve(b.color())
&& a.visitedLinkBorderBottomColor().resolve(a.color()) == b.visitedLinkBorderBottomColor().resolve(b.color());
case CSSPropertyBorderBottomLeftRadius:
return a.borderBottomLeftRadius() == b.borderBottomLeftRadius();
case CSSPropertyBorderBottomRightRadius:
return a.borderBottomRightRadius() == b.borderBottomRightRadius();
case CSSPropertyBorderBottomWidth:
return a.borderBottomWidth() == b.borderBottomWidth();
case CSSPropertyBorderImageOutset:
return a.borderImageOutset() == b.borderImageOutset();
case CSSPropertyBorderImageSlice:
return a.borderImageSlices() == b.borderImageSlices();
case CSSPropertyBorderImageSource:
return dataEquivalent(a.borderImageSource(), b.borderImageSource());
case CSSPropertyBorderImageWidth:
return a.borderImageWidth() == b.borderImageWidth();
case CSSPropertyBorderLeftColor:
return a.borderLeftColor().resolve(a.color()) == b.borderLeftColor().resolve(b.color())
&& a.visitedLinkBorderLeftColor().resolve(a.color()) == b.visitedLinkBorderLeftColor().resolve(b.color());
case CSSPropertyBorderLeftWidth:
return a.borderLeftWidth() == b.borderLeftWidth();
case CSSPropertyBorderRightColor:
return a.borderRightColor().resolve(a.color()) == b.borderRightColor().resolve(b.color())
&& a.visitedLinkBorderRightColor().resolve(a.color()) == b.visitedLinkBorderRightColor().resolve(b.color());
case CSSPropertyBorderRightWidth:
return a.borderRightWidth() == b.borderRightWidth();
case CSSPropertyBorderTopColor:
return a.borderTopColor().resolve(a.color()) == b.borderTopColor().resolve(b.color())
&& a.visitedLinkBorderTopColor().resolve(a.color()) == b.visitedLinkBorderTopColor().resolve(b.color());
case CSSPropertyBorderTopLeftRadius:
return a.borderTopLeftRadius() == b.borderTopLeftRadius();
case CSSPropertyBorderTopRightRadius:
return a.borderTopRightRadius() == b.borderTopRightRadius();
case CSSPropertyBorderTopWidth:
return a.borderTopWidth() == b.borderTopWidth();
case CSSPropertyBottom:
return a.bottom() == b.bottom();
case CSSPropertyBoxShadow:
return dataEquivalent(a.boxShadow(), b.boxShadow());
case CSSPropertyClip:
return a.clip() == b.clip();
case CSSPropertyColor:
return a.color() == b.color() && a.visitedLinkColor() == b.visitedLinkColor();
case CSSPropertyFill: {
const SVGRenderStyle& aSVG = *a.svgStyle();
const SVGRenderStyle& bSVG = *b.svgStyle();
return aSVG.fillPaintType() == bSVG.fillPaintType()
&& (aSVG.fillPaintType() != SVGPaint::SVG_PAINTTYPE_RGBCOLOR || aSVG.fillPaintColor() == bSVG.fillPaintColor())
&& aSVG.visitedLinkFillPaintType() == bSVG.visitedLinkFillPaintType()
&& (aSVG.visitedLinkFillPaintType() != SVGPaint::SVG_PAINTTYPE_RGBCOLOR || aSVG.visitedLinkFillPaintColor() == bSVG.visitedLinkFillPaintColor());
}
case CSSPropertyFillOpacity:
return a.fillOpacity() == b.fillOpacity();
case CSSPropertyFlexBasis:
return a.flexBasis() == b.flexBasis();
case CSSPropertyFlexGrow:
return a.flexGrow() == b.flexGrow();
case CSSPropertyFlexShrink:
return a.flexShrink() == b.flexShrink();
case CSSPropertyFloodColor:
return a.floodColor() == b.floodColor();
case CSSPropertyFloodOpacity:
return a.floodOpacity() == b.floodOpacity();
case CSSPropertyFontSize:
// CSSPropertyFontSize: Must pass a specified size to setFontSize if Text Autosizing is enabled, but a computed size
// if text zoom is enabled (if neither is enabled it's irrelevant as they're probably the same).
// FIXME: Should we introduce an option to pass the computed font size here, allowing consumers to
// enable text zoom rather than Text Autosizing? See http://crbug.com/227545.
return a.specifiedFontSize() == b.specifiedFontSize();
case CSSPropertyFontWeight:
return a.fontWeight() == b.fontWeight();
case CSSPropertyHeight:
return a.height() == b.height();
case CSSPropertyLeft:
return a.left() == b.left();
case CSSPropertyLetterSpacing:
return a.letterSpacing() == b.letterSpacing();
case CSSPropertyLightingColor:
return a.lightingColor() == b.lightingColor();
case CSSPropertyLineHeight:
return a.specifiedLineHeight() == b.specifiedLineHeight();
case CSSPropertyListStyleImage:
return dataEquivalent(a.listStyleImage(), b.listStyleImage());
//.........这里部分代码省略.........
示例7: CGContextGetPathBoundingBox
bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
{
CGContextRef contextRef = context->platformContext();
// Build pattern tile, passing destination object bounding box
FloatRect targetRect;
if (isPaintingText) {
IntRect textBoundary = const_cast<RenderObject*>(object)->absoluteBoundingBoxRect();
targetRect = object->absoluteTransform().inverse().mapRect(textBoundary);
} else
targetRect = CGContextGetPathBoundingBox(contextRef);
m_ownerElement->buildPattern(targetRect);
if (!tile())
return false;
CGSize cellSize = CGSize(tile()->size());
CGFloat alpha = 1; // canvasStyle->opacity(); //which?
context->save();
// Repesct local pattern transformations
CGContextConcatCTM(contextRef, patternTransform());
// Pattern space seems to start in the lower-left, so we flip the Y here.
CGSize phase = CGSizeMake(patternBoundaries().x(), -patternBoundaries().y());
CGContextSetPatternPhase(contextRef, phase);
RenderStyle* style = object->style();
CGContextSetAlpha(contextRef, style->opacity()); // or do I set the alpha above?
ASSERT(!m_pattern);
CGPatternCallbacks callbacks = {0, patternCallback, NULL};
m_pattern = CGPatternCreate(tile(),
CGRectMake(0, 0, cellSize.width, cellSize.height),
CGContextGetCTM(contextRef),
patternBoundaries().width(),
patternBoundaries().height(),
kCGPatternTilingConstantSpacing, // FIXME: should ask CG guys.
true, // has color
&callbacks);
if (!m_patternSpace)
m_patternSpace = CGColorSpaceCreatePattern(0);
if ((type & ApplyToFillTargetType) && style->svgStyle()->hasFill()) {
CGContextSetFillColorSpace(contextRef, m_patternSpace);
CGContextSetFillPattern(contextRef, m_pattern, &alpha);
if (isPaintingText)
context->setTextDrawingMode(cTextFill);
}
if ((type & ApplyToStrokeTargetType) && style->svgStyle()->hasStroke()) {
CGContextSetStrokeColorSpace(contextRef, m_patternSpace);
CGContextSetStrokePattern(contextRef, m_pattern, &alpha);
applyStrokeStyleToContext(contextRef, style, object);
if (isPaintingText)
context->setTextDrawingMode(cTextStroke);
}
return true;
}
示例8: renderer
IntRect EllipsisBox::selectionRect()
{
RenderStyle* style = renderer().style(isFirstLineStyle());
const Font& font = style->font();
return enclosingIntRect(font.selectionRectForText(RenderBlockFlow::constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(logicalLeft(), logicalTop() + root().selectionTopAdjustedForPrecedingBlock()), root().selectionHeightAdjustedForPrecedingBlock()));
}
示例9: registerElementForFlowThreadIfNeeded
static void registerElementForFlowThreadIfNeeded(Element& element, const RenderStyle& style)
{
if (!element.shouldMoveToFlowThread(style))
return;
FlowThreadController& flowThreadController = element.document().renderView()->flowThreadController();
flowThreadController.registerNamedFlowContentElement(element, flowThreadController.ensureRenderFlowThreadWithName(style.flowThread()));
}
示例10: Path
bool RenderSVGResourceClipper::pathOnlyClipping(GraphicsContext* context, const AffineTransform& animatedLocalTransform, const FloatRect& objectBoundingBox)
{
// If the current clip-path gets clipped itself, we have to fallback to masking.
if (!style()->svgStyle()->clipperResource().isEmpty())
return false;
WindRule clipRule = RULE_NONZERO;
Path clipPath = Path();
for (Node* childNode = node()->firstChild(); childNode; childNode = childNode->nextSibling()) {
RenderObject* renderer = childNode->renderer();
if (!renderer)
continue;
// Only shapes or paths are supported for direct clipping. We need to fallback to masking for texts.
if (renderer->isSVGText())
return false;
if (!childNode->isSVGElement() || !toSVGElement(childNode)->isSVGGraphicsElement())
continue;
SVGGraphicsElement* styled = toSVGGraphicsElement(childNode);
RenderStyle* style = renderer->style();
if (!style || style->display() == NONE || style->visibility() != VISIBLE)
continue;
const SVGRenderStyle* svgStyle = style->svgStyle();
// Current shape in clip-path gets clipped too. Fallback to masking.
if (!svgStyle->clipperResource().isEmpty())
return false;
if (clipPath.isEmpty()) {
// First clip shape.
styled->toClipPath(clipPath);
clipRule = svgStyle->clipRule();
clipPath.setWindRule(clipRule);
continue;
}
if (RuntimeEnabledFeatures::pathOpsSVGClippingEnabled()) {
// Attempt to generate a combined clip path, fall back to masking if not possible.
Path subPath;
styled->toClipPath(subPath);
subPath.setWindRule(svgStyle->clipRule());
if (!clipPath.unionPath(subPath))
return false;
} else {
return false;
}
}
// Only one visible shape/path was found. Directly continue clipping and transform the content to userspace if necessary.
if (static_cast<SVGClipPathElement*>(node())->clipPathUnitsCurrentValue() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
AffineTransform transform;
transform.translate(objectBoundingBox.x(), objectBoundingBox.y());
transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
clipPath.transform(transform);
}
// Transform path by animatedLocalTransform.
clipPath.transform(animatedLocalTransform);
// The SVG specification wants us to clip everything, if clip-path doesn't have a child.
if (clipPath.isEmpty())
clipPath.addRect(FloatRect());
context->clipPath(clipPath, clipRule);
return true;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:62,代码来源:RenderSVGResourceClipper.cpp
示例11: ASSERT
bool RenderSVGResourceClipper::drawContentIntoMaskImage(ClipperData* clipperData, const FloatRect& objectBoundingBox)
{
ASSERT(frame());
ASSERT(clipperData);
ASSERT(clipperData->clipMaskImage);
GraphicsContext* maskContext = clipperData->clipMaskImage->context();
ASSERT(maskContext);
AffineTransform maskContentTransformation;
SVGClipPathElement* clipPath = static_cast<SVGClipPathElement*>(node());
if (clipPath->clipPathUnitsCurrentValue() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
maskContentTransformation.translate(objectBoundingBox.x(), objectBoundingBox.y());
maskContentTransformation.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.height());
maskContext->concatCTM(maskContentTransformation);
}
// Switch to a paint behavior where all children of this <clipPath> will be rendered using special constraints:
// - fill-opacity/stroke-opacity/opacity set to 1
// - masker/filter not applied when rendering the children
// - fill is set to the initial fill paint server (solid, black)
// - stroke is set to the initial stroke paint server (none)
PaintBehavior oldBehavior = frame()->view()->paintBehavior();
frame()->view()->setPaintBehavior(oldBehavior | PaintBehaviorRenderingSVGMask);
// Draw all clipPath children into a global mask.
for (Node* childNode = node()->firstChild(); childNode; childNode = childNode->nextSibling()) {
RenderObject* renderer = childNode->renderer();
if (!childNode->isSVGElement() || !renderer)
continue;
if (renderer->needsLayout()) {
frame()->view()->setPaintBehavior(oldBehavior);
return false;
}
RenderStyle* style = renderer->style();
if (!style || style->display() == NONE || style->visibility() != VISIBLE)
continue;
WindRule newClipRule = style->svgStyle()->clipRule();
bool isUseElement = childNode->hasTagName(SVGNames::useTag);
if (isUseElement) {
SVGUseElement* useElement = toSVGUseElement(childNode);
renderer = useElement->rendererClipChild();
if (!renderer)
continue;
if (!useElement->hasAttribute(SVGNames::clip_ruleAttr))
newClipRule = renderer->style()->svgStyle()->clipRule();
}
// Only shapes, paths and texts are allowed for clipping.
if (!renderer->isSVGShape() && !renderer->isSVGText())
continue;
maskContext->setFillRule(newClipRule);
// In the case of a <use> element, we obtained its renderere above, to retrieve its clipRule.
// We have to pass the <use> renderer itself to renderSubtreeToImageBuffer() to apply it's x/y/transform/etc. values when rendering.
// So if isUseElement is true, refetch the childNode->renderer(), as renderer got overriden above.
SVGRenderingContext::renderSubtreeToImageBuffer(clipperData->clipMaskImage.get(), isUseElement ? childNode->renderer() : renderer, maskContentTransformation);
}
frame()->view()->setPaintBehavior(oldBehavior);
return true;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:64,代码来源:RenderSVGResourceClipper.cpp
示例12: isDeletableElement
static bool isDeletableElement(const Node* node)
{
if (!node || !node->isHTMLElement() || !node->inDocument() || !node->rendererIsEditable())
return false;
// In general we want to only draw the UI around object of a certain area, but we still keep the min width/height to
// make sure we don't end up with very thin or very short elements getting the UI.
const int minimumArea = 2500;
const int minimumWidth = 48;
const int minimumHeight = 16;
const unsigned minimumVisibleBorders = 1;
RenderObject* renderer = node->renderer();
if (!renderer || !renderer->isBox())
return false;
// Disallow the body element since it isn't practical to delete, and the deletion UI would be clipped.
if (node->hasTagName(bodyTag))
return false;
// Disallow elements with any overflow clip, since the deletion UI would be clipped as well. <rdar://problem/6840161>
if (renderer->hasOverflowClip())
return false;
// Disallow Mail blockquotes since the deletion UI would get in the way of editing for these.
if (isMailBlockquote(node))
return false;
RenderBox* box = toRenderBox(renderer);
IntRect borderBoundingBox = box->borderBoundingBox();
if (borderBoundingBox.width() < minimumWidth || borderBoundingBox.height() < minimumHeight)
return false;
if ((borderBoundingBox.width() * borderBoundingBox.height()) < minimumArea)
return false;
if (renderer->isTable())
return true;
if (node->hasTagName(ulTag) || node->hasTagName(olTag) || node->hasTagName(iframeTag))
return true;
if (renderer->isOutOfFlowPositioned())
return true;
if (renderer->isRenderBlock() && !renderer->isTableCell()) {
RenderStyle* style = renderer->style();
if (!style)
return false;
// Allow blocks that have background images
if (style->hasBackgroundImage()) {
for (const FillLayer* background = style->backgroundLayers(); background; background = background->next()) {
if (background->image() && background->image()->canRender(renderer, 1))
return true;
}
}
// Allow blocks with a minimum number of non-transparent borders
unsigned visibleBorders = style->borderTop().isVisible() + style->borderBottom().isVisible() + style->borderLeft().isVisible() + style->borderRight().isVisible();
if (visibleBorders >= minimumVisibleBorders)
return true;
// Allow blocks that have a different background from it's parent
ContainerNode* parentNode = node->parentNode();
if (!parentNode)
return false;
RenderObject* parentRenderer = parentNode->renderer();
if (!parentRenderer)
return false;
RenderStyle* parentStyle = parentRenderer->style();
if (!parentStyle)
return false;
if (renderer->hasBackground() && (!parentRenderer->hasBackground() || style->visitedDependentColor(CSSPropertyBackgroundColor) != parentStyle->visitedDependentColor(CSSPropertyBackgroundColor)))
return true;
}
return false;
}
示例13: paint
void EllipsisBox::paint(PaintInfo& paintInfo, int tx, int ty)
{
GraphicsContext* context = paintInfo.context;
RenderStyle* style = m_renderer->style(m_firstLine);
Color textColor = style->visitedDependentColor(CSSPropertyColor);
if (textColor != context->fillColor())
context->setFillColor(textColor, style->colorSpace());
bool setShadow = false;
if (style->textShadow()) {
context->setShadow(IntSize(style->textShadow()->x(), style->textShadow()->y()),
style->textShadow()->blur(), style->textShadow()->color(), style->colorSpace());
setShadow = true;
}
if (selectionState() != RenderObject::SelectionNone) {
paintSelection(context, tx, ty, style, style->font());
// Select the correct color for painting the text.
Color foreground = paintInfo.forceBlackText ? Color::black : renderer()->selectionForegroundColor();
if (foreground.isValid() && foreground != textColor)
context->setFillColor(foreground, style->colorSpace());
}
const String& str = m_str;
context->drawText(style->font(), TextRun(str.characters(), str.length(), false, 0, 0, false, style->visuallyOrdered()), IntPoint(m_x + tx, m_y + ty + style->font().ascent()));
// Restore the regular fill color.
if (textColor != context->fillColor())
context->setFillColor(textColor, style->colorSpace());
if (setShadow)
context->clearShadow();
if (m_markupBox) {
// Paint the markup box
tx += m_x + m_width - m_markupBox->x();
ty += m_y + style->font().ascent() - (m_markupBox->y() + m_markupBox->renderer()->style(m_firstLine)->font().ascent());
m_markupBox->paint(paintInfo, tx, ty);
}
}
示例14: ariaRoleAttribute
bool AccessibilityTable::isTableExposableThroughAccessibility()
{
// the following is a heuristic used to determine if a
// <table> should be exposed as an AXTable. The goal
// is to only show "data" tables
if (!m_renderer || !m_renderer->isTable())
return false;
// if the developer assigned an aria role to this, then we shouldn't
// expose it as a table, unless, of course, the aria role is a table
AccessibilityRole ariaRole = ariaRoleAttribute();
if (ariaRole == TableRole)
return true;
if (ariaRole != UnknownRole)
return false;
RenderTable* table = static_cast<RenderTable*>(m_renderer);
// this employs a heuristic to determine if this table should appear.
// Only "data" tables should be exposed as tables.
// Unfortunately, there is no good way to determine the difference
// between a "layout" table and a "data" table
Node* tableNode = table->element();
if (!tableNode || !tableNode->hasTagName(tableTag))
return false;
// if there is a caption element, summary, THEAD, or TFOOT section, it's most certainly a data table
HTMLTableElement* tableElement = static_cast<HTMLTableElement*>(tableNode);
if (!tableElement->summary().isEmpty() || tableElement->tHead() || tableElement->tFoot() || tableElement->caption())
return true;
// if someone used "rules" attribute than the table should appear
if (!tableElement->rules().isEmpty())
return true;
// go through the cell's and check for tell-tale signs of "data" table status
// cells have borders, or use attributes like headers, abbr, scope or axis
RenderTableSection* firstBody = table->firstBody();
if (!firstBody)
return false;
int numCols = firstBody->numColumns();
int numRows = firstBody->numRows();
// if there's only one cell, it's not a good AXTable candidate
if (numRows == 1 && numCols == 1)
return false;
// store the background color of the table to check against cell's background colors
RenderStyle* tableStyle = table->style();
if (!tableStyle)
return false;
Color tableBGColor = tableStyle->backgroundColor();
// check enough of the cells to find if the table matches our criteria
// Criteria:
// 1) must have at least one valid cell (and)
// 2) at least half of cells have borders (or)
// 3) at least half of cells have different bg colors than the table, and there is cell spacing
unsigned validCellCount = 0;
unsigned borderedCellCount = 0;
unsigned backgroundDifferenceCellCount = 0;
for (int row = 0; row < numRows; ++row) {
for (int col = 0; col < numCols; ++col) {
RenderTableCell* cell = firstBody->cellAt(row, col).cell;
if (!cell)
continue;
Node* cellNode = cell->element();
if (!cellNode)
continue;
if (cell->width() < 1 || cell->height() < 1)
continue;
validCellCount++;
HTMLTableCellElement* cellElement = static_cast<HTMLTableCellElement*>(cellNode);
// in this case, the developer explicitly assigned a "data" table attribute
if (!cellElement->headers().isEmpty() || !cellElement->abbr().isEmpty() ||
!cellElement->axis().isEmpty() || !cellElement->scope().isEmpty())
return true;
RenderStyle* renderStyle = cell->style();
if (!renderStyle)
continue;
// a cell needs to have matching bordered sides, before it can be considered a bordered cell.
if ((cell->borderTop() > 0 && cell->borderBottom() > 0) ||
(cell->borderLeft() > 0 && cell->borderRight() > 0))
borderedCellCount++;
// if the cell has a different color from the table and there is cell spacing,
// then it is probably a data table cell (spacing and colors take the place of borders)
Color cellColor = renderStyle->backgroundColor();
if (table->hBorderSpacing() > 0 && table->vBorderSpacing() > 0 &&
tableBGColor != cellColor && cellColor.alpha() != 1)
//.........这里部分代码省略.........
示例15: adjustInnerStyle
void RenderMenuList::adjustInnerStyle()
{
RenderStyle* innerStyle = m_innerBlock->style();
innerStyle->setFlexGrow(1);
innerStyle->setFlexShrink(1);
// min-width: 0; is needed for correct shrinking.
// FIXME: Remove this line when https://bugs.webkit.org/show_bug.cgi?id=111790 is fixed.
innerStyle->setMinWidth(Length(0, Fixed));
// Use margin:auto instead of align-items:center to get safe centering, i.e.
// when the content overflows, treat it the same as align-items: flex-start.
// But we only do that for the cases where html.css would otherwise use center.
if (style()->alignItems() == AlignCenter) {
innerStyle->setMarginTop(Length());
innerStyle->setMarginBottom(Length());
innerStyle->setAlignSelf(AlignFlexStart);
}
innerStyle->setPaddingLeft(Length(theme()->popupInternalPaddingLeft(style()), Fixed));
innerStyle->setPaddingRight(Length(theme()->popupInternalPaddingRight(style()), Fixed));
innerStyle->setPaddingTop(Length(theme()->popupInternalPaddingTop(style()), Fixed));
innerStyle->setPaddingBottom(Length(theme()->popupInternalPaddingBottom(style()), Fixed));
if (document().page()->chrome().selectItemWritingDirectionIsNatural()) {
// Items in the popup will not respect the CSS text-align and direction properties,
// so we must adjust our own style to match.
innerStyle->setTextAlign(LEFT);
TextDirection direction = (m_buttonText && m_buttonText->text()->defaultWritingDirection() == WTF::Unicode::RightToLeft) ? RTL : LTR;
innerStyle->setDirection(direction);
} else if (m_optionStyle && document().page()->chrome().selectItemAlignmentFollowsMenuWritingDirection()) {
if ((m_optionStyle->direction() != innerStyle->direction() || m_optionStyle->unicodeBidi() != innerStyle->unicodeBidi()))
m_innerBlock->setNeedsLayoutAndPrefWidthsRecalc();
innerStyle->setTextAlign(style()->isLeftToRightDirection() ? LEFT : RIGHT);
innerStyle->setDirection(m_optionStyle->direction());
innerStyle->setUnicodeBidi(m_optionStyle->unicodeBidi());
}
}