1

this is a continuation of the question (http://goo.gl/a61CG).

I'm trying to retrieve the visible size of the DOM window or document ( not sure which term is correct ) which contains the plugin. I have been studying the Firebreath's reference but I'm coming up short of an answer.

For instance inside onWindowAttached I do this:

m_host->htmlLog("Attaching window.");

FB::DOM::ElementPtr element_ptr(m_host->getDOMElement());
if( element_ptr )
{
    int Width  = element_ptr->getWidth();
    int Height = element_ptr->getHeight();

    std::stringstream ss;
    ss << "width: " << Width << "; height: " << Height << std::endl;
    m_host->htmlLog(ss.str());
}

FB::DOM::ElementPtr parent_element_ptr = element_ptr->getParentNode();
if( parent_element_ptr )
{
    int Width  = parent_element_ptr->getWidth();
    int Height = parent_element_ptr->getHeight();

    std::stringstream ss;
    ss << "parent props: width: " << Width << "; height: " << Height << std::endl;
    m_host->htmlLog(ss.str());
}

m_host->htmlLog("Finished attaching window.");

Google Chrome ( v.23 ) give me this now:

Attaching window.
width: 300; height: 300

Finished attaching window.

The 300x300 pixels refers to the size of the hmtl object which orders the browser the load the plugin.

So, what is the way to retrieve the visible area of the browser window that contains a plugin?

I'm using a recent firebreath trunk version on Windows 7 and Visual Studio 2010.

Thanks, Christian

chhenning
  • 2,017
  • 3
  • 26
  • 44

1 Answers1

1

Basically what you should be looking for is not actually how to do this with firebreath specifically, but how to do it with javascript. Then you just do the same thing using the DOM element / window / document abstractions.

Many people don't realize that the best browser plugins developers are the ones who understand javascript really well also.

See screen width vs visible portion

Now, you'll want to make sure you test this on all browsers; some properties IE doesn't expose through IDispatch (which is what FireBreath uses by default) in which case a custom handler may need to be added to the DOM abstraction; talk to me on IRC if that's the case (http://npapi.com/chat) and I'll help you.

Community
  • 1
  • 1
taxilian
  • 14,229
  • 4
  • 34
  • 73