X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7cf41a5d66bec0a1297f1417852647aa353a148f..a738f87caeafd5e51fc029a6228c540e942505b7:/src/html/htmltag.cpp diff --git a/src/html/htmltag.cpp b/src/html/htmltag.cpp index 6686cb9cba..05b9c77a25 100644 --- a/src/html/htmltag.cpp +++ b/src/html/htmltag.cpp @@ -17,15 +17,15 @@ #include "wx/html/htmltag.h" -#ifndef WXPRECOMP +#ifndef WX_PRECOMP #include "wx/colour.h" + #include "wx/wxcrtvararg.h" #endif #include "wx/html/htmlpars.h" #include // for vsscanf #include - //----------------------------------------------------------------------------- // wxHtmlTagsCache //----------------------------------------------------------------------------- @@ -68,11 +68,18 @@ wxHtmlTagsCache::wxHtmlTagsCache(const wxString& source) m_CacheSize = 0; m_CachePos = 0; - int pos = 0; - while (pos < lng) + for ( int pos = 0; pos < lng; pos++ ) { if (src[pos] == wxT('<')) // tag found: { + // don't cache comment tags + wxString::const_iterator iter = source.begin() + pos; + if ( wxHtmlParser::SkipCommentTag(iter, source.end()) ) + { + pos = iter - source.begin(); + continue; + } + if (m_CacheSize % CACHE_INCREMENT == 0) m_Cache = (wxHtmlCacheItem*) realloc(m_Cache, (m_CacheSize + CACHE_INCREMENT) * sizeof(wxHtmlCacheItem)); int tg = m_CacheSize++; @@ -169,8 +176,6 @@ wxHtmlTagsCache::wxHtmlTagsCache(const wxString& source) } } } - - pos++; } // ok, we're done, now we'll free .Name members of cache - we don't need it anymore: @@ -402,7 +407,15 @@ wxString wxHtmlTag::GetParam(const wxString& par, bool with_commas) const } int wxHtmlTag::ScanParam(const wxString& par, - const wxChar *format, + const char *format, + void *param) const +{ + wxString parval = GetParam(par); + return wxSscanf(parval, format, param); +} + +int wxHtmlTag::ScanParam(const wxString& par, + const wchar_t *format, void *param) const { wxString parval = GetParam(par); @@ -411,18 +424,16 @@ int wxHtmlTag::ScanParam(const wxString& par, bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const { - wxASSERT(clr); - wxString str = GetParam(par); + wxCHECK_MSG( clr, false, _T("invalid colour argument") ); - if (clr->Set(str)) - return true; + wxString str = GetParam(par); - if (!str.empty()) + // handle colours defined in HTML 4.0 first: + if (str.length() > 1 && str[0] != _T('#')) { - // Handle colours defined in HTML 4.0: - #define HTML_COLOUR(name,r,g,b) \ + #define HTML_COLOUR(name, r, g, b) \ if (str.IsSameAs(wxT(name), false)) \ - { *clr = wxColour(r,g,b); return true; } + { clr->Set(r, g, b); return true; } HTML_COLOUR("black", 0x00,0x00,0x00) HTML_COLOUR("silver", 0xC0,0xC0,0xC0) HTML_COLOUR("gray", 0x80,0x80,0x80) @@ -442,6 +453,13 @@ bool wxHtmlTag::GetParamAsColour(const wxString& par, wxColour *clr) const #undef HTML_COLOUR } + // then try to parse #rrggbb representations or set from other well + // known names (note that this doesn't strictly conform to HTML spec, + // but it doesn't do real harm -- but it *must* be done after the standard + // colors are handled above): + if (clr->Set(str)) + return true; + return false; }