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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGInlineText.cpp

Issue 2575863002: Ignore minimum font-size for SVG text (Closed)
Patch Set: Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> 2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>
3 * Copyright (C) 2006 Apple Computer Inc. 3 * Copyright (C) 2006 Apple Computer Inc.
4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
5 * Copyright (C) 2008 Rob Buis <buis@kde.org> 5 * Copyright (C) 2008 Rob Buis <buis@kde.org>
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 TextRun subRun = constructTextRun(*this, bidiRun->start(), 360 TextRun subRun = constructTextRun(*this, bidiRun->start(),
361 bidiRun->stop() - bidiRun->start(), 361 bidiRun->stop() - bidiRun->start(),
362 bidiRun->direction()); 362 bidiRun->direction());
363 addMetricsFromRun(subRun, lastCharacterWasWhiteSpace); 363 addMetricsFromRun(subRun, lastCharacterWasWhiteSpace);
364 } 364 }
365 365
366 bidiResolver.runs().deleteRuns(); 366 bidiResolver.runs().deleteRuns();
367 } 367 }
368 368
369 void LayoutSVGInlineText::updateScaledFont() { 369 void LayoutSVGInlineText::updateScaledFont() {
370 computeNewScaledFontForStyle(this, m_scalingFactor, m_scaledFont); 370 computeNewScaledFontForStyle(*this, m_scalingFactor, m_scaledFont);
371 } 371 }
372 372
373 void LayoutSVGInlineText::computeNewScaledFontForStyle( 373 void LayoutSVGInlineText::computeNewScaledFontForStyle(
374 LayoutObject* layoutObject, 374 const LayoutObject& layoutObject,
375 float& scalingFactor, 375 float& scalingFactor,
376 Font& scaledFont) { 376 Font& scaledFont) {
377 const ComputedStyle* style = layoutObject->style(); 377 const ComputedStyle& style = layoutObject.styleRef();
378 ASSERT(style);
379 ASSERT(layoutObject);
380 378
381 // Alter font-size to the right on-screen value to avoid scaling the glyphs 379 // Alter font-size to the right on-screen value to avoid scaling the glyphs
382 // themselves, except when GeometricPrecision is specified. 380 // themselves, except when GeometricPrecision is specified.
383 scalingFactor = 381 scalingFactor =
384 SVGLayoutSupport::calculateScreenFontSizeScalingFactor(layoutObject); 382 SVGLayoutSupport::calculateScreenFontSizeScalingFactor(&layoutObject);
385 if (style->effectiveZoom() == 1 && (scalingFactor == 1 || !scalingFactor)) { 383 if (!scalingFactor) {
386 scalingFactor = 1; 384 scalingFactor = 1;
387 scaledFont = style->font(); 385 scaledFont = style.font();
388 return; 386 return;
389 } 387 }
390 388
391 if (style->getFontDescription().textRendering() == GeometricPrecision) 389 const FontDescription& unscaledFontDescription = style.getFontDescription();
390 if (unscaledFontDescription.textRendering() == GeometricPrecision)
392 scalingFactor = 1; 391 scalingFactor = 1;
393 392
394 FontDescription fontDescription(style->getFontDescription()); 393 Document& document = layoutObject.document();
394 float scaledFontSize = FontSize::getComputedSizeFromSpecifiedSize(
395 &document, scalingFactor, unscaledFontDescription.isAbsoluteSize(),
396 unscaledFontDescription.specifiedSize(), DoNotApplyMinimumForFontSize);
397 if (scaledFontSize == unscaledFontDescription.computedSize()) {
398 scaledFont = style.font();
399 return;
400 }
395 401
396 Document& document = layoutObject->document(); 402 FontDescription fontDescription = unscaledFontDescription;
397 // FIXME: We need to better handle the case when we compute very small fonts 403 fontDescription.setComputedSize(scaledFontSize);
398 // below (below 1pt).
399 fontDescription.setComputedSize(FontSize::getComputedSizeFromSpecifiedSize(
400 &document, scalingFactor, fontDescription.isAbsoluteSize(),
401 fontDescription.specifiedSize(), DoNotUseSmartMinimumForFontSize));
402 404
403 scaledFont = Font(fontDescription); 405 scaledFont = Font(fontDescription);
404 scaledFont.update(document.styleEngine().fontSelector()); 406 scaledFont.update(document.styleEngine().fontSelector());
405 } 407 }
406 408
407 LayoutRect LayoutSVGInlineText::absoluteVisualRect() const { 409 LayoutRect LayoutSVGInlineText::absoluteVisualRect() const {
408 return parent()->absoluteVisualRect(); 410 return parent()->absoluteVisualRect();
409 } 411 }
410 412
411 FloatRect LayoutSVGInlineText::visualRectInLocalSVGCoordinates() const { 413 FloatRect LayoutSVGInlineText::visualRectInLocalSVGCoordinates() const {
412 return parent()->visualRectInLocalSVGCoordinates(); 414 return parent()->visualRectInLocalSVGCoordinates();
413 } 415 }
414 416
415 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const { 417 PassRefPtr<StringImpl> LayoutSVGInlineText::originalText() const {
416 RefPtr<StringImpl> result = LayoutText::originalText(); 418 RefPtr<StringImpl> result = LayoutText::originalText();
417 if (!result) 419 if (!result)
418 return nullptr; 420 return nullptr;
419 return normalizeWhitespace(result); 421 return normalizeWhitespace(result);
420 } 422 }
421 423
422 } // namespace blink 424 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698