Make sure to call release() on our smart pointers when we should.
https://bugs.webkit.org/show_bug.cgi?id=116307

Reviewed by Andreas Kling.

Call release() when we should call it. There is probably more occurence
of this problem on the codebase but this is a first bunch of fixes.

No new tests : existing ones should cover.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::valueForNinePieceImage):
(WebCore::getBorderRadiusShorthandValue):
(WebCore::CSSComputedStyleDeclaration::valueForFilter):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
(WebCore::CSSComputedStyleDeclaration::getCSSPropertyValuesForSidesShorthand):
(WebCore::CSSComputedStyleDeclaration::getCSSPropertyValuesForGridShorthand):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseBorderImage):
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::collectStyleForPresentationAttribute):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150255 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed build fix. Remove assertion that doesn't make sense anymore since the
page does not give us access to the Chrome pointer directly anymore.

Patch by Gustavo Noronha Silva <gustavo.noronha@collabora.com> on 2013-05-17

* webkit/webkitwebview.cpp:
(WebKit::kit):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150256 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[BlackBerry] Remove stale comment for select mouse handling.
https://bugs.webkit.org/show_bug.cgi?id=116309

Reviewed by Rob Buis.

PR 135935.

Remove a FIXME that has been invalidated by a change
to our touch -> mouse model.

Internally Rubberstamped by Genevieve Mak.

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::handleMouseEvent):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150257 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Improve -webkit-text-underline-position memory usage.
https://bugs.webkit.org/show_bug.cgi?id=116108

Patch by Lamarque V. Souza <Lamarque.Souza@basyskom.com> on 2013-05-17
Reviewed by Benjamin Poulain.

Remove m_maxLogicalTop private variable from RootInlineBox to reduce
the overall memory used to render RootInlineBoxes (eight bytes per RootInlineBox
instance in a 64-bit machine). RootInline::maxLogicalTop() now computes
the maxLogicalTop value everytime it is called. In a typical page
computeMaxLogicalTop is called less than 10 times for each
InlineTextBox that uses -webkit-text-underline-position. That is a small
price users of -webkit-text-underline-position will pay so that
everybody can benefit from the memory reduction in RootInlineBox.

No new tests, no change in behavior.

* rendering/InlineFlowBox.cpp:
(WebCore::InlineFlowBox::computeMaxLogicalTop): Make it const.
* rendering/InlineFlowBox.h:
* rendering/RootInlineBox.cpp:
(WebCore::RootInlineBox::RootInlineBox): Remove m_maxLogicalTop.
(WebCore::RootInlineBox::alignBoxesInBlockDirection): Remove
computeMaxLogicalTop call and obsolete comment.
(WebCore):
(WebCore::RootInlineBox::maxLogicalTop): Compute maxLogicalTop before
returning its value.
* rendering/RootInlineBox.h:
(RootInlineBox):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150258 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Changes in text-only properties shouldn't cause repaints unless there is actually text.
<http://webkit.org/b/116250>

Reviewed by Antti Koivisto.

Add a new StyleDifferenceRepaintIfText value to the repertoire of RenderStyle::diff().
This result means that the renderer only needs to repaint if one of its immediate children contains text.

This lets us avoid repainting the same pixels when hovering over constructs like:

    <style>
        a { text-decoration: none; }
        a:hover { text-decoration: underline; }
    </style>
    <a href="http://is.gd/andersca">
        <img src="cool-hat.jpg">
    </a>

Since the change in text-decoration has no effect on the rendering of the <img> element,
we'll now be smart enough to avoid repainting it.

* rendering/style/RenderStyleConstants.h:
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::diff):

    Move checking of text-only properties until the very end, and return StyleDifferenceRepaintIfText
    in case a difference is found, giving precedence to StyleDifferenceRepaint.

* rendering/RenderObject.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::hasImmediateNonWhitespaceTextChild):

    Helper to check if a RenderObject has at least one RenderText child containing more than just
    collapsible whitespace.

(WebCore::RenderObject::shouldRepaintForStyleDifference):

    Helper to check if a StyleDifference is either ...Repaint or ...RepaintIfText and the renderer
    has an immediate text child.

(WebCore::RenderObject::styleWillChange):
(WebCore::RenderObject::setStyle):

    Don't repaint for StyleDifferenceRepaintIfText unless hasImmediateNonWhitespaceTextChild().

* rendering/RenderBox.cpp:
(WebCore::RenderBox::styleDidChange):
* rendering/svg/SVGResourcesCache.cpp:
(WebCore::SVGResourcesCache::clientStyleChanged):

    Tweak for new StyleDifference enum value.

* rendering/RenderText.h:
* rendering/RenderText.cpp:
(WebCore::RenderText::isAllCollapsibleWhitespace):

    Made this const.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150259 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Some media/track tests fail or assert on Mac
https://bugs.webkit.org/show_bug.cgi?id=97132

Reviewed by Simon Fraser.

Source/WebCore:

Rationalize the font and padding behavior of cues and cue boxes; ::cue pseudo elements cannot have padding
values applied via CSS (due to padding not being included in the whitelist of applicable CSS properties).
Also, the font values were being applied to the box at one level and the cue at another, leading to incorrect
layout in the snapToLines case. Padding has been removed from the cue, and the font settings are now applied
to the box exclusively.

Additionally, a few drive-by changes were made in TextTrackCue to the return values of displayTreeInternal() &
element(), which previously returned a PassRefPtr<> instead of a plain pointer.

* css/mediaControls.css:
(video::-webkit-media-text-track-container): Move the font size to the display selector.
(video::cue): Remove the display:inline and padding:2px declarations.
(video::-webkit-media-text-track-display): Remove the -webkit-line-content now that the ::cue has no padding.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::TextTrackCue): The background box is now a span, rather than a forced-inline div.
(WebCore::TextTrackCue::displayTreeInternal): Return a plain pointer.
(WebCore::TextTrackCue::getDisplayTree): Ditto.
(WebCore::TextTrackCue::setFontSize): Set the font on the box, not the cue.
* html/track/TextTrackCue.h:
(WebCore::TextTrackCue::element): Return a plain pointer.
* html/track/TextTrackCueGeneric.cpp:
(WebCore::TextTrackCueGenericBoxElement::applyCSSProperties): The cue element is now a span, not a div.
* page/CaptionUserPreferencesMac.mm:
(WebCore::CaptionUserPreferencesMac::captionsWindowCSS): Whitespace.
(WebCore::CaptionUserPreferencesMac::captionsBackgroundCSS): Do not set padding on the cue.

LayoutTests:

* media/track/captions-webvtt/captions-snap-to-lines-not-set.vtt:
* media/track/track-cue-rendering-horizontal.html:
* media/track/track-cue-rendering-snap-to-lines-not-set-expected.txt:
* media/track/track-cue-rendering-snap-to-lines-not-set.html:
* media/track/track-cue-rendering-vertical.html:
* platform/mac/TestExpectations:
* platform/mac/media/track/track-cue-rendering-horizontal-expected.png:
* platform/mac/media/track/track-cue-rendering-horizontal-expected.txt:
* platform/mac/media/track/track-cue-rendering-vertical-expected.png:
* platform/mac/media/track/track-cue-rendering-vertical-expected.txt:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150260 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Reduce number of WebFrameLoaderClient static casts in WebKit
https://bugs.webkit.org/show_bug.cgi?id=116320

Reviewed by Antti Koivisto.

We already have a function to return a WebFrame from a WebCore::Frame, use it.

* DOM/WebDOMOperations.mm:
(WebFrameFilter::shouldIncludeSubframe):
* WebView/WebDataSource.mm:
(-[WebDataSource webFrame]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150261 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[BlackBerry] ImageBlackBerry: add missing BlendMode parameter
https://bugs.webkit.org/show_bug.cgi?id=116316

Patch by Alberto Garcia <agarcia@igalia.com> on 2013-05-17
Reviewed by Carlos Garcia Campos.

When the new BitmapImage::draw() method was added in r147110 it
didn't include the BlendMode parameter, which has been there since
r137011.

* platform/graphics/blackberry/ImageBlackBerry.cpp:
(WebCore::BitmapImage::draw):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150262 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix code that expects Page::chrome() to return a pointer
https://bugs.webkit.org/show_bug.cgi?id=116313

Patch by Alberto Garcia <agarcia@igalia.com> on 2013-05-17
Reviewed by Darin Adler.

Page::chrome() returns a reference after r150214.

* platform/network/blackberry/NetworkManager.cpp:
(WebCore::NetworkManager::startJob):
* platform/network/blackberry/SocketStreamHandleBlackBerry.cpp:
(WebCore::SocketStreamHandle::SocketStreamHandle):
* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
(WebCore::Internals::setEnableMockPagePopup):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150263 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Bad spacing inside MathML formulas when text-indent is specified
https://bugs.webkit.org/show_bug.cgi?id=106600

Patch by Frédéric Wang <fred.wang@free.fr> on 2013-05-17
Reviewed by Martin Robinson.

Source/WebCore:

When MathML is used in a HTML page that modifies the CSS text-indent,
large gaps appear inside the mathematical expressions. Resetting it to
0 on the math root (as Gecko does) fixes the issue.

Tests: mathml/presentation/text-indent.html
       mathml/presentation/text-indent-expected.html

* css/mathml.css:
(math): reset text-indent to its default value.

LayoutTests:

New test to verify that the text-indent property is reset to 0 on
the MathML root.

* mathml/presentation/text-indent-expected.html: Added.
* mathml/presentation/text-indent.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150264 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebFramePolicyListener should keep its Frame in a RefPtr
https://bugs.webkit.org/show_bug.cgi?id=116322

Reviewed by Darin Adler.

* WebCoreSupport/WebFrameLoaderClient.mm:
(-[WebFramePolicyListener initWithWebCoreFrame:]):
No need to ref the frame, the RefPtr does that for us.

(-[WebFramePolicyListener invalidate]):
Just set the frame to null.

(-[WebFramePolicyListener dealloc]):
Remove call to deref, that's done automatically now.

(-[WebFramePolicyListener finalize]):
Remove this method. (We could have kept it just for the assertion but I didn't think that was necessary).

(-[WebFramePolicyListener receivedPolicyDecision:):
Use release() to transfer ownership.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150265 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Move the policy function to WebFramePolicyListener
https://bugs.webkit.org/show_bug.cgi?id=116323

Reviewed by Darin Adler.

There's no need for the WebFrameLoaaderClient to hold on to the policy function,
so move it to WebFramePolicyListener. This gets rid of another WebFrameLoaderClient cast.

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::setUpPolicyListener):
Pass the policy function when creating the WebFramePolicyListener object.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150266 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL][WK2] Fix sub menu initialization in ewk_context_menu_item
https://bugs.webkit.org/show_bug.cgi?id=116321

Patch by Michał Pakuła vel Rutka <m.pakula@samsung.com> on 2013-05-17
Reviewed by Christophe Dumez.

During sub menu creation, after initializing m_parentMenu, parentMenu
pointer became null which may cause segfaults. This patch fixes it by
using m_parentMenu.

* UIProcess/API/efl/ewk_context_menu_item.cpp:
(EwkContextMenuItem::EwkContextMenuItem):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150267 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EFL] Move EFL port off legacy clipboard
https://bugs.webkit.org/show_bug.cgi?id=116181

Reviewed by Anders Carlsson.

* dom/Clipboard.h: Switched EFL away from "legacy" mode for Clipboard.

* page/efl/EventHandlerEfl.cpp:
(WebCore::EventHandler::createDraggingClipboard): Changed to call Clipboard member function.

* platform/efl/ClipboardEfl.cpp: Deleted most of the functions.
(WebCore::Editor::newGeneralClipboard): Changed to call Clipboard member function.
(WebCore::Clipboard::createDragImage): Moved from ClipboardEfl to Clipboard.
(WebCore::Clipboard::declareAndWriteDragImage): Moved from ClipboardEfl to Clipboard.
(WebCore::Clipboard::items): Ditto.

* platform/efl/PasteboardEfl.cpp: A lot of copyright notices for a file that
has no code in it other than notImplemented lines! I didn't add a new one.
(WebCore::Pasteboard::createForCopyAndPaste): Added.
(WebCore::Pasteboard::createPrivate): Added.
(WebCore::Pasteboard::createForDragAndDrop): Added.
(WebCore::Pasteboard::hasData): Added.
(WebCore::Pasteboard::readString): Added.
(WebCore::Pasteboard::writeString): Added.
(WebCore::Pasteboard::types): Added.
(WebCore::Pasteboard::readFilenames): Added.
(WebCore::Pasteboard::setDragImage): Added.
(WebCore::Pasteboard::writePasteboard): Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150268 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make kit(Frame*) more robust
https://bugs.webkit.org/show_bug.cgi?id=116324

Reviewed by Darin Adler.

Check that the frame loader's client isn't the EmptyFrameLoaderClient (or a subclass thereof)
before casting to WebFrameLoaderClient.

* WebView/WebFrame.mm:
(kit):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150269 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix Release builds.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150270 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add WKPageLoadData and WKPageLoadDataWithUserData SPI to support loading arbitrary data blobs
https://bugs.webkit.org/show_bug.cgi?id=116325

Reviewed by Simon Fraser.

* UIProcess/API/C/WKPage.cpp:
(WKPageLoadData):
(WKPageLoadDataWithUserData):
Add new SPI.

* UIProcess/API/C/WKPage.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::loadData):
* UIProcess/WebPageProxy.h:
Pipe through to the WebProcess.

* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::loadDataImpl):
(WebKit::WebPage::loadData):
(WebKit::WebPage::loadHTMLString):
(WebKit::WebPage::loadAlternateHTMLString):
(WebKit::WebPage::loadPlainTextString):
(WebKit::WebPage::loadWebArchiveData):
Rename existing loadData function to loadDataImpl (I hate it) to avoid overload conflict
from IPC magic.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150271 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make filter-build-webkit testable using LoadAsModule
Part 1 of 3: <http://webkit.org/b/116247>

Reviewed by Benjamin Poulain.

* Scripts/filter-build-webkit: Change global variables that are
used in subroutines from 'my' to 'our' to make it possible to
evaluate the script in a package context in LoadAsModule.pm.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150272 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Accessing null function pointers is bad.

* WebCoreSupport/WebFrameLoaderClient.mm:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150273 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[BlackBerry] REGRESSION(r150060): Crash in LayerWebKitThread::updateTextureContents
https://bugs.webkit.org/show_bug.cgi?id=116305

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2013-05-17
Reviewed by Rob Buis.

PR 340537.
Internally reviewed by Arvid Nilsson.

Use updateLayoutAndStyleIfNeededRecursive() instead of
layoutIfNeeded() since we are about to draw in
rootLayerCommitTimerFired().

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::rootLayerCommitTimerFired):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@150274 268f45cc-cd09-0410-ab3c-d52691b4dbfc