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

Side by Side Diff: Source/core/rendering/InlineTextBox.cpp

Issue 14160005: Track the region where text is painted. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixed build on win and mac Created 7 years, 7 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/rendering/EllipsisBox.cpp ('k') | Source/core/rendering/RenderEmbeddedObject.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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 context->clip(shadowRect); 404 context->clip(shadowRect);
405 405
406 extraOffset = FloatSize(0, 2 * textRect.height() + max(0.0f, shadowOffse t.height()) + shadowBlur); 406 extraOffset = FloatSize(0, 2 * textRect.height() + max(0.0f, shadowOffse t.height()) + shadowBlur);
407 shadowOffset -= extraOffset; 407 shadowOffset -= extraOffset;
408 } 408 }
409 409
410 context->setShadow(shadowOffset, shadowBlur, shadowColor, context->fillColor Space()); 410 context->setShadow(shadowOffset, shadowBlur, shadowColor, context->fillColor Space());
411 return extraOffset; 411 return extraOffset;
412 } 412 }
413 413
414 static void paintTextWithShadows(GraphicsContext* context, const Font& font, con st TextRun& textRun, const AtomicString& emphasisMark, int emphasisMarkOffset, i nt startOffset, int endOffset, int truncationPoint, const FloatPoint& textOrigin , 414 static void paintTextWithShadows(GraphicsContext* context, const Font& font, con st TextRun& textRun,
415 const FloatRect& boxRect, const ShadowData* sha dow, bool stroked, bool horizontal) 415 const AtomicString& emphasisMark, int emphasisM arkOffset,
416 int startOffset, int endOffset, int truncationP oint,
417 const FloatPoint& textOrigin, const FloatRect& boxRect,
418 const ShadowData* shadow, bool stroked, bool ho rizontal)
416 { 419 {
417 Color fillColor = context->fillColor(); 420 Color fillColor = context->fillColor();
418 ColorSpace fillColorSpace = context->fillColorSpace(); 421 ColorSpace fillColorSpace = context->fillColorSpace();
419 bool opaque = fillColor.alpha() == 255; 422 bool opaque = fillColor.alpha() == 255;
420 if (!opaque) 423 if (!opaque)
421 context->setFillColor(Color::black, fillColorSpace); 424 context->setFillColor(Color::black, fillColorSpace);
422 425
426 TextRunPaintInfo textRunPaintInfo(textRun);
427 textRunPaintInfo.bounds = boxRect;
423 do { 428 do {
424 IntSize extraOffset; 429 IntSize extraOffset;
425 if (shadow) 430 if (shadow)
426 extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsCon text(context, shadow, boxRect, stroked, opaque, horizontal)); 431 extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsCon text(context, shadow, boxRect, stroked, opaque, horizontal));
427 else if (!opaque) 432 else if (!opaque)
428 context->setFillColor(fillColor, fillColorSpace); 433 context->setFillColor(fillColor, fillColorSpace);
429 434
430 if (startOffset <= endOffset) { 435 if (startOffset <= endOffset) {
436 textRunPaintInfo.from = startOffset;
437 textRunPaintInfo.to = endOffset;
431 if (emphasisMark.isEmpty()) 438 if (emphasisMark.isEmpty())
432 context->drawText(font, textRun, textOrigin + extraOffset, start Offset, endOffset); 439 context->drawText(font, textRunPaintInfo, textOrigin + extraOffs et);
433 else 440 else
434 context->drawEmphasisMarks(font, textRun, emphasisMark, textOrig in + extraOffset + IntSize(0, emphasisMarkOffset), startOffset, endOffset); 441 context->drawEmphasisMarks(font, textRunPaintInfo, emphasisMark, textOrigin + extraOffset + IntSize(0, emphasisMarkOffset));
435 } else { 442 } else {
436 if (endOffset > 0) { 443 if (endOffset > 0) {
444 textRunPaintInfo.from = 0;
445 textRunPaintInfo.to = endOffset;
437 if (emphasisMark.isEmpty()) 446 if (emphasisMark.isEmpty())
438 context->drawText(font, textRun, textOrigin + extraOffset, 0, endOffset); 447 context->drawText(font, textRunPaintInfo, textOrigin + extra Offset);
439 else 448 else
440 context->drawEmphasisMarks(font, textRun, emphasisMark, text Origin + extraOffset + IntSize(0, emphasisMarkOffset), 0, endOffset); 449 context->drawEmphasisMarks(font, textRunPaintInfo, emphasisM ark, textOrigin + extraOffset + IntSize(0, emphasisMarkOffset));
441 } 450 }
442 if (startOffset < truncationPoint) { 451 if (startOffset < truncationPoint) {
452 textRunPaintInfo.from = startOffset;
453 textRunPaintInfo.to = truncationPoint;
443 if (emphasisMark.isEmpty()) 454 if (emphasisMark.isEmpty())
444 context->drawText(font, textRun, textOrigin + extraOffset, s tartOffset, truncationPoint); 455 context->drawText(font, textRunPaintInfo, textOrigin + extra Offset);
445 else 456 else
446 context->drawEmphasisMarks(font, textRun, emphasisMark, text Origin + extraOffset + IntSize(0, emphasisMarkOffset), startOffset, truncationP oint); 457 context->drawEmphasisMarks(font, textRunPaintInfo, emphasisM ark, textOrigin + extraOffset + IntSize(0, emphasisMarkOffset));
447 } 458 }
448 } 459 }
449 460
450 if (!shadow) 461 if (!shadow)
451 break; 462 break;
452 463
453 if (shadow->next() || stroked || !opaque) 464 if (shadow->next() || stroked || !opaque)
454 context->restore(); 465 context->restore();
455 else 466 else
456 context->clearShadow(); 467 context->clearShadow();
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 1640
1630 void InlineTextBox::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 1641 void InlineTextBox::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
1631 { 1642 {
1632 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Rendering); 1643 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Rendering);
1633 InlineBox::reportMemoryUsage(memoryObjectInfo); 1644 InlineBox::reportMemoryUsage(memoryObjectInfo);
1634 info.addMember(m_prevTextBox, "prevTextBox"); 1645 info.addMember(m_prevTextBox, "prevTextBox");
1635 info.addMember(m_nextTextBox, "nextTextBox"); 1646 info.addMember(m_nextTextBox, "nextTextBox");
1636 } 1647 }
1637 1648
1638 } // namespace WebCore 1649 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/EllipsisBox.cpp ('k') | Source/core/rendering/RenderEmbeddedObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698