OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. | 3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "HTMLNames.h" | 31 #include "HTMLNames.h" |
32 #include "core/dom/Document.h" | 32 #include "core/dom/Document.h" |
33 #include "core/dom/Range.h" | 33 #include "core/dom/Range.h" |
34 #include "core/dom/Text.h" | 34 #include "core/dom/Text.h" |
35 #include "core/editing/VisibleUnits.h" | 35 #include "core/editing/VisibleUnits.h" |
36 #include "core/editing/htmlediting.h" | 36 #include "core/editing/htmlediting.h" |
37 #include "core/html/HTMLElement.h" | 37 #include "core/html/HTMLElement.h" |
38 #include "core/html/HTMLHtmlElement.h" | 38 #include "core/html/HTMLHtmlElement.h" |
39 #include "core/platform/graphics/FloatQuad.h" | 39 #include "core/platform/graphics/FloatQuad.h" |
40 #include "core/rendering/RenderBlock.h" | 40 #include "core/rendering/RenderBlock.h" |
| 41 #include "core/rendering/RenderText.h" |
41 #include "core/rendering/RootInlineBox.h" | 42 #include "core/rendering/RootInlineBox.h" |
42 #include "wtf/text/CString.h" | 43 #include "wtf/text/CString.h" |
43 | 44 |
44 namespace WebCore { | 45 namespace WebCore { |
45 | 46 |
46 using namespace HTMLNames; | 47 using namespace HTMLNames; |
47 | 48 |
48 VisiblePosition::VisiblePosition(const Position &pos, EAffinity affinity) | 49 VisiblePosition::VisiblePosition(const Position &pos, EAffinity affinity) |
49 { | 50 { |
50 init(pos, affinity); | 51 init(pos, affinity); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 if (box->bidiLevel() == level) | 241 if (box->bidiLevel() == level) |
241 break; | 242 break; |
242 level = box->bidiLevel(); | 243 level = box->bidiLevel(); |
243 } | 244 } |
244 renderer = box->renderer(); | 245 renderer = box->renderer(); |
245 offset = primaryDirection == LTR ? box->caretMinOffset() : box->
caretMaxOffset(); | 246 offset = primaryDirection == LTR ? box->caretMinOffset() : box->
caretMaxOffset(); |
246 } | 247 } |
247 break; | 248 break; |
248 } | 249 } |
249 | 250 |
| 251 if (renderer->isText()) |
| 252 offset += toRenderText(renderer)->textStartOffset(); |
250 p = createLegacyEditingPosition(renderer->node(), offset); | 253 p = createLegacyEditingPosition(renderer->node(), offset); |
251 | 254 |
252 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO
fTree() || p.atEndOfTree()) | 255 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO
fTree() || p.atEndOfTree()) |
253 return p; | 256 return p; |
254 | 257 |
255 ASSERT(p != m_deepPosition); | 258 ASSERT(p != m_deepPosition); |
256 } | 259 } |
257 } | 260 } |
258 | 261 |
259 VisiblePosition VisiblePosition::left(bool stayInEditableContent) const | 262 VisiblePosition VisiblePosition::left(bool stayInEditableContent) const |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 if (box->bidiLevel() == level) | 411 if (box->bidiLevel() == level) |
409 break; | 412 break; |
410 level = box->bidiLevel(); | 413 level = box->bidiLevel(); |
411 } | 414 } |
412 renderer = box->renderer(); | 415 renderer = box->renderer(); |
413 offset = primaryDirection == LTR ? box->caretMaxOffset() : box->
caretMinOffset(); | 416 offset = primaryDirection == LTR ? box->caretMaxOffset() : box->
caretMinOffset(); |
414 } | 417 } |
415 break; | 418 break; |
416 } | 419 } |
417 | 420 |
| 421 if (renderer->isText()) |
| 422 offset += toRenderText(renderer)->textStartOffset(); |
418 p = createLegacyEditingPosition(renderer->node(), offset); | 423 p = createLegacyEditingPosition(renderer->node(), offset); |
419 | 424 |
420 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO
fTree() || p.atEndOfTree()) | 425 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO
fTree() || p.atEndOfTree()) |
421 return p; | 426 return p; |
422 | 427 |
423 ASSERT(p != m_deepPosition); | 428 ASSERT(p != m_deepPosition); |
424 } | 429 } |
425 } | 430 } |
426 | 431 |
427 VisiblePosition VisiblePosition::right(bool stayInEditableContent) const | 432 VisiblePosition VisiblePosition::right(bool stayInEditableContent) const |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 | 600 |
596 return textNode->data().characterStartingAt(offset); | 601 return textNode->data().characterStartingAt(offset); |
597 } | 602 } |
598 | 603 |
599 LayoutRect VisiblePosition::localCaretRect(RenderObject*& renderer) const | 604 LayoutRect VisiblePosition::localCaretRect(RenderObject*& renderer) const |
600 { | 605 { |
601 if (m_deepPosition.isNull()) { | 606 if (m_deepPosition.isNull()) { |
602 renderer = 0; | 607 renderer = 0; |
603 return IntRect(); | 608 return IntRect(); |
604 } | 609 } |
605 Node* node = m_deepPosition.anchorNode(); | 610 renderer = m_deepPosition.renderer(); |
606 | |
607 renderer = node->renderer(); | |
608 if (!renderer) | 611 if (!renderer) |
609 return LayoutRect(); | 612 return LayoutRect(); |
610 | 613 |
611 InlineBox* inlineBox; | 614 InlineBox* inlineBox; |
612 int caretOffset; | 615 int caretOffset; |
613 getInlineBoxAndOffset(inlineBox, caretOffset); | 616 getInlineBoxAndOffset(inlineBox, caretOffset); |
614 | 617 |
615 if (inlineBox) | 618 if (inlineBox) |
616 renderer = inlineBox->renderer(); | 619 renderer = inlineBox->renderer(); |
617 | 620 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 if (vpos) | 756 if (vpos) |
754 vpos->showTreeForThis(); | 757 vpos->showTreeForThis(); |
755 } | 758 } |
756 | 759 |
757 void showTree(const WebCore::VisiblePosition& vpos) | 760 void showTree(const WebCore::VisiblePosition& vpos) |
758 { | 761 { |
759 vpos.showTreeForThis(); | 762 vpos.showTreeForThis(); |
760 } | 763 } |
761 | 764 |
762 #endif | 765 #endif |
OLD | NEW |