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 24 matching lines...) Expand all Loading... |
35 #include "core/dom/shadow/ShadowRoot.h" | 35 #include "core/dom/shadow/ShadowRoot.h" |
36 #include "core/editing/FrameSelection.h" | 36 #include "core/editing/FrameSelection.h" |
37 #include "core/editing/TextIterator.h" | 37 #include "core/editing/TextIterator.h" |
38 #include "core/events/Event.h" | 38 #include "core/events/Event.h" |
39 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
40 #include "core/frame/UseCounter.h" | 40 #include "core/frame/UseCounter.h" |
41 #include "core/html/HTMLBRElement.h" | 41 #include "core/html/HTMLBRElement.h" |
42 #include "core/html/shadow/ShadowElementNames.h" | 42 #include "core/html/shadow/ShadowElementNames.h" |
43 #include "core/rendering/RenderBlock.h" | 43 #include "core/rendering/RenderBlock.h" |
44 #include "core/rendering/RenderTheme.h" | 44 #include "core/rendering/RenderTheme.h" |
| 45 #include "platform/heap/Handle.h" |
45 #include "wtf/text/StringBuilder.h" | 46 #include "wtf/text/StringBuilder.h" |
46 | 47 |
47 namespace WebCore { | 48 namespace WebCore { |
48 | 49 |
49 using namespace HTMLNames; | 50 using namespace HTMLNames; |
50 using namespace std; | 51 using namespace std; |
51 | 52 |
52 HTMLTextFormControlElement::HTMLTextFormControlElement(const QualifiedName& tagN
ame, Document& doc, HTMLFormElement* form) | 53 HTMLTextFormControlElement::HTMLTextFormControlElement(const QualifiedName& tagN
ame, Document& doc, HTMLFormElement* form) |
53 : HTMLFormControlElementWithState(tagName, doc, form) | 54 : HTMLFormControlElementWithState(tagName, doc, form) |
54 , m_lastChangeWasUserEdit(false) | 55 , m_lastChangeWasUserEdit(false) |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 newSelection.setIsDirectional(direction != SelectionHasNoDirection); | 305 newSelection.setIsDirectional(direction != SelectionHasNoDirection); |
305 | 306 |
306 if (LocalFrame* frame = document().frame()) | 307 if (LocalFrame* frame = document().frame()) |
307 frame->selection().setSelection(newSelection); | 308 frame->selection().setSelection(newSelection); |
308 } | 309 } |
309 | 310 |
310 VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) c
onst | 311 VisiblePosition HTMLTextFormControlElement::visiblePositionForIndex(int index) c
onst |
311 { | 312 { |
312 if (index <= 0) | 313 if (index <= 0) |
313 return VisiblePosition(firstPositionInNode(innerTextElement()), DOWNSTRE
AM); | 314 return VisiblePosition(firstPositionInNode(innerTextElement()), DOWNSTRE
AM); |
314 RefPtr<Range> range = Range::create(document()); | 315 RefPtrWillBeRawPtr<Range> range = Range::create(document()); |
315 range->selectNodeContents(innerTextElement(), ASSERT_NO_EXCEPTION); | 316 range->selectNodeContents(innerTextElement(), ASSERT_NO_EXCEPTION); |
316 CharacterIterator it(range.get()); | 317 CharacterIterator it(range.get()); |
317 it.advance(index - 1); | 318 it.advance(index - 1); |
318 return VisiblePosition(it.range()->endPosition(), UPSTREAM); | 319 return VisiblePosition(it.range()->endPosition(), UPSTREAM); |
319 } | 320 } |
320 | 321 |
321 int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& p
os) const | 322 int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& p
os) const |
322 { | 323 { |
323 Position indexPosition = pos.deepEquivalent().parentAnchoredEquivalent(); | 324 Position indexPosition = pos.deepEquivalent().parentAnchoredEquivalent(); |
324 if (enclosingTextFormControl(indexPosition) != this) | 325 if (enclosingTextFormControl(indexPosition) != this) |
325 return 0; | 326 return 0; |
326 ASSERT(indexPosition.document()); | 327 ASSERT(indexPosition.document()); |
327 RefPtr<Range> range = Range::create(*indexPosition.document()); | 328 RefPtrWillBeRawPtr<Range> range = Range::create(*indexPosition.document()); |
328 range->setStart(innerTextElement(), 0, ASSERT_NO_EXCEPTION); | 329 range->setStart(innerTextElement(), 0, ASSERT_NO_EXCEPTION); |
329 range->setEnd(indexPosition.containerNode(), indexPosition.offsetInContainer
Node(), ASSERT_NO_EXCEPTION); | 330 range->setEnd(indexPosition.containerNode(), indexPosition.offsetInContainer
Node(), ASSERT_NO_EXCEPTION); |
330 return TextIterator::rangeLength(range.get()); | 331 return TextIterator::rangeLength(range.get()); |
331 } | 332 } |
332 | 333 |
333 int HTMLTextFormControlElement::selectionStart() const | 334 int HTMLTextFormControlElement::selectionStart() const |
334 { | 335 { |
335 if (!isTextFormControl()) | 336 if (!isTextFormControl()) |
336 return 0; | 337 return 0; |
337 if (document().focusedElement() != this && hasCachedSelection()) | 338 if (document().focusedElement() != this && hasCachedSelection()) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 { | 414 { |
414 if (node->isTextNode()) { | 415 if (node->isTextNode()) { |
415 containerNode = node; | 416 containerNode = node; |
416 offsetInContainer = offset; | 417 offsetInContainer = offset; |
417 } else { | 418 } else { |
418 containerNode = node->parentNode(); | 419 containerNode = node->parentNode(); |
419 offsetInContainer = node->nodeIndex() + offset; | 420 offsetInContainer = node->nodeIndex() + offset; |
420 } | 421 } |
421 } | 422 } |
422 | 423 |
423 PassRefPtr<Range> HTMLTextFormControlElement::selection() const | 424 PassRefPtrWillBeRawPtr<Range> HTMLTextFormControlElement::selection() const |
424 { | 425 { |
425 if (!renderer() || !isTextFormControl() || !hasCachedSelection()) | 426 if (!renderer() || !isTextFormControl() || !hasCachedSelection()) |
426 return nullptr; | 427 return nullptr; |
427 | 428 |
428 int start = m_cachedSelectionStart; | 429 int start = m_cachedSelectionStart; |
429 int end = m_cachedSelectionEnd; | 430 int end = m_cachedSelectionEnd; |
430 | 431 |
431 ASSERT(start <= end); | 432 ASSERT(start <= end); |
432 HTMLElement* innerText = innerTextElement(); | 433 HTMLElement* innerText = innerTextElement(); |
433 if (!innerText) | 434 if (!innerText) |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 647 |
647 return "ltr"; | 648 return "ltr"; |
648 } | 649 } |
649 | 650 |
650 HTMLElement* HTMLTextFormControlElement::innerTextElement() const | 651 HTMLElement* HTMLTextFormControlElement::innerTextElement() const |
651 { | 652 { |
652 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName
s::innerEditor())); | 653 return toHTMLElement(userAgentShadowRoot()->getElementById(ShadowElementName
s::innerEditor())); |
653 } | 654 } |
654 | 655 |
655 } // namespace Webcore | 656 } // namespace Webcore |
OLD | NEW |