OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2008 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "sky/engine/config.h" | 20 #include "sky/engine/config.h" |
21 #include "sky/engine/core/rendering/RootInlineBox.h" | 21 #include "sky/engine/core/rendering/RootInlineBox.h" |
22 | 22 |
23 #include "sky/engine/core/dom/Document.h" | 23 #include "sky/engine/core/dom/Document.h" |
24 #include "sky/engine/core/dom/StyleEngine.h" | 24 #include "sky/engine/core/dom/StyleEngine.h" |
25 #include "sky/engine/core/rendering/EllipsisBox.h" | 25 #include "sky/engine/core/rendering/EllipsisBox.h" |
26 #include "sky/engine/core/rendering/HitTestResult.h" | 26 #include "sky/engine/core/rendering/HitTestResult.h" |
27 #include "sky/engine/core/rendering/InlineTextBox.h" | 27 #include "sky/engine/core/rendering/InlineTextBox.h" |
28 #include "sky/engine/core/rendering/PaintInfo.h" | 28 #include "sky/engine/core/rendering/PaintInfo.h" |
29 #include "sky/engine/core/rendering/RenderBlockFlow.h" | 29 #include "sky/engine/core/rendering/RenderParagraph.h" |
30 #include "sky/engine/core/rendering/RenderInline.h" | 30 #include "sky/engine/core/rendering/RenderInline.h" |
31 #include "sky/engine/core/rendering/RenderView.h" | 31 #include "sky/engine/core/rendering/RenderView.h" |
32 #include "sky/engine/core/rendering/VerticalPositionCache.h" | 32 #include "sky/engine/core/rendering/VerticalPositionCache.h" |
33 #include "sky/engine/platform/text/BidiResolver.h" | 33 #include "sky/engine/platform/text/BidiResolver.h" |
34 #include "sky/engine/wtf/unicode/Unicode.h" | 34 #include "sky/engine/wtf/unicode/Unicode.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 struct SameSizeAsRootInlineBox : public InlineFlowBox { | 38 struct SameSizeAsRootInlineBox : public InlineFlowBox { |
39 unsigned unsignedVariable; | 39 unsigned unsignedVariable; |
40 void* pointers[4]; | 40 void* pointers[3]; |
41 LayoutUnit layoutVariables[5]; | 41 LayoutUnit layoutVariables[5]; |
42 }; | 42 }; |
43 | 43 |
44 COMPILE_ASSERT(sizeof(RootInlineBox) == sizeof(SameSizeAsRootInlineBox), RootInl
ineBox_should_stay_small); | 44 COMPILE_ASSERT(sizeof(RootInlineBox) == sizeof(SameSizeAsRootInlineBox), RootInl
ineBox_should_stay_small); |
45 | 45 |
46 typedef WTF::HashMap<const RootInlineBox*, EllipsisBox*> EllipsisBoxMap; | 46 typedef WTF::HashMap<const RootInlineBox*, EllipsisBox*> EllipsisBoxMap; |
47 static EllipsisBoxMap* gEllipsisBoxMap = 0; | 47 static EllipsisBoxMap* gEllipsisBoxMap = 0; |
48 | 48 |
49 RootInlineBox::RootInlineBox(RenderBlockFlow& block) | 49 RootInlineBox::RootInlineBox(RenderParagraph& block) |
50 : InlineFlowBox(block) | 50 : InlineFlowBox(block) |
51 , m_lineBreakPos(0) | 51 , m_lineBreakPos(0) |
52 , m_lineBreakObj(0) | 52 , m_lineBreakObj(0) |
53 , m_lineTop(0) | 53 , m_lineTop(0) |
54 , m_lineBottom(0) | 54 , m_lineBottom(0) |
55 , m_lineTopWithLeading(0) | 55 , m_lineTopWithLeading(0) |
56 , m_lineBottomWithLeading(0) | 56 , m_lineBottomWithLeading(0) |
57 , m_selectionBottom(0) | 57 , m_selectionBottom(0) |
58 { | 58 { |
59 } | 59 } |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 LayoutUnit RootInlineBox::selectionTopAdjustedForPrecedingBlock() const | 385 LayoutUnit RootInlineBox::selectionTopAdjustedForPrecedingBlock() const |
386 { | 386 { |
387 LayoutUnit top = selectionTop(); | 387 LayoutUnit top = selectionTop(); |
388 | 388 |
389 RenderObject::SelectionState blockSelectionState = root().block().selectionS
tate(); | 389 RenderObject::SelectionState blockSelectionState = root().block().selectionS
tate(); |
390 if (blockSelectionState != RenderObject::SelectionInside && blockSelectionSt
ate != RenderObject::SelectionEnd) | 390 if (blockSelectionState != RenderObject::SelectionInside && blockSelectionSt
ate != RenderObject::SelectionEnd) |
391 return top; | 391 return top; |
392 | 392 |
393 LayoutSize offsetToBlockBefore; | 393 LayoutSize offsetToBlockBefore; |
394 if (RenderBlock* block = root().block().blockBeforeWithinSelectionRoot(offse
tToBlockBefore)) { | 394 if (RenderBlock* block = root().block().blockBeforeWithinSelectionRoot(offse
tToBlockBefore)) { |
395 if (block->isRenderBlockFlow()) { | 395 if (block->isRenderParagraph()) { |
396 if (RootInlineBox* lastLine = toRenderBlockFlow(block)->lastRootBox(
)) { | 396 if (RootInlineBox* lastLine = toRenderParagraph(block)->lastRootBox(
)) { |
397 RenderObject::SelectionState lastLineSelectionState = lastLine->
selectionState(); | 397 RenderObject::SelectionState lastLineSelectionState = lastLine->
selectionState(); |
398 if (lastLineSelectionState != RenderObject::SelectionInside && l
astLineSelectionState != RenderObject::SelectionStart) | 398 if (lastLineSelectionState != RenderObject::SelectionInside && l
astLineSelectionState != RenderObject::SelectionStart) |
399 return top; | 399 return top; |
400 | 400 |
401 LayoutUnit lastLineSelectionBottom = lastLine->selectionBottom()
+ offsetToBlockBefore.height(); | 401 LayoutUnit lastLineSelectionBottom = lastLine->selectionBottom()
+ offsetToBlockBefore.height(); |
402 top = std::max(top, lastLineSelectionBottom); | 402 top = std::max(top, lastLineSelectionBottom); |
403 } | 403 } |
404 } | 404 } |
405 } | 405 } |
406 | 406 |
407 return top; | 407 return top; |
408 } | 408 } |
409 | 409 |
410 LayoutUnit RootInlineBox::selectionBottom() const | 410 LayoutUnit RootInlineBox::selectionBottom() const |
411 { | 411 { |
412 LayoutUnit selectionBottom = m_selectionBottom; | 412 LayoutUnit selectionBottom = m_selectionBottom; |
413 if (m_hasAnnotationsAfter) | 413 if (m_hasAnnotationsAfter) |
414 selectionBottom += computeUnderAnnotationAdjustment(m_lineBottom); | 414 selectionBottom += computeUnderAnnotationAdjustment(m_lineBottom); |
415 return selectionBottom; | 415 return selectionBottom; |
416 } | 416 } |
417 | 417 |
418 int RootInlineBox::blockDirectionPointInLine() const | 418 int RootInlineBox::blockDirectionPointInLine() const |
419 { | 419 { |
420 return std::max(lineTop(), selectionTop()); | 420 return std::max(lineTop(), selectionTop()); |
421 } | 421 } |
422 | 422 |
423 RenderBlockFlow& RootInlineBox::block() const | 423 RenderParagraph& RootInlineBox::block() const |
424 { | 424 { |
425 return toRenderBlockFlow(renderer()); | 425 return toRenderParagraph(renderer()); |
426 } | 426 } |
427 | 427 |
428 static bool isEditableLeaf(InlineBox* leaf) | 428 static bool isEditableLeaf(InlineBox* leaf) |
429 { | 429 { |
430 return leaf && leaf->renderer().node() && leaf->renderer().node()->hasEditab
leStyle(); | 430 return leaf && leaf->renderer().node() && leaf->renderer().node()->hasEditab
leStyle(); |
431 } | 431 } |
432 | 432 |
433 InlineBox* RootInlineBox::closestLeafChildForPoint(const IntPoint& pointInConten
ts, bool onlyEditableLeaves) | 433 InlineBox* RootInlineBox::closestLeafChildForPoint(const IntPoint& pointInConten
ts, bool onlyEditableLeaves) |
434 { | 434 { |
435 return closestLeafChildForLogicalLeftPosition(pointInContents.x(), onlyEdita
bleLeaves); | 435 return closestLeafChildForLogicalLeftPosition(pointInContents.x(), onlyEdita
bleLeaves); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 } | 803 } |
804 | 804 |
805 #ifndef NDEBUG | 805 #ifndef NDEBUG |
806 const char* RootInlineBox::boxName() const | 806 const char* RootInlineBox::boxName() const |
807 { | 807 { |
808 return "RootInlineBox"; | 808 return "RootInlineBox"; |
809 } | 809 } |
810 #endif | 810 #endif |
811 | 811 |
812 } // namespace blink | 812 } // namespace blink |
OLD | NEW |