OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 1804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1815 ancestor = ancestor->parent(); | 1815 ancestor = ancestor->parent(); |
1816 | 1816 |
1817 // If we can't find an ancestor to check editability on, or editability is u
nchanged, we recur like normal | 1817 // If we can't find an ancestor to check editability on, or editability is u
nchanged, we recur like normal |
1818 if (isEditingBoundary(ancestor, child)) | 1818 if (isEditingBoundary(ancestor, child)) |
1819 return child->positionForPoint(pointInChildCoordinates); | 1819 return child->positionForPoint(pointInChildCoordinates); |
1820 | 1820 |
1821 // Otherwise return before or after the child, depending on if the click was
to the logical left or logical right of the child | 1821 // Otherwise return before or after the child, depending on if the click was
to the logical left or logical right of the child |
1822 LayoutUnit childMiddle = parent->logicalWidthForChild(*child) / 2; | 1822 LayoutUnit childMiddle = parent->logicalWidthForChild(*child) / 2; |
1823 LayoutUnit logicalLeft = parent->isHorizontalWritingMode() ? pointInChildCoo
rdinates.x() : pointInChildCoordinates.y(); | 1823 LayoutUnit logicalLeft = parent->isHorizontalWritingMode() ? pointInChildCoo
rdinates.x() : pointInChildCoordinates.y(); |
1824 if (logicalLeft < childMiddle) | 1824 if (logicalLeft < childMiddle) |
1825 return ancestor->createPositionWithAffinity(childNode->nodeIndex(), DOWN
STREAM); | 1825 return ancestor->createPositionWithAffinity(childNode->nodeIndex()); |
1826 return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, UPST
REAM); | 1826 return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, UPST
REAM); |
1827 } | 1827 } |
1828 | 1828 |
1829 PositionWithAffinity LayoutBlock::positionForPointWithInlineChildren(const Layou
tPoint& pointInLogicalContents) | 1829 PositionWithAffinity LayoutBlock::positionForPointWithInlineChildren(const Layou
tPoint& pointInLogicalContents) |
1830 { | 1830 { |
1831 ASSERT(childrenInline()); | 1831 ASSERT(childrenInline()); |
1832 | 1832 |
1833 if (!firstRootBox()) | 1833 if (!firstRootBox()) |
1834 return createPositionWithAffinity(0, DOWNSTREAM); | 1834 return createPositionWithAffinity(0); |
1835 | 1835 |
1836 bool linesAreFlipped = style()->isFlippedLinesWritingMode(); | 1836 bool linesAreFlipped = style()->isFlippedLinesWritingMode(); |
1837 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); | 1837 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); |
1838 | 1838 |
1839 // look for the closest line box in the root box which is at the passed-in y
coordinate | 1839 // look for the closest line box in the root box which is at the passed-in y
coordinate |
1840 InlineBox* closestBox = nullptr; | 1840 InlineBox* closestBox = nullptr; |
1841 RootInlineBox* firstRootBoxWithChildren = nullptr; | 1841 RootInlineBox* firstRootBoxWithChildren = nullptr; |
1842 RootInlineBox* lastRootBoxWithChildren = nullptr; | 1842 RootInlineBox* lastRootBoxWithChildren = nullptr; |
1843 for (RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox())
{ | 1843 for (RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox())
{ |
1844 if (!root->firstLeafChild()) | 1844 if (!root->firstLeafChild()) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 // We hit this case for Mac behavior when the Y coordinate is below the
last box. | 1904 // We hit this case for Mac behavior when the Y coordinate is below the
last box. |
1905 ASSERT(moveCaretToBoundary); | 1905 ASSERT(moveCaretToBoundary); |
1906 InlineBox* logicallyLastBox; | 1906 InlineBox* logicallyLastBox; |
1907 if (lastRootBoxWithChildren->getLogicalEndBoxWithNode(logicallyLastBox)) | 1907 if (lastRootBoxWithChildren->getLogicalEndBoxWithNode(logicallyLastBox)) |
1908 return PositionWithAffinity(positionForBox(logicallyLastBox, false),
DOWNSTREAM); | 1908 return PositionWithAffinity(positionForBox(logicallyLastBox, false),
DOWNSTREAM); |
1909 } | 1909 } |
1910 | 1910 |
1911 // Can't reach this. We have a root line box, but it has no kids. | 1911 // Can't reach this. We have a root line box, but it has no kids. |
1912 // FIXME: This should ASSERT_NOT_REACHED(), but clicking on placeholder text | 1912 // FIXME: This should ASSERT_NOT_REACHED(), but clicking on placeholder text |
1913 // seems to hit this code path. | 1913 // seems to hit this code path. |
1914 return createPositionWithAffinity(0, DOWNSTREAM); | 1914 return createPositionWithAffinity(0); |
1915 } | 1915 } |
1916 | 1916 |
1917 static inline bool isChildHitTestCandidate(LayoutBox* box) | 1917 static inline bool isChildHitTestCandidate(LayoutBox* box) |
1918 { | 1918 { |
1919 return box->size().height() && box->style()->visibility() == VISIBLE && !box
->isFloatingOrOutOfFlowPositioned() && !box->isLayoutFlowThread(); | 1919 return box->size().height() && box->style()->visibility() == VISIBLE && !box
->isFloatingOrOutOfFlowPositioned() && !box->isLayoutFlowThread(); |
1920 } | 1920 } |
1921 | 1921 |
1922 PositionWithAffinity LayoutBlock::positionForPoint(const LayoutPoint& point) | 1922 PositionWithAffinity LayoutBlock::positionForPoint(const LayoutPoint& point) |
1923 { | 1923 { |
1924 if (isTable()) | 1924 if (isTable()) |
1925 return LayoutBox::positionForPoint(point); | 1925 return LayoutBox::positionForPoint(point); |
1926 | 1926 |
1927 if (isReplaced()) { | 1927 if (isReplaced()) { |
1928 // FIXME: This seems wrong when the object's writing-mode doesn't match
the line's writing-mode. | 1928 // FIXME: This seems wrong when the object's writing-mode doesn't match
the line's writing-mode. |
1929 LayoutUnit pointLogicalLeft = isHorizontalWritingMode() ? point.x() : po
int.y(); | 1929 LayoutUnit pointLogicalLeft = isHorizontalWritingMode() ? point.x() : po
int.y(); |
1930 LayoutUnit pointLogicalTop = isHorizontalWritingMode() ? point.y() : poi
nt.x(); | 1930 LayoutUnit pointLogicalTop = isHorizontalWritingMode() ? point.y() : poi
nt.x(); |
1931 | 1931 |
1932 if (pointLogicalLeft < 0) | 1932 if (pointLogicalLeft < 0) |
1933 return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); | 1933 return createPositionWithAffinity(caretMinOffset()); |
1934 if (pointLogicalLeft >= logicalWidth()) | 1934 if (pointLogicalLeft >= logicalWidth()) |
1935 return createPositionWithAffinity(caretMaxOffset(), DOWNSTREAM); | 1935 return createPositionWithAffinity(caretMaxOffset()); |
1936 if (pointLogicalTop < 0) | 1936 if (pointLogicalTop < 0) |
1937 return createPositionWithAffinity(caretMinOffset(), DOWNSTREAM); | 1937 return createPositionWithAffinity(caretMinOffset()); |
1938 if (pointLogicalTop >= logicalHeight()) | 1938 if (pointLogicalTop >= logicalHeight()) |
1939 return createPositionWithAffinity(caretMaxOffset(), DOWNSTREAM); | 1939 return createPositionWithAffinity(caretMaxOffset()); |
1940 } | 1940 } |
1941 | 1941 |
1942 LayoutPoint pointInContents = point; | 1942 LayoutPoint pointInContents = point; |
1943 offsetForContents(pointInContents); | 1943 offsetForContents(pointInContents); |
1944 LayoutPoint pointInLogicalContents(pointInContents); | 1944 LayoutPoint pointInLogicalContents(pointInContents); |
1945 if (!isHorizontalWritingMode()) | 1945 if (!isHorizontalWritingMode()) |
1946 pointInLogicalContents = pointInLogicalContents.transposedPoint(); | 1946 pointInLogicalContents = pointInLogicalContents.transposedPoint(); |
1947 | 1947 |
1948 if (childrenInline()) | 1948 if (childrenInline()) |
1949 return positionForPointWithInlineChildren(pointInLogicalContents); | 1949 return positionForPointWithInlineChildren(pointInLogicalContents); |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2918 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const | 2918 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const |
2919 { | 2919 { |
2920 showLayoutObject(); | 2920 showLayoutObject(); |
2921 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 2921 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
2922 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 2922 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
2923 } | 2923 } |
2924 | 2924 |
2925 #endif | 2925 #endif |
2926 | 2926 |
2927 } // namespace blink | 2927 } // namespace blink |
OLD | NEW |