diff options
author | pilgrim <pilgrim@chromium.org> | 2015-11-13 16:06:40 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-14 00:08:14 +0000 |
commit | 9c5b99bac6bfbf290706368d4fba1c7b9b4ec93d (patch) | |
tree | 06e4596477677cab12ab5f492af3a715b9a48d04 | |
parent | d6f9f5cbb0deda31a5464bc38768b69edf946abd (diff) | |
download | chromium_src-9c5b99bac6bfbf290706368d4fba1c7b9b4ec93d.zip chromium_src-9c5b99bac6bfbf290706368d4fba1c7b9b4ec93d.tar.gz chromium_src-9c5b99bac6bfbf290706368d4fba1c7b9b4ec93d.tar.bz2 |
[Line Layout API] Convert LayoutBlock::positionForPointRespectingEditingBoundaries to new line layout API
Callers are trying to pass in an inline box's layoutObject, which will
soon no longer be publicly accessible. No functional changes.
BUG=499321
Review URL: https://codereview.chromium.org/1441233004
Cr-Commit-Position: refs/heads/master@{#359698}
5 files changed, 33 insertions, 12 deletions
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp index 8569b99..e337c7d 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBlock.cpp +++ b/third_party/WebKit/Source/core/layout/LayoutBlock.cpp @@ -1774,19 +1774,19 @@ static inline bool isEditingBoundary(LayoutObject* ancestor, LayoutObject* child // FIXME: This function should go on LayoutObject as an instance method. Then // all cases in which positionForPoint recurs could call this instead to // prevent crossing editable boundaries. This would require many tests. -static PositionWithAffinity positionForPointRespectingEditingBoundaries(LayoutBlock* parent, LayoutBox* child, const LayoutPoint& pointInParentCoordinates) +static PositionWithAffinity positionForPointRespectingEditingBoundaries(LayoutBlock* parent, LineLayoutBox child, const LayoutPoint& pointInParentCoordinates) { - LayoutPoint childLocation = child->location(); - if (child->isInFlowPositioned()) - childLocation += child->offsetForInFlowPosition(); + LayoutPoint childLocation = child.location(); + if (child.isInFlowPositioned()) + childLocation += child.offsetForInFlowPosition(); // FIXME: This is wrong if the child's writing-mode is different from the parent's. LayoutPoint pointInChildCoordinates(toLayoutPoint(pointInParentCoordinates - childLocation)); // If this is an anonymous layoutObject, we just recur normally - Node* childNode = child->nonPseudoNode(); + Node* childNode = child.nonPseudoNode(); if (!childNode) - return child->positionForPoint(pointInChildCoordinates); + return child.positionForPoint(pointInChildCoordinates); // Otherwise, first make sure that the editability of the parent and child agree. // If they don't agree, then we return a visible position just before or after the child @@ -1796,10 +1796,10 @@ static PositionWithAffinity positionForPointRespectingEditingBoundaries(LayoutBl // If we can't find an ancestor to check editability on, or editability is unchanged, we recur like normal if (isEditingBoundary(ancestor, child)) - return child->positionForPoint(pointInChildCoordinates); + return child.positionForPoint(pointInChildCoordinates); // Otherwise return before or after the child, depending on if the click was to the logical left or logical right of the child - LayoutUnit childMiddle = parent->logicalWidthForChild(*child) / 2; + LayoutUnit childMiddle = parent->logicalWidthForChildSize(child.size()) / 2; LayoutUnit logicalLeft = parent->isHorizontalWritingMode() ? pointInChildCoordinates.x() : pointInChildCoordinates.y(); if (logicalLeft < childMiddle) return ancestor->createPositionWithAffinity(childNode->nodeIndex()); @@ -1876,7 +1876,7 @@ PositionWithAffinity LayoutBlock::positionForPointWithInlineChildren(const Layou if (!isHorizontalWritingMode()) point = point.transposedPoint(); if (closestBox->lineLayoutItem().isReplaced()) - return positionForPointRespectingEditingBoundaries(this, &toLayoutBox(closestBox->layoutObject()), point); + return positionForPointRespectingEditingBoundaries(this, LineLayoutBox(closestBox->lineLayoutItem()), point); return closestBox->lineLayoutItem().positionForPoint(point); } @@ -1936,7 +1936,7 @@ PositionWithAffinity LayoutBlock::positionForPoint(const LayoutPoint& point) if (lastCandidateBox) { if (pointInLogicalContents.y() > logicalTopForChild(*lastCandidateBox) || (!blocksAreFlipped && pointInLogicalContents.y() == logicalTopForChild(*lastCandidateBox))) - return positionForPointRespectingEditingBoundaries(this, lastCandidateBox, pointInContents); + return positionForPointRespectingEditingBoundaries(this, LineLayoutBox(lastCandidateBox), pointInContents); for (LayoutBox* childBox = firstChildBox(); childBox; childBox = childBox->nextSiblingBox()) { if (!isChildHitTestCandidate(childBox)) @@ -1945,7 +1945,7 @@ PositionWithAffinity LayoutBlock::positionForPoint(const LayoutPoint& point) // We hit child if our click is above the bottom of its padding box (like IE6/7 and FF3). if (isChildHitTestCandidate(childBox) && (pointInLogicalContents.y() < childLogicalBottom || (blocksAreFlipped && pointInLogicalContents.y() == childLogicalBottom))) - return positionForPointRespectingEditingBoundaries(this, childBox, pointInContents); + return positionForPointRespectingEditingBoundaries(this, LineLayoutBox(childBox), pointInContents); } } diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.h b/third_party/WebKit/Source/core/layout/LayoutBlock.h index de1c278..729dbac 100644 --- a/third_party/WebKit/Source/core/layout/LayoutBlock.h +++ b/third_party/WebKit/Source/core/layout/LayoutBlock.h @@ -233,7 +233,8 @@ public: int columnGap() const; // Accessors for logical width/height and margins in the containing block's block-flow direction. - LayoutUnit logicalWidthForChild(const LayoutBox& child) const { return isHorizontalWritingMode() ? child.size().width() : child.size().height(); } + LayoutUnit logicalWidthForChild(const LayoutBox& child) const { return logicalWidthForChildSize(child.size()); } + LayoutUnit logicalWidthForChildSize(LayoutSize childSize) const { return isHorizontalWritingMode() ? childSize.width() : childSize.height(); } LayoutUnit logicalHeightForChild(const LayoutBox& child) const { return isHorizontalWritingMode() ? child.size().height() : child.size().width(); } LayoutSize logicalSizeForChild(const LayoutBox& child) const { return isHorizontalWritingMode() ? child.size() : child.size().transposedSize(); } LayoutUnit logicalTopForChild(const LayoutBox& child) const { return isHorizontalWritingMode() ? child.location().y() : child.location().x(); } diff --git a/third_party/WebKit/Source/core/layout/api/LineLayoutBox.h b/third_party/WebKit/Source/core/layout/api/LineLayoutBox.h index dcbbb4e..b9c6249 100644 --- a/third_party/WebKit/Source/core/layout/api/LineLayoutBox.h +++ b/third_party/WebKit/Source/core/layout/api/LineLayoutBox.h @@ -29,6 +29,16 @@ public: LineLayoutBox() { } + LayoutPoint location() const + { + return toBox()->location(); + } + + LayoutSize size() const + { + return toBox()->size(); + } + void setLogicalHeight(LayoutUnit size) { toBox()->setLogicalHeight(size); diff --git a/third_party/WebKit/Source/core/layout/api/LineLayoutBoxModel.h b/third_party/WebKit/Source/core/layout/api/LineLayoutBoxModel.h index 959294b..b579df4 100644 --- a/third_party/WebKit/Source/core/layout/api/LineLayoutBoxModel.h +++ b/third_party/WebKit/Source/core/layout/api/LineLayoutBoxModel.h @@ -178,6 +178,11 @@ public: return toBoxModel()->boxShadowShouldBeAppliedToBackground(bleedAvoidance, inlineFlowBox); } + LayoutSize offsetForInFlowPosition() const + { + return toBoxModel()->offsetForInFlowPosition(); + } + private: LayoutBoxModelObject* toBoxModel() { return toLayoutBoxModelObject(layoutObject()); } const LayoutBoxModelObject* toBoxModel() const { return toLayoutBoxModelObject(layoutObject()); } diff --git a/third_party/WebKit/Source/core/layout/api/LineLayoutItem.h b/third_party/WebKit/Source/core/layout/api/LineLayoutItem.h index 760b76f5..fb64879 100644 --- a/third_party/WebKit/Source/core/layout/api/LineLayoutItem.h +++ b/third_party/WebKit/Source/core/layout/api/LineLayoutItem.h @@ -309,6 +309,11 @@ public: return m_layoutObject->selectionBackgroundColor(); } + bool isInFlowPositioned() const + { + return m_layoutObject->isInFlowPositioned(); + } + PositionWithAffinity positionForPoint(const LayoutPoint& point) { return m_layoutObject->positionForPoint(point); |