tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

dom.rs (1191B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
      4 
      5 //! Types used to access the DOM from style calculation.
      6 
      7 /// An opaque handle to a node, which, unlike UnsafeNode, cannot be transformed
      8 /// back into a non-opaque representation. The only safe operation that can be
      9 /// performed on this node is to compare it to another opaque handle or to another
     10 /// OpaqueNode.
     11 ///
     12 /// Layout and Graphics use this to safely represent nodes for comparison purposes.
     13 /// Because the script task's GC does not trace layout, node data cannot be safely stored in layout
     14 /// data structures. Also, layout code tends to be faster when the DOM is not being accessed, for
     15 /// locality reasons. Using `OpaqueNode` enforces this invariant.
     16 #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq)]
     17 #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
     18 pub struct OpaqueNode(pub usize);
     19 
     20 impl OpaqueNode {
     21    /// Returns the address of this node, for debugging purposes.
     22    #[inline]
     23    pub fn id(&self) -> usize {
     24        self.0
     25    }
     26 }