From 56cc299b8d2624a59592d81440fdd86fee9d11b5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 30 Oct 2024 13:51:21 +0300 Subject: useless crutch removed --- plugins/NewStory/src/history_array.cpp | 6 ------ plugins/NewStory/src/history_control.cpp | 20 ++++++++++---------- plugins/NewStory/src/history_control.h | 2 -- plugins/NewStory/src/webpage.cpp | 14 ++++---------- 4 files changed, 14 insertions(+), 28 deletions(-) (limited to 'plugins/NewStory') diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index c510c0f7f8..3d81d77b4b 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -470,12 +470,6 @@ void ItemData::setText(const wchar_t *pwszText) { savedHeight = -1; - int fontid, colorid; - getFontColor(fontid, colorid); - - pOwner->webPage.clText = g_fontTable[fontid].cl; - pOwner->webPage.clBack = g_colorTable[colorid].cl; - T2Utf szFormattedBody(formatHtml(pwszText)); if (szFormattedBody) m_doc = litehtml::document::createFromString(litehtml::estring(szFormattedBody.get(), litehtml::encoding::utf_8), &pOwner->webPage); diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index fb55dee379..a944053381 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -727,23 +727,23 @@ void NewstoryListData::Paint(simpledib::dib &dib) auto *pItem = LoadItem(idx); pItem->calcHeight(cachedWindowWidth); // ensure that the item's height is calculated - COLORREF clLine; + COLORREF clLine, clText, clBack; int fontid, colorid; pItem->getFontColor(fontid, colorid); if (pItem->m_bHighlighted) { - webPage.clText = g_fontTable[FONT_HIGHLIGHT].cl; - webPage.clBack = g_colorTable[pItem->m_bSelected ? COLOR_SELBACK : COLOR_HIGHLIGHT_BACK].cl; + clText = g_fontTable[FONT_HIGHLIGHT].cl; + clBack = g_colorTable[pItem->m_bSelected ? COLOR_SELBACK : COLOR_HIGHLIGHT_BACK].cl; clLine = g_colorTable[COLOR_FRAME].cl; } else if (pItem->m_bSelected && !bReadOnly) { - webPage.clText = g_colorTable[COLOR_SELTEXT].cl; - webPage.clBack = g_colorTable[COLOR_SELBACK].cl; + clText = g_colorTable[COLOR_SELTEXT].cl; + clBack = g_colorTable[COLOR_SELBACK].cl; clLine = g_colorTable[COLOR_SELFRAME].cl; } else { - webPage.clText = g_fontTable[fontid].cl; - webPage.clBack = g_colorTable[colorid].cl; + clText = g_fontTable[fontid].cl; + clBack = g_colorTable[colorid].cl; clLine = g_colorTable[COLOR_FRAME].cl; } @@ -759,7 +759,7 @@ void NewstoryListData::Paint(simpledib::dib &dib) } // draw item background - HBRUSH hbr = CreateSolidBrush(webPage.clBack); + HBRUSH hbr = CreateSolidBrush(clBack); RECT rc = { 0, top, cachedWindowWidth, top + iItemHeigth }; FillRect(dib, &rc, hbr); DeleteObject(hbr); @@ -832,10 +832,10 @@ void NewstoryListData::Paint(simpledib::dib &dib) if (auto &pDoc = pItem->m_doc) { if (auto pBody = pDoc->root()->select_one("body")) { litehtml::background back = pBody->css().get_bg(); - back.m_color = litehtml::web_color(GetRValue(webPage.clBack), GetGValue(webPage.clBack), GetBValue(webPage.clBack)); + back.m_color = litehtml::web_color(GetRValue(clBack), GetGValue(clBack), GetBValue(clBack)); pBody->css_w().set_bg(back); - pBody->css_w().set_color(litehtml::web_color(GetRValue(webPage.clText), GetGValue(webPage.clText), GetBValue(webPage.clText))); + pBody->css_w().set_color(litehtml::web_color(GetRValue(clText), GetGValue(clText), GetBValue(clText))); } pDoc->draw((UINT_PTR)dib.hdc(), xPos, yPos + iOffsetY, &clip); diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index 5826e8265f..49289baeb4 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -77,8 +77,6 @@ public: NSWebPage(NewstoryListData &_1); ~NSWebPage(); - COLORREF clText = -1, clBack = -1; - FIBITMAP* find_image(const wchar_t *pwszUrl); FIBITMAP* load_image(const wchar_t *pwszUrl, ItemData *pItem); diff --git a/plugins/NewStory/src/webpage.cpp b/plugins/NewStory/src/webpage.cpp index d9cdb7149b..b2fcd9892d 100644 --- a/plugins/NewStory/src/webpage.cpp +++ b/plugins/NewStory/src/webpage.cpp @@ -105,22 +105,16 @@ static colors[] = { std::string NSWebPage::resolve_color(const std::string &color) const { - char buf[20]; - - if (color == "NSText") { - mir_snprintf(buf, "#%02X%02X%02X", GetRValue(clText), GetGValue(clText), GetBValue(clText)); - return buf; - } - for (auto &clr : colors) { if (!t_strcasecmp(color.c_str(), clr.name)) { char str_clr[20]; DWORD rgb_color = GetSysColor(clr.color_index); - t_snprintf(str_clr, 20, "#%02X%02X%02X", GetRValue(rgb_color), GetGValue(rgb_color), GetBValue(rgb_color)); - return std::move(std::string(str_clr)); + mir_snprintf(str_clr, "#%02X%02X%02X", GetRValue(rgb_color), GetGValue(rgb_color), GetBValue(rgb_color)); + return str_clr; } } - return std::move(std::string()); + + return ""; } ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3