本文整理汇总了C++中ASSERT_WITH_SECURITY_IMPLICATION函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERT_WITH_SECURITY_IMPLICATION函数的具体用法?C++ ASSERT_WITH_SECURITY_IMPLICATION怎么用?C++ ASSERT_WITH_SECURITY_IMPLICATION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASSERT_WITH_SECURITY_IMPLICATION函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: consume
CSSParserToken CSSTokenizer::nextToken()
{
// Unlike the HTMLTokenizer, the CSS Syntax spec is written
// as a stateless, (fixed-size) look-ahead tokenizer.
// We could move to the stateful model and instead create
// states for all the "next 3 codepoints are X" cases.
// State-machine tokenizers are easier to write to handle
// incremental tokenization of partial sources.
// However, for now we follow the spec exactly.
UChar cc = consume();
CodePoint codePointFunc = 0;
if (isASCII(cc)) {
ASSERT_WITH_SECURITY_IMPLICATION(cc < codePointsNumber);
codePointFunc = codePoints[cc];
} else {
codePointFunc = &CSSTokenizer::nameStart;
}
if (codePointFunc)
return ((this)->*(codePointFunc))(cc);
return CSSParserToken(DelimiterToken, cc);
}
示例2: while
void CSSImageSetValue::fillImageSet()
{
size_t length = this->length();
size_t i = 0;
while (i < length) {
CSSValue* imageValue = item(i);
String imageURL = downcast<CSSImageValue>(*imageValue).url();
++i;
ASSERT_WITH_SECURITY_IMPLICATION(i < length);
CSSValue* scaleFactorValue = item(i);
float scaleFactor = downcast<CSSPrimitiveValue>(*scaleFactorValue).getFloatValue();
ImageWithScale image;
image.imageURL = imageURL;
image.scaleFactor = scaleFactor;
m_imagesInSet.append(image);
++i;
}
// Sort the images so that they are stored in order from lowest resolution to highest.
std::sort(m_imagesInSet.begin(), m_imagesInSet.end(), CSSImageSetValue::compareByScaleFactor);
}
示例3: ASSERT_WITH_SECURITY_IMPLICATION
RawPtr<FilterOperation> BasicComponentTransferFilterOperation::blend(const FilterOperation* from, double progress) const
{
double fromAmount;
if (from) {
ASSERT_WITH_SECURITY_IMPLICATION(from->isSameType(*this));
fromAmount = toBasicComponentTransferFilterOperation(from)->amount();
} else {
switch (m_type) {
case OPACITY:
case CONTRAST:
case BRIGHTNESS:
fromAmount = 1;
break;
case INVERT:
fromAmount = 0;
break;
default:
fromAmount = 0;
ASSERT_NOT_REACHED();
}
}
double result = blink::blend(fromAmount, m_amount, progress);
switch (m_type) {
case BRIGHTNESS:
case CONTRAST:
result = clampTo<double>(result, 0);
break;
case INVERT:
case OPACITY:
result = clampTo<double>(result, 0, 1);
break;
default:
ASSERT_NOT_REACHED();
}
return BasicComponentTransferFilterOperation::create(result, m_type);
}
示例4: ASSERT_WITH_SECURITY_IMPLICATION
void CSSSelectorList::adoptSelectorVector(Vector<OwnPtr<CSSParserSelector>>& selectorVector)
{
ASSERT_WITH_SECURITY_IMPLICATION(!selectorVector.isEmpty());
deleteSelectors();
size_t flattenedSize = 0;
for (size_t i = 0; i < selectorVector.size(); ++i) {
for (CSSParserSelector* selector = selectorVector[i].get(); selector; selector = selector->tagHistory())
++flattenedSize;
}
ASSERT(flattenedSize);
m_selectorArray = reinterpret_cast<CSSSelector*>(fastMalloc(sizeof(CSSSelector) * flattenedSize));
size_t arrayIndex = 0;
for (size_t i = 0; i < selectorVector.size(); ++i) {
CSSParserSelector* current = selectorVector[i].get();
while (current) {
{
// Move item from the parser selector vector into m_selectorArray without invoking destructor (Ugh.)
CSSSelector* currentSelector = current->releaseSelector().leakPtr();
memcpy(&m_selectorArray[arrayIndex], currentSelector, sizeof(CSSSelector));
// Free the underlying memory without invoking the destructor.
operator delete (currentSelector);
}
current = current->tagHistory();
ASSERT(!m_selectorArray[arrayIndex].isLastInSelectorList());
if (current)
m_selectorArray[arrayIndex].setNotLastInTagHistory();
++arrayIndex;
}
ASSERT(m_selectorArray[arrayIndex - 1].isLastInTagHistory());
}
ASSERT(flattenedSize == arrayIndex);
m_selectorArray[arrayIndex - 1].setLastInSelectorList();
selectorVector.clear();
}
示例5: getWebView
void AutofillPopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents)
{
WebViewImpl* webView = getWebView();
if (!webView)
return;
ASSERT_WITH_SECURITY_IMPLICATION(listIndex < m_names.size());
if (m_useLegacyBehavior) {
for (size_t i = 0; i < m_itemIDs.size(); ++i) {
if (m_itemIDs[i] == WebAutofillClient::MenuItemIDSeparator) {
if (listIndex > i)
listIndex--;
break;
}
}
}
webView->autofillClient()->didAcceptAutofillSuggestion(WebNode(getTextField()),
m_names[listIndex],
m_labels[listIndex],
m_itemIDs[listIndex],
listIndex);
}
示例6: ASSERT
bool SVGMaskPainter::prepareEffect(const LayoutObject& object, GraphicsContext* context)
{
ASSERT(context);
ASSERT(m_mask.style());
ASSERT_WITH_SECURITY_IMPLICATION(!m_mask.needsLayout());
m_mask.clearInvalidationMask();
FloatRect paintInvalidationRect = object.paintInvalidationRectInLocalCoordinates();
if (paintInvalidationRect.isEmpty() || !m_mask.element()->hasChildren())
return false;
if (RuntimeEnabledFeatures::slimmingPaintEnabled()) {
ASSERT(context->displayItemList());
if (context->displayItemList()->displayItemConstructionIsDisabled())
return true;
context->displayItemList()->createAndAppend<BeginCompositingDisplayItem>(object, SkXfermode::kSrcOver_Mode, 1, &paintInvalidationRect);
} else {
BeginCompositingDisplayItem beginCompositingContent(object, SkXfermode::kSrcOver_Mode, 1, &paintInvalidationRect);
beginCompositingContent.replay(*context);
}
return true;
}
示例7: findBlendRangeAtRow
// Returns two point ranges (<left, width> pairs) at row 'canvasY', that belong to 'src' but not 'dst'.
// A point range is empty if the corresponding width is 0.
inline void findBlendRangeAtRow(const blink::IntRect& src, const blink::IntRect& dst, int canvasY, int& left1, int& width1, int& left2, int& width2)
{
ASSERT_WITH_SECURITY_IMPLICATION(canvasY >= src.y() && canvasY < src.maxY());
left1 = -1;
width1 = 0;
left2 = -1;
width2 = 0;
if (canvasY < dst.y() || canvasY >= dst.maxY() || src.x() >= dst.maxX() || src.maxX() <= dst.x()) {
left1 = src.x();
width1 = src.width();
return;
}
if (src.x() < dst.x()) {
left1 = src.x();
width1 = dst.x() - src.x();
}
if (src.maxX() > dst.maxX()) {
left2 = dst.maxX();
width2 = src.maxX() - dst.maxX();
}
}
示例8: while
void CSSImageSetValue::fillImageSet()
{
size_t length = this->length();
size_t i = 0;
while (i < length) {
CSSImageValue* imageValue = toCSSImageValue(item(i));
String imageURL = imageValue->url();
++i;
ASSERT_WITH_SECURITY_IMPLICATION(i < length);
CSSValue* scaleFactorValue = item(i);
float scaleFactor = toCSSPrimitiveValue(scaleFactorValue)->getFloatValue();
ImageWithScale image;
image.imageURL = imageURL;
image.referrer = SecurityPolicy::generateReferrer(imageValue->referrer().referrerPolicy, KURL(ParsedURLString, imageURL), imageValue->referrer().referrer);
image.scaleFactor = scaleFactor;
m_imagesInSet.append(image);
++i;
}
// Sort the images so that they are stored in order from lowest resolution to highest.
std::sort(m_imagesInSet.begin(), m_imagesInSet.end(), CSSImageSetValue::compareByScaleFactor);
}
示例9: ASSERT_WITH_SECURITY_IMPLICATION
bool ICOImageDecoder::decodeAtIndex(size_t index)
{
ASSERT_WITH_SECURITY_IMPLICATION(index < m_dirEntries.size());
const IconDirectoryEntry& dirEntry = m_dirEntries[index];
const ImageType imageType = imageTypeAtIndex(index);
if (imageType == Unknown)
return false; // Not enough data to determine image type yet.
if (imageType == BMP) {
if (!m_bmpReaders[index]) {
// We need to have already sized m_frameBufferCache before this, and
// we must not resize it again later (see caution in frameCount()).
ASSERT(m_frameBufferCache.size() == m_dirEntries.size());
m_bmpReaders[index] = adoptPtr(new BMPImageReader(this, dirEntry.m_imageOffset, 0, true));
m_bmpReaders[index]->setData(m_data.get());
m_bmpReaders[index]->setBuffer(&m_frameBufferCache[index]);
}
m_frameSize = dirEntry.m_size;
bool result = m_bmpReaders[index]->decodeBMP(false);
m_frameSize = IntSize();
return result;
}
if (!m_pngDecoders[index]) {
m_pngDecoders[index] = adoptPtr(
new PNGImageDecoder(m_premultiplyAlpha ? ImageSource::AlphaPremultiplied : ImageSource::AlphaNotPremultiplied,
m_ignoreGammaAndColorProfile ? ImageSource::GammaAndColorProfileIgnored : ImageSource::GammaAndColorProfileApplied));
setDataForPNGDecoderAtIndex(index);
}
// Fail if the size the PNGImageDecoder calculated does not match the size
// in the directory.
if (m_pngDecoders[index]->isSizeAvailable() && (m_pngDecoders[index]->size() != dirEntry.m_size))
return setFailed();
m_frameBufferCache[index] = *m_pngDecoders[index]->frameBufferAtIndex(0);
return !m_pngDecoders[index]->failed() || setFailed();
}
示例10: ASSERT
bool SVGClipPainter::prepareEffect(const LayoutObject& target, const FloatRect& targetBoundingBox,
const FloatRect& paintInvalidationRect, GraphicsContext* context, ClipperState& clipperState)
{
ASSERT(context);
ASSERT(clipperState == ClipperNotApplied);
ASSERT_WITH_SECURITY_IMPLICATION(!m_clip.needsLayout());
m_clip.clearInvalidationMask();
if (paintInvalidationRect.isEmpty() || m_clip.hasCycle())
return false;
SVGClipExpansionCycleHelper inClipExpansionChange(m_clip);
AffineTransform animatedLocalTransform = toSVGClipPathElement(m_clip.element())->calculateAnimatedLocalTransform();
// When drawing a clip for non-SVG elements, the CTM does not include the zoom factor.
// In this case, we need to apply the zoom scale explicitly - but only for clips with
// userSpaceOnUse units (the zoom is accounted for objectBoundingBox-resolved lengths).
if (!target.isSVG() && m_clip.clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) {
ASSERT(m_clip.style());
animatedLocalTransform.scale(m_clip.style()->effectiveZoom());
}
// First, try to apply the clip as a clipPath.
Path clipPath;
if (m_clip.asPath(animatedLocalTransform, targetBoundingBox, clipPath)) {
clipperState = ClipperAppliedPath;
ASSERT(context->displayItemList());
context->displayItemList()->createAndAppend<BeginClipPathDisplayItem>(target, clipPath);
return true;
}
// Fall back to masking.
clipperState = ClipperAppliedMask;
// Begin compositing the clip mask.
CompositingRecorder::beginCompositing(*context, target, SkXfermode::kSrcOver_Mode, 1, &paintInvalidationRect);
{
TransformRecorder recorder(*context, target, animatedLocalTransform);
// clipPath can also be clipped by another clipPath.
SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObject(&m_clip);
LayoutSVGResourceClipper* clipPathClipper = resources ? resources->clipper() : 0;
ClipperState clipPathClipperState = ClipperNotApplied;
if (clipPathClipper && !SVGClipPainter(*clipPathClipper).prepareEffect(m_clip, targetBoundingBox, paintInvalidationRect, context, clipPathClipperState)) {
// End the clip mask's compositor.
CompositingRecorder::endCompositing(*context, target);
return false;
}
drawClipMaskContent(context, target, targetBoundingBox, paintInvalidationRect);
if (clipPathClipper)
SVGClipPainter(*clipPathClipper).finishEffect(m_clip, context, clipPathClipperState);
}
// Masked content layer start.
CompositingRecorder::beginCompositing(*context, target, SkXfermode::kSrcIn_Mode, 1, &paintInvalidationRect);
return true;
}
示例11: buffer
String TextCodecUTF8::decode(const char* bytes, size_t length, bool flush, bool stopOnError, bool& sawError)
{
// Each input byte might turn into a character.
// That includes all bytes in the partial-sequence buffer because
// each byte in an invalid sequence will turn into a replacement character.
StringBuffer<LChar> buffer(m_partialSequenceSize + length);
const uint8_t* source = reinterpret_cast<const uint8_t*>(bytes);
const uint8_t* end = source + length;
const uint8_t* alignedEnd = alignToMachineWord(end);
LChar* destination = buffer.characters();
do {
if (m_partialSequenceSize) {
// Explicitly copy destination and source pointers to avoid taking pointers to the
// local variables, which may harm code generation by disabling some optimizations
// in some compilers.
LChar* destinationForHandlePartialSequence = destination;
const uint8_t* sourceForHandlePartialSequence = source;
if (handlePartialSequence(destinationForHandlePartialSequence, sourceForHandlePartialSequence, end, flush, stopOnError, sawError)) {
source = sourceForHandlePartialSequence;
goto upConvertTo16Bit;
}
destination = destinationForHandlePartialSequence;
source = sourceForHandlePartialSequence;
if (m_partialSequenceSize)
break;
}
while (source < end) {
if (isASCII(*source)) {
// Fast path for ASCII. Most UTF-8 text will be ASCII.
if (isAlignedToMachineWord(source)) {
while (source < alignedEnd) {
MachineWord chunk = *reinterpret_cast_ptr<const MachineWord*>(source);
if (!isAllASCII<LChar>(chunk))
break;
copyASCIIMachineWord(destination, source);
source += sizeof(MachineWord);
destination += sizeof(MachineWord);
}
if (source == end)
break;
if (!isASCII(*source))
continue;
}
*destination++ = *source++;
continue;
}
int count = nonASCIISequenceLength(*source);
int character;
if (!count)
character = nonCharacter;
else {
if (count > end - source) {
ASSERT_WITH_SECURITY_IMPLICATION(end - source < static_cast<ptrdiff_t>(sizeof(m_partialSequence)));
ASSERT(!m_partialSequenceSize);
m_partialSequenceSize = end - source;
memcpy(m_partialSequence, source, m_partialSequenceSize);
source = end;
break;
}
character = decodeNonASCIISequence(source, count);
}
if (character == nonCharacter) {
sawError = true;
if (stopOnError)
break;
goto upConvertTo16Bit;
}
if (character > 0xff)
goto upConvertTo16Bit;
source += count;
*destination++ = character;
}
} while (flush && m_partialSequenceSize);
buffer.shrink(destination - buffer.characters());
return String::adopt(buffer);
upConvertTo16Bit:
StringBuffer<UChar> buffer16(m_partialSequenceSize + length);
UChar* destination16 = buffer16.characters();
// Copy the already converted characters
for (LChar* converted8 = buffer.characters(); converted8 < destination;)
*destination16++ = *converted8++;
do {
if (m_partialSequenceSize) {
// Explicitly copy destination and source pointers to avoid taking pointers to the
// local variables, which may harm code generation by disabling some optimizations
// in some compilers.
UChar* destinationForHandlePartialSequence = destination16;
const uint8_t* sourceForHandlePartialSequence = source;
handlePartialSequence(destinationForHandlePartialSequence, sourceForHandlePartialSequence, end, flush, stopOnError, sawError);
//.........这里部分代码省略.........
示例12: ASSERT
bool SVGResources::buildCachedResources(const RenderElement& renderer, const RenderStyle& style)
{
ASSERT(renderer.element());
ASSERT_WITH_SECURITY_IMPLICATION(renderer.element()->isSVGElement());
if (!renderer.element())
return false;
auto& element = downcast<SVGElement>(*renderer.element());
Document& document = element.document();
SVGDocumentExtensions& extensions = document.accessSVGExtensions();
const AtomicString& tagName = element.localName();
if (tagName.isNull())
return false;
const SVGRenderStyle& svgStyle = style.svgStyle();
bool foundResources = false;
if (clipperFilterMaskerTags().contains(tagName)) {
if (svgStyle.hasClipper()) {
AtomicString id(svgStyle.clipperResource());
if (setClipper(getRenderSVGResourceById<RenderSVGResourceClipper>(document, id)))
foundResources = true;
else
registerPendingResource(extensions, id, element);
}
if (style.hasFilter()) {
const FilterOperations& filterOperations = style.filter();
if (filterOperations.size() == 1) {
const FilterOperation& filterOperation = *filterOperations.at(0);
if (filterOperation.type() == FilterOperation::REFERENCE) {
const auto& referenceFilterOperation = downcast<ReferenceFilterOperation>(filterOperation);
AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString(referenceFilterOperation.url(), element.document());
if (setFilter(getRenderSVGResourceById<RenderSVGResourceFilter>(document, id)))
foundResources = true;
else
registerPendingResource(extensions, id, element);
}
}
}
if (svgStyle.hasMasker()) {
AtomicString id(svgStyle.maskerResource());
if (setMasker(getRenderSVGResourceById<RenderSVGResourceMasker>(document, id)))
foundResources = true;
else
registerPendingResource(extensions, id, element);
}
}
if (markerTags().contains(tagName) && svgStyle.hasMarkers()) {
AtomicString markerStartId(svgStyle.markerStartResource());
if (setMarkerStart(getRenderSVGResourceById<RenderSVGResourceMarker>(document, markerStartId)))
foundResources = true;
else
registerPendingResource(extensions, markerStartId, element);
AtomicString markerMidId(svgStyle.markerMidResource());
if (setMarkerMid(getRenderSVGResourceById<RenderSVGResourceMarker>(document, markerMidId)))
foundResources = true;
else
registerPendingResource(extensions, markerMidId, element);
AtomicString markerEndId(svgStyle.markerEndResource());
if (setMarkerEnd(getRenderSVGResourceById<RenderSVGResourceMarker>(document, markerEndId)))
foundResources = true;
else
registerPendingResource(extensions, markerEndId, element);
}
if (fillAndStrokeTags().contains(tagName)) {
if (svgStyle.hasFill()) {
bool hasPendingResource = false;
AtomicString id;
if (setFill(paintingResourceFromSVGPaint(document, svgStyle.fillPaintType(), svgStyle.fillPaintUri(), id, hasPendingResource)))
foundResources = true;
else if (hasPendingResource)
registerPendingResource(extensions, id, element);
}
if (svgStyle.hasStroke()) {
bool hasPendingResource = false;
AtomicString id;
if (setStroke(paintingResourceFromSVGPaint(document, svgStyle.strokePaintType(), svgStyle.strokePaintUri(), id, hasPendingResource)))
foundResources = true;
else if (hasPendingResource)
registerPendingResource(extensions, id, element);
}
}
if (chainableResourceTags().contains(tagName)) {
AtomicString id(targetReferenceFromResource(element));
if (setLinkedResource(getRenderSVGResourceContainerById(document, id)))
foundResources = true;
else
registerPendingResource(extensions, id, element);
//.........这里部分代码省略.........
示例13: m_size
ImageData::ImageData(const IntSize& size, PassRefPtr<DOMUint8ClampedArray> byteArray)
: m_size(size)
, m_data(byteArray)
{
ASSERT_WITH_SECURITY_IMPLICATION(static_cast<unsigned>(size.width() * size.height() * 4) <= m_data->length());
}
示例14: ASSERT
IDBCursorWithValue* IDBAny::idbCursorWithValue() const
{
ASSERT(m_type == IDBCursorWithValueType);
ASSERT_WITH_SECURITY_IMPLICATION(m_idbCursor->isCursorWithValue());
return toIDBCursorWithValue(m_idbCursor.get());
}
示例15: ASSERT
void SVGAnimationElement::currentValuesForValuesAnimation(float percent, float& effectivePercent, String& from, String& to)
{
unsigned valuesCount = m_values.size();
ASSERT(m_animationValid);
ASSERT(valuesCount >= 1);
if (percent == 1 || valuesCount == 1) {
from = m_values[valuesCount - 1];
to = m_values[valuesCount - 1];
effectivePercent = 1;
return;
}
CalcMode calcMode = this->calcMode();
if (hasTagName(SVGNames::animateTag) || hasTagName(SVGNames::animateColorTag)) {
AnimatedPropertyType attributeType = toSVGAnimateElement(this)->determineAnimatedPropertyType(targetElement());
// Fall back to discrete animations for Strings.
if (attributeType == AnimatedBoolean
|| attributeType == AnimatedEnumeration
|| attributeType == AnimatedPreserveAspectRatio
|| attributeType == AnimatedString)
calcMode = CalcModeDiscrete;
}
if (!m_keyPoints.isEmpty() && calcMode != CalcModePaced)
return currentValuesFromKeyPoints(percent, effectivePercent, from, to);
unsigned keyTimesCount = m_keyTimes.size();
ASSERT(!keyTimesCount || valuesCount == keyTimesCount);
ASSERT(!keyTimesCount || (keyTimesCount > 1 && !m_keyTimes[0]));
unsigned index = calculateKeyTimesIndex(percent);
if (calcMode == CalcModeDiscrete) {
if (!keyTimesCount)
index = static_cast<unsigned>(percent * valuesCount);
from = m_values[index];
to = m_values[index];
effectivePercent = 0;
return;
}
float fromPercent;
float toPercent;
if (keyTimesCount) {
fromPercent = m_keyTimes[index];
toPercent = m_keyTimes[index + 1];
} else {
index = static_cast<unsigned>(floorf(percent * (valuesCount - 1)));
fromPercent = static_cast<float>(index) / (valuesCount - 1);
toPercent = static_cast<float>(index + 1) / (valuesCount - 1);
}
if (index == valuesCount - 1)
--index;
from = m_values[index];
to = m_values[index + 1];
ASSERT_WITH_SECURITY_IMPLICATION(toPercent > fromPercent);
effectivePercent = (percent - fromPercent) / (toPercent - fromPercent);
if (calcMode == CalcModeSpline) {
ASSERT(m_keySplines.size() == m_values.size() - 1);
effectivePercent = calculatePercentForSpline(effectivePercent, index);
}
}