Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(921)

Unified Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 1188663005: Speed-up font switching in CanvasRenderingContext2D by only validating uncached values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: moved literal "initial" into const Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/canvas/CanvasRenderingContext2D.cpp
diff --git a/Source/core/html/canvas/CanvasRenderingContext2D.cpp b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
index 3492d658b7ba11cb75890cc2e245f5966653c8e3..ad626b2ac61dbe69366729cc585de45edfb25b38 100644
--- a/Source/core/html/canvas/CanvasRenderingContext2D.cpp
+++ b/Source/core/html/canvas/CanvasRenderingContext2D.cpp
@@ -79,6 +79,7 @@ static const int defaultFontSize = 10;
static const char defaultFontFamily[] = "sans-serif";
static const char defaultFont[] = "10px sans-serif";
static const char inherit[] = "inherit";
+static const char initial[] = "initial";
static const char rtl[] = "rtl";
static const char ltr[] = "ltr";
static const double TryRestoreContextInterval = 0.5;
@@ -1679,20 +1680,17 @@ void CanvasRenderingContext2D::setFont(const String& newFont)
m_fetchedFonts.remove(m_fetchedFontsLRUList.first());
m_fetchedFontsLRUList.removeFirst();
}
+ if (parsedStyle->isEmpty())
+ return;
+ String fontValue = parsedStyle->getPropertyValue(CSSPropertyFont);
+ // According to http://lists.w3.org/Archives/Public/public-html/2009Jul/0947.html,
+ // the "inherit" and "initial" values must be ignored.
+ if (fontValue == inherit || fontValue == initial)
+ return;
m_fetchedFonts.add(newFont, parsedStyle);
}
m_fetchedFontsLRUList.add(newFont);
- if (parsedStyle->isEmpty())
- return;
-
- String fontValue = parsedStyle->getPropertyValue(CSSPropertyFont);
-
- // According to http://lists.w3.org/Archives/Public/public-html/2009Jul/0947.html,
- // the "inherit" and "initial" values must be ignored.
- if (fontValue == "inherit" || fontValue == "initial")
- return;
-
// The parse succeeded.
String newFontSafeCopy(newFont); // Create a string copy since newFont can be deleted inside realizeSaves.
modifiableState().setUnparsedFont(newFontSafeCopy);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698