OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights
reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 return logicalLeft; | 380 return logicalLeft; |
381 } | 381 } |
382 | 382 |
383 FloatWillBeLayoutUnit InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* f
irstChild, InlineBox* lastChild, | 383 FloatWillBeLayoutUnit InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* f
irstChild, InlineBox* lastChild, |
384 FloatWillBeLayoutUnit& logicalLeft, FloatWillBeLayoutUnit& minLogicalLeft, F
loatWillBeLayoutUnit& maxLogicalRight, bool& needsWordSpacing) | 384 FloatWillBeLayoutUnit& logicalLeft, FloatWillBeLayoutUnit& minLogicalLeft, F
loatWillBeLayoutUnit& maxLogicalRight, bool& needsWordSpacing) |
385 { | 385 { |
386 for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->n
extOnLine()) { | 386 for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->n
extOnLine()) { |
387 if (curr->layoutObject().isText()) { | 387 if (curr->layoutObject().isText()) { |
388 InlineTextBox* text = toInlineTextBox(curr); | 388 InlineTextBox* text = toInlineTextBox(curr); |
389 LayoutText& rt = text->layoutObject(); | 389 LayoutText& rt = text->layoutObject(); |
390 FloatWillBeLayoutUnit space; | 390 FloatWillBeLayoutUnit characterSpace; |
391 if (rt.textLength()) { | 391 if (rt.textLength()) { |
392 if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->st
art()))) | 392 if (needsWordSpacing && isSpaceOrNewline(rt.characterAt(text->st
art()))) |
393 space = rt.style(isFirstLineStyle())->font().fontDescription
().wordSpacing(); | 393 characterSpace = rt.style(isFirstLineStyle())->font().fontDe
scription().wordSpacing(); |
394 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end())
); | 394 needsWordSpacing = !isSpaceOrNewline(rt.characterAt(text->end())
); |
395 } | 395 } |
396 if (isLeftToRightDirection()) { | 396 if (isLeftToRightDirection()) { |
397 logicalLeft += space; | 397 logicalLeft += characterSpace; |
398 text->setLogicalLeft(logicalLeft); | 398 text->setLogicalLeft(logicalLeft); |
399 } else { | 399 } else { |
400 text->setLogicalLeft(logicalLeft); | 400 text->setLogicalLeft(logicalLeft); |
401 logicalLeft += space; | 401 logicalLeft += characterSpace; |
402 } | 402 } |
403 if (knownToHaveNoOverflow()) | 403 if (knownToHaveNoOverflow()) |
404 minLogicalLeft = std::min(logicalLeft, minLogicalLeft); | 404 minLogicalLeft = std::min(logicalLeft, minLogicalLeft); |
405 logicalLeft += text->logicalWidth(); | 405 logicalLeft += text->logicalWidth(); |
406 if (knownToHaveNoOverflow()) | 406 if (knownToHaveNoOverflow()) |
407 maxLogicalRight = std::max(logicalLeft, maxLogicalRight); | 407 maxLogicalRight = std::max(logicalLeft, maxLogicalRight); |
408 } else { | 408 } else { |
409 if (curr->layoutObject().isOutOfFlowPositioned()) { | 409 if (curr->layoutObject().isOutOfFlowPositioned()) { |
410 if (curr->layoutObject().parent()->style()->isLeftToRightDirecti
on()) { | 410 if (curr->layoutObject().parent()->style()->isLeftToRightDirecti
on()) { |
411 curr->setLogicalLeft(logicalLeft); | 411 curr->setLogicalLeft(logicalLeft); |
(...skipping 21 matching lines...) Expand all Loading... |
433 LayoutUnit logicalRightMargin = isHorizontal() ? curr->boxModelO
bject()->marginRight() : curr->boxModelObject()->marginBottom(); | 433 LayoutUnit logicalRightMargin = isHorizontal() ? curr->boxModelO
bject()->marginRight() : curr->boxModelObject()->marginBottom(); |
434 | 434 |
435 logicalLeft += logicalLeftMargin; | 435 logicalLeft += logicalLeftMargin; |
436 curr->setLogicalLeft(logicalLeft); | 436 curr->setLogicalLeft(logicalLeft); |
437 if (knownToHaveNoOverflow()) | 437 if (knownToHaveNoOverflow()) |
438 minLogicalLeft = std::min(logicalLeft, minLogicalLeft); | 438 minLogicalLeft = std::min(logicalLeft, minLogicalLeft); |
439 logicalLeft += curr->logicalWidth(); | 439 logicalLeft += curr->logicalWidth(); |
440 if (knownToHaveNoOverflow()) | 440 if (knownToHaveNoOverflow()) |
441 maxLogicalRight = std::max(logicalLeft, maxLogicalRight); | 441 maxLogicalRight = std::max(logicalLeft, maxLogicalRight); |
442 logicalLeft += logicalRightMargin; | 442 logicalLeft += logicalRightMargin; |
443 // If we encounter any space after this inline block then ensure
it is treated as the space between two words. | 443 // If we encounter any characterSpace after this inline block th
en ensure it is treated as the characterSpace between two words. |
444 needsWordSpacing = true; | 444 needsWordSpacing = true; |
445 } | 445 } |
446 } | 446 } |
447 } | 447 } |
448 return logicalLeft; | 448 return logicalLeft; |
449 } | 449 } |
450 | 450 |
451 FontBaseline InlineFlowBox::dominantBaseline() const | 451 FontBaseline InlineFlowBox::dominantBaseline() const |
452 { | 452 { |
453 // Use "central" (Ideographic) baseline if writing-mode is vertical-* and te
xt-orientation is not sideways-*. | 453 // Use "central" (Ideographic) baseline if writing-mode is vertical-* and te
xt-orientation is not sideways-*. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 // The primary purpose of this function is to compute the maximal ascent and
descent values for | 488 // The primary purpose of this function is to compute the maximal ascent and
descent values for |
489 // a line. These values are computed based off the block's line-box-contain
property, which indicates | 489 // a line. These values are computed based off the block's line-box-contain
property, which indicates |
490 // what parts of descendant boxes have to fit within the line. | 490 // what parts of descendant boxes have to fit within the line. |
491 // | 491 // |
492 // The maxAscent value represents the distance of the highest point of any b
ox (typically including line-height) from | 492 // The maxAscent value represents the distance of the highest point of any b
ox (typically including line-height) from |
493 // the root box's baseline. The maxDescent value represents the distance of
the lowest point of any box | 493 // the root box's baseline. The maxDescent value represents the distance of
the lowest point of any box |
494 // (also typically including line-height) from the root box baseline. These
values can be negative. | 494 // (also typically including line-height) from the root box baseline. These
values can be negative. |
495 // | 495 // |
496 // A secondary purpose of this function is to store the offset of every box'
s baseline from the root box's | 496 // A secondary purpose of this function is to store the offset of every box'
s baseline from the root box's |
497 // baseline. This information is cached in the logicalTop() of every box. We
're effectively just using | 497 // baseline. This information is cached in the logicalTop() of every box. We
're effectively just using |
498 // the logicalTop() as scratch space. | 498 // the logicalTop() as scratch characterSpace. |
499 // | 499 // |
500 // Because a box can be positioned such that it ends up fully above or fully
below the | 500 // Because a box can be positioned such that it ends up fully above or fully
below the |
501 // root line box, we only consider it to affect the maxAscent and maxDescent
values if some | 501 // root line box, we only consider it to affect the maxAscent and maxDescent
values if some |
502 // part of the box (EXCLUDING leading) is above (for ascent) or below (for d
escent) the root box's baseline. | 502 // part of the box (EXCLUDING leading) is above (for ascent) or below (for d
escent) the root box's baseline. |
503 bool affectsAscent = false; | 503 bool affectsAscent = false; |
504 bool affectsDescent = false; | 504 bool affectsDescent = false; |
505 bool checkChildren = !descendantsHaveSameLineHeightAndBaseline(); | 505 bool checkChildren = !descendantsHaveSameLineHeightAndBaseline(); |
506 | 506 |
507 if (isRootInlineBox()) { | 507 if (isRootInlineBox()) { |
508 // Examine our root box. | 508 // Examine our root box. |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 top = std::max(rootBox.lineTop(), top); | 1040 top = std::max(rootBox.lineTop(), top); |
1041 logicalHeight = bottom - top; | 1041 logicalHeight = bottom - top; |
1042 } | 1042 } |
1043 | 1043 |
1044 // Move x/y to our coordinates. | 1044 // Move x/y to our coordinates. |
1045 LayoutRect rect(minX, minY, width, height); | 1045 LayoutRect rect(minX, minY, width, height); |
1046 flipForWritingMode(rect); | 1046 flipForWritingMode(rect); |
1047 rect.moveBy(accumulatedOffset); | 1047 rect.moveBy(accumulatedOffset); |
1048 | 1048 |
1049 if (visibleToHitTestRequest(result.hitTestRequest()) && locationInContainer.
intersects(rect)) { | 1049 if (visibleToHitTestRequest(result.hitTestRequest()) && locationInContainer.
intersects(rect)) { |
1050 layoutObject().updateHitTestResult(result, flipForWritingMode(locationIn
Container.point() - toLayoutSize(accumulatedOffset))); // Don't add in m_x or m_
y here, we want coords in the containing block's space. | 1050 layoutObject().updateHitTestResult(result, flipForWritingMode(locationIn
Container.point() - toLayoutSize(accumulatedOffset))); // Don't add in m_x or m_
y here, we want coords in the containing block's characterSpace. |
1051 if (!result.addNodeToListBasedTestResult(layoutObject().node(), location
InContainer, rect)) | 1051 if (!result.addNodeToListBasedTestResult(layoutObject().node(), location
InContainer, rect)) |
1052 return true; | 1052 return true; |
1053 } | 1053 } |
1054 | 1054 |
1055 return false; | 1055 return false; |
1056 } | 1056 } |
1057 | 1057 |
1058 void InlineFlowBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf
fset, LayoutUnit lineTop, LayoutUnit lineBottom) | 1058 void InlineFlowBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf
fset, LayoutUnit lineTop, LayoutUnit lineBottom) |
1059 { | 1059 { |
1060 InlineFlowBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto
m); | 1060 InlineFlowBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto
m); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 ASSERT(child->prevOnLine() == prev); | 1310 ASSERT(child->prevOnLine() == prev); |
1311 prev = child; | 1311 prev = child; |
1312 } | 1312 } |
1313 ASSERT(prev == m_lastChild); | 1313 ASSERT(prev == m_lastChild); |
1314 #endif | 1314 #endif |
1315 } | 1315 } |
1316 | 1316 |
1317 #endif | 1317 #endif |
1318 | 1318 |
1319 } // namespace blink | 1319 } // namespace blink |
OLD | NEW |