Code clean up for extracting information from the mix of WritingMode and TextDirection
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 May 2015 21:55:32 +0000 (21:55 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 May 2015 21:55:32 +0000 (21:55 +0000)
commit7975320fd68022422ffb5c1bb4b6225eb37910f1
tree08319ba12d85c0065a6152cf6aaac59de09b1782
parentb240800f4b5b766a6c1a791497b87d611dc9121d
Code clean up for extracting information from the mix of WritingMode and TextDirection
https://bugs.webkit.org/show_bug.cgi?id=143399

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-05-28
Reviewed by Darin Adler.
Source/WebCore:

There should be eight TextFlows. A TextFlow consists of two directions.
The first one controls the inline growing direction and the second one
controls the block growing direction. We are going to use the cardinal
directions to define these combinations.

We need to extract the following information easily from the TextFlow

-- isTextFlowReversed() // RTL
-- isTextFlowFlipped()  // the opposite direction to normal
-- isTextFlowVertical() // The line grows vertically

Mixing WritingMode and TextDirection into TextFlow and choosing their values
carefully to ease implementing the above functions can make things clearer.

* Modules/notifications/Notification.h:
* platform/graphics/TextRun.h:
* platform/ios/SelectionRect.h:
* platform/text/BidiResolver.h:
* platform/text/StringWithDirection.h:
* platform/text/TextFlags.h:
(WebCore::isLeftToRightDirection): Deleted.
enum TextDirection is moved from TextFlags.h to WritingMode.h. So include
WritingMode.h instead of including TextFlags.h.

* css/CSSProperty.cpp:
(WebCore::resolveToPhysicalProperty): Instead of handling the eight possible
cases of the text flows one by one, we can map from a LogicalSide to a
PhysicalSide using the TextFlow value.

* platform/LengthBox.h:
(WebCore::BoxExtent::before):
(WebCore::BoxExtent::after):
(WebCore::BoxExtent::start):
(WebCore::BoxExtent::end):
Use mapLogicalSideToPhysicalSide() to convert from a LogicalSide to a PhysicalSide.

* platform/text/WritingMode.h:
(WebCore::isLeftToRightDirection): Usually the default enum is defined
first. And usually the default value is equal to zero. Since LTR is the
default for the text direction, it should be defined before RTL.

(WebCore::makeTextFlow): Returns a TextFlow given a WritingMode and a
TextDirection.

(WebCore::isReversedTextFlow): Returns true if the text direction is RTL.

(WebCore::isFlippedTextFlow):
(WebCore::isFlippedWritingMode): Returns true if the block growing direction
is in the opposite direction of normal.

(WebCore::isVerticalTextFlow):
(WebCore::isVerticalWritingMode): Returns true if the line grows vertically.

(WebCore::isHorizontalWritingMode):
(WebCore::isFlippedLinesWritingMode): Use isVerticalWritingMode() and
isFlippedWritingMode() to answer these questions.

(WebCore::isHorizontalPhysicalSide):
(WebCore::mirrorPhysicalSide): top <-> bottom and left <-> right conversion.
(WebCore::rotatePhysicalSide): top <-> left and right <-> bottom conversion.

(WebCore::mapLogicalSideToPhysicalSide): Maps a LogicalSide to a PhysicalSide
using either the TextFlow or the WritingMode.

(WebCore::isFlippedBlocksWritingMode): Deleted.
* rendering/RenderMultiColumnSet.cpp:
(WebCore::RenderMultiColumnSet::collectLayerFragments):
(WebCore::RenderMultiColumnSet::columnTranslationForOffset):
* rendering/shapes/Shape.cpp:
(WebCore::physicalRectToLogical):
(WebCore::physicalPointToLogical):
* rendering/style/RenderStyle.h:
Rename isFlippedBlocksWritingMode() to be isFlippedWritingMode() so we can
be consistent with other WritingMode query functions.

Source/WebKit2:

* Shared/WebPopupItem.h:
* UIProcess/API/C/efl/WKAPICastEfl.h:
* UIProcess/WebPopupMenuProxy.h:
enum TextDirection is moved from TextFlags.h to WritingMode.h. So include
WritingMode.h instead of including TextFlags.h.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@184962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/notifications/Notification.h
Source/WebCore/css/CSSProperty.cpp
Source/WebCore/css/CSSProperty.h
Source/WebCore/platform/LengthBox.h
Source/WebCore/platform/graphics/TextRun.h
Source/WebCore/platform/ios/SelectionRect.h
Source/WebCore/platform/text/BidiResolver.h
Source/WebCore/platform/text/StringWithDirection.h
Source/WebCore/platform/text/TextFlags.h
Source/WebCore/platform/text/WritingMode.h
Source/WebCore/rendering/RenderMultiColumnSet.cpp
Source/WebCore/rendering/shapes/Shape.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPopupItem.h
Source/WebKit2/UIProcess/API/C/efl/WKAPICastEfl.h
Source/WebKit2/UIProcess/WebPopupMenuProxy.h