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

Side by Side Diff: sky/engine/core/rendering/InlineTextBox.cpp

Issue 677843004: Remove text-combine. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/core/rendering/InlineFlowBox.cpp ('k') | sky/engine/core/rendering/RenderBlock.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 20 matching lines...) Expand all
31 #include "core/editing/CompositionUnderlineRangeFilter.h" 31 #include "core/editing/CompositionUnderlineRangeFilter.h"
32 #include "core/editing/Editor.h" 32 #include "core/editing/Editor.h"
33 #include "core/editing/InputMethodController.h" 33 #include "core/editing/InputMethodController.h"
34 #include "core/frame/LocalFrame.h" 34 #include "core/frame/LocalFrame.h"
35 #include "core/page/Page.h" 35 #include "core/page/Page.h"
36 #include "core/frame/Settings.h" 36 #include "core/frame/Settings.h"
37 #include "core/rendering/EllipsisBox.h" 37 #include "core/rendering/EllipsisBox.h"
38 #include "core/rendering/HitTestResult.h" 38 #include "core/rendering/HitTestResult.h"
39 #include "core/rendering/PaintInfo.h" 39 #include "core/rendering/PaintInfo.h"
40 #include "core/rendering/RenderBlock.h" 40 #include "core/rendering/RenderBlock.h"
41 #include "core/rendering/RenderCombineText.h"
42 #include "core/rendering/RenderTheme.h" 41 #include "core/rendering/RenderTheme.h"
43 #include "core/rendering/style/ShadowList.h" 42 #include "core/rendering/style/ShadowList.h"
44 #include "platform/RuntimeEnabledFeatures.h" 43 #include "platform/RuntimeEnabledFeatures.h"
45 #include "platform/fonts/FontCache.h" 44 #include "platform/fonts/FontCache.h"
46 #include "platform/fonts/GlyphBuffer.h" 45 #include "platform/fonts/GlyphBuffer.h"
47 #include "platform/fonts/WidthIterator.h" 46 #include "platform/fonts/WidthIterator.h"
48 #include "platform/graphics/GraphicsContextStateSaver.h" 47 #include "platform/graphics/GraphicsContextStateSaver.h"
49 #include "wtf/Vector.h" 48 #include "wtf/Vector.h"
50 #include "wtf/text/CString.h" 49 #include "wtf/text/CString.h"
51 #include "wtf/text/StringBuilder.h" 50 #include "wtf/text/StringBuilder.h"
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 context->drawText(font, textRunPaintInfo, textOrigin); 473 context->drawText(font, textRunPaintInfo, textOrigin);
475 else 474 else
476 context->drawEmphasisMarks(font, textRunPaintInfo, emphasisMark, textOrigin + IntSize(0, emphasisMarkOffset)); 475 context->drawEmphasisMarks(font, textRunPaintInfo, emphasisMark, textOrigin + IntSize(0, emphasisMarkOffset));
477 } 476 }
478 } 477 }
479 } 478 }
480 479
481 inline void paintEmphasisMark(GraphicsContext* context, 480 inline void paintEmphasisMark(GraphicsContext* context,
482 const AtomicString& emphasisMark, int emphasisMarkOffset, 481 const AtomicString& emphasisMark, int emphasisMarkOffset,
483 int startOffset, int endOffset, int paintRunLength, 482 int startOffset, int endOffset, int paintRunLength,
484 const Font& font, RenderCombineText* combinedText, const TextRun& textRun, 483 const Font& font, const TextRun& textRun,
485 const FloatPoint& textOrigin, const FloatRect& boxRect) 484 const FloatPoint& textOrigin, const FloatRect& boxRect)
486 { 485 {
487 ASSERT(!emphasisMark.isEmpty()); 486 ASSERT(!emphasisMark.isEmpty());
488 487 paintText(context, font, textRun, emphasisMark, emphasisMarkOffset, startOff set, endOffset, paintRunLength, textOrigin, boxRect);
489 if (combinedText) {
490 DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (&object ReplacementCharacter, 1));
491 FloatPoint emphasisMarkTextOrigin(boxRect.x() + boxRect.width() / 2, box Rect.y() + font.fontMetrics().ascent());
492 context->concatCTM(InlineTextBox::rotation(boxRect, InlineTextBox::Clock wise));
493 paintText(context, combinedText->originalFont(), objectReplacementCharac terTextRun, emphasisMark, emphasisMarkOffset, 0, 1, 1, emphasisMarkTextOrigin, b oxRect);
494 context->concatCTM(InlineTextBox::rotation(boxRect, InlineTextBox::Count erclockwise));
495 } else {
496 paintText(context, font, textRun, emphasisMark, emphasisMarkOffset, star tOffset, endOffset, paintRunLength, textOrigin, boxRect);
497 }
498 } 488 }
499 489
500 void paintTextWithEmphasisMark( 490 void paintTextWithEmphasisMark(
501 GraphicsContext* context, const Font& font, const TextPaintingStyle& textSty le, const TextRun& textRun, 491 GraphicsContext* context, const Font& font, const TextPaintingStyle& textSty le, const TextRun& textRun,
502 const AtomicString& emphasisMark, int emphasisMarkOffset, int startOffset, i nt endOffset, int length, 492 const AtomicString& emphasisMark, int emphasisMarkOffset, int startOffset, i nt endOffset, int length,
503 RenderCombineText* combinedText, const FloatPoint& textOrigin, const FloatRe ct& boxRect, bool horizontal) 493 const FloatPoint& textOrigin, const FloatRect& boxRect, bool horizontal)
504 { 494 {
505 GraphicsContextStateSaver stateSaver(*context, false); 495 GraphicsContextStateSaver stateSaver(*context, false);
506 updateGraphicsContext(context, textStyle, horizontal, stateSaver); 496 updateGraphicsContext(context, textStyle, horizontal, stateSaver);
507 paintText(context, font, textRun, nullAtom, 0, startOffset, endOffset, lengt h, textOrigin, boxRect); 497 paintText(context, font, textRun, nullAtom, 0, startOffset, endOffset, lengt h, textOrigin, boxRect);
508 498
509 if (!emphasisMark.isEmpty()) { 499 if (!emphasisMark.isEmpty()) {
510 if (textStyle.emphasisMarkColor != textStyle.fillColor) 500 if (textStyle.emphasisMarkColor != textStyle.fillColor)
511 context->setFillColor(textStyle.emphasisMarkColor); 501 context->setFillColor(textStyle.emphasisMarkColor);
512 paintEmphasisMark(context, emphasisMark, emphasisMarkOffset, startOffset , endOffset, length, font, combinedText, textRun, textOrigin, boxRect); 502 paintEmphasisMark(context, emphasisMark, emphasisMarkOffset, startOffset , endOffset, length, font, textRun, textOrigin, boxRect);
513 } 503 }
514 } 504 }
515 505
516 } // namespace 506 } // namespace
517 507
518 void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit /*lineTop*/, LayoutUnit /*lineBottom*/) 508 void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit /*lineTop*/, LayoutUnit /*lineBottom*/)
519 { 509 {
520 if (isLineBreak() || !paintInfo.shouldPaintWithinRoot(&renderer()) 510 if (isLineBreak() || !paintInfo.shouldPaintWithinRoot(&renderer())
521 || m_truncation == cFullTruncation || paintInfo.phase == PaintPhaseOutli ne || !m_len) 511 || m_truncation == cFullTruncation || paintInfo.phase == PaintPhaseOutli ne || !m_len)
522 return; 512 return;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 } 555 }
566 } 556 }
567 557
568 GraphicsContext* context = paintInfo.context; 558 GraphicsContext* context = paintInfo.context;
569 RenderStyle* styleToUse = renderer().style(isFirstLineStyle()); 559 RenderStyle* styleToUse = renderer().style(isFirstLineStyle());
570 560
571 FloatPoint boxOrigin = locationIncludingFlipping(); 561 FloatPoint boxOrigin = locationIncludingFlipping();
572 boxOrigin.move(adjustedPaintOffset.x().toFloat(), adjustedPaintOffset.y().to Float()); 562 boxOrigin.move(adjustedPaintOffset.x().toFloat(), adjustedPaintOffset.y().to Float());
573 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight())); 563 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight()));
574 564
575 RenderCombineText* combinedText = styleToUse->hasTextCombine() && renderer() .isCombineText() && toRenderCombineText(renderer()).isCombined() ? &toRenderComb ineText(renderer()) : 0; 565 bool shouldRotate = !isHorizontal();
576
577 bool shouldRotate = !isHorizontal() && !combinedText;
578 if (shouldRotate) 566 if (shouldRotate)
579 context->concatCTM(rotation(boxRect, Clockwise)); 567 context->concatCTM(rotation(boxRect, Clockwise));
580 568
581 // Determine whether or not we have composition underlines to draw. 569 // Determine whether or not we have composition underlines to draw.
582 bool containsComposition = renderer().node() && renderer().frame()->inputMet hodController().compositionNode() == renderer().node(); 570 bool containsComposition = renderer().node() && renderer().frame()->inputMet hodController().compositionNode() == renderer().node();
583 bool useCustomUnderlines = containsComposition && renderer().frame()->inputM ethodController().compositionUsesCustomUnderlines(); 571 bool useCustomUnderlines = containsComposition && renderer().frame()->inputM ethodController().compositionUsesCustomUnderlines();
584 572
585 // Determine text colors. 573 // Determine text colors.
586 TextPaintingStyle textStyle = textPaintingStyle(renderer(), styleToUse, pain tInfo.forceBlackText()); 574 TextPaintingStyle textStyle = textPaintingStyle(renderer(), styleToUse, pain tInfo.forceBlackText());
587 TextPaintingStyle selectionStyle = selectionPaintingStyle(renderer(), haveSe lection, paintInfo.forceBlackText(), textStyle); 575 TextPaintingStyle selectionStyle = selectionPaintingStyle(renderer(), haveSe lection, paintInfo.forceBlackText(), textStyle);
588 bool paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection); 576 bool paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection);
589 bool paintSelectedTextSeparately = !paintSelectedTextOnly && textStyle != se lectionStyle; 577 bool paintSelectedTextSeparately = !paintSelectedTextOnly && textStyle != se lectionStyle;
590 578
591 // Set our font. 579 // Set our font.
592 const Font& font = styleToUse->font(); 580 const Font& font = styleToUse->font();
593 581
594 FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontM etrics().ascent()); 582 FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontM etrics().ascent());
595 if (combinedText)
596 combinedText->adjustTextOrigin(textOrigin, boxRect);
597 583
598 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection 584 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection
599 // and composition highlights. 585 // and composition highlights.
600 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT extClip) { 586 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT extClip) {
601 if (containsComposition) { 587 if (containsComposition) {
602 paintCompositionBackgrounds(context, boxOrigin, styleToUse, font, us eCustomUnderlines); 588 paintCompositionBackgrounds(context, boxOrigin, styleToUse, font, us eCustomUnderlines);
603 } 589 }
604 590
605 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); 591 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true);
606 592
607 if (haveSelection && !useCustomUnderlines) 593 if (haveSelection && !useCustomUnderlines)
608 paintSelection(context, boxOrigin, styleToUse, font, selectionStyle. fillColor); 594 paintSelection(context, boxOrigin, styleToUse, font, selectionStyle. fillColor);
609 } 595 }
610 596
611 // 2. Now paint the foreground, including text and decorations like underlin e/overline (in quirks mode only). 597 // 2. Now paint the foreground, including text and decorations like underlin e/overline (in quirks mode only).
612 int length = m_len; 598 int length = m_len;
613 int maximumLength; 599 int maximumLength;
614 StringView string; 600 StringView string = renderer().text().createView();
615 if (!combinedText) { 601 if (static_cast<unsigned>(length) != string.length() || m_start)
616 string = renderer().text().createView(); 602 string.narrow(m_start, length);
617 if (static_cast<unsigned>(length) != string.length() || m_start) 603 maximumLength = renderer().textLength() - m_start;
618 string.narrow(m_start, length);
619 maximumLength = renderer().textLength() - m_start;
620 } else {
621 combinedText->getStringToRender(m_start, string, length);
622 maximumLength = length;
623 }
624 604
625 StringBuilder charactersWithHyphen; 605 StringBuilder charactersWithHyphen;
626 TextRun textRun = constructTextRun(styleToUse, font, string, maximumLength, hasHyphen() ? &charactersWithHyphen : 0); 606 TextRun textRun = constructTextRun(styleToUse, font, string, maximumLength, hasHyphen() ? &charactersWithHyphen : 0);
627 if (hasHyphen()) 607 if (hasHyphen())
628 length = textRun.length(); 608 length = textRun.length();
629 609
630 int sPos = 0; 610 int sPos = 0;
631 int ePos = 0; 611 int ePos = 0;
632 if (paintSelectedTextOnly || paintSelectedTextSeparately) 612 if (paintSelectedTextOnly || paintSelectedTextSeparately)
633 selectionStartEnd(sPos, ePos); 613 selectionStartEnd(sPos, ePos);
(...skipping 16 matching lines...) Expand all
650 emphasisMarkOffset = emphasisMarkPosition == TextEmphasisPositionOver ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fon tMetrics().descent() + font.emphasisMarkAscent(emphasisMark); 630 emphasisMarkOffset = emphasisMarkPosition == TextEmphasisPositionOver ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fon tMetrics().descent() + font.emphasisMarkAscent(emphasisMark);
651 631
652 if (!paintSelectedTextOnly) { 632 if (!paintSelectedTextOnly) {
653 // FIXME: Truncate right-to-left text correctly. 633 // FIXME: Truncate right-to-left text correctly.
654 int startOffset = 0; 634 int startOffset = 0;
655 int endOffset = length; 635 int endOffset = length;
656 if (paintSelectedTextSeparately && ePos > sPos) { 636 if (paintSelectedTextSeparately && ePos > sPos) {
657 startOffset = ePos; 637 startOffset = ePos;
658 endOffset = sPos; 638 endOffset = sPos;
659 } 639 }
660 paintTextWithEmphasisMark(context, font, textStyle, textRun, emphasisMar k, emphasisMarkOffset, startOffset, endOffset, length, combinedText, textOrigin, boxRect, isHorizontal()); 640 paintTextWithEmphasisMark(context, font, textStyle, textRun, emphasisMar k, emphasisMarkOffset, startOffset, endOffset, length, textOrigin, boxRect, isHo rizontal());
661 } 641 }
662 642
663 if ((paintSelectedTextOnly || paintSelectedTextSeparately) && sPos < ePos) { 643 if ((paintSelectedTextOnly || paintSelectedTextSeparately) && sPos < ePos) {
664 // paint only the text that is selected 644 // paint only the text that is selected
665 paintTextWithEmphasisMark(context, font, selectionStyle, textRun, emphas isMark, emphasisMarkOffset, sPos, ePos, length, combinedText, textOrigin, boxRec t, isHorizontal()); 645 paintTextWithEmphasisMark(context, font, selectionStyle, textRun, emphas isMark, emphasisMarkOffset, sPos, ePos, length, textOrigin, boxRect, isHorizonta l());
666 } 646 }
667 647
668 // Paint decorations 648 // Paint decorations
669 TextDecoration textDecorations = styleToUse->textDecorationsInEffect(); 649 TextDecoration textDecorations = styleToUse->textDecorationsInEffect();
670 if (textDecorations != TextDecorationNone && !paintSelectedTextOnly) { 650 if (textDecorations != TextDecorationNone && !paintSelectedTextOnly) {
671 GraphicsContextStateSaver stateSaver(*context, false); 651 GraphicsContextStateSaver stateSaver(*context, false);
672 updateGraphicsContext(context, textStyle, isHorizontal(), stateSaver); 652 updateGraphicsContext(context, textStyle, isHorizontal(), stateSaver);
673 if (combinedText)
674 context->concatCTM(rotation(boxRect, Clockwise));
675 paintDecoration(context, boxOrigin, textDecorations); 653 paintDecoration(context, boxOrigin, textDecorations);
676 if (combinedText)
677 context->concatCTM(rotation(boxRect, Counterclockwise));
678 } 654 }
679 655
680 if (paintInfo.phase == PaintPhaseForeground) { 656 if (paintInfo.phase == PaintPhaseForeground) {
681 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false); 657 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false);
682 658
683 // Paint custom underlines for compositions. 659 // Paint custom underlines for compositions.
684 if (useCustomUnderlines) { 660 if (useCustomUnderlines) {
685 const Vector<CompositionUnderline>& underlines = renderer().frame()- >inputMethodController().customCompositionUnderlines(); 661 const Vector<CompositionUnderline>& underlines = renderer().frame()- >inputMethodController().customCompositionUnderlines();
686 CompositionUnderlineRangeFilter filter(underlines, start(), end()); 662 CompositionUnderlineRangeFilter filter(underlines, start(), end());
687 for (CompositionUnderlineRangeFilter::ConstIterator it = filter.begi n(); it != filter.end(); ++it) { 663 for (CompositionUnderlineRangeFilter::ConstIterator it = filter.begi n(); it != filter.end(); ++it) {
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); 1395 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj);
1420 const int rendererCharacterOffset = 24; 1396 const int rendererCharacterOffset = 24;
1421 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) 1397 for (; printedCharacters < rendererCharacterOffset; printedCharacters++)
1422 fputc(' ', stderr); 1398 fputc(' ', stderr);
1423 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); 1399 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata());
1424 } 1400 }
1425 1401
1426 #endif 1402 #endif
1427 1403
1428 } // namespace blink 1404 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/InlineFlowBox.cpp ('k') | sky/engine/core/rendering/RenderBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698