Sheets loaded using @import were incorrectly being flagged as non-editable
user agent sheets because their parent sheet doesn't have an ownerNode. We now
check to make sure sheets also don't have a href before restricting their editability.

Add a second style span at copy time to hold document default styles. This helps us
differentiate between those and user applied styles at paste time, where we'll want
to let Mail's Paste As Quotation blockquote override document default styles, but
not others.

css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Changed the unit type used
for -webkit-text-stroke-width from CSS_NUMBER to CSS_PX, to match other properties that
are thick | medium | thin | <length>. Before, there was a mismatch between the unit
type of -webkit-text-stroke-width property values in a CSSComputedStyleDeclaration for
an element and that element's inlineStyleDecl(), causing identical values to always appear
different to diff().

editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::handlePasteAsQuotationNode): Fixed. Don't just change
the class to an empty string, completely remove it, it's no longer needed.
(WebCore::handleStyleSpansBeforeInsertion): Moved the optimization from doApply here.
(WebCore::ReplaceSelectionCommand::handleStyleSpans):
Added, replaces removeRedundantStyles.
We aren't (yet) removing all redundant styles, just those on style spans, so I removed the
unused code and renamed the function.
There won't be more than two style spans that we need to consider, the one with the
source document's default styles and styles on the commonAncestor of the copied Range,
so don't look for more than two.
Let elements that wrap the incoming fragment override the source document's styles.
(WebCore::ReplaceSelectionCommand::doApply): Moved code to handleStyleSpansBeforeInsertion
and call the renamed handleStyleSpans.

editing/ReplaceSelectionCommand.h:

editing/markup.cpp:
(WebCore::removeDefaultStyles): Added. Don't add document defaults to the style span
that holds user applied styles, since they'll be added to their own style span.
(WebCore::createMarkup):
Add a second style span that holds just the document defaults. This lets us differentiate
between those and user applied styles at paste time.
Mail blockquotes are just another type of special element, moved their handling there. This
also lets paste code make assumptions about the position of the two style spans (they are
*always* parent-child).

A style span isn't removed because at paste time because we don't anticipate
encountering styles on style spans that are non-inheritable, because we don't
create style spans like that at copy time. Turned this into a text only
test. Test remains visually unchanged:

We don't remove styles from style spans that are overridden by all of their
children, even though they are unnecessary. We've never done this, but now
that there can be two style spans at paste time we are more likely to have
a style span left over because of this problem. Mentioned this in the test
case and turned this into a text only test:

Updated resource used in the layout test I landed yesterday.
Due to a difference between Foundation on Tiger vs Leopard, the resource generated on
Leopard caused different results on Leopard and Tiger.
Regenerating the resource on Tiger, however, agrees with Leopard.

Let me tell you a story:
A long time ago, in a cvs repository far, far away, loader code was almost all up in WebKit.
WebArchive code was intertwined with that code in bizarre and complex ways.
During the months long loader re-factoring where we pushed much loader code down into WebCore,
many portions of the WebKit loader were thinned out until they ceased to exist. Others remained
with a sole purpose.

One such section of code whose lineage traces back from WebFrameLoaderClient to WebFrameLoader
to WebLoader was originally rooted in the method [WebLoader loadRequest:]. This method was the
single entry point for almost all loading (network or web archives)

This method would check various headers and other fields on the NSURLRequest and NSURLResponse
to make decisions about the load. If the cache control fields were expired or other conditions
in the headers were met, the load would be forced to go out to the network.

As the loader was moved and tweaked repeatedly, most of this code was pruned or re-factored.
At some point, all that remained was the special cases for loading WebArchives.

Somewhere in the r16,000s, this remaining responsibility was noticed and related methods we renamed
to be WebArchive specific, further cementing the assumed design.

Problem is, the design was bad. A WebArchive is meant to be a static snapshot of a WebPage at a
specific point in time. Referring to the request to see if the resource should be reloaded seems
nonsensical, as does referring to the response headers to see if the resource is "expired". In the
context of loading a WebArchive, available data should *always* be loaded from the WebArchive, at least
during the initial load!

After discovering the secret to reproducing all of these bugs is both emptying our your Foundation
cache and disconnecting your network, it was easy to reproduce the 16 individually reported cases
that were all symptoms of this bug, and easy to verify that they are fixed with this patch.

WebCoreSupport/WebFrameLoaderClient.h:

WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::willUseArchive): Do not call either form of "canUseArchivedResource()" that
inspect the request or response objects - We are loading from a WebArchive, and we should never
make the decision to go out to the network when we actually have the resource available.

WebCoreSupport/WebSystemInterface.m:
(InitWebCoreSystemInterface): Remove two methods that are no longer used anywhere in WebKit

LayoutTests:

Reviewed by Mark Rowe

Test for better fix for <rdar://problem/4930688> (see r19549) and
original fix for <rdar://problem/3947312> (and 14 dupes)

Crafting custom WebArchives for layout tests is a pain and something that should
be resolved if we decide to pursue a new format.

Using a custom php script to act as a stand in for an image resource, I set its
cache-control header to expire immediately. Without the fix for the above bugs,
the resource will be "expired" and an attempt to fetch it from the network will
go out and fail. This failure will manifest with different ResourceLoadDelegate
information, as well as different dimensions in the render tree - the missing
image icon versus the archived image.

With the fix in place, the response will be ignored and the image will be pulled
from the WebArchive.

platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::createGlobalData): Added an overload for Vector<char>.
Streamlined the logic a bit.
(WebCore::append): Added. Helper functions for appending to a
Vector<char>.
(WebCore::markupToCF_HTML): Rewrote to use Vector<char> instead
of DeprecatedCString. Also simplified the logic a bit and used
macros to handle the integer width.
(WebCore::urlToMarkup): Use Vector<UChar> instead of String.
(WebCore::replaceNewlinesWithWindowsStyleNewlines): Tweaked.

platform/win/ClipboardUtilitiesWin.h: Update type of return
value from markupToCF_HTML. Did a bit of streamlining too.

WebCoreSupport/WebFrameLoaderClient.cpp:
(kit):
(WebFrameLoaderClient::dispatchCreatePage): Changed nested ifs to
early returns, and changed to use the COMPtr Query constructor.
(WebFrameLoaderClient::dispatchDidLoadMainResource): Added an early
return, and changed to use getWebDataSource.

WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::updateGlobalHistory):
(WebFrameLoaderClient::shouldGoToHistoryItem):
(WebFrameLoaderClient::setTitle): Changed some nested ifs into early
returns.
(WebFrameLoaderClient::webHistory): Changed to return a COMPtr to
make the reference management foolproof.

WebCoreSupport/WebFrameLoaderClient.cpp:
(getWebDataSource): Moved to the top of the file.
(WebFrameLoaderClient::savePlatformDataToCachedPage):
(WebFrameLoaderClient::transitionToCommittedForNewPage):
(WebFrameLoaderClient::canCachePage):

Scripts/gdb-safari: Set WEBKIT_UNSET_DYLD_FRAMEWORK_PATH in gdb's environment,
so that Safari inherits it when launched. Preexisting code in WebKit checks this
environment variable, and if set, unsets DYLD_FRAMEWORK_PATH, so that applications
launched by Safari continue to use the standard system WebKit.

Make the cleanPath function in CSSStyleSelector more efficient by using
a Vector<UChar>.

css/CSSStyleSelector.cpp:
(WebCore::cleanPath): Make this function work on a Vector<UChar> instead
of a String. Also remove unnecessary reverseFind call that could be acomplished
with two compares.
(WebCore::checkPseudoState): Remove reserveCapacity calls now that we are using
a stack buffer.

platform/text/PlatformString.h:
(WebCore::find): Make this find generic enough that it can be used for
String::find.
(WebCore::reverseFind): Implement reverseFind so that it can be used
for with a UChar* and length.

Fixed for <rdar://problem/5760530> REGRESSION: Assertion failure in
Document::removePendingSheet() from r30438

r30438 added a call to CachedResource::error() from inside
Loader::didReceiveData() if a CSS file 4xxs. There was an
assumption in the loader, though, that either error() would be
called, or didFinishLoading() would be called, so some work is
duplicated in each. Now that we are calling an error() on files
that will also make it to didFinishLoading() (since they succeeded
in the network layer), we need to make sure we do not duplicate the
work. CachedCSSStyleSheet::error() calls checkNotify, which ends up
decrementing the document's pending style sheet counter.
checkNotify() was still getting called, though, through the normal
didFinishLoading code path, and the counter was being decremented
twice. Bad!

rendering/bidi.cpp:
(WebCore::BidiState::addRun): Removed setting of sLogicallyLastBidiRun.
(WebCore::RenderBlock::constructLine): Removed unused start parameter
and added run count and first and last run parameters. Replaced end
parameter with lastLine boolean and endObject pointer.
(WebCore::RenderBlock::computeHorizontalPositionsForLine): Added first
and logically last run parameters.
(WebCore::RenderBlock::computeVerticalPositionsForLine): Added firstRun
parameter.
(WebCore::RenderBlock::bidiReorderLine): Removed setting of static
variables.
(WebCore::RenderBlock::layoutInlineChildren): Changed to use BidiState
accessors instead of file statics.

Add PluginInfoStore.cpp and new PluginDatabase.cpp to GTK+ and Qt ports.
Remove old PlugInInfoStoreQt.cpp as it is obsoleted by shared code.
Add PluginInfoStore, PluginDatabase, and PluginStream files to Wx build.
Add new PluginDatabase.cpp to Windows build.
Add temporary stubs for new PluginDatabase and PluginPackage.
shared classes to GTK+, Qt, and Wx ports.
Copy PluginDatabaseWin.cpp to PluginDatabase.cpp to preserve history.
Remove shared code from PluginDatabaseWin.cpp.
Remove Windows-specific code from PluginDatabase.cpp.
Use PlatformModule and PlatformFileTime instead of HMODULE and FILETIME.

Remove extraneous PluginPackage

from hash() class method prototype.
Subsume storeFileVersion into PluginPackage::fetchInfo.
Add cross-platform PlatformModuleVersion type definition.
Use PlatformModuleVersion to store the module version.
Rename m_fileVersion[ML]S to m_moduleVersion.
Change compareFileVersion to use PlatformModuleVersion as the argument.
Move PluginView::determineQuirks and m_quirks to PluginPackage.
Updated determineQuirks for the PlatformModuleVersion.

Make some of the refcounted style objects start out with a refcount of 1.

rendering/DataRef.h:
Make a DeprecatedDataRef class which is just a copy of the old DataRef class.
Change DataRef to use ::create() and ::copy() instead of the constructors.
Change DataRef's pointer to be a RefPtr instead.

loader/FrameLoader.cpp:
(WebCore::FrameLoader::load): When load type is FrameLoadTypeRedirectWithLockedHistory,
always do a real load. This makes sure that meta refresh loads are treated as real loads
rather than anchor scrolls. Also tweaked formatting a bit.
(WebCore::FrameLoader::continueFragmentScrollAfterNavigationPolicy): This function is
an alternate way to complete a load, so it needs to start the redirection timer if
redirection has already been scheduled.

In HTMLTokenizer::write, the code checks 'pendingScripts.isEmpty()' to decide
whether to save prependingSrc or not. However, in HTMLTokenizer::scriptHandler
and HTMLTokenizer::scriptExecution, the code checks testBit:LoadingExtScript
to decide whether to save prependingSrc or not. The later behavior is not right
because, in scriptHandler and scriptExecution, even the pendingScripts queue is
empty, the testBit:LoadingExtScript might be TRUE.

kjs/testkjs.cpp:
(GlobalObject::GlobalObject): Add readline function to global object.
(functionReadline): Added. Reads characters from stdin until a '\n' or
EOF is encountered. The input is returned as a String to the caller.

This slightly changes the behavior of parsing arguments by requiring
a '-f' before all files.

kjs/testkjs.cpp:
(createGlobalObject): Add a global property called 'arguments' which
contains an array with the parsed arguments as strings.
(runWithScripts): Pass in the arguments vector so that it can be passed
to the global object.
(parseArguments): Change parsing rules to require a '-f' before any script
file. After all '-f' and '-p' arguments have been parsed, the remaining
are added to the arguments vector and exposed to the script. If there is a
chance of ambiguity (the user wants to pass the string '-f' to the script),
the string '--' can be used separate the options from the pass through
arguments.
(kjsmain):

fix float positioning when a float that does not fit on the line is
followed by a float that does

Test: fast/block/float/narrow-after-wide.html

rendering/bidi.cpp:
(WebCore::RenderBlock::findNextLineBreak): Changed to not position any
more floats on the line once a float that does not fit is encountered.
That float should be pushed to the next line, and so should all floats
that follow, regardless of whether they can fit on the current line.

LayoutTests:

Reviewed by Darin Adler.

test float positioning when a float that does not fit on the line is
followed by a float that does

Disentangle global history updating from the back/forward history.
There are many cases where we don't want to create a new back/forward
item, but we do still want to add to the global history (used for visited
link coloring) in those cases.

Test: fast/history/subframe-is-visited.html

loader/FrameLoader.cpp:
(WebCore::FrameLoader::updateGlobalHistory): Renamed from
addHistoryForCurrentLocation and removed the back/forward handling.
(WebCore::FrameLoader::updateHistoryForStandardLoad): Streamlined logic a
bit. Replaced call to addHistoryForCurrentLocation with a call to
addBackForwardItemClippedAtTarget. Added an unconditional call to
updateGlobalHistory.
(WebCore::FrameLoader::updateHistoryForClientRedirect): Added a FIXME;
why doesn't this function update global history?
(WebCore::FrameLoader::updateHistoryForBackForwardNavigation): Ditto.
(WebCore::FrameLoader::updateHistoryForReload): Replaced the direct call
the client with a call to the new updateGlobalHistory function.
(WebCore::FrameLoader::updateHistoryForRedirectWithLockedHistory): Did
the same changes as for updateHistoryForStandardLoad.