diff --git a/Common/3dParty/html/css/src/CCssCalculator.cpp b/Common/3dParty/html/css/src/CCssCalculator.cpp
index 8459444250..99f5d65e05 100644
--- a/Common/3dParty/html/css/src/CCssCalculator.cpp
+++ b/Common/3dParty/html/css/src/CCssCalculator.cpp
@@ -58,6 +58,11 @@ namespace NSCSS
return m_pInternal->GetDpi();
}
+ bool CCssCalculator::HaveStylesById(const std::wstring& wsId) const
+ {
+ return m_pInternal->HaveStylesById(wsId);
+ }
+
void CCssCalculator::ClearPageData()
{
m_pInternal->ClearPageData();
diff --git a/Common/3dParty/html/css/src/CCssCalculator.h b/Common/3dParty/html/css/src/CCssCalculator.h
index 678095428b..5047193e6e 100644
--- a/Common/3dParty/html/css/src/CCssCalculator.h
+++ b/Common/3dParty/html/css/src/CCssCalculator.h
@@ -32,6 +32,8 @@ namespace NSCSS
std::wstring GetEncoding() const;
unsigned short int GetDpi() const;
+ bool HaveStylesById(const std::wstring& wsId) const;
+
void ClearPageData();
void ClearEmbeddedStyles();
void ClearAllowedStyleFiles();
diff --git a/Common/3dParty/html/css/src/CCssCalculator_Private.cpp b/Common/3dParty/html/css/src/CCssCalculator_Private.cpp
index 45017aa9f9..c15e55a36d 100644
--- a/Common/3dParty/html/css/src/CCssCalculator_Private.cpp
+++ b/Common/3dParty/html/css/src/CCssCalculator_Private.cpp
@@ -184,7 +184,7 @@ namespace NSCSS
}
#endif
- const CElement* CStyleStorage::FindElement(const std::wstring& wsSelector)
+ const CElement* CStyleStorage::FindElement(const std::wstring& wsSelector) const
{
if (wsSelector.empty())
return nullptr;
@@ -470,7 +470,7 @@ namespace NSCSS
}
}
- const CElement* CStyleStorage::FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map& mStyleData)
+ const CElement* CStyleStorage::FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map& mStyleData) const
{
std::map::const_iterator itFound = mStyleData.find(wsSelector);
@@ -765,6 +765,11 @@ namespace NSCSS
return m_nDpi;
}
+ bool CCssCalculator_Private::HaveStylesById(const std::wstring& wsId) const
+ {
+ return nullptr != m_oStyleStorage.FindElement(L'#' + wsId);
+ }
+
void CCssCalculator_Private::ClearEmbeddedStyles()
{
m_oStyleStorage.ClearEmbeddedStyles();
diff --git a/Common/3dParty/html/css/src/CCssCalculator_Private.h b/Common/3dParty/html/css/src/CCssCalculator_Private.h
index 814e7228cd..f57c97a189 100644
--- a/Common/3dParty/html/css/src/CCssCalculator_Private.h
+++ b/Common/3dParty/html/css/src/CCssCalculator_Private.h
@@ -37,7 +37,7 @@ namespace NSCSS
void ClearPageData();
#endif
- const CElement* FindElement(const std::wstring& wsSelector);
+ const CElement* FindElement(const std::wstring& wsSelector) const;
private:
typedef struct
{
@@ -77,7 +77,7 @@ namespace NSCSS
void GetOutputData(KatanaOutput* oOutput, std::map& mStyleData);
- const CElement* FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map& mStyleData);
+ const CElement* FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map& mStyleData) const;
};
class CCssCalculator_Private
@@ -122,6 +122,8 @@ namespace NSCSS
std::wstring GetEncoding() const;
unsigned short int GetDpi() const;
+ bool HaveStylesById(const std::wstring& wsId) const;
+
void ClearEmbeddedStyles();
void ClearAllowedStyleFiles();
void ClearStylesFromFile(const std::wstring& wsFilePath);
diff --git a/HtmlFile2/htmlfile2.cpp b/HtmlFile2/htmlfile2.cpp
index 926e3295a0..775c7fec8c 100644
--- a/HtmlFile2/htmlfile2.cpp
+++ b/HtmlFile2/htmlfile2.cpp
@@ -2288,6 +2288,9 @@ private:
{
oNode.m_wsId = EncodeXmlString(m_oLightReader.GetText());
WriteBookmark(oXml, oNode.m_wsId);
+
+ if (!m_oStylesCalculator.HaveStylesById(oNode.m_wsId))
+ oNode.m_wsId.clear();
}
else if(sName == L"style")
oNode.m_wsStyle += m_oLightReader.GetText();