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

Side by Side Diff: Source/core/css/FontFaceSet.cpp

Issue 128043003: Improve core/css exception messages. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Test. Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/FontFace.cpp ('k') | Source/core/css/MediaList.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 DEFINE_STATIC_LOCAL(String, space, (" ")); 288 DEFINE_STATIC_LOCAL(String, space, (" "));
289 return s.isNull() ? space : s; 289 return s.isNull() ? space : s;
290 } 290 }
291 291
292 Vector<RefPtr<FontFace> > FontFaceSet::match(const String& fontString, const Str ing& text, ExceptionState& exceptionState) 292 Vector<RefPtr<FontFace> > FontFaceSet::match(const String& fontString, const Str ing& text, ExceptionState& exceptionState)
293 { 293 {
294 Vector<RefPtr<FontFace> > matchedFonts; 294 Vector<RefPtr<FontFace> > matchedFonts;
295 295
296 Font font; 296 Font font;
297 if (!resolveFontStyle(fontString, font)) { 297 if (!resolveFontStyle(fontString, font)) {
298 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); 298 exceptionState.throwDOMException(SyntaxError, "Could not resolve '" + fo ntString + "' as a font.");
299 return matchedFonts; 299 return matchedFonts;
300 } 300 }
301 301
302 for (const FontFamily* f = &font.family(); f; f = f->next()) { 302 for (const FontFamily* f = &font.family(); f; f = f->next()) {
303 CSSSegmentedFontFace* face = document()->styleEngine()->fontSelector()-> getFontFace(font.fontDescription(), f->family()); 303 CSSSegmentedFontFace* face = document()->styleEngine()->fontSelector()-> getFontFace(font.fontDescription(), f->family());
304 if (face) 304 if (face)
305 matchedFonts.append(face->fontFaces(nullToSpace(text))); 305 matchedFonts.append(face->fontFaces(nullToSpace(text)));
306 } 306 }
307 return matchedFonts; 307 return matchedFonts;
308 } 308 }
309 309
310 ScriptPromise FontFaceSet::load(const String& fontString, const String& text, Ex ceptionState& exceptionState) 310 ScriptPromise FontFaceSet::load(const String& fontString, const String& text, Ex ceptionState& exceptionState)
311 { 311 {
312 Font font; 312 Font font;
313 if (!resolveFontStyle(fontString, font)) { 313 if (!resolveFontStyle(fontString, font)) {
314 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); 314 exceptionState.throwDOMException(SyntaxError, "Could not resolve '" + fo ntString + "' as a font.");
315 return ScriptPromise(); 315 return ScriptPromise();
316 } 316 }
317 317
318 Document* d = document(); 318 Document* d = document();
319 ScriptPromise promise = ScriptPromise::createPending(executionContext()); 319 ScriptPromise promise = ScriptPromise::createPending(executionContext());
320 RefPtr<LoadFontPromiseResolver> resolver = LoadFontPromiseResolver::create(f ont.family(), promise, executionContext()); 320 RefPtr<LoadFontPromiseResolver> resolver = LoadFontPromiseResolver::create(f ont.family(), promise, executionContext());
321 for (const FontFamily* f = &font.family(); f; f = f->next()) { 321 for (const FontFamily* f = &font.family(); f; f = f->next()) {
322 CSSSegmentedFontFace* face = d->styleEngine()->fontSelector()->getFontFa ce(font.fontDescription(), f->family()); 322 CSSSegmentedFontFace* face = d->styleEngine()->fontSelector()->getFontFa ce(font.fontDescription(), f->family());
323 if (!face) { 323 if (!face) {
324 resolver->error(); 324 resolver->error();
325 continue; 325 continue;
326 } 326 }
327 face->loadFont(font.fontDescription(), nullToSpace(text), resolver); 327 face->loadFont(font.fontDescription(), nullToSpace(text), resolver);
328 } 328 }
329 return promise; 329 return promise;
330 } 330 }
331 331
332 bool FontFaceSet::check(const String& fontString, const String& text, ExceptionS tate& exceptionState) 332 bool FontFaceSet::check(const String& fontString, const String& text, ExceptionS tate& exceptionState)
333 { 333 {
334 Font font; 334 Font font;
335 if (!resolveFontStyle(fontString, font)) { 335 if (!resolveFontStyle(fontString, font)) {
336 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); 336 exceptionState.throwDOMException(SyntaxError, "Could not resolve '" + fo ntString + "' as a font.");
337 return false; 337 return false;
338 } 338 }
339 339
340 for (const FontFamily* f = &font.family(); f; f = f->next()) { 340 for (const FontFamily* f = &font.family(); f; f = f->next()) {
341 CSSSegmentedFontFace* face = document()->styleEngine()->fontSelector()-> getFontFace(font.fontDescription(), f->family()); 341 CSSSegmentedFontFace* face = document()->styleEngine()->fontSelector()-> getFontFace(font.fontDescription(), f->family());
342 if (!face || !face->checkFont(nullToSpace(text))) 342 if (!face || !face->checkFont(nullToSpace(text)))
343 return false; 343 return false;
344 } 344 }
345 return true; 345 return true;
346 } 346 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 } 416 }
417 417
418 void FontFaceSet::didLayout(Document* document) 418 void FontFaceSet::didLayout(Document* document)
419 { 419 {
420 if (FontFaceSet* fonts = static_cast<FontFaceSet*>(SupplementType::from(docu ment, supplementName()))) 420 if (FontFaceSet* fonts = static_cast<FontFaceSet*>(SupplementType::from(docu ment, supplementName())))
421 fonts->didLayout(); 421 fonts->didLayout();
422 } 422 }
423 423
424 424
425 } // namespace WebCore 425 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/FontFace.cpp ('k') | Source/core/css/MediaList.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698