| 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 18 matching lines...) Expand all  Loading... | 
| 29  */ | 29  */ | 
| 30 | 30 | 
| 31 #include "config.h" | 31 #include "config.h" | 
| 32 | 32 | 
| 33 #include "core/rendering/RenderRubyRun.h" | 33 #include "core/rendering/RenderRubyRun.h" | 
| 34 | 34 | 
| 35 #include "core/rendering/RenderRubyBase.h" | 35 #include "core/rendering/RenderRubyBase.h" | 
| 36 #include "core/rendering/RenderRubyText.h" | 36 #include "core/rendering/RenderRubyText.h" | 
| 37 #include "core/rendering/RenderText.h" | 37 #include "core/rendering/RenderText.h" | 
| 38 | 38 | 
| 39 using namespace std; |  | 
| 40 |  | 
| 41 namespace WebCore { | 39 namespace WebCore { | 
| 42 | 40 | 
| 43 RenderRubyRun::RenderRubyRun() | 41 RenderRubyRun::RenderRubyRun() | 
| 44     : RenderBlockFlow(0) | 42     : RenderBlockFlow(0) | 
| 45 { | 43 { | 
| 46     setReplaced(true); | 44     setReplaced(true); | 
| 47     setInline(true); | 45     setInline(true); | 
| 48 } | 46 } | 
| 49 | 47 | 
| 50 RenderRubyRun::~RenderRubyRun() | 48 RenderRubyRun::~RenderRubyRun() | 
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 276     RenderRubyBase* rubyBase = this->rubyBase(); | 274     RenderRubyBase* rubyBase = this->rubyBase(); | 
| 277     RenderRubyText* rubyText = this->rubyText(); | 275     RenderRubyText* rubyText = this->rubyText(); | 
| 278 | 276 | 
| 279     if (!rubyBase || !rubyText) | 277     if (!rubyBase || !rubyText) | 
| 280         return; | 278         return; | 
| 281 | 279 | 
| 282     if (!rubyBase->firstRootBox()) | 280     if (!rubyBase->firstRootBox()) | 
| 283         return; | 281         return; | 
| 284 | 282 | 
| 285     int logicalWidth = this->logicalWidth(); | 283     int logicalWidth = this->logicalWidth(); | 
| 286     int logicalLeftOverhang = numeric_limits<int>::max(); | 284     int logicalLeftOverhang = std::numeric_limits<int>::max(); | 
| 287     int logicalRightOverhang = numeric_limits<int>::max(); | 285     int logicalRightOverhang = std::numeric_limits<int>::max(); | 
| 288     for (RootInlineBox* rootInlineBox = rubyBase->firstRootBox(); rootInlineBox;
      rootInlineBox = rootInlineBox->nextRootBox()) { | 286     for (RootInlineBox* rootInlineBox = rubyBase->firstRootBox(); rootInlineBox;
      rootInlineBox = rootInlineBox->nextRootBox()) { | 
| 289         logicalLeftOverhang = min<int>(logicalLeftOverhang, rootInlineBox->logic
     alLeft()); | 287         logicalLeftOverhang = std::min<int>(logicalLeftOverhang, rootInlineBox->
     logicalLeft()); | 
| 290         logicalRightOverhang = min<int>(logicalRightOverhang, logicalWidth - roo
     tInlineBox->logicalRight()); | 288         logicalRightOverhang = std::min<int>(logicalRightOverhang, logicalWidth 
     - rootInlineBox->logicalRight()); | 
| 291     } | 289     } | 
| 292 | 290 | 
| 293     startOverhang = style()->isLeftToRightDirection() ? logicalLeftOverhang : lo
     gicalRightOverhang; | 291     startOverhang = style()->isLeftToRightDirection() ? logicalLeftOverhang : lo
     gicalRightOverhang; | 
| 294     endOverhang = style()->isLeftToRightDirection() ? logicalRightOverhang : log
     icalLeftOverhang; | 292     endOverhang = style()->isLeftToRightDirection() ? logicalRightOverhang : log
     icalLeftOverhang; | 
| 295 | 293 | 
| 296     if (!startRenderer || !startRenderer->isText() || startRenderer->style(first
     Line)->fontSize() > rubyBase->style(firstLine)->fontSize()) | 294     if (!startRenderer || !startRenderer->isText() || startRenderer->style(first
     Line)->fontSize() > rubyBase->style(firstLine)->fontSize()) | 
| 297         startOverhang = 0; | 295         startOverhang = 0; | 
| 298 | 296 | 
| 299     if (!endRenderer || !endRenderer->isText() || endRenderer->style(firstLine)-
     >fontSize() > rubyBase->style(firstLine)->fontSize()) | 297     if (!endRenderer || !endRenderer->isText() || endRenderer->style(firstLine)-
     >fontSize() > rubyBase->style(firstLine)->fontSize()) | 
| 300         endOverhang = 0; | 298         endOverhang = 0; | 
| 301 | 299 | 
| 302     // We overhang a ruby only if the neighboring render object is a text. | 300     // We overhang a ruby only if the neighboring render object is a text. | 
| 303     // We can overhang the ruby by no more than half the width of the neighborin
     g text | 301     // We can overhang the ruby by no more than half the width of the neighborin
     g text | 
| 304     // and no more than half the font size. | 302     // and no more than half the font size. | 
| 305     int halfWidthOfFontSize = rubyText->style(firstLine)->fontSize() / 2; | 303     int halfWidthOfFontSize = rubyText->style(firstLine)->fontSize() / 2; | 
| 306     if (startOverhang) | 304     if (startOverhang) | 
| 307         startOverhang = min<int>(startOverhang, min<int>(toRenderText(startRende
     rer)->minLogicalWidth(), halfWidthOfFontSize)); | 305         startOverhang = std::min<int>(startOverhang, std::min<int>(toRenderText(
     startRenderer)->minLogicalWidth(), halfWidthOfFontSize)); | 
| 308     if (endOverhang) | 306     if (endOverhang) | 
| 309         endOverhang = min<int>(endOverhang, min<int>(toRenderText(endRenderer)->
     minLogicalWidth(), halfWidthOfFontSize)); | 307         endOverhang = std::min<int>(endOverhang, std::min<int>(toRenderText(endR
     enderer)->minLogicalWidth(), halfWidthOfFontSize)); | 
| 310 } | 308 } | 
| 311 | 309 | 
| 312 } // namespace WebCore | 310 } // namespace WebCore | 
| OLD | NEW | 
|---|