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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp

Issue 2555923002: Changed TextDirection to an enum class and renamed its members (Closed)
Patch Set: Added 2 changes in mac files 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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 7 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
8 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 8 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
9 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved.
10 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 10 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 const ComputedStyle** computedStyle = 0) { 667 const ComputedStyle** computedStyle = 0) {
668 const ComputedStyle* style = 668 const ComputedStyle* style =
669 (computedStyle || 669 (computedStyle ||
670 direction == CanvasRenderingContext2DState::DirectionInherit) 670 direction == CanvasRenderingContext2DState::DirectionInherit)
671 ? canvas->ensureComputedStyle() 671 ? canvas->ensureComputedStyle()
672 : nullptr; 672 : nullptr;
673 if (computedStyle) 673 if (computedStyle)
674 *computedStyle = style; 674 *computedStyle = style;
675 switch (direction) { 675 switch (direction) {
676 case CanvasRenderingContext2DState::DirectionInherit: 676 case CanvasRenderingContext2DState::DirectionInherit:
677 return style ? style->direction() : LTR; 677 return style ? style->direction() : TextDirection::Ltr;
678 case CanvasRenderingContext2DState::DirectionRTL: 678 case CanvasRenderingContext2DState::DirectionRTL:
679 return RTL; 679 return TextDirection::Rtl;
680 case CanvasRenderingContext2DState::DirectionLTR: 680 case CanvasRenderingContext2DState::DirectionLTR:
681 return LTR; 681 return TextDirection::Ltr;
682 } 682 }
683 ASSERT_NOT_REACHED(); 683 ASSERT_NOT_REACHED();
684 return LTR; 684 return TextDirection::Ltr;
685 } 685 }
686 686
687 String CanvasRenderingContext2D::direction() const { 687 String CanvasRenderingContext2D::direction() const {
688 if (state().getDirection() == CanvasRenderingContext2DState::DirectionInherit) 688 if (state().getDirection() == CanvasRenderingContext2DState::DirectionInherit)
689 canvas()->document().updateStyleAndLayoutTreeForNode(canvas()); 689 canvas()->document().updateStyleAndLayoutTreeForNode(canvas());
690 return toTextDirection(state().getDirection(), canvas()) == RTL ? rtl : ltr; 690 return toTextDirection(state().getDirection(), canvas()) == TextDirection::Rtl
691 ? rtl
692 : ltr;
691 } 693 }
692 694
693 void CanvasRenderingContext2D::setDirection(const String& directionString) { 695 void CanvasRenderingContext2D::setDirection(const String& directionString) {
694 CanvasRenderingContext2DState::Direction direction; 696 CanvasRenderingContext2DState::Direction direction;
695 if (directionString == inherit) 697 if (directionString == inherit)
696 direction = CanvasRenderingContext2DState::DirectionInherit; 698 direction = CanvasRenderingContext2DState::DirectionInherit;
697 else if (directionString == rtl) 699 else if (directionString == rtl)
698 direction = CanvasRenderingContext2DState::DirectionRTL; 700 direction = CanvasRenderingContext2DState::DirectionRTL;
699 else if (directionString == ltr) 701 else if (directionString == ltr)
700 direction = CanvasRenderingContext2DState::DirectionLTR; 702 direction = CanvasRenderingContext2DState::DirectionLTR;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 DCHECK(fontData); 836 DCHECK(fontData);
835 if (!fontData) 837 if (!fontData)
836 return; 838 return;
837 const FontMetrics& fontMetrics = fontData->getFontMetrics(); 839 const FontMetrics& fontMetrics = fontData->getFontMetrics();
838 840
839 // FIXME: Need to turn off font smoothing. 841 // FIXME: Need to turn off font smoothing.
840 842
841 const ComputedStyle* computedStyle = 0; 843 const ComputedStyle* computedStyle = 0;
842 TextDirection direction = 844 TextDirection direction =
843 toTextDirection(state().getDirection(), canvas(), &computedStyle); 845 toTextDirection(state().getDirection(), canvas(), &computedStyle);
844 bool isRTL = direction == RTL; 846 bool isRTL = direction == TextDirection::Rtl;
845 bool override = 847 bool override =
846 computedStyle ? isOverride(computedStyle->unicodeBidi()) : false; 848 computedStyle ? isOverride(computedStyle->unicodeBidi()) : false;
847 849
848 TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction, 850 TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction,
849 override); 851 override);
850 textRun.setNormalizeSpace(true); 852 textRun.setNormalizeSpace(true);
851 // Draw the item text at the correct point. 853 // Draw the item text at the correct point.
852 FloatPoint location(x, y + getFontBaseline(fontMetrics)); 854 FloatPoint location(x, y + getFontBaseline(fontMetrics));
853 double fontWidth = font.width(textRun); 855 double fontWidth = font.width(textRun);
854 856
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 } 1156 }
1155 return true; 1157 return true;
1156 } 1158 }
1157 1159
1158 void CanvasRenderingContext2D::resetUsageTracking() { 1160 void CanvasRenderingContext2D::resetUsageTracking() {
1159 UsageCounters newCounters; 1161 UsageCounters newCounters;
1160 m_usageCounters = newCounters; 1162 m_usageCounters = newCounters;
1161 } 1163 }
1162 1164
1163 } // namespace blink 1165 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698