Lines Matching +full:higher +full:- +full:end
1 //===-- WindowsManifestMerger.cpp ------------------------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===---------------------------------------------------------------------===//
11 //===---------------------------------------------------------------------===//
60 {"urn:schemas-microsoft-com:asm.v1", "ms_asmv1"},
61 {"urn:schemas-microsoft-com:asm.v2", "ms_asmv2"},
62 {"urn:schemas-microsoft-com:asm.v3", "ms_asmv3"},
65 {"urn:schemas-microsoft-com:compatibility.v1", "ms_compatibilityv1"}};
88 for (xmlNodePtr Child = Parent->children; Child; Child = Child->next) { in getChildWithName()
89 if (xmlStringsEqual(Child->name, ElementName)) { in getChildWithName()
98 for (xmlAttrPtr Attribute = Node->properties; Attribute != nullptr; in getAttribute()
99 Attribute = Attribute->next) { in getAttribute()
100 if (xmlStringsEqual(Attribute->name, AttributeName)) { in getAttribute()
121 // Search for prefix-defined namespace specified by HRef, starting on Node and
125 for (xmlNsPtr Def = Node->nsDef; Def; Def = Def->next) { in search()
126 if (Def->prefix && xmlStringsEqual(Def->href, HRef)) { in search()
130 if (Node->parent) { in search()
131 return search(HRef, Node->parent); in search()
147 // Search for prefix-defined namespace specified by HRef, starting on Node and
149 // not found, then prefix-define that namespace on the node and return a
167 searchOrDefine(AdditionalAttribute->ns->href, OriginalNode); in copyAttributeNamespace()
170 OriginalAttribute->ns = std::move(ExplicitOrError.get()); in copyAttributeNamespace()
180 for (xmlNsPtr Def = Node->nsDef; Def; Def = Def->next) { in getNamespaceWithPrefix()
181 if (xmlStringsEqual(Def->prefix, Prefix)) { in getNamespaceWithPrefix()
194 if (Node->parent == nullptr) in getClosestDefault()
196 return getClosestDefault(Node->parent); in getClosestDefault()
202 // higher priority namespace is used for each attribute, EXCEPT in the case
204 // definition occurs closer than the higher priority one.
208 for (xmlAttrPtr Attribute = AdditionalNode->properties; Attribute; in mergeAttributes()
209 Attribute = Attribute->next) { in mergeAttributes()
211 getAttribute(OriginalNode, Attribute->name)) { in mergeAttributes()
212 if (!xmlStringsEqual(OriginalAttribute->children->content, in mergeAttributes()
213 Attribute->children->content)) { in mergeAttributes()
216 FROM_XML_CHAR(OriginalNode->name)); in mergeAttributes()
218 if (!Attribute->ns) { in mergeAttributes()
221 if (!OriginalAttribute->ns) { in mergeAttributes()
228 if (namespaceOverrides(OriginalAttribute->ns->href, in mergeAttributes()
229 Attribute->ns->href)) { in mergeAttributes()
230 // In this case, the original attribute has a higher priority namespace in mergeAttributes()
234 if (!OriginalAttribute->ns->prefix && !Attribute->ns->prefix && in mergeAttributes()
236 xmlStringsEqual(Attribute->ns->href, ClosestDefault->href)) { in mergeAttributes()
244 // This covers the case where the incoming attribute has the higher in mergeAttributes()
245 // priority. The higher priority namespace is applied in all cases in mergeAttributes()
249 if (Attribute->ns->prefix || OriginalAttribute->ns->prefix || in mergeAttributes()
250 (ClosestDefault && !xmlStringsEqual(OriginalAttribute->ns->href, in mergeAttributes()
251 ClosestDefault->href))) { in mergeAttributes()
261 // to the end of the properties list. Also explicitly apply its in mergeAttributes()
265 xmlNewProp(OriginalNode, Attribute->name, Attribute->children->content); in mergeAttributes()
267 searchOrDefine(Attribute->ns->href, OriginalNode); in mergeAttributes()
270 NewProp->ns = std::move(ExplicitOrError.get()); in mergeAttributes()
275 // Given two nodes, return the one with the higher priority namespace.
278 if (!Node1 || !Node1->ns) in getDominantNode()
280 if (!Node2 || !Node2->ns) in getDominantNode()
282 if (namespaceOverrides(Node1->ns->href, Node2->ns->href)) in getDominantNode()
289 return Node->ns && Node->ns != getNamespaceWithPrefix(Node->ns->prefix, Node); in hasInheritedNs()
295 return hasInheritedNs(Node) && Node->ns->prefix == nullptr; in hasInheritedDefaultNs()
300 return Node->ns && (Node->ns == getNamespaceWithPrefix(nullptr, Node)); in hasDefinedDefaultNamespace()
303 // For the given explicit prefix-definition of a namespace, travel downwards
314 if (Node->ns && xmlStringsEqual(Node->ns->href, PrefixDef->href) && in explicateNamespace()
316 Node->ns = PrefixDef; in explicateNamespace()
317 for (xmlAttrPtr Attribute = Node->properties; Attribute; in explicateNamespace()
318 Attribute = Attribute->next) { in explicateNamespace()
319 if (Attribute->ns && in explicateNamespace()
320 xmlStringsEqual(Attribute->ns->href, PrefixDef->href)) { in explicateNamespace()
321 Attribute->ns = PrefixDef; in explicateNamespace()
324 for (xmlNodePtr Child = Node->children; Child; Child = Child->next) { in explicateNamespace()
337 OriginalDefinedDefaultHref = xmlStrdup(OriginalDefinedDefaultNs->href); in mergeNamespaces()
341 // definition per node, so the higher priority one takes precedence in the in mergeNamespaces()
343 for (xmlNsPtr Def = AdditionalNode->nsDef; Def; Def = Def->next) { in mergeNamespaces()
345 getNamespaceWithPrefix(Def->prefix, OriginalNode)) { in mergeNamespaces()
346 if (!Def->prefix) { in mergeNamespaces()
347 if (namespaceOverrides(Def->href, OriginalNsDef->href)) { in mergeNamespaces()
348 NewDefinedDefaultHref = TO_XML_CHAR(strdup(FROM_XML_CHAR(Def->href))); in mergeNamespaces()
350 } else if (!xmlStringsEqual(OriginalNsDef->href, Def->href)) { in mergeNamespaces()
353 FROM_XML_CHAR(Def->prefix)); in mergeNamespaces()
357 NewDef->next = OriginalNode->nsDef; in mergeNamespaces()
358 OriginalNode->nsDef = NewDef; in mergeNamespaces()
362 // Check whether the original node or the incoming node has the higher in mergeNamespaces()
374 // the lower priority node ended up having a higher priority default in mergeNamespaces()
375 // definition. This can occur if the higher priority node is prefix in mergeNamespaces()
380 namespaceOverrides(NonDominantDefinedDefault->href, in mergeNamespaces()
390 // In this case the node with a higher priority namespace did not have a in mergeNamespaces()
398 if (DominantNode->parent) { in mergeNamespaces()
399 xmlNsPtr ClosestDefault = getClosestDefault(DominantNode->parent); in mergeNamespaces()
401 searchOrDefine(ClosestDefault->href, DominantNode); in mergeNamespaces()
414 NonDominantNode->ns = getNamespaceWithPrefix(nullptr, NonDominantNode); in mergeNamespaces()
421 searchOrDefine(DominantNode->ns->href, NonDominantNode); in mergeNamespaces()
426 NonDominantNode->ns = Explicit; in mergeNamespaces()
433 if (namespaceOverrides(DominantDefaultDefined->href, in mergeNamespaces()
453 searchOrDefine(ClosestDefault->href, NonDominantNode); in mergeNamespaces()
464 xmlFree(const_cast<unsigned char *>(OriginalNsDef->href)); in mergeNamespaces()
465 OriginalNsDef->href = NewDefinedDefaultHref; in mergeNamespaces()
481 return isRecognizedNamespace(Node->ns->href); in hasRecognizedNamespace()
491 Expected<xmlNsPtr> ExplicitOrError = searchOrDefine(Node->ns->href, Node); in reconcileNamespaces()
496 Node->ns = Explicit; in reconcileNamespaces()
498 for (xmlNodePtr Child = Node->children; Child; Child = Child->next) { in reconcileNamespaces()
508 // higher priority.
514 xmlNodePtr AdditionalFirstChild = AdditionalRoot->children; in treeMerge()
516 for (xmlNodePtr Child = AdditionalFirstChild; Child; Child = Child->next) { in treeMerge()
518 if (!isMergeableElement(Child->name) || in treeMerge()
520 getChildWithName(OriginalRoot, Child->name)) || in treeMerge()
522 StoreNext.next = Child->next; in treeMerge()
526 FROM_XML_CHAR(Child->name)); in treeMerge()
541 for (xmlNodePtr Child = Root->children; Child; Child = Child->next) { in stripComments()
542 if (!xmlStringsEqual(Child->name, TO_XML_CHAR("comment"))) { in stripComments()
546 StoreNext.next = Child->next; in stripComments()
558 for (xmlAttrPtr Attribute = Node->properties; Attribute; in setAttributeNamespaces()
559 Attribute = Attribute->next) { in setAttributeNamespaces()
560 if (!Attribute->ns) { in setAttributeNamespaces()
561 Attribute->ns = getClosestDefault(Node); in setAttributeNamespaces()
564 for (xmlNodePtr Child = Node->children; Child; Child = Child->next) { in setAttributeNamespaces()
573 for (xmlNodePtr Child = Node->children; Child; Child = Child->next) { in checkAndStripPrefixes()
576 if (Node->ns && Node->ns->prefix != nullptr) { in checkAndStripPrefixes()
579 xmlStringsEqual(ClosestDefault->href, Node->ns->href)) { in checkAndStripPrefixes()
580 Node->ns = ClosestDefault; in checkAndStripPrefixes()
581 } else if (!llvm::is_contained(RequiredPrefixes, Node->ns)) { in checkAndStripPrefixes()
582 RequiredPrefixes.push_back(Node->ns); in checkAndStripPrefixes()
585 for (xmlAttrPtr Attribute = Node->properties; Attribute; in checkAndStripPrefixes()
586 Attribute = Attribute->next) { in checkAndStripPrefixes()
587 if (Attribute->ns && Attribute->ns->prefix != nullptr) { in checkAndStripPrefixes()
590 xmlStringsEqual(ClosestDefault->href, Attribute->ns->href)) { in checkAndStripPrefixes()
591 Attribute->ns = ClosestDefault; in checkAndStripPrefixes()
592 } else if (!llvm::is_contained(RequiredPrefixes, Node->ns)) { in checkAndStripPrefixes()
593 RequiredPrefixes.push_back(Attribute->ns); in checkAndStripPrefixes()
599 for (xmlNsPtr Def = Node->nsDef; Def; Def = Def->next) { in checkAndStripPrefixes()
600 if (!Def->prefix || llvm::is_contained(RequiredPrefixes, Def)) { in checkAndStripPrefixes()
604 if (Def == Node->nsDef) { in checkAndStripPrefixes()
605 Node->nsDef = Def->next; in checkAndStripPrefixes()
607 Prev->next = Def->next; in checkAndStripPrefixes()
609 Temp.next = Def->next; in checkAndStripPrefixes()
643 if (!xmlStringsEqual(CombinedRoot->name, AdditionalRoot->name) || in merge()
644 !isMergeableElement(AdditionalRoot->name) || in merge()
673 xmlDocDumpFormatMemoryEnc(OutputDoc.get(), &Buff, &BufferSize, "UTF-8", 1); in getMergedManifest()
709 return Impl->merge(Manifest); in merge()
713 return Impl->getMergedManifest(); in getMergedManifest()
719 Merger->ParseErrorOccurred = true; in errorCallback()