| 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 21 matching lines...) Expand all Loading... |
| 32 #include "bindings/v8/ExceptionState.h" | 32 #include "bindings/v8/ExceptionState.h" |
| 33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 34 #include "core/dom/Range.h" | 34 #include "core/dom/Range.h" |
| 35 #include "core/dom/Text.h" | 35 #include "core/dom/Text.h" |
| 36 #include "core/editing/VisibleUnits.h" | 36 #include "core/editing/VisibleUnits.h" |
| 37 #include "core/editing/htmlediting.h" | 37 #include "core/editing/htmlediting.h" |
| 38 #include "core/html/HTMLElement.h" | 38 #include "core/html/HTMLElement.h" |
| 39 #include "core/html/HTMLHtmlElement.h" | 39 #include "core/html/HTMLHtmlElement.h" |
| 40 #include "core/platform/graphics/FloatQuad.h" | 40 #include "core/platform/graphics/FloatQuad.h" |
| 41 #include "core/rendering/RenderBlock.h" | 41 #include "core/rendering/RenderBlock.h" |
| 42 #include "core/rendering/RenderText.h" |
| 42 #include "core/rendering/RootInlineBox.h" | 43 #include "core/rendering/RootInlineBox.h" |
| 43 #include "wtf/text/CString.h" | 44 #include "wtf/text/CString.h" |
| 44 | 45 |
| 45 namespace WebCore { | 46 namespace WebCore { |
| 46 | 47 |
| 47 using namespace HTMLNames; | 48 using namespace HTMLNames; |
| 48 | 49 |
| 49 VisiblePosition::VisiblePosition(const Position &pos, EAffinity affinity) | 50 VisiblePosition::VisiblePosition(const Position &pos, EAffinity affinity) |
| 50 { | 51 { |
| 51 init(pos, affinity); | 52 init(pos, affinity); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 if (box->bidiLevel() == level) | 242 if (box->bidiLevel() == level) |
| 242 break; | 243 break; |
| 243 level = box->bidiLevel(); | 244 level = box->bidiLevel(); |
| 244 } | 245 } |
| 245 renderer = box->renderer(); | 246 renderer = box->renderer(); |
| 246 offset = primaryDirection == LTR ? box->caretMinOffset() : box->
caretMaxOffset(); | 247 offset = primaryDirection == LTR ? box->caretMinOffset() : box->
caretMaxOffset(); |
| 247 } | 248 } |
| 248 break; | 249 break; |
| 249 } | 250 } |
| 250 | 251 |
| 252 if (renderer->isText()) |
| 253 offset += toRenderText(renderer)->textStartOffset(); |
| 251 p = createLegacyEditingPosition(renderer->node(), offset); | 254 p = createLegacyEditingPosition(renderer->node(), offset); |
| 252 | 255 |
| 253 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO
fTree() || p.atEndOfTree()) | 256 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO
fTree() || p.atEndOfTree()) |
| 254 return p; | 257 return p; |
| 255 | 258 |
| 256 ASSERT(p != m_deepPosition); | 259 ASSERT(p != m_deepPosition); |
| 257 } | 260 } |
| 258 } | 261 } |
| 259 | 262 |
| 260 VisiblePosition VisiblePosition::left(bool stayInEditableContent) const | 263 VisiblePosition VisiblePosition::left(bool stayInEditableContent) const |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 if (box->bidiLevel() == level) | 412 if (box->bidiLevel() == level) |
| 410 break; | 413 break; |
| 411 level = box->bidiLevel(); | 414 level = box->bidiLevel(); |
| 412 } | 415 } |
| 413 renderer = box->renderer(); | 416 renderer = box->renderer(); |
| 414 offset = primaryDirection == LTR ? box->caretMaxOffset() : box->
caretMinOffset(); | 417 offset = primaryDirection == LTR ? box->caretMaxOffset() : box->
caretMinOffset(); |
| 415 } | 418 } |
| 416 break; | 419 break; |
| 417 } | 420 } |
| 418 | 421 |
| 422 if (renderer->isText()) |
| 423 offset += toRenderText(renderer)->textStartOffset(); |
| 419 p = createLegacyEditingPosition(renderer->node(), offset); | 424 p = createLegacyEditingPosition(renderer->node(), offset); |
| 420 | 425 |
| 421 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO
fTree() || p.atEndOfTree()) | 426 if ((p.isCandidate() && p.downstream() != downstreamStart) || p.atStartO
fTree() || p.atEndOfTree()) |
| 422 return p; | 427 return p; |
| 423 | 428 |
| 424 ASSERT(p != m_deepPosition); | 429 ASSERT(p != m_deepPosition); |
| 425 } | 430 } |
| 426 } | 431 } |
| 427 | 432 |
| 428 VisiblePosition VisiblePosition::right(bool stayInEditableContent) const | 433 VisiblePosition VisiblePosition::right(bool stayInEditableContent) const |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 601 |
| 597 return textNode->data().characterStartingAt(offset); | 602 return textNode->data().characterStartingAt(offset); |
| 598 } | 603 } |
| 599 | 604 |
| 600 LayoutRect VisiblePosition::localCaretRect(RenderObject*& renderer) const | 605 LayoutRect VisiblePosition::localCaretRect(RenderObject*& renderer) const |
| 601 { | 606 { |
| 602 if (m_deepPosition.isNull()) { | 607 if (m_deepPosition.isNull()) { |
| 603 renderer = 0; | 608 renderer = 0; |
| 604 return IntRect(); | 609 return IntRect(); |
| 605 } | 610 } |
| 606 Node* node = m_deepPosition.anchorNode(); | 611 renderer = m_deepPosition.renderer(); |
| 607 | |
| 608 renderer = node->renderer(); | |
| 609 if (!renderer) | 612 if (!renderer) |
| 610 return LayoutRect(); | 613 return LayoutRect(); |
| 611 | 614 |
| 612 InlineBox* inlineBox; | 615 InlineBox* inlineBox; |
| 613 int caretOffset; | 616 int caretOffset; |
| 614 getInlineBoxAndOffset(inlineBox, caretOffset); | 617 getInlineBoxAndOffset(inlineBox, caretOffset); |
| 615 | 618 |
| 616 if (inlineBox) | 619 if (inlineBox) |
| 617 renderer = inlineBox->renderer(); | 620 renderer = inlineBox->renderer(); |
| 618 | 621 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 if (vpos) | 757 if (vpos) |
| 755 vpos->showTreeForThis(); | 758 vpos->showTreeForThis(); |
| 756 } | 759 } |
| 757 | 760 |
| 758 void showTree(const WebCore::VisiblePosition& vpos) | 761 void showTree(const WebCore::VisiblePosition& vpos) |
| 759 { | 762 { |
| 760 vpos.showTreeForThis(); | 763 vpos.showTreeForThis(); |
| 761 } | 764 } |
| 762 | 765 |
| 763 #endif | 766 #endif |
| OLD | NEW |