Repository: servo/servo
File: components/script/dom/document_embedder_controls.rs (Rust)

Code before:
        if let Some(anchor_element) = anchor_element.as_ref() {
            info.flags.insert(ContextMenuElementInformationFlags::Link);
            info.link_url = document
                .base_url()
                .join(&anchor_element.Href())
                .map(|url| url.as_url().clone())
                .ok();

            items.extend(vec![
                ContextMenuItem::Item {
                    label: "Open Link in New View".into(),
                    action: ContextMenuAction::OpenLinkInNewWebView,
                    enabled: true,
                },
                ContextMenuItem::Item {
                    label: "Copy Link".into(),
                    action: ContextMenuAction::CopyLink,
                    enabled: true,
                },
                ContextMenuItem::Separator,
            ]);
        }

        if let Some(image_element) = image_element.as_ref() {
            info.flags.insert(ContextMenuElementInformationFlags::Image);
            info.image_url = document
                .base_url()
                .join(&image_element.Src())
                .map(|url| url.as_url().clone())
                .ok();

            items.extend(vec![
                ContextMenuItem::Item {
                    label: "Open Image in New View".into(),
                    action: ContextMenuAction::OpenImageInNewView,
                    enabled: true,
                },
                ContextMenuItem::Item {
                    label: "Copy Image Link".into(),
                    action: ContextMenuAction::CopyImageLink,
                    enabled: true,
                },
                ContextMenuItem::Separator,
            ]);
        }

        if let Some(text_input_element) = &text_input_element {
            let has_selection = text_input_element.has_selection();

            info.flags
                .insert(ContextMenuElementInformationFlags::EditableText);

Review comment (suggestion):
Can you expose a method to return https://github.com/servo/servo/blob/8e0c2d57504b88ec145198d6821ebfb88e3e5c71/components/script/dom/html/htmlimageelement.rs#L1526 instead of using Src()? That will make responsive images less surprising.

Code after:
            info.link_url = anchor_element
                .full_href_url_for_user_interface()
                .map(ServoUrl::into_url);

            items.extend(vec![
                ContextMenuItem::Item {
                    label: "Open Link in New View".into(),
                    action: ContextMenuAction::OpenLinkInNewWebView,
                    enabled: true,
                },
                ContextMenuItem::Item {
                    label: "Copy Link".into(),
                    action: ContextMenuAction::CopyLink,
                    enabled: true,
                },
                ContextMenuItem::Separator,
            ]);
        }

        if let Some(image_element) = image_element.as_ref() {
            info.flags.insert(ContextMenuElementInformationFlags::Image);
            info.image_url = image_element
                .full_image_url_for_user_interface()
                .map(ServoUrl::into_url);

            items.extend(vec![
                ContextMenuItem::Item {
                    label: "Open Image in New View".into(),
                    action: ContextMenuAction::OpenImageInNewView,
                    enabled: true,
                },
                ContextMenuItem::Item {
                    label: "Copy Image Link".into(),
                    action: ContextMenuAction::CopyImageLink,
                    enabled: true,
                },
                ContextMenuItem::Separator,
            ]);
        }

        if let Some(text_input_element) = &text_input_element {
            let has_selection = text_input_element.has_selection();

            info.flags
                .insert(ContextMenuElementInformationFlags::EditableText);
            if has_selection {
                info.flags
                    .insert(ContextMenuElementInformationFlags::Selection);
            }

            items.extend(vec![