style: Modify URLExtraData rust debug to include referrerInfo.

Differential Revision: https://phabricator.services.mozilla.com/D36475
This commit is contained in:
Thomas Nguyen 2019-07-16 15:03:40 +00:00 committed by Emilio Cobos Álvarez
parent 2ab9156401
commit 59cf10d1b0
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
2 changed files with 19 additions and 7 deletions

View file

@ -303,6 +303,11 @@ impl_threadsafe_refcount!(
bindings::Gecko_AddRefURLExtraDataArbitraryThread,
bindings::Gecko_ReleaseURLExtraDataArbitraryThread
);
impl_threadsafe_refcount!(
structs::nsIReferrerInfo,
bindings::Gecko_AddRefnsIReferrerInfoArbitraryThread,
bindings::Gecko_ReleasensIReferrerInfoArbitraryThread
);
impl_threadsafe_refcount!(
structs::nsIURI,
bindings::Gecko_AddRefnsIURIArbitraryThread,

View file

@ -178,20 +178,27 @@ impl UrlExtraData {
}
}
#[cfg(feature = "gecko")]
impl fmt::Debug for UrlExtraData {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
struct DebugURI(*mut structs::nsIURI);
impl fmt::Debug for DebugURI {
macro_rules! define_debug_struct {
($struct_name:ident, $gecko_class:ident, $debug_fn:ident) => {
struct $struct_name(*mut structs::$gecko_class);
impl fmt::Debug for $struct_name {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
use nsstring::nsCString;
let mut spec = nsCString::new();
unsafe {
bindings::Gecko_nsIURI_Debug(self.0, &mut spec);
bindings::$debug_fn(self.0, &mut spec);
}
spec.fmt(formatter)
}
}
}
}
#[cfg(feature = "gecko")]
impl fmt::Debug for UrlExtraData {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
define_debug_struct!(DebugURI, nsIURI, Gecko_nsIURI_Debug);
define_debug_struct!(DebugReferrerInfo, nsIReferrerInfo, Gecko_nsIReferrerInfo_Debug);
formatter
.debug_struct("URLExtraData")
@ -202,7 +209,7 @@ impl fmt::Debug for UrlExtraData {
)
.field(
"referrer",
&DebugURI(self.as_ref().mReferrer.raw::<structs::nsIURI>()),
&DebugReferrerInfo(self.as_ref().mReferrerInfo.raw::<structs::nsIReferrerInfo>()),
)
.finish()
}