Small IE capture stability fixes, still most likely no solution to #3557520 and #3557508. In general the code need to be tested with IE9!!!

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1988 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-08-15 10:32:25 +00:00
commit 310c492da1
2 changed files with 25 additions and 12 deletions

View file

@ -250,8 +250,8 @@ namespace Greenshot.Helpers {
} }
} }
} catch (Exception e) { } catch (Exception e) {
LOG.ErrorFormat("Major problem: Problem retrieving Document from {0}", ieWindow.Text);
LOG.Error(e); LOG.Error(e);
LOG.DebugFormat("Major problem: Problem retrieving Document from {0}", ieWindow.Text);
} }
} }
@ -262,7 +262,12 @@ namespace Greenshot.Helpers {
returnWindow.GetParent(); returnWindow.GetParent();
// Create the container // Create the container
returnDocumentContainer = new DocumentContainer(returnDocument2, returnWindow); try {
returnDocumentContainer = new DocumentContainer(returnDocument2, returnWindow);
} catch (Exception e) {
LOG.Error("Major problem: Problem retrieving Document.");
LOG.Error(e);
}
} }
if (returnDocumentContainer == null && alternativeReturnDocument2 != null) { if (returnDocumentContainer == null && alternativeReturnDocument2 != null) {
@ -270,7 +275,12 @@ namespace Greenshot.Helpers {
alternativeReturnWindow.Restore(); alternativeReturnWindow.Restore();
alternativeReturnWindow.GetParent(); alternativeReturnWindow.GetParent();
// Create the container // Create the container
returnDocumentContainer = new DocumentContainer(alternativeReturnDocument2, alternativeReturnWindow); try {
returnDocumentContainer = new DocumentContainer(alternativeReturnDocument2, alternativeReturnWindow);
} catch (Exception e) {
LOG.Error("Major problem: Problem retrieving Document.");
LOG.Error(e);
}
} }
return returnDocumentContainer; return returnDocumentContainer;
} }
@ -291,7 +301,7 @@ namespace Greenshot.Helpers {
/// <returns>ICapture with the content (if any)</returns> /// <returns>ICapture with the content (if any)</returns>
public static ICapture CaptureIE(ICapture capture, WindowDetails windowToCapture) { public static ICapture CaptureIE(ICapture capture, WindowDetails windowToCapture) {
if (windowToCapture == null) { if (windowToCapture == null) {
return CaptureIE(capture, WindowDetails.GetActiveWindow()); windowToCapture = WindowDetails.GetActiveWindow();
} }
// Show backgroundform after retrieving the active window.. // Show backgroundform after retrieving the active window..
BackgroundForm backgroundForm = new BackgroundForm(Language.GetString(LangKey.contextmenu_captureie), Language.GetString(LangKey.wait_ie_capture)); BackgroundForm backgroundForm = new BackgroundForm(Language.GetString(LangKey.contextmenu_captureie), Language.GetString(LangKey.wait_ie_capture));

View file

@ -142,10 +142,14 @@ namespace Greenshot.Helpers.IEInterop {
// Check what access method is needed for the document // Check what access method is needed for the document
IHTMLDocument5 document5 = (IHTMLDocument5)document2; IHTMLDocument5 document5 = (IHTMLDocument5)document2;
//compatibility mode affects how height is computed //compatibility mode affects how height is computed
if ((document3.documentElement != null) && (!document5.compatMode.Equals("BackCompat"))) { isDTD = false;
isDTD = true; try {
} else { if ((document3.documentElement != null) && (!document5.compatMode.Equals("BackCompat"))) {
isDTD = false; isDTD = true;
}
} catch (Exception ex) {
LOG.Error("Error checking the compatibility mode:");
LOG.Error(ex);
} }
Rectangle clientRectangle = contentWindow.WindowRectangle; Rectangle clientRectangle = contentWindow.WindowRectangle;
try { try {
@ -183,17 +187,14 @@ namespace Greenshot.Helpers.IEInterop {
} }
} }
LOG.DebugFormat("Zoomlevel {0}, {1}", zoomLevelX, zoomLevelY); LOG.DebugFormat("Zoomlevel {0}, {1}", zoomLevelX, zoomLevelY);
} catch (Exception e) { } catch (Exception e) {
LOG.Warn("Can't get certain properties for documents, using default. due to: ", e); LOG.Warn("Can't get certain properties for documents, using default. due to: ", e);
} }
LOG.DebugFormat("Calculated location {0} for {1}", startLocation, document2.title);
sourceLocation = new Point(ScaleX((int)startLocation.X), ScaleY((int)startLocation.Y));
destinationLocation = new Point(ScaleX((int)startLocation.X), ScaleY((int)startLocation.Y));
try { try {
LOG.DebugFormat("Calculated location {0} for {1}", startLocation, document2.title);
if (name == null) { if (name == null) {
name = document2.title; name = document2.title;
} }
@ -203,6 +204,8 @@ namespace Greenshot.Helpers.IEInterop {
url = document2.url; url = document2.url;
} catch { } catch {
} }
sourceLocation = new Point(ScaleX((int)startLocation.X), ScaleY((int)startLocation.Y));
destinationLocation = new Point(ScaleX((int)startLocation.X), ScaleY((int)startLocation.Y));
if (parent != null) { if (parent != null) {
return; return;