]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/htmlwin.cpp
Added typeinfo.h which implements wxTypeId, using C++ RTTI if available. wxAny and...
[wxWidgets.git] / src / html / htmlwin.cpp
index 8fedf6c9992b44812f81037e31d592039e661525..636a07610f699b55e6b2113f5e774264aa207dde 100644 (file)
@@ -338,8 +338,9 @@ bool wxHtmlWindow::Create(wxWindow *parent, wxWindowID id,
     // at all so disable it to avoid executing any user-defined handlers twice
     // (and to avoid processing unnecessary event if no handlers are defined).
     SetBackgroundStyle(wxBG_STYLE_PAINT);
-
     SetPage(wxT("<html><body></body></html>"));
+
+    SetInitialSize(size);
     return true;
 }
 
@@ -467,8 +468,14 @@ bool wxHtmlWindow::DoSetPage(const wxString& source)
     SetBackgroundImage(wxNullBitmap);
 
     m_Parser->SetDC(dc);
-
-    delete m_Cell;
+    if (m_Cell)
+    {
+        delete m_Cell;
+        // notice that it's important to set m_Cell to NULL here before calling
+        // Parse() below, even if it will be overwritten by its return value:
+        // without this we may crash if it's used from inside Parse()
+        m_Cell = NULL;
+    }
     m_Cell = (wxHtmlContainerCell*) m_Parser->Parse(newsrc);
     delete dc;
     m_Cell->SetIndent(m_Borders, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS);
@@ -650,6 +657,16 @@ bool wxHtmlWindow::ScrollToAnchor(const wxString& anchor)
     }
     else
     {
+        // Go to next visible cell in current container, if it exists. This
+        // yields a bit better (even though still imperfect) results in that
+        // there's better chance of using a suitable cell for upper Y
+        // coordinate value. See bug #11406 for additional discussion.
+        const wxHtmlCell *c_save = c;
+        while ( c && c->IsFormattingCell() )
+            c = c->GetNext();
+        if ( !c )
+            c = c_save;
+
         int y;
 
         for (y = 0; c != NULL; c = c->GetParent()) y += c->GetPosY();