summaryrefslogtreecommitdiff
path: root/xfa/fde/css/cfde_csssyntaxparser.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-01-23 13:54:53 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-01-23 19:48:54 +0000
commit6414b273506f97012f82c8a32c020b483d5df31a (patch)
treef790a25f03e78fe084ee22cb16418d95deaf3dd3 /xfa/fde/css/cfde_csssyntaxparser.cpp
parenta0b2d23d1121202d3821291483943a47a3c9e32e (diff)
downloadpdfium-6414b273506f97012f82c8a32c020b483d5df31a.tar.xz
Cleanup CSS parsing
This Cl removes unused CSS parsing code. The only caller of CFDE_CSSStyleSheet::LoadeBuffer is from CXFA_TextParser which provides a static string. So, we know there are no Media rules, Import rules, FontFace rules or Page rules in the input style. These rules are also not allowed in inline styles. This CL removes the supporting code. Change-Id: I3a559352b2dd0769c465cbd3da40d1db5f9577b0 Reviewed-on: https://pdfium-review.googlesource.com/2330 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fde/css/cfde_csssyntaxparser.cpp')
-rw-r--r--xfa/fde/css/cfde_csssyntaxparser.cpp140
1 files changed, 0 insertions, 140 deletions
diff --git a/xfa/fde/css/cfde_csssyntaxparser.cpp b/xfa/fde/css/cfde_csssyntaxparser.cpp
index a24b4eee66..f562a374ac 100644
--- a/xfa/fde/css/cfde_csssyntaxparser.cpp
+++ b/xfa/fde/css/cfde_csssyntaxparser.cpp
@@ -19,20 +19,6 @@ bool IsSelectorStart(FX_WCHAR wch) {
(wch >= 'A' && wch <= 'Z');
}
-bool ParseCSSURI(const FX_WCHAR* pszValue, int32_t* iOffset, int32_t* iLength) {
- ASSERT(pszValue && *iLength > 0);
- if (*iLength < 6 || pszValue[*iLength - 1] != ')' ||
- FXSYS_wcsnicmp(L"url(", pszValue, 4)) {
- return false;
- }
- if (CFDE_CSSDeclaration::ParseCSSString(pszValue + 4, *iLength - 5, iOffset,
- iLength)) {
- *iOffset += 4;
- return true;
- }
- return false;
-}
-
} // namespace
CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser()
@@ -85,10 +71,6 @@ FDE_CSSSyntaxStatus CFDE_CSSSyntaxParser::DoSyntaxParse() {
switch (m_eMode) {
case FDE_CSSSyntaxMode::RuleSet:
switch (wch) {
- case '@':
- m_TextPlane.MoveNext();
- SwitchMode(FDE_CSSSyntaxMode::AtRule);
- break;
case '}':
m_TextPlane.MoveNext();
if (RestoreMode())
@@ -194,128 +176,6 @@ FDE_CSSSyntaxStatus CFDE_CSSSyntaxParser::DoSyntaxParse() {
}
m_TextPlane.MoveNext();
break;
- case FDE_CSSSyntaxMode::MediaType:
- switch (wch) {
- case ',':
- m_TextPlane.MoveNext();
- SwitchMode(FDE_CSSSyntaxMode::MediaType);
- if (m_iTextDatLen > 0)
- return FDE_CSSSyntaxStatus::MediaType;
- break;
- case '{': {
- if (m_ModeStack.empty() ||
- m_ModeStack.top() != FDE_CSSSyntaxMode::MediaRule) {
- m_eStatus = FDE_CSSSyntaxStatus::Error;
- return m_eStatus;
- }
-
- if (m_TextData.GetLength() > 0) {
- SaveTextData();
- return FDE_CSSSyntaxStatus::MediaType;
- }
- m_TextPlane.MoveNext();
-
- // Replace the MediaRule with a RuleSet rule.
- m_ModeStack.top() = FDE_CSSSyntaxMode::RuleSet;
-
- SwitchMode(FDE_CSSSyntaxMode::RuleSet);
- return FDE_CSSSyntaxStatus::DeclOpen;
- }
- case ';': {
- if (m_ModeStack.empty() ||
- m_ModeStack.top() != FDE_CSSSyntaxMode::Import) {
- m_eStatus = FDE_CSSSyntaxStatus::Error;
- return m_eStatus;
- }
-
- if (m_TextData.GetLength() > 0) {
- SaveTextData();
- if (IsImportEnabled())
- return FDE_CSSSyntaxStatus::MediaType;
- } else {
- bool bEnabled = IsImportEnabled();
- m_TextPlane.MoveNext();
- m_ModeStack.pop();
- SwitchMode(FDE_CSSSyntaxMode::RuleSet);
- if (bEnabled) {
- DisableImport();
- return FDE_CSSSyntaxStatus::ImportClose;
- }
- }
- } break;
- case '/':
- if (m_TextPlane.GetNextChar() == '*') {
- if (SwitchToComment() > 0)
- return FDE_CSSSyntaxStatus::MediaType;
- break;
- }
- default:
- AppendChar(wch);
- break;
- }
- break;
- case FDE_CSSSyntaxMode::URI: {
- if (m_ModeStack.empty() ||
- m_ModeStack.top() != FDE_CSSSyntaxMode::Import) {
- m_eStatus = FDE_CSSSyntaxStatus::Error;
- return m_eStatus;
- }
-
- if (wch <= ' ' || wch == ';') {
- int32_t iURIStart, iURILength = m_TextData.GetLength();
- if (iURILength > 0 &&
- ParseCSSURI(m_TextData.GetBuffer(), &iURIStart, &iURILength)) {
- m_TextData.Subtract(iURIStart, iURILength);
- SwitchMode(FDE_CSSSyntaxMode::MediaType);
- if (IsImportEnabled())
- return FDE_CSSSyntaxStatus::URI;
- break;
- }
- }
- AppendChar(wch);
- } break;
- case FDE_CSSSyntaxMode::AtRule:
- if (wch > ' ') {
- AppendChar(wch);
- } else {
- int32_t iLen = m_TextData.GetLength();
- const FX_WCHAR* psz = m_TextData.GetBuffer();
- if (FXSYS_wcsncmp(L"charset", psz, iLen) == 0) {
- SwitchMode(FDE_CSSSyntaxMode::Charset);
- } else if (FXSYS_wcsncmp(L"import", psz, iLen) == 0) {
- m_ModeStack.push(FDE_CSSSyntaxMode::Import);
- SwitchMode(FDE_CSSSyntaxMode::URI);
- if (IsImportEnabled())
- return FDE_CSSSyntaxStatus::ImportRule;
- break;
- } else if (FXSYS_wcsncmp(L"media", psz, iLen) == 0) {
- m_ModeStack.push(FDE_CSSSyntaxMode::MediaRule);
- SwitchMode(FDE_CSSSyntaxMode::MediaType);
- return FDE_CSSSyntaxStatus::MediaRule;
- } else if (FXSYS_wcsncmp(L"font-face", psz, iLen) == 0) {
- SwitchMode(FDE_CSSSyntaxMode::Selector);
- return FDE_CSSSyntaxStatus::FontFaceRule;
- } else if (FXSYS_wcsncmp(L"page", psz, iLen) == 0) {
- SwitchMode(FDE_CSSSyntaxMode::Selector);
- return FDE_CSSSyntaxStatus::PageRule;
- } else {
- SwitchMode(FDE_CSSSyntaxMode::UnknownRule);
- }
- }
- break;
- case FDE_CSSSyntaxMode::Charset:
- if (wch == ';') {
- m_TextPlane.MoveNext();
- SwitchMode(FDE_CSSSyntaxMode::RuleSet);
- if (IsCharsetEnabled()) {
- DisableCharset();
- if (m_iTextDatLen > 0)
- return FDE_CSSSyntaxStatus::Charset;
- }
- } else {
- AppendChar(wch);
- }
- break;
case FDE_CSSSyntaxMode::UnknownRule:
if (wch == ';')
SwitchMode(FDE_CSSSyntaxMode::RuleSet);