本文整理汇总了C++中RenderStyle::colorSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ RenderStyle::colorSpace方法的具体用法?C++ RenderStyle::colorSpace怎么用?C++ RenderStyle::colorSpace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderStyle
的用法示例。
在下文中一共展示了RenderStyle::colorSpace方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintMediaVolumeSliderTrack
bool RenderThemeGtk::paintMediaVolumeSliderTrack(RenderObject* renderObject, const PaintInfo& paintInfo, const IntRect& rect)
{
HTMLMediaElement* mediaElement = toParentMediaElement(renderObject);
if (!mediaElement)
return true;
float volume = mediaElement->volume();
if (!volume)
return true;
GraphicsContext* context = paintInfo.context;
context->save();
context->setStrokeStyle(NoStroke);
int rectHeight = rect.height();
float trackHeight = rectHeight * volume;
RenderStyle* style = renderObject->style();
IntRect volumeRect(rect);
volumeRect.move(0, rectHeight - trackHeight);
volumeRect.setHeight(ceil(trackHeight));
context->fillRoundedRect(RoundedRect(volumeRect, borderRadiiFromStyle(style)),
style->visitedDependentColor(CSSPropertyColor), style->colorSpace());
context->restore();
return false;
}
示例2: paintMeter
bool RenderTheme::paintMeter(RenderObject* renderObject, const RenderObject::PaintInfo& paintInfo, const IntRect& rect)
{
// Some platforms do not have a native gauge widget, so we draw here a default implementation.
RenderMeter* renderMeter = toRenderMeter(renderObject);
RenderStyle* style = renderObject->style();
int left = style->borderLeft().width() + style->paddingLeft().value();
int top = style->borderTop().width() + style->paddingTop().value();
int right = style->borderRight().width() + style->paddingRight().value();
int bottom = style->borderBottom().width() + style->paddingBottom().value();
FloatRect innerRect(rect.x() + left, rect.y() + top, rect.width() - left - right, rect.height() - top - bottom);
HTMLMeterElement* element = static_cast<HTMLMeterElement*>(renderMeter->node());
double min = element->min();
double max = element->max();
double value = element->value();
if (min >= max) {
paintInfo.context->fillRect(innerRect, Color::black, style->colorSpace());
return false;
}
// Paint the background first
paintInfo.context->fillRect(innerRect, Color::lightGray, style->colorSpace());
FloatRect valueRect;
if (rect.width() < rect.height()) {
// Vertical gauge
double scale = innerRect.height() / (max - min);
valueRect.setLocation(FloatPoint(innerRect.x(), innerRect.y() + narrowPrecisionToFloat((max - value) * scale)));
valueRect.setSize(FloatSize(innerRect.width(), narrowPrecisionToFloat((value - min) * scale)));
} else if (renderMeter->style()->direction() == RTL) {
// right to left horizontal gauge
double scale = innerRect.width() / (max - min);
valueRect.setLocation(FloatPoint(innerRect.x() + narrowPrecisionToFloat((max - value) * scale), innerRect.y()));
valueRect.setSize(FloatSize(narrowPrecisionToFloat((value - min) * scale), innerRect.height()));
} else {
// left to right horizontal gauge
double scale = innerRect.width() / (max - min);
valueRect.setLocation(innerRect.location());
valueRect.setSize(FloatSize(narrowPrecisionToFloat((value - min)) * scale, innerRect.height()));
}
if (!valueRect.isEmpty())
paintInfo.context->fillRect(valueRect, Color::black, style->colorSpace());
return false;
}
示例3: paintItemForeground
void RenderListBox::paintItemForeground(PaintInfo& paintInfo, int tx, int ty, int listIndex)
{
SelectElement* select = toSelectElement(static_cast<Element*>(node()));
const Vector<Element*>& listItems = select->listItems();
Element* element = listItems[listIndex];
OptionElement* optionElement = toOptionElement(element);
String itemText;
if (optionElement)
itemText = optionElement->textIndentedToRespectGroupLabel();
else if (OptionGroupElement* optionGroupElement = toOptionGroupElement(element))
itemText = optionGroupElement->groupLabelText();
// Determine where the item text should be placed
IntRect r = itemBoundingBoxRect(tx, ty, listIndex);
r.move(optionsSpacingHorizontal, style()->font().ascent());
RenderStyle* itemStyle = element->renderStyle();
if (!itemStyle)
itemStyle = style();
Color textColor = element->renderStyle() ? element->renderStyle()->color() : style()->color();
if (optionElement && optionElement->selected()) {
if (document()->frame()->selection()->isFocusedAndActive() && document()->focusedNode() == node())
textColor = theme()->activeListBoxSelectionForegroundColor();
// Honor the foreground color for disabled items
else if (!element->disabled())
textColor = theme()->inactiveListBoxSelectionForegroundColor();
}
ColorSpace colorSpace = itemStyle->colorSpace();
paintInfo.context->setFillColor(textColor, colorSpace);
Font itemFont = style()->font();
if (isOptionGroupElement(element)) {
FontDescription d = itemFont.fontDescription();
d.setWeight(d.bolderWeight());
itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
itemFont.update(document()->styleSelector()->fontSelector());
}
unsigned length = itemText.length();
const UChar* string = itemText.characters();
TextRun textRun(string, length, 0, 0, 0, itemStyle->direction() == RTL, itemStyle->unicodeBidi() == Override, false, false);
// Draw the item text
if (itemStyle->visibility() != HIDDEN)
paintInfo.context->drawBidiText(itemFont, textRun, r.location());
}
示例4: computeTextPaintStyle
TextPaintStyle computeTextPaintStyle(const RenderText& renderer, const RenderStyle& lineStyle, const PaintInfo& paintInfo)
{
TextPaintStyle paintStyle(lineStyle.colorSpace());
paintStyle.strokeWidth = lineStyle.textStrokeWidth();
if (paintInfo.forceBlackText()) {
paintStyle.fillColor = Color::black;
paintStyle.strokeColor = Color::black;
paintStyle.emphasisMarkColor = Color::black;
return paintStyle;
}
paintStyle.fillColor = lineStyle.visitedDependentColor(CSSPropertyWebkitTextFillColor);
bool forceBackgroundToWhite = false;
if (renderer.document().printing()) {
if (lineStyle.printColorAdjust() == PrintColorAdjustEconomy)
forceBackgroundToWhite = true;
if (renderer.frame().settings().shouldPrintBackgrounds())
forceBackgroundToWhite = false;
}
// Make the text fill color legible against a white background
if (forceBackgroundToWhite)
paintStyle.fillColor = adjustColorForVisibilityOnBackground(paintStyle.fillColor, Color::white);
paintStyle.strokeColor = lineStyle.visitedDependentColor(CSSPropertyWebkitTextStrokeColor);
// Make the text stroke color legible against a white background
if (forceBackgroundToWhite)
paintStyle.strokeColor = adjustColorForVisibilityOnBackground(paintStyle.strokeColor, Color::white);
paintStyle.emphasisMarkColor = lineStyle.visitedDependentColor(CSSPropertyWebkitTextEmphasisColor);
// Make the text stroke color legible against a white background
if (forceBackgroundToWhite)
paintStyle.emphasisMarkColor = adjustColorForVisibilityOnBackground(paintStyle.emphasisMarkColor, Color::white);
return paintStyle;
}
示例5: paint
void NinePieceImage::paint(GraphicsContext* graphicsContext, RenderElement* renderer, const RenderStyle& style, const LayoutRect& destination, const LayoutSize& source, bool intrinsicSource, float deviceScaleFactor, CompositeOperator op) const
{
StyleImage* styleImage = image();
ASSERT(styleImage && styleImage->isLoaded());
LayoutBoxExtent sourceSlices = computeSlices(source, imageSlices(), styleImage->imageScaleFactor());
LayoutBoxExtent destinationSlices = computeSlices(destination.size(), borderSlices(), style.borderWidth(), sourceSlices);
scaleSlicesIfNeeded(destination.size(), destinationSlices, deviceScaleFactor);
Vector<FloatRect> destinationRects = computeIntrinsicRects(destination, destinationSlices, deviceScaleFactor);
Vector<FloatRect> sourceRects;
Vector<FloatSize> tileScales;
if (intrinsicSource) {
sourceRects = computeIntrinsicRects(FloatRect(FloatPoint(), source), sourceSlices, deviceScaleFactor);
tileScales = computeIntrinsicTileScales(destinationRects, sourceRects, horizontalRule(), verticalRule());
} else {
sourceRects = computeNonIntrinsicRects(destinationRects, sourceSlices);
tileScales = computeNonIntrinsicTileScales();
}
RefPtr<Image> image = styleImage->image(renderer, source);
ColorSpace colorSpace = style.colorSpace();
for (ImagePiece piece = MinPiece; piece < MaxPiece; ++piece) {
if ((piece == MiddlePiece && !fill()) || isEmptyPieceRect(piece, destinationRects, sourceRects))
continue;
if (isCornerPiece(piece)) {
graphicsContext->drawImage(image.get(), colorSpace, destinationRects[piece], sourceRects[piece], op);
continue;
}
Image::TileRule hRule = isHorizontalPiece(piece) ? static_cast<Image::TileRule>(horizontalRule()) : Image::StretchTile;
Image::TileRule vRule = isVerticalPiece(piece) ? static_cast<Image::TileRule>(verticalRule()) : Image::StretchTile;
graphicsContext->drawTiledImage(image.get(), colorSpace, destinationRects[piece], sourceRects[piece], tileScales[piece], hRule, vRule, op);
}
}
示例6: prepareToRenderSVGContent
bool SVGRenderBase::prepareToRenderSVGContent(RenderObject* object, RenderObject::PaintInfo& paintInfo, const FloatRect& repaintRect, RenderSVGResourceFilter*& filter, RenderSVGResourceFilter* rootFilter)
{
#if !ENABLE(FILTERS)
UNUSED_PARAM(filter);
UNUSED_PARAM(rootFilter);
#endif
ASSERT(object);
SVGElement* svgElement = static_cast<SVGElement*>(object->node());
ASSERT(svgElement && svgElement->document() && svgElement->isStyled());
SVGStyledElement* styledElement = static_cast<SVGStyledElement*>(svgElement);
RenderStyle* style = object->style();
ASSERT(style);
const SVGRenderStyle* svgStyle = style->svgStyle();
ASSERT(svgStyle);
// Setup transparency layers before setting up filters!
float opacity = style->opacity();
if (opacity < 1.0f) {
paintInfo.context->clip(repaintRect);
paintInfo.context->beginTransparencyLayer(opacity);
}
if (const ShadowData* shadow = svgStyle->shadow()) {
paintInfo.context->clip(repaintRect);
paintInfo.context->setShadow(IntSize(shadow->x(), shadow->y()), shadow->blur(), shadow->color(), style->colorSpace());
paintInfo.context->beginTransparencyLayer(1.0f);
}
#if ENABLE(FILTERS)
AtomicString filterId(svgStyle->filterResource());
#endif
AtomicString clipperId(svgStyle->clipperResource());
AtomicString maskerId(svgStyle->maskerResource());
Document* document = object->document();
#if ENABLE(FILTERS)
RenderSVGResourceFilter* newFilter = getRenderSVGResourceById<RenderSVGResourceFilter>(document, filterId);
if (newFilter == rootFilter) {
// Catch <text filter="url(#foo)">Test<tspan filter="url(#foo)">123</tspan></text>.
// The filter is NOT meant to be applied twice in that case!
filter = 0;
filterId = String();
} else
filter = newFilter;
#endif
if (RenderSVGResourceMasker* masker = getRenderSVGResourceById<RenderSVGResourceMasker>(document, maskerId)) {
if (!masker->applyResource(object, style, paintInfo.context, ApplyToDefaultMode))
return false;
} else if (!maskerId.isEmpty())
svgElement->document()->accessSVGExtensions()->addPendingResource(maskerId, styledElement);
if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById<RenderSVGResourceClipper>(document, clipperId))
clipper->applyResource(object, style, paintInfo.context, ApplyToDefaultMode);
else if (!clipperId.isEmpty())
svgElement->document()->accessSVGExtensions()->addPendingResource(clipperId, styledElement);
#if ENABLE(FILTERS)
if (filter) {
if (!filter->applyResource(object, style, paintInfo.context, ApplyToDefaultMode))
return false;
} else if (!filterId.isEmpty())
svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement);
#endif
return true;
}
示例7: paintSelectionBackground
void SVGInlineTextBox::paintSelectionBackground(PaintInfo& paintInfo)
{
ASSERT(paintInfo.shouldPaintWithinRoot(renderer()));
ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
ASSERT(truncation() == cNoTruncation);
if (renderer()->style()->visibility() != VISIBLE)
return;
RenderObject* parentRenderer = parent()->renderer();
ASSERT(parentRenderer);
ASSERT(!parentRenderer->document()->printing());
// Determine whether or not we're selected.
bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection;
bool hasSelection = selectionState() != RenderObject::SelectionNone;
if (!hasSelection || paintSelectedTextOnly)
return;
Color backgroundColor = renderer()->selectionBackgroundColor();
if (!backgroundColor.isValid() || !backgroundColor.alpha())
return;
RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
ASSERT(textRenderer);
if (!textShouldBePainted(textRenderer))
return;
RenderStyle* style = parentRenderer->style();
ASSERT(style);
RenderStyle* selectionStyle = style;
if (hasSelection) {
selectionStyle = parentRenderer->getCachedPseudoStyle(SELECTION);
if (!selectionStyle)
selectionStyle = style;
}
int startPosition, endPosition;
selectionStartEnd(startPosition, endPosition);
int fragmentStartPosition = 0;
int fragmentEndPosition = 0;
AffineTransform fragmentTransform;
unsigned textFragmentsSize = m_textFragments.size();
for (unsigned i = 0; i < textFragmentsSize; ++i) {
SVGTextFragment& fragment = m_textFragments.at(i);
ASSERT(!m_paintingResource);
fragmentStartPosition = startPosition;
fragmentEndPosition = endPosition;
if (!mapStartEndPositionsIntoFragmentCoordinates(fragment, fragmentStartPosition, fragmentEndPosition))
continue;
GraphicsContextStateSaver stateSaver(*paintInfo.context);
fragment.buildFragmentTransform(fragmentTransform);
if (!fragmentTransform.isIdentity())
paintInfo.context->concatCTM(fragmentTransform);
paintInfo.context->setFillColor(backgroundColor, style->colorSpace());
paintInfo.context->fillRect(selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, style), backgroundColor, style->colorSpace());
m_paintingResourceMode = ApplyToDefaultMode;
}
ASSERT(!m_paintingResource);
}
示例8: paintMediaSliderThumb
bool RenderThemeGtk::paintMediaSliderThumb(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
RenderStyle* style = o->style();
paintInfo.context->fillRoundedRect(RoundedRect(r, borderRadiiFromStyle(style)), style->visitedDependentColor(CSSPropertyColor), style->colorSpace());
return false;
}
示例9: paintMediaSliderTrack
bool RenderThemeGtk::paintMediaSliderTrack(RenderObject* o, const PaintInfo& paintInfo, const IntRect& r)
{
HTMLMediaElement* mediaElement = toParentMediaElement(o);
if (!mediaElement)
return false;
GraphicsContext* context = paintInfo.context;
context->save();
context->setStrokeStyle(NoStroke);
float mediaDuration = mediaElement->duration();
float totalTrackWidth = r.width();
RenderStyle* style = o->style();
RefPtr<TimeRanges> timeRanges = mediaElement->buffered();
for (unsigned index = 0; index < timeRanges->length(); ++index) {
float start = timeRanges->start(index, IGNORE_EXCEPTION);
float end = timeRanges->end(index, IGNORE_EXCEPTION);
float startRatio = start / mediaDuration;
float lengthRatio = (end - start) / mediaDuration;
if (!lengthRatio)
continue;
IntRect rangeRect(r);
rangeRect.setWidth(lengthRatio * totalTrackWidth);
if (index)
rangeRect.move(startRatio * totalTrackWidth, 0);
context->fillRoundedRect(RoundedRect(rangeRect, borderRadiiFromStyle(style)), style->visitedDependentColor(CSSPropertyColor), style->colorSpace());
}
context->restore();
return false;
}
示例10: paintSelection
void EllipsisBox::paintSelection(GraphicsContext& context, const LayoutPoint& paintOffset, const RenderStyle& style, const FontCascade& font)
{
Color textColor = style.visitedDependentColor(CSSPropertyColor);
Color c = blockFlow().selectionBackgroundColor();
if (!c.isValid() || !c.alpha())
return;
// If the text color ends up being the same as the selection background, invert the selection
// background.
if (textColor == c)
c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
const RootInlineBox& rootBox = root();
GraphicsContextStateSaver stateSaver(context);
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
LayoutRect selectionRect = LayoutRect(x() + paintOffset.x(), y() + paintOffset.y() + rootBox.selectionTop(), 0, rootBox.selectionHeight());
TextRun run = RenderBlock::constructTextRun(&blockFlow(), font, m_str, style, AllowTrailingExpansion);
font.adjustSelectionRectForText(run, selectionRect, 0, -1);
context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), run.ltr()), c, style.colorSpace());
}
示例11: paintSelection
void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& paintOffset, const RenderStyle& style, const Font& font)
{
Color textColor = style.visitedDependentColor(CSSPropertyColor);
Color c = blockFlow().selectionBackgroundColor();
if (!c.isValid() || !c.alpha())
return;
// If the text color ends up being the same as the selection background, invert the selection
// background.
if (textColor == c)
c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
const RootInlineBox& rootBox = root();
LayoutUnit top = rootBox.selectionTop();
LayoutUnit h = rootBox.selectionHeight();
FloatRect clipRect(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWidth, h);
alignSelectionRectToDevicePixels(clipRect);
GraphicsContextStateSaver stateSaver(*context);
context->clip(clipRect);
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
context->drawHighlightForText(font, RenderBlock::constructTextRun(&blockFlow(), font, m_str, style, TextRun::AllowTrailingExpansion), roundedIntPoint(LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + top)), h, c, style.colorSpace());
}