Replace .unwrap() calls and sentinel values with safe null handling patterns to prevent runtime panics and improve code robustness.

Key Issues:

  1. Unsafe unwrapping: Using .unwrap() on operations that could fail, especially downcasts and IPC operations
  2. Sentinel values: Using invalid constants like Invalid or None = -1 instead of proper Option types
  3. Missing graceful degradation: Not handling None cases appropriately

Safe Patterns:

Example:

// ❌ Unsafe - could panic
let video_elem = self.downcast::<HTMLVideoElement>().unwrap();
video_elem.resize(width, height);

// ✅ Safe pattern
if let Some(video_elem) = self.downcast::<HTMLVideoElement>() {
    video_elem.resize(width, height);
}

// ❌ Sentinel value antipattern  
pub enum LargestContentfulPaintType {
    None = -1,
    // ...
}

// ✅ Proper Option usage
pub fn get_lcp_candidate() -> Option<LCPCandidate> {
    // ...
}

This prevents runtime crashes and makes null states explicit in the type system, improving both safety and code clarity.