Make IE driver calculate viewport with window.innerHeight/Width instead of documentElement
@@ -1211,22 +1211,39 @@ bool Element::GetClickableViewPortLocation(const bool document_contains_frames,
return false;
}
-
long window_width = window_info.rcClient.right - window_info.rcClient.left;
long window_height = window_info.rcClient.bottom - window_info.rcClient.top;
// If we're not on the top-level document, we can assume that the view port
// includes the entire client window, since scrollIntoView should do the
// right thing and make it visible. Otherwise, we prefer getting the view
- // port size by getting documentElement.clientHeight and .clientWidth.
+ // port size by either getting the window.innerWidth and .innerHeight, or
+ // by using documentElement.clientHeight and .clientWidth.
if (!document_contains_frames) {
CComPtr<IHTMLDocument2> doc;
int status_code = this->GetContainingDocument(false, &doc);
if (status_code == WD_SUCCESS) {
+ bool used_window_properties = false;
+ CComPtr<IHTMLWindow2> parent_window;
+ HRESULT hr = doc->get_parentWindow(&parent_window);
+ if (SUCCEEDED(hr) && parent_window) {
+ CComPtr<IHTMLWindow7> window;
+ hr = parent_window->QueryInterface<IHTMLWindow7>(&window);
+ if (SUCCEEDED(hr) && window) {
+ window->get_innerHeight(&window_height);
+ window->get_innerWidth(&window_width);
+ used_window_properties = true;
+ }
+ }
+
+ // If using the window object's innerWidth and innerHeight properties
+ // failed, then fall back to the document element's clientWidth and
+ // clientHeight properties.
+ if (!used_window_properties) {
int document_mode = DocumentHost::GetDocumentMode(doc);
CComPtr<IHTMLDocument3> document_element_doc;
CComPtr<IHTMLElement> document_element;
- HRESULT hr = doc->QueryInterface<IHTMLDocument3>(&document_element_doc);
+ hr = doc->QueryInterface<IHTMLDocument3>(&document_element_doc);
if (SUCCEEDED(hr) && document_element_doc) {
hr = document_element_doc->get_documentElement(&document_element);
}
@@ -1254,6 +1271,7 @@ bool Element::GetClickableViewPortLocation(const bool document_contains_frames,
}
}
}
+ }
// Hurrah! Now we know what the visible area of the viewport is
// N.B. There is an n-pixel sized area next to the client area border
