| 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 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 if (block->hasOverflowClip()) { | 941 if (block->hasOverflowClip()) { |
| 942 block->layer()->scrollableArea()->updateAfterLayout(); | 942 block->layer()->scrollableArea()->updateAfterLayout(); |
| 943 } | 943 } |
| 944 } | 944 } |
| 945 } | 945 } |
| 946 } | 946 } |
| 947 | 947 |
| 948 void RenderBlock::updateScrollInfoAfterLayout() | 948 void RenderBlock::updateScrollInfoAfterLayout() |
| 949 { | 949 { |
| 950 if (hasOverflowClip()) { | 950 if (hasOverflowClip()) { |
| 951 if (style()->isFlippedBlocksWritingMode()) { | |
| 952 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=97937 | |
| 953 // Workaround for now. We cannot delay the scroll info for overflow | |
| 954 // for items with opposite writing directions, as the contents needs | |
| 955 // to overflow in that direction | |
| 956 layer()->scrollableArea()->updateAfterLayout(); | |
| 957 return; | |
| 958 } | |
| 959 | |
| 960 if (gDelayUpdateScrollInfo) | 951 if (gDelayUpdateScrollInfo) |
| 961 gDelayedUpdateScrollInfoSet->add(this); | 952 gDelayedUpdateScrollInfoSet->add(this); |
| 962 else | 953 else |
| 963 layer()->scrollableArea()->updateAfterLayout(); | 954 layer()->scrollableArea()->updateAfterLayout(); |
| 964 } | 955 } |
| 965 } | 956 } |
| 966 | 957 |
| 967 void RenderBlock::layout() | 958 void RenderBlock::layout() |
| 968 { | 959 { |
| 969 // Table cells call layoutBlock directly, so don't add any logic here. Put
code into | 960 // Table cells call layoutBlock directly, so don't add any logic here. Put
code into |
| (...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, UPST
REAM); | 2269 return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, UPST
REAM); |
| 2279 } | 2270 } |
| 2280 | 2271 |
| 2281 PositionWithAffinity RenderBlock::positionForPointWithInlineChildren(const Layou
tPoint& pointInLogicalContents) | 2272 PositionWithAffinity RenderBlock::positionForPointWithInlineChildren(const Layou
tPoint& pointInLogicalContents) |
| 2282 { | 2273 { |
| 2283 ASSERT(childrenInline()); | 2274 ASSERT(childrenInline()); |
| 2284 | 2275 |
| 2285 if (!firstRootBox()) | 2276 if (!firstRootBox()) |
| 2286 return createPositionWithAffinity(0, DOWNSTREAM); | 2277 return createPositionWithAffinity(0, DOWNSTREAM); |
| 2287 | 2278 |
| 2288 bool linesAreFlipped = style()->isFlippedLinesWritingMode(); | |
| 2289 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); | |
| 2290 | |
| 2291 // look for the closest line box in the root box which is at the passed-in y
coordinate | 2279 // look for the closest line box in the root box which is at the passed-in y
coordinate |
| 2292 InlineBox* closestBox = 0; | 2280 InlineBox* closestBox = 0; |
| 2293 RootInlineBox* firstRootBoxWithChildren = 0; | 2281 RootInlineBox* firstRootBoxWithChildren = 0; |
| 2294 RootInlineBox* lastRootBoxWithChildren = 0; | 2282 RootInlineBox* lastRootBoxWithChildren = 0; |
| 2295 for (RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox())
{ | 2283 for (RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox())
{ |
| 2296 if (!root->firstLeafChild()) | 2284 if (!root->firstLeafChild()) |
| 2297 continue; | 2285 continue; |
| 2298 if (!firstRootBoxWithChildren) | 2286 if (!firstRootBoxWithChildren) |
| 2299 firstRootBoxWithChildren = root; | 2287 firstRootBoxWithChildren = root; |
| 2300 | 2288 |
| 2301 if (!linesAreFlipped && root->isFirstAfterPageBreak() && (pointInLogical
Contents.y() < root->lineTopWithLeading() | 2289 if (root->isFirstAfterPageBreak() && (pointInLogicalContents.y() < root-
>lineTopWithLeading())) |
| 2302 || (blocksAreFlipped && pointInLogicalContents.y() == root->lineTopW
ithLeading()))) | |
| 2303 break; | 2290 break; |
| 2304 | 2291 |
| 2305 lastRootBoxWithChildren = root; | 2292 lastRootBoxWithChildren = root; |
| 2306 | 2293 |
| 2307 // check if this root line box is located at this y coordinate | 2294 // check if this root line box is located at this y coordinate |
| 2308 if (pointInLogicalContents.y() < root->selectionBottom() || (blocksAreFl
ipped && pointInLogicalContents.y() == root->selectionBottom())) { | 2295 if (pointInLogicalContents.y() < root->selectionBottom()) { |
| 2309 if (linesAreFlipped) { | |
| 2310 RootInlineBox* nextRootBoxWithChildren = root->nextRootBox(); | |
| 2311 while (nextRootBoxWithChildren && !nextRootBoxWithChildren->firs
tLeafChild()) | |
| 2312 nextRootBoxWithChildren = nextRootBoxWithChildren->nextRootB
ox(); | |
| 2313 | |
| 2314 if (nextRootBoxWithChildren && nextRootBoxWithChildren->isFirstA
fterPageBreak() && (pointInLogicalContents.y() > nextRootBoxWithChildren->lineTo
pWithLeading() | |
| 2315 || (!blocksAreFlipped && pointInLogicalContents.y() == nextR
ootBoxWithChildren->lineTopWithLeading()))) | |
| 2316 continue; | |
| 2317 } | |
| 2318 closestBox = root->closestLeafChildForLogicalLeftPosition(pointInLog
icalContents.x()); | 2296 closestBox = root->closestLeafChildForLogicalLeftPosition(pointInLog
icalContents.x()); |
| 2319 if (closestBox) | 2297 if (closestBox) |
| 2320 break; | 2298 break; |
| 2321 } | 2299 } |
| 2322 } | 2300 } |
| 2323 | 2301 |
| 2324 bool moveCaretToBoundary = document().frame()->editor().behavior().shouldMov
eCaretToHorizontalBoundaryWhenPastTopOrBottom(); | 2302 bool moveCaretToBoundary = document().frame()->editor().behavior().shouldMov
eCaretToHorizontalBoundaryWhenPastTopOrBottom(); |
| 2325 | 2303 |
| 2326 if (!moveCaretToBoundary && !closestBox && lastRootBoxWithChildren) { | 2304 if (!moveCaretToBoundary && !closestBox && lastRootBoxWithChildren) { |
| 2327 // y coordinate is below last root line box, pretend we hit it | 2305 // y coordinate is below last root line box, pretend we hit it |
| 2328 closestBox = lastRootBoxWithChildren->closestLeafChildForLogicalLeftPosi
tion(pointInLogicalContents.x()); | 2306 closestBox = lastRootBoxWithChildren->closestLeafChildForLogicalLeftPosi
tion(pointInLogicalContents.x()); |
| 2329 } | 2307 } |
| 2330 | 2308 |
| 2331 if (closestBox) { | 2309 if (closestBox) { |
| 2332 if (moveCaretToBoundary) { | 2310 if (moveCaretToBoundary) { |
| 2333 LayoutUnit firstRootBoxWithChildrenTop = std::min<LayoutUnit>(firstR
ootBoxWithChildren->selectionTop(), firstRootBoxWithChildren->logicalTop()); | 2311 LayoutUnit firstRootBoxWithChildrenTop = std::min<LayoutUnit>(firstR
ootBoxWithChildren->selectionTop(), firstRootBoxWithChildren->logicalTop()); |
| 2334 if (pointInLogicalContents.y() < firstRootBoxWithChildrenTop | 2312 if (pointInLogicalContents.y() < firstRootBoxWithChildrenTop) { |
| 2335 || (blocksAreFlipped && pointInLogicalContents.y() == firstRootB
oxWithChildrenTop)) { | |
| 2336 InlineBox* box = firstRootBoxWithChildren->firstLeafChild(); | 2313 InlineBox* box = firstRootBoxWithChildren->firstLeafChild(); |
| 2337 if (box->isLineBreak()) { | 2314 if (box->isLineBreak()) { |
| 2338 if (InlineBox* newBox = box->nextLeafChildIgnoringLineBreak(
)) | 2315 if (InlineBox* newBox = box->nextLeafChildIgnoringLineBreak(
)) |
| 2339 box = newBox; | 2316 box = newBox; |
| 2340 } | 2317 } |
| 2341 // y coordinate is above first root line box, so return the star
t of the first | 2318 // y coordinate is above first root line box, so return the star
t of the first |
| 2342 return PositionWithAffinity(positionForBox(box, true), DOWNSTREA
M); | 2319 return PositionWithAffinity(positionForBox(box, true), DOWNSTREA
M); |
| 2343 } | 2320 } |
| 2344 } | 2321 } |
| 2345 | 2322 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2390 offsetForContents(pointInContents); | 2367 offsetForContents(pointInContents); |
| 2391 LayoutPoint pointInLogicalContents(pointInContents); | 2368 LayoutPoint pointInLogicalContents(pointInContents); |
| 2392 | 2369 |
| 2393 if (childrenInline()) | 2370 if (childrenInline()) |
| 2394 return positionForPointWithInlineChildren(pointInLogicalContents); | 2371 return positionForPointWithInlineChildren(pointInLogicalContents); |
| 2395 | 2372 |
| 2396 RenderBox* lastCandidateBox = lastChildBox(); | 2373 RenderBox* lastCandidateBox = lastChildBox(); |
| 2397 while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox)) | 2374 while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox)) |
| 2398 lastCandidateBox = lastCandidateBox->previousSiblingBox(); | 2375 lastCandidateBox = lastCandidateBox->previousSiblingBox(); |
| 2399 | 2376 |
| 2400 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); | |
| 2401 if (lastCandidateBox) { | 2377 if (lastCandidateBox) { |
| 2402 if (pointInLogicalContents.y() > logicalTopForChild(lastCandidateBox) | 2378 if (pointInLogicalContents.y() > logicalTopForChild(lastCandidateBox) |
| 2403 || (!blocksAreFlipped && pointInLogicalContents.y() == logicalTopFor
Child(lastCandidateBox))) | 2379 || (pointInLogicalContents.y() == logicalTopForChild(lastCandidateBo
x))) |
| 2404 return positionForPointRespectingEditingBoundaries(this, lastCandida
teBox, pointInContents); | 2380 return positionForPointRespectingEditingBoundaries(this, lastCandida
teBox, pointInContents); |
| 2405 | 2381 |
| 2406 for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBo
x->nextSiblingBox()) { | 2382 for (RenderBox* childBox = firstChildBox(); childBox; childBox = childBo
x->nextSiblingBox()) { |
| 2407 if (!isChildHitTestCandidate(childBox)) | 2383 if (!isChildHitTestCandidate(childBox)) |
| 2408 continue; | 2384 continue; |
| 2409 LayoutUnit childLogicalBottom = logicalTopForChild(childBox) + logic
alHeightForChild(childBox); | 2385 LayoutUnit childLogicalBottom = logicalTopForChild(childBox) + logic
alHeightForChild(childBox); |
| 2410 // We hit child if our click is above the bottom of its padding box
(like IE6/7 and FF3). | 2386 // We hit child if our click is above the bottom of its padding box
(like IE6/7 and FF3). |
| 2411 if (isChildHitTestCandidate(childBox) && (pointInLogicalContents.y()
< childLogicalBottom | 2387 if (isChildHitTestCandidate(childBox) && (pointInLogicalContents.y()
< childLogicalBottom)) |
| 2412 || (blocksAreFlipped && pointInLogicalContents.y() == childLogic
alBottom))) | |
| 2413 return positionForPointRespectingEditingBoundaries(this, childBo
x, pointInContents); | 2388 return positionForPointRespectingEditingBoundaries(this, childBo
x, pointInContents); |
| 2414 } | 2389 } |
| 2415 } | 2390 } |
| 2416 | 2391 |
| 2417 // We only get here if there are no hit test candidate children below the cl
ick. | 2392 // We only get here if there are no hit test candidate children below the cl
ick. |
| 2418 return RenderBox::positionForPoint(point); | 2393 return RenderBox::positionForPoint(point); |
| 2419 } | 2394 } |
| 2420 | 2395 |
| 2421 void RenderBlock::offsetForContents(LayoutPoint& offset) const | 2396 void RenderBlock::offsetForContents(LayoutPoint& offset) const |
| 2422 { | 2397 { |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3148 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const | 3123 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render
Object* obj) const |
| 3149 { | 3124 { |
| 3150 showRenderObject(); | 3125 showRenderObject(); |
| 3151 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 3126 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
| 3152 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 3127 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
| 3153 } | 3128 } |
| 3154 | 3129 |
| 3155 #endif | 3130 #endif |
| 3156 | 3131 |
| 3157 } // namespace blink | 3132 } // namespace blink |
| OLD | NEW |