本文整理汇总了C++中RefPtr类的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr类的具体用法?C++ RefPtr怎么用?C++ RefPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RefPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetResponsibleDocument
already_AddRefed<Promise>
ScreenOrientation::LockInternal(ScreenOrientationInternal aOrientation, ErrorResult& aRv)
{
// Steps to apply an orientation lock as defined in spec.
nsIDocument* doc = GetResponsibleDocument();
if (NS_WARN_IF(!doc)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
if (NS_WARN_IF(!owner)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
nsCOMPtr<nsIDocShell> docShell = owner->GetDocShell();
if (NS_WARN_IF(!docShell)) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(owner);
MOZ_ASSERT(go);
RefPtr<Promise> p = Promise::Create(go, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_GONK)
// User agent does not support locking the screen orientation.
p->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return p.forget();
#else
LockPermission perm = GetLockOrientationPermission(true);
if (perm == LOCK_DENIED) {
p->MaybeReject(NS_ERROR_DOM_SECURITY_ERR);
return p.forget();
}
nsCOMPtr<nsIDocShellTreeItem> root;
docShell->GetSameTypeRootTreeItem(getter_AddRefs(root));
nsCOMPtr<nsIDocShell> rootShell(do_QueryInterface(root));
if (!rootShell) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return nullptr;
}
rootShell->SetOrientationLock(aOrientation);
AbortOrientationPromises(rootShell);
doc->SetOrientationPendingPromise(p);
nsCOMPtr<nsIRunnable> lockOrientationTask =
new LockOrientationTask(this, p, aOrientation, doc,
perm == FULLSCREEN_LOCK_ALLOWED);
aRv = NS_DispatchToMainThread(lockOrientationTask);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
return p.forget();
#endif
}
示例2: create
PassRefPtr<HistoryItem> HistoryItem::decodeBackForwardTree(const String& topURLString, const String& topTitle, const String& topOriginalURLString, Decoder& decoder)
{
// Since the data stream is not trusted, the decode has to be non-recursive.
// We don't want bad data to cause a stack overflow.
uint32_t version;
if (!decoder.decodeUInt32(version))
return 0;
if (version != backForwardTreeEncodingVersion)
return 0;
String urlString = topURLString;
String title = topTitle;
String originalURLString = topOriginalURLString;
Vector<DecodeRecursionStackElement, 16> recursionStack;
recurse:
RefPtr<HistoryItem> node = create(urlString, title, 0);
node->setOriginalURLString(originalURLString);
title = String();
uint64_t size;
if (!decoder.decodeUInt64(size))
return 0;
size_t i;
RefPtr<HistoryItem> child;
for (i = 0; i < size; ++i) {
if (!decoder.decodeString(originalURLString))
return 0;
if (!decoder.decodeString(urlString))
return 0;
recursionStack.append(DecodeRecursionStackElement(node.release(), i, size));
goto recurse;
resume:
node->m_children.append(child.release());
}
if (!decoder.decodeInt64(node->m_documentSequenceNumber))
return 0;
if (!decoder.decodeUInt64(size))
return 0;
for (i = 0; i < size; ++i) {
String state;
if (!decoder.decodeString(state))
return 0;
node->m_documentState.append(state);
}
if (!decoder.decodeString(node->m_formContentType))
return 0;
bool hasFormData;
if (!decoder.decodeBool(hasFormData))
return 0;
if (hasFormData) {
node->m_formData = FormData::decode(decoder);
if (!node->m_formData)
return 0;
}
if (!decoder.decodeInt64(node->m_itemSequenceNumber))
return 0;
if (!decoder.decodeString(node->m_referrer))
return 0;
int32_t x;
if (!decoder.decodeInt32(x))
return 0;
int32_t y;
if (!decoder.decodeInt32(y))
return 0;
node->m_scrollPoint = IntPoint(x, y);
if (!decoder.decodeFloat(node->m_pageScaleFactor))
return 0;
bool hasStateObject;
if (!decoder.decodeBool(hasStateObject))
return 0;
if (hasStateObject) {
Vector<uint8_t> bytes;
if (!decoder.decodeBytes(bytes))
return 0;
node->m_stateObject = SerializedScriptValue::adopt(bytes);
}
if (!decoder.decodeString(node->m_target))
return 0;
// Simulate recursion with our own stack.
if (!recursionStack.isEmpty()) {
DecodeRecursionStackElement& element = recursionStack.last();
//.........这里部分代码省略.........
示例3: NS_ENSURE_TRUE
HRESULT
D3D11DXVA2Manager::ConfigureForSize(uint32_t aWidth, uint32_t aHeight)
{
mWidth = aWidth;
mHeight = aHeight;
RefPtr<IMFMediaType> inputType;
HRESULT hr = wmf::MFCreateMediaType(getter_AddRefs(inputType));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = inputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = inputType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_NV12);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = inputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = inputType->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<IMFAttributes> attr = mTransform->GetAttributes();
hr = attr->SetUINT32(MF_XVP_PLAYBACK_MODE, TRUE);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = attr->SetUINT32(MF_LOW_LATENCY, FALSE);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = MFSetAttributeSize(inputType, MF_MT_FRAME_SIZE, aWidth, aHeight);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
RefPtr<IMFMediaType> outputType;
hr = wmf::MFCreateMediaType(getter_AddRefs(outputType));
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = outputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
hr = outputType->SetGUID(MF_MT_SUBTYPE, MFVideoFormat_ARGB32);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
gfx::IntSize size(mWidth, mHeight);
hr = mTransform->SetMediaTypes(inputType, outputType, ConfigureOutput, &size);
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
return S_OK;
}
示例4: inputEffect
void FEComposite::platformApplySoftware()
{
FilterEffect* in = inputEffect(0);
FilterEffect* in2 = inputEffect(1);
if (m_type == FECOMPOSITE_OPERATOR_ARITHMETIC) {
Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult();
if (!dstPixelArray)
return;
IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
RefPtr<Uint8ClampedArray> srcPixelArray = in->asPremultipliedImage(effectADrawingRect);
IntRect effectBDrawingRect = requestedRegionOfInputImageData(in2->absolutePaintRect());
in2->copyPremultipliedImage(dstPixelArray, effectBDrawingRect);
platformArithmeticSoftware(srcPixelArray.get(), dstPixelArray, m_k1, m_k2, m_k3, m_k4);
return;
}
ImageBuffer* resultImage = createImageBufferResult();
if (!resultImage)
return;
GraphicsContext* filterContext = resultImage->context();
ImageBuffer* imageBuffer = in->asImageBuffer();
ImageBuffer* imageBuffer2 = in2->asImageBuffer();
ASSERT(imageBuffer);
ASSERT(imageBuffer2);
switch (m_type) {
case FECOMPOSITE_OPERATOR_OVER:
filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()));
break;
case FECOMPOSITE_OPERATOR_IN: {
// Applies only to the intersected region.
IntRect destinationRect = in->absolutePaintRect();
destinationRect.intersect(in2->absolutePaintRect());
destinationRect.intersect(absolutePaintRect());
if (destinationRect.isEmpty())
break;
IntPoint destinationPoint(destinationRect.x() - absolutePaintRect().x(), destinationRect.y() - absolutePaintRect().y());
IntRect sourceRect(IntPoint(destinationRect.x() - in->absolutePaintRect().x(),
destinationRect.y() - in->absolutePaintRect().y()), destinationRect.size());
IntRect source2Rect(IntPoint(destinationRect.x() - in2->absolutePaintRect().x(),
destinationRect.y() - in2->absolutePaintRect().y()), destinationRect.size());
filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, IntRect(destinationPoint, source2Rect.size()), source2Rect);
filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, IntRect(destinationPoint, sourceRect.size()), sourceRect, CompositeSourceIn);
break;
}
case FECOMPOSITE_OPERATOR_OUT:
filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()));
filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()), IntRect(IntPoint(), imageBuffer2->logicalSize()), CompositeDestinationOut);
break;
case FECOMPOSITE_OPERATOR_ATOP:
filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositeSourceAtop);
break;
case FECOMPOSITE_OPERATOR_XOR:
filterContext->drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in2->absolutePaintRect()));
filterContext->drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, drawingRegionOfInputImage(in->absolutePaintRect()), IntRect(IntPoint(), imageBuffer->logicalSize()), CompositeXOR);
break;
default:
break;
}
}
示例5: createFullScreenStyle
static PassRefPtr<RenderStyle> createFullScreenStyle()
{
RefPtr<RenderStyle> fullscreenStyle = RenderStyle::createDefaultStyle();
// Create a stacking context:
fullscreenStyle->setZIndex(INT_MAX);
fullscreenStyle->setFontDescription(FontDescription());
fullscreenStyle->font().update(0);
fullscreenStyle->setDisplay(FLEX);
fullscreenStyle->setJustifyContent(JustifyCenter);
fullscreenStyle->setAlignItems(AlignCenter);
fullscreenStyle->setFlexDirection(FlowColumn);
fullscreenStyle->setPosition(FixedPosition);
fullscreenStyle->setWidth(Length(100.0, Percent));
fullscreenStyle->setHeight(Length(100.0, Percent));
fullscreenStyle->setLeft(Length(0, WebCore::Fixed));
fullscreenStyle->setTop(Length(0, WebCore::Fixed));
fullscreenStyle->setBackgroundColor(Color::black);
return fullscreenStyle.release();
}
示例6: reporter
HRESULT
D3D11DXVA2Manager::Init(nsACString& aFailureReason)
{
HRESULT hr;
ScopedGfxFeatureReporter reporter("DXVA2D3D11");
gfx::D3D11VideoCrashGuard crashGuard;
if (crashGuard.Crashed()) {
NS_WARNING("DXVA2D3D11 crash detected");
aFailureReason.AssignLiteral("DXVA2D3D11 crashes detected in the past");
return E_FAIL;
}
mDevice = gfx::DeviceManagerDx::Get()->CreateDecoderDevice();
if (!mDevice) {
aFailureReason.AssignLiteral("Failed to create D3D11 device for decoder");
return E_FAIL;
}
mDevice->GetImmediateContext(getter_AddRefs(mContext));
if (!mContext) {
aFailureReason.AssignLiteral("Failed to get immediate context for d3d11 device");
return E_FAIL;
}
hr = wmf::MFCreateDXGIDeviceManager(&mDeviceManagerToken, getter_AddRefs(mDXGIDeviceManager));
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("MFCreateDXGIDeviceManager failed with code %X", hr);
return hr;
}
hr = mDXGIDeviceManager->ResetDevice(mDevice, mDeviceManagerToken);
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("IMFDXGIDeviceManager::ResetDevice failed with code %X", hr);
return hr;
}
mTransform = new MFTDecoder();
hr = mTransform->Create(CLSID_VideoProcessorMFT);
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("MFTDecoder::Create(CLSID_VideoProcessorMFT) failed with code %X", hr);
return hr;
}
hr = mTransform->SendMFTMessage(MFT_MESSAGE_SET_D3D_MANAGER, ULONG_PTR(mDXGIDeviceManager.get()));
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("MFTDecoder::SendMFTMessage(MFT_MESSAGE_SET_D3D_MANAGER) failed with code %X", hr);
return hr;
}
RefPtr<ID3D11VideoDevice> videoDevice;
hr = mDevice->QueryInterface(static_cast<ID3D11VideoDevice**>(getter_AddRefs(videoDevice)));
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("QI to ID3D11VideoDevice failed with code %X", hr);
return hr;
}
bool found = false;
UINT profileCount = videoDevice->GetVideoDecoderProfileCount();
for (UINT i = 0; i < profileCount; i++) {
GUID id;
hr = videoDevice->GetVideoDecoderProfile(i, &id);
if (SUCCEEDED(hr) && (id == DXVA2_ModeH264_E || id == DXVA2_Intel_ModeH264_E)) {
mDecoderGUID = id;
found = true;
break;
}
}
if (!found) {
aFailureReason.AssignLiteral("Failed to find an appropriate decoder GUID");
return E_FAIL;
}
BOOL nv12Support = false;
hr = videoDevice->CheckVideoDecoderFormat(&mDecoderGUID, DXGI_FORMAT_NV12, &nv12Support);
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("CheckVideoDecoderFormat failed with code %X", hr);
return hr;
}
if (!nv12Support) {
aFailureReason.AssignLiteral("Decoder doesn't support NV12 surfaces");
return E_FAIL;
}
RefPtr<IDXGIDevice> dxgiDevice;
hr = mDevice->QueryInterface(static_cast<IDXGIDevice**>(getter_AddRefs(dxgiDevice)));
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("QI to IDXGIDevice failed with code %X", hr);
return hr;
}
RefPtr<IDXGIAdapter> adapter;
hr = dxgiDevice->GetAdapter(adapter.StartAssignment());
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("IDXGIDevice::GetAdapter failed with code %X", hr);
return hr;
}
DXGI_ADAPTER_DESC adapterDesc;
//.........这里部分代码省略.........
示例7: deleteSelection
void InsertLineBreakCommand::doApply()
{
deleteSelection();
VisibleSelection selection = endingSelection();
if (!selection.isNonOrphanedCaretOrRange())
return;
VisiblePosition caret(selection.visibleStart());
// FIXME: If the node is hidden, we should still be able to insert text.
// For now, we return to avoid a crash. https://bugs.webkit.org/show_bug.cgi?id=40342
if (caret.isNull())
return;
Position pos(caret.deepEquivalent());
pos = positionAvoidingSpecialElementBoundary(pos);
pos = positionOutsideTabSpan(pos);
RefPtr<Node> nodeToInsert;
if (shouldUseBreakElement(pos))
nodeToInsert = createBreakElement(document());
else
nodeToInsert = document().createTextNode("\n");
// FIXME: Need to merge text nodes when inserting just after or before text.
if (isEndOfParagraph(caret) && !lineBreakExistsAtVisiblePosition(caret)) {
bool needExtraLineBreak = !pos.deprecatedNode()->hasTagName(hrTag) && !isHTMLTableElement(pos.deprecatedNode());
insertNodeAt(nodeToInsert.get(), pos);
if (needExtraLineBreak)
insertNodeBefore(nodeToInsert->cloneNode(false), nodeToInsert);
VisiblePosition endingPosition(positionBeforeNode(nodeToInsert.get()));
setEndingSelection(VisibleSelection(endingPosition, endingSelection().isDirectional()));
} else if (pos.deprecatedEditingOffset() <= caretMinOffset(pos.deprecatedNode())) {
insertNodeAt(nodeToInsert.get(), pos);
// Insert an extra br or '\n' if the just inserted one collapsed.
if (!isStartOfParagraph(positionBeforeNode(nodeToInsert.get())))
insertNodeBefore(nodeToInsert->cloneNode(false).get(), nodeToInsert.get());
setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInsert.get()), DOWNSTREAM, endingSelection().isDirectional()));
// If we're inserting after all of the rendered text in a text node, or into a non-text node,
// a simple insertion is sufficient.
} else if (pos.deprecatedEditingOffset() >= caretMaxOffset(pos.deprecatedNode()) || !pos.deprecatedNode()->isTextNode()) {
insertNodeAt(nodeToInsert.get(), pos);
setEndingSelection(VisibleSelection(positionInParentAfterNode(nodeToInsert.get()), DOWNSTREAM, endingSelection().isDirectional()));
} else if (pos.deprecatedNode()->isTextNode()) {
// Split a text node
Text* textNode = toText(pos.deprecatedNode());
splitTextNode(textNode, pos.deprecatedEditingOffset());
insertNodeBefore(nodeToInsert, textNode);
Position endingPosition = firstPositionInNode(textNode);
// Handle whitespace that occurs after the split
document().updateLayoutIgnorePendingStylesheets();
if (!endingPosition.isRenderedCharacter()) {
Position positionBeforeTextNode(positionInParentBeforeNode(textNode));
// Clear out all whitespace and insert one non-breaking space
deleteInsignificantTextDownstream(endingPosition);
ASSERT(!textNode->renderer() || textNode->renderer()->style().collapseWhiteSpace());
// Deleting insignificant whitespace will remove textNode if it contains nothing but insignificant whitespace.
if (textNode->inDocument())
insertTextIntoNode(textNode, 0, nonBreakingSpaceString());
else {
RefPtr<Text> nbspNode = document().createTextNode(nonBreakingSpaceString());
insertNodeAt(nbspNode.get(), positionBeforeTextNode);
endingPosition = firstPositionInNode(nbspNode.get());
}
}
setEndingSelection(VisibleSelection(endingPosition, DOWNSTREAM, endingSelection().isDirectional()));
}
// Handle the case where there is a typing style.
RefPtr<EditingStyle> typingStyle = frame().selection().typingStyle();
if (typingStyle && !typingStyle->isEmpty()) {
// Apply the typing style to the inserted line break, so that if the selection
// leaves and then comes back, new input will have the right style.
// FIXME: We shouldn't always apply the typing style to the line break here,
// see <rdar://problem/5794462>.
applyStyle(typingStyle.get(), firstPositionInOrBeforeNode(nodeToInsert.get()), lastPositionInOrAfterNode(nodeToInsert.get()));
// Even though this applyStyle operates on a Range, it still sets an endingSelection().
// It tries to set a VisibleSelection around the content it operated on. So, that VisibleSelection
// will either (a) select the line break we inserted, or it will (b) be a caret just
// before the line break (if the line break is at the end of a block it isn't selectable).
// So, this next call sets the endingSelection() to a caret just after the line break
// that we inserted, or just before it if it's at the end of a block.
setEndingSelection(endingSelection().visibleEnd());
}
rebalanceWhitespace();
}
示例8: registerFileBlobURL
void NetworkConnectionToWebProcess::registerFileBlobURL(const URL& url, const String& path, const SandboxExtension::Handle& extensionHandle, const String& contentType)
{
RefPtr<SandboxExtension> extension = SandboxExtension::create(extensionHandle);
NetworkBlobRegistry::singleton().registerFileBlobURL(this, url, path, extension.release(), contentType);
}
示例9: create
PassRefPtr<FormData> FormData::create(const CString& string)
{
RefPtr<FormData> result = create();
result->appendData(string.data(), string.length());
return result.release();
}
示例10: adoptRef
PassRefPtr<RTCSessionDescriptionRequestImpl> RTCSessionDescriptionRequestImpl::create(ScriptExecutionContext* context, PassRefPtr<RTCSessionDescriptionCallback> successCallback, PassRefPtr<RTCErrorCallback> errorCallback)
{
RefPtr<RTCSessionDescriptionRequestImpl> request = adoptRef(new RTCSessionDescriptionRequestImpl(context, successCallback, errorCallback));
request->suspendIfNeeded();
return request.release();
}
示例11: getPropertyCSSValue
String CSSMutableStyleDeclaration::getPropertyValue(int propertyID) const
{
RefPtr<CSSValue> value = getPropertyCSSValue(propertyID);
if (value)
return value->cssText();
// Shorthand and 4-values properties
switch (propertyID) {
case CSSPropertyBackgroundPosition: {
// FIXME: Is this correct? The code in cssparser.cpp is confusing
const int properties[2] = { CSSPropertyBackgroundPositionX, CSSPropertyBackgroundPositionY };
return getLayeredShorthandValue(properties, 2);
}
case CSSPropertyBackgroundRepeat: {
const int properties[2] = { CSSPropertyBackgroundRepeatX, CSSPropertyBackgroundRepeatY };
return getLayeredShorthandValue(properties, 2);
}
case CSSPropertyBackground: {
const int properties[9] = { CSSPropertyBackgroundColor,
CSSPropertyBackgroundImage,
CSSPropertyBackgroundRepeatX,
CSSPropertyBackgroundRepeatY,
CSSPropertyBackgroundAttachment,
CSSPropertyBackgroundPositionX,
CSSPropertyBackgroundPositionY,
CSSPropertyBackgroundClip,
CSSPropertyBackgroundOrigin };
return getLayeredShorthandValue(properties, 9);
}
case CSSPropertyBorder: {
const int properties[3][4] = {{ CSSPropertyBorderTopWidth,
CSSPropertyBorderRightWidth,
CSSPropertyBorderBottomWidth,
CSSPropertyBorderLeftWidth },
{ CSSPropertyBorderTopStyle,
CSSPropertyBorderRightStyle,
CSSPropertyBorderBottomStyle,
CSSPropertyBorderLeftStyle },
{ CSSPropertyBorderTopColor,
CSSPropertyBorderRightColor,
CSSPropertyBorderBottomColor,
CSSPropertyBorderLeftColor }};
String res;
for (size_t i = 0; i < WTF_ARRAY_LENGTH(properties); ++i) {
String value = getCommonValue(properties[i], 4);
if (!value.isNull()) {
if (!res.isNull())
res += " ";
res += value;
}
}
return res;
}
case CSSPropertyBorderTop: {
const int properties[3] = { CSSPropertyBorderTopWidth, CSSPropertyBorderTopStyle,
CSSPropertyBorderTopColor};
return getShorthandValue(properties, 3);
}
case CSSPropertyBorderRight: {
const int properties[3] = { CSSPropertyBorderRightWidth, CSSPropertyBorderRightStyle,
CSSPropertyBorderRightColor};
return getShorthandValue(properties, 3);
}
case CSSPropertyBorderBottom: {
const int properties[3] = { CSSPropertyBorderBottomWidth, CSSPropertyBorderBottomStyle,
CSSPropertyBorderBottomColor};
return getShorthandValue(properties, 3);
}
case CSSPropertyBorderLeft: {
const int properties[3] = { CSSPropertyBorderLeftWidth, CSSPropertyBorderLeftStyle,
CSSPropertyBorderLeftColor};
return getShorthandValue(properties, 3);
}
case CSSPropertyOutline: {
const int properties[3] = { CSSPropertyOutlineWidth, CSSPropertyOutlineStyle,
CSSPropertyOutlineColor };
return getShorthandValue(properties, 3);
}
case CSSPropertyBorderColor: {
const int properties[4] = { CSSPropertyBorderTopColor, CSSPropertyBorderRightColor,
CSSPropertyBorderBottomColor, CSSPropertyBorderLeftColor };
return get4Values(properties);
}
case CSSPropertyBorderWidth: {
const int properties[4] = { CSSPropertyBorderTopWidth, CSSPropertyBorderRightWidth,
CSSPropertyBorderBottomWidth, CSSPropertyBorderLeftWidth };
return get4Values(properties);
}
case CSSPropertyBorderStyle: {
const int properties[4] = { CSSPropertyBorderTopStyle, CSSPropertyBorderRightStyle,
CSSPropertyBorderBottomStyle, CSSPropertyBorderLeftStyle };
return get4Values(properties);
}
case CSSPropertyMargin: {
const int properties[4] = { CSSPropertyMarginTop, CSSPropertyMarginRight,
CSSPropertyMarginBottom, CSSPropertyMarginLeft };
return get4Values(properties);
}
case CSSPropertyOverflow: {
const int properties[2] = { CSSPropertyOverflowX, CSSPropertyOverflowY };
//.........这里部分代码省略.........
示例12: ASSERT
void HTMLLinkElement::process()
{
if (!inDocument() || m_isInShadowTree) {
ASSERT(!m_sheet);
return;
}
String type = m_type.lower();
URL url = getNonEmptyURLAttribute(hrefAttr);
if (!m_linkLoader.loadLink(m_relAttribute, type, m_sizes->toString(), url, &document()))
return;
bool acceptIfTypeContainsTextCSS = document().page() && document().page()->settings().treatsAnyTextCSSLinkAsStylesheet();
if (m_disabledState != Disabled && (m_relAttribute.m_isStyleSheet || (acceptIfTypeContainsTextCSS && type.contains("text/css")))
&& document().frame() && url.isValid()) {
String charset = getAttribute(charsetAttr);
if (charset.isEmpty() && document().frame())
charset = document().charset();
if (m_cachedSheet) {
removePendingSheet();
m_cachedSheet->removeClient(this);
m_cachedSheet = 0;
}
if (!shouldLoadLink())
return;
m_loading = true;
bool mediaQueryMatches = true;
if (!m_media.isEmpty()) {
RefPtr<RenderStyle> documentStyle = Style::resolveForDocument(document());
RefPtr<MediaQuerySet> media = MediaQuerySet::createAllowingDescriptionSyntax(m_media);
MediaQueryEvaluator evaluator(document().frame()->view()->mediaType(), document().frame(), documentStyle.get());
mediaQueryMatches = evaluator.eval(media.get());
}
// Don't hold up render tree construction and script execution on stylesheets
// that are not needed for the rendering at the moment.
bool isActive = mediaQueryMatches && !isAlternate();
addPendingSheet(isActive ? ActiveSheet : InactiveSheet);
// Load stylesheets that are not needed for the rendering immediately with low priority.
ResourceLoadPriority priority = isActive ? ResourceLoadPriorityUnresolved : ResourceLoadPriorityVeryLow;
CachedResourceRequest request(ResourceRequest(document().completeURL(url)), charset, priority);
request.setInitiator(this);
m_cachedSheet = document().cachedResourceLoader()->requestCSSStyleSheet(request);
if (m_cachedSheet)
m_cachedSheet->addClient(this);
else {
// The request may have been denied if (for example) the stylesheet is local and the document is remote.
m_loading = false;
removePendingSheet();
}
} else if (m_sheet) {
// we no longer contain a stylesheet, e.g. perhaps rel or type was changed
clearSheet();
document().styleResolverChanged(DeferRecalcStyle);
}
}
示例13: MOZ_ASSERT
HRESULT
D3D9DXVA2Manager::Init(nsACString& aFailureReason)
{
MOZ_ASSERT(NS_IsMainThread());
ScopedGfxFeatureReporter reporter("DXVA2D3D9");
gfx::D3D9VideoCrashGuard crashGuard;
if (crashGuard.Crashed()) {
NS_WARNING("DXVA2D3D9 crash detected");
aFailureReason.AssignLiteral("DXVA2D3D9 crashes detected in the past");
return E_FAIL;
}
// Create D3D9Ex.
HMODULE d3d9lib = LoadLibraryW(L"d3d9.dll");
NS_ENSURE_TRUE(d3d9lib, E_FAIL);
decltype(Direct3DCreate9Ex)* d3d9Create =
(decltype(Direct3DCreate9Ex)*) GetProcAddress(d3d9lib, "Direct3DCreate9Ex");
if (!d3d9Create) {
NS_WARNING("Couldn't find Direct3DCreate9Ex symbol in d3d9.dll");
aFailureReason.AssignLiteral("Couldn't find Direct3DCreate9Ex symbol in d3d9.dll");
return E_FAIL;
}
RefPtr<IDirect3D9Ex> d3d9Ex;
HRESULT hr = d3d9Create(D3D_SDK_VERSION, getter_AddRefs(d3d9Ex));
if (!d3d9Ex) {
NS_WARNING("Direct3DCreate9 failed");
aFailureReason.AssignLiteral("Direct3DCreate9 failed");
return E_FAIL;
}
// Ensure we can do the YCbCr->RGB conversion in StretchRect.
// Fail if we can't.
hr = d3d9Ex->CheckDeviceFormatConversion(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
(D3DFORMAT)MAKEFOURCC('N','V','1','2'),
D3DFMT_X8R8G8B8);
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("CheckDeviceFormatConversion failed with error %X", hr);
return hr;
}
// Create D3D9DeviceEx. We pass null HWNDs here even though the documentation
// suggests that one of them should not be. At this point in time Chromium
// does the same thing for video acceleration.
D3DPRESENT_PARAMETERS params = {0};
params.BackBufferWidth = 1;
params.BackBufferHeight = 1;
params.BackBufferFormat = D3DFMT_A8R8G8B8;
params.BackBufferCount = 1;
params.SwapEffect = D3DSWAPEFFECT_DISCARD;
params.hDeviceWindow = nullptr;
params.Windowed = TRUE;
params.Flags = D3DPRESENTFLAG_VIDEO;
RefPtr<IDirect3DDevice9Ex> device;
hr = d3d9Ex->CreateDeviceEx(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
nullptr,
D3DCREATE_FPU_PRESERVE |
D3DCREATE_MULTITHREADED |
D3DCREATE_MIXED_VERTEXPROCESSING,
¶ms,
nullptr,
getter_AddRefs(device));
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("CreateDeviceEx failed with error %X", hr);
return hr;
}
// Ensure we can create queries to synchronize operations between devices.
// Without this, when we make a copy of the frame in order to share it with
// another device, we can't be sure that the copy has finished before the
// other device starts using it.
RefPtr<IDirect3DQuery9> query;
hr = device->CreateQuery(D3DQUERYTYPE_EVENT, getter_AddRefs(query));
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("CreateQuery failed with error %X", hr);
return hr;
}
// Create and initialize IDirect3DDeviceManager9.
UINT resetToken = 0;
RefPtr<IDirect3DDeviceManager9> deviceManager;
hr = wmf::DXVA2CreateDirect3DDeviceManager9(&resetToken,
getter_AddRefs(deviceManager));
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("DXVA2CreateDirect3DDeviceManager9 failed with error %X", hr);
return hr;
}
hr = deviceManager->ResetDevice(device, resetToken);
if (!SUCCEEDED(hr)) {
aFailureReason = nsPrintfCString("IDirect3DDeviceManager9::ResetDevice failed with error %X", hr);
return hr;
}
HANDLE deviceHandle;
//.........这里部分代码省略.........
示例14: values
String CSSMutableStyleDeclaration::getLayeredShorthandValue(const int* properties, unsigned number) const
{
String res;
// Begin by collecting the properties into an array.
Vector< RefPtr<CSSValue> > values(number);
size_t numLayers = 0;
for (size_t i = 0; i < number; ++i) {
values[i] = getPropertyCSSValue(properties[i]);
if (values[i]) {
if (values[i]->isValueList()) {
CSSValueList* valueList = static_cast<CSSValueList*>(values[i].get());
numLayers = max(valueList->length(), numLayers);
} else
numLayers = max<size_t>(1U, numLayers);
}
}
// Now stitch the properties together. Implicit initial values are flagged as such and
// can safely be omitted.
for (size_t i = 0; i < numLayers; i++) {
String layerRes;
bool useRepeatXShorthand = false;
bool useRepeatYShorthand = false;
bool useSingleWordShorthand = false;
for (size_t j = 0; j < number; j++) {
RefPtr<CSSValue> value;
if (values[j]) {
if (values[j]->isValueList())
value = static_cast<CSSValueList*>(values[j].get())->item(i);
else {
value = values[j];
// Color only belongs in the last layer.
if (properties[j] == CSSPropertyBackgroundColor) {
if (i != numLayers - 1)
value = 0;
} else if (i != 0) // Other singletons only belong in the first layer.
value = 0;
}
}
// We need to report background-repeat as it was written in the CSS. If the property is implicit,
// then it was written with only one value. Here we figure out which value that was so we can
// report back correctly.
if (properties[j] == CSSPropertyBackgroundRepeatX && isPropertyImplicit(properties[j])) {
// BUG 49055: make sure the value was not reset in the layer check just above.
if (j < number - 1 && properties[j + 1] == CSSPropertyBackgroundRepeatY && value) {
RefPtr<CSSValue> yValue;
RefPtr<CSSValue> nextValue = values[j + 1];
if (nextValue->isValueList())
yValue = static_cast<CSSValueList*>(nextValue.get())->itemWithoutBoundsCheck(i);
else
yValue = nextValue;
int xId = static_cast<CSSPrimitiveValue*>(value.get())->getIdent();
int yId = static_cast<CSSPrimitiveValue*>(yValue.get())->getIdent();
if (xId != yId) {
if (xId == CSSValueRepeat && yId == CSSValueNoRepeat) {
useRepeatXShorthand = true;
++j;
} else if (xId == CSSValueNoRepeat && yId == CSSValueRepeat) {
useRepeatYShorthand = true;
continue;
}
} else {
useSingleWordShorthand = true;
++j;
}
}
}
if (value && !value->isImplicitInitialValue()) {
if (!layerRes.isNull())
layerRes += " ";
if (useRepeatXShorthand) {
useRepeatXShorthand = false;
layerRes += getValueName(CSSValueRepeatX);
} else if (useRepeatYShorthand) {
useRepeatYShorthand = false;
layerRes += getValueName(CSSValueRepeatY);
} else if (useSingleWordShorthand) {
useSingleWordShorthand = false;
layerRes += value->cssText();
} else
layerRes += value->cssText();
}
}
if (!layerRes.isNull()) {
if (!res.isNull())
res += ", ";
res += layerRes;
}
}
return res;
}
示例15: toSVGLengthList
void SVGLengthList::calculateAnimatedValue(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> fromValue, PassRefPtr<SVGPropertyBase> toValue, PassRefPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement)
{
RefPtr<SVGLengthList> fromList = toSVGLengthList(fromValue);
RefPtr<SVGLengthList> toList = toSVGLengthList(toValue);
RefPtr<SVGLengthList> toAtEndOfDurationList = toSVGLengthList(toAtEndOfDurationValue);
SVGLengthContext lengthContext(contextElement);
ASSERT(m_mode == SVGLength::lengthModeForAnimatedLengthAttribute(animationElement->attributeName()));
size_t fromLengthListSize = fromList->length();
size_t toLengthListSize = toList->length();
size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length();
if (!adjustFromToListValues(fromList, toList, percentage, animationElement->animationMode()))
return;
for (size_t i = 0; i < toLengthListSize; ++i) {
float animatedNumber = at(i)->value(lengthContext);
SVGLengthType unitType = toList->at(i)->unitType();
float effectiveFrom = 0;
if (fromLengthListSize) {
if (percentage < 0.5)
unitType = fromList->at(i)->unitType();
effectiveFrom = fromList->at(i)->value(lengthContext);
}
float effectiveTo = toList->at(i)->value(lengthContext);
float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurationList->at(i)->value(lengthContext) : 0;
animationElement->animateAdditiveNumber(percentage, repeatCount, effectiveFrom, effectiveTo, effectiveToAtEnd, animatedNumber);
at(i)->setUnitType(unitType);
at(i)->setValue(animatedNumber, lengthContext, ASSERT_NO_EXCEPTION);
}
}