OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 HTMLElement* innerText = innerTextElement(); | 438 HTMLElement* innerText = innerTextElement(); |
439 if (!innerText) | 439 if (!innerText) |
440 return 0; | 440 return 0; |
441 | 441 |
442 if (!innerText->firstChild()) | 442 if (!innerText->firstChild()) |
443 return Range::create(document(), innerText, 0, innerText, 0); | 443 return Range::create(document(), innerText, 0, innerText, 0); |
444 | 444 |
445 int offset = 0; | 445 int offset = 0; |
446 Node* startNode = 0; | 446 Node* startNode = 0; |
447 Node* endNode = 0; | 447 Node* endNode = 0; |
448 for (Node* node = innerText->firstChild(); node; node = NodeTraversal::next(
node, innerText)) { | 448 for (Node* node = innerText->firstChild(); node; node = NodeTraversal::next(
*node, innerText)) { |
449 ASSERT(!node->firstChild()); | 449 ASSERT(!node->firstChild()); |
450 ASSERT(node->isTextNode() || node->hasTagName(brTag)); | 450 ASSERT(node->isTextNode() || node->hasTagName(brTag)); |
451 int length = node->isTextNode() ? lastOffsetInNode(node) : 1; | 451 int length = node->isTextNode() ? lastOffsetInNode(node) : 1; |
452 | 452 |
453 if (offset <= start && start <= offset + length) | 453 if (offset <= start && start <= offset + length) |
454 setContainerAndOffsetForRange(node, start - offset, startNode, start
); | 454 setContainerAndOffsetForRange(node, start - offset, startNode, start
); |
455 | 455 |
456 if (offset <= end && end <= offset + length) { | 456 if (offset <= end && end <= offset + length) { |
457 setContainerAndOffsetForRange(node, end - offset, endNode, end); | 457 setContainerAndOffsetForRange(node, end - offset, endNode, end); |
458 break; | 458 break; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 return result.toString(); | 531 return result.toString(); |
532 } | 532 } |
533 | 533 |
534 String HTMLTextFormControlElement::innerTextValue() const | 534 String HTMLTextFormControlElement::innerTextValue() const |
535 { | 535 { |
536 HTMLElement* innerText = innerTextElement(); | 536 HTMLElement* innerText = innerTextElement(); |
537 if (!innerText || !isTextFormControl()) | 537 if (!innerText || !isTextFormControl()) |
538 return emptyString(); | 538 return emptyString(); |
539 | 539 |
540 StringBuilder result; | 540 StringBuilder result; |
541 for (Node* node = innerText; node; node = NodeTraversal::next(node, innerTex
t)) { | 541 for (Node* node = innerText; node; node = NodeTraversal::next(*node, innerTe
xt)) { |
542 if (node->hasTagName(brTag)) | 542 if (node->hasTagName(brTag)) |
543 result.append(newlineCharacter); | 543 result.append(newlineCharacter); |
544 else if (node->isTextNode()) | 544 else if (node->isTextNode()) |
545 result.append(toText(node)->data()); | 545 result.append(toText(node)->data()); |
546 } | 546 } |
547 return finishText(result); | 547 return finishText(result); |
548 } | 548 } |
549 | 549 |
550 static void getNextSoftBreak(RootInlineBox*& line, Node*& breakNode, unsigned& b
reakOffset) | 550 static void getNextSoftBreak(RootInlineBox*& line, Node*& breakNode, unsigned& b
reakOffset) |
551 { | 551 { |
(...skipping 26 matching lines...) Expand all Loading... |
578 | 578 |
579 Node* breakNode; | 579 Node* breakNode; |
580 unsigned breakOffset; | 580 unsigned breakOffset; |
581 RootInlineBox* line = renderer->firstRootBox(); | 581 RootInlineBox* line = renderer->firstRootBox(); |
582 if (!line) | 582 if (!line) |
583 return value(); | 583 return value(); |
584 | 584 |
585 getNextSoftBreak(line, breakNode, breakOffset); | 585 getNextSoftBreak(line, breakNode, breakOffset); |
586 | 586 |
587 StringBuilder result; | 587 StringBuilder result; |
588 for (Node* node = innerText->firstChild(); node; node = NodeTraversal::next(
node, innerText)) { | 588 for (Node* node = innerText->firstChild(); node; node = NodeTraversal::next(
*node, innerText)) { |
589 if (node->hasTagName(brTag)) | 589 if (node->hasTagName(brTag)) |
590 result.append(newlineCharacter); | 590 result.append(newlineCharacter); |
591 else if (node->isTextNode()) { | 591 else if (node->isTextNode()) { |
592 String data = toText(node)->data(); | 592 String data = toText(node)->data(); |
593 unsigned length = data.length(); | 593 unsigned length = data.length(); |
594 unsigned position = 0; | 594 unsigned position = 0; |
595 while (breakNode == node && breakOffset <= length) { | 595 while (breakNode == node && breakOffset <= length) { |
596 if (breakOffset > position) { | 596 if (breakOffset > position) { |
597 result.append(data, position, breakOffset - position); | 597 result.append(data, position, breakOffset - position); |
598 position = breakOffset; | 598 position = breakOffset; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 | 650 |
651 return "ltr"; | 651 return "ltr"; |
652 } | 652 } |
653 | 653 |
654 HTMLElement* HTMLTextFormControlElement::innerTextElement() const | 654 HTMLElement* HTMLTextFormControlElement::innerTextElement() const |
655 { | 655 { |
656 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName
s::innerEditor())); | 656 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName
s::innerEditor())); |
657 } | 657 } |
658 | 658 |
659 } // namespace Webcore | 659 } // namespace Webcore |
OLD | NEW |