本文整理汇总了C++中HashMap::get方法的典型用法代码示例。如果您正苦于以下问题:C++ HashMap::get方法的具体用法?C++ HashMap::get怎么用?C++ HashMap::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashMap
的用法示例。
在下文中一共展示了HashMap::get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkStyleSheet
void ProcessingInstruction::checkStyleSheet()
{
if (m_target == "xml-stylesheet" && document().frame() && parentNode() == &document()) {
// see http://www.w3.org/TR/xml-stylesheet/
// ### support stylesheet included in a fragment of this (or another) document
// ### make sure this gets called when adding from javascript
bool attrsOk;
const HashMap<String, String> attrs = parseAttributes(data(), attrsOk);
if (!attrsOk)
return;
HashMap<String, String>::const_iterator i = attrs.find("type");
String type;
if (i != attrs.end())
type = i->value;
m_isCSS = type.isEmpty() || type == "text/css";
#if ENABLE(XSLT)
m_isXSL = (type == "text/xml" || type == "text/xsl" || type == "application/xml" ||
type == "application/xhtml+xml" || type == "application/rss+xml" || type == "application/atom+xml");
if (!m_isCSS && !m_isXSL)
#else
if (!m_isCSS)
#endif
return;
String href = attrs.get("href");
String alternate = attrs.get("alternate");
m_alternate = alternate == "yes";
m_title = attrs.get("title");
m_media = attrs.get("media");
if (m_alternate && m_title.isEmpty())
return;
if (href.length() > 1 && href[0] == '#') {
m_localHref = href.substring(1);
#if ENABLE(XSLT)
// We need to make a synthetic XSLStyleSheet that is embedded. It needs to be able
// to kick off import/include loads that can hang off some parent sheet.
if (m_isXSL) {
URL finalURL(ParsedURLString, m_localHref);
m_sheet = XSLStyleSheet::createEmbedded(this, finalURL);
m_loading = false;
}
#endif
} else {
if (m_cachedSheet) {
m_cachedSheet->removeClient(*this);
m_cachedSheet = nullptr;
}
String url = document().completeURL(href).string();
if (!dispatchBeforeLoadEvent(url))
return;
m_loading = true;
document().styleScope().addPendingSheet();
#if ENABLE(XSLT)
if (m_isXSL) {
auto options = CachedResourceLoader::defaultCachedResourceOptions();
options.mode = FetchOptions::Mode::SameOrigin;
m_cachedSheet = document().cachedResourceLoader().requestXSLStyleSheet({ResourceRequest(document().completeURL(href)), options});
} else
#endif
{
String charset = attrs.get("charset");
CachedResourceRequest request(document().completeURL(href), CachedResourceLoader::defaultCachedResourceOptions(), std::nullopt, charset.isEmpty() ? document().charset() : WTFMove(charset));
m_cachedSheet = document().cachedResourceLoader().requestCSSStyleSheet(WTFMove(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;
document().styleScope().removePendingSheet();
#if ENABLE(XSLT)
if (m_isXSL)
document().styleScope().flushPendingUpdate();
#endif
}
}
}
}
示例2: compileStub
static void compileStub(
unsigned exitID, JITCode* jitCode, OSRExit& exit, VM* vm, CodeBlock* codeBlock)
{
StackMaps::Record* record = nullptr;
for (unsigned i = jitCode->stackmaps.records.size(); i--;) {
record = &jitCode->stackmaps.records[i];
if (record->patchpointID == exit.m_stackmapID)
break;
}
RELEASE_ASSERT(record->patchpointID == exit.m_stackmapID);
// This code requires framePointerRegister is the same as callFrameRegister
static_assert(MacroAssembler::framePointerRegister == GPRInfo::callFrameRegister, "MacroAssembler::framePointerRegister and GPRInfo::callFrameRegister must be the same");
CCallHelpers jit(vm, codeBlock);
// We need scratch space to save all registers, to build up the JS stack, to deal with unwind
// fixup, pointers to all of the objects we materialize, and the elements inside those objects
// that we materialize.
// Figure out how much space we need for those object allocations.
unsigned numMaterializations = 0;
size_t maxMaterializationNumArguments = 0;
for (ExitTimeObjectMaterialization* materialization : exit.m_materializations) {
numMaterializations++;
maxMaterializationNumArguments = std::max(
maxMaterializationNumArguments,
materialization->properties().size());
}
ScratchBuffer* scratchBuffer = vm->scratchBufferForSize(
sizeof(EncodedJSValue) * (
exit.m_values.size() + numMaterializations + maxMaterializationNumArguments) +
requiredScratchMemorySizeInBytes() +
codeBlock->calleeSaveRegisters()->size() * sizeof(uint64_t));
EncodedJSValue* scratch = scratchBuffer ? static_cast<EncodedJSValue*>(scratchBuffer->dataBuffer()) : 0;
EncodedJSValue* materializationPointers = scratch + exit.m_values.size();
EncodedJSValue* materializationArguments = materializationPointers + numMaterializations;
char* registerScratch = bitwise_cast<char*>(materializationArguments + maxMaterializationNumArguments);
uint64_t* unwindScratch = bitwise_cast<uint64_t*>(registerScratch + requiredScratchMemorySizeInBytes());
HashMap<ExitTimeObjectMaterialization*, EncodedJSValue*> materializationToPointer;
unsigned materializationCount = 0;
for (ExitTimeObjectMaterialization* materialization : exit.m_materializations) {
materializationToPointer.add(
materialization, materializationPointers + materializationCount++);
}
// Note that we come in here, the stack used to be as LLVM left it except that someone called pushToSave().
// We don't care about the value they saved. But, we do appreciate the fact that they did it, because we use
// that slot for saveAllRegisters().
saveAllRegisters(jit, registerScratch);
// Bring the stack back into a sane form and assert that it's sane.
jit.popToRestore(GPRInfo::regT0);
jit.checkStackPointerAlignment();
if (vm->m_perBytecodeProfiler && codeBlock->jitCode()->dfgCommon()->compilation) {
Profiler::Database& database = *vm->m_perBytecodeProfiler;
Profiler::Compilation* compilation = codeBlock->jitCode()->dfgCommon()->compilation.get();
Profiler::OSRExit* profilerExit = compilation->addOSRExit(
exitID, Profiler::OriginStack(database, codeBlock, exit.m_codeOrigin),
exit.m_kind, exit.m_kind == UncountableInvalidation);
jit.add64(CCallHelpers::TrustedImm32(1), CCallHelpers::AbsoluteAddress(profilerExit->counterAddress()));
}
// The remaining code assumes that SP/FP are in the same state that they were in the FTL's
// call frame.
// Get the call frame and tag thingies.
// Restore the exiting function's callFrame value into a regT4
jit.move(MacroAssembler::TrustedImm64(TagTypeNumber), GPRInfo::tagTypeNumberRegister);
jit.move(MacroAssembler::TrustedImm64(TagMask), GPRInfo::tagMaskRegister);
// Do some value profiling.
if (exit.m_profileDataFormat != DataFormatNone) {
record->locations[0].restoreInto(jit, jitCode->stackmaps, registerScratch, GPRInfo::regT0);
reboxAccordingToFormat(
exit.m_profileDataFormat, jit, GPRInfo::regT0, GPRInfo::regT1, GPRInfo::regT2);
if (exit.m_kind == BadCache || exit.m_kind == BadIndexingType) {
CodeOrigin codeOrigin = exit.m_codeOriginForExitProfile;
if (ArrayProfile* arrayProfile = jit.baselineCodeBlockFor(codeOrigin)->getArrayProfile(codeOrigin.bytecodeIndex)) {
jit.load32(MacroAssembler::Address(GPRInfo::regT0, JSCell::structureIDOffset()), GPRInfo::regT1);
jit.store32(GPRInfo::regT1, arrayProfile->addressOfLastSeenStructureID());
jit.load8(MacroAssembler::Address(GPRInfo::regT0, JSCell::indexingTypeOffset()), GPRInfo::regT1);
jit.move(MacroAssembler::TrustedImm32(1), GPRInfo::regT2);
jit.lshift32(GPRInfo::regT1, GPRInfo::regT2);
jit.or32(GPRInfo::regT2, MacroAssembler::AbsoluteAddress(arrayProfile->addressOfArrayModes()));
}
}
if (!!exit.m_valueProfile)
jit.store64(GPRInfo::regT0, exit.m_valueProfile.getSpecFailBucket(0));
}
//.........这里部分代码省略.........
示例3: compileRecovery
static void compileRecovery(
CCallHelpers& jit, const ExitValue& value, StackMaps::Record* record, StackMaps& stackmaps,
char* registerScratch,
const HashMap<ExitTimeObjectMaterialization*, EncodedJSValue*>& materializationToPointer)
{
switch (value.kind()) {
case ExitValueDead:
jit.move(MacroAssembler::TrustedImm64(JSValue::encode(jsUndefined())), GPRInfo::regT0);
break;
case ExitValueConstant:
jit.move(MacroAssembler::TrustedImm64(JSValue::encode(value.constant())), GPRInfo::regT0);
break;
case ExitValueArgument:
record->locations[value.exitArgument().argument()].restoreInto(
jit, stackmaps, registerScratch, GPRInfo::regT0);
break;
case ExitValueInJSStack:
case ExitValueInJSStackAsInt32:
case ExitValueInJSStackAsInt52:
case ExitValueInJSStackAsDouble:
jit.load64(AssemblyHelpers::addressFor(value.virtualRegister()), GPRInfo::regT0);
break;
case ExitValueRecovery:
record->locations[value.rightRecoveryArgument()].restoreInto(
jit, stackmaps, registerScratch, GPRInfo::regT1);
record->locations[value.leftRecoveryArgument()].restoreInto(
jit, stackmaps, registerScratch, GPRInfo::regT0);
switch (value.recoveryOpcode()) {
case AddRecovery:
switch (value.recoveryFormat()) {
case DataFormatInt32:
jit.add32(GPRInfo::regT1, GPRInfo::regT0);
break;
case DataFormatInt52:
jit.add64(GPRInfo::regT1, GPRInfo::regT0);
break;
default:
RELEASE_ASSERT_NOT_REACHED();
break;
}
break;
case SubRecovery:
switch (value.recoveryFormat()) {
case DataFormatInt32:
jit.sub32(GPRInfo::regT1, GPRInfo::regT0);
break;
case DataFormatInt52:
jit.sub64(GPRInfo::regT1, GPRInfo::regT0);
break;
default:
RELEASE_ASSERT_NOT_REACHED();
break;
}
break;
default:
RELEASE_ASSERT_NOT_REACHED();
break;
}
break;
case ExitValueMaterializeNewObject:
jit.loadPtr(materializationToPointer.get(value.objectMaterialization()), GPRInfo::regT0);
break;
default:
RELEASE_ASSERT_NOT_REACHED();
break;
}
reboxAccordingToFormat(
value.dataFormat(), jit, GPRInfo::regT0, GPRInfo::regT1, GPRInfo::regT2);
}
示例4: dump
void SamplingTool::dump(ExecState* exec)
{
// Tidies up SunSpider output by removing short scripts - such a small number of samples would likely not be useful anyhow.
if (m_sampleCount < 10)
return;
// (1) Build and sort 'opcodeSampleInfo' array.
OpcodeSampleInfo opcodeSampleInfo[numOpcodeIDs];
for (int i = 0; i < numOpcodeIDs; ++i) {
opcodeSampleInfo[i].opcode = static_cast<OpcodeID>(i);
opcodeSampleInfo[i].count = m_opcodeSamples[i];
opcodeSampleInfo[i].countInCTIFunctions = m_opcodeSamplesInCTIFunctions[i];
}
qsort(opcodeSampleInfo, numOpcodeIDs, sizeof(OpcodeSampleInfo), compareOpcodeIndicesSampling);
// (2) Print Opcode sampling results.
printf("\nOpcode samples [*]\n");
printf(" sample %% of %% of | cti cti %%\n");
printf("opcode count VM total | count of self\n");
printf("------------------------------------------------------- | ----------------\n");
for (int i = 0; i < numOpcodeIDs; ++i) {
long long count = opcodeSampleInfo[i].count;
if (!count)
continue;
OpcodeID opcode = opcodeSampleInfo[i].opcode;
const char* opcodeName = opcodeNames[opcode];
const char* opcodePadding = padOpcodeName(opcode, 28);
double percentOfVM = (static_cast<double>(count) * 100) / m_opcodeSampleCount;
double percentOfTotal = (static_cast<double>(count) * 100) / m_sampleCount;
long long countInCTIFunctions = opcodeSampleInfo[i].countInCTIFunctions;
double percentInCTIFunctions = (static_cast<double>(countInCTIFunctions) * 100) / count;
fprintf(stdout, "%s:%s%-6lld %.3f%%\t%.3f%%\t | %-6lld %.3f%%\n", opcodeName, opcodePadding, count, percentOfVM, percentOfTotal, countInCTIFunctions, percentInCTIFunctions);
}
printf("\n[*] Samples inside host code are not charged to any Opcode.\n\n");
printf("\tSamples inside VM:\t\t%lld / %lld (%.3f%%)\n", m_opcodeSampleCount, m_sampleCount, (static_cast<double>(m_opcodeSampleCount) * 100) / m_sampleCount);
printf("\tSamples inside host code:\t%lld / %lld (%.3f%%)\n\n", m_sampleCount - m_opcodeSampleCount, m_sampleCount, (static_cast<double>(m_sampleCount - m_opcodeSampleCount) * 100) / m_sampleCount);
printf("\tsample count:\tsamples inside this opcode\n");
printf("\t%% of VM:\tsample count / all opcode samples\n");
printf("\t%% of total:\tsample count / all samples\n");
printf("\t--------------\n");
printf("\tcti count:\tsamples inside a CTI function called by this opcode\n");
printf("\tcti %% of self:\tcti count / sample count\n");
// (3) Build and sort 'codeBlockSamples' array.
int scopeCount = m_scopeSampleMap->size();
Vector<ScopeSampleRecord*> codeBlockSamples(scopeCount);
ScopeSampleRecordMap::iterator iter = m_scopeSampleMap->begin();
for (int i = 0; i < scopeCount; ++i, ++iter)
codeBlockSamples[i] = iter->second;
qsort(codeBlockSamples.begin(), scopeCount, sizeof(ScopeSampleRecord*), compareScopeSampleRecords);
// (4) Print data from 'codeBlockSamples' array.
printf("\nCodeBlock samples\n\n");
for (int i = 0; i < scopeCount; ++i) {
ScopeSampleRecord* record = codeBlockSamples[i];
CodeBlock* codeBlock = record->m_codeBlock;
double blockPercent = (record->m_sampleCount * 100.0) / m_sampleCount;
if (blockPercent >= 1) {
Instruction* code = codeBlock->instructions.begin();
printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_scope->sourceURL().UTF8String().c_str(), codeBlock->lineNumberForVPC(code), record->m_sampleCount, m_sampleCount, blockPercent);
if (i < 10) {
HashMap<unsigned,unsigned> lineCounts;
codeBlock->dump(exec);
printf(" Opcode and line number samples [*]\n\n");
for (unsigned op = 0; op < record->m_size; ++op) {
int count = record->m_samples[op];
if (count) {
printf(" [% 4d] has sample count: % 4d\n", op, count);
unsigned line = codeBlock->lineNumberForVPC(code+op);
lineCounts.set(line, (lineCounts.contains(line) ? lineCounts.get(line) : 0) + count);
}
}
printf("\n");
int linesCount = lineCounts.size();
Vector<LineCountInfo> lineCountInfo(linesCount);
int lineno = 0;
for (HashMap<unsigned,unsigned>::iterator iter = lineCounts.begin(); iter != lineCounts.end(); ++iter, ++lineno) {
lineCountInfo[lineno].line = iter->first;
lineCountInfo[lineno].count = iter->second;
}
qsort(lineCountInfo.begin(), linesCount, sizeof(LineCountInfo), compareLineCountInfoSampling);
for (lineno = 0; lineno < linesCount; ++lineno) {
printf(" Line #%d has sample count %d.\n", lineCountInfo[lineno].line, lineCountInfo[lineno].count);
//.........这里部分代码省略.........
示例5: getFontData
FontData* CSSFontSelector::getFontData(const FontDescription& fontDescription, const AtomicString& familyName)
{
if (m_fontFaces.isEmpty()) {
if (familyName.startsWith("-webkit-"))
return fontDataForGenericFamily(m_document, fontDescription, familyName);
return 0;
}
String family = familyName.string();
Vector<RefPtr<CSSFontFace> >* familyFontFaces = m_fontFaces.get(family);
// If no face was found, then return 0 and let the OS come up with its best match for the name.
if (!familyFontFaces || familyFontFaces->isEmpty()) {
// If we were handed a generic family, but there was no match, go ahead and return the correct font based off our
// settings.
return fontDataForGenericFamily(m_document, fontDescription, familyName);
}
HashMap<unsigned, RefPtr<CSSSegmentedFontFace> >* segmentedFontFaceCache = m_fonts.get(family);
if (!segmentedFontFaceCache) {
segmentedFontFaceCache = new HashMap<unsigned, RefPtr<CSSSegmentedFontFace> >;
m_fonts.set(family, segmentedFontFaceCache);
}
FontTraitsMask traitsMask = fontDescription.traitsMask();
RefPtr<CSSSegmentedFontFace> face = segmentedFontFaceCache->get(traitsMask);
if (!face) {
face = CSSSegmentedFontFace::create(this);
segmentedFontFaceCache->set(traitsMask, face);
// Collect all matching faces and sort them in order of preference.
Vector<CSSFontFace*, 32> candidateFontFaces;
for (int i = familyFontFaces->size() - 1; i >= 0; --i) {
CSSFontFace* candidate = familyFontFaces->at(i).get();
unsigned candidateTraitsMask = candidate->traitsMask();
if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask))
continue;
if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask & FontVariantNormalMask))
continue;
#if ENABLE(SVG_FONTS)
// For SVG Fonts that specify that they only support the "normal" variant, we will assume they are incapable
// of small-caps synthesis and just ignore the font face as a candidate.
if (candidate->hasSVGFontFaceSource() && (traitsMask & FontVariantSmallCapsMask) && !(candidateTraitsMask & FontVariantSmallCapsMask))
continue;
#endif
candidateFontFaces.append(candidate);
}
if (Vector<RefPtr<CSSFontFace> >* familyLocallyInstalledFontFaces = m_locallyInstalledFontFaces.get(family)) {
unsigned numLocallyInstalledFontFaces = familyLocallyInstalledFontFaces->size();
for (unsigned i = 0; i < numLocallyInstalledFontFaces; ++i) {
CSSFontFace* candidate = familyLocallyInstalledFontFaces->at(i).get();
unsigned candidateTraitsMask = candidate->traitsMask();
if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask))
continue;
if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask & FontVariantNormalMask))
continue;
candidateFontFaces.append(candidate);
}
}
desiredTraitsMaskForComparison = traitsMask;
std::stable_sort(candidateFontFaces.begin(), candidateFontFaces.end(), compareFontFaces);
unsigned numCandidates = candidateFontFaces.size();
for (unsigned i = 0; i < numCandidates; ++i)
face->appendFontFace(candidateFontFaces[i]);
}
// We have a face. Ask it for a font data. If it cannot produce one, it will fail, and the OS will take over.
return face->getFontData(fontDescription);
}
示例6: testPut
void HashMapTest::testPut() {
{
HashMap<std::string, std::string> hashMap(101);
hashMap.put("KEY", "VALUE");
CPPUNIT_ASSERT_EQUAL_MESSAGE("Failed to install key/value pair",
std::string("VALUE"), hashMap.get("KEY"));
}
{
// Check my actual key instance is returned
HashMap<int, std::string> map;
for (int i = -32767; i < 32768; i++) {
map.put(i, "foobar");
}
int myKey = 0;
// Put a new value at the old key position
map.put(myKey, "myValue");
CPPUNIT_ASSERT(map.containsKey(myKey));
CPPUNIT_ASSERT_EQUAL(std::string("myValue"), map.get(myKey));
bool found = false;
Set<int>& intSet = map.keySet();
Pointer< Iterator<int> > itr(intSet.iterator());
while (itr->hasNext()) {
int key = itr->next();
found = (key == myKey);
if (found) {
break;
}
}
CPPUNIT_ASSERT_MESSAGE("Should find new key instance in hashashMap", found);
// Add a new key instance and check it is returned
CPPUNIT_ASSERT_NO_THROW(map.remove(myKey));
map.put(myKey, "myValue");
CPPUNIT_ASSERT(map.containsKey(myKey));
CPPUNIT_ASSERT_EQUAL(std::string("myValue"), map.get(myKey));
itr.reset(intSet.iterator());
while (itr->hasNext()) {
int key = itr->next();
found = (key == myKey);
if (found) {
break;
}
}
CPPUNIT_ASSERT_MESSAGE("Did not find new key instance in hashashMap", found);
}
{
// Ensure keys with identical hashcode are stored separately
HashMap<MyKey, std::string> map;
// Put non-equal object with same hashcode
MyKey aKey;
CPPUNIT_ASSERT(!map.containsKey(aKey));
map.put(aKey, "value");
MyKey aKey2;
CPPUNIT_ASSERT_THROW_MESSAGE(
"Should have thrown NoSuchElementException",
map.remove(aKey2),
NoSuchElementException);
MyKey aKey3;
map.put(aKey3, "foobar");
CPPUNIT_ASSERT_EQUAL(std::string("foobar"), map.get(aKey3));
CPPUNIT_ASSERT_EQUAL(std::string("value"), map.get(aKey));
}
}
示例7: createHTMLElementWrapper
gpointer createHTMLElementWrapper(PassRefPtr<WebCore::HTMLElement> element)
{
static HashMap<WTF::AtomicStringImpl*, CreateHTMLElementWrapperFunction> map;
if (map.isEmpty()) {
map.set(aTag.localName().impl(), createAnchorWrapper);
map.set(appletTag.localName().impl(), createAppletWrapper);
#if ENABLE(VIDEO)
map.set(audioTag.localName().impl(), createAudioWrapper);
#endif
map.set(areaTag.localName().impl(), createAreaWrapper);
map.set(baseTag.localName().impl(), createBaseWrapper);
map.set(basefontTag.localName().impl(), createBaseFontWrapper);
map.set(blockquoteTag.localName().impl(), createBlockquoteWrapper);
map.set(bodyTag.localName().impl(), createBodyWrapper);
map.set(brTag.localName().impl(), createBRWrapper);
map.set(buttonTag.localName().impl(), createButtonWrapper);
map.set(canvasTag.localName().impl(), createCanvasWrapper);
map.set(captionTag.localName().impl(), createTableCaptionWrapper);
map.set(colTag.localName().impl(), createTableColWrapper);
map.set(delTag.localName().impl(), createModWrapper);
map.set(dirTag.localName().impl(), createDirectoryWrapper);
map.set(divTag.localName().impl(), createDivWrapper);
map.set(dlTag.localName().impl(), createDListWrapper);
map.set(embedTag.localName().impl(), createEmbedWrapper);
map.set(fieldsetTag.localName().impl(), createFieldSetWrapper);
map.set(fontTag.localName().impl(), createFontWrapper);
map.set(formTag.localName().impl(), createFormWrapper);
map.set(frameTag.localName().impl(), createFrameWrapper);
map.set(framesetTag.localName().impl(), createFrameSetWrapper);
map.set(h1Tag.localName().impl(), createHeadingWrapper);
map.set(headTag.localName().impl(), createHeadWrapper);
map.set(hrTag.localName().impl(), createHRWrapper);
map.set(htmlTag.localName().impl(), createHtmlWrapper);
map.set(iframeTag.localName().impl(), createIFrameWrapper);
map.set(imgTag.localName().impl(), createImageWrapper);
map.set(inputTag.localName().impl(), createInputWrapper);
map.set(isindexTag.localName().impl(), createIsIndexWrapper);
map.set(labelTag.localName().impl(), createLabelWrapper);
map.set(legendTag.localName().impl(), createLegendWrapper);
map.set(liTag.localName().impl(), createLIWrapper);
map.set(linkTag.localName().impl(), createLinkWrapper);
map.set(mapTag.localName().impl(), createMapWrapper);
map.set(marqueeTag.localName().impl(), createMarqueeWrapper);
map.set(menuTag.localName().impl(), createMenuWrapper);
map.set(metaTag.localName().impl(), createMetaWrapper);
map.set(objectTag.localName().impl(), createObjectWrapper);
map.set(olTag.localName().impl(), createOListWrapper);
map.set(optgroupTag.localName().impl(), createOptGroupWrapper);
map.set(optionTag.localName().impl(), createOptionWrapper);
map.set(pTag.localName().impl(), createParagraphWrapper);
map.set(paramTag.localName().impl(), createParamWrapper);
map.set(preTag.localName().impl(), createPreWrapper);
map.set(qTag.localName().impl(), createQuoteWrapper);
map.set(scriptTag.localName().impl(), createScriptWrapper);
map.set(selectTag.localName().impl(), createSelectWrapper);
map.set(styleTag.localName().impl(), createStyleWrapper);
map.set(tableTag.localName().impl(), createTableWrapper);
map.set(tbodyTag.localName().impl(), createTableSectionWrapper);
map.set(tdTag.localName().impl(), createTableCellWrapper);
map.set(textareaTag.localName().impl(), createTextAreaWrapper);
map.set(titleTag.localName().impl(), createTitleWrapper);
map.set(trTag.localName().impl(), createTableRowWrapper);
map.set(ulTag.localName().impl(), createUListWrapper);
map.set(colgroupTag.localName().impl(), createTableColWrapper);
map.set(h2Tag.localName().impl(), createHeadingWrapper);
map.set(h3Tag.localName().impl(), createHeadingWrapper);
map.set(h4Tag.localName().impl(), createHeadingWrapper);
map.set(h5Tag.localName().impl(), createHeadingWrapper);
map.set(h6Tag.localName().impl(), createHeadingWrapper);
map.set(imageTag.localName().impl(), createImageWrapper);
map.set(insTag.localName().impl(), createModWrapper);
map.set(keygenTag.localName().impl(), createSelectWrapper);
map.set(listingTag.localName().impl(), createPreWrapper);
map.set(tfootTag.localName().impl(), createTableSectionWrapper);
map.set(thTag.localName().impl(), createTableCellWrapper);
map.set(theadTag.localName().impl(), createTableSectionWrapper);
map.set(xmpTag.localName().impl(), createPreWrapper);
}
CreateHTMLElementWrapperFunction createWrapperFunction =
map.get(element->localName().impl());
if (createWrapperFunction)
return createWrapperFunction(element);
return wrapHTMLElement(element.get());
}
示例8: getPostScriptName
static CFStringRef getPostScriptName(CFStringRef faceName, HDC dc)
{
const DWORD cMaxNameTableSize = 1024 * 1024;
static HashMap<String, RetainPtr<CFStringRef> > nameMap;
// Check our hash first.
String faceString(faceName);
RetainPtr<CFStringRef> result = nameMap.get(faceString);
if (result)
return result.get();
// We need to obtain the PostScript name from the name table and use it instead,.
DWORD bufferSize = GetFontData(dc, 'eman', 0, NULL, 0); // "name" backwards
if (bufferSize == 0 || bufferSize == GDI_ERROR || bufferSize > cMaxNameTableSize)
return NULL;
Vector<BYTE> bufferVector(bufferSize);
BYTE* buffer = bufferVector.data();
if (GetFontData(dc, 'eman', 0, buffer, bufferSize) == GDI_ERROR)
return NULL;
if (bufferSize < 6)
return NULL;
USHORT numberOfRecords = readBigEndianWord(buffer + 2);
UINT stringsOffset = readBigEndianWord(buffer + 4);
if (bufferSize < stringsOffset)
return NULL;
BYTE* strings = buffer + stringsOffset;
// Now walk each name record looking for a Mac or Windows PostScript name.
UINT offset = 6;
for (int i = 0; i < numberOfRecords; i++) {
if (bufferSize < offset + 12)
return NULL;
USHORT platformID = readBigEndianWord(buffer + offset);
USHORT encodingID = readBigEndianWord(buffer + offset + 2);
USHORT languageID = readBigEndianWord(buffer + offset + 4);
USHORT nameID = readBigEndianWord(buffer + offset + 6);
USHORT length = readBigEndianWord(buffer + offset + 8);
USHORT nameOffset = readBigEndianWord(buffer + offset + 10);
if (platformID == 3 && encodingID == 1 && languageID == 0x409 && nameID == 6) {
// This is a Windows PostScript name and is therefore UTF-16.
// Pass Big Endian as the encoding.
if (bufferSize < stringsOffset + nameOffset + length)
return NULL;
result.adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingUTF16BE, false));
break;
} else if (platformID == 1 && encodingID == 0 && languageID == 0 && nameID == 6) {
// This is a Mac PostScript name and is therefore ASCII.
// See http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html
if (bufferSize < stringsOffset + nameOffset + length)
return NULL;
result.adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingASCII, false));
break;
}
offset += 12;
}
if (result)
nameMap.set(faceString, result);
return result.get();
}