mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
2ddfe368e1
- bug 1215748 - use llvm-dsymutil for mac builds. r=mshal (a217006d89) - warnings (31ea43d0d8) - Bug 1175154 - Unit tests for IAC on 3.0. r=ferjm (12c424bab3) - Bug 1219543 - Part 1: isRunningOnCompositor flag is now a member of AnimationProperty. r=bbirtles (85bc668501) - Bug 1219543 - Part 2: Avoid the period that mIsRunningOnCompositor is false between restyling and building display list. r=bbirtles (597e46d479) - Bug 1219543 - Part 3: MutationObserver should disconnect when the test is finished. r=bbirtles (70c26a266e) - Bug 1214148 - patch 1 - propagation from the nested iframe back to the toplevel iframe, r=alwu (b42002f43a) - Bug 1214148 - patch 2 - from toplevel iframe to the nested iframe, r=alwu (7b07fe5399) - Bug 1214148 - patch 3 - correct window for nested iframes, r=alwu (27ee08caf1) - Bug 1166910 - put referrer attribute behind pref in webidl, r=bz (93e421fa1b) - Bug 1187357 - rename referrer attribute to referrerpolicy. r=hsivonen (70c67f5def) - Bug 1187357 - Generated code for renaming referrer to referrerpolicy in html parser. r=hsivonen (738de3f278) - Bug 1221341. Snap box shadow clip rect to device pixels. r=mstange (b63b783714) - Bug 1228634 - Implement Element.getAttributeNames, r=peterv (4594d9c14c) - Bug 1216193. Implement webkitMatchesSelector. r=khuey (39742b7e0b) - Bug 1134648, handle dynamic changes to rel=dns-prefetch, r=bz (e27638080e) - Bug 1229962 - use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in parser/html/; r=hsivonen (75de6314f1) - Bug 1226437 - Speculative CSP should set speculative referrer policy instead of actual referrer policy. r=sicking (f7dfd3fd18) - Bug 1227554 - Default to NullPrincipal if doc is not available within expatdriver. r=bz (336a562965) - Bug 1215781 - Use MOZ_UTF16 to generate sTagUnicodeTable. r=mrbkap (eca371a36b) - Bug 1082598 - Part 5: Fix NPAPI for Skia update. r=jrmuizel (25c4d080ab) - Bug 1183828 - Remove 'nsWindow::GetNativeData not implemented for this type' warning. r=roc (0a60404b57) - Bug 1224445 - Add NS_NATIVE_OPENGL_CONTEXT handling to nsWindow::GetNativeData() r=mwu (ee35844be4) - Bug 1179632 part.1 native IME context should not be stored in InputContext but should be able to retrieve with nsIWidget::GetNativeData() r=smaug (5f1804bb72) - Bug 1179632 part.2 WidgetCompositionEvent should store NativeIMEContext which caused the event and PuppetWidget should store it for GetNativeIMEContext() r=smaug, sr=smaug (e00ca78e3f) - Bug 1179632 part.3 TabParent::RecvEndIMEComposition() shouldn't return true with aNoCompositionEvent when there is no widget r=smaug (ee065ed491) - Bug 1179632 part.4 Clean up the code to request IME to commit composition across process boundary r=smaug (9567c4dc57) - Bug 1179632 part.5 WidgetCompositionEvent::mNativeIMEContext should be used at looking for a TextComposition instance for a WidgetCompositionEvent r=smaug (f4e27ec28c) - Bug 1179632 part.6 KeyboardEvent.isComposing shouldn't expose IME state on different document r=smaug (ca8b8a6a02) - Bug 1227544 - Scaling on 720p devices is broken. r=timdream (cb89af839f)
414 lines
10 KiB
C++
414 lines
10 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
#ifndef nsHtml5Highlighter_h
|
|
#define nsHtml5Highlighter_h
|
|
|
|
#include "nsCOMPtr.h"
|
|
#include "nsHtml5TreeOperation.h"
|
|
#include "nsHtml5UTF16Buffer.h"
|
|
#include "nsHtml5TreeOperation.h"
|
|
#include "nsAHtml5TreeOpSink.h"
|
|
|
|
#define NS_HTML5_HIGHLIGHTER_HANDLE_ARRAY_LENGTH 512
|
|
|
|
/**
|
|
* A state machine for generating HTML for display in View Source based on
|
|
* the transitions the tokenizer makes on the source being viewed.
|
|
*/
|
|
class nsHtml5Highlighter
|
|
{
|
|
public:
|
|
/**
|
|
* The constructor.
|
|
*
|
|
* @param aOpSink the sink for the tree ops generated by this highlighter
|
|
*/
|
|
explicit nsHtml5Highlighter(nsAHtml5TreeOpSink* aOpSink);
|
|
|
|
/**
|
|
* The destructor.
|
|
*/
|
|
~nsHtml5Highlighter();
|
|
|
|
/**
|
|
* Starts the generated document.
|
|
*/
|
|
void Start(const nsAutoString& aTitle);
|
|
|
|
/**
|
|
* Report a tokenizer state transition.
|
|
*
|
|
* @param aState the state being transitioned to
|
|
* @param aReconsume whether this is a reconsuming transition
|
|
* @param aPos the tokenizer's current position into the buffer
|
|
*/
|
|
int32_t Transition(int32_t aState, bool aReconsume, int32_t aPos);
|
|
|
|
/**
|
|
* Report end of file.
|
|
*/
|
|
void End();
|
|
|
|
/**
|
|
* Set the current buffer being tokenized
|
|
*/
|
|
void SetBuffer(nsHtml5UTF16Buffer* aBuffer);
|
|
|
|
/**
|
|
* Let go of the buffer being tokenized but first, flush text from it.
|
|
*
|
|
* @param aPos the first UTF-16 code unit not to flush
|
|
*/
|
|
void DropBuffer(int32_t aPos);
|
|
|
|
/**
|
|
* Flush the tree ops into the sink.
|
|
*
|
|
* @return true if there were ops to flush
|
|
*/
|
|
bool FlushOps();
|
|
|
|
/**
|
|
* Linkify the current attribute value if the attribute name is one of
|
|
* known URL attributes. (When executing tree ops, javascript: URLs will
|
|
* not be linkified, though.)
|
|
*
|
|
* @param aName the name of the attribute
|
|
* @param aValue the value of the attribute
|
|
*/
|
|
void MaybeLinkifyAttributeValue(nsHtml5AttributeName* aName,
|
|
nsString* aValue);
|
|
|
|
/**
|
|
* Inform the highlighter that the tokenizer successfully completed a
|
|
* named character reference.
|
|
*/
|
|
void CompletedNamedCharacterReference();
|
|
|
|
/**
|
|
* Adds an error annotation to the node that's currently on top of
|
|
* mStack.
|
|
*
|
|
* @param aMsgId the id of the message in the property file
|
|
*/
|
|
void AddErrorToCurrentNode(const char* aMsgId);
|
|
|
|
/**
|
|
* Adds an error annotation to the node that corresponds to the most
|
|
* recently opened markup declaration/tag span, character reference or
|
|
* run of text.
|
|
*
|
|
* @param aMsgId the id of the message in the property file
|
|
*/
|
|
void AddErrorToCurrentRun(const char* aMsgId);
|
|
|
|
/**
|
|
* Adds an error annotation to the node that corresponds to the most
|
|
* recently opened markup declaration/tag span, character reference or
|
|
* run of text with one atom to use when formatting the message.
|
|
*
|
|
* @param aMsgId the id of the message in the property file
|
|
* @param aName the atom
|
|
*/
|
|
void AddErrorToCurrentRun(const char* aMsgId, nsIAtom* aName);
|
|
|
|
/**
|
|
* Adds an error annotation to the node that corresponds to the most
|
|
* recently opened markup declaration/tag span, character reference or
|
|
* run of text with two atoms to use when formatting the message.
|
|
*
|
|
* @param aMsgId the id of the message in the property file
|
|
* @param aName the first atom
|
|
* @param aOther the second atom
|
|
*/
|
|
void AddErrorToCurrentRun(const char* aMsgId,
|
|
nsIAtom* aName,
|
|
nsIAtom* aOther);
|
|
|
|
/**
|
|
* Adds an error annotation to the node that corresponds to the most
|
|
* recent potentially character reference-starting ampersand.
|
|
*
|
|
* @param aMsgId the id of the message in the property file
|
|
*/
|
|
void AddErrorToCurrentAmpersand(const char* aMsgId);
|
|
|
|
/**
|
|
* Adds an error annotation to the node that corresponds to the most
|
|
* recent potentially self-closing slash.
|
|
*
|
|
* @param aMsgId the id of the message in the property file
|
|
*/
|
|
void AddErrorToCurrentSlash(const char* aMsgId);
|
|
|
|
/**
|
|
* Enqueues a tree op for adding base to the urls with the view-source:
|
|
*
|
|
* @param aValue the base URL to add
|
|
*/
|
|
void AddBase(const nsString& aValue);
|
|
|
|
private:
|
|
|
|
/**
|
|
* Starts a span with no class.
|
|
*/
|
|
void StartSpan();
|
|
|
|
/**
|
|
* Starts a <span> and sets the class attribute on it.
|
|
*
|
|
* @param aClass the class to set (MUST be a static string that does not
|
|
* need to be released!)
|
|
*/
|
|
void StartSpan(const char16_t* aClass);
|
|
|
|
/**
|
|
* End the current <span> or <a> in the highlighter output.
|
|
*/
|
|
void EndSpanOrA();
|
|
|
|
/**
|
|
* Starts a wrapper around a run of characters.
|
|
*/
|
|
void StartCharacters();
|
|
|
|
/**
|
|
* Ends a wrapper around a run of characters.
|
|
*/
|
|
void EndCharactersAndStartMarkupRun();
|
|
|
|
/**
|
|
* Starts an <a>.
|
|
*/
|
|
void StartA();
|
|
|
|
/**
|
|
* Flushes characters up to but not including the current one.
|
|
*/
|
|
void FlushChars();
|
|
|
|
/**
|
|
* Flushes characters up to and including the current one.
|
|
*/
|
|
void FlushCurrent();
|
|
|
|
/**
|
|
* Finishes highlighting a tag in the input data by closing the open
|
|
* <span> and <a> elements in the highlighter output and then starts
|
|
* another <span> for potentially highlighting characters potentially
|
|
* appearing next.
|
|
*/
|
|
void FinishTag();
|
|
|
|
/**
|
|
* Adds a class attribute to the current node.
|
|
*
|
|
* @param aClass the class to set (MUST be a static string that does not
|
|
* need to be released!)
|
|
*/
|
|
void AddClass(const char16_t* aClass);
|
|
|
|
/**
|
|
* Allocates a handle for an element.
|
|
*
|
|
* See the documentation for nsHtml5TreeBuilder::AllocateContentHandle()
|
|
* in nsHtml5TreeBuilderHSupplement.h.
|
|
*
|
|
* @return the handle
|
|
*/
|
|
nsIContent** AllocateContentHandle();
|
|
|
|
/**
|
|
* Enqueues an element creation tree operation.
|
|
*
|
|
* @param aName the name of the element
|
|
* @param aAttributes the attribute holder (ownership will be taken) or
|
|
* nullptr for no attributes
|
|
* @param aIntendedParent the intended parent node for the created element
|
|
* @return the handle for the element that will be created
|
|
*/
|
|
nsIContent** CreateElement(nsIAtom* aName,
|
|
nsHtml5HtmlAttributes* aAttributes,
|
|
nsIContent** aIntendedParent);
|
|
|
|
/**
|
|
* Gets the handle for the current node. May be called only after the
|
|
* root element has been set.
|
|
*
|
|
* @return the handle for the current node
|
|
*/
|
|
nsIContent** CurrentNode();
|
|
|
|
/**
|
|
* Create an element and push it (its handle) on the stack.
|
|
*
|
|
* @param aName the name of the element
|
|
* @param aAttributes the attribute holder (ownership will be taken) or
|
|
* nullptr for no attributes
|
|
*/
|
|
void Push(nsIAtom* aName, nsHtml5HtmlAttributes* aAttributes);
|
|
|
|
/**
|
|
* Pops the current node off the stack.
|
|
*/
|
|
void Pop();
|
|
|
|
/**
|
|
* Appends text content to the current node.
|
|
*
|
|
* @param aBuffer the buffer to copy from
|
|
* @param aStart the index of the first code unit to copy
|
|
* @param aLength the number of code units to copy
|
|
*/
|
|
void AppendCharacters(const char16_t* aBuffer,
|
|
int32_t aStart,
|
|
int32_t aLength);
|
|
|
|
/**
|
|
* Enqueues a tree op for adding an href attribute with the view-source:
|
|
* URL scheme to the current node.
|
|
*
|
|
* @param aValue the (potentially relative) URL to link to
|
|
*/
|
|
void AddViewSourceHref(const nsString& aValue);
|
|
|
|
/**
|
|
* The state we are transitioning away from.
|
|
*/
|
|
int32_t mState;
|
|
|
|
/**
|
|
* The index of the first UTF-16 code unit in mBuffer that hasn't been
|
|
* flushed yet.
|
|
*/
|
|
int32_t mCStart;
|
|
|
|
/**
|
|
* The position of the code unit in mBuffer that caused the current
|
|
* transition.
|
|
*/
|
|
int32_t mPos;
|
|
|
|
/**
|
|
* The current line number.
|
|
*/
|
|
int32_t mLineNumber;
|
|
|
|
/**
|
|
* The number of inline elements open inside the <pre> excluding the
|
|
* span potentially wrapping a run of characters.
|
|
*/
|
|
int32_t mInlinesOpen;
|
|
|
|
/**
|
|
* Whether there's a span wrapping a run of characters (excluding CDATA
|
|
* section) open.
|
|
*/
|
|
bool mInCharacters;
|
|
|
|
/**
|
|
* The current buffer being tokenized.
|
|
*/
|
|
nsHtml5UTF16Buffer* mBuffer;
|
|
|
|
/**
|
|
* The outgoing tree op queue.
|
|
*/
|
|
nsTArray<nsHtml5TreeOperation> mOpQueue;
|
|
|
|
/**
|
|
* The tree op stage for the tree op executor.
|
|
*/
|
|
nsAHtml5TreeOpSink* mOpSink;
|
|
|
|
/**
|
|
* The most recently opened markup declaration/tag or run of characters.
|
|
*/
|
|
nsIContent** mCurrentRun;
|
|
|
|
/**
|
|
* The most recent ampersand in a place where character references were
|
|
* allowed.
|
|
*/
|
|
nsIContent** mAmpersand;
|
|
|
|
/**
|
|
* The most recent slash that might become a self-closing slash.
|
|
*/
|
|
nsIContent** mSlash;
|
|
|
|
/**
|
|
* Memory for element handles.
|
|
*/
|
|
mozilla::UniquePtr<nsIContent*[]> mHandles;
|
|
|
|
/**
|
|
* Number of handles used in mHandles
|
|
*/
|
|
int32_t mHandlesUsed;
|
|
|
|
/**
|
|
* A holder for old contents of mHandles
|
|
*/
|
|
nsTArray<mozilla::UniquePtr<nsIContent*[]>> mOldHandles;
|
|
|
|
/**
|
|
* The element stack.
|
|
*/
|
|
nsTArray<nsIContent**> mStack;
|
|
|
|
/**
|
|
* The string "comment"
|
|
*/
|
|
static char16_t sComment[];
|
|
|
|
/**
|
|
* The string "cdata"
|
|
*/
|
|
static char16_t sCdata[];
|
|
|
|
/**
|
|
* The string "start-tag"
|
|
*/
|
|
static char16_t sStartTag[];
|
|
|
|
/**
|
|
* The string "attribute-name"
|
|
*/
|
|
static char16_t sAttributeName[];
|
|
|
|
/**
|
|
* The string "attribute-value"
|
|
*/
|
|
static char16_t sAttributeValue[];
|
|
|
|
/**
|
|
* The string "end-tag"
|
|
*/
|
|
static char16_t sEndTag[];
|
|
|
|
/**
|
|
* The string "doctype"
|
|
*/
|
|
static char16_t sDoctype[];
|
|
|
|
/**
|
|
* The string "entity"
|
|
*/
|
|
static char16_t sEntity[];
|
|
|
|
/**
|
|
* The string "pi"
|
|
*/
|
|
static char16_t sPi[];
|
|
|
|
/**
|
|
* Whether base is already visited once.
|
|
*/
|
|
bool mSeenBase;
|
|
};
|
|
|
|
#endif // nsHtml5Highlighter_h
|