Changeset 140215 in webkit
- Timestamp:
- Jan 18, 2013 4:12:54 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r140213 r140215 1 2013-01-18 Shinya Kawanaka <shinyak@chromium.org> 2 3 Introduce isHTMLTextFormControlElement and toHTMLTextFormControlElement instead of toTextFormControl 4 https://bugs.webkit.org/show_bug.cgi?id=107089 5 6 Reviewed by Kent Tamura. 7 8 toTextFormControl(node) returns 0 if node is not HTMLTextFormControl. In recent coding convention, 9 we only have ASSERT and statc_cast in this kind of conversion function. So this code looks like 10 having a bad cast, though it does not. 11 12 In this patch, we convert toTextFromControl to isHTMLTextFormControlElement and toHTMLFormControlElement, 13 which aligns our coding convention. 14 15 No new tests, simple refactoring. 16 17 * editing/Editor.cpp: 18 (WebCore::Editor::selectionForCommand): 19 (WebCore::Editor::setBaseWritingDirection): 20 * html/HTMLElement.cpp: 21 (WebCore::HTMLElement::directionality): 22 * html/HTMLTextFormControlElement.cpp: 23 (WebCore::enclosingTextFormControl): 24 * html/HTMLTextFormControlElement.h: 25 (WebCore::isHTMLTextFormControlElement): 26 (WebCore): 27 (WebCore::toHTMLTextFormControlElement): 28 * rendering/RenderTextControl.cpp: 29 (WebCore::RenderTextControl::RenderTextControl): 30 (WebCore::RenderTextControl::layoutSpecialExcludedChild): 31 * testing/Internals.cpp: 32 (WebCore::Internals::visiblePlaceholder): 33 1 34 2013-01-18 Emil A Eklund <eae@chromium.org> 2 35 -
trunk/Source/WebCore/editing/Editor.cpp
r139796 r140215 111 111 // then use the saved selection for that text control. 112 112 HTMLTextFormControlElement* textFormControlOfSelectionStart = enclosingTextFormControl(selection.start()); 113 HTMLTextFormControlElement* textFromControlOfTarget = toTextFormControl(event->target()->toNode());113 HTMLTextFormControlElement* textFromControlOfTarget = isHTMLTextFormControlElement(event->target()->toNode()) ? toHTMLTextFormControlElement(event->target()->toNode()) : 0; 114 114 if (textFromControlOfTarget && (selection.start().isNull() || textFromControlOfTarget != textFormControlOfSelectionStart)) { 115 115 if (RefPtr<Range> range = textFromControlOfTarget->selection()) … … 1295 1295 { 1296 1296 Node* focusedNode = frame()->document()->focusedNode(); 1297 if ( toTextFormControl(focusedNode)) {1297 if (focusedNode && isHTMLTextFormControlElement(focusedNode)) { 1298 1298 if (direction == NaturalWritingDirection) 1299 1299 return; -
trunk/Source/WebCore/html/HTMLElement.cpp
r140010 r140215 855 855 TextDirection HTMLElement::directionality(Node** strongDirectionalityTextNode) const 856 856 { 857 if (HTMLTextFormControlElement* textElement = toTextFormControl(const_cast<HTMLElement*>(this))) { 857 if (isHTMLTextFormControlElement(this)) { 858 HTMLTextFormControlElement* textElement = toHTMLTextFormControlElement(const_cast<HTMLElement*>(this)); 858 859 bool hasStrongDirectionality; 859 860 Unicode::Direction textDirection = textElement->value().defaultWritingDirection(&hasStrongDirectionality); -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r139999 r140215 646 646 if (!container) 647 647 return 0; 648 Node* ancestor = container->shadowHost();649 return ancestor ? toTextFormControl(ancestor) : 0;648 Element* ancestor = container->shadowHost(); 649 return ancestor && isHTMLTextFormControlElement(ancestor) ? toHTMLTextFormControlElement(ancestor) : 0; 650 650 } 651 651 -
trunk/Source/WebCore/html/HTMLTextFormControlElement.h
r135069 r140215 142 142 }; 143 143 144 // This function returns 0 when node is an input element and not a text field. 145 inline HTMLTextFormControlElement* toTextFormControl(Node* node) 144 inline bool isHTMLTextFormControlElement(const Node* node) 146 145 { 147 return (node && node->isElementNode() && static_cast<Element*>(node)->isTextFormControl()) ? static_cast<HTMLTextFormControlElement*>(node) : 0; 146 return node->isElementNode() && toElement(node)->isTextFormControl(); 147 } 148 149 inline HTMLTextFormControlElement* toHTMLTextFormControlElement(Node* node) 150 { 151 ASSERT(!node || isHTMLTextFormControlElement(node)); 152 return static_cast<HTMLTextFormControlElement*>(node); 148 153 } 149 154 -
trunk/Source/WebCore/rendering/RenderTextControl.cpp
r140039 r140215 40 40 : RenderBlock(node) 41 41 { 42 ASSERT( toTextFormControl(node));42 ASSERT(isHTMLTextFormControlElement(node)); 43 43 } 44 44 … … 304 304 RenderObject* RenderTextControl::layoutSpecialExcludedChild(bool relayoutChildren) 305 305 { 306 HTMLElement* placeholder = to TextFormControl(node())->placeholderElement();306 HTMLElement* placeholder = toHTMLTextFormControlElement(node())->placeholderElement(); 307 307 RenderObject* placeholderRenderer = placeholder ? placeholder->renderer() : 0; 308 308 if (!placeholderRenderer) -
trunk/Source/WebCore/testing/Internals.cpp
r140105 r140215 686 686 String Internals::visiblePlaceholder(Element* element) 687 687 { 688 HTMLTextFormControlElement* textControl = toTextFormControl(element); 689 if (textControl && textControl->placeholderShouldBeVisible()) 690 return textControl->placeholderElement()->textContent(); 688 if (element && isHTMLTextFormControlElement(element)) { 689 if (toHTMLTextFormControlElement(element)->placeholderShouldBeVisible()) 690 return toHTMLTextFormControlElement(element)->placeholderElement()->textContent(); 691 } 692 691 693 return String(); 692 694 } -
trunk/Source/WebKit/qt/ChangeLog
r140148 r140215 1 2013-01-18 Shinya Kawanaka <shinyak@chromium.org> 2 3 Introduce isHTMLTextFormControlElement and toHTMLTextFormControlElement instead of toTextFormControl 4 https://bugs.webkit.org/show_bug.cgi?id=107089 5 6 Reviewed by Kent Tamura. 7 8 Updated code to use isHTMLTextFormControlElement and toHTMLTextFormControlElement combination instead of 9 toTextFormControl. 10 11 * WebCoreSupport/QWebPageAdapter.cpp: 12 (QWebPageAdapter::inputMethodEvent): 13 1 14 2013-01-18 Seokju Kwon <seokju.kwon@gmail.com> 2 15 -
trunk/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
r138413 r140215 677 677 // A selection in the inputMethodEvent is always reflected in the visible text 678 678 if (node) { 679 if ( HTMLTextFormControlElement* textControl = toTextFormControl(node))680 t extControl->setSelectionRange(qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length)));679 if (isHTMLTextFormControlElement(node)) 680 toHTMLTextFormControlElement(node)->setSelectionRange(qMin(a.start, (a.start + a.length)), qMax(a.start, (a.start + a.length))); 681 681 } 682 682 … … 699 699 int cursorPos = frame->selection()->extent().offsetInContainerNode(); 700 700 int start = cursorPos + ev->replacementStart(); 701 if ( HTMLTextFormControlElement* textControl = toTextFormControl(node))702 t extControl->setSelectionRange(start, start + ev->replacementLength());701 if (isHTMLTextFormControlElement(node)) 702 toHTMLTextFormControlElement(node)->setSelectionRange(start, start + ev->replacementLength()); 703 703 // Commit regardless of whether commitString is empty, to get rid of selection. 704 704 editor->confirmComposition(ev->commitString());
Note: See TracChangeset
for help on using the changeset viewer.