Skip to content
Permalink
Browse files
Audit RenderObject casts and fix problems and style issues found
https://bugs.webkit.org/show_bug.cgi?id=158221

Reviewed by Chris Dumez.

Source/WebCore:

* bindings/objc/DOM.mm:
(-[DOMElement image]): Use auto to get more specific types in code getting
the renderer for an element instead of dumbing down the type to RenderObject.

* dom/Element.cpp:
(WebCore::Element::scrollByUnits): Call renderer only once. The comment in
Node advises we should do this since it has a branch in it.
(WebCore::Element::absoluteEventBounds): Call renderer only once. Also use
auto for a rect type to clarify that we are not changing the type of the
rect returned by the fucntion.
(WebCore::Element::webkitGetRegionFlowRanges): Call renderer only once.

* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::addBlockPlaceholderIfNeeded): Use auto
to get a mroe specific renderer type.

* editing/SimplifyMarkupCommand.cpp:
(WebCore::SimplifyMarkupCommand::doApply): Call renderer only once.

* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_addAttachmentForElement): Add an obviously missing
null check for something that is null checked elsewhere.
(fileWrapperForURL): Ditto.
(fileWrapperForElement): Changed argument type to HTMLImageElement& since
the call site already checks the type of the object. Use HTMLImageElement::src
instead of repeating the code here. Check the type of the renderer instead of
assuming it's a RenderImage.
(WebCore::editingAttributedStringFromRange): Pass a reference, not a pointer.

* html/HTMLAnchorElement.cpp:
(WebCore::appendServerMapMousePosition): Take a reference to an event rather
than a "known to be non-null" pointer. Call renderer only once. Round the
floating point values rather than truncating them.
(WebCore::HTMLAnchorElement::handleClick): Pass a reference.

* html/HTMLAttachmentElement.cpp:
(WebCore::HTMLAttachmentElement::setFile): Removed the now-unneeded cast since
the renderer function returns a pointer of a more specific type now.
(WebCore::HTMLAttachmentElement::parseAttribute): Ditto.
(WebCore::HTMLAttachmentElement::attachmentTitle): Use auto& to avoid a bit of
reference count churn.

* html/HTMLAttachmentElement.h: Override renderer to return a more specific type.
This follows the pattern that ContainerNode::renderer uses.

* html/HTMLButtonElement.h: Ditto.

* html/HTMLCanvasElement.cpp: Gave the constants at the top of the file more
normal names. Removed unneeded "static" from them. Moved the
defaultInterpolationQuality constant here from the header because it doesn't
need to be there.
(WebCore::HTMLCanvasElement::HTMLCanvasElement): Updated for name changes.
(WebCore::HTMLCanvasElement::createElementRenderer): Removed unneeded code to
set m_rendererIsCanvas to record renderer type; we can just check the type.
(WebCore::HTMLCanvasElement::setHeight): Updated for name changes.
(WebCore::HTMLCanvasElement::setWidth): Ditto.
(WebCore::HTMLCanvasElement::reset): Check the type of the renderer directly
instead of calling m_rendererIsCanvas. This helped make it clear we were
do extra unneeded checks since a renderer can't both be a RenderCanvas and
not be a RenderBox.
(WebCore::HTMLCanvasElement::createImageBuffer): Updated for name changes.

* html/HTMLCanvasElement.h: Moved DefaultInterpolationQuality into the cpp file.
Use nullptr instead of 0. Removed m_rendererIsCanvas.

* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::HTMLFieldSetElement): Initialize m_documentVersion
in the class definition.
(WebCore::HTMLFieldSetElement::~HTMLFieldSetElement): Use m_hasDisabledAttribute.
(WebCore::updateFromControlElementsAncestorDisabledStateUnder): Fixed typo.
(WebCore::HTMLFieldSetElement::disabledAttributeChanged): Fixed mistake in this
function that would cause the number of disabled fieldset elements to be too high
if the disabled attribute's value was changed from one value to another. Use a
boolean to track the old value; can't think of a solution that works without that.
(WebCore::HTMLFieldSetElement::childrenChanged): Fixed typo.
(WebCore::HTMLFieldSetElement::didMoveToNewDocument): Use m_hasDisabledAttribute.
(WebCore::HTMLFieldSetElement::updateAssociatedElements): Changed name to make it
clearer what this function does. Tweaked a bit without changing behavior.
(WebCore::HTMLFieldSetElement::associatedElements): Updated for name change.
(WebCore::HTMLFieldSetElement::length): Changed to call associatedElements instead of
repeating that it does.

* html/HTMLFieldSetElement.h: Override renderer to return a more specific type.
Also updated for other changes mentioned above.

* html/HTMLFrameElement.cpp:
(WebCore::HTMLFrameElement::HTMLFrameElement): Initialize booleans in the class
definition rather than doing it here.
(WebCore::HTMLFrameElement::parseAttribute): Call renderer only once.

* html/HTMLFrameElement.h: Override renderer to return a more specific type.
Also initialize some booleans in the class definition.

* html/HTMLIFrameElement.h: Override renderer to return a more specific type.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateRenderer): Added. Helper for a common idiom.
(WebCore::HTMLMediaElement::didAttachRenderers): Use auto to get a more specific
type for the renderer.
(WebCore::HTMLMediaElement::willDetachRenderers): Call renderer only once.
(WebCore::HTMLMediaElement::didRecalcStyle): Use updateRenderer to call renderer
only once.
(WebCore::HTMLMediaElement::loadResource): Ditto.
(WebCore::HTMLMediaElement::waitForSourceChange): Ditto.
(WebCore::HTMLMediaElement::noneSupported): Ditto.
(WebCore::HTMLMediaElement::setReadyState): Ditto.
(WebCore::HTMLMediaElement::progressEventTimerFired): Ditto.
(WebCore::HTMLMediaElement::selectNextSourceChild): Renamed goto label to use a style
that fits WebKit coding style. Call renderer only once in MediaQuery code.
(WebCore::HTMLMediaElement::mediaPlayerRepaint): Call renderer only once.
(WebCore::HTMLMediaElement::mediaPlayerSizeChanged): Use updateRenderer to call
renderer only once.
(WebCore::HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated): Call renderer
only once.
(WebCore::HTMLMediaElement::mediaPlayerGraphicsDeviceAdapter): Call page only once.
(WebCore::HTMLMediaElement::mediaEngineWasUpdated): Use updateRenderer to call
renderer only once.
(WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged): Ditto.
(WebCore::HTMLMediaElement::updatePlayState): Ditto.
(WebCore::HTMLMediaElement::stopWithoutDestroyingMediaPlayer): Ditto.
(WebCore::HTMLMediaElement::resume): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerContentBoxRect): Call renderer only once.
(WebCore::mediaElementIsAllowedToAutoplay): Use auto to get a more specific type.

* html/HTMLMediaElement.h: Removed conditionals around forward declarations.
Tweaked formatting a bit. Added the updateRender function. Override renderer to
return a more specific type.

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::optionElementChildrenChanged): Don't use the renderer
just to get to the document for the AXObjectCache.
(WebCore::HTMLSelectElement::setLength): Use auto for the list items vector.
(WebCore::HTMLSelectElement::nextValidIndex): Ditto.
(WebCore::HTMLSelectElement::firstSelectableListIndex): Ditto.
(WebCore::HTMLSelectElement::nextSelectableListIndexPageAway): Ditto. Also add a
null check for the renderer.
(WebCore::HTMLSelectElement::updateListBoxSelection): Split an assertion with &&
in it into two separate assertions. Use auto for the list items vector and use
a reference for the list items.
(WebCore::HTMLSelectElement::listBoxOnChange): Use auto for the list items vector
and use a reference for the list items.
(WebCore::HTMLSelectElement::setRecalcListItems): Don't use the renderer
just to get to the document for the AXObjectCache.
(WebCore::HTMLSelectElement::selectOption): Use auto for the list items vector.
(WebCore::HTMLSelectElement::optionToListIndex): Ditto.
(WebCore::HTMLSelectElement::listToOptionIndex): Ditto.
(WebCore::HTMLSelectElement::searchOptionsForValue): Ditto.
(WebCore::HTMLSelectElement::restoreFormControlState): Ditto.
(WebCore::HTMLSelectElement::platformHandleKeydownEvent): Call renderer only once.
(WebCore::HTMLSelectElement::menuListDefaultEventHandler): Split an assertion with
&& in it into two separate assertions. Use auto for the list items vector. Call
renderer only once.
(WebCore::HTMLSelectElement::updateSelectedState): Use a reference for the list
item.
(WebCore::HTMLSelectElement::listBoxDefaultEventHandler): Use auto for the list
items vvector. Call renderer less often; could not quite get it down to once.
(WebCore::HTMLSelectElement::defaultEventHandler): Call renderer only once.
(WebCore::HTMLSelectElement::lastSelectedListIndex): Use auto for the list items
vector and use a reference for the list items.
(WebCore::HTMLSelectElement::optionAtIndex): Use a reference for the list item.
(WebCore::HTMLSelectElement::accessKeySetSelectedIndex): Use auto for the list
items vector and use a reference for the list items.
(WebCore::HTMLSelectElement::length): Use auto for the list items vector.

* html/HTMLTextAreaElement.h: Override renderer to return a more specific type.

* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::didAttachRenderers): Call renderer only once and
don't downcast it. There was no obvious type check because the renderer has a
guaranteed type, but this is now clearer because it's the renderer function
that returns a more specific type.
(WebCore::HTMLVideoElement::parseAttribute): Ditto.
(WebCore::HTMLVideoElement::setDisplayMode): Ditto.

* html/HTMLVideoElement.h: Override renderer to return a more specific type.
* html/HTMLWBRElement.h: Ditto.

* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::canControlControlsManager): Removed
unneeded typecast in code that null checks a renderer.
(WebCore::isMainContent): Remove now-unneeded downcast of a renderer
obtained from an HTMLMediaElement. Fixed awkward formatting by splitting
an if statement into two.
(WebCore::isElementLargeEnoughForMainContent): Remove now unneeded downcast
of a renderer obtained from an HTMLMediaElement.

* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::forwardEvent): Call renderer only once.
Also use auto more in the code rather than writing out types.

* html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::setPositionFromPoint): Used the renderBox
function more consistently for all the renderers used here; before,
some had null checks and others did not.

* html/shadow/TextControlInnerElements.cpp:
(WebCore::SearchFieldResultsButtonElement::defaultEventHandler): Use auto
a bit more.

* page/EventHandler.cpp:
(WebCore::enclosingScrollableArea): Removed a redundant null check and
stopped using the name "element" for a local variable that was not
always an element.

* page/PrintContext.cpp:
(WebCore::enclosingBoxModelObject): Rewrote loop to be simpler and tighter.
Also marked this inline since it's used only one place.
(WebCore::PrintContext::pageNumberForElement): Use auto for the return
value rather than writing out the type.

* page/SpatialNavigation.cpp:
(WebCore::isScrollableNode): Tighten the code and use auto a bit.

* platform/ios/WebVideoFullscreenControllerAVKit.mm: Add an include of
RenderVideo.h since this gets at the renderer for a video.

* rendering/RenderAttachment.h:
(WebCore::HTMLAttachmentElement::renderer): Added. Function is here because
it can only be called by code that includes this header. This matches the
pattern of RenderElement.h and ContainerNode::renderer.

* rendering/RenderFrame.cpp: Added now-needed include.

* rendering/RenderFrame.h:
(WebCore::HTMLFrameElement::renderer): Added. Same logic as above.

* rendering/RenderLayerFilterInfo.cpp:
(WebCore::RenderLayer::FilterInfo::updateReferenceFilterClients): Use auto
a bit and call rendeer only once.

* rendering/RenderMedia.h:
(WebCore::HTMLMediaElement::renderer): Added. Same logic as above.
* rendering/RenderTextControlMultiLine.h:
(WebCore::HTMLTextAreaElement::renderer): Ditto.

* rendering/RenderVideo.cpp:
(WebCore::placeholder): Renamed. Tightened up argument type to match what
is passed at all the call sites. Use auto instead of RenderObject.
(WebCore::RenderVideo::offsetLeft): Use auto and the renamed function above.
(WebCore::RenderVideo::offsetTop): Ditto.
(WebCore::RenderVideo::offsetWidth): Ditto.
(WebCore::RenderVideo::offsetHeight): Ditto.

* rendering/RenderVideo.h:
(WebCore::HTMLVideoElement::renderer): Added. Same logic as above.

* svg/SVGGElement.cpp:
(WebCore::SVGGElement::createElementRenderer): Fixed typo.

* svg/SVGGraphicsElement.cpp:
(WebCore::SVGGraphicsElement::createElementRenderer): Removed
non-helpful oblique comment.
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::createElementRenderer): Ditto.

Source/WebKit/mac:

* Misc/WebNSPasteboardExtras.mm:
(imageFromElement): Use auto and tighten the logic a bit.
(-[NSPasteboard _web_declareAndWriteDragImageForElement:URL:title:archive:source:]):
Use auto and added a comment about this not using imageFromElement.

* Plugins/WebBaseNetscapePluginView.mm:
(-[WebBaseNetscapePluginView _windowClipRect]): Consistently cast to
RenderEmbeddedObject, which is the class used for renderers for plug-ins.
(-[WebBaseNetscapePluginView inFlatteningPaint]): Ditto.
(-[WebBaseNetscapePluginView invalidatePluginContentRect:]): Ditto.
(-[WebBaseNetscapePluginView actualVisibleRectInWindow]): Ditto.

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::createPlugin): Changed code so it does a null check
rather than assuming the renderer is non-null.
(WebFrameLoaderClient::createJavaAppletWidget): Ditto.

Source/WebKit2:

* Shared/WebRenderObject.cpp:
(WebKit::WebRenderObject::WebRenderObject): Tightened up the code that
builds the tree of objects; fewer local variables.

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::invalidateRect): Cast to RenderEmbeddedObject since
that is the class used for plug-ins.
(WebKit::PluginView::pluginProcessCrashed): Ditto.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::createPlugin): Ditto.
(WebKit::WebPage::plugInIsPrimarySize): Check the renderer for null here.
Did not change this to RenderEmbeddedObject, though, because I wasn't
absolute certain this is only called with that type of renderer.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::rangeForWebSelectionAtPosition): Tweaked.

Canonical link: https://commits.webkit.org/176375@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201588 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
darinadler committed Jun 2, 2016
1 parent 772b9dd commit 4eb118fa136333c9a1fb480f5cce5d7fe59d19a2
Showing with 846 additions and 527 deletions.
  1. +262 −0 Source/WebCore/ChangeLog
  2. +2 −2 Source/WebCore/bindings/objc/DOM.mm
  3. +12 −10 Source/WebCore/dom/Element.cpp
  4. +3 −4 Source/WebCore/editing/CompositeEditCommand.cpp
  5. +2 −1 Source/WebCore/editing/SimplifyMarkupCommand.cpp
  6. +28 −27 Source/WebCore/editing/cocoa/HTMLConverter.mm
  7. +13 −15 Source/WebCore/html/HTMLAnchorElement.cpp
  8. +6 −9 Source/WebCore/html/HTMLAttachmentElement.cpp
  9. +5 −3 Source/WebCore/html/HTMLAttachmentElement.h
  10. +5 −4 Source/WebCore/html/HTMLButtonElement.h
  11. +32 −29 Source/WebCore/html/HTMLCanvasElement.cpp
  12. +6 −18 Source/WebCore/html/HTMLCanvasElement.h
  13. +17 −15 Source/WebCore/html/HTMLFieldSetElement.cpp
  14. +8 −7 Source/WebCore/html/HTMLFieldSetElement.h
  15. +2 −4 Source/WebCore/html/HTMLFrameElement.cpp
  16. +11 −13 Source/WebCore/html/HTMLFrameElement.h
  17. +10 −10 Source/WebCore/html/HTMLIFrameElement.h
  18. +50 −51 Source/WebCore/html/HTMLMediaElement.cpp
  19. +28 −34 Source/WebCore/html/HTMLMediaElement.h
  20. +84 −78 Source/WebCore/html/HTMLSelectElement.cpp
  21. +4 −4 Source/WebCore/html/HTMLTextAreaElement.h
  22. +10 −6 Source/WebCore/html/HTMLVideoElement.cpp
  23. +5 −2 Source/WebCore/html/HTMLVideoElement.h
  24. +5 −5 Source/WebCore/html/HTMLWBRElement.h
  25. +7 −8 Source/WebCore/html/MediaElementSession.cpp
  26. +5 −5 Source/WebCore/html/TextFieldInputType.cpp
  27. +24 −17 Source/WebCore/html/shadow/SliderThumbElement.cpp
  28. +3 −3 Source/WebCore/html/shadow/TextControlInnerElements.cpp
  29. +3 −6 Source/WebCore/page/EventHandler.cpp
  30. +5 −8 Source/WebCore/page/PrintContext.cpp
  31. +3 −7 Source/WebCore/page/SpatialNavigation.cpp
  32. +8 −5 Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm
  33. +7 −5 Source/WebCore/rendering/RenderAttachment.h
  34. +1 −0 Source/WebCore/rendering/RenderFrame.cpp
  35. +12 −10 Source/WebCore/rendering/RenderFrame.h
  36. +6 −3 Source/WebCore/rendering/RenderLayerFilterInfo.cpp
  37. +6 −4 Source/WebCore/rendering/RenderMedia.h
  38. +7 −6 Source/WebCore/rendering/RenderTextControlMultiLine.h
  39. +8 −6 Source/WebCore/rendering/RenderVideo.cpp
  40. +24 −22 Source/WebCore/rendering/RenderVideo.h
  41. +1 −1 Source/WebCore/svg/SVGGElement.cpp
  42. +0 −1 Source/WebCore/svg/SVGGraphicsElement.cpp
  43. +0 −1 Source/WebCore/svg/SVGPathElement.cpp
  44. +24 −0 Source/WebKit/mac/ChangeLog
  45. +9 −7 Source/WebKit/mac/Misc/WebNSPasteboardExtras.mm
  46. +18 −21 Source/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm
  47. +4 −5 Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
  48. +24 −0 Source/WebKit2/ChangeLog
  49. +6 −13 Source/WebKit2/Shared/WebRenderObject.cpp
  50. +8 −6 Source/WebKit2/WebProcess/Plugins/PluginView.cpp
  51. +12 −5 Source/WebKit2/WebProcess/WebPage/WebPage.cpp
  52. +1 −1 Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
@@ -1,3 +1,265 @@
2016-05-31 Darin Adler <darin@apple.com>

Audit RenderObject casts and fix problems and style issues found
https://bugs.webkit.org/show_bug.cgi?id=158221

Reviewed by Chris Dumez.

* bindings/objc/DOM.mm:
(-[DOMElement image]): Use auto to get more specific types in code getting
the renderer for an element instead of dumbing down the type to RenderObject.

* dom/Element.cpp:
(WebCore::Element::scrollByUnits): Call renderer only once. The comment in
Node advises we should do this since it has a branch in it.
(WebCore::Element::absoluteEventBounds): Call renderer only once. Also use
auto for a rect type to clarify that we are not changing the type of the
rect returned by the fucntion.
(WebCore::Element::webkitGetRegionFlowRanges): Call renderer only once.

* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::addBlockPlaceholderIfNeeded): Use auto
to get a mroe specific renderer type.

* editing/SimplifyMarkupCommand.cpp:
(WebCore::SimplifyMarkupCommand::doApply): Call renderer only once.

* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_addAttachmentForElement): Add an obviously missing
null check for something that is null checked elsewhere.
(fileWrapperForURL): Ditto.
(fileWrapperForElement): Changed argument type to HTMLImageElement& since
the call site already checks the type of the object. Use HTMLImageElement::src
instead of repeating the code here. Check the type of the renderer instead of
assuming it's a RenderImage.
(WebCore::editingAttributedStringFromRange): Pass a reference, not a pointer.

* html/HTMLAnchorElement.cpp:
(WebCore::appendServerMapMousePosition): Take a reference to an event rather
than a "known to be non-null" pointer. Call renderer only once. Round the
floating point values rather than truncating them.
(WebCore::HTMLAnchorElement::handleClick): Pass a reference.

* html/HTMLAttachmentElement.cpp:
(WebCore::HTMLAttachmentElement::setFile): Removed the now-unneeded cast since
the renderer function returns a pointer of a more specific type now.
(WebCore::HTMLAttachmentElement::parseAttribute): Ditto.
(WebCore::HTMLAttachmentElement::attachmentTitle): Use auto& to avoid a bit of
reference count churn.

* html/HTMLAttachmentElement.h: Override renderer to return a more specific type.
This follows the pattern that ContainerNode::renderer uses.

* html/HTMLButtonElement.h: Ditto.

* html/HTMLCanvasElement.cpp: Gave the constants at the top of the file more
normal names. Removed unneeded "static" from them. Moved the
defaultInterpolationQuality constant here from the header because it doesn't
need to be there.
(WebCore::HTMLCanvasElement::HTMLCanvasElement): Updated for name changes.
(WebCore::HTMLCanvasElement::createElementRenderer): Removed unneeded code to
set m_rendererIsCanvas to record renderer type; we can just check the type.
(WebCore::HTMLCanvasElement::setHeight): Updated for name changes.
(WebCore::HTMLCanvasElement::setWidth): Ditto.
(WebCore::HTMLCanvasElement::reset): Check the type of the renderer directly
instead of calling m_rendererIsCanvas. This helped make it clear we were
do extra unneeded checks since a renderer can't both be a RenderCanvas and
not be a RenderBox.
(WebCore::HTMLCanvasElement::createImageBuffer): Updated for name changes.

* html/HTMLCanvasElement.h: Moved DefaultInterpolationQuality into the cpp file.
Use nullptr instead of 0. Removed m_rendererIsCanvas.

* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::HTMLFieldSetElement): Initialize m_documentVersion
in the class definition.
(WebCore::HTMLFieldSetElement::~HTMLFieldSetElement): Use m_hasDisabledAttribute.
(WebCore::updateFromControlElementsAncestorDisabledStateUnder): Fixed typo.
(WebCore::HTMLFieldSetElement::disabledAttributeChanged): Fixed mistake in this
function that would cause the number of disabled fieldset elements to be too high
if the disabled attribute's value was changed from one value to another. Use a
boolean to track the old value; can't think of a solution that works without that.
(WebCore::HTMLFieldSetElement::childrenChanged): Fixed typo.
(WebCore::HTMLFieldSetElement::didMoveToNewDocument): Use m_hasDisabledAttribute.
(WebCore::HTMLFieldSetElement::updateAssociatedElements): Changed name to make it
clearer what this function does. Tweaked a bit without changing behavior.
(WebCore::HTMLFieldSetElement::associatedElements): Updated for name change.
(WebCore::HTMLFieldSetElement::length): Changed to call associatedElements instead of
repeating that it does.

* html/HTMLFieldSetElement.h: Override renderer to return a more specific type.
Also updated for other changes mentioned above.

* html/HTMLFrameElement.cpp:
(WebCore::HTMLFrameElement::HTMLFrameElement): Initialize booleans in the class
definition rather than doing it here.
(WebCore::HTMLFrameElement::parseAttribute): Call renderer only once.

* html/HTMLFrameElement.h: Override renderer to return a more specific type.
Also initialize some booleans in the class definition.

* html/HTMLIFrameElement.h: Override renderer to return a more specific type.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updateRenderer): Added. Helper for a common idiom.
(WebCore::HTMLMediaElement::didAttachRenderers): Use auto to get a more specific
type for the renderer.
(WebCore::HTMLMediaElement::willDetachRenderers): Call renderer only once.
(WebCore::HTMLMediaElement::didRecalcStyle): Use updateRenderer to call renderer
only once.
(WebCore::HTMLMediaElement::loadResource): Ditto.
(WebCore::HTMLMediaElement::waitForSourceChange): Ditto.
(WebCore::HTMLMediaElement::noneSupported): Ditto.
(WebCore::HTMLMediaElement::setReadyState): Ditto.
(WebCore::HTMLMediaElement::progressEventTimerFired): Ditto.
(WebCore::HTMLMediaElement::selectNextSourceChild): Renamed goto label to use a style
that fits WebKit coding style. Call renderer only once in MediaQuery code.
(WebCore::HTMLMediaElement::mediaPlayerRepaint): Call renderer only once.
(WebCore::HTMLMediaElement::mediaPlayerSizeChanged): Use updateRenderer to call
renderer only once.
(WebCore::HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated): Call renderer
only once.
(WebCore::HTMLMediaElement::mediaPlayerGraphicsDeviceAdapter): Call page only once.
(WebCore::HTMLMediaElement::mediaEngineWasUpdated): Use updateRenderer to call
renderer only once.
(WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged): Ditto.
(WebCore::HTMLMediaElement::updatePlayState): Ditto.
(WebCore::HTMLMediaElement::stopWithoutDestroyingMediaPlayer): Ditto.
(WebCore::HTMLMediaElement::resume): Ditto.
(WebCore::HTMLMediaElement::mediaPlayerContentBoxRect): Call renderer only once.
(WebCore::mediaElementIsAllowedToAutoplay): Use auto to get a more specific type.

* html/HTMLMediaElement.h: Removed conditionals around forward declarations.
Tweaked formatting a bit. Added the updateRender function. Override renderer to
return a more specific type.

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::optionElementChildrenChanged): Don't use the renderer
just to get to the document for the AXObjectCache.
(WebCore::HTMLSelectElement::setLength): Use auto for the list items vector.
(WebCore::HTMLSelectElement::nextValidIndex): Ditto.
(WebCore::HTMLSelectElement::firstSelectableListIndex): Ditto.
(WebCore::HTMLSelectElement::nextSelectableListIndexPageAway): Ditto. Also add a
null check for the renderer.
(WebCore::HTMLSelectElement::updateListBoxSelection): Split an assertion with &&
in it into two separate assertions. Use auto for the list items vector and use
a reference for the list items.
(WebCore::HTMLSelectElement::listBoxOnChange): Use auto for the list items vector
and use a reference for the list items.
(WebCore::HTMLSelectElement::setRecalcListItems): Don't use the renderer
just to get to the document for the AXObjectCache.
(WebCore::HTMLSelectElement::selectOption): Use auto for the list items vector.
(WebCore::HTMLSelectElement::optionToListIndex): Ditto.
(WebCore::HTMLSelectElement::listToOptionIndex): Ditto.
(WebCore::HTMLSelectElement::searchOptionsForValue): Ditto.
(WebCore::HTMLSelectElement::restoreFormControlState): Ditto.
(WebCore::HTMLSelectElement::platformHandleKeydownEvent): Call renderer only once.
(WebCore::HTMLSelectElement::menuListDefaultEventHandler): Split an assertion with
&& in it into two separate assertions. Use auto for the list items vector. Call
renderer only once.
(WebCore::HTMLSelectElement::updateSelectedState): Use a reference for the list
item.
(WebCore::HTMLSelectElement::listBoxDefaultEventHandler): Use auto for the list
items vvector. Call renderer less often; could not quite get it down to once.
(WebCore::HTMLSelectElement::defaultEventHandler): Call renderer only once.
(WebCore::HTMLSelectElement::lastSelectedListIndex): Use auto for the list items
vector and use a reference for the list items.
(WebCore::HTMLSelectElement::optionAtIndex): Use a reference for the list item.
(WebCore::HTMLSelectElement::accessKeySetSelectedIndex): Use auto for the list
items vector and use a reference for the list items.
(WebCore::HTMLSelectElement::length): Use auto for the list items vector.

* html/HTMLTextAreaElement.h: Override renderer to return a more specific type.

* html/HTMLVideoElement.cpp:
(WebCore::HTMLVideoElement::didAttachRenderers): Call renderer only once and
don't downcast it. There was no obvious type check because the renderer has a
guaranteed type, but this is now clearer because it's the renderer function
that returns a more specific type.
(WebCore::HTMLVideoElement::parseAttribute): Ditto.
(WebCore::HTMLVideoElement::setDisplayMode): Ditto.

* html/HTMLVideoElement.h: Override renderer to return a more specific type.
* html/HTMLWBRElement.h: Ditto.

* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::canControlControlsManager): Removed
unneeded typecast in code that null checks a renderer.
(WebCore::isMainContent): Remove now-unneeded downcast of a renderer
obtained from an HTMLMediaElement. Fixed awkward formatting by splitting
an if statement into two.
(WebCore::isElementLargeEnoughForMainContent): Remove now unneeded downcast
of a renderer obtained from an HTMLMediaElement.

* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::forwardEvent): Call renderer only once.
Also use auto more in the code rather than writing out types.

* html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::setPositionFromPoint): Used the renderBox
function more consistently for all the renderers used here; before,
some had null checks and others did not.

* html/shadow/TextControlInnerElements.cpp:
(WebCore::SearchFieldResultsButtonElement::defaultEventHandler): Use auto
a bit more.

* page/EventHandler.cpp:
(WebCore::enclosingScrollableArea): Removed a redundant null check and
stopped using the name "element" for a local variable that was not
always an element.

* page/PrintContext.cpp:
(WebCore::enclosingBoxModelObject): Rewrote loop to be simpler and tighter.
Also marked this inline since it's used only one place.
(WebCore::PrintContext::pageNumberForElement): Use auto for the return
value rather than writing out the type.

* page/SpatialNavigation.cpp:
(WebCore::isScrollableNode): Tighten the code and use auto a bit.

* platform/ios/WebVideoFullscreenControllerAVKit.mm: Add an include of
RenderVideo.h since this gets at the renderer for a video.

* rendering/RenderAttachment.h:
(WebCore::HTMLAttachmentElement::renderer): Added. Function is here because
it can only be called by code that includes this header. This matches the
pattern of RenderElement.h and ContainerNode::renderer.

* rendering/RenderFrame.cpp: Added now-needed include.

* rendering/RenderFrame.h:
(WebCore::HTMLFrameElement::renderer): Added. Same logic as above.

* rendering/RenderLayerFilterInfo.cpp:
(WebCore::RenderLayer::FilterInfo::updateReferenceFilterClients): Use auto
a bit and call rendeer only once.

* rendering/RenderMedia.h:
(WebCore::HTMLMediaElement::renderer): Added. Same logic as above.
* rendering/RenderTextControlMultiLine.h:
(WebCore::HTMLTextAreaElement::renderer): Ditto.

* rendering/RenderVideo.cpp:
(WebCore::placeholder): Renamed. Tightened up argument type to match what
is passed at all the call sites. Use auto instead of RenderObject.
(WebCore::RenderVideo::offsetLeft): Use auto and the renamed function above.
(WebCore::RenderVideo::offsetTop): Ditto.
(WebCore::RenderVideo::offsetWidth): Ditto.
(WebCore::RenderVideo::offsetHeight): Ditto.

* rendering/RenderVideo.h:
(WebCore::HTMLVideoElement::renderer): Added. Same logic as above.

* svg/SVGGElement.cpp:
(WebCore::SVGGElement::createElementRenderer): Fixed typo.

* svg/SVGGraphicsElement.cpp:
(WebCore::SVGGraphicsElement::createElementRenderer): Removed
non-helpful oblique comment.
* svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::createElementRenderer): Ditto.

2016-06-01 Chris Fleizach <cfleizach@apple.com>

LayoutTest accessibility/ios-simulator/attributed-string-for-range.html failing on ios-simulator debug
@@ -707,10 +707,10 @@ @implementation DOMElement (DOMElementAppKitExtensions)
- (NSImage*)image
{
// FIXME: Could we move this function to WebCore::Node and autogenerate?
WebCore::RenderObject* renderer = core(self)->renderer();
auto* renderer = core(self)->renderer();
if (!is<RenderImage>(renderer))
return nil;
WebCore::CachedImage* cachedImage = downcast<RenderImage>(*renderer).cachedImage();
auto* cachedImage = downcast<RenderImage>(*renderer).cachedImage();
if (!cachedImage || cachedImage->errorOccurred())
return nil;
return cachedImage->imageForRenderer(renderer)->getNSImage();
@@ -675,10 +675,11 @@ void Element::scrollByUnits(int units, ScrollGranularity granularity)
{
document().updateLayoutIgnorePendingStylesheets();

if (!renderer())
auto* renderer = this->renderer();
if (!renderer)
return;

if (!renderer()->hasOverflowClip())
if (!renderer->hasOverflowClip())
return;

ScrollDirection direction = ScrollDown;
@@ -687,7 +688,7 @@ void Element::scrollByUnits(int units, ScrollGranularity granularity)
units = -units;
}
Element* stopElement = this;
downcast<RenderBox>(*renderer()).scroll(direction, granularity, units, &stopElement);
downcast<RenderBox>(*renderer).scroll(direction, granularity, units, &stopElement);
}

void Element::scrollByLines(int lines)
@@ -1009,8 +1010,9 @@ LayoutRect Element::absoluteEventBounds(bool& boundsIncludeAllDescendantElements
if (svgElement.getBoundingBox(localRect, SVGLocatable::DisallowStyleUpdate))
result = LayoutRect(renderer()->localToAbsoluteQuad(localRect, UseTransforms, &includesFixedPositionElements).boundingBox());
} else {
if (is<RenderBox>(renderer())) {
RenderBox& box = *downcast<RenderBox>(renderer());
auto* renderer = this->renderer();
if (is<RenderBox>(renderer)) {
auto& box = downcast<RenderBox>(*renderer);

bool computedBounds = false;

@@ -1030,7 +1032,7 @@ LayoutRect Element::absoluteEventBounds(bool& boundsIncludeAllDescendantElements
// FIXME: this doesn't handle nested columns.
RenderElement* multicolContainer = flowThread->parent();
if (multicolContainer && is<RenderBox>(multicolContainer)) {
LayoutRect overflowRect = downcast<RenderBox>(multicolContainer)->layoutOverflowRect();
auto overflowRect = downcast<RenderBox>(*multicolContainer).layoutOverflowRect();
result = LayoutRect(multicolContainer->localToAbsoluteQuad(FloatRect(overflowRect), UseTransforms, &includesFixedPositionElements).boundingBox());
computedBounds = true;
}
@@ -1043,7 +1045,7 @@ LayoutRect Element::absoluteEventBounds(bool& boundsIncludeAllDescendantElements
boundsIncludeAllDescendantElements = layoutOverflowRectContainsAllDescendants(box);
}
} else
result = LayoutRect(renderer()->absoluteBoundingBoxRect(true /* useTransforms */, &includesFixedPositionElements));
result = LayoutRect(renderer->absoluteBoundingBoxRect(true /* useTransforms */, &includesFixedPositionElements));
}

return result;
@@ -2967,12 +2969,12 @@ Vector<RefPtr<Range>> Element::webkitGetRegionFlowRanges() const
{
Vector<RefPtr<Range>> rangeObjects;
document().updateLayoutIgnorePendingStylesheets();
if (renderer() && renderer()->isRenderNamedFlowFragmentContainer()) {
RenderNamedFlowFragment& namedFlowFragment = *downcast<RenderBlockFlow>(*renderer()).renderNamedFlowFragment();
auto* renderer = this->renderer();
if (renderer && renderer->isRenderNamedFlowFragmentContainer()) {
auto& namedFlowFragment = *downcast<RenderBlockFlow>(*renderer).renderNamedFlowFragment();
if (namedFlowFragment.isValid())
namedFlowFragment.getRanges(rangeObjects);
}

return rangeObjects;
}

@@ -1059,13 +1059,12 @@ RefPtr<Node> CompositeEditCommand::addBlockPlaceholderIfNeeded(Element* containe

document().updateLayoutIgnorePendingStylesheets();

RenderObject* renderer = container->renderer();
auto* renderer = container->renderer();
if (!is<RenderBlockFlow>(renderer))
return nullptr;

// append the placeholder to make sure it follows
// any unrendered blocks
RenderBlockFlow& blockFlow = downcast<RenderBlockFlow>(*renderer);
// Append the placeholder to make sure it follows any unrendered blocks.
auto& blockFlow = downcast<RenderBlockFlow>(*renderer);
if (!blockFlow.height() || (blockFlow.isListItem() && blockFlow.isEmpty()))
return appendBlockPlaceholder(container);

@@ -70,7 +70,8 @@ void SimplifyMarkupCommand::doApply()
if (!currentNode)
break;

if (!is<RenderInline>(currentNode->renderer()) || downcast<RenderInline>(*currentNode->renderer()).alwaysCreateLineBoxes())
auto* renderer = currentNode->renderer();
if (!is<RenderInline>(renderer) || downcast<RenderInline>(*renderer).alwaysCreateLineBoxes())
continue;

if (currentNode->firstChild() != currentNode->lastChild()) {

0 comments on commit 4eb118f

Please sign in to comment.