Changeset 90775 in webkit
- Timestamp:
- Jul 11, 2011, 12:06:34 PM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r90773 r90775 1 2011-07-08 Ryosuke Niwa <rniwa@webkit.org> 2 3 Move innerTextElement() from RenderTextControl to HTMLTextFormControlElement 4 https://bugs.webkit.org/show_bug.cgi?id=64134 5 6 Reviewed by Kent Tamura. 7 8 Moved innerTextElement from RenderTextControl to HTMLTextFormControlElement. It is implemented by 9 HTMLInputElement and HTMLTextAreaElement instead of RenderTextControlSingleLine and 10 RenderTextControlMultiLine. 11 12 This refactoring removes the indirection through RenderTextControl and makes the ownership of 13 shadow DOM for input and textarea elements clear. Accessing the shadow DOM of input and textarea elements 14 are now less error prone because it no longer depends on the lifetime of the render tree. 15 16 * accessibility/AccessibilityRenderObject.cpp: 17 (WebCore::AccessibilityRenderObject::indexForVisiblePosition): Access innerTextElement via 18 HTMLTextFormControlElement. 19 * dom/Node.cpp: 20 (WebCore::traverseTreeAndMark): No longer calls innerTextElement because this was a work-around 21 needed before making input and textarea elements use the new shadow DOM model. 22 * editing/TextIterator.cpp: 23 (WebCore::TextIterator::handleReplacedElement): Access innerTextElement via HTMLTextFormControlElement. 24 * html/HTMLFormControlElement.cpp: 25 (WebCore::hasVisibleTextArea): Takes innerTextElement. 26 (WebCore::HTMLTextFormControlElement::setSelectionRange): Calls innerTextElement(). 27 (WebCore::HTMLTextFormControlElement::selection): Ditto. 28 (WebCore::HTMLTextFormControlElement::selectionStart): Ditto; no longer uses a temporary local variable 29 for innerTextElement because innerTextElement() no longer depends on the lifetime of the render tree. 30 (WebCore::HTMLTextFormControlElement::selectionEnd): Ditto. 31 * html/HTMLFormControlElement.h: 32 * html/HTMLTextAreaElement.cpp: 33 (WebCore::HTMLTextAreaElement::innerTextElement): Added. 34 * html/HTMLTextAreaElement.h: 35 * rendering/RenderTextControl.cpp: 36 (WebCore::RenderTextControl::textFormControlElement): Made this function a const member. 37 (WebCore::RenderTextControl::innerTextElement): Added. 38 * rendering/RenderTextControl.h: 39 * rendering/RenderTextControlMultiLine.cpp: 40 * rendering/RenderTextControlMultiLine.h: 41 * rendering/RenderTextControlSingleLine.cpp: 42 * rendering/RenderTextControlSingleLine.h: 43 1 44 2011-07-11 Tony Chang <tony@chromium.org> 2 45 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r90763 r90775 2494 2494 int AccessibilityRenderObject::indexForVisiblePosition(const VisiblePosition& pos) const 2495 2495 { 2496 if (isNativeTextControl()) 2497 return RenderTextControl::indexForVisiblePosition(toRenderTextControl(m_renderer)->innerTextElement(), pos); 2498 2496 if (isNativeTextControl()) { 2497 HTMLTextFormControlElement* textControl = toRenderTextControl(m_renderer)->textFormControlElement(); 2498 return RenderTextControl::indexForVisiblePosition(textControl->innerTextElement(), pos); 2499 } 2500 2499 2501 if (!isTextControl()) 2500 2502 return 0; -
trunk/Source/WebCore/dom/Node.cpp
r90378 r90775 2344 2344 ContainerNode* rootNode = shadowRoot(const_cast<Node*>(node)); 2345 2345 2346 if (!rootNode && node->renderer() && node->renderer()->isTextControl())2347 rootNode = static_cast<RenderTextControl*>(node->renderer())->innerTextElement();2348 2349 2346 if (rootNode) { 2350 2347 indent += "\t"; -
trunk/Source/WebCore/editing/TextIterator.cpp
r89831 r90775 31 31 #include "Frame.h" 32 32 #include "HTMLElement.h" 33 #include "HTMLFormControlElement.h" 33 34 #include "HTMLNames.h" 34 35 #include "htmlediting.h" … … 638 639 639 640 if (m_entersTextControls && renderer->isTextControl()) { 640 if (HTMLElement* innerTextElement = toRenderTextControl(renderer)-> innerTextElement()) {641 if (HTMLElement* innerTextElement = toRenderTextControl(renderer)->textFormControlElement()->innerTextElement()) { 641 642 m_node = innerTextElement->shadowTreeRootNode(); 642 643 pushFullyClippedState(m_fullyClippedStack, m_node); -
trunk/Source/WebCore/html/HTMLFormControlElement.cpp
r90763 r90775 682 682 } 683 683 684 static inline bool hasVisibleTextArea(RenderTextControl* textControl )684 static inline bool hasVisibleTextArea(RenderTextControl* textControl, HTMLElement* innerText) 685 685 { 686 686 ASSERT(textControl); 687 HTMLElement* innerText = textControl->innerTextElement(); 688 return textControl->style()->visibility() == HIDDEN || !innerText || !innerText->renderer() || !innerText->renderBox()->height(); 687 return textControl->style()->visibility() != HIDDEN && innerText && innerText->renderer() && innerText->renderBox()->height(); 689 688 } 690 689 … … 700 699 701 700 RenderTextControl* control = toRenderTextControl(renderer()); 702 if ( hasVisibleTextArea(control)) {701 if (!hasVisibleTextArea(control, innerTextElement())) { 703 702 cacheSelection(start, end); 704 703 return; … … 736 735 { 737 736 Frame* frame = document()->frame(); 738 if (!renderer() || !frame) 739 return 0; 740 741 HTMLElement* innerText = toRenderTextControl(renderer())->innerTextElement(); 742 // Do not call innerTextElement() in the function arguments as creating a VisiblePosition 743 // from frame->selection->start() can blow us from underneath. Also, function ordering is 744 // usually dependent on the compiler. 745 return RenderTextControl::indexForVisiblePosition(innerText, frame->selection()->start()); 737 if (!frame) 738 return 0; 739 740 return RenderTextControl::indexForVisiblePosition(innerTextElement(), frame->selection()->start()); 746 741 } 747 742 … … 758 753 { 759 754 Frame* frame = document()->frame(); 760 if (!renderer() || !frame) 761 return 0; 762 763 HTMLElement* innerText = toRenderTextControl(renderer())->innerTextElement(); 764 // Do not call innerTextElement() in the function arguments as creating a VisiblePosition 765 // from frame->selection->end() can blow us from underneath. Also, function ordering is 766 // usually dependent on the compiler. 767 return RenderTextControl::indexForVisiblePosition(innerText, frame->selection()->end()); 755 if (!frame) 756 return 0; 757 758 return RenderTextControl::indexForVisiblePosition(innerTextElement(), frame->selection()->end()); 768 759 } 769 760 … … 788 779 789 780 ASSERT(start <= end); 790 HTMLElement* innerText = toRenderTextControl(renderer())->innerTextElement();781 HTMLElement* innerText = innerTextElement(); 791 782 if (!innerText) 792 783 return 0; -
trunk/Source/WebCore/html/HTMLFormControlElement.h
r90763 r90775 215 215 virtual String value() const = 0; 216 216 217 virtual HTMLElement* innerTextElement() const = 0; 218 217 219 void cacheSelection(int start, int end) 218 220 { -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r90591 r90775 270 270 } 271 271 272 HTMLElement* HTMLTextAreaElement::innerTextElement() const 273 { 274 Node* node = shadowRoot()->firstChild(); 275 ASSERT(!node || node->hasTagName(divTag)); 276 return static_cast<HTMLElement*>(node); 277 } 278 272 279 void HTMLTextAreaElement::rendererWillBeDestroyed() 273 280 { -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r90591 r90775 52 52 bool isValidValue(const String&) const; 53 53 54 virtual HTMLElement* innerTextElement() const; 55 54 56 void rendererWillBeDestroyed(); 55 57 56 58 void setCols(int); 57 59 void setRows(int); -
trunk/Source/WebCore/rendering/RenderTextControl.cpp
r90763 r90775 83 83 } 84 84 85 HTMLTextFormControlElement* RenderTextControl::textFormControlElement() 85 HTMLTextFormControlElement* RenderTextControl::textFormControlElement() const 86 86 { 87 87 return static_cast<HTMLTextFormControlElement*>(node()); 88 } 89 90 HTMLElement* RenderTextControl::innerTextElement() const 91 { 92 return textFormControlElement()->innerTextElement(); 88 93 } 89 94 -
trunk/Source/WebCore/rendering/RenderTextControl.h
r90763 r90775 36 36 virtual ~RenderTextControl(); 37 37 38 HTMLTextFormControlElement* textFormControlElement(); 39 virtual HTMLElement* innerTextElement() const = 0; 38 HTMLTextFormControlElement* textFormControlElement() const; 40 39 virtual PassRefPtr<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const = 0; 41 40 … … 54 53 protected: 55 54 RenderTextControl(Node*, bool); 55 56 // This convenience function should not be made public because innerTextElement may outlive the render tree. 57 HTMLElement* innerTextElement() const; 56 58 57 59 int scrollbarThickness() const; -
trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp
r90591 r90775 43 43 if (node() && node()->inDocument()) 44 44 static_cast<HTMLTextAreaElement*>(node())->rendererWillBeDestroyed(); 45 }46 47 HTMLElement* RenderTextControlMultiLine::innerTextElement() const48 {49 return toHTMLElement(toElement(node())->shadowRoot()->firstChild());50 45 } 51 46 -
trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h
r90591 r90775 31 31 RenderTextControlMultiLine(Node*, bool); 32 32 virtual ~RenderTextControlMultiLine(); 33 34 virtual HTMLElement* innerTextElement() const;35 33 36 34 void forwardEvent(Event*); -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp
r90667 r90775 95 95 } 96 96 97 inline HTMLElement* RenderTextControlSingleLine::innerTextElement() const98 {99 return inputElement()->innerTextElement();100 }101 102 97 inline HTMLElement* RenderTextControlSingleLine::innerBlockElement() const 103 98 { -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h
r90591 r90775 132 132 133 133 HTMLElement* containerElement() const; 134 virtual HTMLElement* innerTextElement() const;135 134 HTMLElement* innerBlockElement() const; 136 135 HTMLElement* innerSpinButtonElement() const;
Note:
See TracChangeset
for help on using the changeset viewer.