OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 lastLineBottom += rb->logicalTop(); | 257 lastLineBottom += rb->logicalTop(); |
258 } | 258 } |
259 | 259 |
260 rt->setLogicalTop(-firstLineRubyTextTop + lastLineBottom); | 260 rt->setLogicalTop(-firstLineRubyTextTop + lastLineBottom); |
261 } | 261 } |
262 | 262 |
263 // Update our overflow to account for the new RenderRubyText position. | 263 // Update our overflow to account for the new RenderRubyText position. |
264 computeOverflow(clientLogicalBottom()); | 264 computeOverflow(clientLogicalBottom()); |
265 } | 265 } |
266 | 266 |
267 void RenderRubyRun::getOverhang(bool firstLine, RenderObject* startRenderer, Ren
derObject* endRenderer, int& startOverhang, int& endOverhang) const | 267 void RenderRubyRun::getOverhang(bool isFirstLine, RenderObject* startRenderer, R
enderObject* endRenderer, int& startOverhang, int& endOverhang) const |
268 { | 268 { |
269 ASSERT(!needsLayout()); | 269 ASSERT(!needsLayout()); |
270 | 270 |
271 startOverhang = 0; | 271 startOverhang = 0; |
272 endOverhang = 0; | 272 endOverhang = 0; |
273 | 273 |
274 RenderRubyBase* rubyBase = this->rubyBase(); | 274 RenderRubyBase* rubyBase = this->rubyBase(); |
275 RenderRubyText* rubyText = this->rubyText(); | 275 RenderRubyText* rubyText = this->rubyText(); |
276 | 276 |
277 if (!rubyBase || !rubyText) | 277 if (!rubyBase || !rubyText) |
278 return; | 278 return; |
279 | 279 |
280 if (!rubyBase->firstRootBox()) | 280 if (!rubyBase->firstRootBox()) |
281 return; | 281 return; |
282 | 282 |
| 283 const OwnOrFirstLineStyle firstLine = isFirstLine ? FirstLineStyle : OwnStyl
e; |
283 int logicalWidth = this->logicalWidth(); | 284 int logicalWidth = this->logicalWidth(); |
284 int logicalLeftOverhang = std::numeric_limits<int>::max(); | 285 int logicalLeftOverhang = std::numeric_limits<int>::max(); |
285 int logicalRightOverhang = std::numeric_limits<int>::max(); | 286 int logicalRightOverhang = std::numeric_limits<int>::max(); |
286 for (RootInlineBox* rootInlineBox = rubyBase->firstRootBox(); rootInlineBox;
rootInlineBox = rootInlineBox->nextRootBox()) { | 287 for (RootInlineBox* rootInlineBox = rubyBase->firstRootBox(); rootInlineBox;
rootInlineBox = rootInlineBox->nextRootBox()) { |
287 logicalLeftOverhang = std::min<int>(logicalLeftOverhang, rootInlineBox->
logicalLeft()); | 288 logicalLeftOverhang = std::min<int>(logicalLeftOverhang, rootInlineBox->
logicalLeft()); |
288 logicalRightOverhang = std::min<int>(logicalRightOverhang, logicalWidth
- rootInlineBox->logicalRight()); | 289 logicalRightOverhang = std::min<int>(logicalRightOverhang, logicalWidth
- rootInlineBox->logicalRight()); |
289 } | 290 } |
290 | 291 |
291 startOverhang = style()->isLeftToRightDirection() ? logicalLeftOverhang : lo
gicalRightOverhang; | 292 startOverhang = style()->isLeftToRightDirection() ? logicalLeftOverhang : lo
gicalRightOverhang; |
292 endOverhang = style()->isLeftToRightDirection() ? logicalRightOverhang : log
icalLeftOverhang; | 293 endOverhang = style()->isLeftToRightDirection() ? logicalRightOverhang : log
icalLeftOverhang; |
293 | 294 |
294 if (!startRenderer || !startRenderer->isText() || startRenderer->style(first
Line)->fontSize() > rubyBase->style(firstLine)->fontSize()) | 295 if (!startRenderer || !startRenderer->isText() || startRenderer->style(first
Line)->fontSize() > rubyBase->style(firstLine)->fontSize()) |
295 startOverhang = 0; | 296 startOverhang = 0; |
296 | 297 |
297 if (!endRenderer || !endRenderer->isText() || endRenderer->style(firstLine)-
>fontSize() > rubyBase->style(firstLine)->fontSize()) | 298 if (!endRenderer || !endRenderer->isText() || endRenderer->style(firstLine)-
>fontSize() > rubyBase->style(firstLine)->fontSize()) |
298 endOverhang = 0; | 299 endOverhang = 0; |
299 | 300 |
300 // We overhang a ruby only if the neighboring render object is a text. | 301 // We overhang a ruby only if the neighboring render object is a text. |
301 // We can overhang the ruby by no more than half the width of the neighborin
g text | 302 // We can overhang the ruby by no more than half the width of the neighborin
g text |
302 // and no more than half the font size. | 303 // and no more than half the font size. |
303 int halfWidthOfFontSize = rubyText->style(firstLine)->fontSize() / 2; | 304 int halfWidthOfFontSize = rubyText->style(firstLine)->fontSize() / 2; |
304 if (startOverhang) | 305 if (startOverhang) |
305 startOverhang = std::min<int>(startOverhang, std::min<int>(toRenderText(
startRenderer)->minLogicalWidth(), halfWidthOfFontSize)); | 306 startOverhang = std::min<int>(startOverhang, std::min<int>(toRenderText(
startRenderer)->minLogicalWidth(), halfWidthOfFontSize)); |
306 if (endOverhang) | 307 if (endOverhang) |
307 endOverhang = std::min<int>(endOverhang, std::min<int>(toRenderText(endR
enderer)->minLogicalWidth(), halfWidthOfFontSize)); | 308 endOverhang = std::min<int>(endOverhang, std::min<int>(toRenderText(endR
enderer)->minLogicalWidth(), halfWidthOfFontSize)); |
308 } | 309 } |
309 | 310 |
310 } // namespace WebCore | 311 } // namespace WebCore |
OLD | NEW |