| 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 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 } | 1846 } |
| 1847 | 1847 |
| 1848 return false; | 1848 return false; |
| 1849 } | 1849 } |
| 1850 | 1850 |
| 1851 Position RenderBlock::positionForBox(InlineBox *box, bool start) const | 1851 Position RenderBlock::positionForBox(InlineBox *box, bool start) const |
| 1852 { | 1852 { |
| 1853 if (!box) | 1853 if (!box) |
| 1854 return Position(); | 1854 return Position(); |
| 1855 | 1855 |
| 1856 if (!box->renderer().nonPseudoNode()) | 1856 if (!box->renderer().node()) |
| 1857 return createLegacyEditingPosition(nonPseudoNode(), start ? caretMinOffs
et() : caretMaxOffset()); | 1857 return createLegacyEditingPosition(node(), start ? caretMinOffset() : ca
retMaxOffset()); |
| 1858 | 1858 |
| 1859 if (!box->isInlineTextBox()) | 1859 if (!box->isInlineTextBox()) |
| 1860 return createLegacyEditingPosition(box->renderer().nonPseudoNode(), star
t ? box->renderer().caretMinOffset() : box->renderer().caretMaxOffset()); | 1860 return createLegacyEditingPosition(box->renderer().node(), start ? box->
renderer().caretMinOffset() : box->renderer().caretMaxOffset()); |
| 1861 | 1861 |
| 1862 InlineTextBox* textBox = toInlineTextBox(box); | 1862 InlineTextBox* textBox = toInlineTextBox(box); |
| 1863 return createLegacyEditingPosition(box->renderer().nonPseudoNode(), start ?
textBox->start() : textBox->start() + textBox->len()); | 1863 return createLegacyEditingPosition(box->renderer().node(), start ? textBox->
start() : textBox->start() + textBox->len()); |
| 1864 } | 1864 } |
| 1865 | 1865 |
| 1866 static inline bool isEditingBoundary(RenderObject* ancestor, RenderObject* child
) | 1866 static inline bool isEditingBoundary(RenderObject* ancestor, RenderObject* child
) |
| 1867 { | 1867 { |
| 1868 ASSERT(!ancestor || ancestor->nonPseudoNode()); | 1868 ASSERT(!ancestor || ancestor->node()); |
| 1869 ASSERT(child && child->nonPseudoNode()); | 1869 ASSERT(child && child->node()); |
| 1870 return !ancestor || !ancestor->parent() || (ancestor->hasLayer() && ancestor
->parent()->isRenderView()) | 1870 return !ancestor || !ancestor->parent() || (ancestor->hasLayer() && ancestor
->parent()->isRenderView()) |
| 1871 || ancestor->nonPseudoNode()->hasEditableStyle() == child->nonPseudoNode
()->hasEditableStyle(); | 1871 || ancestor->node()->hasEditableStyle() == child->node()->hasEditableSty
le(); |
| 1872 } | 1872 } |
| 1873 | 1873 |
| 1874 // FIXME: This function should go on RenderObject as an instance method. Then | 1874 // FIXME: This function should go on RenderObject as an instance method. Then |
| 1875 // all cases in which positionForPoint recurs could call this instead to | 1875 // all cases in which positionForPoint recurs could call this instead to |
| 1876 // prevent crossing editable boundaries. This would require many tests. | 1876 // prevent crossing editable boundaries. This would require many tests. |
| 1877 static PositionWithAffinity positionForPointRespectingEditingBoundaries(RenderBl
ock* parent, RenderBox* child, const LayoutPoint& pointInParentCoordinates) | 1877 static PositionWithAffinity positionForPointRespectingEditingBoundaries(RenderBl
ock* parent, RenderBox* child, const LayoutPoint& pointInParentCoordinates) |
| 1878 { | 1878 { |
| 1879 LayoutPoint childLocation = child->location(); | 1879 LayoutPoint childLocation = child->location(); |
| 1880 if (child->isRelPositioned()) | 1880 if (child->isRelPositioned()) |
| 1881 childLocation += child->offsetForInFlowPosition(); | 1881 childLocation += child->offsetForInFlowPosition(); |
| 1882 | 1882 |
| 1883 // FIXME: This is wrong if the child's writing-mode is different from the pa
rent's. | 1883 // FIXME: This is wrong if the child's writing-mode is different from the pa
rent's. |
| 1884 LayoutPoint pointInChildCoordinates(toLayoutPoint(pointInParentCoordinates -
childLocation)); | 1884 LayoutPoint pointInChildCoordinates(toLayoutPoint(pointInParentCoordinates -
childLocation)); |
| 1885 | 1885 |
| 1886 // If this is an anonymous renderer, we just recur normally | 1886 // If this is an anonymous renderer, we just recur normally |
| 1887 Node* childNode = child->nonPseudoNode(); | 1887 Node* childNode = child->node(); |
| 1888 if (!childNode) | 1888 if (!childNode) |
| 1889 return child->positionForPoint(pointInChildCoordinates); | 1889 return child->positionForPoint(pointInChildCoordinates); |
| 1890 | 1890 |
| 1891 // Otherwise, first make sure that the editability of the parent and child a
gree. | 1891 // Otherwise, first make sure that the editability of the parent and child a
gree. |
| 1892 // If they don't agree, then we return a visible position just before or aft
er the child | 1892 // If they don't agree, then we return a visible position just before or aft
er the child |
| 1893 RenderObject* ancestor = parent; | 1893 RenderObject* ancestor = parent; |
| 1894 while (ancestor && !ancestor->nonPseudoNode()) | 1894 while (ancestor && !ancestor->node()) |
| 1895 ancestor = ancestor->parent(); | 1895 ancestor = ancestor->parent(); |
| 1896 | 1896 |
| 1897 // If we can't find an ancestor to check editability on, or editability is u
nchanged, we recur like normal | 1897 // If we can't find an ancestor to check editability on, or editability is u
nchanged, we recur like normal |
| 1898 if (isEditingBoundary(ancestor, child)) | 1898 if (isEditingBoundary(ancestor, child)) |
| 1899 return child->positionForPoint(pointInChildCoordinates); | 1899 return child->positionForPoint(pointInChildCoordinates); |
| 1900 | 1900 |
| 1901 // Otherwise return before or after the child, depending on if the click was
to the logical left or logical right of the child | 1901 // Otherwise return before or after the child, depending on if the click was
to the logical left or logical right of the child |
| 1902 LayoutUnit childMiddle = parent->logicalWidthForChild(child) / 2; | 1902 LayoutUnit childMiddle = parent->logicalWidthForChild(child) / 2; |
| 1903 LayoutUnit logicalLeft = pointInChildCoordinates.x(); | 1903 LayoutUnit logicalLeft = pointInChildCoordinates.x(); |
| 1904 if (logicalLeft < childMiddle) | 1904 if (logicalLeft < childMiddle) |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2422 } | 2422 } |
| 2423 | 2423 |
| 2424 LayoutRect RenderBlock::rectWithOutlineForPaintInvalidation(const RenderLayerMod
elObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInvali
dationState* paintInvalidationState) const | 2424 LayoutRect RenderBlock::rectWithOutlineForPaintInvalidation(const RenderLayerMod
elObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInvali
dationState* paintInvalidationState) const |
| 2425 { | 2425 { |
| 2426 LayoutRect r(RenderBox::rectWithOutlineForPaintInvalidation(paintInvalidatio
nContainer, outlineWidth, paintInvalidationState)); | 2426 LayoutRect r(RenderBox::rectWithOutlineForPaintInvalidation(paintInvalidatio
nContainer, outlineWidth, paintInvalidationState)); |
| 2427 if (isAnonymousBlockContinuation()) | 2427 if (isAnonymousBlockContinuation()) |
| 2428 r.inflateY(marginBefore()); // FIXME: This is wrong for block-flows that
are horizontal. | 2428 r.inflateY(marginBefore()); // FIXME: This is wrong for block-flows that
are horizontal. |
| 2429 return r; | 2429 return r; |
| 2430 } | 2430 } |
| 2431 | 2431 |
| 2432 RenderObject* RenderBlock::hoverAncestor() const | |
| 2433 { | |
| 2434 return isAnonymousBlockContinuation() ? continuation() : RenderBox::hoverAnc
estor(); | |
| 2435 } | |
| 2436 | |
| 2437 void RenderBlock::childBecameNonInline(RenderObject*) | 2432 void RenderBlock::childBecameNonInline(RenderObject*) |
| 2438 { | 2433 { |
| 2439 ASSERT_NOT_REACHED(); | 2434 ASSERT_NOT_REACHED(); |
| 2440 // FIXME(sky): Remove | 2435 // FIXME(sky): Remove |
| 2441 } | 2436 } |
| 2442 | 2437 |
| 2443 void RenderBlock::updateHitTestResult(HitTestResult& result, const LayoutPoint&
point) | 2438 void RenderBlock::updateHitTestResult(HitTestResult& result, const LayoutPoint&
point) |
| 2444 { | 2439 { |
| 2445 if (result.innerNode()) | 2440 if (result.innerNode()) |
| 2446 return; | 2441 return; |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2661 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const | 2656 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const |
| 2662 { | 2657 { |
| 2663 showRenderObject(); | 2658 showRenderObject(); |
| 2664 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 2659 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
| 2665 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 2660 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
| 2666 } | 2661 } |
| 2667 | 2662 |
| 2668 #endif | 2663 #endif |
| 2669 | 2664 |
| 2670 } // namespace blink | 2665 } // namespace blink |
| OLD | NEW |