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

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: Rebase after reopen Created 3 years, 12 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
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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 const ComputedStyle** computedStyle = 0) { 670 const ComputedStyle** computedStyle = 0) {
671 const ComputedStyle* style = 671 const ComputedStyle* style =
672 (computedStyle || 672 (computedStyle ||
673 direction == CanvasRenderingContext2DState::DirectionInherit) 673 direction == CanvasRenderingContext2DState::DirectionInherit)
674 ? canvas->ensureComputedStyle() 674 ? canvas->ensureComputedStyle()
675 : nullptr; 675 : nullptr;
676 if (computedStyle) 676 if (computedStyle)
677 *computedStyle = style; 677 *computedStyle = style;
678 switch (direction) { 678 switch (direction) {
679 case CanvasRenderingContext2DState::DirectionInherit: 679 case CanvasRenderingContext2DState::DirectionInherit:
680 return style ? style->direction() : LTR; 680 return style ? style->direction() : TextDirection::Ltr;
681 case CanvasRenderingContext2DState::DirectionRTL: 681 case CanvasRenderingContext2DState::DirectionRTL:
682 return RTL; 682 return TextDirection::Rtl;
683 case CanvasRenderingContext2DState::DirectionLTR: 683 case CanvasRenderingContext2DState::DirectionLTR:
684 return LTR; 684 return TextDirection::Ltr;
685 } 685 }
686 ASSERT_NOT_REACHED(); 686 ASSERT_NOT_REACHED();
687 return LTR; 687 return TextDirection::Ltr;
688 } 688 }
689 689
690 String CanvasRenderingContext2D::direction() const { 690 String CanvasRenderingContext2D::direction() const {
691 if (state().getDirection() == CanvasRenderingContext2DState::DirectionInherit) 691 if (state().getDirection() == CanvasRenderingContext2DState::DirectionInherit)
692 canvas()->document().updateStyleAndLayoutTreeForNode(canvas()); 692 canvas()->document().updateStyleAndLayoutTreeForNode(canvas());
693 return toTextDirection(state().getDirection(), canvas()) == RTL ? rtl : ltr; 693 return toTextDirection(state().getDirection(), canvas()) == TextDirection::Rtl
694 ? rtl
695 : ltr;
694 } 696 }
695 697
696 void CanvasRenderingContext2D::setDirection(const String& directionString) { 698 void CanvasRenderingContext2D::setDirection(const String& directionString) {
697 CanvasRenderingContext2DState::Direction direction; 699 CanvasRenderingContext2DState::Direction direction;
698 if (directionString == inherit) 700 if (directionString == inherit)
699 direction = CanvasRenderingContext2DState::DirectionInherit; 701 direction = CanvasRenderingContext2DState::DirectionInherit;
700 else if (directionString == rtl) 702 else if (directionString == rtl)
701 direction = CanvasRenderingContext2DState::DirectionRTL; 703 direction = CanvasRenderingContext2DState::DirectionRTL;
702 else if (directionString == ltr) 704 else if (directionString == ltr)
703 direction = CanvasRenderingContext2DState::DirectionLTR; 705 direction = CanvasRenderingContext2DState::DirectionLTR;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 DCHECK(fontData); 839 DCHECK(fontData);
838 if (!fontData) 840 if (!fontData)
839 return; 841 return;
840 const FontMetrics& fontMetrics = fontData->getFontMetrics(); 842 const FontMetrics& fontMetrics = fontData->getFontMetrics();
841 843
842 // FIXME: Need to turn off font smoothing. 844 // FIXME: Need to turn off font smoothing.
843 845
844 const ComputedStyle* computedStyle = 0; 846 const ComputedStyle* computedStyle = 0;
845 TextDirection direction = 847 TextDirection direction =
846 toTextDirection(state().getDirection(), canvas(), &computedStyle); 848 toTextDirection(state().getDirection(), canvas(), &computedStyle);
847 bool isRTL = direction == RTL; 849 bool isRTL = direction == TextDirection::Rtl;
848 bool override = 850 bool override =
849 computedStyle ? isOverride(computedStyle->unicodeBidi()) : false; 851 computedStyle ? isOverride(computedStyle->unicodeBidi()) : false;
850 852
851 TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction, 853 TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction,
852 override); 854 override);
853 textRun.setNormalizeSpace(true); 855 textRun.setNormalizeSpace(true);
854 // Draw the item text at the correct point. 856 // Draw the item text at the correct point.
855 FloatPoint location(x, y + getFontBaseline(fontMetrics)); 857 FloatPoint location(x, y + getFontBaseline(fontMetrics));
856 double fontWidth = font.width(textRun); 858 double fontWidth = font.width(textRun);
857 859
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 } 1159 }
1158 return true; 1160 return true;
1159 } 1161 }
1160 1162
1161 void CanvasRenderingContext2D::resetUsageTracking() { 1163 void CanvasRenderingContext2D::resetUsageTracking() {
1162 UsageCounters newCounters; 1164 UsageCounters newCounters;
1163 m_usageCounters = newCounters; 1165 m_usageCounters = newCounters;
1164 } 1166 }
1165 1167
1166 } // namespace blink 1168 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp ('k') | third_party/WebKit/Source/platform/DragImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698