11/12/07:

kjs/ustring.h: Moved UTF8SequenceLength() and decodeUTF8Sequence() to wtf/unicode.

kjs/ustring.cpp: (KJS::UString::UTF8String): Changed this function to take a strict/lenient
parameter. Callers are not interested in getting decoding results in strict mode, so
this allows for bailing out as soon as an error is seen.

html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::defaultEventHandler):
Adapted for SelectionController::setSelectedRange() now returning a bool.
SelectionController::toString() is no longer avasilable, use plainText() explicitly.

fix use of prefix and config.h, got rid of a few unneeded things in
the PCRE code; no behavior changes

API/JSBase.cpp: Added include of config.h.

API/JSCallbackConstructor.cpp: Ditto.

API/JSCallbackFunction.cpp: Ditto.

API/JSCallbackObject.cpp: Ditto.

API/JSClassRef.cpp: Ditto.

API/JSContextRef.cpp: Ditto.

API/JSObjectRef.cpp: Ditto.

API/JSStringRef.cpp: Ditto.

API/JSValueRef.cpp: Ditto.

JavaScriptCorePrefix.h: Removed obsolete <ctype.h> workaround.
Moved new/delete macros after includes, as they are in WebCore's prefix.
Removed "config.h".

pcre/dftables.cpp: (main): Changed back to not use a separate maketables
function. This is needed for PCRE, but not helpful for our use. Also changed
the tables to all be 128 entries long instead of 256, since only the first
128 are ever used.

pcre/pcre_compile.cpp: Added include of config.h. Eliminated digitab,
which was only being used to check hex digits. Changed all uses of TRUE and
FALSE to use the C++ true and false instead.
(check_escape): Just the TRUE/FALSE thing.
(is_counted_repeat): Ditto.
(could_be_empty_branch): Ditto.
(get_othercase_range): Ditto.
(compile_branch): Ditto.
(compile_regex): Ditto.
(is_anchored): Ditto.
(is_startline): Ditto.
(find_firstassertedchar): Ditto.
(jsRegExpCompile): Ditto.

pcre/pcre_exec.cpp: Added include of config.h. Changed all uses of TRUE and
FALSE to use the C++ true and false instead.
(match_ref): Just the TRUE/FALSE thing.
(match): Ditto. Removed some unneeded braces.
(jsRegExpExecute): Just the TRUE/FALSE thing.

pcre/pcre_internal.h: Moved the constants needed by dftables.cpp to the top
of the file instead of the bottom, so they can be used. Also changed the table
sizes to 128 instead of 256. Removed macro definitions of FALSE and TRUE.
Set array sizes for all the const arrays. Changed _pcre_utf8_table1_size to
be a macro instead of a extern int.

loader/FrameLoader.cpp: (WebCore::FrameLoader::isLocationChange):
Factored out the slow case of isScheduledLocationChangePending into this.

loader/FrameLoader.h:
(WebCore::FrameLoader::isScheduledLocationChangePending): Added an
inline check of the far and away most common case, where m_scheduledRedirection
is 0; the rest is in the isLocationChange function.

<rdar://problem/5522011> The content of the password field of Safari is displayed by reconversion.

Reviewed by Darin.

Some input methods (notably Kotoeri) can incorrectly provide
access to the raw text of a password field. To work around
this we forcefully override the inputContext whenever a password
field is active.

11/11/07:

The bug was due to a mismatch between HashMap::remove and
HashTable::checkTableConsistency. HashMap::remove can delete the value
stored in the HashTable (by derefing it), which is not normally
allowed by HashTable. It's OK in this case because the value is about
to be removed from the table, but HashTable wasn't aware of this.

HashMap::remove now performs the consistency check itself before
derefing the value.

Darin noticed that the same bug would occur in HashSet, so I've fixed
it there as well.

platform/SegmentedString.h:
(WebCore::SegmentedSubstring::SegmentedSubstring): Reversed the sense of m_excludeLineNumbers
and rename it to m_doNotExcludeLineNumbers.
(WebCore::SegmentedSubstring::excludeLineNumbers): Updated.
(WebCore::SegmentedSubstring::doNotExcludeLineNumbers): Added.
(WebCore::SegmentedSubstring::setExcludeLineNumbers): Updated.
(WebCore::SegmentedString::advance): Use doNotExcludeLineNumbers to reverse the sense and fix
the regression, but keep the speediness. I accidentally had removed a ! here.

platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::restorePlatformState): Clear the flag since we no
longer know if the transform is identity or not.
(WebCore::GraphicsContext::strokeArc): Removed an extra set of redundant
CGContextSave/RestoreGState.
(WebCore::GraphicsContext::beginTransparencyLayer): Clear the flag since we no
longer know if the transform is identity or not.
(WebCore::GraphicsContext::endTransparencyLayer): Ditto.
(WebCore::GraphicsContext::scale): Ditto.
(WebCore::GraphicsContext::rotate): Ditto.
(WebCore::GraphicsContext::translate): Ditto.
(WebCore::GraphicsContext::concatCTM): Ditto.
(WebCore::GraphicsContext::roundToDevicePixels): Return quickly if the transform
is known to be identity, and record that fact when we discover it otherwise.

platform/SegmentedString.h: (WebCore::SegmentedString::advance): Streamlined
the most common case, and pushed less common cases into a separate function
that is not inlined. Also got rid of a branch by separating the case with a
line number from the case without one.

platform/SegmentedString.cpp: (WebCore::SegmentedString::advanceSlowCase):
Added. The aforementioned less common cases are here.

dom/Node.cpp: (WebCore::Node::maxCharacterOffset): Renamed from maxOffset()
to highlight that it is a match to offsetInCharacters(), and much different from other
offset-related methods. Added ASSERT_NOT_REACHED(), as callers are supposed to check
offsetInCharacters() before calling this.

dom/Position.cpp:
(WebCore::Position::uncheckedPreviousOffset): Moved from Node::previousOffset().
(WebCore::Position::uncheckedNextOffset): Moved from Node::NextOffset().
(WebCore::Position::previous): Adapted to the above move.
(WebCore::Position::next): Ditto.
(WebCore::Position::upstream): Removed an isBR() check, since a non-BR element cannot have a BR renderer (I think),
and BR elements are covered by editingIgnoresContent().
(WebCore::Position::downstream): Ditto.
(WebCore::caretMaxRenderedOffset): Moved from Node::caretMaxRenderedOffset().
(WebCore::Position::rendersInDifferentPosition): Updated for the above moves.

dom/PositionIterator.h: Added a comment describing this class from the original check-in.

dom/ProcessingInstruction.cpp: (WebCore::ProcessingInstruction::maxCharacterOffset):
ProcessingInstruction was already returning true from offsetInCharacters(), but didn't override maxCharacterOffset().
I think that implementing it has no actual effect, as PIs are not rendered, but it looks cleaner this way.

editing/TextIterator.cpp:
(WebCore::SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator): Changed the condition to obviously
match a maxCharacterOffset() call made after it; hopefully, this doesn't break any border cases.
(WebCore::SimplifiedBackwardsTextIterator::advance): Updated for the above moves.

editing/htmlediting.h:

editing/htmlediting.cpp:
(WebCore::canHaveChildrenForEditing): Removed a bogus comment: I don't thin BRs have a special ability to accept
child nodes, other than via DOM manipulation, which is not specific to BRs.
(WebCore::rangeCompliantEquivalent): Removed a check for BR, which is already covered by editingIgnoresContent().
(WebCore::maxDeepOffset): Ditto.
(WebCore::caretMinOffset): Moved from Node. Changed some runtime checks that seemingly cannot fail into assertions.
(WebCore::caretMaxOffset): Ditto.

page/EventHandler.cpp:
(WebCore::EventHandler::handleMousePressEventSingleClick): Pass 0 to VisiblePosition constructor instead of
caretMinOffset. I didn't want to include htmlediting.h here, and I think that VisiblePosition constructor
will take care of adjusting the offset.

kjs/regexp.cpp:
(KJS::RegExp::RegExp): Changed to use the error message without calling
strdup on it and to pass the new types and options.
(KJS::RegExp::~RegExp): Removed the now-unneeded free of the error message.
(KJS::RegExp::match): Pass the new types and options.

kjs/regexp.h: Update type of m_constructionError.

pcre/AUTHORS: Update to reflect the status of the project -- we don't include
the Google parts, and this isn't the PCRE library, per se.

pcre/pcre.h: Convert to C++, tweak API a bit. Use UChar instead of JSRegExpChar.

pcre/pcre_compile.cpp: Copied from JavaScriptCore/pcre/pcre_compile.c.
Moved a lot of private stuff used only within this file here from pcre_internal.h.
Renumbered the error codes.
(error_text): Use a single string with embedded nulls for the error text (I got
this idea from newer versions of PCRE).
(check_escape): Changed return type to be enum instead of int. Replaced ctype_digit
uses with isASCIIDigit.
(is_counted_repeat): Ditto.
(read_repeat_counts): Ditto.
(first_significant_code): Ditto.
(find_fixedlength): Ditto.
(could_be_empty_branch): Ditto.
(compile_branch): Ditto. Also removed some code that handles changing options.
JavaScript doesn't have any of the features that allow options to change.
(compile_regex): Updated for change to options parameter.
(is_anchored): Ditto.
(find_firstassertedchar): Ditto.
(jsRegExpCompile): Changed to take separate flags instead of an options int.
Also changed to call new/delete instead of pcre_malloc/free.
(jsRegExpFree): Ditto.

pcre/pcre_exec.cpp: Copied from JavaScriptCore/pcre/pcre_exec.c.
Added a case that uses computed goto for the opcode loop, but did not turn it on.
Changed the RMATCH macro to handle returns more efficiently by putting the where
pointer in the new frame instead of the old one, allowing us to branch to the
return with a single statement. Switched to new/delete from pcre_malloc/free.
Changed many RRETURN callers to not set the return value since it's already
set correctly. Replaced the rrc variable with an is_match variable. Values other
than "match" and "no match" are now handled differently. This allows us to remove
the code to check for those cases in various rules.
(match): All the case statements use a macro BEGIN_OPCODE instead. And all the
continue statements, or break statements that break out of the outer case use
a macro NEXT_OPCODE instead. Replaced a few if statements with assertions.
(jsRegExpExecute): Use new/delete instead of pcre_malloc/free. Removed unused
start_match field from the match block.

pcre/pcre_internal.h: Moved the last few configuration macros from pcre-config.h
in here. Removed various unused types. Converted from JSRegExpChar to UChar.
Eliminated pcre_malloc/free. Replaced the opcode enum with a macro that can be
used in multiple places. Unfortunately we lose the comments for each opcode; we
should find a place to put those back. Removed ctype_digit.

pcre/pcre_maketables.cpp: Copied from JavaScriptCore/pcre/pcre_maketables.c.
(pcre_maketables): Got rid of the conditional code that allows this to be compiled
in -- it's only used for dftables now (and soon may be obsolete entirely).
Changed code for cbit_digit to not use isdigit, and took the "_" case out of the
loop. Removed ctype_digit.

wtf/ASCIICType.h: (WTF::isASCIIDigit): Removed a branch by changing from && to
& for this operation. Also added an overload that takes an int because that's
useful for PCRE. Later we could optimize for int and overload other functions in
this file; stuck to this simple one for now.

kjs/property_map.cpp:
(KJS::PropertyMap::put): Added a missing "- 1"; code to find an empty slot was not working.
(KJS::PropertyMap::checkConsistency): Added a missing range check that would have caught this
problem before.

roll out a last-minute change to my evaluateToBoolean patch that was incorrect.

kjs/nodes.h: (KJS::ExprStatementNode::ExprStatementNode): Take out call to
optimizeForUnnecessaryResult, since the result is used in some cases.

dom/Range.cpp:
(WebCore::Range::processContents): Implemented ProcessingInstruction cases.
(WebCore::Range::checkNodeWOffset): Removed a FIXME - yes, I think that we are supposed
to use ProcessingInstruction.data.

kjs/nodes.h: Changed to use Noncopyable. Moved optimizeForUnnecessaryResult
down from Node to ExpressionNode. Changed some classes to not inherit from
ExpressionNode where not necessary, and removed unnneeded evaluate functions
as well as evaluate functions that need not be virtual. Call the
optimizeForUnnecessaryResult function on the start of a for loop too.

<rdar://problem/5435940>
The COM bindings for the DOM should be autogenerated like the other DOM bindings

Initial commit of the autogeneration of the COM DOM Bindings. No behavior change
is being introduced in this patch and to insure that no conflicts arise, a temporary
prefix of "GEN_" has been used for all the new classes.

The build architecture for these bindings differs slightly from the other autogenerated
bindings. Instead of building in WebCore and migrating the resuting code to WebKit (as
is done for the Objective-C bindigs currently), the IDLs and generation scripts are
migrated to WebKit and built there. This is done with a series of scripts and Makefiles.

dom/EventListener.h: Make the isWindowEvent parameter default to false
to allow autogeneration based on the IDL.

WebKit/win:

Reviewed by Adam Roben.

<rdar://problem/5435940>
The COM bindings for the DOM should be autogenerated like the other DOM bindings

Initial commit of the autogeneration of the COM DOM Bindings. No behavior change
is being introduced in this patch and to insure that no conflicts arise, a temporary
prefix of "GEN_" has been used for all the new classes.

The build architecture for these bindings differs slightly from the other autogenerated
bindings. Instead of building in WebCore and migrating the resuting code to WebKit (as
is done for the Objective-C bindigs currently), the IDLs and generation scripts are
migrated to WebKit and built there. This is done with a series of scripts and Makefiles.

This patch is for the WebKit side of <rdar://problem/5591115>.
We need a way to tell context menu navigations, such as "Open in New Window"
to override any sort of browser preference for tab based navigation.

WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::createWindow):
Pass up the new preferredType parameter as a string.

WebCore:

Reviewed by Timothy Hatcher.

This patch is for the WebKit side of <rdar://problem/5591115>.
We need a way to tell context menu navigations, such as "Open in New Window"
to override any sort of browser preference for tab based navigation.

bridge/WindowFeatures.h:
(WebCore::WindowFeatures::WindowFeatures):
Added a new struct member var, preferredType
and an accompanying enum type PreferredType
to send a window type recommendation up to the Chrome.

page/ContextMenuController.cpp:
(WebCore::openNewWindow):
Set the window features to recommend a new Window for
"Open in New Window" context menu action.

<rdar://problem/5103720> REGRESSION: [WebView stringByEvaluatingJavaScriptFromString:] fails if "return" is used

Extend the linked on or after check to every application when a script passed to
stringByEvaluatingJavaScriptFromString: has a return statement. Before the check
was limited to VitalSource Bookshelf, but other developers are running into this.

WebView/WebDocumentLoaderMac.mm:
(needsDataLoadWorkaround): Use WEBKIT_FIRST_VERSION_WITHOUT_ADOBE_INSTALLER_QUIRK sicne the
WebKitLinkedOnOrAfter check here was about the Adobe installer, not VitalSource.

WebView/WebView.mm:
(-[WebView stringByEvaluatingJavaScriptFromString:]): Remove the bundle ID check and use
WEBKIT_FIRST_VERSION_WITHOUT_JAVASCRIPT_RETURN_QUIRK for the WebKitLinkedOnOrAfter call.

We now match the behavior of Firefox and IE, which is to always just
send a click event to the focused button when the Enter key is pressed
(previously we were submitting forms directly in some cases).

Reviewed by Adele.

Test: fast/forms/enter-clicks-buttons.html

html/HTMLButtonElement.cpp:
(WebCore::HTMLButtonElement::defaultEventHandler): Don't do anything
fancy when Enter is pressed on a <button type=button> -- just send a
click event like we do for other button types.

html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::defaultEventHandler): Treat type=button
the same way we treat type=submit and type=reset: just send a click
event when Enter is pressed.

Transform matrices accept the first four parameters as CSS lengths.
CSS lengths get mapped into WebCore::Lengths as percents by
WebCore::convertToLength(). Percent lengths cannot call value(). It
does not yield a correct result and it asserts on Debug builds.

rendering/RenderStyle.h:
(WebCore::MatrixTransformOperation::apply): Instead of calling
value() on the lengths, call calcValue. This fixes the assert and
the bad rendering.

Store all items and submenus value based in ContextMenu and ContextMenuItem.
That fixes the crashes when the context menu was populated with sub-menus because
of the use of temporary ContextMenu objects like this:

This patch does two main things.
1) It adds pragma warning guards around WebCore includes in WebKit files
that were previously overlooked.
2) It implements almost the entireity of WebScriptDebugger. Only one
function remains and that implementation is dependent on finishing the
implementation of WebScriptScope.

kjs/property_map.cpp:
(KJS::PropertyMap::getEnumerablePropertyNames):
Use insertion sort instead of qsort for small sets of property names.
We can probably do some even-better speedups of for/in, but this nets
0.6% overall and 6.7% on fasta.

This fixes one source of the slowness -- the conversion to an unused
Identifier as we call the get function from the slot -- but doesn't
fix others, such as the fact that we have to allocate a new UString::Rep
for every single character.

Speeds up string-base64 30%, and at least 0.5% overall.
But does slow down access-fannkuch quite a bit. Might be worth
revisiting in the future to see what we can do about that (although
I did look at a profile for a while).

kjs/property_slot.h: Add a new marker for "numeric" property slots;
slots where we don't need to pass the identifier to the get function.
(KJS::PropertySlot::getValue): Added code to call the numeric get function.
(KJS::PropertySlot::setCustomNumeric): Added.

kjs/string_object.cpp:
(KJS::StringInstance::indexGetter): Changed to use substr() instead
of constructing a wholly new UString each time.
(KJS::stringInstanceNumericPropertyGetter): Added. Like indexGetter, but
takes advantage of setCustomNumeric to avoid creating an Identifier.
(KJS::StringInstance::getOwnPropertySlot): Changed to use setCustomNumeric.

kjs/JSImmediate.h: Eliminate the now-unneeded FPBitValues struct template.
(KJS::JSImmediate::from): Overload for most numeric types; many types can
do fewer branches and checks.
(KJS::JSImmediate::getUInt32): Removed unneeded check for undefined.
(KJS::JSImmediate::getTruncatedInt32): Ditto.
(KJS::JSImmediate::getTruncatedUInt32): Ditto. There's no difference any more
between getUInt32 and getTruncatedUInt32, so that's worth a rename and merge later.

dom/StyledElement.cpp:
(WebCore::StyledElement::addCSSLength): Changed the garbage-stripping
logic to stop after the first "%" or "*" in the string. This allows for
"100%25" to be mapped to "100%" like it is in Firefox and WinIE.

Add a fast path for bitwise-and of two immediate numbers for a 0.7% improvement in SunSpider (4% bitop improvement).

Reviewed by Sam.

This only improves bitwise-and performance, as the additional logic required
for similar code paths on or, xor, and shifting requires additional operations
and branches that negate (and in certain cases, regress) any advantage we might
otherwise receive.

This improves performance on all bitop tests, the cryptography tests, as well as
the string-base64 and string-unpack-code tests. No significant degradation on
any other tests.

With this change Drosera can now get the source of a website and the
listings of the sources it gets. This also lays the foundation for
letting Drosera show the scope chain of the JavaScript stack.

Interfaces/IWebFrame.idl: Changed the signature of the local function,
globalContext(), because COM was unable to marshal this object with the
other signature.

Interfaces/IWebScriptDebugServer.idl: Of course adding and removing
a listener cannot be done in a const function.

WebChromeClient.h: Added accessor to the WebView for the new added
kit() function in WebFrame.
(WebChromeClient::webView):

WebFrame.cpp: Added a script debugger object and the necessary
functions to attach and communicate with it. Also needed to change the
local function, globalContext(), because of a COM issue.
(kit):
(WebFrame::WebFrame):
(WebFrame::globalContext):
(WebFrame::loadData):
(WebFrame::attachScriptDebugger):
(WebFrame::detachScriptDebugger):
(WebFrame::dispatchDidLoadMainResource):
(WebFrame::windowObjectCleared):

WebFrame.h: Ditto.

WebHTMLRepresentation.cpp: Implemented documentSource so Drosera has
some source code to display.
(WebHTMLRepresentation::WebHTMLRepresentation):
(WebHTMLRepresentation::documentSource):

WebKit.vcproj/WebKit.vcproj: Added the new WebScriptDebugger class.

WebScriptCallFrame.cpp: Implemented much of this class' functionality.
(EnumScopes::EnumScopes): Made an EnumScopes class to create an
IEnumVARIANT to wrap a ScopeChain for Drosera.
(EnumScopes::QueryInterface):
(EnumScopes::AddRef):
(EnumScopes::Release):
(EnumScopes::Next):
(EnumScopes::Skip):
(EnumScopes::Reset):
(EnumScopes::Clone):
(WebScriptCallFrame::caller):
(WebScriptCallFrame::scopeChain):
(WebScriptCallFrame::functionName):
(WebScriptCallFrame::stringByEvaluatingJavaScriptFromString):

WebScriptCallFrame.h: Added member data needed for the above functions

Convert JavaScript internal function objects to use one class per
function. This avoids a switch statement inside what used to be
the shared function classes and will allow Shark to better analyze
the code.

To make this switch, the value property of the HashEntry was changed
to a union of an intptr_t (which is used to continue handle valueGetters)
and function pointer which points to a static constructor for the
individual new function objects.

Convert JavaScript internal function objects to use one class per
function. This avoids a switch statement inside what used to be
the shared function classes and will allow Shark to better analyze
the code.

To make this switch, the value property of the HashEntry was changed
to a union of an intptr_t (which is used to continue handle valueGetters)
and function pointer which points to a static constructor for the
individual new function objects.

SunSpider claims this is a 0.5% speedup.

On the WebCore side, I updated CodeGeneratorJS.pm to generate the
new classes and hand updated the remain non-generated (groan) classes.

Replace the use of floats for immediate values with the use of integers for a 4.5% improvement in SunSpider.

Reviewed by Darin.

Unfortunately this change results in NaN, +Inf, -Inf, and -0 being heap allocated now, but
we should now have faster array access, faster immediate to double conversion, and the
potential to further improve bitwise operators in future.

This also removes the need for unions to avoid strict aliasing problems when extracting
a value from immediates.

test changes for <rdar://problem/5552943> accesskey does not focus <button> elements

fast/forms/access-key.html: Check for both focus and click events on all elements, but
resisted the urge to switch to the American spelling for "focused".

fast/forms/access-key-expected.txt: Updated to reflect the bug fix ("1 button focussed"),
the fact that <input type=button>, <input type=checkbox>, <input type=submit>, and
<input type=reset> are all both focused and clicked ("2 input type button clicked",
"3 input type checkbox clicked", "5 input type submit focussed", and
"6 input type reset focussed"). Unfortunately this now also demonstrates that we don't
send a click to <input type=text> and Gecko does. And there are still quite a few types
that are not covered.

George (pmax) reviewed the networking patches and found the following bug (thanks for reviewing)

if (jobMode == AsynchronousJob) {

+ if (jobMode == SynchronousJob) {

add job to synchronous list/hash

Just applying the above change will lead to crashes because we can finish
jobs before we started them.

Avoid these issues by saving all work (starting a job, sending data and
finishing it) inside one list. JobWork will contain any
of the above three work types and doWork will just work on this list
(m_pendingWork). As foreach takes a copy of the list calling started, data
and finished will not add new work and we gurantee that if we have JobStarted
it will be in the list before JobData and JobFinished.