Handle detached nodes in ComparePreorderTreePosition

The method now correctly handles detached nodes and nodes from different
Documents by checking the topmost ancestor during the depth calculation
in ComparePreorderTreePosition. If the two nodes do not share the same
Document as their topmost ancestor or if either is detached, return 0 to
indicate no relative preorder tree position without causing a
null-pointer dereference during the LCA search.

TAG=agy
CONV=57441e29-f47e-47f2-8367-dbfe2bf6e459

Fixed: 533050757
Change-Id: I09403b3294231594cb0d56f0e51f936c4272eb46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8083742
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1661286}
NOKEYCHECK=True
GitOrigin-RevId: 46e117af28cb5223fdade49a348e872c67efa981
3 files changed
tree: 7ff2618210fad89a1aaa346c7ea6f3cc20d84b1a
  1. abseil-cpp/
  2. agility-sdk/
  3. android_build_tools/
  4. android_deps/
  5. android_media/
  6. android_opengl/
  7. android_platform/
  8. android_prebuilts/
  9. android_provider/
  10. android_sdk/
  11. android_swipe_refresh/
  12. android_system_sdk/
  13. android_toolchain/
  14. androidx/
  15. androidx_javascriptengine/
  16. anonymous_tokens/
  17. aosp_dalvik/
  18. apache-portable-runtime/
  19. apache-win32/
  20. apple_apsl/
  21. arcore-android-sdk/
  22. arcore-android-sdk-client/
  23. aria-practices/
  24. axe-core/
  25. bidimapper/
  26. blink/
  27. boringssl/
  28. breakpad/
  29. brotli/
  30. byte_buddy/
  31. cardboard/
  32. cast_core/
  33. ced/
  34. checkstyle/
  35. chevron/
  36. chromevox/
  37. cld_3/
  38. cldr/
  39. closure_compiler/
  40. cloud_authenticator/
  41. colorama/
  42. compiler-rt/
  43. content_analysis_sdk/
  44. coremltools/
  45. cpu_features/
  46. cpuinfo/
  47. crabbyavif/
  48. crashpad/
  49. crc32c/
  50. cros-components/
  51. d3/
  52. dav1d/
  53. dbus/
  54. decklink/
  55. devscripts/
  56. devtools-frontend/
  57. disarm/
  58. dom_distiller_js/
  59. domato/
  60. dpkg-shlibdeps/
  61. dragonbox/
  62. eigen3/
  63. emoji-metadata/
  64. emoji-segmenter/
  65. enterprise_companion/
  66. expat/
  67. fadec/
  68. farmhash/
  69. fast_float/
  70. fdlibm/
  71. federated_compute/
  72. fft2d/
  73. flatbuffers/
  74. flex/
  75. fontconfig/
  76. fp16/
  77. freetype/
  78. fuchsia-gn-sdk/
  79. fuchsia-sdk/
  80. fusejs/
  81. fuzztest/
  82. fxdiv/
  83. gemmlowp/
  84. gif_player/
  85. glfw/
  86. glib/
  87. glslang/
  88. google-closure-library/
  89. google-java-format/
  90. google-truth/
  91. google_benchmark/
  92. google_input_tools/
  93. googlefonts_testdata/
  94. googletest/
  95. grpc/
  96. grpc-java/
  97. gsettings-desktop-schemas/
  98. gvdb/
  99. hamcrest/
  100. harfbuzz/
  101. highway/
  102. hunspell/
  103. hyphenation-patterns/
  104. iaccessible2/
  105. iamf_tools/
  106. icu4j/
  107. ijar/
  108. ink/
  109. inspector_protocol/
  110. ipcz/
  111. isimpledom/
  112. jacoco/
  113. javalang/
  114. jdk/
  115. jdk11/
  116. jetstream/
  117. jinja2/
  118. jni_zero/
  119. js_code_coverage/
  120. jsoncpp/
  121. junit/
  122. khronos/
  123. kotlin_stdlib/
  124. kotlinc/
  125. lens_server_proto/
  126. leveldatabase/
  127. libaddressinput/
  128. libaom/
  129. libbrlapi/
  130. libc++/
  131. libc++abi/
  132. libdisplay-info/
  133. libdmg-hfsplus/
  134. libdrm/
  135. libei/
  136. libFuzzer/
  137. libgav1/
  138. libgudev/
  139. libinput/
  140. libipp/
  141. libjingle_xmpp/
  142. liblouis/
  143. libpfm4/
  144. libphonenumber/
  145. libpng/
  146. libprotobuf-mutator/
  147. libsecret/
  148. libsync/
  149. libtess2/
  150. libunwind/
  151. liburlpattern/
  152. libusb/
  153. libva-fake-driver/
  154. libva_protected_content/
  155. libvpx/
  156. libwebm/
  157. libwebp/
  158. libx11/
  159. libxcb-keysyms/
  160. libxml/
  161. libxslt/
  162. libzip/
  163. lit/
  164. litert/
  165. llvm-libc/
  166. logdog/
  167. logilab/
  168. lottie/
  169. lzma_sdk/
  170. mako/
  171. markdown/
  172. markupsafe/
  173. material_color_utilities/
  174. material_web_components/
  175. maven/
  176. mediapipe/
  177. metrics_proto/
  178. microsoft_dxheaders/
  179. microsoft_webauthn/
  180. mig/
  181. minigbm/
  182. ml_dtypes/
  183. mockito/
  184. modp_b64/
  185. mutter/
  186. nearby/
  187. neon_2_sse/
  188. netty-tcnative/
  189. netty4/
  190. nlohmann_json/
  191. node/
  192. oak/
  193. ocmock/
  194. omnibox_proto/
  195. one_euro_filter/
  196. openh264/
  197. openscreen/
  198. openxr/
  199. opus/
  200. ots/
  201. pefile_py3/
  202. pffft/
  203. pipewire/
  204. ply/
  205. polymer/
  206. private-join-and-compute/
  207. private_membership/
  208. protobuf/
  209. protobuf-javascript/
  210. pthreadpool/
  211. puffin/
  212. pycoverage/
  213. pyjson5/
  214. pylint/
  215. pywebsocket3/
  216. pyyaml/
  217. quic_trace/
  218. r8/
  219. rapidhash/
  220. re2/
  221. readability/
  222. requests/
  223. rjsmin/
  224. rnnoise/
  225. robolectric/
  226. rust/
  227. ruy/
  228. s2cellid/
  229. screen-ai/
  230. search_engines_data/
  231. securemessage/
  232. selenium-atoms/
  233. sentencepiece/
  234. sframe/
  235. shell-encryption/
  236. simdutf/
  237. simplejson/
  238. siso/
  239. six/
  240. smhasher/
  241. snappy/
  242. speech-dispatcher/
  243. speedometer/
  244. spirv-cross/
  245. spirv-headers/
  246. spirv-tools/
  247. sqlite/
  248. sqlite4java/
  249. subresource-filter-ruleset/
  250. swift-toolchain/
  251. tensorflow-text/
  252. tensorflow_models/
  253. test_fonts/
  254. text-fragments-polyfill/
  255. tflite/
  256. tflite_support/
  257. turbine/
  258. typescript/
  259. ukey2/
  260. unrar/
  261. updater/
  262. usb_ids/
  263. utf/
  264. v4l-utils/
  265. vulkan-headers/
  266. vulkan-loader/
  267. vulkan-tools/
  268. vulkan-utility-libraries/
  269. vulkan-validation-layers/
  270. wayland/
  271. wayland-protocols/
  272. webdriver/
  273. webgl/
  274. webgpu-cts/
  275. webrtc_overrides/
  276. webview2/
  277. webxr_test_pages/
  278. weston/
  279. widevine/
  280. win_build_output/
  281. win_virtual_display/
  282. windows_app_sdk_headers/
  283. wireplumber/
  284. woff2/
  285. wpt_tools/
  286. wtl/
  287. wuffs/
  288. x11proto/
  289. xcbproto/
  290. xnnpack/
  291. zlib/
  292. zstd/
  293. zxcvbn-cpp/
  294. .clang-format-ignore
  295. .gitignore
  296. .swift-format-ignore
  297. BUILD.gn
  298. DEPS
  299. libjpeg.gni
  300. OWNERS
  301. PRESUBMIT.py
  302. README.chromium.template
  303. README.md
README.md

The third_party directory contains sources from other projects.

For guidelines on adding a new package to the third_party directory can be found at //docs/adding_to_third_party.md